mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-07-02 18:46:07 -04:00
Update codebase with changes for Zelda 64: Recompiled 1.2
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
|
||||
namespace recompui {
|
||||
|
||||
extern const std::string mod_tab_id;
|
||||
|
||||
ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) {
|
||||
set_flex(1.0f, 1.0f, 200.0f);
|
||||
set_height(100.0f, Unit::Percent);
|
||||
set_display(Display::Flex);
|
||||
set_flex_direction(FlexDirection::Column);
|
||||
set_border_bottom_right_radius(16.0f);
|
||||
set_background_color(Color{ 190, 184, 219, 25 });
|
||||
|
||||
ContextId context = get_current_context();
|
||||
@@ -19,6 +20,8 @@ ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) {
|
||||
header_container->set_padding(16.0f);
|
||||
header_container->set_gap(16.0f);
|
||||
header_container->set_background_color(Color{ 0, 0, 0, 89 });
|
||||
header_container->set_border_bottom_width(1.1f);
|
||||
header_container->set_border_bottom_color(Color{ 255, 255, 255, 25 });
|
||||
{
|
||||
thumbnail_container = context.create_element<Container>(header_container, FlexDirection::Column, JustifyContent::SpaceEvenly);
|
||||
thumbnail_container->set_flex(0.0f, 0.0f);
|
||||
@@ -39,42 +42,48 @@ ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) {
|
||||
}
|
||||
}
|
||||
|
||||
body_container = context.create_element<Container>(this, FlexDirection::Column, JustifyContent::FlexStart);
|
||||
body_container->set_flex(0.0f, 0.0f);
|
||||
body_container = context.create_element<ScrollContainer>(this, ScrollDirection::Vertical);
|
||||
body_container->set_text_align(TextAlign::Left);
|
||||
body_container->set_padding(16.0f);
|
||||
body_container->set_gap(16.0f);
|
||||
{
|
||||
description_label = context.create_element<Label>(body_container, LabelStyle::Normal);
|
||||
authors_label = context.create_element<Label>(body_container, LabelStyle::Normal);
|
||||
authors_label->set_margin_bottom(16.0f);
|
||||
description_label = context.create_element<Label>(body_container, LabelStyle::Normal);
|
||||
}
|
||||
|
||||
spacer_element = context.create_element<Element>(this);
|
||||
spacer_element->set_flex(1.0f, 0.0f);
|
||||
|
||||
buttons_container = context.create_element<Container>(this, FlexDirection::Row, JustifyContent::SpaceAround);
|
||||
buttons_container->set_flex(0.0f, 0.0f);
|
||||
buttons_container->set_padding(16.0f);
|
||||
buttons_container->set_justify_content(JustifyContent::SpaceBetween);
|
||||
buttons_container->set_border_top_width(1.1f);
|
||||
buttons_container->set_border_top_color(Color{ 255, 255, 255, 25 });
|
||||
buttons_container->set_background_color(Color{ 0, 0, 0, 89 });
|
||||
{
|
||||
enable_container = context.create_element<Container>(buttons_container, FlexDirection::Row, JustifyContent::FlexStart);
|
||||
enable_container->set_align_items(AlignItems::Center);
|
||||
enable_container->set_gap(16.0f);
|
||||
{
|
||||
enable_toggle = context.create_element<Toggle>(enable_container);
|
||||
enable_toggle->add_checked_callback(std::bind(&ModDetailsPanel::enable_toggle_checked, this, std::placeholders::_1));
|
||||
enable_toggle->add_checked_callback([this](bool checked){ enable_toggle_checked(checked); });
|
||||
enable_toggle->set_nav_manual(NavDirection::Up, mod_tab_id);
|
||||
|
||||
enable_label = context.create_element<Label>(enable_container, "A currently enabled mod requires this mod", LabelStyle::Annotation);
|
||||
}
|
||||
|
||||
configure_button = context.create_element<Button>(buttons_container, "Configure", recompui::ButtonStyle::Secondary);
|
||||
configure_button->add_pressed_callback(std::bind(&ModDetailsPanel::configure_button_pressed, this));
|
||||
configure_button->add_pressed_callback([this](){ configure_button_pressed(); });
|
||||
configure_button->set_nav_manual(NavDirection::Up, mod_tab_id);
|
||||
}
|
||||
clear_mod_navigation();
|
||||
}
|
||||
|
||||
ModDetailsPanel::~ModDetailsPanel() {
|
||||
}
|
||||
|
||||
void ModDetailsPanel::disable_toggle() {
|
||||
enable_toggle->set_enabled(false);
|
||||
}
|
||||
|
||||
void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details, const std::string &thumbnail, bool toggle_checked, bool toggle_enabled, bool toggle_label_visible, bool configure_enabled) {
|
||||
cur_details = details;
|
||||
|
||||
@@ -83,7 +92,7 @@ void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details, c
|
||||
title_label->set_text(cur_details.display_name);
|
||||
version_label->set_text(cur_details.version.to_string());
|
||||
|
||||
std::string authors_str = "<i>Authors</i>:";
|
||||
std::string authors_str = "Authors:";
|
||||
bool first = true;
|
||||
for (const std::string& author : details.authors) {
|
||||
authors_str += (first ? " " : ", ") + author;
|
||||
@@ -96,6 +105,13 @@ void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details, c
|
||||
enable_toggle->set_enabled(toggle_enabled);
|
||||
configure_button->set_enabled(configure_enabled);
|
||||
enable_label->set_display(toggle_label_visible ? Display::Block : Display::None);
|
||||
|
||||
if (configure_enabled) {
|
||||
enable_toggle->set_nav(NavDirection::Right, configure_button);
|
||||
}
|
||||
else {
|
||||
enable_toggle->set_nav_none(NavDirection::Right);
|
||||
}
|
||||
}
|
||||
|
||||
void ModDetailsPanel::set_mod_toggled_callback(std::function<void(bool)> callback) {
|
||||
@@ -106,6 +122,22 @@ void ModDetailsPanel::set_mod_configure_pressed_callback(std::function<void()> c
|
||||
mod_configure_pressed_callback = callback;
|
||||
}
|
||||
|
||||
void ModDetailsPanel::setup_mod_navigation(Element* nav_target) {
|
||||
enable_toggle->set_nav(NavDirection::Left, nav_target);
|
||||
|
||||
if (enable_toggle->is_enabled()) {
|
||||
configure_button->set_nav(NavDirection::Left, enable_toggle);
|
||||
}
|
||||
else {
|
||||
configure_button->set_nav(NavDirection::Left, nav_target);
|
||||
}
|
||||
}
|
||||
|
||||
void ModDetailsPanel::clear_mod_navigation() {
|
||||
enable_toggle->set_nav_none(NavDirection::Left);
|
||||
configure_button->set_nav_none(NavDirection::Left);
|
||||
}
|
||||
|
||||
void ModDetailsPanel::enable_toggle_checked(bool checked) {
|
||||
if (mod_toggled_callback != nullptr) {
|
||||
mod_toggled_callback(checked);
|
||||
|
||||
Reference in New Issue
Block a user