summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/GameWinDX9.h
blob: c6862da310052a80af625587d75a0dd16a80a4e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*  Starshatter: The Open Source Project
    Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
    Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
    Copyright (c) 1997-2006, Destroyer Studios LLC.
*/

#ifndef GameWinDX9_h
#define GameWinDX9_h

#include "Color.h"
#include "Game.h"
#include "Screen.h"
#include "SoundCard.h"
#include "Types.h"
#include "VideoFactory.h"
#include "Video.h"
#include "VideoSettings.h"
#include "WndProc.h"


class GameWinDX9 : public Game
{
public:
    static GameWinDX9* GetInstance();

    GameWinDX9();
    virtual ~GameWinDX9();

    virtual bool Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow);
    virtual bool InitApplication(HINSTANCE hInstance);
    virtual bool InitInstance(HINSTANCE hInstance, int nCmdShow);
    virtual bool InitGame();

    virtual bool InitVideo();
    virtual bool ResizeVideo();
    virtual bool ResetVideo();
    virtual bool ToggleFullscreen();
    virtual bool AdjustWindowForChange();

    virtual bool SetupPalette();
    virtual bool LoadPalette(PALETTEENTRY* pal, BYTE* inv);

    virtual void PumpEvents() override;
    virtual void UpdateScreen() override;
    virtual void Activate(bool f) override;
    virtual void Pause(bool f) override;
    void ShowStats();

    int MaxTexSize() const;
    int MaxTexAspect() const;
    Color GetScreenColor() const;
    int GetScreenWidth() const;
    int GetScreenHeight() const;

    HINSTANCE GetHINST();
    HWND GetHWND();

    void SetMaxTexSize(int n);
    void SetScreenColor(Color c);


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;

    HINSTANCE         hInst;
    HWND              hwnd;
    HMENU             hmenu;

    // Internal variables for the state of the app
    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

    const char*       app_name;
    const char*       title_text;
    const char*       palette_name;

    VideoFactory*     video_factory;
    Video*            video;
    VideoSettings*    video_settings;
    SoundCard*        soundcard;
    Screen*           screen;

    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;
};


#endif  // GameWinDX9_h