changeset 33:06b151afc8d0

Cleaned up UI art; Completed drag and drop; Centered grid
author koryspansel <koryspansel@bendbroadband.com>
date Wed, 21 Sep 2011 00:50:20 -0700
parents c227be6a15fe
children 7f5feeb3f604
files Assets/UI/Background03.PSD Assets/UI/Button1D.PSD Assets/UI/Button1H.PSD Assets/UI/Button1N.PSD Assets/UI/PanelA.PSD Assets/UI/PanelB.PSD Assets/UI/Toolbar.PSD Data/Textures/Background03.tga Data/Textures/Button1D.png Data/Textures/Button1H.png Data/Textures/Button1N.png Data/Textures/PanelA.png Data/Textures/PanelA.tga Data/Textures/PanelB.png Data/Textures/PanelB.tga LightClone/Source/CodePanel.cpp LightClone/Source/CodePanel.h LightClone/Source/CodeSlot.cpp LightClone/Source/CodeSlot.h LightClone/Source/Environment.cpp LightClone/Source/GraphicsDevice.cpp LightClone/Source/GraphicsDevice.h LightClone/Source/GuiButton.cpp LightClone/Source/GuiButton.h LightClone/Source/GuiElement.cpp LightClone/Source/GuiElement.h LightClone/Source/HashMap.h LightClone/Source/RenderContext.cpp LightClone/Source/RenderContext.h LightClone/Source/World.cpp LightClone/Source/World.h
diffstat 31 files changed, 197 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
Binary file Assets/UI/Background03.PSD has changed
Binary file Assets/UI/Button1D.PSD has changed
Binary file Assets/UI/Button1H.PSD has changed
Binary file Assets/UI/Button1N.PSD has changed
Binary file Assets/UI/PanelA.PSD has changed
Binary file Assets/UI/PanelB.PSD has changed
Binary file Assets/UI/Toolbar.PSD has changed
Binary file Data/Textures/Background03.tga has changed
Binary file Data/Textures/Button1D.png has changed
Binary file Data/Textures/Button1H.png has changed
Binary file Data/Textures/Button1N.png has changed
Binary file Data/Textures/PanelA.png has changed
Binary file Data/Textures/PanelA.tga has changed
Binary file Data/Textures/PanelB.png has changed
Binary file Data/Textures/PanelB.tga has changed
--- a/LightClone/Source/CodePanel.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/CodePanel.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -25,8 +25,6 @@
 	ErrorCode eCode = GuiImage::Initialize(pResourceManager);
 	if(eCode == Error_Success)
 	{
-		//SetTexture("Data\\Textures\\Slot.tga");
-		SetTexture("Data\\Textures\\Panel.tga");
 		SetDimensions(2.0f * fSlotPadding + (fSlotSizeX + fSlotSpacing) * nSizeX - fSlotSpacing, 2.0f * fSlotPadding + (fSlotSizeY + fSlotSpacing) * nSizeY - fSlotSpacing);
 
 		for(uint32 i = 0; i < nSizeY; ++i)
@@ -53,4 +51,18 @@
 void CodePanel::SetSlot(uint32 nSlot, uint32 nAction)
 {
 	pSlot[nSlot]->SetAction(nAction);
+}
+
+/*
+ * SetPermanent
+ */
+void CodePanel::SetPermanent(bool bPermanent)
+{
+	for(uint32 i = 0; i < nSizeY; ++i)
+	{
+		for(uint32 j = 0; j < nSizeX; ++j)
+		{
+			pSlot[i * nSizeX + j]->SetPermanent(bPermanent);
+		}
+	}
 }
\ No newline at end of file
--- a/LightClone/Source/CodePanel.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/CodePanel.h	Wed Sep 21 00:50:20 2011 -0700
@@ -49,6 +49,11 @@
 	 * SetSlot
 	 */
 	void SetSlot(uint32 nSlot, uint32 nAction);
+
+	/*
+	 * SetPermanent
+	 */
+	void SetPermanent(bool bPermanent);
 };
 
 #endif //__CODEPANEL_H__
--- a/LightClone/Source/CodeSlot.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/CodeSlot.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -23,12 +23,9 @@
 /*
  * CodeSlot
  */
