summaryrefslogtreecommitdiffhomepage
path: root/StarsEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-03 22:51:15 +0200
committerAki <please@ignore.pl>2022-04-03 22:51:15 +0200
commit4cc312f90d27ea7abb010bd317188d9d08a9fd3e (patch)
tree844ae61007f22a9c561221aad814a54562972641 /StarsEx
parent4b8ddd088afb8f0021c6cfa1b7700e0b521b8ac5 (diff)
downloadstarshatter-4cc312f90d27ea7abb010bd317188d9d08a9fd3e.zip
starshatter-4cc312f90d27ea7abb010bd317188d9d08a9fd3e.tar.gz
starshatter-4cc312f90d27ea7abb010bd317188d9d08a9fd3e.tar.bz2
Added base game mode management to Game
Diffstat (limited to 'StarsEx')
-rw-r--r--StarsEx/AwardDlg.cpp4
-rw-r--r--StarsEx/CampaignMissionFighter.cpp3
-rw-r--r--StarsEx/CampaignMissionStarship.cpp3
-rw-r--r--StarsEx/CmdDlg.cpp2
-rw-r--r--StarsEx/CmdMissionsDlg.cpp2
-rw-r--r--StarsEx/CmpSelectDlg.cpp3
-rw-r--r--StarsEx/CmpnScreen.cpp5
-rw-r--r--StarsEx/DebriefDlg.cpp5
-rw-r--r--StarsEx/Game.cpp3
-rw-r--r--StarsEx/Game.h14
-rw-r--r--StarsEx/LoadDlg.cpp6
-rw-r--r--StarsEx/LoadScreen.cpp5
-rw-r--r--StarsEx/MissionEvent.cpp2
-rw-r--r--StarsEx/MsnDlg.cpp6
-rw-r--r--StarsEx/MsnSelectDlg.cpp2
-rw-r--r--StarsEx/MusicTrack.cpp2
-rw-r--r--StarsEx/NetLobbyClient.cpp3
-rw-r--r--StarsEx/NetLobbyServer.cpp19
-rw-r--r--StarsEx/QuitView.cpp6
-rw-r--r--StarsEx/Sim.cpp6
-rw-r--r--StarsEx/StarServer.cpp2
-rw-r--r--StarsEx/StarServer.h9
-rw-r--r--StarsEx/Starshatter.cpp6
-rw-r--r--StarsEx/Starshatter.h14
24 files changed, 68 insertions, 64 deletions
diff --git a/StarsEx/AwardDlg.cpp b/StarsEx/AwardDlg.cpp
index bdaf4a5..90e1bb4 100644
--- a/StarsEx/AwardDlg.cpp
+++ b/StarsEx/AwardDlg.cpp
@@ -141,9 +141,9 @@ AwardDlg::OnClose(AWEvent* event)
Campaign* campaign = Campaign::GetCampaign();
if (campaign && campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS)
- stars->SetGameMode(Starshatter::CMPN_MODE);
+ stars->SetGameMode(Game::CMPN_MODE);
else
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
}
else
diff --git a/StarsEx/CampaignMissionFighter.cpp b/StarsEx/CampaignMissionFighter.cpp
index be39d58..78409e9 100644
--- a/StarsEx/CampaignMissionFighter.cpp
+++ b/StarsEx/CampaignMissionFighter.cpp
@@ -34,6 +34,7 @@
#include "ContentBundle.h"
#include "Random.h"
+#include "Game.h"
static int pkg_id = 1000;
extern int dump_missions;
@@ -2150,5 +2151,5 @@ CampaignMissionFighter::Exit()
{
Starshatter* stars = Starshatter::GetInstance();
if (stars)
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
}
diff --git a/StarsEx/CampaignMissionStarship.cpp b/StarsEx/CampaignMissionStarship.cpp
index 60d88af..63f182e 100644
--- a/StarsEx/CampaignMissionStarship.cpp
+++ b/StarsEx/CampaignMissionStarship.cpp
@@ -32,6 +32,7 @@
#include "Player.h"
#include "ContentBundle.h"
#include "Random.h"
+#include "Game.h"
static int pkg_id = 1000;
extern int dump_missions;
@@ -1399,5 +1400,5 @@ CampaignMissionStarship::Exit()
{
Starshatter* stars = Starshatter::GetInstance();
if (stars)
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
}
diff --git a/StarsEx/CmdDlg.cpp b/StarsEx/CmdDlg.cpp
index d260c6c..89f7a9e 100644
--- a/StarsEx/CmdDlg.cpp
+++ b/StarsEx/CmdDlg.cpp
@@ -175,7 +175,7 @@ CmdDlg::OnExit(AWEvent* event)
{
if (stars) {
Mouse::Show(false);
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
}
}
diff --git a/StarsEx/CmdMissionsDlg.cpp b/StarsEx/CmdMissionsDlg.cpp
index ee5b265..ab71bdd 100644
--- a/StarsEx/CmdMissionsDlg.cpp
+++ b/StarsEx/CmdMissionsDlg.cpp
@@ -320,5 +320,5 @@ CmdMissionsDlg::OnAccept(AWEvent* event)
Mouse::Show(false);
campaign->SetMissionId(mission->Identity());
campaign->StartMission();
- stars->SetGameMode(Starshatter::PREP_MODE);
+ stars->SetGameMode(Game::PREP_MODE);
}
diff --git a/StarsEx/CmpSelectDlg.cpp b/StarsEx/CmpSelectDlg.cpp
index 95f9efa..6942a60 100644
--- a/StarsEx/CmpSelectDlg.cpp
+++ b/StarsEx/CmpSelectDlg.cpp
@@ -34,6 +34,7 @@
#include "Mouse.h"
#include "ParseUtil.h"
#include "FormatUtil.h"
+#include "Game.h"
// +--------------------------------------------------------------------+
// DECLARE MAPPING FUNCTIONS:
@@ -500,7 +501,7 @@ CmpSelectDlg::OnAccept(AWEvent* event)
Clock::GetInstance()->ResetGameTime();
Mouse::Show(false);
- stars->SetGameMode(Starshatter::CLOD_MODE);
+ stars->SetGameMode(Game::CLOD_MODE);
}
void
diff --git a/StarsEx/CmpnScreen.cpp b/StarsEx/CmpnScreen.cpp
index 970eaf9..70fcf8a 100644
--- a/StarsEx/CmpnScreen.cpp
+++ b/StarsEx/CmpnScreen.cpp
@@ -41,6 +41,7 @@
#include "FontMgr.h"
#include "EventDispatch.h"
#include "DataLoader.h"
+#include "Game.h"
// +--------------------------------------------------------------------+
@@ -283,7 +284,7 @@ CmpnScreen::ExecFrame()
if (c) {
c->Load();
Campaign::SelectCampaign(c->Name());
- stars->SetGameMode(Starshatter::CLOD_MODE);
+ stars->SetGameMode(Game::CLOD_MODE);
return;
}
}
@@ -297,7 +298,7 @@ CmpnScreen::ExecFrame()
else {
Mouse::Show(false);
MusicDirector::SetMode(MusicDirector::MENU);
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
return;
}
}
diff --git a/StarsEx/DebriefDlg.cpp b/StarsEx/DebriefDlg.cpp
index d4977ab..a0a2b30 100644
--- a/StarsEx/DebriefDlg.cpp
+++ b/StarsEx/DebriefDlg.cpp
@@ -39,6 +39,7 @@
#include "Slider.h"
#include "ParseUtil.h"
#include "Panic.h"
+#include "Game.h"
// +--------------------------------------------------------------------+
// DECLARE MAPPING FUNCTIONS:
@@ -361,9 +362,9 @@ DebriefDlg::OnClose(AWEvent* event)
Campaign* campaign = Campaign::GetCampaign();
if (campaign && campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS)
- stars->SetGameMode(Starshatter::CMPN_MODE);
+ stars->SetGameMode(Game::CMPN_MODE);
else
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
}
else {
diff --git a/StarsEx/Game.cpp b/StarsEx/Game.cpp
index d4de97c..4fda01e 100644
--- a/StarsEx/Game.cpp
+++ b/StarsEx/Game.cpp
@@ -34,7 +34,8 @@ const double MAX_FRAME_TIME_NORMAL = 1.0 / 5.0;
Game::Game() :
world(0),
status(Game::OK),
- exit_code(0)
+ exit_code(0),
+ game_mode(MENU_MODE)
{
Clock::Init();
if (!game) {
diff --git a/StarsEx/Game.h b/StarsEx/Game.h
index 4070faf..cf62744 100644
--- a/StarsEx/Game.h
+++ b/StarsEx/Game.h
@@ -23,6 +23,16 @@ class Game
public:
static const char* TYPENAME() { return "Game"; }
enum STATUS { OK, RUN, EXIT, INIT_FAILED, TOO_MANY };
+ enum MODE {
+ MENU_MODE,
+ CLOD_MODE,
+ CMPN_MODE,
+ PREP_MODE,
+ PLAN_MODE,
+ LOAD_MODE,
+ PLAY_MODE,
+ EXIT_MODE,
+ };
Game();
virtual ~Game();
@@ -37,6 +47,9 @@ public:
virtual bool OnPaint() { return false; }
virtual bool OnHelp() { return false; }
+ virtual int GetGameMode() const { return game_mode; }
+ virtual void SetGameMode(int mode) { game_mode = mode; }
+
virtual void Activate(bool f);
virtual void Pause(bool f);
int Status() const { return status; }
@@ -69,6 +82,7 @@ protected:
int status;
int exit_code;
+ int game_mode;
bool active;
bool paused;
diff --git a/StarsEx/LoadDlg.cpp b/StarsEx/LoadDlg.cpp
index 1138fec..61bafa7 100644
--- a/StarsEx/LoadDlg.cpp
+++ b/StarsEx/LoadDlg.cpp
@@ -56,11 +56,11 @@ LoadDlg::ExecFrame()
if (stars) {
if (title) {
- if (stars->GetGameMode() == Starshatter::CLOD_MODE ||
- stars->GetGameMode() == Starshatter::CMPN_MODE)
+ if (stars->GetGameMode() == Game::CLOD_MODE ||
+ stars->GetGameMode() == Game::CMPN_MODE)
title->SetText(ContentBundle::GetInstance()->GetText("LoadDlg.campaign"));
- else if (stars->GetGameMode() == Starshatter::MENU_MODE)
+ else if (stars->GetGameMode() == Game::MENU_MODE)
title->SetText(ContentBundle::GetInstance()->GetText("LoadDlg.tac-ref"));
else
diff --git a/StarsEx/LoadScreen.cpp b/StarsEx/LoadScreen.cpp
index 60972e2..56234c6 100644
--- a/StarsEx/LoadScreen.cpp
+++ b/StarsEx/LoadScreen.cpp
@@ -12,6 +12,7 @@
#include "CmpLoadDlg.h"
#include "Starshatter.h"
+#include "Game.h"
#include "GameWinDX9.h"
#include "Video.h"
#include "Screen.h"
@@ -132,8 +133,8 @@ LoadScreen::ShowLoadDlg()
// show campaign load dialog if available and loading campaign
if (stars && cmp_load_dlg) {
- if (stars->GetGameMode() == Starshatter::CLOD_MODE ||
- stars->GetGameMode() == Starshatter::CMPN_MODE) {
+ if (stars->GetGameMode() == Game::CLOD_MODE ||
+ stars->GetGameMode() == Game::CMPN_MODE) {
cmp_load_dlg->Show();
Mouse::Show(false);
return;
diff --git a/StarsEx/MissionEvent.cpp b/StarsEx/MissionEvent.cpp
index 24da372..575c855 100644
--- a/StarsEx/MissionEvent.cpp
+++ b/StarsEx/MissionEvent.cpp
@@ -710,7 +710,7 @@ MissionEvent::Execute(bool silent)
if (event_target.length())
server->SetNextMission(event_target);
- server->SetGameMode(StarServer::MENU_MODE);
+ server->SetGameMode(Game::MENU_MODE);
}
}
}
diff --git a/StarsEx/MsnDlg.cpp b/StarsEx/MsnDlg.cpp
index 4d2bfba..f332b3d 100644
--- a/StarsEx/MsnDlg.cpp
+++ b/StarsEx/MsnDlg.cpp
@@ -277,7 +277,7 @@ MsnDlg::OnCommit(AWEvent* event)
if (stars) {
Mouse::Show(false);
- stars->SetGameMode(Starshatter::LOAD_MODE);
+ stars->SetGameMode(Game::LOAD_MODE);
}
else
@@ -293,9 +293,9 @@ MsnDlg::OnCancel(AWEvent* event)
Mouse::Show(false);
if (campaign && (campaign->IsDynamic() || campaign->IsTraining()))
- stars->SetGameMode(Starshatter::CMPN_MODE);
+ stars->SetGameMode(Game::CMPN_MODE);
else
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
}
else
diff --git a/StarsEx/MsnSelectDlg.cpp b/StarsEx/MsnSelectDlg.cpp
index fdd6b06..4137712 100644
--- a/StarsEx/MsnSelectDlg.cpp
+++ b/StarsEx/MsnSelectDlg.cpp
@@ -485,7 +485,7 @@ MsnSelectDlg::OnAccept(AWEvent* event)
campaign->SetMissionId(id);
campaign->ReloadMission(id);
- stars->SetGameMode(Starshatter::PREP_MODE);
+ stars->SetGameMode(Game::PREP_MODE);
}
}
diff --git a/StarsEx/MusicTrack.cpp b/StarsEx/MusicTrack.cpp
index cca61a5..88e970e 100644
--- a/StarsEx/MusicTrack.cpp
+++ b/StarsEx/MusicTrack.cpp
@@ -82,7 +82,7 @@ MusicTrack::ExecFrame()
Starshatter* stars = Starshatter::GetInstance();
if (stars) {
- music_pause = (stars->GetGameMode() == Starshatter::PLAY_MODE) &&
+ music_pause = (stars->GetGameMode() == Game::PLAY_MODE) &&
Game::GetInstance()->Paused();
}
diff --git a/StarsEx/NetLobbyClient.cpp b/StarsEx/NetLobbyClient.cpp
index ca0ff81..df66900 100644
--- a/StarsEx/NetLobbyClient.cpp
+++ b/StarsEx/NetLobbyClient.cpp
@@ -28,6 +28,7 @@
#include "NetLayer.h"
#include "FormatUtil.h"
#include "VersionInfo.h"
+#include "Game.h"
// +-------------------------------------------------------------------+
@@ -217,7 +218,7 @@ NetLobbyClient::GameStart()
Sleep(100);
SetStatus(NetServerInfo::ACTIVE);
- Starshatter::GetInstance()->SetGameMode(Starshatter::PREP_MODE);
+ Starshatter::GetInstance()->SetGameMode(Game::PREP_MODE);
// discard unit map selection data so that
// it will be refreshed when we return to
diff --git a/StarsEx/NetLobbyServer.cpp b/StarsEx/NetLobbyServer.cpp
index b3060c5..b3afc9f 100644
--- a/StarsEx/NetLobbyServer.cpp
+++ b/StarsEx/NetLobbyServer.cpp
@@ -43,6 +43,7 @@
#include "Clock.h"
#include "FormatUtil.h"
#include "VersionInfo.h"
+#include "Game.h"
// +-------------------------------------------------------------------+
@@ -99,7 +100,7 @@ NetLobbyServer::NetLobbyServer()
mission_id = (Campaign::MULTIPLAYER_MISSIONS << NET_CAMPAIGN_SHIFT) + m->id;
SelectMission(mission_id);
- star_server->SetGameMode(StarServer::LOAD_MODE);
+ star_server->SetGameMode(Game::LOAD_MODE);
// lock in mission:
SetStatus(NetServerInfo::PERSISTENT);
@@ -273,7 +274,7 @@ NetLobbyServer::ExecFrame()
// restart persistent mission?
if (star_server &&
- star_server->GetGameMode() == StarServer::MENU_MODE &&
+ star_server->GetGameMode() == Game::MENU_MODE &&
server_mission.length() > 0) {
NetCampaignInfo* c = campaigns.last();
@@ -306,8 +307,8 @@ NetLobbyServer::ExecFrame()
SelectMission(mission_id);
- if (star_server->GetGameMode() == StarServer::MENU_MODE) {
- star_server->SetGameMode(StarServer::LOAD_MODE);
+ if (star_server->GetGameMode() == Game::MENU_MODE) {
+ star_server->SetGameMode(Game::LOAD_MODE);
}
// lock in new mission:
@@ -408,12 +409,12 @@ NetLobbyServer::GameStart()
SetStatus(NetServerInfo::BRIEFING);
if (Starshatter::GetInstance()) {
- Starshatter::GetInstance()->SetGameMode(Starshatter::PREP_MODE);
+ Starshatter::GetInstance()->SetGameMode(Game::PREP_MODE);
}
else {
StarServer* s = StarServer::GetInstance();
- if (s && s->GetGameMode() == StarServer::MENU_MODE) {
- s->SetGameMode(StarServer::LOAD_MODE);
+ if (s && s->GetGameMode() == Game::MENU_MODE) {
+ s->SetGameMode(Game::LOAD_MODE);
}
}
}
@@ -426,8 +427,8 @@ NetLobbyServer::GameStop()
SetStatus(NetServerInfo::LOBBY);
StarServer* s = StarServer::GetInstance();
- if (s && s->GetGameMode() != StarServer::MENU_MODE) {
- s->SetGameMode(StarServer::MENU_MODE);
+ if (s && s->GetGameMode() != Game::MENU_MODE) {
+ s->SetGameMode(Game::MENU_MODE);
}
}
}
diff --git a/StarsEx/QuitView.cpp b/StarsEx/QuitView.cpp
index 90b90ab..8bee3e4 100644
--- a/StarsEx/QuitView.cpp
+++ b/StarsEx/QuitView.cpp
@@ -166,7 +166,7 @@ QuitView::ExecFrame()
Clock::GetInstance()->SetTimeCompression(1.0);
Starshatter* stars = Starshatter::GetInstance();
- stars->SetGameMode(Starshatter::PLAN_MODE);
+ stars->SetGameMode(Game::PLAN_MODE);
}
// quit and discard results:
@@ -183,11 +183,11 @@ QuitView::ExecFrame()
if (campaign && campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS) {
campaign->RollbackMission();
- stars->SetGameMode(Starshatter::CMPN_MODE);
+ stars->SetGameMode(Game::CMPN_MODE);
}
else {
- stars->SetGameMode(Starshatter::MENU_MODE);
+ stars->SetGameMode(Game::MENU_MODE);
}
}
diff --git a/StarsEx/Sim.cpp b/StarsEx/Sim.cpp
index 36d5356..7249d82 100644
--- a/StarsEx/Sim.cpp
+++ b/StarsEx/Sim.cpp
@@ -1553,7 +1553,7 @@ Sim::ExecFrame(double seconds)
// setup music
if (!MusicDirector::IsNoMusic()) {
Starshatter* stars = Starshatter::GetInstance();
- if (stars && stars->GetGameMode() == Starshatter::PLAY_MODE) {
+ if (stars && stars->GetGameMode() == Game::PLAY_MODE) {
Ship* player_ship = GetPlayerShip();
if (player_ship) {
int phase = player_ship->GetFlightPhase();
@@ -3251,7 +3251,7 @@ SimRegion::DestroyShip(Ship* ship)
if (player_destroyed) {
Starshatter* stars = Starshatter::GetInstance();
if (stars)
- stars->SetGameMode(Starshatter::PLAN_MODE);
+ stars->SetGameMode(Game::PLAN_MODE);
}
}
@@ -3386,7 +3386,7 @@ SimRegion::DockShips()
// close mission, return to menu:
Starshatter* stars = Starshatter::GetInstance();
if (stars)
- stars->SetGameMode(Starshatter::PLAN_MODE);
+ stars->SetGameMode(Game::PLAN_MODE);
}
if (carrier)
diff --git a/StarsEx/StarServer.cpp b/StarsEx/StarServer.cpp
index b065d51..2d24bde 100644
--- a/StarsEx/StarServer.cpp
+++ b/StarsEx/StarServer.cpp
@@ -66,7 +66,7 @@ static bool exit_latch = true;
// +--------------------------------------------------------------------+
StarServer::StarServer()
-: loader(0), time_mark(0), minutes(0), game_mode(MENU_MODE),
+: loader(0), time_mark(0), minutes(0),
admin_server(0), lobby_server(0)
{
if (!instance)
diff --git a/StarsEx/StarServer.h b/StarsEx/StarServer.h
index 9776e07..3e8a722 100644
--- a/StarsEx/StarServer.h
+++ b/StarsEx/StarServer.h
@@ -41,13 +41,7 @@ public:
virtual bool InitGame();
virtual void GameState();
- enum MODE { MENU_MODE, // main menu
- LOAD_MODE, // loading mission into simulator
- PLAY_MODE // active simulation
- };
-
- int GetGameMode() { return game_mode; }
- void SetGameMode(int mode);
+ void SetGameMode(int mode) override;
void SetNextMission(const char* script);
void CreateWorld();
@@ -66,7 +60,6 @@ protected:
NetLobbyServer* lobby_server;
DataLoader* loader;
- int game_mode;
DWORD time_mark;
DWORD minutes;
};
diff --git a/StarsEx/Starshatter.cpp b/StarsEx/Starshatter.cpp
index 3981917..415a04b 100644
--- a/StarsEx/Starshatter.cpp
+++ b/StarsEx/Starshatter.cpp
@@ -150,7 +150,7 @@ input(0), loader(0), cam_dir(0), music_dir(0),
field_of_view(2), time_mark(0), minutes(0),
player_ship(0), net_lobby(0),
spinning(false), tactical(false), mouse_x(0), mouse_y(0),
-game_mode(MENU_MODE), mouse_input(0), head_tracker(0),
+mouse_input(0), head_tracker(0),
terminal(0), verdana(0), limerick18(0), limerick12(0),
HUDfont(0), GUIfont(0), GUI_small_font(0), title_font(0),
ocrb(0), req_change_video(0), video_changed(0),
@@ -1613,7 +1613,7 @@ Starshatter::DoGameKeys()
if (quit)
quit->ShowMenu();
else
- SetGameMode(Starshatter::PLAN_MODE);
+ SetGameMode(PLAN_MODE);
}
}
@@ -2733,7 +2733,7 @@ Starshatter::EndMission()
}
}
- SetGameMode(Starshatter::PLAN_MODE);
+ SetGameMode(PLAN_MODE);
}
Mission*
diff --git a/StarsEx/Starshatter.h b/StarsEx/Starshatter.h
index f18967d..ed800fc 100644
--- a/StarsEx/Starshatter.h
+++ b/StarsEx/Starshatter.h
@@ -54,22 +54,11 @@ public:
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 SetGameMode(int mode) override;
void RequestChangeVideo();
void LoadVideoConfig(const char* filename);
void SaveVideoConfig(const char* filename);
@@ -192,7 +181,6 @@ protected:
int mouse_dx;
int mouse_dy;
- int game_mode;
int test_mode;
int req_change_video;
int video_changed;