diff LightClone/Source/Mediator.cpp @ 63:44dcff5abf12

Work on ServiceProvider
author koryspansel
date Tue, 04 Oct 2011 12:04:09 -0700
parents dc1f4a668d50
children 3507bd831c7f
line wrap: on
line diff
--- 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;
 }