From e866e6321cb81491b0dbbb7130b0c13d1b262958 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 14 Sep 2018 20:26:16 +0200 Subject: [PATCH] Add the option for a config item to check on which screen it can draw via the Overlay API safely. --- loader/src/myutils/ConfigUtils.cpp | 1 + wups_include/wups/config/WUPSConfigItem.h | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/loader/src/myutils/ConfigUtils.cpp b/loader/src/myutils/ConfigUtils.cpp index 0775605..39675be 100644 --- a/loader/src/myutils/ConfigUtils.cpp +++ b/loader/src/myutils/ConfigUtils.cpp @@ -263,6 +263,7 @@ void ConfigUtils::configMenuOpenedCallback(wups_overlay_options_type_t screen, v if(screen_y_pos >= visible_rows_end) { break; } + curItem->visibleOnScreen(screen); if(curSelect == inSelect) { if(pressedButtons != WUPS_CONFIG_BUTTON_NONE) { curItem->onButtonPressed(pressedButtons); diff --git a/wups_include/wups/config/WUPSConfigItem.h b/wups_include/wups/config/WUPSConfigItem.h index 08ed4b9..aad945e 100644 --- a/wups_include/wups/config/WUPSConfigItem.h +++ b/wups_include/wups/config/WUPSConfigItem.h @@ -20,6 +20,7 @@ #include #include +#include "../utils.h" #define WUPS_CONFIG_BUTTON_NONE 0 #define WUPS_CONFIG_BUTTON_LEFT (1<<0) @@ -115,7 +116,6 @@ public: **/ virtual void restoreDefault() = 0; - /** Call callback with with current value. This function will be called whenever this item should call it's (optional) given @@ -125,6 +125,16 @@ public: **/ virtual bool callCallback() = 0; + /** + Will be called by the "config menu manager" if this configitem is currently displayed on the screen. + If this config item decides to draw onto the screen, it can use "lastVisibleOnScreen()" function to + get information about which screen(s) are available. + Check the Overlay API for more information on drawing on the screen. + **/ + virtual void visibleOnScreen(wups_overlay_options_type_t screen){ + this->displayScreen = screen; + } + WUPSConfigItem(std::string configID, std::string displayName){ this->configID = configID; this->displayName = displayName; @@ -133,10 +143,21 @@ public: virtual ~WUPSConfigItem(){ } +protected: + /** + If this config item decides to draw onto the screen, this function can be used + get information about which screen(s) are available for OS drawing. + Check the Overlay API for more information on drawing on the screen. + **/ + wups_overlay_options_type_t lastVisibleOnScreen(){ + return displayScreen; + } private: std::string displayName; std::string configID; + + wups_overlay_options_type_t displayScreen = WUPS_OVERLAY_NONE; }; #endif