# HG changeset patch
# User koryspansel
# Date 1318380250 25200
# Node ID 0574e2cf8bacf94e4cdafd1c57b29c691185160c
# Parent 9a9be3d8632e4cfb833b363ab72a49b6a3ab0193
Additional screen types
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/LightClone.vcproj
--- a/LightClone/LightClone.vcproj Tue Oct 11 13:49:40 2011 -0700
+++ b/LightClone/LightClone.vcproj Tue Oct 11 17:44:10 2011 -0700
@@ -338,6 +338,14 @@
Name="Screens"
>
+
+
+
+
@@ -346,6 +354,10 @@
>
+
+
@@ -552,6 +564,14 @@
Name="Screens"
>
+
+
+
+
@@ -560,6 +580,10 @@
>
+
+
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/ConfirmScreen.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LightClone/Source/ConfirmScreen.cpp Tue Oct 11 17:44:10 2011 -0700
@@ -0,0 +1,87 @@
+/*
+ * ConfirmScreen
+ */
+
+#include "ConfirmScreen.h"
+#include "ScreenManager.h"
+
+/*
+ * Initialize
+ */
+ErrorCode ConfirmScreen::Initialize(ServiceProvider* pServiceProvider)
+{
+ ErrorCode eCode = kInterface.Initialize(pServiceProvider);
+ if(eCode == Error_Success)
+ {
+ pDialog = new ChoiceDialog();
+ pDialog->Initialize(pServiceProvider);
+ pDialog->Subscribe(GuiDialog::EventResult, &ConfirmScreen::OnResult, this);
+
+ const D3DXVECTOR2& kMessageSize = pDialog->GetDimensions();
+ pDialog->SetPosition(0.5f * ((ScreenSizeX - 280) - kMessageSize.x), 0.5f * (ScreenSizeY - kMessageSize.y));
+ }
+
+ return Error_Success;
+}
+
+/*
+ * Terminate
+ */
+void ConfirmScreen::Terminate()
+{
+ kInterface.Terminate();
+
+ Screen::Terminate();
+}
+
+/*
+ * Update
+ */
+void ConfirmScreen::Update(float fElapsed)
+{
+ kInterface.Update(fElapsed);
+}
+
+/*
+ * Render
+ */
+void ConfirmScreen::Render(RenderContext& kContext)
+{
+ kCameraController.SetMode(CameraMode_2D);
+ kInterface.Render(kContext, kCameraController);
+}
+
+/*
+ * OnEnter
+ */
+void ConfirmScreen::OnEnter()
+{
+ pDialog->SetFlag(GuiElementFlag_Visible);
+}
+
+/*
+ * OnExit
+ */
+void ConfirmScreen::OnExit()
+{
+ pDialog->ClearFlag(GuiElementFlag_Visible);
+}
+
+/*
+ * OnResult
+ */
+void ConfirmScreen::OnResult(GuiEventArguments& kArguments)
+{
+ GuiResultArguments& kResultArguments = (GuiResultArguments&)kArguments;
+
+ if(kResultArguments.nResult == DialogResult_Yes)
+ {
+ pScreenManager->Set(NULL);
+ }
+ else
+
+ if(kResultArguments.nResult == DialogResult_No)
+ {
+ pScreenManager->Pop();
+ }
+}
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/ConfirmScreen.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LightClone/Source/ConfirmScreen.h Tue Oct 11 17:44:10 2011 -0700
@@ -0,0 +1,76 @@
+/*
+ * ConfirmScreen
+ */
+
+#ifndef __CONFIRMSCREEN_H__
+#define __CONFIRMSCREEN_H__
+
+#include "Core.h"
+#include "Screen.h"
+#include "CameraController.h"
+#include "GuiInterface.h"
+#include "Dialog.h"
+
+/*
+ * ConfirmScreen
+ */
+class ConfirmScreen : public Screen
+{
+ /*
+ * kCameraController
+ */
+ CameraController kCameraController;
+
+ /*
+ * kInterface
+ */
+ GuiInterface kInterface;
+
+ /*
+ * pMessageDialog
+ */
+ ChoiceDialog* pDialog;
+
+public:
+
+ /*
+ * Initialize
+ */
+ virtual ErrorCode Initialize(ServiceProvider* pServiceProvider);
+
+ /*
+ * Terminate
+ */
+ virtual void Terminate();
+
+ /*
+ * Update
+ */
+ virtual void Update(float fElapsed);
+
+ /*
+ * Render
+ */
+ virtual void Render(RenderContext& kContext);
+
+protected:
+
+ /*
+ * OnEnter
+ */
+ virtual void OnEnter();
+
+ /*
+ * OnExit
+ */
+ virtual void OnExit();
+
+private:
+
+ /*
+ * OnResult
+ */
+ void OnResult(GuiEventArguments& kArguments);
+};
+
+#endif //__CONFIRMSCREEN_H__
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/Dialog.h
--- a/LightClone/Source/Dialog.h Tue Oct 11 13:49:40 2011 -0700
+++ b/LightClone/Source/Dialog.h Tue Oct 11 17:44:10 2011 -0700
@@ -140,4 +140,14 @@
}
};
+/*
+ * MessageDialog
+ */
+typedef Dialog<1> MessageDialog;
+
+/*
+ * ChoiceDialog
+ */
+typedef Dialog<2> ChoiceDialog;
+
#endif //__DIALOG_H__
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/GameOverScreen.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LightClone/Source/GameOverScreen.cpp Tue Oct 11 17:44:10 2011 -0700
@@ -0,0 +1,81 @@
+/*
+ * GameOverScreen
+ */
+
+#include "GameOverScreen.h"
+#include "ScreenManager.h"
+
+/*
+ * Initialize
+ */
+ErrorCode GameOverScreen::Initialize(ServiceProvider* pServiceProvider)
+{
+ ErrorCode eCode = kInterface.Initialize(pServiceProvider);
+ if(eCode == Error_Success)
+ {
+ pDialog = new MessageDialog();
+ pDialog->Initialize(pServiceProvider);
+ pDialog->Subscribe(GuiDialog::EventResult, &GameOverScreen::OnResult, this);
+
+ const D3DXVECTOR2& kMessageSize = pDialog->GetDimensions();
+ pDialog->SetPosition(0.5f * ((ScreenSizeX - 280) - kMessageSize.x), 0.5f * (ScreenSizeY - kMessageSize.y));
+ }
+
+ return Error_Success;
+}
+
+/*
+ * Terminate
+ */
+void GameOverScreen::Terminate()
+{
+ kInterface.Terminate();
+
+ Screen::Terminate();
+}
+
+/*
+ * Update
+ */
+void GameOverScreen::Update(float fElapsed)
+{
+ kInterface.Update(fElapsed);
+}
+
+/*
+ * Render
+ */
+void GameOverScreen::Render(RenderContext& kContext)
+{
+ kCameraController.SetMode(CameraMode_2D);
+ kInterface.Render(kContext, kCameraController);
+}
+
+/*
+ * OnEnter
+ */
+void GameOverScreen::OnEnter()
+{
+ pDialog->SetFlag(GuiElementFlag_Visible);
+}
+
+/*
+ * OnExit
+ */
+void GameOverScreen::OnExit()
+{
+ pDialog->ClearFlag(GuiElementFlag_Visible);
+}
+
+/*
+ * OnResult
+ */
+void GameOverScreen::OnResult(GuiEventArguments& kArguments)
+{
+ GuiResultArguments& kResultArguments = (GuiResultArguments&)kArguments;
+
+ if(kResultArguments.nResult == DialogResult_Ok)
+ {
+ pScreenManager->Set("Main");
+ }
+}
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/GameOverScreen.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LightClone/Source/GameOverScreen.h Tue Oct 11 17:44:10 2011 -0700
@@ -0,0 +1,76 @@
+/*
+ * GameOverScreen
+ */
+
+#ifndef __GAMEOVERSCREEN_H__
+#define __GAMEOVERSCREEN_H__
+
+#include "Core.h"
+#include "Screen.h"
+#include "CameraController.h"
+#include "GuiInterface.h"
+#include "Dialog.h"
+
+/*
+ * GameOverScreen
+ */
+class GameOverScreen : public Screen
+{
+ /*
+ * kCameraController
+ */
+ CameraController kCameraController;
+
+ /*
+ * kInterface
+ */
+ GuiInterface kInterface;
+
+ /*
+ * pMessageDialog
+ */
+ MessageDialog* pDialog;
+
+public:
+
+ /*
+ * Initialize
+ */
+ virtual ErrorCode Initialize(ServiceProvider* pServiceProvider);
+
+ /*
+ * Terminate
+ */
+ virtual void Terminate();
+
+ /*
+ * Update
+ */
+ virtual void Update(float fElapsed);
+
+ /*
+ * Render
+ */
+ virtual void Render(RenderContext& kContext);
+
+protected:
+
+ /*
+ * OnEnter
+ */
+ virtual void OnEnter();
+
+ /*
+ * OnExit
+ */
+ virtual void OnExit();
+
+private:
+
+ /*
+ * OnResult
+ */
+ void OnResult(GuiEventArguments& kArguments);
+};
+
+#endif //__GAMEOVERSCREEN_H__
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/GameScreen.cpp
--- a/LightClone/Source/GameScreen.cpp Tue Oct 11 13:49:40 2011 -0700
+++ b/LightClone/Source/GameScreen.cpp Tue Oct 11 17:44:10 2011 -0700
@@ -3,6 +3,7 @@
*/
#include "GameScreen.h"
+#include "ScreenManager.h"
/*
* Initialize
@@ -289,20 +290,6 @@
pBackground->Add(pButtonReset);
pBackground->Add(pButtonExit);
- pMessageDialog = new MessageDialog();
- pMessageDialog->Initialize(pServiceProvider);
- pMessageDialog->Subscribe(GuiDialog::EventResult, &GameScreen::OnResult, this);
-
- const D3DXVECTOR2& kMessageSize = pMessageDialog->GetDimensions();
- pMessageDialog->SetPosition(0.5f * ((ScreenSizeX - pBackground->GetWidth()) - kMessageSize.x), 0.5f * (ScreenSizeY - kMessageSize.y));
-
- pConfirmDialog = new ChoiceDialog();
- pConfirmDialog->Initialize(pServiceProvider);
- pConfirmDialog->Subscribe(GuiDialog::EventResult, &GameScreen::OnConfirm, this);
-
- const D3DXVECTOR2& kConfigSize = pConfirmDialog->GetDimensions();
- pConfirmDialog->SetPosition(0.5f * ((ScreenSizeX - pBackground->GetWidth()) - kConfigSize.x), 0.5f * (ScreenSizeY - kConfigSize.y));
-
pDebugText = new GuiLabel();
pDebugText->Initialize(pServiceProvider);
pDebugText->SetFont("Courier New", 16);
@@ -312,8 +299,6 @@
kInterface.Add(pBackground);
kInterface.Add(pDebugText);
- kInterface.Add(pMessageDialog);
- kInterface.Add(pConfirmDialog);
}
return eCode;
@@ -474,11 +459,7 @@
}
else
{
- pMessageDialog->SetButton(0, "Ok", 0);
- pMessageDialog->SetMessage("Congratulations!\nYou have completed the game");
- pMessageDialog->Show();
-
- nLogicState = LogicState_GameOver;
+ pScreenManager->Push("GameOver");
}
nSimulationState = SimulationState_Idle;
@@ -493,11 +474,8 @@
{
if(kEnvironment.RequirementsMet())
{
- pMessageDialog->SetButton(0, "Ok", 0);
- pMessageDialog->SetMessage("Congratulations!\nYou have completed level %d", nCurrentLevel);
- pMessageDialog->Show();
-
- nLogicState = LogicState_LevelComplete;
+ nLogicState = LogicState_LevelLoad;
+ pScreenManager->Push("LevelOver");
}
}
}
@@ -573,49 +551,5 @@
*/
void GameScreen::OnExit(GuiEventArguments& kArguments)
{
- pConfirmDialog->SetMessage("Are you sure you want to exit?");
- pConfirmDialog->SetButton(0, "Yes", DialogResult_Yes);
- pConfirmDialog->SetButton(1, "No", DialogResult_No);
- pConfirmDialog->Show();
-
- //nWorldState = WorldState_Confirm;
+ pScreenManager->Push("Confirm");
}
-
-/*
- * OnResult
- */
-void GameScreen::OnResult(GuiEventArguments& kArguments)
-{
- if(nLogicState == LogicState_LevelComplete)
- {
- nLogicState = LogicState_LevelLoad;
- }
- else
-
- if(nLogicState == LogicState_GameOver)
- {
- nCurrentLevel = 0;
- nLogicState = LogicState_LevelLoad;
-
- //TODO: Return to main menu
- //nWorldState = WorldState_Main;
- }
-}
-
-/*
- * OnConfirm
- */
-void GameScreen::OnConfirm(GuiEventArguments& kArguments)
-{
- GuiResultArguments& kResultArguments = (GuiResultArguments&)kArguments;
-
- if(kResultArguments.nResult == DialogResult_Yes)
- {
- }
- else
-
- if(kResultArguments.nResult == DialogResult_No)
- {
- //nWorldState = WorldState_Game;
- }
-}
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/GameScreen.h
--- a/LightClone/Source/GameScreen.h Tue Oct 11 13:49:40 2011 -0700
+++ b/LightClone/Source/GameScreen.h Tue Oct 11 17:44:10 2011 -0700
@@ -12,20 +12,10 @@
#include "GuiImage.h"
#include "GuiButton.h"
#include "ActionPanel.h"
-#include "Dialog.h"
#include "Loader.h"
#include "Environment.h"
#include "Bot.h"
-
-/*
- * MessageDialog
- */
-typedef Dialog<1> MessageDialog;
-
-/*
- * ChoiceDialog
- */
-typedef Dialog<2> ChoiceDialog;
+#include "Dialog.h"
/*
* GameScreen
@@ -200,16 +190,6 @@
* OnExit
*/
void OnExit(GuiEventArguments& kArguments);
-
- /*
- * OnResult
- */
- void OnResult(GuiEventArguments& kArguments);
-
- /*
- * OnConfirm
- */
- void OnConfirm(GuiEventArguments& kArguments);
};
#endif //__GAMESCREEN_H__
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/LevelOverScreen.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LightClone/Source/LevelOverScreen.cpp Tue Oct 11 17:44:10 2011 -0700
@@ -0,0 +1,81 @@
+/*
+ * LevelOverScreen
+ */
+
+#include "LevelOverScreen.h"
+#include "ScreenManager.h"
+
+/*
+ * Initialize
+ */
+ErrorCode LevelOverScreen::Initialize(ServiceProvider* pServiceProvider)
+{
+ ErrorCode eCode = kInterface.Initialize(pServiceProvider);
+ if(eCode == Error_Success)
+ {
+ pDialog = new MessageDialog();
+ pDialog->Initialize(pServiceProvider);
+ pDialog->Subscribe(GuiDialog::EventResult, &LevelOverScreen::OnResult, this);
+
+ const D3DXVECTOR2& kMessageSize = pDialog->GetDimensions();
+ pDialog->SetPosition(0.5f * ((ScreenSizeX - 280) - kMessageSize.x), 0.5f * (ScreenSizeY - kMessageSize.y));
+ }
+
+ return Error_Success;
+}
+
+/*
+ * Terminate
+ */
+void LevelOverScreen::Terminate()
+{
+ kInterface.Terminate();
+
+ Screen::Terminate();
+}
+
+/*
+ * Update
+ */
+void LevelOverScreen::Update(float fElapsed)
+{
+ kInterface.Update(fElapsed);
+}
+
+/*
+ * Render
+ */
+void LevelOverScreen::Render(RenderContext& kContext)
+{
+ kCameraController.SetMode(CameraMode_2D);
+ kInterface.Render(kContext, kCameraController);
+}
+
+/*
+ * OnEnter
+ */
+void LevelOverScreen::OnEnter()
+{
+ pDialog->SetFlag(GuiElementFlag_Visible);
+}
+
+/*
+ * OnExit
+ */
+void LevelOverScreen::OnExit()
+{
+ pDialog->ClearFlag(GuiElementFlag_Visible);
+}
+
+/*
+ * OnResult
+ */
+void LevelOverScreen::OnResult(GuiEventArguments& kArguments)
+{
+ GuiResultArguments& kResultArguments = (GuiResultArguments&)kArguments;
+
+ if(kResultArguments.nResult == DialogResult_Ok)
+ {
+ pScreenManager->Pop();
+ }
+}
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/LevelOverScreen.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LightClone/Source/LevelOverScreen.h Tue Oct 11 17:44:10 2011 -0700
@@ -0,0 +1,76 @@
+/*
+ * LevelOverScreen
+ */
+
+#ifndef __LEVELOVERSCREEN_H__
+#define __LEVELOVERSCREEN_H__
+
+#include "Core.h"
+#include "Screen.h"
+#include "CameraController.h"
+#include "GuiInterface.h"
+#include "Dialog.h"
+
+/*
+ * LevelOverScreen
+ */
+class LevelOverScreen : public Screen
+{
+ /*
+ * kCameraController
+ */
+ CameraController kCameraController;
+
+ /*
+ * kInterface
+ */
+ GuiInterface kInterface;
+
+ /*
+ * pDialog
+ */
+ MessageDialog* pDialog;
+
+public:
+
+ /*
+ * Initialize
+ */
+ virtual ErrorCode Initialize(ServiceProvider* pServiceProvider);
+
+ /*
+ * Terminate
+ */
+ virtual void Terminate();
+
+ /*
+ * Update
+ */
+ virtual void Update(float fElapsed);
+
+ /*
+ * Render
+ */
+ virtual void Render(RenderContext& kContext);
+
+protected:
+
+ /*
+ * OnEnter
+ */
+ virtual void OnEnter();
+
+ /*
+ * OnExit
+ */
+ virtual void OnExit();
+
+private:
+
+ /*
+ * OnResult
+ */
+ void OnResult(GuiEventArguments& kArguments);
+};
+
+#endif //__LEVELOVERSCREEN_H__
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/Mediator.cpp
--- a/LightClone/Source/Mediator.cpp Tue Oct 11 13:49:40 2011 -0700
+++ b/LightClone/Source/Mediator.cpp Tue Oct 11 17:44:10 2011 -0700
@@ -23,6 +23,9 @@
kScreenManager.Register("Help", &kHelpScreen);
kScreenManager.Register("Game", &kGameScreen);
kScreenManager.Register("Pause", &kPauseScreen);
+ kScreenManager.Register("LevelOver", &kLevelOverScreen);
+ kScreenManager.Register("GameOver", &kGameOverScreen);
+ kScreenManager.Register("Confirm", &kConfirmScreen);
}
/*
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/Mediator.h
--- a/LightClone/Source/Mediator.h Tue Oct 11 13:49:40 2011 -0700
+++ b/LightClone/Source/Mediator.h Tue Oct 11 17:44:10 2011 -0700
@@ -18,6 +18,9 @@
#include "HelpScreen.h"
#include "PauseScreen.h"
#include "GameScreen.h"
+#include "LevelOverScreen.h"
+#include "GameOverScreen.h"
+#include "ConfirmScreen.h"
/*
* Mediator
@@ -84,6 +87,21 @@
*/
PauseScreen kPauseScreen;
+ /*
+ * kLevelOverScreen
+ */
+ LevelOverScreen kLevelOverScreen;
+
+ /*
+ * kGameOverScreen
+ */
+ GameOverScreen kGameOverScreen;
+
+ /*
+ * kConfirmScreen
+ */
+ ConfirmScreen kConfirmScreen;
+
public:
/*
diff -r 9a9be3d8632e -r 0574e2cf8bac LightClone/Source/ScreenManager.cpp
--- a/LightClone/Source/ScreenManager.cpp Tue Oct 11 13:49:40 2011 -0700
+++ b/LightClone/Source/ScreenManager.cpp Tue Oct 11 17:44:10 2011 -0700
@@ -78,9 +78,16 @@
{
bDirty = false;
- for(int32 i = kStack.Size() - 1; i >= 0 && !bDirty; --i)
+ //for(int32 i = kStack.Size() - 1; i >= 0 && !bDirty; --i)
+ //{
+ // kStack[i]->Update(fElapsed);
+ //}
+ if(kStack.Size() > 0)
{
- kStack[i]->Update(fElapsed);
+ Screen* pTop = kStack.Peek();
+ ASSERT(pTop != NULL);
+
+ pTop->Update(fElapsed);
}
}