MCPcopy Create free account
hub / github.com/XorTroll/uLaunch / theme_DefaultKey

Method theme_DefaultKey

projects/uMenu/source/ul/menu/ui/ui_ThemesMenuLayout.cpp:94–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 }
93
94 void ThemesMenuLayout::theme_DefaultKey() {
95 const auto idx = this->themes_menu->GetSelectedIndex();
96 const auto &selected_theme = this->loaded_themes.at(idx);
97 if(selected_theme.IsValid()) {
98 if(selected_theme.IsSame(g_GlobalSettings.active_theme)) {
99 g_MenuApplication->ShowNotification(GetLanguageString("theme_active_this"));
100 }
101 else {
102 std::string theme_conf_msg = selected_theme.manifest.name + "\n";
103 theme_conf_msg += selected_theme.manifest.description + "\n";
104 theme_conf_msg += "(" + selected_theme.manifest.release + ", " + selected_theme.manifest.author + ")\n\n";
105 theme_conf_msg += GetLanguageString("theme_set_conf");
106
107 const auto option = g_MenuApplication->DisplayDialog(selected_theme.manifest.name, theme_conf_msg, { GetLanguageString("yes"), GetLanguageString("cancel") }, true, this->loaded_theme_icons.at(idx));
108 if(option == 0) {
109 if(selected_theme.IsOutdated()) {
110 const auto option_2 = g_MenuApplication->DisplayDialog(selected_theme.manifest.name, GetLanguageString("theme_outdated"), { GetLanguageString("ok"), GetLanguageString("cancel") }, true);
111 if(option_2 != 0) {
112 return;
113 }
114 }
115
116 g_GlobalSettings.SetActiveTheme(selected_theme);
117 g_MenuApplication->ShowNotification(GetLanguageString("theme_cache"));
118
119 pu::audio::PlaySfx(this->theme_change_sfx);
120 g_MenuApplication->ShowNotification(GetLanguageString("theme_changed"));
121
122 g_MenuApplication->FadeOutToNonLibraryApplet();
123 UL_RC_ASSERT(ul::menu::smi::RestartMenu(true));
124 g_MenuApplication->Finalize();
125 }
126 }
127 }
128 else {
129 if(g_GlobalSettings.active_theme.IsValid()) {
130 const auto option = g_MenuApplication->DisplayDialog(GetLanguageString("theme_reset"), GetLanguageString("theme_reset_conf"), { GetLanguageString("yes"), GetLanguageString("cancel") }, true);
131 if(option == 0) {
132 g_GlobalSettings.SetActiveTheme({});
133 g_MenuApplication->ShowNotification(GetLanguageString("theme_cache"));
134
135 pu::audio::PlaySfx(this->theme_change_sfx);
136 g_MenuApplication->ShowNotification(GetLanguageString("theme_changed"));
137
138 g_MenuApplication->FadeOutToNonLibraryApplet();
139 UL_RC_ASSERT(ul::menu::smi::RestartMenu(true));
140 g_MenuApplication->Finalize();
141 }
142 }
143 else {
144 g_MenuApplication->ShowNotification(GetLanguageString("theme_no_active"));
145 }
146 }
147 }
148
149}

Callers

nothing calls this directly

Calls 10

RestartMenuFunction · 0.85
IsSameMethod · 0.80
DisplayDialogMethod · 0.80
IsOutdatedMethod · 0.80
SetActiveThemeMethod · 0.80
FinalizeMethod · 0.80
GetLanguageStringFunction · 0.70
IsValidMethod · 0.45
ShowNotificationMethod · 0.45

Tested by

no test coverage detected