diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp index fa004a8be..7f28b5e2f 100644 --- a/src/game/SignTool.cpp +++ b/src/game/SignTool.cpp @@ -5,10 +5,12 @@ #include "interface/Button.h" #include "interface/Label.h" #include "interface/Textbox.h" +#include "interface/DropDown.h" class SignWindow: public ui::Window { public: + ui::DropDown * justification; ui::Textbox * textField; SignTool * tool; Simulation * sim; @@ -29,11 +31,11 @@ public: ui::Engine::Ref().CloseWindow(); if(prompt->signID==-1 && prompt->textField->GetText().length()) { - prompt->sim->signs.push_back(sign(prompt->textField->GetText(), prompt->signPosition.X, prompt->signPosition.Y, sign::Left)); + prompt->sim->signs.push_back(sign(prompt->textField->GetText(), prompt->signPosition.X, prompt->signPosition.Y, (sign::Justification)prompt->justification->GetOption().second)); } else if(prompt->textField->GetText().length()) { - prompt->sim->signs[prompt->signID] = sign(sign(prompt->textField->GetText(), prompt->signPosition.X, prompt->signPosition.Y, sign::Left)); + prompt->sim->signs[prompt->signID] = sign(sign(prompt->textField->GetText(), prompt->signPosition.X, prompt->signPosition.Y, (sign::Justification)prompt->justification->GetOption().second)); } prompt->SelfDestruct(); } @@ -56,6 +58,13 @@ SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Poi okayButton->SetActionCallback(new OkayAction(this)); AddComponent(okayButton); + justification = new ui::DropDown(ui::Point(4, 18), ui::Point(50, 16)); + AddComponent(justification); + justification->AddOption(std::pair("Left", (int)sign::Left)); + justification->AddOption(std::pair("Centre", (int)sign::Centre)); + justification->AddOption(std::pair("Right", (int)sign::Right)); + justification->SetOption(0); + textField = new ui::Textbox(ui::Point(4, 32), ui::Point(Size.X-8, 16), ""); textField->SetAlignment(AlignLeft, AlignBottom); AddComponent(textField); diff --git a/src/interface/DropDown.cpp b/src/interface/DropDown.cpp index ea7d56a5a..d5af4c418 100644 --- a/src/interface/DropDown.cpp +++ b/src/interface/DropDown.cpp @@ -79,7 +79,8 @@ public: DropDown::DropDown(Point position, Point size): Component(position, size), isMouseInside(false), - optionIndex(-1) + optionIndex(-1), + callback(NULL) { background = activeBackground = Colour(0, 0, 0); activeText = text = activeBackground = border = activeBorder = Colour(255, 255, 255); @@ -114,6 +115,15 @@ void DropDown::Draw(const Point& screenPos) } + std::pair DropDown::GetOption() + { + if(optionIndex!=-1) + { + return options[optionIndex]; + } + return std::pair("", -1); + } + void DropDown::SetOption(std::string option) { for(int i = 0; i < options.size(); i++) diff --git a/src/interface/DropDown.h b/src/interface/DropDown.h index 34310df7d..40fac6839 100644 --- a/src/interface/DropDown.h +++ b/src/interface/DropDown.h @@ -33,6 +33,7 @@ class DropDown: public ui::Component { std::vector > options; public: DropDown(Point position, Point size); + std::pair GetOption(); void SetOption(int option); void SetOption(std::string option); void AddOption(std::pair option); diff --git a/src/interface/Window.cpp b/src/interface/Window.cpp index 86221ab0e..8dba69a16 100644 --- a/src/interface/Window.cpp +++ b/src/interface/Window.cpp @@ -1,3 +1,4 @@ +#include #include "Window.h" #include "Component.h" #include "interface/Point.h" @@ -209,7 +210,7 @@ void Window::DoTick(float dt) void Window::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { #ifdef DEBUG - if(character = 'd' && ctrl && shift) + if(key == KEY_TAB && ctrl) debugMode = !debugMode; if(debugMode) { diff --git a/src/options/OptionsModel.cpp b/src/options/OptionsModel.cpp index 3891d41d6..b24a51336 100644 --- a/src/options/OptionsModel.cpp +++ b/src/options/OptionsModel.cpp @@ -5,7 +5,7 @@ * Author: Simon */ -#include "Air.h" +#include "simulation/Air.h" #include "OptionsModel.h" OptionsModel::OptionsModel(Simulation * sim_) {