# HG changeset patch # User koryspansel # Date 1317755049 25200 # Node ID 44dcff5abf127628ce4c5d6e0038b209741266cf # Parent 6d4437a24aeba28ff7d65a4c2fbd14758406e047 Work on ServiceProvider diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/LightClone.vcproj --- a/LightClone/LightClone.vcproj Mon Oct 03 15:14:41 2011 -0700 +++ b/LightClone/LightClone.vcproj Tue Oct 04 12:04:09 2011 -0700 @@ -306,6 +306,14 @@ > + + + + @@ -480,6 +488,14 @@ > + + + + diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/InputManager.h --- a/LightClone/Source/InputManager.h Mon Oct 03 15:14:41 2011 -0700 +++ b/LightClone/Source/InputManager.h Tue Oct 04 12:04:09 2011 -0700 @@ -8,6 +8,7 @@ #define DIRECTINPUT_VERSION 0x0800 #include #include "Core.h" +#include "Service.h" /* * MouseButton @@ -23,7 +24,7 @@ /* * InputManager */ -class InputManager +class InputManager : public Service { /* * pDirectInput diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/Mediator.cpp --- a/LightClone/Source/Mediator.cpp Mon Oct 03 15:14:41 2011 -0700 +++ b/LightClone/Source/Mediator.cpp Tue Oct 04 12:04:09 2011 -0700 @@ -84,53 +84,76 @@ InitializeTrace(TraceFlag_Debug | TraceFlag_File); ErrorCode eCode = kWindow.Initialize(); - if(eCode == Error_Success) + if(eCode != Error_Success) + { + TRACE("Error: Failed to initialize window\n"); + + Terminate(); + return eCode; + } + + eCode = GraphicsDevice::Create(kWindow.GetHandle(), ScreenSizeX, ScreenSizeY, &pGraphicsDevice); + if(eCode != Error_Success) { - ErrorCode eCode = GraphicsDevice::Create(kWindow.GetHandle(), ScreenSizeX, ScreenSizeY, &pGraphicsDevice); - if(eCode != Error_Success) - { - TRACE("Error: Failed to initialize graphics device\n"); - - Terminate(); - return Error_Fail; - } + TRACE("Error: Failed to initialize graphics device\n"); + + Terminate(); + return eCode; + } + + eCode = kContext.Initialize(pGraphicsDevice); + if(eCode != Error_Success) + { + TRACE("Error: Failed to initialize render context\n"); - eCode = kContext.Initialize(pGraphicsDevice); - if(eCode != Error_Success) - { - TRACE("Error: Failed to initialize render context\n"); + Terminate(); + return eCode; + } - Terminate(); - return Error_Fail; - } + eCode = kResourceManager.Initialize(pGraphicsDevice); + if(eCode != Error_Success) + { + TRACE("Error: Failed to initialize resource manager\n"); + + Terminate(); + return eCode; + } - eCode = kResourceManager.Initialize(pGraphicsDevice); - if(eCode != Error_Success) - { - TRACE("Error: Failed to initialize resource manager\n"); + eCode = kInputManager.Initialize(kWindow.GetHandle()); + if(eCode != Error_Success) + { + TRACE("Error: Failed to initialize input manager\n"); + + Terminate(); + return eCode; + } - Terminate(); - return Error_Fail; - } + eCode = kWorld.Initialize(&kResourceManager, &kInputManager); + if(eCode != Error_Success) + { + TRACE("Error: Failed to initialize world\n"); - eCode = kInputManager.Initialize(kWindow.GetHandle()); - if(eCode != Error_Success) - { - TRACE("Error: Failed to initialize input manager\n"); + Terminate(); + return eCode; + } - Terminate(); - return Error_Fail; - } + eCode = kServiceProvider.AddService("ResourceManager", &kResourceManager); + if(eCode != Error_Success) + { + TRACE("Error: Failed to add resource manager service\n"); + + Terminate(); + return eCode; + } - eCode = kWorld.Initialize(&kResourceManager, &kInputManager); - if(eCode != Error_Success) - { - TRACE("Error: Failed to initialize world\n"); + eCode = kServiceProvider.AddService("InputManager", &kInputManager); + if(eCode != Error_Success) + { + TRACE("Error: Failed to add input manager service\n"); - Terminate(); - return Error_Fail; - } - } + Terminate(); + return eCode; + } return eCode; } diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/Mediator.h --- a/LightClone/Source/Mediator.h Mon Oct 03 15:14:41 2011 -0700 +++ b/LightClone/Source/Mediator.h Tue Oct 04 12:04:09 2011 -0700 @@ -13,6 +13,7 @@ #include "ResourceManager.h" #include "RenderContext.h" #include "World.h" +#include "ServiceProvider.h" /* * Mediator @@ -50,6 +51,11 @@ InputManager kInputManager; /* + * kServiceProvider + */ + ServiceProvider kServiceProvider; + + /* * kWorld */ World kWorld; diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/ResourceManager.h --- a/LightClone/Source/ResourceManager.h Mon Oct 03 15:14:41 2011 -0700 +++ b/LightClone/Source/ResourceManager.h Tue Oct 04 12:04:09 2011 -0700 @@ -9,6 +9,7 @@ #include "GraphicsDevice.h" #include "FixedString.h" #include "HashMap.h" +#include "Service.h" /* * ResourceType @@ -31,7 +32,7 @@ /* * ResourceManager */ -class ResourceManager +class ResourceManager : public Service { /* * TextureCache diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/Service.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/Service.cpp Tue Oct 04 12:04:09 2011 -0700 @@ -0,0 +1,12 @@ +/* + * Service + */ + +#include "Service.h" + +/* + * ~Service + */ +Service::~Service() +{ +} diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/Service.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/Service.h Tue Oct 04 12:04:09 2011 -0700 @@ -0,0 +1,23 @@ +/* + * Service + */ + +#ifndef __SERVICE_H__ +#define __SERVICE_H__ + +#include "Types.h" + +/* + * Service + */ +class Service +{ +public: + + /* + * ~Service + */ + virtual ~Service(); +}; + +#endif //__SERVICE_H__ diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/ServiceProvider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/ServiceProvider.cpp Tue Oct 04 12:04:09 2011 -0700 @@ -0,0 +1,21 @@ +/* + * ServiceProvider + */ + +#include "ServiceProvider.h" + +/* + * AddService + */ +ErrorCode ServiceProvider::AddService(const char* pName, Service* pService) +{ + return Error_Success; +} + +/* + * GetService + */ +Service* ServiceProvider::GetService(const char* pName) +{ + return 0; +} diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/Source/ServiceProvider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LightClone/Source/ServiceProvider.h Tue Oct 04 12:04:09 2011 -0700 @@ -0,0 +1,49 @@ +/* + * ServiceProvider + */ + +#ifndef __SERVICEPROVIDER_H__ +#define __SERVICEPROVIDER_H__ + +#include "Types.h" +#include "Service.h" + +/* + * ServiceProvider + */ +class ServiceProvider +{ +public: + + /* + * AddService + */ + ErrorCode AddService(const char* pName, Service* pService); + + /* + * GetService + */ + Service* GetService(const char* pName); + + /* + * GetService + */ + template + ErrorCode GetService(const char* pName, Service** pService) + { + ErrorCode eCode = Error_Fail; + + if(pService) + { + *pService = (ServiceType*)GetService(pName); + if(*pService) + { + eCode = Error_Success; + } + } + + return eCode; + } +}; + +#endif //__SERVICEPROVIDER_H__ diff -r 6d4437a24aeb -r 44dcff5abf12 LightClone/ToDo.txt --- a/LightClone/ToDo.txt Mon Oct 03 15:14:41 2011 -0700 +++ b/LightClone/ToDo.txt Tue Oct 04 12:04:09 2011 -0700 @@ -3,7 +3,6 @@ 2. Main menu 3. Pause menu 4. Additional maps -5. Add camera position to map Polish: 1. Button tool tips