summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-23 21:59:48 +0100
committerAki <please@ignore.pl>2022-03-23 21:59:48 +0100
commit9f9f2456d5ee0091bf171fae3ad321f82e5f2ca4 (patch)
treefb5a264f26e4c3b07dc1c8e6260e7730b44fd343
parent2c4aaec387ffe0eb60f92a027539195993b6408f (diff)
downloadstarshatter-9f9f2456d5ee0091bf171fae3ad321f82e5f2ca4.zip
starshatter-9f9f2456d5ee0091bf171fae3ad321f82e5f2ca4.tar.gz
starshatter-9f9f2456d5ee0091bf171fae3ad321f82e5f2ca4.tar.bz2
Moved application state internals to GameWinDX9
-rw-r--r--Stars45/Game.cpp17
-rw-r--r--Stars45/Game.h12
-rw-r--r--Stars45/GameWinDX9.cpp10
-rw-r--r--Stars45/GameWinDX9.h12
-rw-r--r--Stars45/PlayerDlg.cpp1
-rw-r--r--Stars45/WndProc.cpp12
6 files changed, 27 insertions, 37 deletions
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;