# HG changeset patch # User koryspansel # Date 1316469326 25200 # Node ID d9e9ce8219f8c9ece2a7450ef901f748374e53f7 # Parent 4bb3bcee0601b84a7f089560dbddfa57cd8541a7 Drag and drop diff -r 4bb3bcee0601 -r d9e9ce8219f8 LightClone/LightClone.vcproj --- a/LightClone/LightClone.vcproj Mon Sep 19 12:51:07 2011 -0700 +++ b/LightClone/LightClone.vcproj Mon Sep 19 14:55:26 2011 -0700 @@ -193,6 +193,10 @@ > + + @@ -339,6 +343,10 @@ > + + diff -r 4bb3bcee0601 -r d9e9ce8219f8 LightClone/Source/CodePanel.cpp --- a/LightClone/Source/CodePanel.cpp Mon Sep 19 12:51:07 2011 -0700 +++ b/LightClone/Source/CodePanel.cpp Mon Sep 19 14:55:26 2011 -0700 @@ -3,13 +3,13 @@ */ #include "CodePanel.h" -#include "GuiImage.h" /* * CodePanel */ -CodePanel::CodePanel() +CodePanel::CodePanel(uint32 nMaximum) : GuiImage(), nSlotCount(nMaximum) { + pSlot = new CodeSlot*[nMaximum]; } /* @@ -17,29 +17,20 @@ */ ErrorCode CodePanel::Initialize(ResourceManager* pResourceManager) { - ErrorCode eCode = GuiElement::Initialize(pResourceManager); + ErrorCode eCode = GuiImage::Initialize(pResourceManager); if(eCode == Error_Success) { - for(uint32 i = 0; i < 4; ++i) + SetTexture("Data\\Textures\\Panel.tga"); + + for(uint32 i = 0; i < nSlotCount; ++i) { - GuiImage* - pImage = new GuiImage(); - pImage->Initialize(pResourceManager); - pImage->SetTexture("Data\\Textures\\Slot.tga"); - pImage->SetDimensions(48.0f, 48.0f); - pImage->SetPosition(48.0f * i, 0.0f); + pSlot[i] = new CodeSlot(); + pSlot[i]->Initialize(pResourceManager); + pSlot[i]->SetPosition(48.0f * i, 0.0f); - Add(pImage); + Add(pSlot[i]); } } return eCode; } - -/* - * Update - */ -void CodePanel::Update(float fElapsed) -{ -} - diff -r 4bb3bcee0601 -r d9e9ce8219f8 LightClone/Source/CodePanel.h --- a/LightClone/Source/CodePanel.h Mon Sep 19 12:51:07 2011 -0700 +++ b/LightClone/Source/CodePanel.h Mon Sep 19 14:55:26 2011 -0700 @@ -6,34 +6,34 @@ #define __CODEPANEL_H__ #include "Core.h" -#include "GuiImage.h" +#include "CodeSlot.h" /* * CodePanel */ -class CodePanel : public GuiElement +class CodePanel : public GuiImage { /* * pSlot */ - GuiImage** pSlot; + CodeSlot** pSlot; + + /* + * nSlotCount + */ + uint32 nSlotCount; public: /* * CodePanel */ - CodePanel(); + CodePanel(uint32 nMaximum); /* * Initialize */ virtual ErrorCode Initialize(ResourceManager* pResourceManager); - - /* - * Update - */ - virtual void Update(float fElapsed); }; #endif //__CODEPANEL_H__ diff -r 4bb3bcee0601 -r d9e9ce8219f8 LightClone/Source/CodeSlot.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/CodeSlot.cpp Mon Sep 19 14:55:26 2011 -0700 @@ -0,0 +1,99 @@ +/* + * CodeSlot + */ + +#include "CodeSlot.h" +#include "GuiInterface.h" +#include "InputManager.h" + +/* + * ActionTextureName + */ +const char* ActionTextureName[] = +{ + "Data\\Textures\\Forward.tga", + "Data\\Textures\\RotateCW.tga", + "Data\\Textures\\RotateCCW.tga", + "Data\\Textures\\Jump.tga", + "Data\\Textures\\Light.tga", + "Data\\Textures\\FunctionA.tga", + "Data\\Textures\\FunctionB.tga", +}; + +/* + * CodeSlot + */ +CodeSlot::CodeSlot() : GuiImage() +{ + nAction = Action_Default; + bMouseDown = false; +} + +/* + * Initialize + */ +ErrorCode CodeSlot::Initialize(ResourceManager* pManager) +{ + ErrorCode eCode = GuiImage::Initialize(pManager); + if(eCode == Error_Success) + { + SetTexture("Data\\Textures\\Slot.tga", true); + } + + return eCode; +} + +/* + * Terminate + */ +void CodeSlot::Terminate() +{ +} + +/* + * OnMouseDown + */ +void CodeSlot::OnMouseDown(uint32 nButton, float fX, float fY) +{ + if(nButton == MouseButton_Left) + { + bMouseDown = true; + } +} + +/* + * OnMouseUp + */ +void CodeSlot::OnMouseUp(uint32 nButton, float fX, float fY) +{ + bMouseDown = false; +} + +/* + * OnMouseMove + */ +void CodeSlot::OnMouseMove(float fX, float fY) +{ + if(bMouseDown) + { + if(nAction != Action_Default) + { + pInterface->BeginDrag(this, MouseButton_Left); + } + } +} + +/* + * OnDrop + */ +void CodeSlot::OnDrop(GuiElement* pSource, float fX, float fY) +{ + if(true) // pSource is a CodeSlot + { + uint32 nAction = ((CodeSlot*)pSource)->nAction; + + if(nAction != Action_Default) + { + } + } +} diff -r 4bb3bcee0601 -r d9e9ce8219f8 LightClone/Source/CodeSlot.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/CodeSlot.h Mon Sep 19 14:55:26 2011 -0700 @@ -0,0 +1,66 @@ +/* + * CodeSlot + */ + +#ifndef __CODESLOT_H__ +#define __CODESLOT_H__ + +#include "Core.h" +#include "GuiImage.h" + +/* + * CodeSlot + */ +class CodeSlot : public GuiImage +{ + /* + * bMouseDown + */ + bool bMouseDown; + + /* + * nAction + */ + uint32 nAction; + +public: + + /* + * CodeSlot + */ + CodeSlot(); + + /* + * Initialize + */ + virtual ErrorCode Initialize(ResourceManager* pResourceManager); + + /* + * Terminate + */ + virtual void Terminate(); + +protected: + + /* + * OnMouseDown + */ + virtual void OnMouseDown(uint32 nButton, float fX, float fY); + + /* + * OnMouseUp + */ + virtual void OnMouseUp(uint32 nButton, float fX, float fY); + + /* + * OnMouseMove + */ + virtual void OnMouseMove(float fX, float fY); + + /* + * OnDrop + */ + virtual void OnDrop(GuiElement* pSource, float fX, float fY); +}; + +#endif //__CODESLOT_H__ diff -r 4bb3bcee0601 -r d9e9ce8219f8 LightClone/Source/GuiImage.h --- a/LightClone/Source/GuiImage.h Mon Sep 19 12:51:07 2011 -0700 +++ b/LightClone/Source/GuiImage.h Mon Sep 19 14:55:26 2011 -0700 @@ -13,6 +13,8 @@ */ class GuiImage : public GuiElement { +protected: + /* * pResourceManager */