mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2025-10-30 08:03:03 +00:00
Remove more redundant mod scanning and fix mods being scanned during gameplay
This commit is contained in:
parent
f9df5c2b7c
commit
df674f2dfc
5 changed files with 14 additions and 12 deletions
|
|
@ -111,7 +111,7 @@ namespace recompui {
|
|||
);
|
||||
void close_prompt();
|
||||
bool is_prompt_open();
|
||||
void update_mod_list();
|
||||
void update_mod_list(bool scan_mods = true);
|
||||
void process_game_started();
|
||||
|
||||
void apply_color_hack();
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ public:
|
|||
}
|
||||
void load_document() override {
|
||||
config_context = recompui::create_context(zelda64::get_asset_path("config_menu.rml"));
|
||||
recompui::update_mod_list();
|
||||
recompui::update_mod_list(false);
|
||||
}
|
||||
void register_events(recompui::UiEventListenerInstancer& listener) override {
|
||||
recompui::register_event(listener, "apply_options",
|
||||
|
|
|
|||
|
|
@ -246,12 +246,14 @@ void ModEntrySpacer::set_target_height(float target_height, bool animate_to_targ
|
|||
|
||||
// ModMenu
|
||||
|
||||
void ModMenu::refresh_mods() {
|
||||
void ModMenu::refresh_mods(bool scan_mods) {
|
||||
for (const std::string &thumbnail : loaded_thumbnails) {
|
||||
recompui::release_image(thumbnail);
|
||||
}
|
||||
|
||||
recomp::mods::scan_mods();
|
||||
if (scan_mods) {
|
||||
recomp::mods::scan_mods();
|
||||
}
|
||||
mod_details = recomp::mods::get_all_mod_details(game_mod_id);
|
||||
create_mod_list();
|
||||
}
|
||||
|
|
@ -606,8 +608,9 @@ void ModMenu::create_mod_list() {
|
|||
void ModMenu::process_event(const Event &e) {
|
||||
if (e.type == EventType::Update) {
|
||||
if (mods_dirty) {
|
||||
refresh_mods();
|
||||
refresh_mods(mod_scan_queued);
|
||||
mods_dirty = false;
|
||||
mod_scan_queued = false;
|
||||
}
|
||||
if (ultramodern::is_game_started()) {
|
||||
install_mods_button->set_enabled(false);
|
||||
|
|
@ -686,7 +689,7 @@ ModMenu::ModMenu(Element *parent) : Element(parent) {
|
|||
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](){ refresh_mods(); });
|
||||
refresh_button->add_pressed_callback([this](){ refresh_mods(true); });
|
||||
refresh_button->set_nav_manual(NavDirection::Up, mod_tab_id);
|
||||
|
||||
mods_folder_button = context.create_element<Button>(footer_container, "Open Mods Folder", recompui::ButtonStyle::Primary);
|
||||
|
|
@ -721,12 +724,12 @@ ModMenu::~ModMenu() {
|
|||
|
||||
recompui::ModMenu* mod_menu;
|
||||
|
||||
void update_mod_list() {
|
||||
void update_mod_list(bool scan_mods) {
|
||||
if (mod_menu) {
|
||||
recompui::ContextId ui_context = recompui::get_config_context_id();
|
||||
bool opened = ui_context.open_if_not_already();
|
||||
|
||||
mod_menu->set_mods_dirty();
|
||||
mod_menu->set_mods_dirty(scan_mods);
|
||||
mod_menu->queue_update();
|
||||
|
||||
if (opened) {
|
||||
|
|
|
|||
|
|
@ -73,11 +73,11 @@ class ModMenu : public Element {
|
|||
public:
|
||||
ModMenu(Element *parent);
|
||||
virtual ~ModMenu();
|
||||
void set_mods_dirty() { mods_dirty = true; }
|
||||
void set_mods_dirty(bool scan_mods) { mods_dirty = true; mod_scan_queued = scan_mods; }
|
||||
protected:
|
||||
std::string_view get_type_name() override { return "ModMenu"; }
|
||||
private:
|
||||
void refresh_mods();
|
||||
void refresh_mods(bool scan_mods);
|
||||
void open_mods_folder();
|
||||
void open_install_dialog();
|
||||
void mod_toggled(bool enabled);
|
||||
|
|
@ -113,6 +113,7 @@ private:
|
|||
std::unordered_set<std::string> loaded_thumbnails;
|
||||
std::string game_mod_id;
|
||||
bool mods_dirty = false;
|
||||
bool mod_scan_queued = false;
|
||||
|
||||
ConfigSubMenu *config_sub_menu;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -957,7 +957,6 @@ 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()) {
|
||||
|
|
@ -990,7 +989,6 @@ void recompui::drop_files(const std::list<std::filesystem::path> &file_list) {
|
|||
std::vector<std::string> error_messages{};
|
||||
recomp::mods::close_mods();
|
||||
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()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue