backport widget changes from totalsms

This commit is contained in:
ITotalJustice
2025-07-21 12:40:54 +01:00
parent ecb470b938
commit b6497c03f6
14 changed files with 188 additions and 160 deletions

View File

@@ -302,7 +302,7 @@ 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::OptionLong m_install_prompt{INI_SECTION, "install_prompt", 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};

View File

@@ -6,8 +6,8 @@
namespace sphaira::ui::gfx {
void drawImage(NVGcontext*, float x, float y, float w, float h, int texture, float rounded = 0.F);
void drawImage(NVGcontext*, const Vec4& v, int texture, float rounded = 0.F);
void drawImage(NVGcontext*, float x, float y, float w, float h, int texture, float rounded = 0.F, float alpha = 1.0F);
void drawImage(NVGcontext*, const Vec4& v, int texture, float rounded = 0.F, float alpha = 1.0F);
void dimBackground(NVGcontext*);

View File

@@ -32,9 +32,10 @@ public:
using Options = std::vector<Option>;
public:
OptionBox(const std::string& message, const Option& a, Callback cb = [](auto){}, int image = 0); // confirm
OptionBox(const std::string& message, const Option& a, const Option& b, Callback cb, int image = 0); // yesno
OptionBox(const std::string& message, const Option& a, const Option& b, s64 index, Callback cb, int image = 0); // yesno
OptionBox(const std::string& message, const Option& a, const Callback& cb = [](auto){}, int image = 0, bool own_image = false); // confirm
OptionBox(const std::string& message, const Option& a, const Option& b, const Callback& cb, int image = 0, bool own_image = false); // yesno
OptionBox(const std::string& message, const Option& a, const Option& b, s64 index, const Callback& cb, int image = 0, bool own_image = false); // yesno
~OptionBox();
auto Update(Controller* controller, TouchInfo* touch) -> void override;
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
@@ -46,9 +47,10 @@ private:
void SetIndex(s64 index);
private:
std::string m_message{};
Callback m_callback{};
int m_image{};
const std::string m_message;
const Callback m_callback;
const int m_image;
const bool m_own_image;
Vec4 m_spacer_line{};

View File

@@ -29,7 +29,7 @@ private:
private:
static constexpr Vec2 m_title_pos{70.f, 28.f};
static constexpr Vec4 m_block{280.f, 110.f, 720.f, 60.f};
static constexpr Vec4 m_block{280.f, 110.f, SCREEN_HEIGHT, 60.f};
static constexpr float m_text_xoffset{15.f};
static constexpr float m_line_width{1220.f};

View File

@@ -3,6 +3,7 @@
#include "ui/widget.hpp"
#include "ui/list.hpp"
#include "ui/scrolling_text.hpp"
#include "option.hpp"
#include <memory>
#include <concepts>
#include <utility>
@@ -34,6 +35,8 @@ public:
public:
explicit SidebarEntryBool(const std::string& title, bool option, Callback cb, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, bool& option, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, option::OptionBool& option, const Callback& cb, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, option::OptionBool& option, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
private:
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;

View File

@@ -274,6 +274,13 @@ enum class Button : u64 {
START = static_cast<u64>(HidNpadButton_Plus),
SELECT = static_cast<u64>(HidNpadButton_Minus),
SL_LEFT = static_cast<u64>(HidNpadButton_LeftSL),
SR_LEFT = static_cast<u64>(HidNpadButton_LeftSR),
SL_RIGHT = static_cast<u64>(HidNpadButton_RightSL),
SR_RIGHT = static_cast<u64>(HidNpadButton_RightSR),
SL_ANY = SL_LEFT | SL_RIGHT,
SR_ANY = SR_LEFT | SR_RIGHT,
// todo:
DPAD_LEFT = static_cast<u64>(HidNpadButton_Left),
DPAD_RIGHT = static_cast<u64>(HidNpadButton_Right),

View File

@@ -10,11 +10,14 @@
namespace sphaira::ui {
struct uiButton final : Object {
uiButton(Button button, Action action) : m_button{button}, m_action{action} {}
uiButton(Button button, const std::string& button_str, const std::string& action_str);
uiButton(Button button, const std::string& action_str);
auto Draw(NVGcontext* vg, Theme* theme) -> void override;
Button m_button;
Action m_action;
std::string m_button_str;
std::string m_action_str;
Vec4 m_button_pos{};
Vec4 m_hint_pos{};
};
@@ -84,6 +87,8 @@ struct Widget : public Object {
}
auto GetUiButtons() const -> uiButtons;
static void SetupUiButtons(uiButtons& buttons, const Vec2& button_pos = {1220, 675});
static auto GetUiButtons(const Actions& actions, const Vec2& button_pos = {1220, 675}) -> uiButtons;
Actions m_actions{};
Vec2 m_button_pos{1220, 675};