diff --git a/data/settings.gd b/data/settings.gd index 35536c4..89391b1 100644 --- a/data/settings.gd +++ b/data/settings.gd @@ -26,6 +26,7 @@ const SAVED_SETTINGS: Dictionary[String, Array] = { &"inspiration_list_speed", ], "window": [&"fullscreen"], + "app": [&"last_seen_version"], } ## When this environment variable is set, the settings files are kept in that folder ## instead of the user's config folder. The tests set it so they never touch the real files. @@ -83,6 +84,9 @@ var character_select_open: bool = false ## [code]MusicServerClient[/code]. Saved in the [code][queues][/code] section of ## [method saved_settings_path], so the game goes on with the same queue after a restart. var queue_ids: Dictionary[String, String] = {} +## The version the game last showed the About popup for. When it is not [member version], +## this version is new and the main window opens the About popup to show what is new. +var last_seen_version: String = "" ## The game version, set in Project Settings > Application > Config > Version. ## Releases are made from it, see RELEASING.md. diff --git a/main/main_window.gd b/main/main_window.gd index 0ea17aa..6dde8b4 100644 --- a/main/main_window.gd +++ b/main/main_window.gd @@ -43,6 +43,16 @@ func _ready() -> void: statistics_view.soundtrack_selected.connect(soundtrack_stats_popup.show_soundtrack) search_popup.get_list_of_soundtracks() + show_about_if_new_version() + + +## Opens the About popup, with what is new, the first time this version starts. +func show_about_if_new_version() -> void: + if Settings.last_seen_version == Settings.version: + return + Settings.last_seen_version = Settings.version + Settings.save_settings() + show_about() func _input(event: InputEvent) -> void: diff --git a/tests/fakes/main_window_test_suite.gd b/tests/fakes/main_window_test_suite.gd index d13445f..ef3eb77 100644 --- a/tests/fakes/main_window_test_suite.gd +++ b/tests/fakes/main_window_test_suite.gd @@ -24,6 +24,8 @@ func before_test() -> void: Settings.hide_next_track = true Settings.use_low_played_mode = false Settings.winning_score = 20 + # Otherwise the About popup opens at start, as for a new version + Settings.last_seen_version = Settings.version _server = FakeHttpTransport.new().install() var mp3: PackedByteArray = FileAccess.get_file_as_bytes("res://tests/data/short.mp3") diff --git a/tests/fakes/ui_tour.gd b/tests/fakes/ui_tour.gd index 9cfc3a0..d52c7b0 100644 --- a/tests/fakes/ui_tour.gd +++ b/tests/fakes/ui_tour.gd @@ -170,6 +170,7 @@ static func prepare_autoloads() -> void: Settings.hide_next_track = true Settings.use_low_played_mode = false Settings.winning_score = 20 + Settings.last_seen_version = Settings.version # The inspiration list scrolls by itself, which would make every picture different Settings.inspiration_list_speed = 0 diff --git a/tests/integration/test_about_on_new_version.gd b/tests/integration/test_about_on_new_version.gd new file mode 100644 index 0000000..fe8c344 --- /dev/null +++ b/tests/integration/test_about_on_new_version.gd @@ -0,0 +1,58 @@ +extends MainWindowTestSuite +## The About popup opens by itself the first time a new version starts, to show what is +## new. + +var _last_seen_before_start: String = "1.0.0" + + +func _before_window_starts() -> void: + Settings.last_seen_version = _last_seen_before_start + + +func _about() -> AboutPopup: + return _window.get_node("%AboutPopup") + + +func test_new_version_opens_about_at_start() -> void: + assert_bool(_about().visible).is_true() + + +func test_new_version_is_remembered_and_saved() -> void: + assert_str(Settings.last_seen_version).is_equal(Settings.version) + var saved: ConfigFile = ConfigFile.new() + assert_int(saved.load(Settings.saved_settings_path())).is_equal(OK) + assert_str(saved.get_value("app", "last_seen_version")).is_equal(Settings.version) + + +func test_about_opens_only_once_per_version() -> void: + _about().close() + + _window.show_about_if_new_version() + + assert_bool(_about().visible).is_false() + + +func test_about_can_be_closed_like_any_popup() -> void: + await _click_at(Vector2(5, 1075)) + + assert_bool(_about().visible).is_false() + + +@warning_ignore("unused_parameter") +func test_first_start_opens_about_too( + last_seen: String, test_parameters: Array = [[""], ["0.1.0"]]) -> void: + _about().close() + Settings.last_seen_version = last_seen + + _window.show_about_if_new_version() + + assert_bool(_about().visible).is_true() + + +func test_same_version_does_not_open_about() -> void: + _about().close() + Settings.last_seen_version = Settings.version + + _window.show_about_if_new_version() + + assert_bool(_about().visible).is_false() diff --git a/tests/integration/test_about_on_new_version.gd.uid b/tests/integration/test_about_on_new_version.gd.uid new file mode 100644 index 0000000..686731c --- /dev/null +++ b/tests/integration/test_about_on_new_version.gd.uid @@ -0,0 +1 @@ +uid://davke6pxkvvw3 diff --git a/tests/unit/test_settings_files.gd b/tests/unit/test_settings_files.gd index 2f253d9..ff32131 100644 --- a/tests/unit/test_settings_files.gd +++ b/tests/unit/test_settings_files.gd @@ -6,7 +6,7 @@ const SAVED_VALUES: Dictionary = { &"auto_repeat_song": false, &"stop_after_current": false, &"hide_next_track": false, &"hide_beginning": true, &"hide_for_seconds": 7.0, &"hide_length": true, &"hide_ticks": true, &"winning_score": 13, &"inspiration_list_speed": 4, - &"fullscreen": true, + &"fullscreen": true, &"last_seen_version": "1.2.3", } var _snapshot: AutoloadSnapshot