changeset 34:7f5feeb3f604

Implemented reset functionality
author koryspansel <koryspansel@bendbroadband.com>
date Wed, 21 Sep 2011 01:20:58 -0700
parents 06b151afc8d0
children 4750819f465d
files LightClone/Source/CodePanel.cpp LightClone/Source/CodePanel.h LightClone/Source/GuiButton.cpp LightClone/Source/World.cpp
diffstat 4 files changed, 55 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/LightClone/Source/CodePanel.cpp	Wed Sep 21 00:50:20 2011 -0700
+++ b/LightClone/Source/CodePanel.cpp	Wed Sep 21 01:20:58 2011 -0700
@@ -54,15 +54,27 @@
 }
 
 /*
+ * Clear
+ */
+void CodePanel::Clear()
+{
+	const uint32 nCount = nSizeX * nSizeY;
+
+	for(uint32 i = 0; i < nCount; ++i)
+	{
+		pSlot[i]->SetAction(Action_Default);
+	}
+}
+
+/*
  * SetPermanent
  */
 void CodePanel::SetPermanent(bool bPermanent)
 {
-	for(uint32 i = 0; i < nSizeY; ++i)
+	const uint32 nCount = nSizeX * nSizeY;
+
+	for(uint32 i = 0; i < nCount; ++i)
 	{
-		for(uint32 j = 0; j < nSizeX; ++j)
-		{
-			pSlot[i * nSizeX + j]->SetPermanent(bPermanent);
-		}
+		pSlot[i]->SetPermanent(bPermanent);
 	}
 }
\ No newline at end of file
--- a/LightClone/Source/CodePanel.h	Wed Sep 21 00:50:20 2011 -0700
+++ b/LightClone/Source/CodePanel.h	Wed Sep 21 01:20:58 2011 -0700
@@ -51,6 +51,11 @@
 	void SetSlot(uint32 nSlot, uint32 nAction);
 
 	/*
+	 * Clear
+	 */
+	void Clear();
+
+	/*
 	 * SetPermanent
 	 */
 	void SetPermanent(bool bPermanent);
--- a/LightClone/Source/GuiButton.cpp	Wed Sep 21 00:50:20 2011 -0700
+++ b/LightClone/Source/GuiButton.cpp	Wed Sep 21 01:20:58 2011 -0700
@@ -115,8 +115,8 @@
 					nOffsetY += 2;
 				}
 
-				const int32 nX		= (int32)(kLocation.x + 0.5f * kDimensions.x) + nOffsetX;
-				const int32 nY		= (int32)(kLocation.y + 0.5f * kDimensions.y) + nOffsetY;
+				const int32 nX		= (int32)(kLocation.x + 0.5f * kDimensions.x + 1) + nOffsetX;
+				const int32 nY		= (int32)(kLocation.y + 0.5f * kDimensions.y + 0) + nOffsetY;
 
 				RECT kRectangle;
 				kRectangle.left		= nX;
--- a/LightClone/Source/World.cpp	Wed Sep 21 00:50:20 2011 -0700
+++ b/LightClone/Source/World.cpp	Wed Sep 21 01:20:58 2011 -0700
@@ -269,16 +269,37 @@
 		pToolbar->SetSlot(6, Action_FunctionB);
 		pToolbar->SetPermanent(true);
 
+		GuiLabel* pMainLabel = new GuiLabel();
+		pMainLabel->Initialize(pResourceManager);
+		pMainLabel->SetFont("Courier New", 16);
+		pMainLabel->SetText("Main:");
+		pMainLabel->SetColor(D3DCOLOR_XRGB(0, 0, 0));
+		pMainLabel->SetPosition(26.0f, 149.0f);
+
 		pMain = new CodePanel(4, 3);
 		pMain->Initialize(pResourceManager);
 		pMain->SetTexture("Data\\Textures\\PanelB.png");
 		pMain->SetPosition(16.0f, 160.0f);
 
+		GuiLabel* pFunctionALabel = new GuiLabel();
+		pFunctionALabel->Initialize(pResourceManager);
+		pFunctionALabel->SetFont("Courier New", 16);
+		pFunctionALabel->SetText("Function 1:");
+		pFunctionALabel->SetColor(D3DCOLOR_XRGB(0, 0, 0));
+		pFunctionALabel->SetPosition(26.0f, 349.0f);
+
 		pFunctionA = new CodePanel(4, 2);
 		pFunctionA->Initialize(pResourceManager);
 		pFunctionA->SetTexture("Data\\Textures\\PanelA.png");
 		pFunctionA->SetPosition(16.0f, 360.0f);
 
