changeset 44:6790cf9e8bd8

Game works from start to finish
author koryspansel <koryspansel@bendbroadband.com>
date Thu, 22 Sep 2011 12:34:42 -0700
parents d27c06bd8ce1
children 50def8c971d9
files LightClone/Source/Dialog.h LightClone/Source/GuiElement.cpp LightClone/Source/World.cpp LightClone/Source/World.h
diffstat 4 files changed, 29 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/LightClone/Source/Dialog.h	Thu Sep 22 10:47:05 2011 -0700
+++ b/LightClone/Source/Dialog.h	Thu Sep 22 12:34:42 2011 -0700
@@ -79,10 +79,13 @@
 				kButton[i].SetTexture(GuiButtonState_Down, "Data\\Textures\\ButtonD.tga");
 				kButton[i].SetFont("Courier New", 16);
 				kButton[i].SetColor(D3DCOLOR_XRGB(0, 0, 0));
-				kButton[i].Subscribe(GuiButton::EventClick, &Dialog::OnClick, this);
+				kButton[i].Subscribe(GuiButton::EventClick, &Dialog<ButtonCount>::OnClick, this);
 
-				const float fX	= ((i + 1) * kDimensions.x / (float)(ButtonCount + 1)) - 0.5f * kButton[i].GetDimensions().x;
-				const float fY	= 0.65f * kDimensions.y;
+				// assumes all buttons are equally sized
+				const float fWidth		= kButton[i].GetDimensions().x;
+				const float fPadding	= (kDimensions.x - ButtonCount * fWidth) / (float)(ButtonCount + 1);
+				const float fX			= fPadding + i * (fWidth + fPadding);
+				const float fY			= 0.65f * kDimensions.y;
 
 				kButton[i].SetPosition(fX, fY);
 
--- a/LightClone/Source/GuiElement.cpp	Thu Sep 22 10:47:05 2011 -0700
+++ b/LightClone/Source/GuiElement.cpp	Thu Sep 22 12:34:42 2011 -0700
@@ -213,21 +213,24 @@
 {
 	GuiElement* pElement = NULL;
 
-	for(int32 i = (int32)kChildren.Size() - 1; i >= 0 && !pElement; --i)
+	if(HasFlag(GuiElementFlag_Visible))
 	{
-		if(kChildren[i]->Contains(fX, fY))
+		for(int32 i = (int32)kChildren.Size() - 1; i >= 0 && !pElement; --i)
 		{
-			pElement = kChildren[i]->Pick(fX, fY);
+			if(kChildren[i]->Contains(fX, fY))
+			{
+				pElement = kChildren[i]->Pick(fX, fY);
+			}
 		}
-	}
 
-	if(!pElement)
-	{
-		if(HasFlag(GuiElementFlag_Visible | GuiElementFlag_Pickable))
+		if(!pElement)
 		{
-			if(Contains(fX, fY))
+			if(HasFlag(GuiElementFlag_Pickable))
 			{
-				pElement = this;
+				if(Contains(fX, fY))
+				{
+					pElement = this;
+				}
 			}
 		}
 	}
--- a/LightClone/Source/World.cpp	Thu Sep 22 10:47:05 2011 -0700
+++ b/LightClone/Source/World.cpp	Thu Sep 22 12:34:42 2011 -0700
@@ -164,7 +164,7 @@
 				if(kEnvironment.RequirementsMet())
 				{
 					kMessageDialog.SetButton(0, "Ok", 0);
-					kMessageDialog.SetMessage("Congratulations!\nYou have completed level XX");
+					kMessageDialog.SetMessage("Congratulations!\nYou have completed level %d", nCurrentLevel);
 					kMessageDialog.Show();
 
 					nGameState = GameState_Complete;
@@ -344,15 +344,15 @@
 		const D3DXVECTOR2& kMessageSize = kMessageDialog.GetDimensions();
 		kMessageDialog.SetPosition(0.5f * ((ScreenSizeX - pBackground->GetWidth()) - kMessageSize.x), 0.5f * (ScreenSizeY - kMessageSize.y));
 
-		kConfigDialog.Initialize(pResourceManager);
-		kConfigDialog.Subscribe(GuiDialog::EventResult, &World::OnConfirm, this);
+		kConfirmDialog.Initialize(pResourceManager);
+		kConfirmDialog.Subscribe(GuiDialog::EventResult, &World::OnConfirm, this);
 
 		const D3DXVECTOR2& kConfigSize = kMessageDialog.GetDimensions();
-		kConfigDialog.SetPosition(0.5f * ((ScreenSizeX - pBackground->GetWidth()) - kConfigSize.x), 0.5f * (ScreenSizeY - kConfigSize.y));
+		kConfirmDialog.SetPosition(0.5f * ((ScreenSizeX - pBackground->GetWidth()) - kConfigSize.x), 0.5f * (ScreenSizeY - kConfigSize.y));
 
 		kInterface.Add(pBackground);
 		kInterface.Add(&kMessageDialog);
-		kInterface.Add(&kConfigDialog);
+		kInterface.Add(&kConfirmDialog);
 	}
 
 	return eCode;
@@ -495,6 +495,11 @@
  */
 void World::OnExit(GuiEventArguments& kArguments)
 {
+	kConfirmDialog.SetMessage("Are you sure you want to exit?");
+	kConfirmDialog.SetButton(0, "Yes", DialogResult_Yes);
+	kConfirmDialog.SetButton(1, "No", DialogResult_No);
+	kConfirmDialog.Show();
+
 	nGameStatePrevious	= nGameState;
 	nGameState			= GameState_Confirm;
 }
--- a/LightClone/Source/World.h	Thu Sep 22 10:47:05 2011 -0700
+++ b/LightClone/Source/World.h	Thu Sep 22 12:34:42 2011 -0700
@@ -133,7 +133,7 @@
 	/*
 	 * kConfirmDialog
 	 */
-	Dialog<2> kConfigDialog;
+	Dialog<2> kConfirmDialog;
 
 public: