mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-17 14:28:30 +01:00
Improve appearance of some dialogues, style defaults
This commit is contained in:
parent
4bb90d0d79
commit
f39d2361e7
9
Style.cpp
Normal file
9
Style.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
//
|
||||
// Style.cpp
|
||||
// The Powder Toy
|
||||
//
|
||||
// Created by Simon Robertshaw on 14/05/2012.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
14
Style.h
Normal file
14
Style.h
Normal file
@ -0,0 +1,14 @@
|
||||
//
|
||||
// Style.h
|
||||
// The Powder Toy
|
||||
//
|
||||
// Created by Simon Robertshaw on 14/05/2012.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef The_Powder_Toy_Style_h
|
||||
#define The_Powder_Toy_Style_h
|
||||
|
||||
|
||||
|
||||
#endif
|
22
src/Style.cpp
Normal file
22
src/Style.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Style.cpp
|
||||
// The Powder Toy
|
||||
//
|
||||
// Created by Simon Robertshaw on 14/05/2012.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "Style.h"
|
||||
|
||||
namespace style {
|
||||
ui::Colour Colour::InformationTitle = ui::Colour(140, 140, 255);
|
||||
ui::Colour Colour::WarningTitle = ui::Colour(255, 255, 50);
|
||||
ui::Colour Colour::ErrorTitle = ui::Colour(255, 20, 20);
|
||||
|
||||
ui::Colour Colour::ActiveBorder = ui::Colour(255, 255, 255);
|
||||
ui::Colour Colour::InactiveBorder = ui::Colour(180, 180, 180);
|
||||
|
||||
ui::Colour Colour::ActiveBackground = ui::Colour(50, 50, 50);
|
||||
ui::Colour Colour::InactiveBackground = ui::Colour(0, 0, 0);
|
||||
}
|
32
src/Style.h
Normal file
32
src/Style.h
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Style.h
|
||||
// The Powder Toy
|
||||
//
|
||||
// Created by Simon Robertshaw on 14/05/2012.
|
||||
//
|
||||
|
||||
#ifndef The_Powder_Toy_Style_h
|
||||
#define The_Powder_Toy_Style_h
|
||||
#include "interface/Colour.h"
|
||||
|
||||
namespace style
|
||||
{
|
||||
class Colour
|
||||
{
|
||||
public:
|
||||
static ui::Colour InformationTitle;
|
||||
static ui::Colour WarningTitle;
|
||||
static ui::Colour ErrorTitle;
|
||||
|
||||
static ui::Colour ActiveBorder;
|
||||
static ui::Colour InactiveBorder;
|
||||
|
||||
static ui::Colour ActiveBackground;
|
||||
static ui::Colour InactiveBackground;
|
||||
};
|
||||
class Metrics
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
78
src/game/PropertyTool.cpp
Normal file
78
src/game/PropertyTool.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
#include <iostream>
|
||||
#include "Style.h"
|
||||
#include "simulation/Simulation.h"
|
||||
#include "Tool.h"
|
||||
#include "interface/Window.h"
|
||||
#include "interface/Button.h"
|
||||
#include "interface/Label.h"
|
||||
#include "interface/Textbox.h"
|
||||
#include "interface/DropDown.h"
|
||||
|
||||
class PropertyWindow: public ui::Window
|
||||
{
|
||||
public:
|
||||
ui::DropDown * property;
|
||||
ui::Textbox * textField;
|
||||
SignTool * tool;
|
||||
Simulation * sim;
|
||||
int signID;
|
||||
ui::Point position;
|
||||
PropertyWindow(PropertyTool * tool_, Simulation * sim_, ui::Point position_);
|
||||
virtual void OnDraw();
|
||||
virtual ~PropertyWindow() {}
|
||||
};
|
||||
|
||||
class OkayAction: public ui::ButtonAction
|
||||
{
|
||||
public:
|
||||
PropertyWindow * prompt;
|
||||
OkayAction(PropertyWindow * prompt_) { prompt = prompt_; }
|
||||
void ActionCallback(ui::Button * sender)
|
||||
{
|
||||
ui::Engine::Ref().CloseWindow();
|
||||
|
||||
prompt->SelfDestruct();
|
||||
}
|
||||
};
|
||||
|
||||
PropertyWindow::PropertyWindow(PropertyTool * tool_, Simulation * sim_, ui::Point position_):
|
||||
ui::Window(ui::Point(-1, -1), ui::Point(200, 87)),
|
||||
sim(sim_),
|
||||
position(position_)
|
||||
{
|
||||
ui::Label * messageLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Edit property");
|
||||
messageLabel->SetTextColour(style::Colour::InformationTitle);
|
||||
messageLabel->SetAlignment(AlignLeft, AlignTop);
|
||||
AddComponent(messageLabel);
|
||||
|
||||
ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 17), "OK");
|
||||
okayButton->SetAlignment(AlignLeft, AlignBottom);
|
||||
okayButton->SetBorderColour(ui::Colour(200, 200, 200));
|
||||
okayButton->SetActionCallback(new OkayAction(this));
|
||||
AddComponent(okayButton);
|
||||
|
||||
property = new ui::DropDown(ui::Point(8, 25), ui::Point(Size.X-16, 17));
|
||||
AddComponent(property);
|
||||
property->AddOption(std::pair<std::string, int>("Left", (int)sign::Left));
|
||||
property->AddOption(std::pair<std::string, int>("Centre", (int)sign::Centre));
|
||||
property->AddOption(std::pair<std::string, int>("Right", (int)sign::Right));
|
||||
property->SetOption(0);
|
||||
|
||||
textField = new ui::Textbox(ui::Point(8, 46), ui::Point(Size.X-16, 16), "");
|
||||
textField->SetAlignment(AlignLeft, AlignBottom);
|
||||
AddComponent(textField);
|
||||
|
||||
ui::Engine::Ref().ShowWindow(this);
|
||||
}
|
||||
void PropertyWindow::OnDraw()
|
||||
{
|
||||
Graphics * g = ui::Engine::Ref().g;
|
||||
|
||||
g->clearrect(Position.X-2, Position.Y-2, Size.X+4, Size.Y+4);
|
||||
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);
|
||||
}
|
||||
|
||||
void PropertyTool::Click(Simulation * sim, Brush * brush, ui::Point position)
|
||||
{
|
||||
new PropertyWindow(this, sim, position);
|
||||
}
|
@ -65,6 +65,7 @@ public:
|
||||
{
|
||||
}
|
||||
virtual ~PropertyTool() {}
|
||||
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) {};
|
||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "interface/Button.h"
|
||||
#include "Graphics.h"
|
||||
#include "Engine.h"
|
||||
@ -30,6 +29,7 @@ Button::Button(Point position, Point size, std::string buttonText):
|
||||
{
|
||||
activeText = background = Colour(0, 0, 0);
|
||||
text = activeBackground = border = activeBorder = Colour(255, 255, 255);
|
||||
|
||||
TextPosition();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "Style.h"
|
||||
#include "Button.h"
|
||||
#include "DropDown.h"
|
||||
|
||||
@ -35,29 +36,31 @@ public:
|
||||
}
|
||||
};
|
||||
DropDownWindow(DropDown * dropDown):
|
||||
Window(ui::Point(dropDown->Position.X+dropDown->GetParentWindow()->Position.X-5, dropDown->Position.Y+dropDown->GetParentWindow()->Position.Y-3), ui::Point(dropDown->Size.X+10, dropDown->options.size()*13)),
|
||||
Window(ui::Point(dropDown->Position.X+dropDown->GetParentWindow()->Position.X-5, dropDown->Position.Y+dropDown->GetParentWindow()->Position.Y-3), ui::Point(dropDown->Size.X+10, 1+dropDown->options.size()*15)),
|
||||
dropDown(dropDown),
|
||||
background(background),
|
||||
background(dropDown->background),
|
||||
activeBackground(dropDown->activeBackground),
|
||||
border(dropDown->border),
|
||||
activeBorder(dropDown->activeBorder),
|
||||
text(dropDown->text),
|
||||
activeText(dropDown->activeText)
|
||||
{
|
||||
int currentY = 0;
|
||||
int currentY = 1;
|
||||
for(int i = 0; i < dropDown->options.size(); i++)
|
||||
{
|
||||
Button * tempButton = new Button(Point(0, currentY), Point(Size.X, 14), dropDown->options[i].first);
|
||||
Button * tempButton = new Button(Point(1, currentY), Point(Size.X-2, 14), dropDown->options[i].first);
|
||||
tempButton->SetTextColour(dropDown->text);
|
||||
tempButton->SetBorderColour(dropDown->background);
|
||||
tempButton->SetActionCallback(new ItemSelectedAction(this, dropDown->options[i].first));
|
||||
AddComponent(tempButton);
|
||||
currentY += 13;
|
||||
currentY += 15;
|
||||
}
|
||||
}
|
||||
virtual void OnDraw()
|
||||
{
|
||||
Graphics * g = ui::Engine::Ref().g;
|
||||
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255);
|
||||
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255);
|
||||
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 100, 100, 100, 255);
|
||||
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, border.Alpha);
|
||||
}
|
||||
void setOption(std::string option)
|
||||
{
|
||||
@ -85,8 +88,12 @@ DropDown::DropDown(Point position, Point size):
|
||||
textHAlign(AlignLeft),
|
||||
callback(NULL)
|
||||
{
|
||||
background = activeBackground = Colour(0, 0, 0);
|
||||
activeText = text = activeBackground = border = activeBorder = Colour(255, 255, 255);
|
||||
activeText = text = Colour(255, 255, 255);
|
||||
|
||||
border = style::Colour::InactiveBorder;
|
||||
activeBorder = style::Colour::ActiveBorder;
|
||||
background = style::Colour::InactiveBackground;
|
||||
activeBackground = style::Colour::ActiveBackground;
|
||||
}
|
||||
|
||||
void DropDown::OnMouseClick(int x, int y, unsigned int button)
|
||||
|
@ -6,15 +6,16 @@
|
||||
*/
|
||||
|
||||
#include "OptionsView.h"
|
||||
#include "Style.h"
|
||||
#include "interface/Button.h"
|
||||
#include "interface/Label.h"
|
||||
#include "interface/DropDown.h"
|
||||
|
||||
OptionsView::OptionsView():
|
||||
ui::Window(ui::Point(-1, -1), ui::Point(300, 300)){
|
||||
ui::Window(ui::Point(-1, -1), ui::Point(300, 206)){
|
||||
|
||||
ui::Label * tempLabel = new ui::Label(ui::Point(3, 3), ui::Point(Size.X-6, 14), "Simulation Options");
|
||||
tempLabel->SetTextColour(ui::Colour(255, 220, 0));
|
||||
ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options");
|
||||
tempLabel->SetTextColour(style::Colour::InformationTitle);
|
||||
tempLabel->SetAlignment(AlignLeft, AlignMiddle);
|
||||
AddComponent(tempLabel);
|
||||
|
||||
@ -26,7 +27,7 @@ OptionsView::OptionsView():
|
||||
virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetHeatSimulation(sender->GetChecked()); }
|
||||
};
|
||||
|
||||
heatSimulation = new ui::Checkbox(ui::Point(3, 23), ui::Point(Size.X-6, 16), "Heat simulation \bgIntroduced in version 34");
|
||||
heatSimulation = new ui::Checkbox(ui::Point(8, 23), ui::Point(Size.X-6, 16), "Heat simulation \bgIntroduced in version 34");
|
||||
heatSimulation->SetActionCallback(new HeatSimulationAction(this));
|
||||
AddComponent(heatSimulation);
|
||||
tempLabel = new ui::Label(ui::Point(24, heatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour with very old saves");
|
||||
@ -41,7 +42,7 @@ OptionsView::OptionsView():
|
||||
virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetAmbientHeatSimulation(sender->GetChecked()); }
|
||||
};
|
||||
|
||||
ambientHeatSimulation = new ui::Checkbox(ui::Point(3, 53), ui::Point(Size.X-6, 16), "Ambient heat simulation \bgIntroduced in version 50");
|
||||
ambientHeatSimulation = new ui::Checkbox(ui::Point(8, 53), ui::Point(Size.X-6, 16), "Ambient heat simulation \bgIntroduced in version 50");
|
||||
ambientHeatSimulation->SetActionCallback(new AmbientHeatSimulationAction(this));
|
||||
AddComponent(ambientHeatSimulation);
|
||||
tempLabel = new ui::Label(ui::Point(24, ambientHeatSimulation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour with old saves");
|
||||
@ -56,7 +57,7 @@ OptionsView::OptionsView():
|
||||
virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetNewtonianGravity(sender->GetChecked()); }
|
||||
};
|
||||
|
||||
newtonianGravity = new ui::Checkbox(ui::Point(3, 83), ui::Point(Size.X-6, 16), "Newtonian gravity \bgIntroduced in version 48");
|
||||
newtonianGravity = new ui::Checkbox(ui::Point(8, 83), ui::Point(Size.X-6, 16), "Newtonian gravity \bgIntroduced in version 48");
|
||||
newtonianGravity->SetActionCallback(new NewtonianGravityAction(this));
|
||||
AddComponent(newtonianGravity);
|
||||
tempLabel = new ui::Label(ui::Point(24, newtonianGravity->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance on older computers");
|
||||
@ -71,7 +72,7 @@ OptionsView::OptionsView():
|
||||
virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetWaterEqualisation(sender->GetChecked()); }
|
||||
};
|
||||
|
||||
waterEqualisation = new ui::Checkbox(ui::Point(3, 113), ui::Point(Size.X-6, 16), "Water equalisation \bgIntroduced in version 61");
|
||||
waterEqualisation = new ui::Checkbox(ui::Point(8, 113), ui::Point(Size.X-6, 16), "Water equalisation \bgIntroduced in version 61");
|
||||
waterEqualisation->SetActionCallback(new WaterEqualisationAction(this));
|
||||
AddComponent(waterEqualisation);
|
||||
tempLabel = new ui::Label(ui::Point(24, waterEqualisation->Position.Y+14), ui::Point(Size.X-28, 16), "\bgMay cause poor performance with a lot of water");
|
||||
@ -85,7 +86,7 @@ OptionsView::OptionsView():
|
||||
AirModeChanged(OptionsView * v): v(v) { }
|
||||
virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) { v->c->SetAirMode(option.second); }
|
||||
};
|
||||
airMode = new ui::DropDown(ui::Point(Size.X-85, 143), ui::Point(80, 16));
|
||||
airMode = new ui::DropDown(ui::Point(Size.X-88, 146), ui::Point(80, 16));
|
||||
AddComponent(airMode);
|
||||
airMode->AddOption(std::pair<std::string, int>("On", 0));
|
||||
airMode->AddOption(std::pair<std::string, int>("Pressure off", 1));
|
||||
@ -94,7 +95,7 @@ OptionsView::OptionsView():
|
||||
airMode->AddOption(std::pair<std::string, int>("No Update", 4));
|
||||
airMode->SetActionCallback(new AirModeChanged(this));
|
||||
|
||||
tempLabel = new ui::Label(ui::Point(3, 143), ui::Point(Size.X-90, 16), "Air Simulation Mode");
|
||||
tempLabel = new ui::Label(ui::Point(8, 146), ui::Point(Size.X-96, 16), "Air Simulation Mode");
|
||||
tempLabel->SetAlignment(AlignLeft, AlignMiddle);
|
||||
AddComponent(tempLabel);
|
||||
|
||||
@ -106,14 +107,14 @@ OptionsView::OptionsView():
|
||||
virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option) { v->c->SetGravityMode(option.second); }
|
||||
};
|
||||
|
||||
gravityMode = new ui::DropDown(ui::Point(Size.X-85, 163), ui::Point(80, 16));
|
||||
gravityMode = new ui::DropDown(ui::Point(Size.X-88, 166), ui::Point(80, 16));
|
||||
AddComponent(gravityMode);
|
||||
gravityMode->AddOption(std::pair<std::string, int>("Vertical", 0));
|
||||
gravityMode->AddOption(std::pair<std::string, int>("Off", 1));
|
||||
gravityMode->AddOption(std::pair<std::string, int>("Radial", 2));
|
||||
gravityMode->SetActionCallback(new GravityModeChanged(this));
|
||||
|
||||
tempLabel = new ui::Label(ui::Point(3, 163), ui::Point(Size.X-90, 16), "Gravity Simulation Mode");
|
||||
tempLabel = new ui::Label(ui::Point(8, 166), ui::Point(Size.X-96, 16), "Gravity Simulation Mode");
|
||||
tempLabel->SetAlignment(AlignLeft, AlignMiddle);
|
||||
AddComponent(tempLabel);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user