#include "ui_mod_details_panel.h" #include "librecomp/mods.hpp" namespace recompui { ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) { set_flex(1.0f, 1.0f, 200.0f); set_height(100.0f, Unit::Percent); set_flex_direction(FlexDirection::Column); set_border_bottom_right_radius(16.0f); set_background_color(Color{ 190, 184, 219, 25 }); header_container = new Container(FlexDirection::Row, JustifyContent::FlexStart, this); header_container->set_padding(16.0f); header_container->set_background_color(Color{ 0, 0, 0, 89 }); { thumbnail_container = new Container(FlexDirection::Column, JustifyContent::SpaceEvenly, header_container); { thumbnail_image = new Image(thumbnail_container); thumbnail_image->set_width(100.0f); thumbnail_image->set_height(100.0f); thumbnail_image->set_background_color(Color{ 190, 184, 219, 25 }); } header_details_container = new Container(FlexDirection::Column, JustifyContent::SpaceEvenly, header_container); header_details_container->set_width(100.0f, Unit::Percent); header_details_container->set_margin_left(32.0f); header_details_container->set_overflow(Overflow::Hidden); { title_label = new Label(LabelStyle::Large, header_details_container); version_label = new Label(LabelStyle::Normal, header_details_container); } } body_container = new recompui::Container(FlexDirection::Column, JustifyContent::FlexStart, this); body_container->set_padding_left(16.0f); { description_label = new Label(LabelStyle::Normal, body_container); authors_label = new Label(LabelStyle::Normal, body_container); buttons_container = new Container(FlexDirection::Row, JustifyContent::SpaceAround, body_container); buttons_container->set_padding_left(16.0f); { 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); erase_button = new Button("Erase", recompui::ButtonStyle::Secondary, buttons_container); } } } ModDetailsPanel::~ModDetailsPanel() { } void ModDetailsPanel::set_mod_details(const recomp::mods::ModDetails& details, bool enabled) { cur_details = details; title_label->set_text(cur_details.mod_id); version_label->set_text(cur_details.version.to_string()); std::string authors_str = "Authors:"; bool first = true; for (const std::string& author : details.authors) { authors_str += (first ? " " : ", ") + author; first = false; } 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."); enable_toggle->set_checked(enabled); } void ModDetailsPanel::set_mod_toggled_callback(std::function callback) { mod_toggled_callback = callback; } void ModDetailsPanel::enable_toggle_checked(bool checked) { if (mod_toggled_callback != nullptr) { mod_toggled_callback(checked); } } } // namespace recompui