summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cat/LuaScriptInterface.cpp7
-rw-r--r--src/console/ConsoleView.cpp4
-rw-r--r--src/interface/Label.cpp30
-rw-r--r--src/interface/Label.h2
-rw-r--r--src/interface/Textbox.cpp5
-rw-r--r--src/interface/Textbox.h3
6 files changed, 38 insertions, 13 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index 5aa6a73..40bcc08 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -310,7 +310,12 @@ int LuaScriptInterface::Command(std::string command)
std::string LuaScriptInterface::FormatCommand(std::string command)
{
- return command;
+ if(command[0] == '!')
+ {
+ return "!"+legacy->FormatCommand(command.substr(1));
+ }
+ else
+ return command;
}
LuaScriptInterface::~LuaScriptInterface() {
diff --git a/src/console/ConsoleView.cpp b/src/console/ConsoleView.cpp
index 32b366c..67c83de 100644
--- a/src/console/ConsoleView.cpp
+++ b/src/console/ConsoleView.cpp
@@ -17,7 +17,7 @@ ConsoleView::ConsoleView():
ConsoleView * v;
public:
CommandHighlighter(ConsoleView * v_) { v = v_; }
- void TextChangedCallback(ui::Textbox * sender)
+ virtual void TextChangedCallback(ui::Textbox * sender)
{
sender->SetDisplayText(v->c->FormatCommand(sender->GetText()));
}
@@ -43,6 +43,7 @@ void ConsoleView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, b
case KEY_ENTER:
c->EvaluateCommand(commandField->GetText());
commandField->SetText("");
+ commandField->SetDisplayText("");
break;
case KEY_DOWN:
c->NextCommand();
@@ -88,6 +89,7 @@ void ConsoleView::NotifyPreviousCommandsChanged(ConsoleModel * sender)
void ConsoleView::NotifyCurrentCommandChanged(ConsoleModel * sender)
{
commandField->SetText(sender->GetCurrentCommand().Command);
+ commandField->SetDisplayText(c->FormatCommand(commandField->GetText()));
}
diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp
index 8a8055e..ee52fd8 100644
--- a/src/interface/Label.cpp
+++ b/src/interface/Label.cpp
@@ -266,6 +266,11 @@ void Label::updateSelection()
}
}
+void Label::SetDisplayText(std::string newText)
+{
+ displayText = newText;
+}
+
void Label::Draw(const Point& screenPos)
{
if(!drawn)
@@ -282,6 +287,23 @@ void Label::Draw(const Point& screenPos)
}
Graphics * g = Engine::Ref().g;
+ std::string cDisplayText = displayText;
+
+ if(!cDisplayText.length())
+ {
+ if(selectionXL != -1 && selectionXH != -1)
+ {
+ cDisplayText = textFragments;
+ }
+ else
+ {
+ if(multiline)
+ cDisplayText = textLines;
+ else
+ cDisplayText = text;
+ }
+ }
+
if(multiline)
{
if(selectionXL != -1 && selectionXH != -1)
@@ -298,21 +320,21 @@ void Label::Draw(const Point& screenPos)
} else {
g->fillrect(screenPos.X+textPosition.X+selectionXL, screenPos.Y+selectionYL+textPosition.Y-1, selectionXH-(selectionXL), 10, 255, 255, 255, 255);
}
- g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, textFragments, textColour.Red, textColour.Green, textColour.Blue, 255);
+ g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, cDisplayText, textColour.Red, textColour.Green, textColour.Blue, 255);
}
else
{
- g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, textLines, textColour.Red, textColour.Green, textColour.Blue, 255);
+ g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, cDisplayText, textColour.Red, textColour.Green, textColour.Blue, 255);
}
} else {
if(selectionXL != -1 && selectionXH != -1)
{
g->fillrect(screenPos.X+textPosition.X+selectionXL, screenPos.Y+textPosition.Y-1, selectionXH-(selectionXL), 10, 255, 255, 255, 255);
- g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, textFragments, textColour.Red, textColour.Green, textColour.Blue, 255);
+ g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, cDisplayText, textColour.Red, textColour.Green, textColour.Blue, 255);
}
else
{
- g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, text, textColour.Red, textColour.Green, textColour.Blue, 255);
+ g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, cDisplayText, textColour.Red, textColour.Green, textColour.Blue, 255);
}
}
}
diff --git a/src/interface/Label.h b/src/interface/Label.h
index 1fa7148..77c28d6 100644
--- a/src/interface/Label.h
+++ b/src/interface/Label.h
@@ -14,6 +14,7 @@ namespace ui
protected:
std::string textFragments;
std::string textLines;
+ std::string displayText;
std::string text;
Colour textColour;
@@ -48,6 +49,7 @@ namespace ui
virtual void SetMultiline(bool status);
virtual void SetText(std::string text);
+ virtual void SetDisplayText(std::string newText);
virtual std::string GetText();
virtual bool HasSelection();
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index a57d69a..71a485e 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -99,11 +99,6 @@ size_t Textbox::GetLimit()
return limit;
}
-void Textbox::SetDisplayText(std::string newText)
-{
- Label::SetText(text);
-}
-
std::string Textbox::GetText()
{
return backingText;
diff --git a/src/interface/Textbox.h b/src/interface/Textbox.h
index 2bc959d..a43a7e5 100644
--- a/src/interface/Textbox.h
+++ b/src/interface/Textbox.h
@@ -24,7 +24,6 @@ public:
Textbox(Point position, Point size, std::string textboxText = "", std::string textboxPlaceholder = "");
virtual ~Textbox();
- virtual void SetDisplayText(std::string text);
virtual void SetText(std::string text);
virtual std::string GetText();
@@ -44,7 +43,7 @@ public:
//Determines if the given character is valid given the input type
bool CharacterValid(Uint16 character);
- virtual void Tick(float dt);
+ virtual void Tick(float dt);
virtual void OnContextMenuAction(int item);
virtual void OnMouseClick(int x, int y, unsigned button);
virtual void OnMouseUp(int x, int y, unsigned button);