From c9f5a48886b8f24647ff63401182d362e46335e9 Mon Sep 17 00:00:00 2001 From: Chris Laurel Date: Sun, 22 Sep 2002 09:17:10 +0000 Subject: [PATCH] Enhanced print command --- src/celengine/cmdparser.cpp | 65 ++++++++++++++++++++++++++++++++++++- src/celengine/command.cpp | 10 ++++-- src/celengine/command.h | 8 ++++- src/celengine/execenv.h | 2 +- 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/src/celengine/cmdparser.cpp b/src/celengine/cmdparser.cpp index 5136d44d2..596b9a671 100644 --- a/src/celengine/cmdparser.cpp +++ b/src/celengine/cmdparser.cpp @@ -272,8 +272,71 @@ Command* CommandParser::parseCommand() else if (commandName == "print") { string text; + string origin; + int horig = -1; + int vorig = -1; + double hoff = 0; + double voff = 0; + double duration = 1.0e9; paramList->getString("text", text); - cmd = new CommandPrint(text); + paramList->getString("origin", origin); + paramList->getNumber("duration", duration); + paramList->getNumber("row", voff); + paramList->getNumber("column", hoff); + if (compareIgnoringCase(origin, "left") == 0) + { + horig = -1; + vorig = 0; + } + else if (compareIgnoringCase(origin, "right") == 0) + { + horig = 1; + vorig = 0; + } + else if (compareIgnoringCase(origin, "center") == 0) + { + horig = 0; + vorig = 0; + } + else if (compareIgnoringCase(origin, "left") == 0) + { + horig = -1; + vorig = 0; + } + else if (compareIgnoringCase(origin, "top") == 0) + { + horig = 0; + vorig = 1; + } + else if (compareIgnoringCase(origin, "bottom") == 0) + { + horig = 0; + vorig = -1; + } + else if (compareIgnoringCase(origin, "topright") == 0) + { + horig = 1; + vorig = 1; + } + else if (compareIgnoringCase(origin, "topleft") == 0) + { + horig = -1; + vorig = 1; + } + else if (compareIgnoringCase(origin, "bottomleft") == 0) + { + horig = -1; + vorig = -1; + } + else if (compareIgnoringCase(origin, "bottomright") == 0) + { + horig = 1; + vorig = -1; + } + + cmd = new CommandPrint(text, + horig, vorig, (int) hoff, (int) -voff, + duration); } else if (commandName == "cls") { diff --git a/src/celengine/command.cpp b/src/celengine/command.cpp index f7f3655fc..611c15bfe 100644 --- a/src/celengine/command.cpp +++ b/src/celengine/command.cpp @@ -236,13 +236,19 @@ void CommandCancel::process(ExecutionEnvironment& env) //////////////// // Print command: print text to the console -CommandPrint::CommandPrint(string _text) : text(_text) +CommandPrint::CommandPrint(string _text, + int horig, int vorig, int hoff, int voff, + double _duration + ) : text(_text), + hOrigin(horig), vOrigin(vorig), + hOffset(hoff), vOffset(voff), + duration(_duration) { } void CommandPrint::process(ExecutionEnvironment& env) { - env.showText(text); + env.showText(text, hOrigin, vOrigin, hOffset, vOffset, duration); } diff --git a/src/celengine/command.h b/src/celengine/command.h index 30697e75b..0a6488df1 100644 --- a/src/celengine/command.h +++ b/src/celengine/command.h @@ -208,11 +208,17 @@ class CommandCancel : public InstantaneousCommand class CommandPrint : public InstantaneousCommand { public: - CommandPrint(std::string); + CommandPrint(std::string, int horig, int vorig, int hoff, int voff, + double duration); void process(ExecutionEnvironment&); private: std::string text; + int hOrigin; + int vOrigin; + int hOffset; + int vOffset; + double duration; }; diff --git a/src/celengine/execenv.h b/src/celengine/execenv.h index 37c9642f8..08cb1c982 100644 --- a/src/celengine/execenv.h +++ b/src/celengine/execenv.h @@ -22,7 +22,7 @@ class ExecutionEnvironment virtual inline Simulation* getSimulation() const = 0; virtual inline Renderer* getRenderer() const = 0; - virtual void showText(std::string) = 0; + virtual void showText(std::string, int, int, int, int, double) = 0; }; #endif // _EXECENV_H_