Skip to content

Commit

Permalink
Options in pause menu #284
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Mar 14, 2024
1 parent 672777a commit 8e21906
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 216 deletions.
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(CDOGS_SDL_SOURCES
menu.c
menu_utils.c
namegen.c
options_menu.c
password.c
pause_menu.c
player_select_menus.c
Expand All @@ -57,6 +58,7 @@ set(CDOGS_SDL_HEADERS
menu.h
menu_utils.h
namegen.h
options_menu.h
password.h
pause_menu.h
player_select_menus.h
Expand Down
19 changes: 17 additions & 2 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ static void RunGameReset(RunGameData *rData)
BlitUpdateFromBuf(&gGraphicsDevice, gGraphicsDevice.bkg);
CameraReset(&rData->Camera);
}
static void OnGfxChangeCallback(void *data, const bool resetBg)
{
RunGameData *rData = data;
if (resetBg)
{
RunGameReset(rData);
}
rData->pm.ms.size = svec2i(
rData->pm.ms.graphics->cachedConfig.Res.x,
rData->pm.ms.graphics->cachedConfig.Res.y);
}
static void RunGameTerminate(GameLoopData *data)
{
RunGameData *rData = data->Data;
Expand Down Expand Up @@ -216,7 +227,9 @@ static void RunGameOnEnter(GameLoopData *data)
}
}

PauseMenuInit(&rData->pm, &gEventHandlers, &gGraphicsDevice);
PauseMenuInit(
&rData->pm, &gEventHandlers, &gGraphicsDevice, OnGfxChangeCallback,
rData);

rData->m->state = MISSION_STATE_WAITING;
rData->m->isDone = false;
Expand Down Expand Up @@ -645,7 +658,9 @@ static void RunGameDraw(GameLoopData *data)
// Draw HUD layer
BlitClearBuf(&gGraphicsDevice);
CameraDrawMode(&rData->Camera);
HUDDraw(&rData->Camera.HUD, rData->Camera.NumViews, PauseMenuIsShown(&rData->pm));
HUDDraw(
&rData->Camera.HUD, rData->Camera.NumViews,
PauseMenuIsShown(&rData->pm));
PauseMenuDraw(&rData->pm);
// Draw automap if enabled
if (rData->isMap)
Expand Down
Loading

0 comments on commit 8e21906

Please sign in to comment.