# HG changeset patch # User koryspansel # Date 1316720082 25200 # Node ID 6790cf9e8bd84733bbbb212813d38f2a9d83a029 # Parent d27c06bd8ce13a983b25f960dde42323e16e6210 Game works from start to finish diff -r d27c06bd8ce1 -r 6790cf9e8bd8 LightClone/Source/Dialog.h --- 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::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); diff -r d27c06bd8ce1 -r 6790cf9e8bd8 LightClone/Source/GuiElement.cpp --- 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; + } } } } diff -r d27c06bd8ce1 -r 6790cf9e8bd8 LightClone/Source/World.cpp --- 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; } diff -r d27c06bd8ce1 -r 6790cf9e8bd8 LightClone/Source/World.h --- 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: