mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 21:38:40 +00:00
prefer serializing theme presets, if applicable
This commit is contained in:
+72
-13
@@ -8075,24 +8075,60 @@ df_cfg_strings_from_gfx(Arena *arena, String8 root_path, DF_CfgSrc source)
|
|||||||
//- rjf: serialize theme colors
|
//- rjf: serialize theme colors
|
||||||
if(source == DF_CfgSrc_User)
|
if(source == DF_CfgSrc_User)
|
||||||
{
|
{
|
||||||
|
// rjf: determine if this theme matches an existing preset
|
||||||
|
B32 is_preset = 0;
|
||||||
|
DF_ThemePreset matching_preset = DF_ThemePreset_DefaultDark;
|
||||||
|
{
|
||||||
|
for(DF_ThemePreset p = (DF_ThemePreset)0; p < DF_ThemePreset_COUNT; p = (DF_ThemePreset)(p+1))
|
||||||
|
{
|
||||||
|
B32 matches_this_preset = 1;
|
||||||
|
for(DF_ThemeColor c = (DF_ThemeColor)(DF_ThemeColor_Null+1); c < DF_ThemeColor_COUNT; c = (DF_ThemeColor)(c+1))
|
||||||
|
{
|
||||||
|
if(!MemoryMatchStruct(&df_gfx_state->cfg_theme_target.colors[c], &df_g_theme_preset_colors_table[p][c]))
|
||||||
|
{
|
||||||
|
matches_this_preset = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(matches_this_preset)
|
||||||
|
{
|
||||||
|
is_preset = 1;
|
||||||
|
matching_preset = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// rjf: serialize header
|
||||||
String8 indent_str = str8_lit(" ");
|
String8 indent_str = str8_lit(" ");
|
||||||
str8_list_push(arena, &strs, str8_lit("/// colors ////////////////////////////////////////////////////////////////////\n"));
|
str8_list_push(arena, &strs, str8_lit("/// colors ////////////////////////////////////////////////////////////////////\n"));
|
||||||
str8_list_push(arena, &strs, str8_lit("\n"));
|
str8_list_push(arena, &strs, str8_lit("\n"));
|
||||||
str8_list_push(arena, &strs, str8_lit("colors:\n"));
|
|
||||||
str8_list_push(arena, &strs, str8_lit("{\n"));
|
// rjf: serialize preset theme
|
||||||
for(DF_ThemeColor color = (DF_ThemeColor)(DF_ThemeColor_Null+1);
|
if(is_preset)
|
||||||
color < DF_ThemeColor_COUNT;
|
|
||||||
color = (DF_ThemeColor)(color+1))
|
|
||||||
{
|
{
|
||||||
String8 color_name = df_g_theme_color_cfg_string_table[color];
|
str8_list_pushf(arena, &strs, "color_preset: \"%S\"\n\n", df_g_theme_preset_code_string_table[matching_preset]);
|
||||||
Vec4F32 color_rgba = df_gfx_state->cfg_theme_target.colors[color];
|
}
|
||||||
String8 color_hex = hex_string_from_rgba_4f32(arena, color_rgba);
|
|
||||||
str8_list_pushf(arena, &strs, " %S:%.*s0x%S\n",
|
// rjf: serialize non-preset theme
|
||||||
color_name,
|
if(!is_preset)
|
||||||
30 > color_name.size ? ((int)(30 - color_name.size)) : 0, indent_str.str,
|
{
|
||||||
color_hex);
|
str8_list_push(arena, &strs, str8_lit("colors:\n"));
|
||||||
|
str8_list_push(arena, &strs, str8_lit("{\n"));
|
||||||
|
for(DF_ThemeColor color = (DF_ThemeColor)(DF_ThemeColor_Null+1);
|
||||||
|
color < DF_ThemeColor_COUNT;
|
||||||
|
color = (DF_ThemeColor)(color+1))
|
||||||
|
{
|
||||||
|
String8 color_name = df_g_theme_color_cfg_string_table[color];
|
||||||
|
Vec4F32 color_rgba = df_gfx_state->cfg_theme_target.colors[color];
|
||||||
|
String8 color_hex = hex_string_from_rgba_4f32(arena, color_rgba);
|
||||||
|
str8_list_pushf(arena, &strs, " %S:%.*s0x%S\n",
|
||||||
|
color_name,
|
||||||
|
30 > color_name.size ? ((int)(30 - color_name.size)) : 0, indent_str.str,
|
||||||
|
color_hex);
|
||||||
|
}
|
||||||
|
str8_list_push(arena, &strs, str8_lit("}\n\n"));
|
||||||
}
|
}
|
||||||
str8_list_push(arena, &strs, str8_lit("}\n\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: serialize fonts
|
//- rjf: serialize fonts
|
||||||
@@ -11477,6 +11513,29 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- rjf: apply theme presets
|
||||||
|
DF_CfgVal *color_preset = df_cfg_val_from_string(table, str8_lit("color_preset"));
|
||||||
|
if(color_preset != &df_g_nil_cfg_val)
|
||||||
|
{
|
||||||
|
String8 color_preset_name = color_preset->last->first->string;
|
||||||
|
DF_ThemePreset preset = (DF_ThemePreset)0;
|
||||||
|
B32 found_preset = 0;
|
||||||
|
for(DF_ThemePreset p = (DF_ThemePreset)0; p < DF_ThemePreset_COUNT; p = (DF_ThemePreset)(p+1))
|
||||||
|
{
|
||||||
|
if(str8_match(color_preset_name, df_g_theme_preset_code_string_table[p], StringMatchFlag_CaseInsensitive))
|
||||||
|
{
|
||||||
|
found_preset = 1;
|
||||||
|
preset = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(found_preset)
|
||||||
|
{
|
||||||
|
MemoryCopy(df_gfx_state->cfg_theme_target.colors, df_g_theme_preset_colors_table[preset], sizeof(df_g_theme_preset_colors__default_dark));
|
||||||
|
MemoryCopy(df_gfx_state->cfg_theme.colors, df_g_theme_preset_colors_table[preset], sizeof(df_g_theme_preset_colors__default_dark));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//- rjf: if theme colors are all zeroes, then set to default - config appears busted
|
//- rjf: if theme colors are all zeroes, then set to default - config appears busted
|
||||||
{
|
{
|
||||||
B32 all_colors_are_zero = 1;
|
B32 all_colors_are_zero = 1;
|
||||||
|
|||||||
+60
-54
@@ -308,62 +308,62 @@ DF_GfxViewRuleTable:
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Theme Color Codes
|
//~ rjf: Theme Color Codes
|
||||||
|
|
||||||
@table(name display_name name_lower r g b a)
|
@table(name display_name name_lower allow_zero_on_load)
|
||||||
DF_ThemeTable:
|
DF_ThemeTable:
|
||||||
{
|
{
|
||||||
{Null "Null" null }
|
{Null "Null" null 0}
|
||||||
{PlainText "Plain Text" plain_text }
|
{PlainText "Plain Text" plain_text 0}
|
||||||
{PlainBackground "Plain Background" plain_background }
|
{PlainBackground "Plain Background" plain_background 0}
|
||||||
{PlainBorder "Plain Border" plain_border }
|
{PlainBorder "Plain Border" plain_border 0}
|
||||||
{PlainOverlay "Plain Overlay" plain_overlay }
|
{PlainOverlay "Plain Overlay" plain_overlay 0}
|
||||||
{CodeDefault "Code (Default)" code_default }
|
{CodeDefault "Code (Default)" code_default 0}
|
||||||
{CodeFunction "Code (Function)" code_function }
|
{CodeFunction "Code (Function)" code_function 0}
|
||||||
{CodeType "Code (Type)" code_type }
|
{CodeType "Code (Type)" code_type 0}
|
||||||
{CodeLocal "Code (Local)" code_local }
|
{CodeLocal "Code (Local)" code_local 0}
|
||||||
{CodeKeyword "Code (Keyword)" code_keyword }
|
{CodeKeyword "Code (Keyword)" code_keyword 0}
|
||||||
{CodeSymbol "Code (Symbol)" code_symbol }
|
{CodeSymbol "Code (Symbol)" code_symbol 0}
|
||||||
{CodeNumeric "Code (Numeric)" code_numeric }
|
{CodeNumeric "Code (Numeric)" code_numeric 0}
|
||||||
{CodeString "Code (String)" code_string }
|
{CodeString "Code (String)" code_string 0}
|
||||||
{CodeMeta "Code (Meta)" code_meta }
|
{CodeMeta "Code (Meta)" code_meta 0}
|
||||||
{CodeComment "Code (Comment)" code_comment }
|
{CodeComment "Code (Comment)" code_comment 0}
|
||||||
{LineInfo0 "Line Info (0)" line_info_0 }
|
{LineInfo0 "Line Info (0)" line_info_0 0}
|
||||||
{LineInfo1 "Line Info (1)" line_info_1 }
|
{LineInfo1 "Line Info (1)" line_info_1 0}
|
||||||
{LineInfo2 "Line Info (2)" line_info_2 }
|
{LineInfo2 "Line Info (2)" line_info_2 0}
|
||||||
{LineInfo3 "Line Info (3)" line_info_3 }
|
{LineInfo3 "Line Info (3)" line_info_3 0}
|
||||||
{AltText "Alt Text" alt_text }
|
{AltText "Alt Text" alt_text 0}
|
||||||
{AltBackground "Alt Background" alt_background }
|
{AltBackground "Alt Background" alt_background 0}
|
||||||
{AltBorder "Alt Border" alt_border }
|
{AltBorder "Alt Border" alt_border 0}
|
||||||
{AltOverlay "Alt Overlay" alt_overlay }
|
{AltOverlay "Alt Overlay" alt_overlay 0}
|
||||||
{TabInactive "Inactive Tab" tab_inactive }
|
{TabInactive "Inactive Tab" tab_inactive 0}
|
||||||
{TabActive "Active Tab" tab_active }
|
{TabActive "Active Tab" tab_active 0}
|
||||||
{EntityBackground "Entity Background" entity_background }
|
{EntityBackground "Entity Background" entity_background 0}
|
||||||
{QueryBar "Query Bar" query_bar }
|
{QueryBar "Query Bar" query_bar 0}
|
||||||
{WeakText "Weak Text" weak_text }
|
{WeakText "Weak Text" weak_text 0}
|
||||||
{TextSelection "Text Selection" text_selection }
|
{TextSelection "Text Selection" text_selection 0}
|
||||||
{Cursor "Cursor" cursor }
|
{Cursor "Cursor" cursor 0}
|
||||||
{Highlight0 "Highlight (0)" highlight_0 }
|
{Highlight0 "Highlight (0)" highlight_0 0}
|
||||||
{Highlight1 "Highlight (1)" highlight_1 }
|
{Highlight1 "Highlight (1)" highlight_1 0}
|
||||||
{SuccessText "Success Text" success_text }
|
{SuccessText "Success Text" success_text 0}
|
||||||
{SuccessBackground "Success Background" success_background }
|
{SuccessBackground "Success Background" success_background 0}
|
||||||
{SuccessBorder "Success Border" success_border }
|
{SuccessBorder "Success Border" success_border 0}
|
||||||
{FailureText "Failure Text" failure_text }
|
{FailureText "Failure Text" failure_text 0}
|
||||||
{FailureBackground "Failure Background" failure_background }
|
{FailureBackground "Failure Background" failure_background 0}
|
||||||
{FailureBorder "Failure Border" failure_border }
|
{FailureBorder "Failure Border" failure_border 0}
|
||||||
{ActionText "Action Text" action_text }
|
{ActionText "Action Text" action_text 0}
|
||||||
{ActionBackground "Action Background" action_background }
|
{ActionBackground "Action Background" action_background 0}
|
||||||
{ActionBorder "Action Border" action_border }
|
{ActionBorder "Action Border" action_border 0}
|
||||||
{DropSiteOverlay "Drop Site Overlay" drop_site_overlay }
|
{DropSiteOverlay "Drop Site Overlay" drop_site_overlay 0}
|
||||||
{Thread0 "Thread (0)" thread_0 }
|
{Thread0 "Thread (0)" thread_0 0}
|
||||||
{Thread1 "Thread (1)" thread_1 }
|
{Thread1 "Thread (1)" thread_1 0}
|
||||||
{Thread2 "Thread (2)" thread_2 }
|
{Thread2 "Thread (2)" thread_2 0}
|
||||||
{Thread3 "Thread (3)" thread_3 }
|
{Thread3 "Thread (3)" thread_3 0}
|
||||||
{Thread4 "Thread (4)" thread_4 }
|
{Thread4 "Thread (4)" thread_4 0}
|
||||||
{Thread5 "Thread (5)" thread_5 }
|
{Thread5 "Thread (5)" thread_5 0}
|
||||||
{Thread6 "Thread (6)" thread_6 }
|
{Thread6 "Thread (6)" thread_6 0}
|
||||||
{Thread7 "Thread (7)" thread_7 }
|
{Thread7 "Thread (7)" thread_7 0}
|
||||||
{ThreadUnwound "Thread (Unwound)" thread_unwound }
|
{ThreadUnwound "Thread (Unwound)" thread_unwound 0}
|
||||||
{InactivePanelOverlay "Inactive Panel Overlay" inactive_panel_overlay }
|
{InactivePanelOverlay "Inactive Panel Overlay" inactive_panel_overlay 1}
|
||||||
{DropShadow "Drop Shadow" drop_shadow }
|
{DropShadow "Drop Shadow" drop_shadow 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -487,6 +487,12 @@ df_g_theme_preset_display_string_table:
|
|||||||
@expand(DF_ThemePresetTable a) `str8_lit_comp("$(a.display_string)"),`;
|
@expand(DF_ThemePresetTable a) `str8_lit_comp("$(a.display_string)"),`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@table_gen_data(type: String8, fallback: `{0}`)
|
||||||
|
df_g_theme_preset_code_string_table:
|
||||||
|
{
|
||||||
|
@expand(DF_ThemePresetTable a) `str8_lit_comp("$(a.name_lower)"),`;
|
||||||
|
}
|
||||||
|
|
||||||
@table_gen_data(type: Vec4F32, fallback: `{1, 0, 1, 1}`)
|
@table_gen_data(type: Vec4F32, fallback: `{1, 0, 1, 1}`)
|
||||||
df_g_theme_preset_colors__default_dark:
|
df_g_theme_preset_colors__default_dark:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -235,6 +235,19 @@ str8_lit_comp("4coder"),
|
|||||||
str8_lit_comp("Far Manager"),
|
str8_lit_comp("Far Manager"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
String8 df_g_theme_preset_code_string_table[] =
|
||||||
|
{
|
||||||
|
str8_lit_comp("default_dark"),
|
||||||
|
str8_lit_comp("default_light"),
|
||||||
|
str8_lit_comp("vs_dark"),
|
||||||
|
str8_lit_comp("vs_light"),
|
||||||
|
str8_lit_comp("solarized_dark"),
|
||||||
|
str8_lit_comp("solarized_light"),
|
||||||
|
str8_lit_comp("handmade_hero"),
|
||||||
|
str8_lit_comp("four_coder"),
|
||||||
|
str8_lit_comp("far_manager"),
|
||||||
|
};
|
||||||
|
|
||||||
Vec4F32 df_g_theme_preset_colors__default_dark[] =
|
Vec4F32 df_g_theme_preset_colors__default_dark[] =
|
||||||
{
|
{
|
||||||
rgba_from_u32_lit_comp(0xff00ffff),
|
rgba_from_u32_lit_comp(0xff00ffff),
|
||||||
|
|||||||
Reference in New Issue
Block a user