summaryrefslogtreecommitdiff
path: root/src/game/GameController.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-20 16:51:51 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-20 16:51:51 (GMT)
commit0594aa5d07d7bf63885eee966d102e3e7354c925 (patch)
tree5700cb10ab0e63b6684eaeba225d578bf2f1dfa6 /src/game/GameController.cpp
parent088b2f678d5baedcf3555a5afce76710e6900a9e (diff)
downloadpowder-0594aa5d07d7bf63885eee966d102e3e7354c925.zip
powder-0594aa5d07d7bf63885eee966d102e3e7354c925.tar.gz
More in the way of an autoupdater
Diffstat (limited to 'src/game/GameController.cpp')
-rw-r--r--src/game/GameController.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 6ed6e0f..71e485d 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -10,6 +10,7 @@
#include "login/LoginController.h"
#include "interface/Point.h"
#include "dialogues/ErrorMessage.h"
+#include "dialogues/ConfirmPrompt.h"
#include "GameModelException.h"
#include "simulation/Air.h"
#include "Notification.h"
@@ -121,7 +122,8 @@ GameController::GameController():
ssave(NULL),
console(NULL),
tagsWindow(NULL),
- options(NULL)
+ options(NULL),
+ HasDone(false)
{
gameView = new GameView();
gameModel = new GameModel();
@@ -391,6 +393,13 @@ void GameController::Tick()
commandInterface->OnTick();
}
+void GameController::Exit()
+{
+ if(ui::Engine::Ref().GetWindow() == gameView)
+ ui::Engine::Ref().CloseWindow();
+ HasDone = true;
+}
+
void GameController::Update()
{
ui::Point pos = gameView->GetMousePosition();
@@ -629,6 +638,19 @@ std::string GameController::ElementResolve(int type)
void GameController::NotifyUpdateAvailable(Client * sender)
{
+ class UpdateConfirmation: public ConfirmDialogueCallback {
+ public:
+ GameController * c;
+ UpdateConfirmation(GameController * c_) { c = c_; }
+ virtual void ConfirmCallback(ConfirmPrompt::DialogueResult result) {
+ if (result == ConfirmPrompt::ResultOkay)
+ {
+ c->RunUpdater();
+ }
+ }
+ virtual ~UpdateConfirmation() { }
+ };
+
class UpdateNotification : public Notification
{
GameController * c;
@@ -638,7 +660,7 @@ void GameController::NotifyUpdateAvailable(Client * sender)
virtual void Action()
{
- c->RemoveNotification(this);
+ new ConfirmPrompt("Run Updater", "Are you sure you want to run the updater, please save any changes before updating", new UpdateConfirmation(c));
}
};
@@ -650,3 +672,8 @@ void GameController::RemoveNotification(Notification * notification)
gameModel->RemoveNotification(notification);
}
+void GameController::RunUpdater()
+{
+ Exit();
+}
+