Skip to content

Commit

Permalink
gui/settings: Skip theme list refresh if no recent updates detected.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zangetsu38 committed Oct 25, 2024
1 parent 52b82dd commit daf8d8a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions vita3k/gui/src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,27 @@ struct Theme {

static std::map<std::string, Theme> themes_info;
static std::vector<std::pair<std::string, time_t>> themes_list;
static time_t last_updated_themes_list = 0;

static void get_themes_list(GuiState &gui, EmuEnvState &emuenv) {
gui.themes_preview.clear();
themes_info.clear();
themes_list.clear();

const auto theme_path{ emuenv.pref_path / "ux0/theme" };
const auto fw_theme_path{ emuenv.pref_path / "vs0/data/internal/theme" };
if ((!fs::exists(fw_theme_path) || fs::is_empty(fw_theme_path)) && (!fs::exists(theme_path) || fs::is_empty(theme_path))) {
LOG_WARN("Theme path is empty");
return;
}

// Check if the theme has been updated recently to avoid unnecessary updates
if ((fs::last_write_time(theme_path) < last_updated_themes_list) && (fs::last_write_time(fw_theme_path) < last_updated_themes_list))
return;
else if (last_updated_themes_list != 0)
LOG_INFO("Found new update of themes list, updating...");

// Clear all themes list
gui.themes_preview.clear();
themes_info.clear();
themes_list.clear();

std::string user_lang;
const auto sys_lang = static_cast<SceSystemParamLang>(emuenv.cfg.sys_lang);
switch (sys_lang) {
Expand Down Expand Up @@ -180,6 +188,9 @@ static void get_themes_list(GuiState &gui, EmuEnvState &emuenv) {
}
}
}

// Update last updated themes list
last_updated_themes_list = time(0);
}

static std::string popup, menu, sub_menu, selected, title, delete_user_background, delete_theme;
Expand Down

0 comments on commit daf8d8a

Please sign in to comment.