@@ -329,7 +329,7 @@ public UndertaleCodeEditor()
329329 DecompiledSearchReplacePanel . Initialize ( DecompiledEditor . TextArea ) ;
330330 DecompiledEditor . FontSize = ZoomFontSize ;
331331
332- LoadGMLHighlighting ( Settings . Instance ? . EnableDarkMode ?? false ) ;
332+ LoadGMLHighlighting ( Settings . IsCodeEditorDark ) ;
333333
334334 DecompiledEditor . Options . ConvertTabsToSpaces = true ;
335335
@@ -360,7 +360,7 @@ public UndertaleCodeEditor()
360360 DisassemblySearchReplacePanel . Initialize ( DisassemblyEditor . TextArea ) ;
361361 DisassemblyEditor . FontSize = ZoomFontSize ;
362362
363- LoadVMASMHighlighting ( Settings . Instance ? . EnableDarkMode ?? false ) ;
363+ LoadVMASMHighlighting ( Settings . IsCodeEditorDark ) ;
364364
365365 textArea = DisassemblyEditor . TextArea ;
366366 _disassemblyNameGenerator = new NameGenerator ( this , textArea ) ;
@@ -379,7 +379,7 @@ public UndertaleCodeEditor()
379379 _disassemblyModifiedRenderer . MarkDirty ( ) ;
380380 } ;
381381
382- ApplyEditorTheme ( Settings . Instance ? . EnableDarkMode ?? false ) ;
382+ ApplyEditorTheme ( Settings . IsCodeEditorDark ) ;
383383
384384 _foldingTimer = new System . Windows . Threading . DispatcherTimer
385385 {
@@ -472,6 +472,8 @@ private void LoadVMASMHighlighting(bool isDark)
472472
473473 private void ApplyEditorTheme ( bool isDark )
474474 {
475+ ApplyEditorBackground ( ) ;
476+
475477 void ApplyTo ( TextEditor editor )
476478 {
477479 editor . Foreground = isDark
@@ -901,7 +903,7 @@ private Border BuildNumberHoverContent(string numText, UndertaleData data)
901903 }
902904
903905 StackPanel panel = new ( ) { MaxWidth = 320 } ;
904- bool isDarkMode = Settings . Instance . EnableDarkMode ;
906+ bool isDarkMode = Settings . IsCodeEditorDark ;
905907 Brush textBrush = isDarkMode ? Brushes . White : Brushes . Black ;
906908 Brush subTextBrush = isDarkMode ? Brushes . LightGray : Brushes . DarkGray ;
907909
@@ -1073,7 +1075,7 @@ private Border BuildNameHoverContent(string nameText, UndertaleData data, bool i
10731075 }
10741076
10751077 StackPanel panel = new ( ) { MaxWidth = 320 } ;
1076- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1078+ bool isDarkMode = Settings . IsCodeEditorDark ;
10771079 Brush textBrush = isDarkMode ? Brushes . White : Brushes . Black ;
10781080 Brush subTextBrush = isDarkMode ? Brushes . LightGray : Brushes . DarkGray ;
10791081
@@ -1152,7 +1154,7 @@ private Border AppendInferredArgumentHover(Border hoverContent, string numText,
11521154 if ( perArgTypes is null || argIndex >= perArgTypes . Length || perArgTypes [ argIndex ] is not IMacroType argType )
11531155 return hoverContent ;
11541156
1155- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1157+ bool isDarkMode = Settings . IsCodeEditorDark ;
11561158 Brush textBrush = isDarkMode ? Brushes . White : Brushes . Black ;
11571159 Brush typeBrush = isDarkMode
11581160 ? new SolidColorBrush ( Color . FromRgb ( 78 , 201 , 176 ) )
@@ -1209,7 +1211,7 @@ private Border AppendInferredFunctionTypesHover(Border hoverContent, string func
12091211 if ( description . Length > 120 )
12101212 description = description . Substring ( 0 , 117 ) + "..." ;
12111213
1212- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1214+ bool isDarkMode = Settings . IsCodeEditorDark ;
12131215 Brush typeBrush = isDarkMode
12141216 ? new SolidColorBrush ( Color . FromRgb ( 78 , 201 , 176 ) )
12151217 : new SolidColorBrush ( Color . FromRgb ( 0 , 128 , 0 ) ) ;
@@ -1389,7 +1391,7 @@ private static string ResolveMacroValueName(IMacroType type, int value, Undertal
13891391
13901392 private Border CreateHoverBorder ( UIElement content )
13911393 {
1392- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1394+ bool isDarkMode = Settings . IsCodeEditorDark ;
13931395 Brush bgBrush = isDarkMode
13941396 ? new SolidColorBrush ( Color . FromRgb ( 45 , 45 , 48 ) )
13951397 : new SolidColorBrush ( Color . FromRgb ( 240 , 240 , 240 ) ) ;
@@ -1410,7 +1412,7 @@ private Border CreateHoverBorder(UIElement content)
14101412
14111413 private Border BuildBuiltinFunctionHover ( string nameText )
14121414 {
1413- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1415+ bool isDarkMode = Settings . IsCodeEditorDark ;
14141416 Brush textBrush = isDarkMode ? Brushes . White : Brushes . Black ;
14151417 Brush subTextBrush = isDarkMode ? Brushes . LightGray : Brushes . DarkGray ;
14161418 Brush paramBrush = isDarkMode
@@ -1523,7 +1525,7 @@ private Border BuildBuiltinFunctionHover(string nameText)
15231525
15241526 private Border BuildBuiltinVariableHover ( string nameText )
15251527 {
1526- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1528+ bool isDarkMode = Settings . IsCodeEditorDark ;
15271529 Brush textBrush = isDarkMode ? Brushes . White : Brushes . Black ;
15281530 Brush subTextBrush = isDarkMode ? Brushes . LightGray : Brushes . DarkGray ;
15291531 Brush typeBrush = isDarkMode
@@ -1590,7 +1592,7 @@ private Border BuildBuiltinVariableHover(string nameText)
15901592
15911593 private Border BuildBuiltinConstantHover ( string nameText )
15921594 {
1593- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1595+ bool isDarkMode = Settings . IsCodeEditorDark ;
15941596 Brush textBrush = isDarkMode ? Brushes . White : Brushes . Black ;
15951597 Brush subTextBrush = isDarkMode ? Brushes . LightGray : Brushes . DarkGray ;
15961598 Brush typeBrush = isDarkMode
@@ -1652,9 +1654,24 @@ private Border BuildBuiltinConstantHover(string nameText)
16521654
16531655 public void SetBackgroundTransparency ( bool enable )
16541656 {
1655- bool isDarkMode = Settings . Instance . EnableDarkMode ;
1657+ _editorBackgroundTransparent = enable ;
1658+ ApplyEditorBackground ( ) ;
1659+ }
1660+
1661+ /// <summary>
1662+ /// Whether the editor backgrounds are currently semi-transparent (custom background image active).
1663+ /// </summary>
1664+ private bool _editorBackgroundTransparent ;
1665+
1666+ /// <summary>
1667+ /// Applies the editor background brush for the current code editor theme
1668+ /// (opaque unless a custom background image is active).
1669+ /// </summary>
1670+ private void ApplyEditorBackground ( )
1671+ {
1672+ bool isDarkMode = Settings . IsCodeEditorDark ;
16561673 Brush bg ;
1657- if ( enable )
1674+ if ( _editorBackgroundTransparent )
16581675 {
16591676 // Semi-transparent: dark mode = dark tint, light mode = white tint
16601677 bg = isDarkMode
@@ -1677,7 +1694,7 @@ void ApplyToEditor(ICSharpCode.AvalonEdit.TextEditor editor)
16771694 ApplyToEditor ( DisassemblyEditor ) ;
16781695
16791696 // Make the TabControl content panel transparent so background image shows through
1680- CodeModeTabs . SetBackgroundTransparency ( enable ) ;
1697+ CodeModeTabs . SetBackgroundTransparency ( _editorBackgroundTransparent ) ;
16811698 }
16821699
16831700 private void InitializeIntellisense ( )
@@ -2244,7 +2261,7 @@ private void UndertaleCodeEditor_Unloaded(object sender, RoutedEventArgs e)
22442261 private void UndertaleCodeEditor_Loaded ( object sender , RoutedEventArgs e )
22452262 {
22462263 // Make sure the colors match the theme if it changed while this editor was hidden
2247- ApplyTheme ( Settings . Instance ? . EnableDarkMode ?? false ) ;
2264+ ApplyTheme ( Settings . IsCodeEditorDark ) ;
22482265 FillInCodeViewer ( ) ;
22492266 }
22502267 private void FillInCodeViewer ( bool overrideFirst = false )
@@ -3469,7 +3486,7 @@ public NameGenerator(UndertaleCodeEditor codeEditorInst, TextArea textAreaInst)
34693486 highlighterInst = textAreaInst . GetService ( typeof ( IHighlighter ) ) as IHighlighter ;
34703487 textEditorInst = textAreaInst . GetService ( typeof ( TextEditor ) ) as TextEditor ;
34713488
3472- UpdateBrushTheme ( Settings . Instance ? . EnableDarkMode ?? false ) ;
3489+ UpdateBrushTheme ( Settings . IsCodeEditorDark ) ;
34733490 }
34743491
34753492 /// <summary>
@@ -3945,7 +3962,7 @@ private static class CompletionItemStyle
39453962 private static readonly Dictionary < string , Brush > _darkBrushes = new ( ) ;
39463963 private static readonly Dictionary < string , Brush > _lightBrushes = new ( ) ;
39473964
3948- private static bool IsDark => Settings . Instance ? . EnableDarkMode ?? true ;
3965+ private static bool IsDark => Settings . IsCodeEditorDark ;
39493966
39503967 public static ImageSource GetIcon ( string kind )
39513968 {
0 commit comments