-CodeSlot::CodeSlot() : GuiImage()
+CodeSlot::CodeSlot() : GuiImage(), nAction(Action_Default), bPermanent(false)
 {
 	SetFlag(GuiElementFlag_Pickable);
-
-	nAction		= Action_Default;
-	bMouseDown	= false;
 }
 
 /*
@@ -71,13 +68,20 @@
 }
 
 /*
+ * SetPermanent
+ */
+void CodeSlot::SetPermanent(bool bValue)
+{
+	bPermanent = bValue;
+}
+
+/*
  * OnMouseDown
  */
 void CodeSlot::OnMouseDown(uint32 nButton, float fX, float fY)
 {
 	if(nButton == MouseButton_Left)
 	{
-		bMouseDown = true;
 		pInterface->AcquireCursor(this);
 	}
 }
@@ -87,8 +91,6 @@
  */
 void CodeSlot::OnMouseUp(uint32 nButton, float fX, float fY)
 {
-	bMouseDown = false;
-	
 	if(pInterface->IsCursorAcquiredBy(this))
 	{
 		pInterface->ReleaseCursor();
@@ -100,11 +102,15 @@
  */
 void CodeSlot::OnMouseMove(float fX, float fY)
 {
-	//if(bMouseDown)
 	if(pInterface->IsCursorAcquiredBy(this))
 	{
+		pInterface->ReleaseCursor();
+
 		if(nAction != Action_Default)
 		{
+			//TODO: Figure out some other way of doing this
+
+			// create a new element to represent the object being dragged
 			CodeSlot* pInstance = new CodeSlot();
 			pInstance->Initialize(pResourceManager);
 			pInstance->SetAction(nAction);
@@ -112,10 +118,15 @@
 			pInstance->SetPosition(kPosition);
 			pInstance->SetInterface(pInterface);
 
-			//CodeSlot* pInstance = Clone();
+			// let the interface and cursor manage the drag object
+			pInterface->BeginDrag(pInstance, MouseButton_Left);
 
-			pInterface->ReleaseCursor();
-			pInterface->BeginDrag(pInstance, MouseButton_Left);
+			// if this slot is always suppose to have a valid action, do
+			// not clear out the current action
+			if(!bPermanent)
+			{
+				SetAction(Action_Default);
+			}
 		}
 	}
 }
@@ -125,12 +136,5 @@
  */
 void CodeSlot::OnDrop(GuiElement* pSource, float fX, float fY)
 {
-	if(true) // pSource is a CodeSlot
-	{
-		uint32 nAction = ((CodeSlot*)pSource)->nAction;
-
-		if(nAction != Action_Default)
-		{
-		}
-	}
+	SetAction(((CodeSlot*)pSource)->nAction);
 }
--- a/LightClone/Source/CodeSlot.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/CodeSlot.h	Wed Sep 21 00:50:20 2011 -0700
@@ -14,15 +14,15 @@
 class CodeSlot : public GuiImage
 {
 	/*
-	 * bMouseDown
-	 */
-	bool bMouseDown;
-
-	/*
 	 * nAction
 	 */
 	uint32 nAction;
 
+	/*
+	 * bPermanent
+	 */
+	bool bPermanent;
+
 public:
 
 	/*
@@ -50,6 +50,11 @@
 	 */
 	uint32 GetAction() const;
 
+	/*
+	 * SetPermanent
+	 */
+	void SetPermanent(bool bPermanent);
+
 protected:
 
 	/*
--- a/LightClone/Source/Environment.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/Environment.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -118,8 +118,8 @@
 	const float fMagicOffset = 400.0f;
 	//const D3DXVECTOR3& kCenterWorld = ComputeOrigin(0.5f * (ScreenSizeX - (304.0f + fMagicOffset)), 0.5f * ScreenSizeY, kViewport, kProjection, kView);
 
-	const float fOffsetX	= -0.5f * (nWidth * kScale.x);
-	const float fOffsetZ	= -0.5f * (nHeight * kScale.z);
+	const float fOffsetX	= -0.5f * ((nWidth - 1) * kScale.x);
+	const float fOffsetZ	= -0.5f * ((nHeight - 1) * kScale.z);
 
 	for(uint32 nZ = 0; nZ < nHeight; ++nZ)
 	{
--- a/LightClone/Source/GraphicsDevice.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/GraphicsDevice.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -102,6 +102,14 @@
 }
 
 /*
+ * SetViewport
+ */
+ErrorCode GraphicsDevice::SetViewport(const D3DVIEWPORT9& kViewport)
+{
+	return SUCCEEDED(pDevice->SetViewport(&kViewport)) ? Error_Success : Error_Fail;
+}
+
+/*
  * GetViewport
  */
 ErrorCode GraphicsDevice::GetViewport(D3DVIEWPORT9* pViewport)
--- a/LightClone/Source/GraphicsDevice.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/GraphicsDevice.h	Wed Sep 21 00:50:20 2011 -0700
@@ -50,6 +50,11 @@
 	static void Destroy(GraphicsDevice*& pDevice);
 
 	/*
+	 * SetViewport
+	 */
+	ErrorCode SetViewport(const D3DVIEWPORT9& kViewport);
+
+	/*
 	 * GetViewport
 	 */
 	ErrorCode GetViewport(D3DVIEWPORT9* pViewport);
--- a/LightClone/Source/GuiButton.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/GuiButton.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -106,8 +106,17 @@
 
 			if(pFont && kText.Length() > 0)
 			{
-				const int32 nX		= (int32)(kLocation.x + 0.5f * kDimensions.x);
-				const int32 nY		= (int32)(kLocation.y + 0.5f * kDimensions.y);
+				int32 nOffsetX		= 0;
+				int32 nOffsetY		= 0;
+
+				if(nState == GuiButtonState_Down)
+				{
+					nOffsetX += 1;
+					nOffsetY += 2;
+				}
+
+				const int32 nX		= (int32)(kLocation.x + 0.5f * kDimensions.x) + nOffsetX;
+				const int32 nY		= (int32)(kLocation.y + 0.5f * kDimensions.y) + nOffsetY;
 
 				RECT kRectangle;
 				kRectangle.left		= nX;
--- a/LightClone/Source/GuiButton.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/GuiButton.h	Wed Sep 21 00:50:20 2011 -0700
@@ -104,7 +104,7 @@
 	/*
 	 * SetFont
 	 */
-	ErrorCode SetFont(const char* pName, uint32 nSize, uint32 nHeight = FW_NORMAL);
+	ErrorCode SetFont(const char* pName, uint32 nSize, uint32 nWeight = FW_NORMAL);
 
 	/*
 	 * SetText
--- a/LightClone/Source/GuiElement.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/GuiElement.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -194,6 +194,14 @@
 }
 
 /*
+ * SetColor
+ */
+void GuiElement::SetColor(D3DCOLOR nColor)
+{
+	kColor = nColor;
+}
+
+/*
  * Pick
  */
 GuiElement* GuiElement::Pick(float fX, float fY)
--- a/LightClone/Source/GuiElement.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/GuiElement.h	Wed Sep 21 00:50:20 2011 -0700
@@ -188,6 +188,11 @@
 	bool IsVisible() const;
 
 	/*
+	 * SetColor
+	 */
+	void SetColor(D3DCOLOR nColor);
+
+	/*
 	 * Pick
 	 */
 	virtual GuiElement* Pick(float fX, float fY);
--- a/LightClone/Source/HashMap.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/HashMap.h	Wed Sep 21 00:50:20 2011 -0700
@@ -199,7 +199,7 @@
 				return &pNode->kValue;
 			}
 			
-			++pNode;
+			pNode = pNode->pNext;
 		}
 
 		return NULL;
--- a/LightClone/Source/RenderContext.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/RenderContext.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -197,6 +197,14 @@
 }
 
 /*
+ * SetViewport
+ */
+ErrorCode RenderContext::SetViewport(const D3DVIEWPORT9& kViewport)
+{
+	return pGraphicsDevice->SetViewport(kViewport);
+}
+
+/*
  * GetViewport
  */
 ErrorCode RenderContext::GetViewport(D3DVIEWPORT9* pViewport)
--- a/LightClone/Source/RenderContext.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/RenderContext.h	Wed Sep 21 00:50:20 2011 -0700
@@ -87,6 +87,11 @@
 	void DrawTriangles(IDirect3DVertexDeclaration9* pDeclaration, IDirect3DVertexBuffer9* pBuffer, uint32 nSize, uint32 nCount);
 
 	/*
+	 * SetViewport
+	 */
+	ErrorCode SetViewport(const D3DVIEWPORT9& kViewport);
+
+	/*
 	 * GetViewport
 	 */
 	ErrorCode GetViewport(D3DVIEWPORT9* pViewport);
--- a/LightClone/Source/World.cpp	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/World.cpp	Wed Sep 21 00:50:20 2011 -0700
@@ -11,7 +11,7 @@
 /*
  * World
  */
-World::World() //: kToolbar(8), kMain(16), kFunction(8)
+World::World()
 {
 	nGameState				= GameState_Active;
 	nSimulationState		= SimulationState_Idle;
@@ -218,9 +218,24 @@
 	//TODO: Remove
 	if(nGameState >= GameState_Active)
 	{
+		D3DVIEWPORT9 kOriginal;
+		kContext.GetViewport(&kOriginal);
+
+		D3DVIEWPORT9 kViewport;
+		kViewport.X			= 0;
+		kViewport.Y			= 0;
+		kViewport.Width		= ScreenSizeX - 280;
+		kViewport.Height	= ScreenSizeY;
+		kViewport.MinZ		= kOriginal.MinZ;
+		kViewport.MaxZ		= kOriginal.MaxZ;
+
+		kContext.SetViewport(kViewport);
+
 		kCameraController.SetMode(CameraMode_3D);
 		Render3D(kContext);
 
+		kContext.SetViewport(kOriginal);
+
 		kCameraController.SetMode(CameraMode_2D);
 		Render2D(kContext);
 	}
@@ -238,12 +253,13 @@
 	{
 		pBackground = new GuiImage();
 		pBackground->Initialize(pResourceManager);
-		pBackground->SetTexture("Data\\Textures\\Background01.tga", true);
+		pBackground->SetTexture("Data\\Textures\\Background03.tga", true);
 		pBackground->SetPosition(ScreenSizeX - pBackground->GetWidth(), 0.0f);
 
 		pToolbar = new CodePanel(4, 2);
 		pToolbar->Initialize(pResourceManager);
-		pToolbar->SetPosition(1004.0f, 69.0f);
+		pToolbar->SetTexture("Data\\Textures\\PanelA.png");
+		pToolbar->SetPosition(16, 16.0f);
 		pToolbar->SetSlot(0, Action_Forward);
 		pToolbar->SetSlot(1, Action_RotateCW);
 		pToolbar->SetSlot(2, Action_RotateCCW);
@@ -251,37 +267,69 @@
 		pToolbar->SetSlot(4, Action_Light);
 		pToolbar->SetSlot(5, Action_FunctionA);
 		pToolbar->SetSlot(6, Action_FunctionB);
+		pToolbar->SetPermanent(true);
+
+		pMain = new CodePanel(4, 3);
+		pMain->Initialize(pResourceManager);
+		pMain->SetTexture("Data\\Textures\\PanelB.png");
+		pMain->SetPosition(16.0f, 160.0f);
+
+		pFunctionA = new CodePanel(4, 2);
+		pFunctionA->Initialize(pResourceManager);
+		pFunctionA->SetTexture("Data\\Textures\\PanelA.png");
+		pFunctionA->SetPosition(16.0f, 360.0f);
+
+		pFunctionB = new CodePanel(4, 2);
+		pFunctionB->Initialize(pResourceManager);
+		pFunctionB->SetTexture("Data\\Textures\\PanelA.png");
+		pFunctionB->SetPosition(16.0f, 504.0f);
+
+		const float fButtonPadding	= 32.0f;
+		const float fButtonSpacing	= 8.0f;
+		const float fButtonSize		= 48.0f;
 
 		pButtonPlay = new GuiButton();
 		pButtonPlay->Initialize(pResourceManager);
-		pButtonPlay->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Play.tga", true);
-		pButtonPlay->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Play.tga", true);
-		pButtonPlay->SetTexture(GuiButtonState_Down, "Data\\Textures\\Play.tga", true);
-		pButtonPlay->SetPosition(1023.0f + 0.0f * 54.0f, 640.0f);
+		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->SetText("Play");
+		pButtonPlay->SetColor(D3DCOLOR_XRGB(0, 0, 0));
+		pButtonPlay->SetPosition(fButtonPadding + 0.0f * (fButtonSize + fButtonSpacing), 652.0f);
 		pButtonPlay->Subscribe(GuiButton::EventClick, &World::OnPlay, this);
 
 		pButtonStop = new GuiButton();
 		pButtonStop->Initialize(pResourceManager);
-		pButtonStop->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Stop.tga", true);
-		pButtonStop->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Stop.tga", true);
-		pButtonStop->SetTexture(GuiButtonState_Down, "Data\\Textures\\Stop.tga", true);
-		pButtonStop->SetPosition(1023.0f + 1.0f * 54.0f, 640.0f);
+		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->SetText("Stop");
+		pButtonStop->SetColor(D3DCOLOR_XRGB(0, 0, 0));
+		pButtonStop->SetPosition(fButtonPadding + 1.0f * (fButtonSize + fButtonSpacing), 652.0f);
 		pButtonStop->Subscribe(GuiButton::EventClick, &World::OnStop, this);
 
-		/*
 		pButtonReset = new GuiButton();
 		pButtonReset->Initialize(pResourceManager);
-		pButtonReset->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Reset.tga", true);
-		pButtonReset->SetPosition(1023.0f + 2.0f * 54.0f, 640.0f.0f);
+		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->SetText("Reset");
+		pButtonReset->SetColor(D3DCOLOR_XRGB(0, 0, 0));
+		pButtonReset->SetPosition(fButtonPadding + 2.0f * (fButtonSize + fButtonSpacing), 652.0f);
 		pButtonReset->Subscribe(GuiButton::EventClick, &World::OnReset, this);
-		*/
 
 		pButtonExit = new GuiButton();
 		pButtonExit->Initialize(pResourceManager);
-		pButtonExit->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Exit.tga", true);
-		pButtonExit->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Stop.tga", true);
-		pButtonExit->SetTexture(GuiButtonState_Down, "Data\\Textures\\Play.tga", true);
-		pButtonExit->SetPosition(1023.0f + 3.0f * 54.0f, 640.0f);
+		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->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);
 
 		/*
@@ -294,6 +342,15 @@
 		pLabel->SetPosition(0.5f * ScreenSizeX, 0.5f * ScreenSizeY);
 		*/
 
+		pBackground->Add(pToolbar);
+		pBackground->Add(pMain);
+		pBackground->Add(pFunctionA);
+		pBackground->Add(pFunctionB);
+		pBackground->Add(pButtonPlay);
+		pBackground->Add(pButtonStop);
+		pBackground->Add(pButtonReset);
+		pBackground->Add(pButtonExit);
+
 		pLevelDialog = new GuiImage();
 		pLevelDialog->Initialize(pResourceManager);
 		pLevelDialog->ClearFlag(GuiElementFlag_Visible);
@@ -329,11 +386,6 @@
 		pGameDialog->Add(pGameDialogOk);
 
 		kInterface.Add(pBackground);
-		kInterface.Add(pToolbar);
-		kInterface.Add(pButtonPlay);
-		kInterface.Add(pButtonStop);
-		//kInterface.Add(pButtonReset);
-		kInterface.Add(pButtonExit);
 		kInterface.Add(pLevelDialog);
 		kInterface.Add(pGameDialog);
 	}
--- a/LightClone/Source/World.h	Tue Sep 20 21:26:22 2011 -0700
+++ b/LightClone/Source/World.h	Wed Sep 21 00:50:20 2011 -0700
@@ -116,6 +116,21 @@
 	CodePanel* pToolbar;
 
 	/*
+	 * pMain
+	 */
+	CodePanel* pMain;
+
+	/*
+	 * pFunctionA
+	 */
+	CodePanel* pFunctionA;
+
+	/*
+	 * pFunctionB
+	 */
+	CodePanel* pFunctionB;
+
+	/*
 	 * pLevelDialog
 	 */
 	GuiImage* pLevelDialog;