Skip to content

Commit

Permalink
implement video::showMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Aug 25, 2024
1 parent 7789b99 commit 14ddc0f
Show file tree
Hide file tree
Showing 9 changed files with 2,023 additions and 12 deletions.
21 changes: 21 additions & 0 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ void Application::resetGame()

_core.resetGame();
_video.clear();
_video.showMessage("Reset", 60);
refreshMemoryMap();
RA_OnReset();
}
Expand Down Expand Up @@ -1781,6 +1782,10 @@ void Application::saveState(unsigned ndx)
return;
}

char message[128];
snprintf(message, sizeof(message), "Saved state %u", ndx);
_video.showMessage(message, 60);

_validSlots |= 1 << ndx;
enableSlots();
}
Expand Down Expand Up @@ -1816,6 +1821,10 @@ void Application::loadState(unsigned ndx)

if (_states.loadState(ndx))
{
char message[128];
snprintf(message, sizeof(message), "Loaded state %u", ndx);
_video.showMessage(message, 60);

updateDiscMenu(false);
}
}
Expand All @@ -1838,6 +1847,13 @@ void Application::loadState()
}
}

void Application::changeCurrentState(unsigned ndx)
{
char message[128];
snprintf(message, sizeof(message), "Current state set to %u", ndx);
_video.showMessage(message, 60);
}

void Application::screenshot()
{
if (!isGameActive())
Expand All @@ -1859,6 +1875,8 @@ void Application::screenshot()
std::string path = getScreenshotPath();
util::saveImage(&_logger, path, data, width, height, pitch, format);
free((void*)data);

_video.showMessage("Screenshot captured", 60);
}

void Application::aboutDialog()
Expand Down Expand Up @@ -2517,6 +2535,7 @@ void Application::handle(const KeyBinds::Action action, unsigned extra)
// State management
case KeyBinds::Action::kSaveState: saveState(extra); break;
case KeyBinds::Action::kLoadState: loadState(extra); break;
case KeyBinds::Action::kChangeCurrentState: changeCurrentState(extra); break;

// Window size
case KeyBinds::Action::kSetWindowSize1: resizeWindow(1); break;
Expand Down Expand Up @@ -2585,6 +2604,8 @@ void Application::handle(const KeyBinds::Action action, unsigned extra)

case KeyBinds::Action::kGameFocusToggle:
updateMenu();

_video.showMessage(_keybinds.hasGameFocus() ? "Game focus enabled" : "Game focus disabled", 60);
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Application
void loadState(const std::string& path);
void loadState(unsigned ndx);
void loadState();
void changeCurrentState(unsigned ndx);
void screenshot();
void aboutDialog();
void resizeWindow(unsigned multiplier);
Expand Down
24 changes: 12 additions & 12 deletions src/KeyBinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,18 @@ KeyBinds::Action KeyBinds::translateButtonPress(int button, unsigned* extra)
case kLoadState8: *extra = 8; return Action::kLoadState;
case kLoadState9: *extra = 9; return Action::kLoadState;
case kLoadState10: *extra = 10; return Action::kLoadState;
case kPreviousSlot: _slot = (_slot == 1) ? 10 : _slot - 1; return Action::kNothing;
case kNextSlot: _slot = (_slot == 10) ? 1 : _slot + 1; return Action::kNothing;
case kSetSlot1: _slot = 1; return Action::kNothing;
case kSetSlot2: _slot = 2; return Action::kNothing;
case kSetSlot3: _slot = 3; return Action::kNothing;
case kSetSlot4: _slot = 4; return Action::kNothing;
case kSetSlot5: _slot = 5; return Action::kNothing;
case kSetSlot6: _slot = 6; return Action::kNothing;
case kSetSlot7: _slot = 7; return Action::kNothing;
case kSetSlot8: _slot = 8; return Action::kNothing;
case kSetSlot9: _slot = 9; return Action::kNothing;
case kSetSlot10: _slot = 10; return Action::kNothing;
case kPreviousSlot: *extra = _slot = (_slot == 1) ? 10 : _slot - 1; return Action::kChangeCurrentState;
case kNextSlot: *extra = _slot = (_slot == 10) ? 1 : _slot + 1; return Action::kChangeCurrentState;
case kSetSlot1: *extra = _slot = 1; return Action::kChangeCurrentState;
case kSetSlot2: *extra = _slot = 2; return Action::kChangeCurrentState;
case kSetSlot3: *extra = _slot = 3; return Action::kChangeCurrentState;
case kSetSlot4: *extra = _slot = 4; return Action::kChangeCurrentState;
case kSetSlot5: *extra = _slot = 5; return Action::kChangeCurrentState;
case kSetSlot6: *extra = _slot = 6; return Action::kChangeCurrentState;
case kSetSlot7: *extra = _slot = 7; return Action::kChangeCurrentState;
case kSetSlot8: *extra = _slot = 8; return Action::kChangeCurrentState;
case kSetSlot9: *extra = _slot = 9; return Action::kChangeCurrentState;
case kSetSlot10: *extra = _slot = 10; return Action::kChangeCurrentState;
case kLoadCurrent: *extra = _slot; return Action::kLoadState;
case kSaveCurrent: *extra = _slot; return Action::kSaveState;

Expand Down
1 change: 1 addition & 0 deletions src/KeyBinds.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class KeyBinds
// State state management (extra = slot)
kSaveState,
kLoadState,
kChangeCurrentState,

// Window size
kSetWindowSize1,
Expand Down
Loading

0 comments on commit 14ddc0f

Please sign in to comment.