From 6cb37160f9fc3a1c41662e46c5a1c55b2a35afd9 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:08:37 -0400 Subject: [PATCH] Make character preset palettes always come first --- src/game/player_palette.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/game/player_palette.c b/src/game/player_palette.c index 89666c7b8..9e2c9215c 100644 --- a/src/game/player_palette.c +++ b/src/game/player_palette.c @@ -114,6 +114,40 @@ void player_palettes_read(const char* palettesPath, bool appendPalettes) { } os_closedir(d); + + // this should mean we are in the exe path's palette dir + if (appendPalettes) { + struct PresetPalette characterPresetPalettes[MAX_PRESET_PALETTES] = { 0 }; + u8 characterPresetPaletteCount = 0; + + // copy character palettes first + for (int c = 0; c < CT_MAX; c++) { // heh, c++ + for (int i = 0; i < gPresetPaletteCount; i++) { + if (!strcmp(gPresetPalettes[i].name, gCharacters[c].name)) { + characterPresetPalettes[characterPresetPaletteCount++] = gPresetPalettes[i]; + } + } + } + + // copy remaining palettes + for (int i = 0; i < gPresetPaletteCount; i++) { + bool isCharacterPalette = false; + for (int c = 0; c < CT_MAX; c++) { // heh, c++ + if (!strcmp(gPresetPalettes[i].name, gCharacters[c].name)) { + isCharacterPalette = true; + break; + } + } + if (!isCharacterPalette) { + characterPresetPalettes[characterPresetPaletteCount++] = gPresetPalettes[i]; + } + } + + // finally, write to gPresetPalettes + for (int i = 0; i < gPresetPaletteCount; i++) { + gPresetPalettes[i] = characterPresetPalettes[i]; + } + } } void player_palette_export(char* name) {