mGUI: Add status indicators for fast-forward and mute
Vicki Pfau vi@endrift.com
Mon, 17 Aug 2020 20:17:39 -0700
6 files changed,
42 insertions(+),
5 deletions(-)
M
CHANGES
→
CHANGES
@@ -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
M
include/mgba-util/gui/font.h
→
include/mgba-util/gui/font.h
@@ -53,6 +53,8 @@ GUI_ICON_BUTTON_CROSS,
GUI_ICON_BUTTON_TRIANGLE, GUI_ICON_BUTTON_SQUARE, GUI_ICON_BUTTON_HOME, + GUI_ICON_STATUS_FAST_FORWARD, + GUI_ICON_STATUS_MUTE, GUI_ICON_MAX, };
M
src/feature/gui/gui-config.c
→
src/feature/gui/gui-config.c
@@ -62,6 +62,16 @@ },
.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", .submenu = 0,
M
src/feature/gui/gui-runner.c
→
src/feature/gui/gui-runner.c
@@ -202,6 +202,7 @@ mCoreConfigSetDefaultIntValue(&runner->config, "autosave", false);
#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 @@ if (autoload) {
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 @@ }
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 @@ }
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) {
M
src/util/gui/font-metrics.c
→
src/util/gui/font-metrics.c
@@ -152,4 +152,6 @@ [GUI_ICON_BUTTON_CROSS] = { 18, 34, 12, 11 },
[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 }, };