Mercurial > LightClone
changeset 27:5656c8e382fc
More Gui work; Remove some old files
author | koryspansel |
---|---|
date | Fri, 16 Sep 2011 18:21:36 -0700 |
parents | 3a63df04f3c0 |
children | 13e53b74aed7 |
files | LightClone/LightClone.vcproj LightClone/Source/Bot.cpp LightClone/Source/ButtonPane.cpp LightClone/Source/ButtonPane.h LightClone/Source/Dialog.cpp LightClone/Source/Dialog.h LightClone/Source/DragController.cpp LightClone/Source/DragController.h LightClone/Source/Environment.cpp LightClone/Source/Environment.h LightClone/Source/GuiButton.cpp LightClone/Source/GuiCursor.cpp LightClone/Source/GuiImage.cpp LightClone/Source/GuiLabel.cpp LightClone/Source/HashMap.h LightClone/Source/HashMapIterator.h LightClone/Source/ResourceManager.cpp LightClone/Source/ResourceManager.h LightClone/Source/World.cpp LightClone/Source/World.h |
diffstat | 20 files changed, 210 insertions(+), 592 deletions(-) [+] |
line wrap: on
line diff
--- a/LightClone/LightClone.vcproj Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/LightClone.vcproj Fri Sep 16 18:21:36 2011 -0700 @@ -181,10 +181,6 @@ > </File> <File - RelativePath=".\Source\ButtonPane.cpp" - > - </File> - <File RelativePath=".\Source\Camera.cpp" > </File> @@ -209,14 +205,6 @@ > </File> <File - RelativePath=".\Source\Dialog.cpp" - > - </File> - <File - RelativePath=".\Source\DragController.cpp" - > - </File> - <File RelativePath=".\Source\Environment.cpp" > </File> @@ -339,10 +327,6 @@ > </File> <File - RelativePath=".\Source\ButtonPane.h" - > - </File> - <File RelativePath=".\Source\Camera.h" > </File> @@ -367,14 +351,6 @@ > </File> <File - RelativePath=".\Source\Dialog.h" - > - </File> - <File - RelativePath=".\Source\DragController.h" - > - </File> - <File RelativePath=".\Source\Environment.h" > </File>
--- a/LightClone/Source/Bot.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/Bot.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -67,18 +67,6 @@ pVertexBuffer->Release(); pVertexBuffer = NULL; } - - if(pTexture) - { - pTexture->Release(); - pTexture = NULL; - } - - if(pEffect) - { - pEffect->Release(); - pEffect = NULL; - } } /*
--- a/LightClone/Source/ButtonPane.cpp Fri Sep 16 15:28:15 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * ButtonPane - */ - -#include "ButtonPane.h" - -/* - * ButtonPane - */ -ButtonPane::ButtonPane(uint32 nMax) : nMaximum(nMax), nSize(0) -{ - pBounds = new Rectangle2[nMax]; -} - -/* - * Add - */ -void ButtonPane::Add(float fX, float fY, float fWidth, float fHeight) -{ - if(nSize < nMaximum) - { - pBounds[nSize++] = Rectangle2(fX, fY, fWidth, fHeight); - } -} - -/* - * Pick - */ -int32 ButtonPane::Pick(float fX, float fY) -{ - for(uint32 i = 0; i < nMaximum; ++i) - { - if(pBounds[i].Contains(fX, fY)) - { - return (int32)i; - } - } - - return -1; -} - -/* - * GetMaximum - */ -uint32 ButtonPane::GetMaximum() const -{ - return nMaximum; -} - -/* - * GetSize - */ -uint32 ButtonPane::GetSize() const -{ - return nSize; -} - -/* - * GetBounds - */ -const Rectangle2& ButtonPane::GetBounds(uint32 nSlot) const -{ - return pBounds[nSlot]; -}
--- a/LightClone/Source/ButtonPane.h Fri Sep 16 15:28:15 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * ButtonPane - */ - -#ifndef __BUTTONPANE_H__ -#define __BUTTONPANE_H__ - -#include "Core.h" - -/* - * ButtonPane - */ -class ButtonPane -{ -private: - - /* - * nMaximum - */ - uint32 nMaximum; - - /* - * nSize - */ - uint32 nSize; - - /* - * pBounds - */ - Rectangle2* pBounds; - -public: - - /* - * ButtonPane - */ - ButtonPane(uint32 nMax); - - /* - * Add - */ - void Add(float fX, float fY, float fWidth, float fHeight); - - /* - * Pick - */ - int32 Pick(float fX, float fY); - - /* - * GetMaximum - */ - uint32 GetMaximum() const; - - /* - * GetSize - */ - uint32 GetSize() const; - - /* - * GetBounds - */ - const Rectangle2& GetBounds(uint32 nSlot) const; -}; - -#endif //__BUTTONPANE_H__
--- a/LightClone/Source/Dialog.cpp Fri Sep 16 15:28:15 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Dialog - */ - -#include "Dialog.h" - -/* - * Dialog - */ -Dialog::Dialog() -{ - nButtonCount = 0; -} - -/* - * Reset - */ -void Dialog::Reset(const char* pText) -{ - if(strcpy_s(kMessage, pText) == 0) - { - nButtonCount = 0; - } -} - -/* - * AddButton - */ -void Dialog::AddButton(uint32 nButton, const char* pText, float fX, float fY, float fWidth, float fHeight) -{ - if(nButtonCount < MaximumButtonCount) - { - if(strcpy_s(kButtonLabel[nButtonCount], pText) == 0) - { - kButtonRectangle[nButtonCount] = Rectangle2(fX, fY, fWidth, fHeight); - nButtonIdentifier[nButtonCount] = nButton; - - ++nButtonCount; - } - } -} - -/* - * Pick - */ -int32 Dialog::Pick(float fX, float fY) -{ - for(uint32 i = 0; i < nButtonCount; ++i) - { - if(kButtonRectangle[i].Contains(fX, fY)) - { - return (int32)nButtonIdentifier[i]; - } - } - - return -1; -}
--- a/LightClone/Source/Dialog.h Fri Sep 16 15:28:15 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Dialog - */ - -#ifndef __DIALOG_H__ -#define __DIALOG_H__ - -#include "Core.h" - -/* - * Dialog - */ -class Dialog -{ -public: - - /* - * MaximumButtonCount - */ - static const uint32 MaximumButtonCount = 2; - - /* - * MaximumMessageLength - */ - static const uint32 MaximumMessageLength = 256; - -private: - - /* - * kMessage - */ - char kMessage[MaximumMessageLength]; - - /* - * kButtonLabel - */ - char kButtonLabel[MaximumButtonCount][MaximumMessageLength]; - - /* - * kButtonRectangle - */ - Rectangle2 kButtonRectangle[MaximumButtonCount]; - - /* - * nButtonIdentifier - */ - uint32 nButtonIdentifier[MaximumButtonCount]; - - /* - * nButtonCount - */ - uint32 nButtonCount; - -public: - - /* - * Dialog - */ - Dialog(); - - /* - * Reset - */ - void Reset(const char* pText); - - /* - * AddButton - */ - void AddButton(uint32 nButton, const char* pText, float fX, float fY, float fWidth, float fHeight); - - /* - * Pick - */ - int32 Pick(float fX, float fY); -}; - -#endif //__DIALOG_H__
--- a/LightClone/Source/DragController.cpp Fri Sep 16 15:28:15 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * DragController - */ - -#include "DragController.h" - -/* - * DragController - */ -DragController::DragController() -{ - bActive = false; - nParameter = 0; -} - -/* - * Begin - */ -void DragController::Begin(uint32 nValue) -{ - bActive = true; - nParameter = nValue; -} - -/* - * End - */ -uint32 DragController::End() -{ - bActive = false; - return nParameter; -} - -/* - * Reset - */ -void DragController::Reset() -{ - bActive = false; - nParameter = 0; -} - -/* - * IsActive - */ -bool DragController::IsActive() const -{ - return bActive; -} - -/* - * GetParameter - */ -uint32 DragController::GetParameter() const -{ - return nParameter; -} \ No newline at end of file
--- a/LightClone/Source/DragController.h Fri Sep 16 15:28:15 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * DragController - */ - -#ifndef __DRAGCONTROLLER_H__ -#define __DRAGCONTROLLER_H__ - -#include "Core.h" - -/* - * DragController - */ -class DragController -{ - /* - * bActive - */ - bool bActive; - - /* - * nParameter - */ - uint32 nParameter; - -public: - - /* - * DragController - */ - DragController(); - - /* - * Begin - */ - void Begin(uint32 nValue); - - /* - * End - */ - uint32 End(); - - /* - * Reset - */ - void Reset(); - - /* - * IsActive - */ - bool IsActive() const; - - /* - * GetParameter - */ - uint32 GetParameter() const; -}; - -#endif //__DRAGCONTROLLER_H__
--- a/LightClone/Source/Environment.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/Environment.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -11,14 +11,14 @@ */ Environment::Environment() : pGrid(0) { - pBlockEffect = NULL; - pBlockVertexBuffer = NULL; - pBlockTexture = NULL; - nWidth = 0; - nHeight = 0; - kScale.x = 1.0f; - kScale.y = 0.4f; - kScale.z = 1.0f; + pEffect = NULL; + pVertexBuffer = NULL; + pTexture = NULL; + nWidth = 0; + nHeight = 0; + kScale.x = 1.0f; + kScale.y = 0.4f; + kScale.z = 1.0f; } /* @@ -34,13 +34,13 @@ */ ErrorCode Environment::Initialize(ResourceManager* pResourceManager) { - ErrorCode eCode = pResourceManager->CreateEffectFromFile("Data\\Shaders\\Environment.fx", &pBlockEffect); + ErrorCode eCode = pResourceManager->CreateEffectFromFile("Data\\Shaders\\Environment.fx", &pEffect); if(eCode == Error_Success) { - eCode = pResourceManager->CreateTextureFromFile("Data\\Textures\\Block02.tga", &pBlockTexture); + eCode = pResourceManager->CreateTextureFromFile("Data\\Textures\\Block02.tga", &pTexture); if(eCode == Error_Success) { - eCode = pResourceManager->CreateVertexBuffer(VerticesPerBlock * sizeof(Vertex::Block), D3DUSAGE_WRITEONLY, D3DPOOL_MANAGED, &pBlockVertexBuffer); + eCode = pResourceManager->CreateVertexBuffer(VerticesPerBlock * sizeof(Vertex::Block), D3DUSAGE_WRITEONLY, D3DPOOL_MANAGED, &pVertexBuffer); if(eCode == Error_Success) { eCode = SetupVertexBuffer(); @@ -56,22 +56,10 @@ */ void Environment::Terminate() { - if(pBlockVertexBuffer) - { - pBlockVertexBuffer->Release(); - pBlockVertexBuffer = NULL; - } - - if(pBlockTexture) + if(pVertexBuffer) { - pBlockTexture->Release(); - pBlockTexture = NULL; - } - - if(pBlockEffect) - { - pBlockEffect->Release(); - pBlockEffect = 0; + pVertexBuffer->Release(); + pVertexBuffer = NULL; } } @@ -111,11 +99,11 @@ { uint32 nPasses = 0; - kContext.ApplyCameraToEffect(kCamera, pBlockEffect); + kContext.ApplyCameraToEffect(kCamera, pEffect); - pBlockEffect->SetTechnique(pBlockEffect->GetTechnique(0)); - pBlockEffect->Begin(&nPasses, 0); - pBlockEffect->BeginPass(0); + pEffect->SetTechnique(pEffect->GetTechnique(0)); + pEffect->Begin(&nPasses, 0); + pEffect->BeginPass(0); D3DXMATRIX kScaleMatrix; D3DXMatrixScaling(&kScaleMatrix, kScale.x, kScale.y, kScale.z); @@ -162,24 +150,24 @@ const D3DXVECTOR4 kColorVector(fRed, fGreen, fBlue, fAlpha); - pBlockEffect->SetMatrix(pBlockEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); - pBlockEffect->SetVector(pBlockEffect->GetParameterByName(NULL, "kColor"), &kColorVector); - pBlockEffect->SetTexture(pBlockEffect->GetParameterByName(NULL, "kTexture"), pBlockTexture); - pBlockEffect->CommitChanges(); + pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); + pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector); + pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture); + pEffect->CommitChanges(); - kContext.DrawTriangles(Vertex::Block::Declaration, pBlockVertexBuffer, sizeof(Vertex::Block), FacesPerCube * TrianglesPerFace); + kContext.DrawTriangles(Vertex::Block::Declaration, pVertexBuffer, sizeof(Vertex::Block), FacesPerCube * TrianglesPerFace); } } } - pBlockEffect->EndPass(); - pBlockEffect->End(); + pEffect->EndPass(); + pEffect->End(); if(false) // wireframe { - pBlockEffect->SetTechnique(pBlockEffect->GetTechniqueByName("Wire")); - pBlockEffect->Begin(&nPasses, 0); - pBlockEffect->BeginPass(0); + pEffect->SetTechnique(pEffect->GetTechniqueByName("Wire")); + pEffect->Begin(&nPasses, 0); + pEffect->BeginPass(0); for(uint32 nZ = 0; nZ < nHeight; ++nZ) { @@ -195,18 +183,18 @@ const D3DXVECTOR4 kColorVector(0.0f, 0.0f, 0.0f, 1.0f); - pBlockEffect->SetMatrix(pBlockEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); - pBlockEffect->SetVector(pBlockEffect->GetParameterByName(NULL, "kColor"), &kColorVector); - pBlockEffect->SetTexture(pBlockEffect->GetParameterByName(NULL, "kTexture"), pBlockTexture); - pBlockEffect->CommitChanges(); + pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); + pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector); + pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture); + pEffect->CommitChanges(); - kContext.DrawTriangles(Vertex::Block::Declaration, pBlockVertexBuffer, sizeof(Vertex::Block), FacesPerCube * TrianglesPerFace); + kContext.DrawTriangles(Vertex::Block::Declaration, pVertexBuffer, sizeof(Vertex::Block), FacesPerCube * TrianglesPerFace); } } } - pBlockEffect->EndPass(); - pBlockEffect->End(); + pEffect->EndPass(); + pEffect->End(); } } @@ -404,7 +392,7 @@ { Vertex::Block* pVertices = NULL; - HRESULT hResult = pBlockVertexBuffer->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD); + HRESULT hResult = pVertexBuffer->Lock(0, 0, (void**)&pVertices, D3DLOCK_DISCARD); if(FAILED(hResult)) { return Error_Fail; @@ -456,7 +444,7 @@ pVertices[34] = Vertex::Block(+0.5f, 0.0f, -0.5f, 0.0f, -1.0f, 0.0f, 1.00f, 0.00f); pVertices[35] = Vertex::Block(+0.5f, 0.0f, +0.5f, 0.0f, -1.0f, 0.0f, 1.00f, 0.66f); - pBlockVertexBuffer->Unlock(); + pVertexBuffer->Unlock(); return Error_Success; } \ No newline at end of file
--- a/LightClone/Source/Environment.h Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/Environment.h Fri Sep 16 18:21:36 2011 -0700 @@ -16,19 +16,19 @@ class Environment { /* - * pBlockEffect + * pEffect */ - ID3DXEffect* pBlockEffect; + ID3DXEffect* pEffect; /* - * pBlockVertexBuffer + * pVertexBuffer */ - IDirect3DVertexBuffer9* pBlockVertexBuffer; + IDirect3DVertexBuffer9* pVertexBuffer; /* - * pBlockTexture + * pTexture */ - IDirect3DTexture9* pBlockTexture; + IDirect3DTexture9* pTexture; /* * nWidth
--- a/LightClone/Source/GuiButton.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/GuiButton.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -46,32 +46,11 @@ */ void GuiButton::Terminate() { - if(pFont) - { - pFont->Release(); - pFont = NULL; - } - - for(uint32 i = 0; i < GuiButtonState_Count; ++i) - { - if(pTexture[i]) - { - pTexture[i]->Release(); - pTexture[i] = NULL; - } - } - if(pVertexBuffer) { pVertexBuffer->Release(); pVertexBuffer = NULL; } - - if(pEffect) - { - pEffect->Release(); - pEffect = NULL; - } } /* @@ -155,11 +134,7 @@ if(nState < GuiButtonState_Count) { - if(pTexture[nState]) - { - pTexture[nState]->Release(); - pTexture[nState] = NULL; - } + pTexture[nState] = NULL; eCode = pResourceManager->CreateTextureFromFile(pName, &pTexture[nState]); if(eCode == Error_Success) @@ -183,11 +158,7 @@ */ ErrorCode GuiButton::SetFont(const char* pName, uint32 nSize, uint32 nWeight) { - if(pFont) - { - pFont->Release(); - pFont = NULL; - } + pFont = NULL; return pResourceManager->CreateFontFromName(pName, nSize, nWeight, &pFont); }
--- a/LightClone/Source/GuiCursor.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/GuiCursor.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -37,23 +37,11 @@ */ void GuiCursor::Terminate() { - if(pTexture) - { - pTexture->Release(); - pTexture = NULL; - } - if(pVertexBuffer) { pVertexBuffer->Release(); pVertexBuffer = NULL; } - - if(pEffect) - { - pEffect->Release(); - pEffect = NULL; - } } /* @@ -109,11 +97,7 @@ */ ErrorCode GuiCursor::SetTexture(const char* pName, bool bResize) { - if(pTexture) - { - pTexture->Release(); - pTexture = NULL; - } + pTexture = NULL; ErrorCode eCode = pResourceManager->CreateTextureFromFile(pName, &pTexture); if(eCode == Error_Success)
--- a/LightClone/Source/GuiImage.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/GuiImage.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -37,23 +37,11 @@ */ void GuiImage::Terminate() { - if(pTexture) - { - pTexture->Release(); - pTexture = NULL; - } - if(pVertexBuffer) { pVertexBuffer->Release(); pVertexBuffer = NULL; } - - if(pEffect) - { - pEffect->Release(); - pEffect = NULL; - } } /* @@ -115,11 +103,7 @@ */ ErrorCode GuiImage::SetTexture(const char* pName, bool bResize) { - if(pTexture) - { - pTexture->Release(); - pTexture = NULL; - } + pTexture = NULL; ErrorCode eCode = pResourceManager->CreateTextureFromFile(pName, &pTexture); if(eCode == Error_Success)
--- a/LightClone/Source/GuiLabel.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/GuiLabel.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -24,11 +24,6 @@ */ void GuiLabel::Terminate() { - if(pFont) - { - pFont->Release(); - pFont = NULL; - } } /* @@ -80,11 +75,7 @@ */ ErrorCode GuiLabel::SetFont(const char* pName, uint32 nSize, uint32 nWeight) { - if(pFont) - { - pFont->Release(); - pFont = NULL; - } + pFont = NULL; return pResourceManager->CreateFontFromName(pName, nSize, nWeight, &pFont); }
--- a/LightClone/Source/HashMap.h Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/HashMap.h Fri Sep 16 18:21:36 2011 -0700 @@ -30,6 +30,11 @@ class HashMap { /* + * Iterator + */ + friend class HashMapIterator<HashMap<Key, Value, HashFunction, Size>, Value>; + + /* * Node */ struct Node @@ -54,6 +59,9 @@ */ Node(Key& kNodeKey) : kKey(kNodeKey), pNext(NULL) { + uint8* pData = (uint8*)&kValue; + for(uint32 i = 0; i < sizeof(kValue); ++i) + *pData++ = 0; } }; @@ -100,6 +108,14 @@ } /* + * ~HashMap + */ + ~HashMap() + { + Clear(); + } + + /* * Add */ Value* Add(Key& kKey) @@ -121,6 +137,27 @@ } /* + * Clear + */ + void Clear() + { + for(uint32 i = 0; i < Size; ++i) + { + Node* pNode = pTable[i]; + + while(pNode) + { + Node* pItem = pNode; + pNode = pNode->pNext; + + delete pItem; + } + + pTable[i] = NULL; + } + } + + /* * Find */ Value* Find(const Key& kKey) @@ -144,12 +181,18 @@ /* * Begin */ - Iterator Begin(); + Iterator Begin() + { + return Iterator(this, Size); + } /* * End */ - Iterator End(); + Iterator End() + { + return Iterator(this, Size, Size); + } private:
--- a/LightClone/Source/HashMapIterator.h Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/HashMapIterator.h Fri Sep 16 18:21:36 2011 -0700 @@ -40,6 +40,10 @@ */ HashMapIterator(Map* pInstance, uint32 nInstanceSize) : pMap(pInstance), nSize(nInstanceSize), pNode(NULL), nSlot(0) { + while(!pNode && nSlot < nSize) + { + pNode = pInstance->pTable[nSlot++]; + } } /* @@ -47,7 +51,10 @@ */ HashMapIterator(Map* pInstance, uint32 nInstanceSize, uint32 nStart) : pMap(pInstance), nSize(nInstanceSize), pNode(NULL), nSlot(nStart) { - //pNode = pInstance->pTable[nSlot]; + while(!pNode && nSlot < nSize) + { + pNode = pInstance->pTable[nSlot++]; + } } /* @@ -55,6 +62,18 @@ */ HashMapIterator& operator ++() { + if(pNode) + { + pNode = pNode->pNext; + if(!pNode) + { + while(!pNode && nSlot < nSize) + { + pNode = pMap->pTable[nSlot++]; + } + } + } + return *this; } @@ -63,6 +82,18 @@ */ HashMapIterator& operator ++(int) { + if(pNode) + { + pNode = pNode->pNext; + if(!pNode) + { + while(!pNode && nSlot < nSize) + { + pNode = pMap->pTable[nSlot++]; + } + } + } + return *this; }
--- a/LightClone/Source/ResourceManager.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/ResourceManager.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -59,8 +59,33 @@ */ void ResourceManager::Terminate() { - //TODO: Iterate over each cache and release resources + TextureCache::Iterator kTexture = kTextureCache.Begin(); + TextureCache::Iterator kTextureEnd = kTextureCache.End(); + + for(; kTexture != kTextureEnd; ++kTexture) + { + (*kTexture)->Release(); + } + + EffectCache::Iterator kEffect = kEffectCache.Begin(); + EffectCache::Iterator kEffectEnd = kEffectCache.End(); + for(; kEffect != kEffectEnd; ++kEffect) + { + (*kEffect)->Release(); + } + + FontCache::Iterator kFont = kFontCache.Begin(); + FontCache::Iterator kFontEnd = kFontCache.Begin(); + + for(; kFont != kFontEnd; ++kFont) + { + (*kFont)->Release(); + } + + kTextureCache.Clear(); + kEffectCache.Clear(); + kFontCache.Clear(); pGraphicsDevice = NULL; }
--- a/LightClone/Source/ResourceManager.h Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/ResourceManager.h Fri Sep 16 18:21:36 2011 -0700 @@ -34,6 +34,21 @@ class ResourceManager { /* + * TextureCache + */ + typedef HashMap<ResourcePath, IDirect3DTexture9*, ResourcePath::Hash> TextureCache; + + /* + * EffectCache + */ + typedef HashMap<ResourcePath, ID3DXEffect*, ResourcePath::Hash> EffectCache; + + /* + * FontCache + */ + typedef HashMap<ResourcePath, ID3DXFont*, ResourcePath::Hash> FontCache; + + /* * pGraphicsDevice */ GraphicsDevice* pGraphicsDevice; @@ -41,17 +56,17 @@ /* * kTextureCache */ - HashMap<ResourcePath, IDirect3DTexture9*, ResourcePath::Hash> kTextureCache; + TextureCache kTextureCache; /* * kEffectCache */ - HashMap<ResourcePath, ID3DXEffect*, ResourcePath::Hash> kEffectCache; + EffectCache kEffectCache; /* * kFontCache */ - HashMap<ResourcePath, ID3DXFont*, ResourcePath::Hash> kFontCache; + FontCache kFontCache; public:
--- a/LightClone/Source/World.cpp Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/World.cpp Fri Sep 16 18:21:36 2011 -0700 @@ -11,7 +11,7 @@ /* * World */ -World::World() : kToolbar(8), kMain(16), kFunction(8) +World::World() //: kToolbar(8), kMain(16), kFunction(8) { nGameState = GameState_Active; nSimulationState = SimulationState_Idle; @@ -19,14 +19,15 @@ nCurrentFunction = 0; nCurrentLevel = 0; - kArrowBounds[0] = Rectangle2(1206.0f + 0 * 16.0f, 473.0f + 0 * 54.0f, 16.0f, 16.0f); - kArrowBounds[1] = Rectangle2(1206.0f + 2 * 16.0f, 473.0f + 0 * 54.0f, 16.0f, 16.0f); + //kArrowBounds[0] = Rectangle2(1206.0f + 0 * 16.0f, 473.0f + 0 * 54.0f, 16.0f, 16.0f); + //kArrowBounds[1] = Rectangle2(1206.0f + 2 * 16.0f, 473.0f + 0 * 54.0f, 16.0f, 16.0f); + + //kDialog1Bounds[0] = Rectangle2(567.0f, 412.0f, 150.0f, 60.0f); - kDialog1Bounds[0] = Rectangle2(567.0f, 412.0f, 150.0f, 60.0f); + //kDialog2Bounds[0] = Rectangle2(1023.0f + 2.5f * 54.0f, 638.0f + 0 * 00.0f, 48.0f, 48.0f); + //kDialog2Bounds[1] = Rectangle2(1023.0f + 2.5f * 54.0f, 638.0f + 0 * 00.0f, 48.0f, 48.0f); - kDialog2Bounds[0] = Rectangle2(1023.0f + 2.5f * 54.0f, 638.0f + 0 * 00.0f, 48.0f, 48.0f); - kDialog2Bounds[1] = Rectangle2(1023.0f + 2.5f * 54.0f, 638.0f + 0 * 00.0f, 48.0f, 48.0f); - + /* kToolbar.Add(1023.0f + 0 * 54.0f, 85.0f + 0 * 54.0f, 48.0f, 48.0f); kToolbar.Add(1023.0f + 1 * 54.0f, 85.0f + 0 * 54.0f, 48.0f, 48.0f); kToolbar.Add(1023.0f + 2 * 54.0f, 85.0f + 0 * 54.0f, 48.0f, 48.0f); @@ -61,6 +62,7 @@ kFunction.Add(1023.0f + 1 * 54.0f, 501.0f + 1 * 54.0f, 48.0f, 48.0f); kFunction.Add(1023.0f + 2 * 54.0f, 501.0f + 1 * 54.0f, 48.0f, 48.0f); kFunction.Add(1023.0f + 3 * 54.0f, 501.0f + 1 * 54.0f, 48.0f, 48.0f); + */ } /* @@ -237,8 +239,8 @@ { if(kEnvironment.RequirementsMet()) { - kDialog.Reset("Some message"); - kDialog.AddButton(DialogButton_Ok, "Ok", 0.0f, 0.0f, 0.0f, 0.0f); + //kDialog.Reset("Some message"); + //kDialog.AddButton(DialogButton_Ok, "Ok", 0.0f, 0.0f, 0.0f, 0.0f); nGameState = GameState_Complete; } @@ -284,6 +286,8 @@ pBackground->SetTexture("Data\\Textures\\Background01.tga", true); pBackground->SetPosition(ScreenSizeX - pBackground->GetWidth(), 0.0f); + //GuiImage* pToolbar = new GuiImage(); + GuiButton* pButtonPlay = new GuiButton(); pButtonPlay->Initialize(pResourceManager); pButtonPlay->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Play.tga", true); @@ -339,21 +343,20 @@ pLevelDialog->Add(pLevelDialogOk); - /* + pGameDialog = new GuiImage(); + pGameDialog->Initialize(pResourceManager); + pGameDialog->ClearFlag(GuiElementFlag_Visible); + pGameDialog->SetTexture("Data\\Textures\\Dialog0.tga", true); + pGameDialog->SetPosition(0.5f * (ScreenSizeX - pGameDialog->GetWidth()), 0.5f * (ScreenSizeY - pGameDialog->GetHeight())); + pGameDialogOk = new GuiButton(); pGameDialogOk->Initialize(pResourceManager); pGameDialogOk->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button.tga", true); pGameDialogOk->SetText("Ok"); pGameDialogOk->SetPosition(0.5f * (pGameDialog->GetWidth() - pGameDialogOk->GetWidth()), 171.0f); - pGameDialogOk->Subscribe(GuiButton::EventClick, &World::OnOk, this); - */ + pGameDialogOk->Subscribe(GuiButton::EventClick, &World::OnExit, this); - pGameDialog = new GuiImage(); - pGameDialog->Initialize(pResourceManager); - pGameDialog->ClearFlag(GuiElementFlag_Visible); - pGameDialog->SetTexture("Data\\Textures\\Dialog0.tga", true); - pGameDialog->SetPosition(0.5f * (ScreenSizeX - pGameDialog->GetWidth()), 0.5f * (ScreenSizeY - pGameDialog->GetHeight())); - //pGameDialog->Add(pGameDialogOk); + pGameDialog->Add(pGameDialogOk); kInterface.Add(pBackground); kInterface.Add(pButtonPlay); @@ -490,9 +493,10 @@ } #endif - const float fMouseX = pInputManager->GetMouseX(); - const float fMouseY = pInputManager->GetMouseY(); + //const float fMouseX = pInputManager->GetMouseX(); + //const float fMouseY = pInputManager->GetMouseY(); + /* if(nGameState == GameState_Active) { if(pInputManager->IsButtonDown(0) && !pInputManager->WasButtonDown(0)) @@ -593,7 +597,7 @@ } } - /* + #if 0 int32 nSelection = kDialog.Pick(fMouseX, fMouseY); if(nSelection == DialogButton_A) @@ -608,7 +612,7 @@ nGameState = GameState_LoadMap; } - */ + #endif } } else @@ -630,7 +634,7 @@ } } - /* + #if 0 int32 nSelection = kDialog.Pick(fMouseX, fMouseY); if(nSelection == DialogButton_A) @@ -638,7 +642,7 @@ nCurrentLevel = 0; nGameState = GameState_LoadMap; } - */ + #endif } } else @@ -665,7 +669,7 @@ } } - /* + #if 0 int32 nSelection = kDialog.Pick(fMouseX, fMouseY); if(nSelection == DialogButton_A) @@ -678,9 +682,10 @@ { nGameState = GameState_Active; } - */ + #endif } } + */ } /*
--- a/LightClone/Source/World.h Fri Sep 16 15:28:15 2011 -0700 +++ b/LightClone/Source/World.h Fri Sep 16 18:21:36 2011 -0700 @@ -14,10 +14,10 @@ #include "Code.h" #include "Loader.h" #include "CameraController.h" -#include "DragController.h" +//#include "DragController.h" #include "InputManager.h" -#include "ButtonPane.h" -#include "Dialog.h" +//#include "ButtonPane.h" +//#include "Dialog.h" #include "GuiInterface.h" #include "GuiImage.h" #include "GuiButton.h" @@ -88,44 +88,39 @@ GuiInterface kInterface; /* - * kDragController - */ - DragController kDragController; - - /* * kToolbar */ - ButtonPane kToolbar; + //ButtonPane kToolbar; /* * kMain */ - ButtonPane kMain; + //ButtonPane kMain; /* * kFunction */ - ButtonPane kFunction; + //ButtonPane kFunction; /* * kArrowBounds */ - Rectangle2 kArrowBounds[2]; + //Rectangle2 kArrowBounds[2]; /* * kDialog1Bounds */ - Rectangle2 kDialog1Bounds[1]; + //Rectangle2 kDialog1Bounds[1]; /* * kDialog2Bounds */ - Rectangle2 kDialog2Bounds[2]; + //Rectangle2 kDialog2Bounds[2]; /* * kDialog */ - Dialog kDialog; + //Dialog kDialog; /* * pLevelDialog