summaryrefslogtreecommitdiffhomepage
path: root/Stars45/Starshatter.h
blob: f18967d15828265a6889cf1cb0bdc2ee83fc2e5a (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*  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.

    AUTHOR:       John DiCamillo

*/

#ifndef Starshatter_h
#define Starshatter_h

#include "Types.h"
#include "GameWinDX9.h"
#include "Bitmap.h"
#include "KeyMap.h"
#include "Text.h"

// +--------------------------------------------------------------------+

class Campaign;
class MenuScreen;
class CmpnScreen;
class PlanScreen;
class LoadScreen;
class GameScreen;
class Ship;
class Sim;
class FadeView;
class CameraDirector;
class MultiController;
class MouseController;
class MusicDirector;
class DataLoader;
class Font;
class TrackIR;
class Mission;

class NetServer;
class NetLobby;

// +--------------------------------------------------------------------+

class Starshatter : public GameWinDX9
{
public:
    Starshatter();
    virtual ~Starshatter();

    virtual bool      Init(HINSTANCE hi, HINSTANCE hpi, LPSTR cmdline, int nCmdShow);
    virtual bool      InitGame();
    virtual bool      ChangeVideo();
    virtual void      GameState();
    virtual void      Exit();
    virtual bool      OnHelp();

    enum MODE   {     MENU_MODE,  // main menu
        CLOD_MODE,  // loading campaign
        CMPN_MODE,  // operational command for dynamic campaign
        PREP_MODE,  // loading mission info for planning
        PLAN_MODE,  // mission briefing
        LOAD_MODE,  // loading mission into simulator
        PLAY_MODE,  // active simulation
        EXIT_MODE   // shutting down
    };

    enum LOBBY  {     NET_LOBBY_CLIENT,
        NET_LOBBY_SERVER
    };

    int       GetGameMode()       { return game_mode; }
    void      SetGameMode(int mode);
    void      RequestChangeVideo();
    void      LoadVideoConfig(const char* filename);
    void      SaveVideoConfig(const char* filename);
    void      SetupSplash();
    void      SetupMenuScreen();
    void      SetupCmpnScreen();
    void      SetupPlanScreen();
    void      SetupLoadScreen();
    void      SetupGameScreen();
    void      OpenTacticalReference();
    void      CreateWorld();
    int       KeyDown(int action) const;

    void      PlayerCam(int mode);
    void      ViewSelection();

    void      MapKeys();
    static  void      MapKeys(KeyMap* mapping, int nkeys);
    static  void      MapKey(int act, int key, int alt=0);

    void      SetTestMode(int t)   { test_mode = t;        }

    static Starshatter*  GetInstance()     { return instance;      }

    // graphic options:
    int               LensFlare()          { return lens_flare;    }
    int               Corona()             { return corona;        }
    int               Nebula()             { return nebula;        }
    int               Dust()               { return dust;          }

    KeyMap&           GetKeyMap()          { return keycfg;        }

    int               GetLoadProgress()    { return load_progress; }
    const char*       GetLoadActivity()    { return load_activity; }

    int               GetChatMode() const  { return chat_mode;        }
    void              SetChatMode(int c);
    const char*       GetChatText() const  { return chat_text.data(); }

    void              StopNetGame();

    int               GetLobbyMode();
    void              SetLobbyMode(int mode = NET_LOBBY_CLIENT);
    void              StartLobby();
    void              StopLobby();

    void              ExecCutscene(const char* msn_file, const char* path);
    void              BeginCutscene();
    void              EndCutscene();
    bool              InCutscene()         const { return cutscene > 0; }
    Mission*          GetCutsceneMission() const;
    const char*       GetSubtitles()       const;
    void              EndMission();

    void              StartOrResumeGame();

    static bool       UseFileSystem();

protected:
    virtual void      DoMenuScreenFrame();
    virtual void      DoCmpnScreenFrame();
    virtual void      DoPlanScreenFrame();
    virtual void      DoLoadScreenFrame();
    virtual void      DoGameScreenFrame();
    virtual void      DoMouseFrame();

    virtual void      DoChatMode();
    virtual void      DoGameKeys();

    virtual bool      GameLoop();
    virtual void      UpdateWorld();
    virtual void      InstantiateMission();
    virtual bool      ResizeVideo();
    virtual void      InitMouse();

    static Starshatter*     instance;
    Window*                 gamewin;
    MenuScreen*             menuscreen;
    LoadScreen*             loadscreen;
    PlanScreen*             planscreen;
    GameScreen*             gamescreen;
    CmpnScreen*             cmpnscreen;

    FadeView*               splash;
    int                     splash_index;
    Bitmap                  splash_image;
    MultiController*        input;
    MouseController*        mouse_input;
    TrackIR*                head_tracker;
    DataLoader*             loader;

    Ship*                   player_ship;
    CameraDirector*         cam_dir;
    MusicDirector*          music_dir;

    Font*                   HUDfont;
    Font*                   GUIfont;
    Font*                   GUI_small_font;
    Font*                   terminal;
    Font*                   verdana;
    Font*                   title_font;
    Font*                   limerick18;
    Font*                   limerick12;
    Font*                   ocrb;

    DWORD                   time_mark;
    DWORD                   minutes;

    double                  field_of_view;
    double                  orig_fov;

    static int              keymap[256];
    static int              keyalt[256];
    KeyMap                  keycfg;

    bool                    tactical;
    bool                    spinning;
    int                     mouse_x;
    int                     mouse_y;
    int                     mouse_dx;
    int                     mouse_dy;

    int                     game_mode;
    int                     test_mode;
    int                     req_change_video;
    int                     video_changed;

    int                     lens_flare;
    int                     corona;
    int                     nebula;
    int                     dust;

    double                  exit_time;

    int                     load_step;
    int                     load_progress;
    Text                    load_activity;
    int                     catalog_index;

    int                     cutscene;
    int                     lobby_mode;
    NetLobby*               net_lobby;
    int                     chat_mode;
    Text                    chat_text;
};

#endif  // Starshatter_h