summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-11-26 11:48:27 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-11-26 11:48:27 (GMT)
commit3664a22f98951548fc2257fb78f3c0232bb9beeb (patch)
treea80d148d5c01b0ff14734828837ff17e33ca2eb3 /src
parentb08812569cf96dcd5a62c8d0467bd14f3ae90e54 (diff)
downloadpowder-3664a22f98951548fc2257fb78f3c0232bb9beeb.zip
powder-3664a22f98951548fc2257fb78f3c0232bb9beeb.tar.gz
Right clicking on reload button will show save preview.
Diffstat (limited to 'src')
-rw-r--r--src/game/GameController.cpp9
-rw-r--r--src/game/GameController.h1
-rw-r--r--src/game/GameView.cpp4
-rw-r--r--src/interface/Button.cpp44
-rw-r--r--src/interface/Button.h4
5 files changed, 49 insertions, 13 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 18b93d6..c929f3a 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -987,6 +987,15 @@ void GameController::OpenSavePreview(int saveID, int saveDate)
ui::Engine::Ref().ShowWindow(activePreview->GetView());
}
+void GameController::OpenSavePreview()
+{
+ if(gameModel->GetSave())
+ {
+ activePreview = new PreviewController(gameModel->GetSave()->GetID(), new SaveOpenCallback(this));
+ ui::Engine::Ref().ShowWindow(activePreview->GetView());
+ }
+}
+
void GameController::OpenLocalBrowse()
{
class LocalSaveOpenCallback: public FileSelectedCallback
diff --git a/src/game/GameController.h b/src/game/GameController.h
index 4c7a8c9..a5c4416 100644
--- a/src/game/GameController.h
+++ b/src/game/GameController.h
@@ -106,6 +106,7 @@ public:
void OpenLogin();
void OpenTags();
void OpenSavePreview(int saveID, int saveDate);
+ void OpenSavePreview();
void OpenLocalSaveWindow(bool asCurrent);
void OpenLocalBrowse();
void OpenOptions();
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 0e3f580..9d900ba 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -223,6 +223,10 @@ GameView::GameView():
{
v->c->ReloadSim();
}
+ void AltActionCallback(ui::Button * sender)
+ {
+ v->c->OpenSavePreview();
+ }
};
reloadButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15), "", "Reload the simulation");
reloadButton->SetIcon(IconReload);
diff --git a/src/interface/Button.cpp b/src/interface/Button.cpp
index fbf9b54..4b9c5d9 100644
--- a/src/interface/Button.cpp
+++ b/src/interface/Button.cpp
@@ -156,26 +156,38 @@ void Button::Draw(const Point& screenPos)
void Button::OnMouseUnclick(int x, int y, unsigned int button)
{
- if(button != 1)
+ if(button == 1)
{
- return;
+ if(isButtonDown)
+ {
+ isButtonDown = false;
+ DoAction();
+ }
}
-
- if(isButtonDown)
+ else if(button == 3)
{
- isButtonDown = false;
- DoAction();
- }
+ if(isAltButtonDown)
+ {
+ isAltButtonDown = false;
+ DoAltAction();
+ }
+ }
}
void Button::OnMouseClick(int x, int y, unsigned int button)
{
- if(button != 1) return;
- if(isTogglable)
- {
- toggle = !toggle;
+ if(button == 1)
+ {
+ if(isTogglable)
+ {
+ toggle = !toggle;
+ }
+ isButtonDown = true;
+ }
+ else if(button == 3)
+ {
+ isAltButtonDown = true;
}
- isButtonDown = true;
}
void Button::OnMouseEnter(int x, int y)
@@ -206,6 +218,14 @@ void Button::DoAction()
actionCallback->ActionCallback(this);
}
+void Button::DoAltAction()
+{
+ if(!Enabled)
+ return;
+ if(actionCallback)
+ actionCallback->AltActionCallback(this);
+}
+
void Button::SetActionCallback(ButtonAction * action)
{
if(actionCallback)
diff --git a/src/interface/Button.h b/src/interface/Button.h
index 5bc7fc3..dff15b4 100644
--- a/src/interface/Button.h
+++ b/src/interface/Button.h
@@ -20,6 +20,7 @@ class ButtonAction
{
public:
virtual void ActionCallback(ui::Button * sender) {}
+ virtual void AltActionCallback(ui::Button * sender) {}
virtual void MouseEnterCallback(ui::Button * sender) {}
virtual ~ButtonAction() {}
};
@@ -45,6 +46,7 @@ public:
virtual void TextPosition();
inline bool GetState() { return state; }
virtual void DoAction(); //action of button what ever it may be
+ virtual void DoAltAction(); //action of button what ever it may be
void SetTogglable(bool isTogglable);
bool GetTogglable();
TPT_NO_INLINE bool GetToggleState();
@@ -60,7 +62,7 @@ protected:
std::string buttonDisplayText;
std::string ButtonText;
- bool isButtonDown, state, isMouseInside, isTogglable, toggle;
+ bool isButtonDown, isAltButtonDown, state, isMouseInside, isTogglable, toggle;
ButtonAction * actionCallback;
};