sidebar: add callback when a disabled option is clicked. install: option to enable when a disabled option is clicked.
This commit is contained in:
@@ -103,7 +103,6 @@ public:
|
||||
static auto GetInstallSysmmcEnable() -> bool;
|
||||
static auto GetInstallEmummcEnable() -> bool;
|
||||
static auto GetInstallSdEnable() -> bool;
|
||||
static auto GetInstallPrompt() -> bool;
|
||||
static auto GetThemeMusicEnable() -> bool;
|
||||
static auto Get12HourTimeEnable() -> bool;
|
||||
static auto GetLanguage() -> long;
|
||||
@@ -138,6 +137,11 @@ public:
|
||||
static void DisplayInstallOptions(bool left_side = true);
|
||||
static void DisplayDumpOptions(bool left_side = true);
|
||||
|
||||
// helper for sidebar options to toggle install on/off
|
||||
static void ShowEnableInstallPromptOption(option::OptionBool& option, bool& enable);
|
||||
// displays an option box to enable installing, shows warning.
|
||||
static void ShowEnableInstallPrompt();
|
||||
|
||||
void Draw();
|
||||
void Update();
|
||||
void Poll();
|
||||
@@ -302,7 +306,6 @@ public:
|
||||
option::OptionBool m_install_sysmmc{INI_SECTION, "install_sysmmc", false};
|
||||
option::OptionBool m_install_emummc{INI_SECTION, "install_emummc", false};
|
||||
option::OptionBool m_install_sd{INI_SECTION, "install_sd", true};
|
||||
option::OptionBool m_install_prompt{INI_SECTION, "install_prompt", true};
|
||||
option::OptionBool m_allow_downgrade{INI_SECTION, "allow_downgrade", false};
|
||||
option::OptionBool m_skip_if_already_installed{INI_SECTION, "skip_if_already_installed", true};
|
||||
option::OptionBool m_ticket_only{INI_SECTION, "ticket_only", false};
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace sphaira::ui {
|
||||
class SidebarEntryBase : public Widget {
|
||||
public:
|
||||
using DependsCallback = std::function<bool(void)>;
|
||||
using DependsClickCallback = std::function<void(void)>;
|
||||
|
||||
public:
|
||||
explicit SidebarEntryBase(const std::string& title, const std::string& info);
|
||||
@@ -20,23 +21,26 @@ public:
|
||||
using Widget::Draw;
|
||||
virtual void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left);
|
||||
|
||||
void Depends(const DependsCallback& callback, const std::string& depends_info) {
|
||||
void Depends(const DependsCallback& callback, const std::string& depends_info, const DependsClickCallback& depends_click = {}) {
|
||||
m_depends_callback = callback;
|
||||
m_depends_info = depends_info;
|
||||
m_depends_click = depends_click;
|
||||
}
|
||||
|
||||
void Depends(bool& value, const std::string& depends_info) {
|
||||
void Depends(bool& value, const std::string& depends_info, const DependsClickCallback& depends_click = {}) {
|
||||
m_depends_callback = [&value](){ return value; };
|
||||
m_depends_info = depends_info;
|
||||
m_depends_click = depends_click;
|
||||
}
|
||||
|
||||
void Depends(option::OptionBool& value, const std::string& depends_info) {
|
||||
void Depends(option::OptionBool& value, const std::string& depends_info, const DependsClickCallback& depends_click = {}) {
|
||||
m_depends_callback = [&value](){ return value.Get(); };
|
||||
m_depends_info = depends_info;
|
||||
m_depends_click = depends_click;
|
||||
}
|
||||
|
||||
protected:
|
||||
auto IsEnabled() -> bool {
|
||||
auto IsEnabled() const -> bool {
|
||||
if (m_depends_callback) {
|
||||
return m_depends_callback();
|
||||
}
|
||||
@@ -44,6 +48,12 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
void DependsClick() const {
|
||||
if (m_depends_click) {
|
||||
m_depends_click();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string m_title;
|
||||
|
||||
@@ -51,6 +61,7 @@ private:
|
||||
std::string m_info{};
|
||||
std::string m_depends_info{};
|
||||
DependsCallback m_depends_callback{};
|
||||
DependsClickCallback m_depends_click{};
|
||||
ScrollingText m_scolling_title{};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user