Add a theme picker and an Original web theme (#42)
Settings has a Theme row listing Settings.THEMES: Classic (main_theme.tres, still the default) and Original web (original_web_theme.tres), which looks like MusicFrontend: orange-bordered buttons, a #333 header and popups, #424242 panels, #4e4e4e alternating rows, a yellow playing song and a light grey player bar. Picking one sets the root window's theme at once and saves it as theme_id in settings.cfg, and it is applied at start. The popup backdrop and score graph follow a theme switch. The top bar has its own TopBarBackground style. test_theme.gd checks that every theme has everything main_theme.tres has. The screenshot tool takes a theme id. Closes #42 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
70e970b24c
commit
94e8dfb602
15 files changed
+2497
-586
No files matched your search
@@ -0,0 +1,74 @@
|
||||
extends MainWindowTestSuite
|
||||
## Picking a theme in Settings switches the whole game's look at once and is saved.
|
||||
|
||||
var _settings: SettingsPopup
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
await super()
|
||||
_settings = _window.get_node("SettingsPopup")
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
Settings.apply_theme(Settings.THEMES[0].id)
|
||||
await super()
|
||||
|
||||
|
||||
func _pick(theme_name: String) -> void:
|
||||
var index: int = Settings.THEMES.map(
|
||||
func(entry: Dictionary) -> String: return entry.name).find(theme_name)
|
||||
_settings.theme_button.select(index)
|
||||
_settings.theme_button.item_selected.emit(index)
|
||||
await _runner.simulate_frames(1)
|
||||
|
||||
|
||||
func test_picker_lists_every_theme_and_shows_the_one_in_use() -> void:
|
||||
var names: Array[String] = []
|
||||
for index: int in _settings.theme_button.item_count:
|
||||
names.append(_settings.theme_button.get_item_text(index))
|
||||
|
||||
assert_array(names).contains_exactly(["Classic", "Original web"])
|
||||
assert_str(_settings.theme_button.get_item_text(_settings.theme_button.selected)) \
|
||||
.is_equal("Classic")
|
||||
|
||||
|
||||
func test_picking_a_theme_switches_the_look_at_once() -> void:
|
||||
var button: Button = _window.get_node("TopBar/%SyncButton")
|
||||
var classic_text: Color = button.get_theme_color(&"font_color")
|
||||
var panel: Panel = _window.get_node("SettingsPopup/SettingsPanel")
|
||||
var popup_style: StyleBox = panel.get_theme_stylebox(&"panel")
|
||||
|
||||
await _pick("Original web")
|
||||
|
||||
assert_str(Settings.theme_id).is_equal("original_web")
|
||||
assert_str(_window.get_tree().root.theme.resource_path) \
|
||||
.is_equal("res://themes/original_web_theme.tres")
|
||||
assert_object(panel.get_theme_stylebox(&"panel")).is_not_same(popup_style)
|
||||
# The web version's buttons have orange text
|
||||
assert_bool(button.get_theme_color(&"font_color") != classic_text).is_true()
|
||||
|
||||
|
||||
func test_chosen_theme_is_saved() -> void:
|
||||
await _pick("Original web")
|
||||
|
||||
var saved: ConfigFile = ConfigFile.new()
|
||||
assert_int(saved.load(Settings.saved_settings_path())).is_equal(OK)
|
||||
assert_str(saved.get_value("app", "theme_id")).is_equal("original_web")
|
||||
|
||||
|
||||
func test_backdrop_and_graph_follow_the_theme() -> void:
|
||||
var backdrop: PopupBackdrop = _window.get_node("PopupBackdrop")
|
||||
var classic: Color = backdrop.color
|
||||
|
||||
await _pick("Original web")
|
||||
|
||||
assert_object(backdrop.color).is_equal(backdrop.get_theme_color(&"backdrop", &"Palette"))
|
||||
assert_bool(backdrop.color != classic).is_true()
|
||||
|
||||
|
||||
func test_unknown_theme_falls_back_to_the_default() -> void:
|
||||
Settings.apply_theme("no_such_theme")
|
||||
|
||||
assert_str(Settings.theme_id).is_equal("classic")
|
||||
assert_str(_window.get_tree().root.theme.resource_path) \
|
||||
.is_equal("res://themes/main_theme.tres")
|
||||
Reference in new issue
Block a user