mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 11:19:51 +02:00
Make Confirm dialogue less ugly
This commit is contained in:
@@ -6,24 +6,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ConfirmPrompt.h"
|
#include "ConfirmPrompt.h"
|
||||||
#include "interface/Label.h"
|
#include "interface/Textblock.h"
|
||||||
#include "interface/Button.h"
|
#include "interface/Button.h"
|
||||||
|
|
||||||
ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDialogueCallback * callback_):
|
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_)
|
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->SetTextColour(ui::Colour(220, 220, 50));
|
||||||
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
AddComponent(titleLabel);
|
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.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
|
messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
|
||||||
AddComponent(messageLabel);
|
AddComponent(messageLabel);
|
||||||
|
|
||||||
|
Size.Y += height;
|
||||||
|
Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;
|
||||||
|
|
||||||
class CloseAction: public ui::ButtonAction
|
class CloseAction: public ui::ButtonAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -34,21 +40,21 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
|
|||||||
{
|
{
|
||||||
ui::Engine::Ref().CloseWindow();
|
ui::Engine::Ref().CloseWindow();
|
||||||
prompt->callback->ConfirmCallback(result);
|
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");
|
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.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->Appearance.BorderInactive = ui::Colour(200, 200, 200);
|
||||||
cancelButton->SetActionCallback(new CloseAction(this, ResultCancel));
|
cancelButton->SetActionCallback(new CloseAction(this, ResultCancel));
|
||||||
AddComponent(cancelButton);
|
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.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->Appearance.TextInactive = ui::Colour(220, 220, 50);
|
||||||
okayButton->SetActionCallback(new CloseAction(this, ResultOkay));
|
okayButton->SetActionCallback(new CloseAction(this, ResultOkay));
|
||||||
AddComponent(okayButton);
|
AddComponent(okayButton);
|
||||||
|
@@ -25,6 +25,7 @@ public:
|
|||||||
Textblock(Point position, Point size, std::string textboxText);
|
Textblock(Point position, Point size, std::string textboxText);
|
||||||
virtual void TextPosition() {}
|
virtual void TextPosition() {}
|
||||||
virtual void SetText(std::string text);
|
virtual void SetText(std::string text);
|
||||||
|
virtual std::string GetDisplayText() { return textLines; }
|
||||||
virtual void Draw(const Point& screenPos);
|
virtual void Draw(const Point& screenPos);
|
||||||
virtual ~Textblock();
|
virtual ~Textblock();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user