aboutsummaryrefslogtreecommitdiff
path: root/game/src
diff options
context:
space:
mode:
author ClarkeCode <clarke.john.robert@gmail.com>2023-04-18 03:03:02 +0200
committer ClarkeCode <clarke.john.robert@gmail.com>2023-04-18 20:10:54 +0200
commitc945680d960ccd0fb4a0ef5058ddfdd48e150f2d (patch)
tree5bf6622bd220dc5e48a761365e9d871ffd3e4129 /game/src
parentea077c8a7c78477bd247c7fbd21de13bcf2285e9 (diff)
Added game speed panel to GameSession
Diffstat (limited to 'game/src')
-rw-r--r--game/src/GameSession/GameSession.tscn6
-rw-r--r--game/src/GameSession/GameSpeedPanel.gd33
-rw-r--r--game/src/GameSession/GameSpeedPanel.tscn38
3 files changed, 76 insertions, 1 deletions
diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn
index d23cb6c..864c657 100644
--- a/game/src/GameSession/GameSession.tscn
+++ b/game/src/GameSession/GameSession.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=7 format=3 uid="uid://bgnupcshe1m7r"]
+[gd_scene load_steps=8 format=3 uid="uid://bgnupcshe1m7r"]
[ext_resource type="Script" path="res://src/GameSession/GameSession.gd" id="1_eklvp"]
[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/MapControlPanel.tscn" id="3_afh6d"]
@@ -6,6 +6,7 @@
[ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/GameSession/MapView.tscn" id="4_xkg5j"]
[ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/GameSession/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"]
[node name="GameSession" type="Control" node_paths=PackedStringArray("_game_session_menu")]
editor_description = "SS-102, UI-546"
@@ -49,6 +50,9 @@ layout_mode = 1
visible = false
layout_mode = 1
+[node name="GameSpeedPanel" parent="." instance=ExtResource("7_myy4q")]
+layout_mode = 0
+
[connection signal="map_view_camera_changed" from="MapView" to="MapControlPanel" method="_on_map_view_camera_changed"]
[connection signal="province_selected" from="MapView" to="ProvinceOverviewPanel" method="_on_province_selected"]
[connection signal="options_button_pressed" from="GameSessionMenu" to="OptionsMenu" method="show"]
diff --git a/game/src/GameSession/GameSpeedPanel.gd b/game/src/GameSession/GameSpeedPanel.gd
new file mode 100644
index 0000000..8dc35d7
--- /dev/null
+++ b/game/src/GameSession/GameSpeedPanel.gd
@@ -0,0 +1,33 @@
+extends PanelContainer
+
+#UI-74 UI-75 UI-76 UI-77
+
+@export var _longform_date_button : Button
+@export var _play_pause_display_button : Button
+@export var _decrease_speed_button : Button
+@export var _increase_speed_button : Button
+
+var is_game_paused : bool = true
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ _update_playpause_button()
+
+func _update_playpause_button():
+ _play_pause_display_button.text = "⏸️" if is_game_paused else "▶"
+ print("Game is paused" if is_game_paused else "Game is advancing")
+
+
+func _on_decrease_speed_button_pressed():
+ print("Decrease speed")
+
+func _on_increase_speed_button_pressed():
+ print("Increase speed")
+
+func _on_play_pause_display_button_pressed():
+ is_game_paused = !is_game_paused
+ _update_playpause_button()
+
+func _on_longform_date_label_pressed():
+ is_game_paused = !is_game_paused
+ _update_playpause_button()
diff --git a/game/src/GameSession/GameSpeedPanel.tscn b/game/src/GameSession/GameSpeedPanel.tscn
new file mode 100644
index 0000000..bfb869c
--- /dev/null
+++ b/game/src/GameSession/GameSpeedPanel.tscn
@@ -0,0 +1,38 @@
+[gd_scene load_steps=2 format=3 uid="uid://dd8k3p7r3huwc"]
+
+[ext_resource type="Script" path="res://src/GameSession/GameSpeedPanel.gd" id="1_pfs8t"]
+
+[node name="GameSpeedPanel" type="PanelContainer" node_paths=PackedStringArray("_longform_date_button", "_play_pause_display_button", "_decrease_speed_button", "_increase_speed_button")]
+script = ExtResource("1_pfs8t")
+_longform_date_button = NodePath("HBoxContainer/LongformDateButton")
+_play_pause_display_button = NodePath("HBoxContainer/PlayPauseDisplayButton")
+_decrease_speed_button = NodePath("HBoxContainer/DecreaseSpeedButton")
+_increase_speed_button = NodePath("HBoxContainer/IncreaseSpeedButton")
+
+[node name="HBoxContainer" type="HBoxContainer" parent="."]
+layout_mode = 2
+
+[node name="LongformDateButton" type="Button" parent="HBoxContainer"]
+custom_minimum_size = Vector2(200, 0)
+layout_mode = 2
+text = "LONGFORM DATE"
+
+[node name="PlayPauseDisplayButton" type="Button" parent="HBoxContainer"]
+custom_minimum_size = Vector2(30, 0)
+layout_mode = 2
+text = "⏸"
+
+[node name="DecreaseSpeedButton" type="Button" parent="HBoxContainer"]
+custom_minimum_size = Vector2(30, 0)
+layout_mode = 2
+text = "➖"
+
+[node name="IncreaseSpeedButton" type="Button" parent="HBoxContainer"]
+custom_minimum_size = Vector2(30, 0)
+layout_mode = 2
+text = "➕"
+
+[connection signal="pressed" from="HBoxContainer/LongformDateButton" to="." method="_on_longform_date_label_pressed"]
+[connection signal="pressed" from="HBoxContainer/PlayPauseDisplayButton" to="." method="_on_play_pause_display_button_pressed"]
+[connection signal="pressed" from="HBoxContainer/DecreaseSpeedButton" to="." method="_on_decrease_speed_button_pressed"]
+[connection signal="pressed" from="HBoxContainer/IncreaseSpeedButton" to="." method="_on_increase_speed_button_pressed"]