Skip to content

Commit

Permalink
Can now edit and save both custom theme 1 and 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sago007 committed Feb 7, 2024
1 parent de41f45 commit c8e0251
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
21 changes: 17 additions & 4 deletions source/code/menudef_themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ static void themesEditSwitchBoardBackground() {
globalData.theme = themeToEdit;
}

static void themesEditSlot1() {
ThemesMenu tem(globalData.screen, _("Edit custom theme 1"), true);
size_t theme_index = ThemeGetNumber("custom_slot_1");
static void themesEditSlot(int slot) {
ThemesMenu tem(globalData.screen, fmt::format(_("Edit custom theme {}"), slot), true);
size_t theme_index = ThemeGetNumber(fmt::format("custom_slot_{}", slot));
if (theme_index == 0) {
// Theme not found
return;
Expand All @@ -110,6 +110,15 @@ static void themesEditSlot1() {
RunGameState(tem);
ThemesAddOrReplace(themeToEdit);
globalData.theme = themeBackup;
ThemesSaveCustomSlots();
}

static void themesEditSlot1() {
themesEditSlot(1);
}

static void themesEditSlot2() {
themesEditSlot(2);
}


Expand All @@ -120,9 +129,13 @@ void OpenThemesMenu() {
bSwitchTheme.setAction(&switchTheme);
tm.addButton(&bSwitchTheme);
Button bEditTheme1;
bEditTheme1.setLabel(_("Edit custom theme 1"));
bEditTheme1.setLabel(fmt::format(_("Edit custom theme {}"), 1));
bEditTheme1.setAction(&themesEditSlot1);
tm.addButton(&bEditTheme1);
Button bEditTheme2;
bEditTheme2.setLabel(fmt::format(_("Edit custom theme {}"), 2));
bEditTheme2.setAction(&themesEditSlot2);
tm.addButton(&bEditTheme2);
if (!globalData.NoSound) {
Button bTestMusic;
bTestMusic.setLabel(_("Test music"));
Expand Down
1 change: 1 addition & 0 deletions source/code/themes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void ThemesFillMissingFields(Theme& theme);

void ThemesAddOrReplace(const Theme& theme);


/**
* @brief returns a theme from a list
* @return A copy of a theme
Expand Down

0 comments on commit c8e0251

Please sign in to comment.