diff --git a/main/MainWindow.tscn b/main/MainWindow.tscn index 2db5143..a4c9fd4 100644 --- a/main/MainWindow.tscn +++ b/main/MainWindow.tscn @@ -78,9 +78,9 @@ offset_bottom = 860.0 unique_name_in_owner = true visible = false layout_mode = 1 -offset_left = 720.0 +offset_left = 360.0 offset_top = 153.0 -offset_right = 720.0 +offset_right = 360.0 offset_bottom = 153.0 [node name="LogPopup" parent="." unique_id=1289881388 instance=ExtResource("14_26rwn")] diff --git a/popups/AboutPopup.tscn b/popups/AboutPopup.tscn index d410293..c705847 100644 --- a/popups/AboutPopup.tscn +++ b/popups/AboutPopup.tscn @@ -15,45 +15,87 @@ panel = NodePath("AboutPanel") [node name="AboutPanel" type="Panel" parent="." unique_id=1907299275] unique_name_in_owner = true layout_mode = 0 -offset_right = 600.0 +offset_right = 1200.0 offset_bottom = 640.0 theme_type_variation = &"PopupBackground" [node name="TitleLabel" type="Label" parent="AboutPanel" unique_id=200295721] layout_mode = 0 -offset_right = 600.0 +offset_right = 1200.0 offset_bottom = 50.0 text = "About" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ScrollContainer" type="ScrollContainer" parent="AboutPanel" unique_id=417677913] +[node name="DescriptionLabel" type="Label" parent="AboutPanel" unique_id=543094263] layout_mode = 0 offset_left = 20.0 offset_top = 50.0 -offset_right = 580.0 -offset_bottom = 630.0 -horizontal_scroll_mode = 0 - -[node name="ContentVBox" type="VBoxContainer" parent="AboutPanel/ScrollContainer" unique_id=1746337912] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="VersionLabel" type="Label" parent="AboutPanel/ScrollContainer/ContentVBox" unique_id=352884126] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -horizontal_alignment = 1 - -[node name="DescriptionLabel" type="Label" parent="AboutPanel/ScrollContainer/ContentVBox" unique_id=543094263] -layout_mode = 2 -size_flags_horizontal = 3 +offset_right = 1180.0 +offset_bottom = 80.0 text = "Try your video game music knowledge with this VGM randomizer, invite your friends and see who is the best." horizontal_alignment = 1 autowrap_mode = 2 -[node name="WhatsNewLabel" type="Label" parent="AboutPanel/ScrollContainer/ContentVBox" unique_id=1363040291] +[node name="Columns" type="HBoxContainer" parent="AboutPanel" unique_id=200295722] +layout_mode = 0 +offset_left = 20.0 +offset_top = 96.0 +offset_right = 1180.0 +offset_bottom = 630.0 +theme_override_constants/separation = 40 + +[node name="ScrollContainer" type="ScrollContainer" parent="AboutPanel/Columns" unique_id=417677913] +layout_mode = 2 +size_flags_horizontal = 3 +horizontal_scroll_mode = 0 + +[node name="ContentVBox" type="VBoxContainer" parent="AboutPanel/Columns/ScrollContainer" unique_id=1746337912] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="PlayerHeader" type="Label" parent="AboutPanel/Columns/ScrollContainer/ContentVBox" unique_id=1746337913] +layout_mode = 2 +theme_type_variation = &"HighlightLarge" +text = "Music Player" +horizontal_alignment = 1 + +[node name="VersionLabel" type="Label" parent="AboutPanel/Columns/ScrollContainer/ContentVBox" unique_id=352884126] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +horizontal_alignment = 1 + +[node name="WhatsNewLabel" type="Label" parent="AboutPanel/Columns/ScrollContainer/ContentVBox" unique_id=1363040291] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +autowrap_mode = 2 + +[node name="ServerScrollContainer" type="ScrollContainer" parent="AboutPanel/Columns" unique_id=417677914] +layout_mode = 2 +size_flags_horizontal = 3 +horizontal_scroll_mode = 0 + +[node name="ServerContentVBox" type="VBoxContainer" parent="AboutPanel/Columns/ServerScrollContainer" unique_id=1746337914] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="ServerHeader" type="Label" parent="AboutPanel/Columns/ServerScrollContainer/ServerContentVBox" unique_id=1746337915] +layout_mode = 2 +theme_type_variation = &"HighlightLarge" +text = "Music Server" +horizontal_alignment = 1 + +[node name="ServerVersionLabel" type="Label" parent="AboutPanel/Columns/ServerScrollContainer/ServerContentVBox" unique_id=352884127] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +horizontal_alignment = 1 + +[node name="ServerHistoryLabel" type="Label" parent="AboutPanel/Columns/ServerScrollContainer/ServerContentVBox" unique_id=1363040292] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 diff --git a/popups/about_popup.gd b/popups/about_popup.gd index d6ee581..93258ad 100644 --- a/popups/about_popup.gd +++ b/popups/about_popup.gd @@ -1,6 +1,7 @@ class_name AboutPopup extends BasePopup -## Shows the game version and what is new in each version. +## Shows the game's and the server's version, and what is new in each of their versions, +## side by side. ## What is new in each version, newest first. const WHATS_NEW: Dictionary = { @@ -57,16 +58,42 @@ const WHATS_NEW: Dictionary = { @onready var about_panel: Panel = %AboutPanel @onready var version_label: Label = %VersionLabel @onready var whats_new_label: Label = %WhatsNewLabel +@onready var server_version_label: Label = %ServerVersionLabel +@onready var server_history_label: Label = %ServerHistoryLabel func open() -> void: super() version_label.text = Settings.version - - # Build changelog text with version headers - var changelog_text: String = "" + var entries: Array = [] for version: String in WHATS_NEW.keys(): - changelog_text += "\n" + version + "\n" - changelog_text += WHATS_NEW[version] + "\n" + entries.append([version, [WHATS_NEW[version]]]) + whats_new_label.text = changelog_text(entries) - whats_new_label.text = changelog_text + # Asked every time, as another server can be picked in the settings + server_version_label.text = "Loading…" + server_history_label.text = "" + MusicServerClient.fetch_version_history(_show_server_history, _show_server_history_failed) + + +## The changelog text for [param entries], each a [code][version, lines][/code] pair, newest +## first: every version on its own line, followed by its lines, with an empty line +## between versions. +static func changelog_text(entries: Array) -> String: + var versions: PackedStringArray = [] + for entry: Array in entries: + versions.append(entry[0] + "\n" + "\n".join(entry[1])) + return "\n\n".join(versions) + + +func _show_server_history(history: Array[VersionData]) -> void: + server_version_label.text = history[0].version if !history.is_empty() else "" + var entries: Array = [] + for version: VersionData in history: + entries.append([version.version, version.changelog]) + server_history_label.text = changelog_text(entries) + + +func _show_server_history_failed() -> void: + server_version_label.text = "Could not reach the server" + server_history_label.text = "" diff --git a/tests/data/layout_baseline.json b/tests/data/layout_baseline.json index b4ed50f..9e5be95 100644 --- a/tests/data/layout_baseline.json +++ b/tests/data/layout_baseline.json @@ -11,7 +11,7 @@ }, "AboutPopup": { "rect": [ - 720.0, + 360.0, 153.0, 1920.0, 1080.0 @@ -20,63 +20,126 @@ }, "AboutPopup/AboutPanel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 640.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer": { + "AboutPopup/AboutPanel/Columns": { "rect": [ - 740.0, - 203.0, - 560.0, - 580.0 + 380.0, + 249.0, + 1160.0, + 534.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox": { + "AboutPopup/AboutPanel/Columns/ScrollContainer": { "rect": [ - 740.0, - 203.0, - 1.0, - 545.0 + 380.0, + 249.0, + 130.0, + 0.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/DescriptionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox": { "rect": [ - 740.0, - 203.0, - 1.0, - 491.0 + 380.0, + 249.0, + 122.0, + 82.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/VersionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/PlayerHeader": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, + 122.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/VersionLabel": { + "rect": [ + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/WhatsNewLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/WhatsNewLabel": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer": { + "rect": [ + 380.0, + 249.0, + 132.0, + 0.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox": { + "rect": [ + 380.0, + 249.0, + 124.0, + 82.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHeader": { + "rect": [ + 380.0, + 249.0, + 124.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHistoryLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerVersionLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/DescriptionLabel": { + "rect": [ + 380.0, + 203.0, + 1160.0, + 30.0 + ], + "visible": false + }, "AboutPopup/AboutPanel/TitleLabel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 50.0 ], "visible": false @@ -3370,7 +3433,7 @@ }, "AboutPopup": { "rect": [ - 720.0, + 360.0, 153.0, 1920.0, 1080.0 @@ -3379,63 +3442,126 @@ }, "AboutPopup/AboutPanel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 640.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer": { + "AboutPopup/AboutPanel/Columns": { "rect": [ - 740.0, - 203.0, - 560.0, - 580.0 + 380.0, + 249.0, + 1160.0, + 534.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox": { + "AboutPopup/AboutPanel/Columns/ScrollContainer": { "rect": [ - 740.0, - 203.0, - 1.0, - 545.0 + 380.0, + 249.0, + 130.0, + 0.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/DescriptionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox": { "rect": [ - 740.0, - 203.0, - 1.0, - 491.0 + 380.0, + 249.0, + 122.0, + 82.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/VersionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/PlayerHeader": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, + 122.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/VersionLabel": { + "rect": [ + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/WhatsNewLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/WhatsNewLabel": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer": { + "rect": [ + 380.0, + 249.0, + 132.0, + 0.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox": { + "rect": [ + 380.0, + 249.0, + 124.0, + 82.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHeader": { + "rect": [ + 380.0, + 249.0, + 124.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHistoryLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerVersionLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/DescriptionLabel": { + "rect": [ + 380.0, + 203.0, + 1160.0, + 30.0 + ], + "visible": false + }, "AboutPopup/AboutPanel/TitleLabel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 50.0 ], "visible": false @@ -6945,7 +7071,7 @@ }, "AboutPopup": { "rect": [ - 720.0, + 360.0, 153.0, 1920.0, 1080.0 @@ -6954,63 +7080,126 @@ }, "AboutPopup/AboutPanel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 640.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer": { + "AboutPopup/AboutPanel/Columns": { "rect": [ - 740.0, - 203.0, - 560.0, - 580.0 + 380.0, + 249.0, + 1160.0, + 534.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox": { + "AboutPopup/AboutPanel/Columns/ScrollContainer": { "rect": [ - 740.0, - 203.0, - 1.0, - 545.0 + 380.0, + 249.0, + 130.0, + 0.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/DescriptionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox": { "rect": [ - 740.0, - 203.0, - 1.0, - 491.0 + 380.0, + 249.0, + 122.0, + 82.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/VersionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/PlayerHeader": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, + 122.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/VersionLabel": { + "rect": [ + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/WhatsNewLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/WhatsNewLabel": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer": { + "rect": [ + 380.0, + 249.0, + 132.0, + 0.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox": { + "rect": [ + 380.0, + 249.0, + 124.0, + 82.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHeader": { + "rect": [ + 380.0, + 249.0, + 124.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHistoryLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerVersionLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/DescriptionLabel": { + "rect": [ + 380.0, + 203.0, + 1160.0, + 30.0 + ], + "visible": false + }, "AboutPopup/AboutPanel/TitleLabel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 50.0 ], "visible": false @@ -10601,7 +10790,7 @@ "popup_AboutWindow": { "AboutPopup": { "rect": [ - 720.0, + 360.0, 153.0, 1920.0, 1080.0 @@ -10610,63 +10799,126 @@ }, "AboutPopup/AboutPanel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 640.0 ], "visible": true }, - "AboutPopup/AboutPanel/ScrollContainer": { + "AboutPopup/AboutPanel/Columns": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, + 1160.0, + 534.0 + ], + "visible": true + }, + "AboutPopup/AboutPanel/Columns/ScrollContainer": { + "rect": [ + 380.0, + 249.0, 560.0, - 580.0 + 534.0 ], "visible": true }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, 552.0, - 2105.0 + 2032.0 ], "visible": true }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/DescriptionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/PlayerHeader": { "rect": [ - 740.0, - 230.0, + 380.0, + 249.0, 552.0, - 49.0 + 28.0 ], "visible": true }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/VersionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/VersionLabel": { "rect": [ - 740.0, - 203.0, + 380.0, + 281.0, 552.0, 23.0 ], "visible": true }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/WhatsNewLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/WhatsNewLabel": { "rect": [ - 740.0, - 283.0, + 380.0, + 308.0, 552.0, - 2025.0 + 1973.0 + ], + "visible": true + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer": { + "rect": [ + 980.0, + 249.0, + 560.0, + 534.0 + ], + "visible": true + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox": { + "rect": [ + 980.0, + 249.0, + 560.0, + 534.0 + ], + "visible": true + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHeader": { + "rect": [ + 980.0, + 249.0, + 560.0, + 28.0 + ], + "visible": true + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHistoryLabel": { + "rect": [ + 980.0, + 308.0, + 560.0, + 309.0 + ], + "visible": true + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerVersionLabel": { + "rect": [ + 980.0, + 281.0, + 560.0, + 23.0 + ], + "visible": true + }, + "AboutPopup/AboutPanel/DescriptionLabel": { + "rect": [ + 380.0, + 203.0, + 1160.0, + 30.0 ], "visible": true }, "AboutPopup/AboutPanel/TitleLabel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 50.0 ], "visible": true @@ -13710,7 +13962,7 @@ }, "AboutPopup": { "rect": [ - 720.0, + 360.0, 153.0, 1920.0, 1080.0 @@ -13719,63 +13971,126 @@ }, "AboutPopup/AboutPanel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 640.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer": { + "AboutPopup/AboutPanel/Columns": { "rect": [ - 740.0, - 203.0, - 560.0, - 580.0 + 380.0, + 249.0, + 1160.0, + 534.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox": { + "AboutPopup/AboutPanel/Columns/ScrollContainer": { "rect": [ - 740.0, - 203.0, - 1.0, - 545.0 + 380.0, + 249.0, + 130.0, + 0.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/DescriptionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox": { "rect": [ - 740.0, - 203.0, - 1.0, - 491.0 + 380.0, + 249.0, + 122.0, + 82.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/VersionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/PlayerHeader": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, + 122.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/VersionLabel": { + "rect": [ + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/WhatsNewLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/WhatsNewLabel": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, 1.0, 23.0 ], "visible": false }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer": { + "rect": [ + 380.0, + 249.0, + 132.0, + 0.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox": { + "rect": [ + 380.0, + 249.0, + 124.0, + 82.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHeader": { + "rect": [ + 380.0, + 249.0, + 124.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHistoryLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerVersionLabel": { + "rect": [ + 380.0, + 249.0, + 1.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/DescriptionLabel": { + "rect": [ + 380.0, + 203.0, + 1160.0, + 30.0 + ], + "visible": false + }, "AboutPopup/AboutPanel/TitleLabel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 50.0 ], "visible": false @@ -21206,7 +21521,7 @@ }, "AboutPopup": { "rect": [ - 720.0, + 360.0, 153.0, 1920.0, 1080.0 @@ -21215,63 +21530,126 @@ }, "AboutPopup/AboutPanel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 640.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer": { + "AboutPopup/AboutPanel/Columns": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, + 1160.0, + 534.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ScrollContainer": { + "rect": [ + 380.0, + 249.0, 560.0, - 580.0 + 534.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox": { "rect": [ - 740.0, - 203.0, + 380.0, + 249.0, 552.0, - 2105.0 + 2032.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/DescriptionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/PlayerHeader": { "rect": [ - 740.0, - 230.0, + 380.0, + 249.0, 552.0, - 49.0 + 28.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/VersionLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/VersionLabel": { "rect": [ - 740.0, - 203.0, + 380.0, + 281.0, 552.0, 23.0 ], "visible": false }, - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox/WhatsNewLabel": { + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox/WhatsNewLabel": { "rect": [ - 740.0, - 283.0, + 380.0, + 308.0, 552.0, - 2025.0 + 1973.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer": { + "rect": [ + 980.0, + 249.0, + 560.0, + 534.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox": { + "rect": [ + 980.0, + 249.0, + 560.0, + 534.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHeader": { + "rect": [ + 980.0, + 249.0, + 560.0, + 28.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerHistoryLabel": { + "rect": [ + 980.0, + 308.0, + 560.0, + 309.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox/ServerVersionLabel": { + "rect": [ + 980.0, + 281.0, + 560.0, + 23.0 + ], + "visible": false + }, + "AboutPopup/AboutPanel/DescriptionLabel": { + "rect": [ + 380.0, + 203.0, + 1160.0, + 30.0 ], "visible": false }, "AboutPopup/AboutPanel/TitleLabel": { "rect": [ - 720.0, + 360.0, 153.0, - 600.0, + 1200.0, 50.0 ], "visible": false diff --git a/tests/fakes/ui_tour.gd b/tests/fakes/ui_tour.gd index b7e61eb..38d2daf 100644 --- a/tests/fakes/ui_tour.gd +++ b/tests/fakes/ui_tour.gd @@ -28,6 +28,19 @@ const SYNC_RESULT: Dictionary = { "total_time": "00:00:03", } +## The server's version history, newest first. +const SERVER_HISTORY: Array[Dictionary] = [ + {"version": "5.0.0", "changelog": [ + "#9 - Major routes refactor and expansion", "#15 - Added API for statistics", + "Token authentication for /api/v1", + ]}, + {"version": "4.5.0", "changelog": [ + "#1 - Created request to check newest version of the app", + "#2 - Added request to download the newest version of the app", + ]}, + {"version": "4.0.0", "changelog": ["Changed framework from gin to Echo", "Reorganized the code"]}, +] + ## Song names of the first soundtrack in the statistics, to show Japanese text. const JAPANESE_SONGS: Array[String] = [ "時の回廊", "カエルのテーマ", "風の憧憬", "魔王決戦", "遥かなる時の彼方へ", @@ -76,6 +89,7 @@ static func make_server() -> FakeHttpTransport: server.respond_bytes("/sync", PackedByteArray()) server.respond_json("/sync/progress", SYNC_PROGRESS) server.respond_json("/statistics/soundtracks", soundtrack_statistics()) + server.respond_json("/version/history", SERVER_HISTORY) return server diff --git a/tests/integration/test_about_popup.gd b/tests/integration/test_about_popup.gd new file mode 100644 index 0000000..00b2ec7 --- /dev/null +++ b/tests/integration/test_about_popup.gd @@ -0,0 +1,102 @@ +extends MainWindowTestSuite +## The About popup: the game's version history next to the server's. + +const HISTORY: Array[Dictionary] = [ + {"version": "5.0.0", "changelog": ["Statistics for every soundtrack", "Tokens"]}, + {"version": "4.5.0", "changelog": ["Download the newest player"]}, +] + +var _popup: AboutPopup + + +func _before_window_starts() -> void: + _server.respond_json("/version/history", HISTORY) + + +func before_test() -> void: + super() + _popup = _window.get_node("AboutPopup") + + +func _open_with_top_bar_button() -> void: + await _click_at((_window.get_node("TopBar/AboutButton") as Control).get_global_rect() + .get_center()) + + +func test_about_button_opens_the_popup_and_clicking_outside_closes_it() -> void: + await _open_with_top_bar_button() + assert_bool(_popup.visible).is_true() + + await _click_at(Vector2(100, 1000)) + + assert_bool(_popup.visible).is_false() + + +func test_shows_the_server_versions_in_the_servers_order() -> void: + await _open_with_top_bar_button() + + assert_int(_server.count("/version/history")).is_equal(1) + assert_str(_popup.server_version_label.text).is_equal("5.0.0") + assert_str(_popup.server_history_label.text).is_equal( + "5.0.0\nStatistics for every soundtrack\nTokens\n\n4.5.0\nDownload the newest player") + + +func test_still_shows_the_games_own_versions() -> void: + await _open_with_top_bar_button() + + assert_str(_popup.version_label.text).is_equal(Settings.version) + var lines: PackedStringArray = _popup.whats_new_label.text.split("\n") + for version: String in AboutPopup.WHATS_NEW: + assert_bool(lines.has(version)).override_failure_message(version + " is missing") \ + .is_true() + assert_str(_popup.whats_new_label.text).starts_with(AboutPopup.WHATS_NEW.keys()[0] + "\n") + + +func test_columns_sit_side_by_side_in_the_window() -> void: + await _open_with_top_bar_button() + + var game: Rect2 = _popup.find_child("PlayerHeader").get_global_rect() + var server: Rect2 = _popup.find_child("ServerHeader").get_global_rect() + assert_float(server.position.x).is_greater(game.end.x) + assert_float(server.position.y).is_equal(game.position.y) + assert_bool(Rect2(Vector2.ZERO, Vector2(1920, 1080)).encloses( + _popup.about_panel.get_global_rect())).is_true() + + +func test_server_error_says_so() -> void: + _server.respond_json("/version/history", {"error": "Internal Server Error"}, 500) + + await _open_with_top_bar_button() + + assert_str(_popup.server_version_label.text).is_equal("Could not reach the server") + assert_str(_popup.server_history_label.text).is_empty() + + +func test_shows_loading_until_the_server_answers() -> void: + _server.hold("/version/history") + + await _open_with_top_bar_button() + + assert_str(_popup.server_version_label.text).is_equal("Loading…") + _server.release("/version/history") + assert_str(_popup.server_version_label.text).is_equal("5.0.0") + + +func test_opening_again_asks_the_server_again() -> void: + _popup.open() + _popup.close() + _popup.open() + + assert_int(_server.count("/version/history")).is_equal(2) + + +func test_description_is_centred_above_both_columns() -> void: + await _open_with_top_bar_button() + + var description: Label = _popup.find_child("DescriptionLabel") + assert_object(description.get_parent()).is_same(_popup.about_panel) + assert_int(description.horizontal_alignment).is_equal(HORIZONTAL_ALIGNMENT_CENTER) + assert_float(description.get_global_rect().end.y) \ + .is_less_equal(_popup.find_child("PlayerHeader").get_global_rect().position.y) + assert_float(description.get_global_rect().get_center().x) \ + .is_equal_approx(_popup.about_panel.get_global_rect().get_center().x, 1.0) diff --git a/tests/integration/test_about_popup.gd.uid b/tests/integration/test_about_popup.gd.uid new file mode 100644 index 0000000..4dc8354 --- /dev/null +++ b/tests/integration/test_about_popup.gd.uid @@ -0,0 +1 @@ +uid://blyg83doq82wl diff --git a/tests/integration/test_layout_unchanged.gd b/tests/integration/test_layout_unchanged.gd index 635419b..49ee984 100644 --- a/tests/integration/test_layout_unchanged.gd +++ b/tests/integration/test_layout_unchanged.gd @@ -12,7 +12,8 @@ const BASELINE_PATH: String = "res://tests/data/layout_baseline.json" ## Nodes whose height follows text that changes between versions, such as the changelog. ## Their position and width are still checked. const HEIGHT_FOLLOWS_TEXT: Array[String] = [ - "AboutPopup/AboutPanel/ScrollContainer/ContentVBox", + "AboutPopup/AboutPanel/Columns/ScrollContainer/ContentVBox", + "AboutPopup/AboutPanel/Columns/ServerScrollContainer/ServerContentVBox", ] ## How far a node may be from its old place, in pixels.