+		GuiLabel* pFunctionBLabel = new GuiLabel();
+		pFunctionBLabel->Initialize(pResourceManager);
+		pFunctionBLabel->SetFont("Courier New", 16);
+		pFunctionBLabel->SetText("Function 2:");
+		pFunctionBLabel->SetColor(D3DCOLOR_XRGB(0, 0, 0));
+		pFunctionBLabel->SetPosition(26.0f, 493.0f);
+
 		pFunctionB = new CodePanel(4, 2);
 		pFunctionB->Initialize(pResourceManager);
 		pFunctionB->SetTexture("Data\\Textures\\PanelA.png");
@@ -293,7 +314,7 @@
 		pButtonPlay->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true);
 		pButtonPlay->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true);
 		pButtonPlay->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true);
-		pButtonPlay->SetFont("Courier New", 16);
+		pButtonPlay->SetFont("Courier New", 16, FW_BOLD);
 		pButtonPlay->SetText("Play");
 		pButtonPlay->SetColor(D3DCOLOR_XRGB(0, 0, 0));
 		pButtonPlay->SetPosition(fButtonPadding + 0.0f * (fButtonSize + fButtonSpacing), 652.0f);
@@ -304,7 +325,7 @@
 		pButtonStop->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true);
 		pButtonStop->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true);
 		pButtonStop->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true);
-		pButtonStop->SetFont("Courier New", 16);
+		pButtonStop->SetFont("Courier New", 16, FW_BOLD);
 		pButtonStop->SetText("Stop");
 		pButtonStop->SetColor(D3DCOLOR_XRGB(0, 0, 0));
 		pButtonStop->SetPosition(fButtonPadding + 1.0f * (fButtonSize + fButtonSpacing), 652.0f);
@@ -315,7 +336,7 @@
 		pButtonReset->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true);
 		pButtonReset->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true);
 		pButtonReset->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true);
-		pButtonReset->SetFont("Courier New", 16);
+		pButtonReset->SetFont("Courier New", 16, FW_BOLD);
 		pButtonReset->SetText("Reset");
 		pButtonReset->SetColor(D3DCOLOR_XRGB(0, 0, 0));
 		pButtonReset->SetPosition(fButtonPadding + 2.0f * (fButtonSize + fButtonSpacing), 652.0f);
@@ -326,25 +347,18 @@
 		pButtonExit->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true);
 		pButtonExit->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true);
 		pButtonExit->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true);
-		pButtonExit->SetFont("Courier New", 16);
+		pButtonExit->SetFont("Courier New", 16, FW_BOLD);
 		pButtonExit->SetText("Exit");
 		pButtonExit->SetColor(D3DCOLOR_XRGB(0, 0, 0));
 		pButtonExit->SetPosition(fButtonPadding + 3.0f * (fButtonSize + fButtonSpacing), 652.0f);
 		pButtonExit->Subscribe(GuiButton::EventClick, &World::OnExit, this);
 
-		/*
-		GuiLabel*
-		pLabel = new GuiLabel();
-		pLabel->Initialize(pResourceManager);
-		pLabel->SetFont("Courier New", 16);
-		pLabel->SetText("This is a test!");
-		pLabel->SetFlags(GuiLabelFlag_CenterX | GuiLabelFlag_CenterY);
-		pLabel->SetPosition(0.5f * ScreenSizeX, 0.5f * ScreenSizeY);
-		*/
-
 		pBackground->Add(pToolbar);
+		pBackground->Add(pMainLabel);
 		pBackground->Add(pMain);
+		pBackground->Add(pFunctionALabel);
 		pBackground->Add(pFunctionA);
+		pBackground->Add(pFunctionBLabel);
 		pBackground->Add(pFunctionB);
 		pBackground->Add(pButtonPlay);
 		pBackground->Add(pButtonStop);
@@ -680,6 +694,9 @@
  */
 void World::OnReset(GuiEventArguments& kArguments)
 {
+	pMain->Clear();
+	pFunctionA->Clear();
+	pFunctionB->Clear();
 }
 
 /*