Skip to content

Commit

Permalink
- route all accesses to gameaction from the backend through the sysCa…
Browse files Browse the repository at this point in the history
…llbacks.

gameactions are frontend specific so this needs to be decoupled.
  • Loading branch information
coelckers committed May 22, 2021
1 parent 50045dd commit b800a2f
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 35 deletions.
5 changes: 2 additions & 3 deletions src/common/console/c_console.cpp
Expand Up @@ -592,8 +592,7 @@ void C_DrawConsole ()

oldbottom = ConBottom;

if (ConsoleState == c_up && gamestate != GS_INTRO && gamestate != GS_INTERMISSION &&
gamestate != GS_FULLCONSOLE && gamestate != GS_MENUSCREEN)
if (ConsoleState == c_up && gamestate == GS_LEVEL)
{
if (NotifyStrings) NotifyStrings->Draw();
return;
Expand Down Expand Up @@ -731,7 +730,7 @@ void C_ToggleConsole ()
}
if (gamestate == GS_MENUSCREEN)
{
gameaction = ga_fullconsole;
if (sysCallbacks.ToggleFullConsole) sysCallbacks.ToggleFullConsole();
togglestate = c_down;
}
else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off)
Expand Down
3 changes: 2 additions & 1 deletion src/common/cutscenes/screenjob.cpp
Expand Up @@ -50,6 +50,7 @@
#include "c_dispatch.h"
#include "s_music.h"
#include "m_argv.h"
#include "i_interface.h"

CVAR(Bool, inter_subtitles, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);

Expand Down Expand Up @@ -316,7 +317,7 @@ bool StartCutscene(CutsceneDef& cs, int flags, const CompletionFunc& completion_
}
if (flags & SJ_DELAY) intermissiondelay = 10; // need to wait a bit at the start to let the timer catch up.
else intermissiondelay = 0;
gameaction = (flags & SJ_BLOCKUI) ? ga_intro : ga_intermission;
if (sysCallbacks.StartCutscene) sysCallbacks.StartCutscene(flags & SJ_BLOCKUI);
}
catch (...)
{
Expand Down
31 changes: 4 additions & 27 deletions src/gamestate.h → src/common/engine/gamestate.h
Expand Up @@ -14,6 +14,8 @@ enum gamestate_t : int
GS_STARTUP, // [RH] Console is fullscreen, and game is just starting
GS_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN
GS_INTRO,
GS_CUTSCENE,

GS_MENUSCREEN = GS_DEMOSCREEN,

GS_FORCEWIPE = -1,
Expand All @@ -22,31 +24,6 @@ enum gamestate_t : int
GS_FORCEWIPEMELT = -4
};

extern gamestate_t gamestate;

enum gameaction_t : int
{
ga_nothing,
ga_loadlevel, // not used.
ga_newgame,
ga_newgame2,
ga_recordgame,
ga_loadgame,
ga_loadgamehidecon,
ga_loadgameplaydemo,
ga_autoloadgame,
ga_savegame,
ga_autosave,
ga_playdemo,
ga_completed,
ga_slideshow,
ga_worlddone,
ga_screenshot,
ga_togglemap,
ga_fullconsole,
ga_resumeconversation,
ga_intro,
ga_intermission,
};

extern gameaction_t gameaction;
extern gamestate_t gamestate;
extern int intermissiondelay;
2 changes: 2 additions & 0 deletions src/common/engine/i_interface.h
Expand Up @@ -32,6 +32,8 @@ struct SystemCallbacks
void (*ConsoleToggled)(int state);
bool (*PreBindTexture)(FRenderState* state, FGameTexture*& tex, EUpscaleFlags& flags, int& scaleflags, int& clampmode, int& translation, int& overrideshader);
void (*FontCharCreated)(FGameTexture* base, FGameTexture* untranslated, FGameTexture* translated);
void (*ToggleFullConsole)();
void (*StartCutscene)(bool blockui);
};

extern SystemCallbacks sysCallbacks;
Expand Down
24 changes: 24 additions & 0 deletions src/d_event.h
Expand Up @@ -75,6 +75,30 @@ typedef enum
// Called by IO functions when input is detected.
void D_Render(std::function<void()> action, bool interpolate);

enum gameaction_t : int
{
ga_nothing,
ga_loadlevel, // not used.
ga_newgame,
ga_newgame2,
ga_recordgame,
ga_loadgame,
ga_loadgamehidecon,
ga_loadgameplaydemo,
ga_autoloadgame,
ga_savegame,
ga_autosave,
ga_playdemo,
ga_completed,
ga_slideshow,
ga_worlddone,
ga_screenshot,
ga_togglemap,
ga_fullconsole,
ga_resumeconversation,
ga_intro,
ga_intermission,
};

extern gameaction_t gameaction;

Expand Down
15 changes: 15 additions & 0 deletions src/d_main.cpp
Expand Up @@ -3042,6 +3042,17 @@ static void GC_MarkGameRoots()
GC::Mark(NextToThink);
}

static void System_ToggleFullConsole()
{
gameaction = ga_fullconsole;
}

static void System_StartCutscene(bool blockui)
{
gameaction = blockui ? ga_intro : ga_intermission;
}


bool CheckSkipGameOptionBlock(const char* str);

//==========================================================================
Expand Down Expand Up @@ -3090,6 +3101,10 @@ static int D_DoomMain_Internal (void)
nullptr,
CheckSkipGameOptionBlock,
System_ConsoleToggled,
nullptr,
nullptr,
System_ToggleFullConsole,
System_StartCutscene,
};


Expand Down
1 change: 1 addition & 0 deletions src/g_game.cpp
Expand Up @@ -77,6 +77,7 @@
#include "v_palette.h"
#include "s_music.h"
#include "p_setup.h"
#include "d_event.h"

#include "v_video.h"
#include "g_hub.h"
Expand Down
11 changes: 7 additions & 4 deletions wadsrc/static/zscript/engine/base.zs
Expand Up @@ -76,11 +76,14 @@ enum EGameState
GS_INTERMISSION,
GS_FINALE,
GS_DEMOSCREEN,
GS_FULLCONSOLE, // [RH] Fullscreen console
GS_HIDECONSOLE, // [RH] The menu just did something that should hide fs console
GS_STARTUP, // [RH] Console is fullscreen, and game is just starting
GS_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN
GS_INTRO,
GS_CUTSCENE,

GS_MENUSCREEN = GS_DEMOSCREEN,
GS_FULLCONSOLE,
GS_HIDECONSOLE,
GS_STARTUP,
GS_TITLELEVEL,
}

const TEXTCOLOR_BRICK = "\034A";
Expand Down

0 comments on commit b800a2f

Please sign in to comment.