From 4553da720c90a399d43a4a003ac9250ec4eded23 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 12 Jun 2019 03:32:25 +0200 Subject: [PATCH] add setting for showing/hiding OSD --- src/libui_sdl/OSD.cpp | 12 ++++++++++++ src/libui_sdl/PlatformConfig.cpp | 2 ++ src/libui_sdl/PlatformConfig.h | 1 + src/libui_sdl/main.cpp | 12 ++++++++++++ 4 files changed, 27 insertions(+) diff --git a/src/libui_sdl/OSD.cpp b/src/libui_sdl/OSD.cpp index 8b87e9d3..bd44e99f 100644 --- a/src/libui_sdl/OSD.cpp +++ b/src/libui_sdl/OSD.cpp @@ -28,6 +28,8 @@ #include "OSD.h" #include "font.h" +#include "PlatformConfig.h" + extern int WindowWidth, WindowHeight; namespace OSD @@ -306,6 +308,8 @@ void RenderText(u32 color, const char* text, Item* item) void AddMessage(u32 color, const char* text) { + if (!Config::ShowOSD) return; + while (Rendering); Item item; @@ -341,6 +345,14 @@ void WindowResized(bool opengl) void Update(bool opengl, uiAreaDrawParams* params) { + if (!Config::ShowOSD) + { + Rendering = true; + if (ItemQueue.size() > 0) DeInit(opengl); + Rendering = false; + return; + } + Rendering = true; Uint32 tick_now = SDL_GetTicks(); diff --git a/src/libui_sdl/PlatformConfig.cpp b/src/libui_sdl/PlatformConfig.cpp index 6a9d4b2f..7f45b591 100644 --- a/src/libui_sdl/PlatformConfig.cpp +++ b/src/libui_sdl/PlatformConfig.cpp @@ -46,6 +46,7 @@ int ScreenUseGL; int ScreenRatio; int LimitFPS; +int ShowOSD; int DirectBoot; @@ -120,6 +121,7 @@ ConfigEntry PlatformConfigFile[] = {"ScreenRatio", 0, &ScreenRatio, 0, NULL, 0}, {"LimitFPS", 0, &LimitFPS, 1, NULL, 0}, + {"ShowOSD", 0, &ShowOSD, 1, NULL, 0}, {"DirectBoot", 0, &DirectBoot, 1, NULL, 0}, diff --git a/src/libui_sdl/PlatformConfig.h b/src/libui_sdl/PlatformConfig.h index d6eb1514..2c59e5d9 100644 --- a/src/libui_sdl/PlatformConfig.h +++ b/src/libui_sdl/PlatformConfig.h @@ -57,6 +57,7 @@ extern int ScreenUseGL; extern int ScreenRatio; extern int LimitFPS; +extern int ShowOSD; extern int DirectBoot; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 9d145176..86949eb3 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -93,6 +93,7 @@ uiMenuItem* MenuItem_ScreenSizing[4]; uiMenuItem* MenuItem_ScreenFilter; uiMenuItem* MenuItem_LimitFPS; +uiMenuItem* MenuItem_ShowOSD; SDL_Thread* EmuThread; int EmuRunning; @@ -2144,6 +2145,13 @@ void OnSetLimitFPS(uiMenuItem* item, uiWindow* window, void* blarg) else Config::LimitFPS = false; } +void OnSetShowOSD(uiMenuItem* item, uiWindow* window, void* blarg) +{ + int chk = uiMenuItemChecked(item); + if (chk != 0) Config::ShowOSD = true; + else Config::ShowOSD = false; +} + void ApplyNewSettings(int type) { if (!RunningSomething) @@ -2370,6 +2378,9 @@ void CreateMainWindowMenu() MenuItem_LimitFPS = uiMenuAppendCheckItem(menu, "Limit framerate"); uiMenuItemOnClicked(MenuItem_LimitFPS, OnSetLimitFPS, NULL); + + MenuItem_ShowOSD = uiMenuAppendCheckItem(menu, "Show OSD"); + uiMenuItemOnClicked(MenuItem_ShowOSD, OnSetShowOSD, NULL); } void CreateMainWindow(bool opengl) @@ -2604,6 +2615,7 @@ int main(int argc, char** argv) uiMenuItemSetChecked(MenuItem_ScreenFilter, Config::ScreenFilter==1); uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1); + uiMenuItemSetChecked(MenuItem_ShowOSD, Config::ShowOSD==1); SDL_AudioSpec whatIwant, whatIget; memset(&whatIwant, 0, sizeof(SDL_AudioSpec));