Skip to content

Commit

Permalink
gui/setting: Check for recent theme updates to avoid unnecessary proc…
Browse files Browse the repository at this point in the history
…essing.
  • Loading branch information
Zangetsu38 committed Oct 25, 2024
1 parent 52b82dd commit 69d0dfb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 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_update_themes = 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_update_themes) && (fs::last_write_time(fw_theme_path) < last_update_themes))
return;
else if (last_update_themes != 0)
LOG_INFO("Found new update of themes, updating themes list...");

// 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

0 comments on commit 69d0dfb

Please sign in to comment.