mGUI: Add status indicators for fast-forward and mute

This commit is contained in:
Vicki Pfau 2020-08-17 20:17:39 -07:00
parent a263d4718f
commit 209eed35ed
6 changed files with 42 additions and 5 deletions

View File

@ -3,6 +3,7 @@ Features:
- e-Reader card scanning
- Add WebP and APNG recording
- Add mute option in homebrew ports
- Add status indicators for fast-forward and mute in homebrew ports
- Support for unlicensed Pokemon Jade/Diamond Game Boy mapper
- Support for unlicensed BBD Game Boy mapper
- Support for unlicensed Hitek Game Boy mapper

View File

@ -53,6 +53,8 @@ enum GUIIcon {
GUI_ICON_BUTTON_TRIANGLE,
GUI_ICON_BUTTON_SQUARE,
GUI_ICON_BUTTON_HOME,
GUI_ICON_STATUS_FAST_FORWARD,
GUI_ICON_STATUS_MUTE,
GUI_ICON_MAX,
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -61,6 +61,16 @@ void mGUIShowConfig(struct mGUIRunner* runner, struct GUIMenuItem* extra, size_t
},
.nStates = 2
};
*GUIMenuItemListAppend(&menu.items) = (struct GUIMenuItem) {
.title = "Show status OSD",
.data = "showOSD",
.submenu = 0,
.state = true,
.validStates = (const char*[]) {
"Off", "On"
},
.nStates = 2
};
*GUIMenuItemListAppend(&menu.items) = (struct GUIMenuItem) {
.title = "Autosave state",
.data = "autosave",

View File

@ -202,6 +202,7 @@ void mGUIInit(struct mGUIRunner* runner, const char* port) {
#else
mCoreConfigSetDefaultIntValue(&runner->config, "autosave", true);
#endif
mCoreConfigSetDefaultIntValue(&runner->config, "showOSD", true);
mCoreConfigLoad(&runner->config);
mCoreConfigGetIntValue(&runner->config, "logLevel", &logger.logLevel);
@ -430,6 +431,12 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
mCoreLoadState(runner->core, 0, SAVESTATE_SCREENSHOT | SAVESTATE_RTC);
}
int showOSD = true;
mCoreConfigGetIntValue(&runner->config, "showOSD", &showOSD);
int drawFps = false;
mCoreConfigGetIntValue(&runner->config, "fpsCounter", &drawFps);
bool running = true;
#ifndef DISABLE_THREADING
@ -503,16 +510,29 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
runner->core->setKeys(runner->core, keys);
runner->core->runFrame(runner->core);
if (runner->drawFrame) {
int drawFps = false;
mCoreConfigGetIntValue(&runner->config, "fpsCounter", &drawFps);
runner->params.drawStart();
runner->drawFrame(runner, false);
if (drawFps) {
if (showOSD || drawFps) {
if (runner->params.guiPrepare) {
runner->params.guiPrepare();
}
GUIFontPrintf(runner->params.font, 0, GUIFontHeight(runner->params.font), GUI_ALIGN_LEFT, 0x7FFFFFFF, "%.2f fps", runner->fps);
if (drawFps) {
GUIFontPrintf(runner->params.font, 0, GUIFontHeight(runner->params.font), GUI_ALIGN_LEFT, 0x7FFFFFFF, "%.2f fps", runner->fps);
}
if (showOSD) {
unsigned origin = runner->params.width - GUIFontHeight(runner->params.font) / 2;
unsigned w;
if (fastForward || (heldKeys & (1 << mGUI_INPUT_FAST_FORWARD_HELD))) {
GUIFontDrawIcon(runner->params.font, origin, GUIFontHeight(runner->params.font) / 2, GUI_ALIGN_RIGHT, 0, 0x7FFFFFFF, GUI_ICON_STATUS_FAST_FORWARD);
GUIFontIconMetrics(runner->params.font, GUI_ICON_STATUS_FAST_FORWARD, &w, NULL);
origin -= w + GUIFontHeight(runner->params.font) / 2;
}
if (runner->core->opts.mute) {
GUIFontDrawIcon(runner->params.font, origin, GUIFontHeight(runner->params.font) / 2, GUI_ALIGN_RIGHT, 0, 0x7FFFFFFF, GUI_ICON_STATUS_MUTE);
GUIFontIconMetrics(runner->params.font, GUI_ICON_STATUS_MUTE, &w, NULL);
origin -= w + GUIFontHeight(runner->params.font) / 2;
}
}
if (runner->params.guiFinish) {
runner->params.guiFinish();
}
@ -603,6 +623,8 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
if (runner->unpaused) {
runner->unpaused(runner);
}
mCoreConfigGetIntValue(&runner->config, "fpsCounter", &drawFps);
mCoreConfigGetIntValue(&runner->config, "showOSD", &showOSD);
}
mLOG(GUI_RUNNER, DEBUG, "Shutting down...");
if (runner->gameUnloaded) {

View File

@ -152,4 +152,6 @@ const struct GUIIconMetric defaultIconMetrics[] = {
[GUI_ICON_BUTTON_TRIANGLE] = { 34, 34, 12, 11 },
[GUI_ICON_BUTTON_SQUARE] = { 50, 34, 12, 11 },
[GUI_ICON_BUTTON_HOME] = { 66, 34, 12, 11 },
[GUI_ICON_STATUS_FAST_FORWARD] = { 2, 50, 12, 12 },
[GUI_ICON_STATUS_MUTE] = { 17, 50, 14, 12 },
};