From ad76b293d8fc257a7efe0cbcf6f7fb9380616030 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Wed, 20 Jun 2012 19:39:33 +0100 Subject: [PATCH] Make Confirm dialogue less ugly --- src/dialogues/ConfirmPrompt.cpp | 24 +++++++++++++++--------- src/interface/Textblock.h | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/dialogues/ConfirmPrompt.cpp b/src/dialogues/ConfirmPrompt.cpp index a5f742dbf..6943555bd 100644 --- a/src/dialogues/ConfirmPrompt.cpp +++ b/src/dialogues/ConfirmPrompt.cpp @@ -6,24 +6,30 @@ */ #include "ConfirmPrompt.h" -#include "interface/Label.h" +#include "interface/Textblock.h" #include "interface/Button.h" ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDialogueCallback * callback_): - ui::Window(ui::Point(-1, -1), ui::Point(200, 75)), + ui::Window(ui::Point(-1, -1), ui::Point(200, 50)), callback(callback_) { - ui::Label * titleLabel = new ui::Label(ui::Point(2, 1), ui::Point(Size.X-4, 16), title); + int width, height; + ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), title); titleLabel->SetTextColour(ui::Colour(220, 220, 50)); titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; - titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom; + titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; AddComponent(titleLabel); - ui::Label * messageLabel = new ui::Label(ui::Point(4, 18), ui::Point(Size.X-8, 60), message); + + ui::Textblock * messageLabel = new ui::Textblock(ui::Point(4, 25), ui::Point(Size.X-8, 60), message); + Graphics::textsize(messageLabel->GetDisplayText().c_str(), width, height); messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop; AddComponent(messageLabel); + Size.Y += height; + Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2; + class CloseAction: public ui::ButtonAction { public: @@ -34,21 +40,21 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial { ui::Engine::Ref().CloseWindow(); prompt->callback->ConfirmCallback(result); - prompt->SelfDestruct(); //TODO: Fix component disposal + prompt->SelfDestruct(); } }; ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X-50, 16), "Cancel"); cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; - cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom; + cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200); cancelButton->SetActionCallback(new CloseAction(this, ResultCancel)); AddComponent(cancelButton); - ui::Button * okayButton = new ui::Button(ui::Point(Size.X-50, Size.Y-16), ui::Point(50, 16), "Continue"); + ui::Button * okayButton = new ui::Button(ui::Point(Size.X-76, Size.Y-16), ui::Point(76, 16), "Continue"); okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; - okayButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom; + okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; okayButton->Appearance.TextInactive = ui::Colour(220, 220, 50); okayButton->SetActionCallback(new CloseAction(this, ResultOkay)); AddComponent(okayButton); diff --git a/src/interface/Textblock.h b/src/interface/Textblock.h index 99b79e6fa..7a94c7797 100644 --- a/src/interface/Textblock.h +++ b/src/interface/Textblock.h @@ -25,6 +25,7 @@ public: Textblock(Point position, Point size, std::string textboxText); virtual void TextPosition() {} virtual void SetText(std::string text); + virtual std::string GetDisplayText() { return textLines; } virtual void Draw(const Point& screenPos); virtual ~Textblock(); };