From c945680d960ccd0fb4a0ef5058ddfdd48e150f2d Mon Sep 17 00:00:00 2001 From: ClarkeCode Date: Mon, 17 Apr 2023 21:03:02 -0400 Subject: Added game speed panel to GameSession --- game/src/GameSession/GameSession.tscn | 6 ++++- game/src/GameSession/GameSpeedPanel.gd | 33 +++++++++++++++++++++++++++ game/src/GameSession/GameSpeedPanel.tscn | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 game/src/GameSession/GameSpeedPanel.gd create mode 100644 game/src/GameSession/GameSpeedPanel.tscn (limited to 'game/src/GameSession') 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"] -- cgit v1.2.3-56-ga3b1 From 18151dc9829701a20d0bc12e83958ddfe9beb039 Mon Sep 17 00:00:00 2001 From: ClarkeCode Date: Mon, 17 Apr 2023 21:08:25 -0400 Subject: Added music player control to GameSession --- game/src/GameSession/GameSession.tscn | 12 +++++++++++- game/src/MusicConductor/MusicPlayer.gd | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'game/src/GameSession') diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn index 864c657..8a8b18c 100644 --- a/game/src/GameSession/GameSession.tscn +++ b/game/src/GameSession/GameSession.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=8 format=3 uid="uid://bgnupcshe1m7r"] +[gd_scene load_steps=9 format=3 uid="uid://bgnupcshe1m7r"] [ext_resource type="Script" path="res://src/GameSession/GameSession.gd" id="1_eklvp"] +[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] [ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/MapControlPanel.tscn" id="3_afh6d"] [ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] [ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/GameSession/MapView.tscn" id="4_xkg5j"] @@ -20,6 +21,15 @@ mouse_filter = 2 script = ExtResource("1_eklvp") _game_session_menu = NodePath("GameSessionMenu") +[node name="MusicPlayer" parent="." instance=ExtResource("2_kt6aa")] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -150.0 +offset_bottom = 110.0 +grow_horizontal = 0 + [node name="MapView" parent="." instance=ExtResource("4_xkg5j")] [node name="GameSessionMenu" parent="." instance=ExtResource("3_bvmqh")] diff --git a/game/src/MusicConductor/MusicPlayer.gd b/game/src/MusicConductor/MusicPlayer.gd index baf8a43..b775b84 100644 --- a/game/src/MusicConductor/MusicPlayer.gd +++ b/game/src/MusicConductor/MusicPlayer.gd @@ -44,6 +44,8 @@ func _on_previous_song_button_pressed(): func _on_option_button_item_selected(index): # UIFUN-92 MusicConductor.start_song_by_index(index) + _update_song_name_visual() + _update_play_pause_button() func _on_progress_slider_drag_started(): -- cgit v1.2.3-56-ga3b1