mirror of
https://github.com/Mr-Wiseguy/Zelda64Recomp.git
synced 2025-02-14 02:39:11 +01:00
Convert to spaces, hook up mod enabled to toggle.
This commit is contained in:
parent
eeb935a5fe
commit
2ab4d7dfac
@ -53,8 +53,8 @@ namespace recompui {
|
|||||||
hover_disabled_style.set_border_color({ 196, 196, 196, border_hover_opacity });
|
hover_disabled_style.set_border_color({ 196, 196, 196, border_hover_opacity });
|
||||||
hover_disabled_style.set_background_color({ 196, 196, 196, background_hover_opacity });
|
hover_disabled_style.set_background_color({ 196, 196, 196, background_hover_opacity });
|
||||||
|
|
||||||
add_style(&hover_style, { hover_state });
|
add_style(&hover_style, hover_state);
|
||||||
add_style(&disabled_style, { disabled_state });
|
add_style(&disabled_style, disabled_state);
|
||||||
add_style(&hover_disabled_style, { hover_state, disabled_state });
|
add_style(&hover_disabled_style, { hover_state, disabled_state });
|
||||||
|
|
||||||
// transition: color 0.05s linear-in-out, background-color 0.05s linear-in-out;
|
// transition: color 0.05s linear-in-out, background-color 0.05s linear-in-out;
|
||||||
|
@ -157,6 +157,10 @@ void Element::clear_children() {
|
|||||||
children.clear();
|
children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Element::add_style(Style *style, const std::string_view style_name) {
|
||||||
|
add_style(style, { style_name });
|
||||||
|
}
|
||||||
|
|
||||||
void Element::add_style(Style *style, const std::initializer_list<std::string_view> &style_names) {
|
void Element::add_style(Style *style, const std::initializer_list<std::string_view> &style_names) {
|
||||||
for (const std::string_view &style_name : style_names) {
|
for (const std::string_view &style_name : style_names) {
|
||||||
style_name_index_map.emplace(style_name, styles.size());
|
style_name_index_map.emplace(style_name, styles.size());
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
Element(Element *parent, uint32_t events_enabled = 0, Rml::String base_class = "div");
|
Element(Element *parent, uint32_t events_enabled = 0, Rml::String base_class = "div");
|
||||||
virtual ~Element();
|
virtual ~Element();
|
||||||
void clear_children();
|
void clear_children();
|
||||||
|
void add_style(Style *style, const std::string_view style_name);
|
||||||
void add_style(Style *style, const std::initializer_list<std::string_view> &style_names);
|
void add_style(Style *style, const std::initializer_list<std::string_view> &style_names);
|
||||||
void set_enabled(bool enabled);
|
void set_enabled(bool enabled);
|
||||||
void set_text(const std::string &text);
|
void set_text(const std::string &text);
|
||||||
|
@ -43,6 +43,7 @@ ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) {
|
|||||||
buttons_container->set_padding_left(16.0f);
|
buttons_container->set_padding_left(16.0f);
|
||||||
{
|
{
|
||||||
enable_toggle = new Toggle(buttons_container);
|
enable_toggle = new Toggle(buttons_container);
|
||||||
|
enable_toggle->add_checked_callback(std::bind(&ModDetailsPanel::enable_toggle_checked, this, std::placeholders::_1));
|
||||||
configure_button = new Button("Configure", recompui::ButtonStyle::Secondary, buttons_container);
|
configure_button = new Button("Configure", recompui::ButtonStyle::Secondary, buttons_container);
|
||||||
erase_button = new Button("Erase", recompui::ButtonStyle::Secondary, buttons_container);
|
erase_button = new Button("Erase", recompui::ButtonStyle::Secondary, buttons_container);
|
||||||
}
|
}
|
||||||
@ -52,7 +53,7 @@ ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) {
|
|||||||
ModDetailsPanel::~ModDetailsPanel() {
|
ModDetailsPanel::~ModDetailsPanel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details) {
|
void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details, bool enabled) {
|
||||||
cur_details = details;
|
cur_details = details;
|
||||||
|
|
||||||
title_label->set_text(cur_details.mod_id);
|
title_label->set_text(cur_details.mod_id);
|
||||||
@ -67,6 +68,17 @@ void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details) {
|
|||||||
|
|
||||||
authors_label->set_text(authors_str);
|
authors_label->set_text(authors_str);
|
||||||
description_label->set_text("Placeholder description. Some long text to make sure that wrapping is working correctly. Yet more text and so on.");
|
description_label->set_text("Placeholder description. Some long text to make sure that wrapping is working correctly. Yet more text and so on.");
|
||||||
|
enable_toggle->set_checked(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModDetailsPanel::set_mod_toggled_callback(std::function<void(bool)> callback) {
|
||||||
|
mod_toggled_callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModDetailsPanel::enable_toggle_checked(bool checked) {
|
||||||
|
if (mod_toggled_callback != nullptr) {
|
||||||
|
mod_toggled_callback(checked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace recompui
|
} // namespace recompui
|
||||||
|
@ -14,7 +14,8 @@ class ModDetailsPanel : public Element {
|
|||||||
public:
|
public:
|
||||||
ModDetailsPanel(Element *parent);
|
ModDetailsPanel(Element *parent);
|
||||||
virtual ~ModDetailsPanel();
|
virtual ~ModDetailsPanel();
|
||||||
void set_mod_details(const recomp::mods::ModDetails& details);
|
void set_mod_details(const recomp::mods::ModDetails& details, bool enabled);
|
||||||
|
void set_mod_toggled_callback(std::function<void(bool)> callback);
|
||||||
private:
|
private:
|
||||||
recomp::mods::ModDetails cur_details;
|
recomp::mods::ModDetails cur_details;
|
||||||
Container *thumbnail_container = nullptr;
|
Container *thumbnail_container = nullptr;
|
||||||
@ -30,6 +31,9 @@ private:
|
|||||||
Toggle *enable_toggle = nullptr;
|
Toggle *enable_toggle = nullptr;
|
||||||
Button *configure_button = nullptr;
|
Button *configure_button = nullptr;
|
||||||
Button *erase_button = nullptr;
|
Button *erase_button = nullptr;
|
||||||
|
std::function<void(bool)> mod_toggled_callback = {};
|
||||||
|
|
||||||
|
void enable_toggle_checked(bool checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace recompui
|
} // namespace recompui
|
||||||
|
@ -69,8 +69,12 @@ void ModEntry::process_event(const Event& e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModMenu::set_active_mod(uint32_t mod_index) {
|
void ModMenu::set_active_mod(int32_t mod_index) {
|
||||||
mod_details_panel->set_mod_details(mod_details[mod_index]);
|
active_mod_index = mod_index;
|
||||||
|
if (active_mod_index >= 0) {
|
||||||
|
bool mod_enabled = recomp::mods::is_mod_enabled(mod_details[mod_index].mod_id);
|
||||||
|
mod_details_panel->set_mod_details(mod_details[mod_index], mod_enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModMenu::refresh_mods() {
|
void ModMenu::refresh_mods() {
|
||||||
@ -79,6 +83,12 @@ void ModMenu::refresh_mods() {
|
|||||||
create_mod_list();
|
create_mod_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModMenu::mod_toggled(bool enabled) {
|
||||||
|
if (active_mod_index >= 0) {
|
||||||
|
recomp::mods::enable_mod(mod_details[active_mod_index].mod_id, enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModMenu::create_mod_list() {
|
void ModMenu::create_mod_list() {
|
||||||
// Clear the contents of the list scroll.
|
// Clear the contents of the list scroll.
|
||||||
list_scroll_container->clear_children();
|
list_scroll_container->clear_children();
|
||||||
@ -121,6 +131,7 @@ ModMenu::ModMenu(Element *parent) : Element(parent) {
|
|||||||
} // list_container
|
} // list_container
|
||||||
|
|
||||||
mod_details_panel = new ModDetailsPanel(body_container);
|
mod_details_panel = new ModDetailsPanel(body_container);
|
||||||
|
mod_details_panel->set_mod_toggled_callback(std::bind(&ModMenu::mod_toggled, this, std::placeholders::_1));
|
||||||
} // body_container
|
} // body_container
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,9 +28,10 @@ class ModMenu : public Element {
|
|||||||
public:
|
public:
|
||||||
ModMenu(Element *parent);
|
ModMenu(Element *parent);
|
||||||
virtual ~ModMenu();
|
virtual ~ModMenu();
|
||||||
void set_active_mod(uint32_t mod_index);
|
void set_active_mod(int32_t mod_index);
|
||||||
private:
|
private:
|
||||||
void refresh_mods();
|
void refresh_mods();
|
||||||
|
void mod_toggled(bool enabled);
|
||||||
void create_mod_list();
|
void create_mod_list();
|
||||||
|
|
||||||
Container *body_container = nullptr;
|
Container *body_container = nullptr;
|
||||||
@ -39,6 +40,7 @@ private:
|
|||||||
ModDetailsPanel *mod_details_panel = nullptr;
|
ModDetailsPanel *mod_details_panel = nullptr;
|
||||||
Container *footer_container = nullptr;
|
Container *footer_container = nullptr;
|
||||||
Button *refresh_button = nullptr;
|
Button *refresh_button = nullptr;
|
||||||
|
int32_t active_mod_index = -1;
|
||||||
std::vector<ModEntry *> mod_entries;
|
std::vector<ModEntry *> mod_entries;
|
||||||
std::vector<recomp::mods::ModDetails> mod_details{};
|
std::vector<recomp::mods::ModDetails> mod_details{};
|
||||||
std::string game_mod_id;
|
std::string game_mod_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user