diff options
author | George L. Albany <Megacake1234@gmail.com> | 2023-05-18 02:43:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-18 02:43:51 +0200 |
commit | 5b679386eb2241216402468a06469b31c263e300 (patch) | |
tree | 6e4a7424c75565ee938457b7a3f36e99e8d40cfd /game/src | |
parent | 6c7a1a7c8f55d92882d9364c0ad36a61a3f5614f (diff) | |
parent | 56675b0401573f799271eff4716cd6788c98ce7b (diff) |
Merge pull request #113 from Nemrav/keep-video-settings-dialog
Diffstat (limited to 'game/src')
-rw-r--r-- | game/src/GameSession/GameSession.tscn | 34 | ||||
-rw-r--r-- | game/src/OptionMenu/ResolutionSelector.gd | 30 | ||||
-rw-r--r-- | game/src/OptionMenu/VideoTab.tscn | 19 |
3 files changed, 67 insertions, 16 deletions
diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn index 996891a..188ccde 100644 --- a/game/src/GameSession/GameSession.tscn +++ b/game/src/GameSession/GameSession.tscn @@ -8,7 +8,7 @@ [ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn" id="5_osjnn"] [ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"] [ext_resource type="PackedScene" uid="uid://dd8k3p7r3huwc" path="res://src/GameSession/GameSpeedPanel.tscn" id="7_myy4q"] -[ext_resource type="PackedScene" uid="uid://dayy28gn8kq34" path="res://src/SaveLoadMenu/SaveLoadMenu.tscn" id="8_4g7ko"] +[ext_resource type="PackedScene" uid="uid://d3g6wbvwflmyk" path="res://src/SaveLoadMenu/SaveLoadMenu.tscn" id="8_4g7ko"] [node name="GameSession" type="Control" node_paths=PackedStringArray("_game_session_menu")] editor_description = "SS-102, UI-546" @@ -24,17 +24,6 @@ _game_session_menu = NodePath("GameSessionMenu") [node name="MapView" parent="." instance=ExtResource("4_xkg5j")] -[node name="GameSessionMenu" parent="." instance=ExtResource("3_bvmqh")] -visible = false -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -grow_horizontal = 2 -grow_vertical = 2 - [node name="MapControlPanel" parent="." instance=ExtResource("3_afh6d")] layout_mode = 1 anchors_preset = 3 @@ -53,6 +42,21 @@ layout_mode = 0 offset_right = 302.0 offset_bottom = 31.0 +[node name="GameSessionMenu" parent="." instance=ExtResource("3_bvmqh")] +visible = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -159.0 +offset_top = -165.0 +offset_right = 159.0 +offset_bottom = 165.0 +grow_horizontal = 2 +grow_vertical = 2 + [node name="OptionsMenu" parent="." instance=ExtResource("6_p5mnx")] visible = false layout_mode = 1 @@ -76,9 +80,6 @@ offset_right = 0.0 grow_horizontal = 0 [connection signal="map_view_camera_changed" from="MapView" to="MapControlPanel" method="_on_map_view_camera_changed"] -[connection signal="load_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_load"] -[connection signal="options_button_pressed" from="GameSessionMenu" to="OptionsMenu" method="show"] -[connection signal="save_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_save"] [connection signal="game_session_menu_button_pressed" from="MapControlPanel" to="." method="_on_game_session_menu_button_pressed"] [connection signal="minimap_clicked" from="MapControlPanel" to="MapView" method="_on_minimap_clicked"] [connection signal="mouse_entered" from="MapControlPanel" to="MapView" method="_on_mouse_exited_viewport"] @@ -87,5 +88,8 @@ grow_horizontal = 0 [connection signal="zoom_out_button_pressed" from="MapControlPanel" to="MapView" method="zoom_out"] [connection signal="mouse_entered" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_exited_viewport"] [connection signal="mouse_exited" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_entered_viewport"] +[connection signal="load_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_load"] +[connection signal="options_button_pressed" from="GameSessionMenu" to="OptionsMenu" method="show"] +[connection signal="save_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_save"] [connection signal="back_button_pressed" from="OptionsMenu" to="MapView" method="enable_processing"] [connection signal="back_button_pressed" from="OptionsMenu" to="OptionsMenu" method="hide"] diff --git a/game/src/OptionMenu/ResolutionSelector.gd b/game/src/OptionMenu/ResolutionSelector.gd index 2fdcba2..fee6e31 100644 --- a/game/src/OptionMenu/ResolutionSelector.gd +++ b/game/src/OptionMenu/ResolutionSelector.gd @@ -3,10 +3,16 @@ extends SettingOptionButton # REQUIREMENTS # * UIFUN-21 # * UIFUN-28 +# * UIFUN-301 +# * UIFUN-302 @export var default_value : Vector2i = Resolution.error_resolution +var previous_resolution : Vector2i = Resolution.error_resolution +@export var revert_dialog : ConfirmationDialog +@export var timer : Timer + func _find_resolution_index_by_value(value : Vector2i) -> int: for item_index in item_count: if get_item_metadata(item_index) == value: @@ -63,7 +69,31 @@ func _set_value_from_file(load_value): func _on_item_selected(index : int): if _valid_index(index): + previous_resolution = Resolution.get_current_resolution() Resolution.set_resolution(get_item_metadata(index)) + var new_resolution = get_item_metadata(index) + + #has_focus() indicates the user is calling _on_item_selected, not some other function + if has_focus() and previous_resolution != new_resolution: + print("Start Revert Countdown!") + start_revert_countdown() else: push_error("Invalid ResolutionSelector index: %d" % index) reset_setting() + +func _process(_delta): + revert_dialog.dialog_text = tr("OPTIONS_VIDEO_RESOLUTION_DIALOG_TEXT").format({"time":round(timer.time_left)}) + +func start_revert_countdown() -> void: + timer.start() + revert_dialog.popup_centered(Vector2(1,1)) + +func _on_confirmed() -> void: + timer.stop() + +func _cancel_changes() -> void: + Resolution.set_resolution(previous_resolution) + _sync_resolutions() + print("Resolution reset to (%dx%d)" % [previous_resolution.x,previous_resolution.y]) + timer.stop() + revert_dialog.hide() diff --git a/game/src/OptionMenu/VideoTab.tscn b/game/src/OptionMenu/VideoTab.tscn index 7c9e2ad..0802eb9 100644 --- a/game/src/OptionMenu/VideoTab.tscn +++ b/game/src/OptionMenu/VideoTab.tscn @@ -31,7 +31,7 @@ columns = 2 layout_mode = 2 text = "OPTIONS_VIDEO_RESOLUTION" -[node name="ResolutionSelector" type="OptionButton" parent="VBoxContainer/GridContainer"] +[node name="ResolutionSelector" type="OptionButton" parent="VBoxContainer/GridContainer" node_paths=PackedStringArray("revert_dialog", "timer")] editor_description = "UI-19" layout_mode = 2 focus_neighbor_bottom = NodePath("../ScreenModeSelector") @@ -40,9 +40,23 @@ selected = 0 popup/item_0/text = "MISSING" popup/item_0/id = 0 script = ExtResource("1_i8nro") +revert_dialog = NodePath("ConfirmationDialog") +timer = NodePath("Timer") section_name = "video" setting_name = "resolution" +[node name="ConfirmationDialog" type="ConfirmationDialog" parent="VBoxContainer/GridContainer/ResolutionSelector"] +editor_description = "UI-873" +disable_3d = true +title = "OPTIONS_VIDEO_RESOLUTION_DIALOG_TITLE" +size = Vector2i(730, 100) +ok_button_text = "DIALOG_OK" +cancel_button_text = "DIALOG_CANCEL" + +[node name="Timer" type="Timer" parent="VBoxContainer/GridContainer/ResolutionSelector"] +wait_time = 5.0 +one_shot = true + [node name="GuiScaleLabel" type="Label" parent="VBoxContainer/GridContainer"] layout_mode = 2 text = "OPTIONS_VIDEO_GUI_SCALE" @@ -155,6 +169,9 @@ setting_name = "quality_preset" default_selected = 1 [connection signal="item_selected" from="VBoxContainer/GridContainer/ResolutionSelector" to="VBoxContainer/GridContainer/ResolutionSelector" method="_on_item_selected"] +[connection signal="canceled" from="VBoxContainer/GridContainer/ResolutionSelector/ConfirmationDialog" to="VBoxContainer/GridContainer/ResolutionSelector" method="_cancel_changes"] +[connection signal="confirmed" from="VBoxContainer/GridContainer/ResolutionSelector/ConfirmationDialog" to="VBoxContainer/GridContainer/ResolutionSelector" method="_on_confirmed"] +[connection signal="timeout" from="VBoxContainer/GridContainer/ResolutionSelector/Timer" to="VBoxContainer/GridContainer/ResolutionSelector" method="_cancel_changes"] [connection signal="item_selected" from="VBoxContainer/GridContainer/GuiScaleSelector" to="VBoxContainer/GridContainer/GuiScaleSelector" method="_on_item_selected"] [connection signal="item_selected" from="VBoxContainer/GridContainer/ScreenModeSelector" to="VBoxContainer/GridContainer/ScreenModeSelector" method="_on_item_selected"] [connection signal="item_selected" from="VBoxContainer/GridContainer/MonitorDisplaySelector" to="VBoxContainer/GridContainer/MonitorDisplaySelector" method="_on_item_selected"] |