aboutsummaryrefslogtreecommitdiff
path: root/game/src
diff options
context:
space:
mode:
author Robert Clarke <clarke.john.robert@gmail.com>2023-02-08 11:31:11 +0100
committer Robert Clarke <clarke.john.robert@gmail.com>2023-02-08 11:31:11 +0100
commitf998d1b539f572a87cea81843e8d76ceb6960b8c (patch)
treef72ebd20ff1854ff298270ac3707f3465226520c /game/src
parent2c0ef462ac500d089ea107f2bc00b0905606d070 (diff)
Exploration of UI and rudimentary scene switching.
Diffstat (limited to 'game/src')
-rw-r--r--game/src/MainMenu.gd36
-rw-r--r--game/src/MainMenu.tscn58
-rw-r--r--game/src/OptionsMenu.gd43
-rw-r--r--game/src/OptionsMenu.tscn141
-rw-r--r--game/src/StartNode.gd5
-rw-r--r--game/src/StartNode.tscn6
6 files changed, 278 insertions, 11 deletions
diff --git a/game/src/MainMenu.gd b/game/src/MainMenu.gd
new file mode 100644
index 0000000..a9cdf10
--- /dev/null
+++ b/game/src/MainMenu.gd
@@ -0,0 +1,36 @@
+extends Control
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ print("From GDScript")
+ TestSingleton.hello_singleton()
+ $CenterContainer/VBoxContainer/NewGameButton.grab_focus()
+ pass # Replace with function body.
+
+
+## Called every frame. 'delta' is the elapsed time since the previous frame.
+#func _process(delta):
+# pass
+
+
+func _on_new_game_button_pressed():
+ print("Start a new game!")
+
+
+func _on_continue_button_pressed():
+ print("Continue last game!")
+
+
+func _on_multi_player_button_pressed():
+ print("Have fun with friends!")
+
+
+func _on_options_button_pressed():
+ print("Check out some options!")
+ get_tree().change_scene_to_file("res://src/OptionsMenu.tscn")
+
+
+func _on_exit_button_pressed():
+ print("See you later!")
+ get_tree().quit()
diff --git a/game/src/MainMenu.tscn b/game/src/MainMenu.tscn
new file mode 100644
index 0000000..5a2cb8a
--- /dev/null
+++ b/game/src/MainMenu.tscn
@@ -0,0 +1,58 @@
+[gd_scene load_steps=2 format=3 uid="uid://b4pg2y2ivib8f"]
+
+[ext_resource type="Script" path="res://src/MainMenu.gd" id="1_6akq8"]
+
+[node name="MainMenu" type="Control"]
+layout_mode = 3
+anchors_preset = 0
+offset_right = 1152.0
+offset_bottom = 648.0
+script = ExtResource("1_6akq8")
+
+[node name="Label" type="Label" parent="."]
+layout_mode = 0
+offset_top = 137.0
+offset_right = 1152.0
+offset_bottom = 264.0
+theme_override_font_sizes/font_size = 90
+text = "OpenVic2"
+horizontal_alignment = 1
+
+[node name="CenterContainer" type="CenterContainer" parent="."]
+layout_mode = 0
+offset_top = 268.0
+offset_right = 1152.0
+offset_bottom = 648.0
+
+[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
+layout_mode = 2
+
+[node name="NewGameButton" type="Button" parent="CenterContainer/VBoxContainer" node_paths=PackedStringArray("shortcut_context")]
+layout_mode = 2
+focus_neighbor_top = NodePath("../ExitButton")
+shortcut_context = NodePath("")
+text = "New Game"
+
+[node name="ContinueButton" type="Button" parent="CenterContainer/VBoxContainer"]
+layout_mode = 2
+disabled = true
+text = "Continue"
+
+[node name="MultiPlayerButton" type="Button" parent="CenterContainer/VBoxContainer"]
+layout_mode = 2
+text = "Multi-Player"
+
+[node name="OptionsButton" type="Button" parent="CenterContainer/VBoxContainer"]
+layout_mode = 2
+text = "Options"
+
+[node name="ExitButton" type="Button" parent="CenterContainer/VBoxContainer"]
+layout_mode = 2
+focus_neighbor_bottom = NodePath("../NewGameButton")
+text = "Exit"
+
+[connection signal="pressed" from="CenterContainer/VBoxContainer/NewGameButton" to="." method="_on_new_game_button_pressed"]
+[connection signal="pressed" from="CenterContainer/VBoxContainer/ContinueButton" to="." method="_on_continue_button_pressed"]
+[connection signal="pressed" from="CenterContainer/VBoxContainer/MultiPlayerButton" to="." method="_on_multi_player_button_pressed"]
+[connection signal="pressed" from="CenterContainer/VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"]
+[connection signal="pressed" from="CenterContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"]
diff --git a/game/src/OptionsMenu.gd b/game/src/OptionsMenu.gd
new file mode 100644
index 0000000..adcd3b5
--- /dev/null
+++ b/game/src/OptionsMenu.gd
@@ -0,0 +1,43 @@
+extends Control
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ print("TODO: Load user settings!")
+ pass # Replace with function body.
+
+## Called every frame. 'delta' is the elapsed time since the previous frame.
+#func _process(delta):
+# pass
+
+func _on_resolution_selector_item_selected(index):
+ print("Selected index: %d" % index)
+
+func _on_screen_mode_selector_item_selected(index):
+ print("Selected index: %d" % index)
+
+func _on_monitor_display_selector_item_selected(index):
+ print("Selected index: %d" % index)
+
+func _on_music_volume_value_changed(value):
+ print("Music: %f" % value)
+
+
+func _on_sfx_volume_value_changed(value):
+ print("SFX: %f" % value)
+
+
+func _on_ear_exploder_toggled(button_pressed):
+ print("KABOOM!!!" if button_pressed else "DEFUSED!!!")
+
+
+func _on_save_settings_button_pressed():
+ print("TODO: save current settings!")
+
+
+func _on_back_button_pressed():
+ get_tree().change_scene_to_file("res://src/MainMenu.tscn")
+
+
+func _on_spin_box_value_changed(value):
+ print("Spinbox: %d" % value)
diff --git a/game/src/OptionsMenu.tscn b/game/src/OptionsMenu.tscn
new file mode 100644
index 0000000..495d72c
--- /dev/null
+++ b/game/src/OptionsMenu.tscn
@@ -0,0 +1,141 @@
+[gd_scene load_steps=2 format=3 uid="uid://ch03lp7d7fvw3"]
+
+[ext_resource type="Script" path="res://src/OptionsMenu.gd" id="1_2tajv"]
+
+[node name="OptionsMenu" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_2tajv")
+
+[node name="TabContainer" type="TabContainer" parent="."]
+layout_mode = 0
+offset_right = 1152.0
+offset_bottom = 648.0
+
+[node name="VideoTab" type="TabBar" parent="TabContainer"]
+layout_mode = 2
+tooltip_text = "This is my cool and very nice tooltip"
+
+[node name="GridContainer" type="GridContainer" parent="TabContainer/VideoTab"]
+layout_mode = 0
+offset_right = 40.0
+offset_bottom = 40.0
+columns = 2
+
+[node name="Label2" type="Label" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+text = "Resolution:"
+
+[node name="ResolutionSelector" type="OptionButton" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+item_count = 3
+selected = 0
+popup/item_0/text = "1920x1080"
+popup/item_0/id = 0
+popup/item_1/text = "1366x768"
+popup/item_1/id = 1
+popup/item_2/text = "1280x1024"
+popup/item_2/id = 2
+
+[node name="Label3" type="Label" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+text = "Screen Mode:"
+
+[node name="ScreenModeSelector" type="OptionButton" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+item_count = 3
+selected = 0
+popup/item_0/text = "Borderless"
+popup/item_0/id = 0
+popup/item_1/text = "Windowed"
+popup/item_1/id = 1
+popup/item_2/text = "Fullscreen"
+popup/item_2/id = 2
+
+[node name="Label" type="Label" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+text = "Monitor Selection:"
+
+[node name="MonitorDisplaySelector" type="OptionButton" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+item_count = 1
+selected = 0
+popup/item_0/text = "Monitor 1"
+popup/item_0/id = 0
+
+[node name="BackButton" type="Button" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+text = "Back to Main Menu"
+
+[node name="SaveSettingsButton" type="Button" parent="TabContainer/VideoTab/GridContainer"]
+layout_mode = 2
+text = "Save Me!"
+
+[node name="SoundTab" type="TabBar" parent="TabContainer"]
+visible = false
+layout_mode = 2
+
+[node name="GridContainer" type="GridContainer" parent="TabContainer/SoundTab"]
+layout_mode = 0
+offset_top = 33.0
+offset_right = 1152.0
+offset_bottom = 648.0
+columns = 2
+
+[node name="Label" type="Label" parent="TabContainer/SoundTab/GridContainer"]
+layout_mode = 2
+text = "Music Volume"
+horizontal_alignment = 2
+
+[node name="MusicVolume" type="HSlider" parent="TabContainer/SoundTab/GridContainer"]
+layout_mode = 2
+value = 100.0
+
+[node name="Label3" type="Label" parent="TabContainer/SoundTab/GridContainer"]
+layout_mode = 2
+text = "SFX Volume"
+horizontal_alignment = 2
+
+[node name="SfxVolume" type="HSlider" parent="TabContainer/SoundTab/GridContainer"]
+layout_mode = 2
+value = 100.0
+
+[node name="Label2" type="Label" parent="TabContainer/SoundTab/GridContainer"]
+layout_mode = 2
+horizontal_alignment = 2
+
+[node name="EarExploder" type="CheckButton" parent="TabContainer/SoundTab/GridContainer"]
+layout_mode = 2
+text = "Explode Eardrums on Startup?"
+
+[node name="OtherTab" type="TabBar" parent="TabContainer"]
+visible = false
+layout_mode = 2
+
+[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/OtherTab"]
+layout_mode = 0
+offset_right = 40.0
+offset_bottom = 40.0
+
+[node name="Label" type="Label" parent="TabContainer/OtherTab/HBoxContainer"]
+layout_mode = 2
+text = "Spinbox Example :)"
+
+[node name="SpinBox" type="SpinBox" parent="TabContainer/OtherTab/HBoxContainer"]
+layout_mode = 2
+
+[connection signal="item_selected" from="TabContainer/VideoTab/GridContainer/ResolutionSelector" to="." method="_on_resolution_selector_item_selected"]
+[connection signal="item_selected" from="TabContainer/VideoTab/GridContainer/ScreenModeSelector" to="." method="_on_screen_mode_selector_item_selected"]
+[connection signal="item_selected" from="TabContainer/VideoTab/GridContainer/MonitorDisplaySelector" to="." method="_on_monitor_display_selector_item_selected"]
+[connection signal="pressed" from="TabContainer/VideoTab/GridContainer/BackButton" to="." method="_on_back_button_pressed"]
+[connection signal="pressed" from="TabContainer/VideoTab/GridContainer/SaveSettingsButton" to="." method="_on_save_settings_button_pressed"]
+[connection signal="changed" from="TabContainer/SoundTab/GridContainer/MusicVolume" to="." method="_on_music_volume_changed"]
+[connection signal="drag_ended" from="TabContainer/SoundTab/GridContainer/MusicVolume" to="." method="_on_music_volume_drag_ended"]
+[connection signal="value_changed" from="TabContainer/SoundTab/GridContainer/MusicVolume" to="." method="_on_music_volume_value_changed"]
+[connection signal="value_changed" from="TabContainer/SoundTab/GridContainer/SfxVolume" to="." method="_on_sfx_volume_value_changed"]
+[connection signal="toggled" from="TabContainer/SoundTab/GridContainer/EarExploder" to="." method="_on_ear_exploder_toggled"]
+[connection signal="value_changed" from="TabContainer/OtherTab/HBoxContainer/SpinBox" to="." method="_on_spin_box_value_changed"]
diff --git a/game/src/StartNode.gd b/game/src/StartNode.gd
deleted file mode 100644
index 131dc40..0000000
--- a/game/src/StartNode.gd
+++ /dev/null
@@ -1,5 +0,0 @@
-extends Node
-
-func _ready():
- print("From GDScript")
- TestSingleton.hello_singleton()
diff --git a/game/src/StartNode.tscn b/game/src/StartNode.tscn
deleted file mode 100644
index f992b6c..0000000
--- a/game/src/StartNode.tscn
+++ /dev/null
@@ -1,6 +0,0 @@
-[gd_scene load_steps=2 format=3 uid="uid://b5hk77pbyfd2j"]
-
-[ext_resource type="Script" path="res://src/StartNode.gd" id="1_6ch7h"]
-
-[node name="StartNode" type="Node"]
-script = ExtResource("1_6ch7h")