diff LightClone/Source/ConfirmScreen.cpp @ 73:0574e2cf8bac

Additional screen types
author koryspansel
date Tue, 11 Oct 2011 17:44:10 -0700
parents
children 40c0b5305de8
line wrap: on
line diff
--- /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();
+	}
+}