mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2025-10-30 08:03:03 +00:00
Add mod install button, put mod description in scroll container, minor mod menu tweaks
This commit is contained in:
parent
f1a7a1674b
commit
d646d781ef
5 changed files with 45 additions and 14 deletions
|
|
@ -9,7 +9,6 @@ ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) {
|
|||
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 +18,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,23 +40,22 @@ 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);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "elements/ui_image.h"
|
||||
#include "elements/ui_label.h"
|
||||
#include "elements/ui_toggle.h"
|
||||
#include "elements/ui_scroll_container.h"
|
||||
|
||||
namespace recompui {
|
||||
|
||||
|
|
@ -26,10 +27,9 @@ private:
|
|||
Container *header_details_container = nullptr;
|
||||
Label *title_label = nullptr;
|
||||
Label *version_label = nullptr;
|
||||
Container *body_container = nullptr;
|
||||
ScrollContainer *body_container = nullptr;
|
||||
Label *description_label = nullptr;
|
||||
Label *authors_label = nullptr;
|
||||
Element *spacer_element = nullptr;
|
||||
Container *buttons_container = nullptr;
|
||||
Container *enable_container = nullptr;
|
||||
Toggle *enable_toggle = nullptr;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "ui_mod_menu.h"
|
||||
#include "ui_mod_menu.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "zelda_support.h"
|
||||
|
||||
|
|
@ -232,6 +232,20 @@ void ModMenu::open_mods_folder() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void ModMenu::open_install_dialog() {
|
||||
zelda64::open_file_dialog([](bool success, const std::filesystem::path& path) {
|
||||
if (success) {
|
||||
ContextId old_context = recompui::try_close_current_context();
|
||||
|
||||
recompui::drop_files({ path });
|
||||
|
||||
if (old_context != ContextId::null()) {
|
||||
old_context.open();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ModMenu::mod_toggled(bool enabled) {
|
||||
if (active_mod_index >= 0) {
|
||||
recomp::mods::enable_mod(mod_details[active_mod_index].mod_id, enabled);
|
||||
|
|
@ -481,6 +495,7 @@ void ModMenu::process_event(const Event &e) {
|
|||
mods_dirty = false;
|
||||
}
|
||||
if (ultramodern::is_game_started()) {
|
||||
install_mods_button->set_enabled(false);
|
||||
refresh_button->set_enabled(false);
|
||||
}
|
||||
if (active_mod_index != -1) {
|
||||
|
|
@ -544,9 +559,16 @@ ModMenu::ModMenu(Element *parent) : Element(parent) {
|
|||
footer_container->set_border_top_width(1.1f);
|
||||
footer_container->set_border_top_color(Color{ 255, 255, 255, 25 });
|
||||
footer_container->set_padding(20.0f);
|
||||
footer_container->set_gap(20.0f);
|
||||
footer_container->set_border_bottom_left_radius(16.0f);
|
||||
footer_container->set_border_bottom_right_radius(16.0f);
|
||||
{
|
||||
install_mods_button = context.create_element<Button>(footer_container, "Install Mods", recompui::ButtonStyle::Primary);
|
||||
install_mods_button->add_pressed_callback([this](){ open_install_dialog(); });
|
||||
|
||||
Element* footer_spacer = context.create_element<Element>(footer_container);
|
||||
footer_spacer->set_flex(1.0f, 0.0f);
|
||||
|
||||
refresh_button = context.create_element<Button>(footer_container, "Refresh", recompui::ButtonStyle::Primary);
|
||||
refresh_button->add_pressed_callback([this](){ recomp::mods::scan_mods(); refresh_mods(); });
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ public:
|
|||
private:
|
||||
void refresh_mods();
|
||||
void open_mods_folder();
|
||||
void open_install_dialog();
|
||||
void mod_toggled(bool enabled);
|
||||
void mod_selected(uint32_t mod_index);
|
||||
void mod_dragged(uint32_t mod_index, EventDrag drag);
|
||||
|
|
@ -85,6 +86,7 @@ private:
|
|||
ModDetailsPanel *mod_details_panel = nullptr;
|
||||
Container *body_empty_container = nullptr;
|
||||
Container *footer_container = nullptr;
|
||||
Button *install_mods_button = nullptr;
|
||||
Button *refresh_button = nullptr;
|
||||
Button *mods_folder_button = nullptr;
|
||||
int32_t active_mod_index = -1;
|
||||
|
|
|
|||
|
|
@ -901,6 +901,12 @@ void recompui::drop_files(const std::list<std::filesystem::path> &file_list) {
|
|||
if (confirmations.empty()) {
|
||||
std::vector<std::string> error_messages{};
|
||||
ModInstaller::finish_mod_installation(result, error_messages);
|
||||
recomp::mods::scan_mods();
|
||||
ContextId old_context = recompui::try_close_current_context();
|
||||
recompui::update_mod_list();
|
||||
if (old_context != ContextId::null()) {
|
||||
old_context.open();
|
||||
}
|
||||
// TODO show errors
|
||||
}
|
||||
else {
|
||||
|
|
@ -929,10 +935,11 @@ void recompui::drop_files(const std::list<std::filesystem::path> &file_list) {
|
|||
recomp::mods::close_mods();
|
||||
ModInstaller::finish_mod_installation(result, error_messages);
|
||||
recomp::mods::scan_mods();
|
||||
ContextId old_context = recompui::get_current_context();
|
||||
old_context.close();
|
||||
ContextId old_context = recompui::try_close_current_context();
|
||||
recompui::update_mod_list();
|
||||
old_context.open();
|
||||
if (old_context != ContextId::null()) {
|
||||
old_context.open();
|
||||
}
|
||||
// TODO show errors
|
||||
},
|
||||
[result]() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue