From 2ae135bbe43065978a4659278d18d9533d8a3b27 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 17 Feb 2022 10:26:46 +0100 Subject: Everything but panic and singleton impl is now instance based --- Stars45/Game.cpp | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'Stars45/Game.cpp') diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp index d0a5735..c1c4463 100644 --- a/Stars45/Game.cpp +++ b/Stars45/Game.cpp @@ -744,15 +744,13 @@ Game::InitContent() void Game::UseLocale(Locale* locale) { - if (game) { - DataLoader* loader = DataLoader::GetLoader(); - loader->SetDataPath("Content/"); - delete game->content; + DataLoader* loader = DataLoader::GetLoader(); + loader->SetDataPath("Content/"); + delete content; - game->content = new(__FILE__,__LINE__) ContentBundle("content", locale); + content = new(__FILE__,__LINE__) ContentBundle("content", locale); - loader->SetDataPath(0); - } + loader->SetDataPath(0); } // +--------------------------------------------------------------------+ @@ -1012,28 +1010,22 @@ Game::GetVideo() Color Game::GetScreenColor() { - if (game) - return game->screen_color; - - return Color::Black; + return screen_color; } void Game::SetScreenColor(Color c) { - if (game) { - game->screen_color = c; - - if (game->screen) - game->screen->SetBackgroundColor(c); - } + screen_color = c; + if (screen) + screen->SetBackgroundColor(c); } int Game::GetScreenWidth() { - if (game && game->video) - return game->video->Width(); + if (video) + return video->Width(); return 0; } @@ -1041,8 +1033,8 @@ Game::GetScreenWidth() int Game::GetScreenHeight() { - if (game && game->video) - return game->video->Height(); + if (video) + return video->Height(); return 0; } @@ -1141,7 +1133,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam) break; case WM_SETCURSOR: - if (Game::ShowMouse()) { + if (game && game->ShowMouse()) { return DefWindowProc(hwnd, message, uParam, lParam); } else { @@ -1366,8 +1358,9 @@ GetKeyPlus(int& key, int& shift) DWORD GetRealTime() { + Game* game = Game::GetInstance(); if (game) - return Game::RealTime(); + return game->RealTime(); return timeGetTime(); } -- cgit v1.1