summaryrefslogtreecommitdiff
path: root/src/game/GameView.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-03-04 16:26:03 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-03-04 16:26:03 (GMT)
commit644e6770e43e5ed568b0cdc14d63f20869d7fccc (patch)
tree19e0b8b60df245d0972a3d7afb106f6954b931ee /src/game/GameView.cpp
parent3bbaa1a111e3770d2ce9b04f4b0f9688948d3e85 (diff)
downloadpowder-644e6770e43e5ed568b0cdc14d63f20869d7fccc.zip
powder-644e6770e43e5ed568b0cdc14d63f20869d7fccc.tar.gz
Slider and decoration colour changer
Diffstat (limited to 'src/game/GameView.cpp')
-rw-r--r--src/game/GameView.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index faf973e..7969ed0 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -4,6 +4,7 @@
#include "interface/Button.h"
#include "interface/Colour.h"
#include "interface/Keys.h"
+#include "interface/Slider.h"
GameView::GameView():
ui::Window(ui::Point(0, 0), ui::Point(XRES+BARSIZE, YRES+MENUSIZE)),
@@ -194,6 +195,24 @@ GameView::GameView():
pauseButton->SetTogglable(true);
pauseButton->SetActionCallback(new PauseAction(this));
AddComponent(pauseButton);
+
+ class ColourChange : public ui::SliderAction
+ {
+ GameView * v;
+ public:
+ ColourChange(GameView * _v) { v = _v; }
+ void ValueChangedCallback(ui::Slider * sender)
+ {
+ v->changeColour();
+ }
+ };
+ ColourChange * colC = new ColourChange(this);
+ colourRSlider = new ui::Slider(ui::Point(5, Size.Y-40), ui::Point(100, 16), 255);
+ colourRSlider->SetActionCallback(colC);
+ colourGSlider = new ui::Slider(ui::Point(115, Size.Y-40), ui::Point(100, 16), 255);
+ colourGSlider->SetActionCallback(colC);
+ colourBSlider = new ui::Slider(ui::Point(225, Size.Y-40), ui::Point(100, 16), 255);
+ colourBSlider->SetActionCallback(colC);
}
class GameView::MenuAction: public ui::ButtonAction
@@ -328,6 +347,39 @@ void GameView::NotifyToolListChanged(GameModel * sender)
}
+void GameView::NotifyColourSelectorVisibilityChanged(GameModel * sender)
+{
+ RemoveComponent(colourRSlider);
+ colourRSlider->SetParentWindow(NULL);
+ RemoveComponent(colourGSlider);
+ colourGSlider->SetParentWindow(NULL);
+ RemoveComponent(colourBSlider);
+ colourBSlider->SetParentWindow(NULL);
+ if(sender->GetColourSelectorVisibility())
+ {
+ AddComponent(colourRSlider);
+ AddComponent(colourGSlider);
+ AddComponent(colourBSlider);
+ }
+
+}
+
+void GameView::NotifyColourSelectorColourChanged(GameModel * sender)
+{
+ colourRSlider->SetValue(sender->GetColourSelectorColour().Red);
+ colourGSlider->SetValue(sender->GetColourSelectorColour().Green);
+ colourBSlider->SetValue(sender->GetColourSelectorColour().Blue);
+
+ vector<Tool*> tools = sender->GetMenuList()[SC_DECO]->GetToolList();
+ for(int i = 0; i < tools.size(); i++)
+ {
+ tools[i]->colRed = sender->GetColourSelectorColour().Red;
+ tools[i]->colGreen = sender->GetColourSelectorColour().Green;
+ tools[i]->colBlue = sender->GetColourSelectorColour().Blue;
+ }
+ NotifyToolListChanged(sender);
+}
+
void GameView::NotifyRendererChanged(GameModel * sender)
{
ren = sender->GetRenderer();
@@ -565,6 +617,11 @@ void GameView::NotifyZoomChanged(GameModel * sender)
zoomEnabled = sender->GetZoomEnabled();
}
+void GameView::changeColour()
+{
+ c->SetColour(ui::Colour(colourRSlider->GetValue(), colourGSlider->GetValue(), colourBSlider->GetValue()));
+}
+
void GameView::OnDraw()
{
if(ren)