Skip to content

Commit

Permalink
Save theme selected in settings config
Browse files Browse the repository at this point in the history
  • Loading branch information
popcar2 committed Apr 17, 2024
1 parent c70ab94 commit 8eb4ef5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Scenes/MainScene/main_scene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_vckgf")
text = "Settings"

[node name="Settings" type="Control" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand Down Expand Up @@ -742,6 +743,7 @@ layout_mode = 2
size_flags_horizontal = 3

[node name="ThemeSelect" type="OptionButton" parent="Settings/ColorRect/MarginContainer/Panel/VBoxContainer/ThemeContainer/Control" groups=["color_button_toggle"]]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 13
anchor_left = 0.5
Expand Down
8 changes: 7 additions & 1 deletion Scenes/Settings/Settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func save_config():

config.set_value("Settings", "close_after_start", %CloseAfterStartButton.button_pressed)
config.set_value("Settings", "different_save_dirs", %DifferentSaveDirsButton.button_pressed)
config.set_value("Settings", "theme_index", %ThemeSelect.selected)

var err: Error = config.save("user://settings.cfg")
if err != OK:
Expand All @@ -35,6 +36,8 @@ func load_config():

_on_close_after_start_button_toggled(config.get_value("Settings", "close_after_start", false))
_on_different_save_dirs_button_toggled(config.get_value("Settings", "different_save_dirs", false))

%ThemeSelect.selected = config.get_value("Settings", "theme_index", 0)

func _on_back_button_pressed():
if modulate.a < 1:
Expand Down Expand Up @@ -85,4 +88,7 @@ func _on_theme_select_item_selected(index: int):
ThemeManager.set_theme("Cyan")
elif index == 2: #Purple
ThemeManager.set_theme("Purple")
elif index == 3: ThemeManager.set_theme("Simple")
elif index == 3:
ThemeManager.set_theme("Simple")

save_config()

0 comments on commit 8eb4ef5

Please sign in to comment.