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 - e-Reader card scanning
- Add WebP and APNG recording - Add WebP and APNG recording
- Add mute option in homebrew ports - 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 Pokemon Jade/Diamond Game Boy mapper
- Support for unlicensed BBD Game Boy mapper - Support for unlicensed BBD Game Boy mapper
- Support for unlicensed Hitek 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_TRIANGLE,
GUI_ICON_BUTTON_SQUARE, GUI_ICON_BUTTON_SQUARE,
GUI_ICON_BUTTON_HOME, GUI_ICON_BUTTON_HOME,
GUI_ICON_STATUS_FAST_FORWARD,
GUI_ICON_STATUS_MUTE,
GUI_ICON_MAX, 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 .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) { *GUIMenuItemListAppend(&menu.items) = (struct GUIMenuItem) {
.title = "Autosave state", .title = "Autosave state",
.data = "autosave", .data = "autosave",

View File

@ -202,6 +202,7 @@ void mGUIInit(struct mGUIRunner* runner, const char* port) {
#else #else
mCoreConfigSetDefaultIntValue(&runner->config, "autosave", true); mCoreConfigSetDefaultIntValue(&runner->config, "autosave", true);
#endif #endif
mCoreConfigSetDefaultIntValue(&runner->config, "showOSD", true);
mCoreConfigLoad(&runner->config); mCoreConfigLoad(&runner->config);
mCoreConfigGetIntValue(&runner->config, "logLevel", &logger.logLevel); 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); 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; bool running = true;
#ifndef DISABLE_THREADING #ifndef DISABLE_THREADING
@ -503,16 +510,29 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
runner->core->setKeys(runner->core, keys); runner->core->setKeys(runner->core, keys);
runner->core->runFrame(runner->core); runner->core->runFrame(runner->core);
if (runner->drawFrame) { if (runner->drawFrame) {
int drawFps = false;
mCoreConfigGetIntValue(&runner->config, "fpsCounter", &drawFps);
runner->params.drawStart(); runner->params.drawStart();
runner->drawFrame(runner, false); runner->drawFrame(runner, false);
if (drawFps) { if (showOSD || drawFps) {
if (runner->params.guiPrepare) { if (runner->params.guiPrepare) {
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) { if (runner->params.guiFinish) {
runner->params.guiFinish(); runner->params.guiFinish();
} }
@ -603,6 +623,8 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
if (runner->unpaused) { if (runner->unpaused) {
runner->unpaused(runner); runner->unpaused(runner);
} }
mCoreConfigGetIntValue(&runner->config, "fpsCounter", &drawFps);
mCoreConfigGetIntValue(&runner->config, "showOSD", &showOSD);
} }
mLOG(GUI_RUNNER, DEBUG, "Shutting down..."); mLOG(GUI_RUNNER, DEBUG, "Shutting down...");
if (runner->gameUnloaded) { if (runner->gameUnloaded) {

View File

@ -152,4 +152,6 @@ const struct GUIIconMetric defaultIconMetrics[] = {
[GUI_ICON_BUTTON_TRIANGLE] = { 34, 34, 12, 11 }, [GUI_ICON_BUTTON_TRIANGLE] = { 34, 34, 12, 11 },
[GUI_ICON_BUTTON_SQUARE] = { 50, 34, 12, 11 }, [GUI_ICON_BUTTON_SQUARE] = { 50, 34, 12, 11 },
[GUI_ICON_BUTTON_HOME] = { 66, 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 },
}; };