# HG changeset patch # User koryspansel # Date 1317448083 25200 # Node ID 63806b850aa523231c0dd6cfcfca16a92cfa794e # Parent 5e382dee4c70f1ef955dd0578fe709eeafc96ff6 Rename ProgramPanel to ActionPanel diff -r 5e382dee4c70 -r 63806b850aa5 LightClone/LightClone.vcproj --- a/LightClone/LightClone.vcproj Fri Sep 30 22:39:08 2011 -0700 +++ b/LightClone/LightClone.vcproj Fri Sep 30 22:48:03 2011 -0700 @@ -183,6 +183,10 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -219,10 +223,6 @@ > - - @@ -329,6 +329,10 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + @@ -365,10 +369,6 @@ > - - diff -r 5e382dee4c70 -r 63806b850aa5 LightClone/Source/ActionPanel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/ActionPanel.cpp Fri Sep 30 22:48:03 2011 -0700 @@ -0,0 +1,115 @@ +/* + * ActionPanel + */ + +#include "ActionPanel.h" + +/* + * EventAction + */ +const char* ActionPanel::EventAction = "ActionPanel:EventAction"; + +/* + * ActionPanel + */ +ActionPanel::ActionPanel(uint32 nWidth, uint32 nHeight) : GuiImage(), nSizeX(nWidth), nSizeY(nHeight) +{ + pSlot = new ActionSlot[nSizeX * nSizeY]; +} + +/* + * Initialize + */ +ErrorCode ActionPanel::Initialize(ResourceManager* pResourceManager) +{ + const float fSlotSizeX = 48.0f; + const float fSlotSizeY = 48.0f; + const float fSlotPadding = 16.0f; + const float fSlotSpacing = 8.0f; + + ErrorCode eCode = GuiImage::Initialize(pResourceManager); + if(eCode == Error_Success) + { + SetDimensions(2.0f * fSlotPadding + (fSlotSizeX + fSlotSpacing) * nSizeX - fSlotSpacing, 2.0f * fSlotPadding + (fSlotSizeY + fSlotSpacing) * nSizeY - fSlotSpacing); + + for(uint32 i = 0; i < nSizeY; ++i) + { + for(uint32 j = 0; j < nSizeX; ++j) + { + const uint32 nIndex = i * nSizeX + j; + + pSlot[nIndex].Initialize(pResourceManager); + pSlot[nIndex].SetTexture("Data\\Textures\\Slot.tga"); + pSlot[nIndex].SetDimensions(fSlotSizeX, fSlotSizeY); + pSlot[nIndex].SetPosition(fSlotPadding + (fSlotSizeX + fSlotSpacing) * j, fSlotPadding + (fSlotSizeY + fSlotSpacing) * i); + pSlot[nIndex].Subscribe(ActionSlot::EventDrop, &ActionPanel::OnActionDropped, this); + pSlot[nIndex].SetSlot(nIndex); + pSlot[nIndex].SetAction(Action_None); + + Add(&pSlot[nIndex]); + } + } + } + + return eCode; +} + +/* + * SetAction + */ +void ActionPanel::SetAction(uint32 nIndex, uint32 nAction) +{ + pSlot[nIndex].SetAction(nAction); +} + +/* + * GetAction + */ +uint32 ActionPanel::GetAction(uint32 nIndex) const +{ + return pSlot[nIndex].GetAction(); +} + +/* + * Clear + */ +void ActionPanel::Clear() +{ + const uint32 nCount = nSizeX * nSizeY; + + for(uint32 i = 0; i < nCount; ++i) + { + pSlot[i].SetAction(Action_None); + } +} + +/* + * SetPermanent + */ +void ActionPanel::SetPermanent(bool bPermanent) +{ + const uint32 nCount = nSizeX * nSizeY; + + for(uint32 i = 0; i < nCount; ++i) + { + pSlot[i].SetPermanent(bPermanent); + } +} + +/* + * OnActionDropped + */ +void ActionPanel::OnActionDropped(GuiEventArguments& kArguments) +{ + ActionSlot* pSlot = (ActionSlot*)kArguments.pSource; + //ASSERT(pSlot != NULL); + + const uint32 nIndex = pSlot->GetSlot(); + //if(nIndex < nActionSlots) + { + ActionArguments kActionArguments(this, nIndex); + Fire(ActionPanel::EventAction, kActionArguments); + } + + Fire(ActionPanel::EventDrop, kArguments); +} \ No newline at end of file diff -r 5e382dee4c70 -r 63806b850aa5 LightClone/Source/ActionPanel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/ActionPanel.h Fri Sep 30 22:48:03 2011 -0700 @@ -0,0 +1,103 @@ +/* + * ActionPanel + */ + +#ifndef __ACTIONPANEL_H__ +#define __ACTIONPANEL_H__ + +#include "Core.h" +#include "ActionSlot.h" + +/* + * ActionArguments + */ +struct ActionArguments : public GuiEventArguments +{ + /* + * nSlot + */ + uint32 nSlot; + + /* + * ActionArguments + */ + ActionArguments(GuiElement* pSource, uint32 nCodeSlot) : GuiEventArguments(pSource), nSlot(nCodeSlot) + { + } +}; + +/* + * ActionPanel + */ +class ActionPanel : public GuiImage +{ +public: + + /* + * EventAction + */ + static const char* EventAction; + +private: + + /* + * pSlot + */ + ActionSlot* pSlot; + + /* + * nSizeX + */ + uint32 nSizeX; + + /* + * nSizeY + */ + uint32 nSizeY; + +public: + + /* + * ActionPanel + */ + ActionPanel(uint32 nWidth, uint32 nHeight); + + /* + * Initialize + */ + virtual ErrorCode Initialize(ResourceManager* pResourceManager); + + /* + * SetAvailableSlots + */ + void SetAvailableSlots(uint32 nCount); + + /* + * SetAction + */ + void SetAction(uint32 nIndex, uint32 nAction); + + /* + * GetAction + */ + uint32 GetAction(uint32 nIndex) const; + + /* + * Clear + */ + void Clear(); + + /* + * SetPermanent + */ + void SetPermanent(bool bPermanent); + +private: + + /* + * OnActionDropped + */ + void OnActionDropped(GuiEventArguments& kArguments); +}; + +#endif //__ACTIONPANEL_H__ diff -r 5e382dee4c70 -r 63806b850aa5 LightClone/Source/ProgramPanel.cpp --- a/LightClone/Source/ProgramPanel.cpp Fri Sep 30 22:39:08 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* - * ProgramPanel - */ - -#include "ProgramPanel.h" - -/* - * EventAction - */ -const char* ProgramPanel::EventAction = "ProgramPanel:EventAction"; - -/* - * ProgramPanel - */ -ProgramPanel::ProgramPanel(uint32 nWidth, uint32 nHeight) : GuiImage(), nSizeX(nWidth), nSizeY(nHeight) -{ - pSlot = new ActionSlot[nSizeX * nSizeY]; -} - -/* - * Initialize - */ -ErrorCode ProgramPanel::Initialize(ResourceManager* pResourceManager) -{ - const float fSlotSizeX = 48.0f; - const float fSlotSizeY = 48.0f; - const float fSlotPadding = 16.0f; - const float fSlotSpacing = 8.0f; - - ErrorCode eCode = GuiImage::Initialize(pResourceManager); - if(eCode == Error_Success) - { - SetDimensions(2.0f * fSlotPadding + (fSlotSizeX + fSlotSpacing) * nSizeX - fSlotSpacing, 2.0f * fSlotPadding + (fSlotSizeY + fSlotSpacing) * nSizeY - fSlotSpacing); - - for(uint32 i = 0; i < nSizeY; ++i) - { - for(uint32 j = 0; j < nSizeX; ++j) - { - const uint32 nIndex = i * nSizeX + j; - - pSlot[nIndex].Initialize(pResourceManager); - pSlot[nIndex].SetTexture("Data\\Textures\\Slot.tga"); - pSlot[nIndex].SetDimensions(fSlotSizeX, fSlotSizeY); - pSlot[nIndex].SetPosition(fSlotPadding + (fSlotSizeX + fSlotSpacing) * j, fSlotPadding + (fSlotSizeY + fSlotSpacing) * i); - pSlot[nIndex].Subscribe(ActionSlot::EventDrop, &ProgramPanel::OnActionDropped, this); - pSlot[nIndex].SetSlot(nIndex); - pSlot[nIndex].SetAction(Action_None); - - Add(&pSlot[nIndex]); - } - } - } - - return eCode; -} - -/* - * SetAction - */ -void ProgramPanel::SetAction(uint32 nIndex, uint32 nAction) -{ - pSlot[nIndex].SetAction(nAction); -} - -/* - * GetAction - */ -uint32 ProgramPanel::GetAction(uint32 nIndex) const -{ - return pSlot[nIndex].GetAction(); -} - -/* - * Clear - */ -void ProgramPanel::Clear() -{ - const uint32 nCount = nSizeX * nSizeY; - - for(uint32 i = 0; i < nCount; ++i) - { - pSlot[i].SetAction(Action_None); - } -} - -/* - * SetPermanent - */ -void ProgramPanel::SetPermanent(bool bPermanent) -{ - const uint32 nCount = nSizeX * nSizeY; - - for(uint32 i = 0; i < nCount; ++i) - { - pSlot[i].SetPermanent(bPermanent); - } -} - -/* - * OnActionDropped - */ -void ProgramPanel::OnActionDropped(GuiEventArguments& kArguments) -{ - ActionSlot* pSlot = (ActionSlot*)kArguments.pSource; - //ASSERT(pSlot != NULL); - - const uint32 nIndex = pSlot->GetSlot(); - //if(nIndex < nActionSlots) - { - ActionArguments kActionArguments(this, nIndex); - Fire(ProgramPanel::EventAction, kActionArguments); - } - - Fire(ProgramPanel::EventDrop, kArguments); -} \ No newline at end of file diff -r 5e382dee4c70 -r 63806b850aa5 LightClone/Source/ProgramPanel.h --- a/LightClone/Source/ProgramPanel.h Fri Sep 30 22:39:08 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* - * ProgramPanel - */ - -#ifndef __PROGRAMPANEL_H__ -#define __PROGRAMPANEL_H__ - -#include "Core.h" -#include "ActionSlot.h" - -/* - * ActionArguments - */ -struct ActionArguments : public GuiEventArguments -{ - /* - * nSlot - */ - uint32 nSlot; - - /* - * ActionArguments - */ - ActionArguments(GuiElement* pSource, uint32 nCodeSlot) : GuiEventArguments(pSource), nSlot(nCodeSlot) - { - } -}; - -/* - * ProgramPanel - */ -class ProgramPanel : public GuiImage -{ -public: - - /* - * EventAction - */ - static const char* EventAction; - -private: - - /* - * pSlot - */ - ActionSlot* pSlot; - - /* - * nSizeX - */ - uint32 nSizeX; - - /* - * nSizeY - */ - uint32 nSizeY; - -public: - - /* - * ProgramPanel - */ - ProgramPanel(uint32 nWidth, uint32 nHeight); - - /* - * Initialize - */ - virtual ErrorCode Initialize(ResourceManager* pResourceManager); - - /* - * SetAvailableSlots - */ - void SetAvailableSlots(uint32 nCount); - - /* - * SetAction - */ - void SetAction(uint32 nIndex, uint32 nAction); - - /* - * GetAction - */ - uint32 GetAction(uint32 nIndex) const; - - /* - * Clear - */ - void Clear(); - - /* - * SetPermanent - */ - void SetPermanent(bool bPermanent); - -private: - - /* - * OnActionDropped - */ - void OnActionDropped(GuiEventArguments& kArguments); -}; - -#endif //__PROGRAMPANEL_H__ diff -r 5e382dee4c70 -r 63806b850aa5 LightClone/Source/World.cpp --- a/LightClone/Source/World.cpp Fri Sep 30 22:39:08 2011 -0700 +++ b/LightClone/Source/World.cpp Fri Sep 30 22:48:03 2011 -0700 @@ -221,7 +221,7 @@ pBackground->SetPosition(ScreenSizeX - pBackground->GetWidth(), 0.0f); pBackground->SetDepth(512.0f); - pToolbar = new ProgramPanel(4, 2); + pToolbar = new ActionPanel(4, 2); pToolbar->Initialize(pResourceManager); pToolbar->SetTexture("Data\\Textures\\PanelA.png"); pToolbar->SetPosition(16, 16.0f); @@ -243,11 +243,11 @@ pMainLabel->SetPosition(26.0f, 149.0f); pMainLabel->SetDepth(256.0f); - pCode[0] = new ProgramPanel(4, 3); + pCode[0] = new ActionPanel(4, 3); pCode[0]->Initialize(pResourceManager); pCode[0]->SetTexture("Data\\Textures\\PanelB.png"); pCode[0]->SetPosition(16.0f, 160.0f); - pCode[0]->Subscribe(ProgramPanel::EventAction, &World::OnAction, this); + pCode[0]->Subscribe(ActionPanel::EventAction, &World::OnAction, this); pCode[0]->SetDepth(256.0f); GuiLabel* pFunctionALabel = new GuiLabel(); @@ -257,11 +257,11 @@ pFunctionALabel->SetColor(D3DCOLOR_XRGB(0, 0, 0)); pFunctionALabel->SetPosition(26.0f, 349.0f); - pCode[1] = new ProgramPanel(4, 2); + pCode[1] = new ActionPanel(4, 2); pCode[1]->Initialize(pResourceManager); pCode[1]->SetTexture("Data\\Textures\\PanelA.png"); pCode[1]->SetPosition(16.0f, 360.0f); - pCode[1]->Subscribe(ProgramPanel::EventAction, &World::OnAction, this); + pCode[1]->Subscribe(ActionPanel::EventAction, &World::OnAction, this); GuiLabel* pFunctionBLabel = new GuiLabel(); pFunctionBLabel->Initialize(pResourceManager); @@ -270,11 +270,11 @@ pFunctionBLabel->SetColor(D3DCOLOR_XRGB(0, 0, 0)); pFunctionBLabel->SetPosition(26.0f, 493.0f); - pCode[2] = new ProgramPanel(4, 2); + pCode[2] = new ActionPanel(4, 2); pCode[2]->Initialize(pResourceManager); pCode[2]->SetTexture("Data\\Textures\\PanelA.png"); pCode[2]->SetPosition(16.0f, 504.0f); - pCode[2]->Subscribe(ProgramPanel::EventAction, &World::OnAction, this); + pCode[2]->Subscribe(ActionPanel::EventAction, &World::OnAction, this); const float fButtonPadding = 32.0f; const float fButtonSpacing = 8.0f; diff -r 5e382dee4c70 -r 63806b850aa5 LightClone/Source/World.h --- a/LightClone/Source/World.h Fri Sep 30 22:39:08 2011 -0700 +++ b/LightClone/Source/World.h Fri Sep 30 22:48:03 2011 -0700 @@ -16,7 +16,7 @@ #include "GuiInterface.h" #include "GuiImage.h" #include "GuiButton.h" -#include "ProgramPanel.h" +#include "ActionPanel.h" #include "Program.h" #include "Dialog.h" @@ -138,12 +138,12 @@ /* * pToolbar */ - ProgramPanel* pToolbar; + ActionPanel* pToolbar; /* * pCode */ - ProgramPanel* pCode[MaximumFunctionCount]; + ActionPanel* pCode[MaximumFunctionCount]; /* * pMessageDialog