From d38da165755e6f8096c5bf40a56b8c51aafe33fd Mon Sep 17 00:00:00 2001 From: R Ferreira Date: Mon, 12 Jan 2026 15:02:54 +0000 Subject: [PATCH] add new theme colours w. back compat and adjust parsing code slightly --- arm9/source/tobkit/normalizebox.cpp | 4 +- arm9/source/tobkit/sampledisplay.cpp | 24 ++-- themes/Default.nttheme | 201 ++++++++++++++------------- themes/Sky.nttheme | 10 +- tobkit/include/tobkit/theme.h | 6 +- tobkit/source/messagebox.cpp | 4 +- tobkit/source/theme.cpp | 29 ++-- tobkit/source/themeselectorbox.cpp | 4 +- 8 files changed, 152 insertions(+), 130 deletions(-) diff --git a/arm9/source/tobkit/normalizebox.cpp b/arm9/source/tobkit/normalizebox.cpp index be0cc3a..8baf5e3 100644 --- a/arm9/source/tobkit/normalizebox.cpp +++ b/arm9/source/tobkit/normalizebox.cpp @@ -124,13 +124,13 @@ void NormalizeBox::setTheme(Theme *theme_, u16 bgcolor_) void NormalizeBox::draw(void) { - drawGradient(theme->col_list_highlight1, theme->col_list_highlight2, 1, 1, width - 2, 15); + drawGradient(theme->col_messagebox_title_col1, theme->col_messagebox_title_col2, 1, 1, width - 2, 15); drawHLine(1, 16, width - 2, theme->col_outline); drawFullBox(1, 17, width - 2, NORMALIZEBOX_HEIGHT-17, theme->col_light_bg); drawBorder(theme->col_outline); u8 titlewidth = getStringWidth(title)+5; - drawString(title, (NORMALIZEBOX_WIDTH-titlewidth)/2, 2, theme->col_text, titlewidth+5); + drawString(title, (NORMALIZEBOX_WIDTH-titlewidth)/2, 3, theme->col_messagebox_title_text, titlewidth+5); gui.draw(); } diff --git a/arm9/source/tobkit/sampledisplay.cpp b/arm9/source/tobkit/sampledisplay.cpp index c690862..579a368 100644 --- a/arm9/source/tobkit/sampledisplay.cpp +++ b/arm9/source/tobkit/sampledisplay.cpp @@ -685,32 +685,32 @@ void SampleDisplay::draw(void) if(!draw_mode) { // Outlines - drawHLine(2, 1, 7, theme->col_light_bg); - drawHLine(10, 1, 7, theme->col_light_bg); + drawHLine(2, 1, 7, theme->col_smp_zoom); + drawHLine(10, 1, 7, theme->col_smp_zoom); - drawHLine(2, 9, 7, theme->col_light_bg); - drawHLine(10, 9, 7, theme->col_light_bg); + drawHLine(2, 9, 7, theme->col_smp_zoom); + drawHLine(10, 9, 7, theme->col_smp_zoom); - drawVLine(1, 2, 7, theme->col_light_bg); - drawVLine(9, 2, 7, theme->col_light_bg); - drawVLine(17, 2, 7, theme->col_light_bg); + drawVLine(1, 2, 7, theme->col_smp_zoom); + drawVLine(9, 2, 7, theme->col_smp_zoom); + drawVLine(17, 2, 7, theme->col_smp_zoom); // + if(pen_on_zoom_in) { - drawFullBox(2, 2, 7, 7, theme->col_light_bg); + drawFullBox(2, 2, 7, 7, theme->col_smp_zoom); drawHLine(3, 5, 5, theme->col_smp_bg); drawVLine(5, 3, 5, theme->col_smp_bg); } else { - drawHLine(3, 5, 5, theme->col_light_bg); - drawVLine(5, 3, 5, theme->col_light_bg); + drawHLine(3, 5, 5, theme->col_smp_zoom); + drawVLine(5, 3, 5, theme->col_smp_zoom); } // - if(pen_on_zoom_out) { - drawFullBox(10, 2, 7, 7, theme->col_light_bg); + drawFullBox(10, 2, 7, 7, theme->col_smp_zoom); drawHLine(11, 5, 5, theme->col_smp_bg); } else { - drawHLine(11, 5, 5, theme->col_light_bg); + drawHLine(11, 5, 5, theme->col_smp_zoom); } } } diff --git a/themes/Default.nttheme b/themes/Default.nttheme index 919b7dd..3a68020 100644 --- a/themes/Default.nttheme +++ b/themes/Default.nttheme @@ -1,98 +1,103 @@ -0=20317b ; Background -1=20317b ; Envelope editor background -2=4a5a8b ; Medium background -3=8394c5 ; Light background -4=bdcdff ; Lighter background -5=ffff00 ; Light control / button gradient 1 -6=ff9400 ; Dark control / button gradient 2 -7=8394c5 ; Light control (disabled) -8=4a5a8b ; Dark control (disabled) -9=8394c5 ; Selected tab -10=4a5a8b ; Unselected tab -11=4a5a8b ; List item gradient 1 -12=8394c5 ; List item gradient 2 -13=e67b00 ; List item gradient 1 (highlighted) -14=e6e600 ; List item gradient 2 (highlighted) -15=4a5a8b ; Scrollbar background gradient 1 -16=8394c5 ; Scrollbar background gradient 2 -17=ff9400 ; Scrollbar thumb (inactive) -18=ffff00 ; Scrollbar thumb (active) -19=ff9400 ; Scrollbar arrow background gradient 1 -20=ffff00 ; Scrollbar arrow background gradient 2 -21=000000 ; Widget outline -22=000000 ; Tab/tab box outline -23=ffff00 ; List item separator line -24=000000 ; Tab icon -25=000000 ; Button icon and scrollbar arrows -26=000000 ; Checkmark -27=000000 ; Text -28=8394c5 ; Text (light) -29=000000 ; Text (buttons) -30=000000 ; Text (value input) -31=000000 ; Text (list items) -32=000000 ; Text (highlighted list item) -33=ff0000 ; Recording/signal (red) -34=940000 ; Recording/signal (off, dark red) -35=000000 ; Piano mapping label (naturals) -36=ffffff ; Piano mapping label (inverted, sharps) -37=39cd29 ; Loop points -38=00ff00 ; Envelope sustain line -39=ff9400 ; Envelope line -40=ffff00 ; Envelope point fill -41=000000 ; Envelope point outline -42=ff0000 ; Envelope point outline (active) -43=8bc583 ; Memory usage: OK -44=ffff00 ; Memory usage: Warning -45=ff0000 ; Memory usage: Alert -46=000000 ; Text entry cursor -47=20317b ; Sample editor background -48=ffff00 ; Sample editor background (selection) -49=ff9c00 ; Sample editor waveform -50=000000 ; Sample editor waveform (selection) -51=20317b ; Pattern - background -52=8394c5 ; Pattern - channel number -53=8394c5 ; Pattern - lines -54=394a8b ; Pattern - sublines -55=ff9400 ; Pattern - lines (recording) -56=4a5a8b ; Pattern - cursor bar gradient 1 -57=8394c5 ; Pattern - cursor bar gradient 2 -58=e67b00 ; Pattern - cursor bar gradient 1 (highlight) -59=e6e600 ; Pattern - cursor bar gradient 2 (highlight) -60=e67b00 ; Pattern - row numbers -61=4a7bff ; Pattern - notes -62=0031d5 ; Pattern - notes (dark) -63=ff5a00 ; Pattern - instruments -64=a43100 ; Pattern - instruments (dark) -65=00de00 ; Pattern - volume -66=008300 ; Patterm - volume (dark) -67=ff62ee ; Pattern - effect command -68=623194 ; Pattern - effect command (dark) -69=f6d541 ; Pattern - effect parameter -70=4a4129 ; Pattern - effect parameter (dark) -71=ffc500 ; Pattern - selection -72=000000 ; Pattern - row outline -73=000000 ; Pattern - cursor outline -74=000000 ; Pattern - mute/solo text color -75=4a5a8b ; Pattern - mute/solo gradient 1 -76=8394c5 ; Pattern - mute/solo gradient 2 -77=e67b00 ; Pattern - mute/solo gradient 1 (highlight) -78=e6e600 ; Pattern - mute/solo gradient 2 (highlight) -79=e67b00 ; Pattern - row numbers (highlight) -80=ffff00 ; List item separator line (vertical) -81=ff9400 ; Togglebutton background -82=000000 ; Togglebutton text (off) -83=ffff00 ; Togglebutton text (on) -84=ffffff ; Piano - full key color 1 -85=cbcbcb ; Piano - full key color 2 -86=000000 ; Piano - half key color 1 -87=383838 ; Piano - half key color 2 -88=b2b2e3 ; Piano - full key color 1 (highlight) -89=a2a2d3 ; Piano - full key color 2 (highlight) -90=690000 ; Piano - half key color 1 (highlight) -91=9a3838 ; Piano - half key color 2 (highlight) -92=000000 ; Piano - outline -93=ffffff ; Text entry background -94=b2b2e3 ; Text entry keys -95=000000 ; Text entry key labels -96=8a8ad3 ; Text entry modifier keys -97=ffffff ; Text entry pressed keys \ No newline at end of file +0=20317b ; Background +1=20317b ; Envelope editor background +2=4a5a8b ; Medium background +3=8394c5 ; Light background +4=bdcdff ; Lighter background +5=ffff00 ; Light control / button gradient 1 +6=ff9400 ; Dark control / button gradient 2 +7=8394c5 ; Light control (disabled) +8=4a5a8b ; Dark control (disabled) +9=8394c5 ; Selected tab +10=4a5a8b ; Unselected tab +11=4a5a8b ; List item gradient 1 +12=8394c5 ; List item gradient 2 +13=e67b00 ; List item gradient 1 (highlighted) +14=e6e600 ; List item gradient 2 (highlighted) +15=4a5a8b ; Scrollbar background gradient 1 +16=8394c5 ; Scrollbar background gradient 2 +17=ff9400 ; Scrollbar thumb (inactive) +18=ffff00 ; Scrollbar thumb (active) +19=ff9400 ; Scrollbar arrow background gradient 1 +20=ffff00 ; Scrollbar arrow background gradient 2 +21=000000 ; Widget outline +22=000000 ; Tab/tab box outline +23=ffff00 ; List item separator line +24=000000 ; Tab icon +25=000000 ; Button icon and scrollbar arrows +26=000000 ; Checkmark +27=000000 ; Text +28=8394c5 ; Text (light) +29=000000 ; Text (buttons) +30=000000 ; Text (value input) +31=000000 ; Text (list items) +32=000000 ; Text (highlighted list item) +33=ff0000 ; Recording/signal (red) +34=940000 ; Recording/signal (off, dark red) +35=000000 ; Piano mapping label (naturals) +36=ffffff ; Piano mapping label (inverted, sharps) +37=39cd29 ; Loop points +38=00ff00 ; Envelope sustain line +39=ff9400 ; Envelope line +40=ffff00 ; Envelope point fill +41=000000 ; Envelope point outline +42=ff0000 ; Envelope point outline (active) +43=8bc583 ; Memory usage: OK +44=ffff00 ; Memory usage: Warning +45=ff0000 ; Memory usage: Alert +46=000000 ; Text entry cursor +47=20317b ; Sample editor background +48=ffff00 ; Sample editor background (selection) +49=ff9c00 ; Sample editor waveform +50=000000 ; Sample editor waveform (selection) +51=20317b ; Pattern - background +52=8394c5 ; Pattern - channel number +53=8394c5 ; Pattern - lines +54=394a8b ; Pattern - sublines +55=ff9400 ; Pattern - lines (recording) +56=4a5a8b ; Pattern - cursor bar gradient 1 +57=8394c5 ; Pattern - cursor bar gradient 2 +58=e67b00 ; Pattern - cursor bar gradient 1 (highlight) +59=e6e600 ; Pattern - cursor bar gradient 2 (highlight) +60=e67b00 ; Pattern - row numbers +61=4a7bff ; Pattern - notes +62=0031d5 ; Pattern - notes (dark) +63=ff5a00 ; Pattern - instruments +64=a43100 ; Pattern - instruments (dark) +65=00de00 ; Pattern - volume +66=008300 ; Patterm - volume (dark) +67=ff62ee ; Pattern - effect command +68=623194 ; Pattern - effect command (dark) +69=f6d541 ; Pattern - effect parameter +70=4a4129 ; Pattern - effect parameter (dark) +71=ffc500 ; Pattern - selection +72=000000 ; Pattern - row outline +73=000000 ; Pattern - cursor outline +74=000000 ; Pattern - mute/solo text color +75=4a5a8b ; Pattern - mute/solo gradient 1 +76=8394c5 ; Pattern - mute/solo gradient 2 +77=e67b00 ; Pattern - mute/solo gradient 1 (highlight) +78=e6e600 ; Pattern - mute/solo gradient 2 (highlight) +79=e67b00 ; Pattern - row numbers (highlight) +80=ffff00 ; List item separator line (vertical) +81=ff9400 ; Togglebutton background +82=000000 ; Togglebutton text (off) +83=ffff00 ; Togglebutton text (on) +84=ffffff ; Piano - full key color 1 +85=cbcbcb ; Piano - full key color 2 +86=000000 ; Piano - half key color 1 +87=383838 ; Piano - half key color 2 +88=b2b2e3 ; Piano - full key color 1 (highlight) +89=a2a2d3 ; Piano - full key color 2 (highlight) +90=690000 ; Piano - half key color 1 (highlight) +91=9a3838 ; Piano - half key color 2 (highlight) +92=000000 ; Piano - outline +93=ffffff ; Text entry background +94=b2b2e3 ; Text entry keys +95=000000 ; Text entry key labels +96=8a8ad3 ; Text entry modifier keys +97=ffffff ; Text entry pressed keys +98=000000 ; Text entry modifier key labesl +99=8394c5 ; Sample editor zoom buttons +100=e67b00 ; Message box title bar gradient 1 +101=e6e600 ; Message box title bar gradient 2 +102=000000 ; Message box title bar text \ No newline at end of file diff --git a/themes/Sky.nttheme b/themes/Sky.nttheme index c5b5f66..c0c98e7 100644 --- a/themes/Sky.nttheme +++ b/themes/Sky.nttheme @@ -5,8 +5,8 @@ 4=fcfdff ; Lighter background 5=ebfafa ; Light control / button gradient 1 6=a9e3fa ; Dark control / button gradient 2 -7=cce4eb ; Light control (disabled) -8=b2c9d0 ; Dark control (disabled) +7=acc4eb ; Light control (disabled) +8=82a9d0 ; Dark control (disabled) 9=f7faff ; Selected tab 10=5c90c4 ; Unselected tab 11=e3fcee ; List item gradient 1 @@ -96,4 +96,8 @@ 95=bce6f9 ; Text entry key labels 96=bcb2d8 ; Text entry modifier keys 97=b5f9df ; Text entry pressed keys -98=8d83b6 ; Text entry modifier key labels \ No newline at end of file +98=8d83b6 ; Text entry modifier key labels +99=c0bbd9 ; Sample editor zoom buttons +100=8acbb2 ; Message box title bar gradient 1 +101=b5f9df ; Message box title bar gradient 2 +102=fdfeff ; Message box title bar text \ No newline at end of file diff --git a/tobkit/include/tobkit/theme.h b/tobkit/include/tobkit/theme.h index 19dd71a..4c0f055 100644 --- a/tobkit/include/tobkit/theme.h +++ b/tobkit/include/tobkit/theme.h @@ -22,7 +22,7 @@ limitations under the License. #include "../../arm9/source/tools.h" #include -#define NUM_COLORS 99 +#define NUM_COLORS 103 namespace tobkit { @@ -129,6 +129,10 @@ struct ColorScheme { u16 col_typewriter_mod_key; u16 col_typewriter_pressed_key; u16 col_typewriter_mod_key_label; + u16 col_smp_zoom; + u16 col_messagebox_title_col1; + u16 col_messagebox_title_col2; + u16 col_messagebox_title_text; }; }; diff --git a/tobkit/source/messagebox.cpp b/tobkit/source/messagebox.cpp index d612b1b..631a2e0 100644 --- a/tobkit/source/messagebox.cpp +++ b/tobkit/source/messagebox.cpp @@ -160,11 +160,11 @@ void MessageBox::setTheme(Theme *theme_, u16 bgcolor_) void MessageBox::draw(void) { - drawGradient(theme->col_list_highlight1, theme->col_list_highlight2, 0, 1, width, 15); + drawGradient(theme->col_messagebox_title_col1, theme->col_messagebox_title_col2, 0, 1, width, 15); drawHLine(0, 16, width, theme->col_outline); drawFullBox(0, 17, width, MB_HEIGHT-17, theme->col_light_bg); drawBorder(theme->col_outline); u8 labelx = (width-getStringWidth(msg))/2; - drawString(msg, labelx, 3, theme->col_text, width); + drawString(msg, labelx, 3, theme->col_messagebox_title_text, width); gui.draw(); } diff --git a/tobkit/source/theme.cpp b/tobkit/source/theme.cpp index 62677c1..9567537 100644 --- a/tobkit/source/theme.cpp +++ b/tobkit/source/theme.cpp @@ -120,6 +120,10 @@ ColorScheme::ColorScheme() { col_typewriter_mod_key = RGB15(17, 17, 26) | BIT(15); col_typewriter_pressed_key = col_typewriter_bg; col_typewriter_mod_key_label = col_typewriter_key_label; + col_smp_zoom = col_light_bg; + col_messagebox_title_col1 = col_list_highlight1; + col_messagebox_title_col2 = col_list_highlight2; + col_messagebox_title_text = col_text; } Theme::Theme(char* themepath, bool use_fat) @@ -190,14 +194,15 @@ bool Theme::parseTheme(FILE* theme_, u16* theme_cols) { if (theme_ == NULL || theme_cols == NULL) return false; - int theme_i = 0; - int r, g, b, k, parsed; + int r, g, b, k, l, parsed; - for (int l = 0; l < NUM_COLORS; ++l) { + bool theme_has_key[NUM_COLORS] = { 0 }; + + for (l = 0;;++l) { parsed = fscanf(theme_, "%d=%02x%02x%02x%*[^\n]\n", &k, &r, &g, &b); if (parsed == EOF) break; - + if (parsed != 4 || k < 0) { debugprintf("theme parse error on line %d\n", l + 1); return false; @@ -207,16 +212,20 @@ bool Theme::parseTheme(FILE* theme_, u16* theme_cols) { return false; } theme_cols[k] = RGB15(r >> 3, g >> 3, b >> 3) | BIT(15); - theme_i++; + theme_has_key[k] = true; } - if (theme_i == 0) { - debugprintf("ignoring empty theme\n"); + if (l == 0) { + ntxm_dprintf("ignoring empty theme\n"); return false; } - - if (theme_i < NUM_COLORS - 1) - debugprintf("theme only specifies %u colors, using defaults for remaining %u\n", theme_i, NUM_COLORS - theme_i); + + // check if specific colours were specified by the theme + // if not replace them with their previous colour from the same theme + if (!theme_has_key[99]) theme_cols[99] = theme_cols[3]; // Sample editor zoom buttons + if (!theme_has_key[100]) theme_cols[100] = theme_cols[13]; // Message box title gradient col1 + if (!theme_has_key[101]) theme_cols[101] = theme_cols[14]; // Message box title gradient col2 + if (!theme_has_key[102]) theme_cols[102] = theme_cols[27]; // Message box title text return true; } diff --git a/tobkit/source/themeselectorbox.cpp b/tobkit/source/themeselectorbox.cpp index 961209b..6e26701 100644 --- a/tobkit/source/themeselectorbox.cpp +++ b/tobkit/source/themeselectorbox.cpp @@ -130,13 +130,13 @@ void ThemeSelectorBox::pleaseDraw(void) void ThemeSelectorBox::draw(void) { - drawGradient(theme->col_list_highlight1, theme->col_list_highlight2, 1, 1, width - 2, 15); + drawGradient(theme->col_messagebox_title_col1, theme->col_messagebox_title_col2, 1, 1, width - 2, 15); drawHLine(1, 16, width - 2, theme->col_outline); drawFullBox(1, 17, width - 2, THEMESELBOX_HEIGHT-17, theme->col_light_bg); drawBorder(theme->col_outline); u8 titlewidth = getStringWidth(title)+5; - drawString(title, (THEMESELBOX_WIDTH-titlewidth)/2, 4, theme->col_text, titlewidth+5); + drawString(title, (THEMESELBOX_WIDTH-titlewidth)/2, 4, theme->col_messagebox_title_text, titlewidth+5); gui.draw(); }