Enhanced print command

ver1_5_1
Chris Laurel 2002-09-22 09:17:10 +00:00
parent 8b7d496eab
commit c9f5a48886
4 changed files with 80 additions and 5 deletions

View File

@ -272,8 +272,71 @@ Command* CommandParser::parseCommand()
else if (commandName == "print") else if (commandName == "print")
{ {
string text; string text;
string origin;
int horig = -1;
int vorig = -1;
double hoff = 0;
double voff = 0;
double duration = 1.0e9;
paramList->getString("text", text); 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") else if (commandName == "cls")
{ {

View File

@ -236,13 +236,19 @@ void CommandCancel::process(ExecutionEnvironment& env)
//////////////// ////////////////
// Print command: print text to the console // 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) void CommandPrint::process(ExecutionEnvironment& env)
{ {
env.showText(text); env.showText(text, hOrigin, vOrigin, hOffset, vOffset, duration);
} }

View File

@ -208,11 +208,17 @@ class CommandCancel : public InstantaneousCommand
class CommandPrint : public InstantaneousCommand class CommandPrint : public InstantaneousCommand
{ {
public: public:
CommandPrint(std::string); CommandPrint(std::string, int horig, int vorig, int hoff, int voff,
double duration);
void process(ExecutionEnvironment&); void process(ExecutionEnvironment&);
private: private:
std::string text; std::string text;
int hOrigin;
int vOrigin;
int hOffset;
int vOffset;
double duration;
}; };

View File

@ -22,7 +22,7 @@ class ExecutionEnvironment
virtual inline Simulation* getSimulation() const = 0; virtual inline Simulation* getSimulation() const = 0;
virtual inline Renderer* getRenderer() 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_ #endif // _EXECENV_H_