From 9f9f2456d5ee0091bf171fae3ad321f82e5f2ca4 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 23 Mar 2022 21:59:48 +0100 Subject: Moved application state internals to GameWinDX9 --- Stars45/Game.cpp | 17 ----------------- Stars45/Game.h | 12 ------------ Stars45/GameWinDX9.cpp | 10 +++++++++- Stars45/GameWinDX9.h | 12 ++++++++++++ Stars45/PlayerDlg.cpp | 1 + Stars45/WndProc.cpp | 12 +++++------- 6 files changed, 27 insertions(+), 37 deletions(-) (limited to 'Stars45') diff --git a/Stars45/Game.cpp b/Stars45/Game.cpp index 7e75634..62d1e69 100644 --- a/Stars45/Game.cpp +++ b/Stars45/Game.cpp @@ -50,15 +50,6 @@ Game::Game() max_frame_length = MAX_FRAME_TIME_NORMAL; video_settings = new(__FILE__,__LINE__) VideoSettings; - - is_windowed = false; - is_active = false; - is_device_lost = false; - is_minimized = false; - is_maximized = false; - ignore_size_change = false; - is_device_initialized = false; - is_device_restored = false; } else status = TOO_MANY; @@ -98,14 +89,6 @@ HWND Game::GetHWND() return 0; } -bool Game::IsWindowed() -{ - if (game) - return game->is_windowed; - - return false; -} - // +--------------------------------------------------------------------+ bool diff --git a/Stars45/Game.h b/Stars45/Game.h index 6b69788..d0d5841 100644 --- a/Stars45/Game.h +++ b/Stars45/Game.h @@ -15,7 +15,6 @@ #include "Screen.h" #include "Video.h" #include "VideoSettings.h" -#include "WndProc.h" // +--------------------------------------------------------------------+ @@ -69,7 +68,6 @@ public: bool Paused() { return paused; } bool Server() { return server; } bool ShowMouse() { return show_mouse; } - bool IsWindowed(); HINSTANCE GetHINST(); HWND GetHWND(); @@ -85,8 +83,6 @@ public: virtual void ShowStats(); protected: - friend LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam); - Universe* world; VideoFactory* video_factory; Video* video; @@ -107,14 +103,6 @@ protected: char* palette_name; // Internal variables for the state of the app - bool is_windowed; - bool is_active; - bool is_device_lost; - bool is_minimized; - bool is_maximized; - bool ignore_size_change; - bool is_device_initialized; - bool is_device_restored; DWORD window_style; // Saved window style for mode switches RECT bounds_rect; // Saved window bounds for mode switches RECT client_rect; // Saved client area size for mode switches diff --git a/Stars45/GameWinDX9.cpp b/Stars45/GameWinDX9.cpp index cc86769..2189712 100644 --- a/Stars45/GameWinDX9.cpp +++ b/Stars45/GameWinDX9.cpp @@ -35,7 +35,15 @@ GameWinDX9::GetInstance() GameWinDX9::GameWinDX9() : max_tex_size {2048}, - screen_color {Color::Black} + screen_color {Color::Black}, + is_windowed {false}, + is_active {false}, + is_device_lost {false}, + is_minimized {false}, + is_maximized {false}, + ignore_size_change {false}, + is_device_initialized {false}, + is_device_restored {false} { if (instance != nullptr) Panic::Panic("Multiple instances of GameWinDX9"); diff --git a/Stars45/GameWinDX9.h b/Stars45/GameWinDX9.h index bf5470d..9f31ce1 100644 --- a/Stars45/GameWinDX9.h +++ b/Stars45/GameWinDX9.h @@ -10,6 +10,7 @@ #include "Color.h" #include "Game.h" #include "Types.h" +#include "WndProc.h" class GameWinDX9 : public Game @@ -45,12 +46,23 @@ public: protected: + friend LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam); + PALETTEENTRY standard_palette[256]; BYTE inverse_palette[32768]; int max_tex_size; Color screen_color; + bool is_windowed; + bool is_active; + bool is_device_lost; + bool is_minimized; + bool is_maximized; + bool ignore_size_change; + bool is_device_initialized; + bool is_device_restored; + private: static GameWinDX9* instance; }; diff --git a/Stars45/PlayerDlg.cpp b/Stars45/PlayerDlg.cpp index 1c09161..0ea6d18 100644 --- a/Stars45/PlayerDlg.cpp +++ b/Stars45/PlayerDlg.cpp @@ -31,6 +31,7 @@ #include "Video.h" #include "Keyboard.h" #include "MachineInfo.h" +#include "WndProc.h" // +--------------------------------------------------------------------+ // DECLARE MAPPING FUNCTIONS: diff --git a/Stars45/WndProc.cpp b/Stars45/WndProc.cpp index f473752..1f068b3 100644 --- a/Stars45/WndProc.cpp +++ b/Stars45/WndProc.cpp @@ -6,7 +6,6 @@ #include "WndProc.h" -#include "Game.h" #include "GameWinDX9.h" #include "Keyboard.h" #include "Mouse.h" @@ -21,8 +20,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam) { - auto game = Game::GetInstance(); - auto app = GameWinDX9::GetInstance(); + auto game = GameWinDX9::GetInstance(); switch (message) { case WM_SYSKEYDOWN: if (uParam == VK_TAB || uParam == VK_F4) @@ -77,19 +75,19 @@ WndProc(HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam) game->is_minimized = false; game->is_maximized = true; - app->ResizeVideo(); + game->ResizeVideo(); } else if (uParam == SIZE_RESTORED) { if (game->is_maximized) { game->is_maximized = false; - app->ResizeVideo(); + game->ResizeVideo(); } else if (game->is_minimized) { game->Pause(false); // Unpause since we're no longer minimized game->is_minimized = false; - app->ResizeVideo(); + game->ResizeVideo(); } else { // If we're neither maximized nor minimized, the window size @@ -104,7 +102,7 @@ WndProc(HWND hwnd, UINT message, WPARAM uParam, LPARAM lParam) case WM_EXITSIZEMOVE: if (game) { game->Pause(false); - app->ResizeVideo(); + game->ResizeVideo(); } break; -- cgit v1.1