Reworked weapons and projectiles

This commit is contained in:
2025-12-20 18:35:27 +03:00
parent 2ecc53416a
commit 8227e8bcf3
312 changed files with 2466 additions and 1376 deletions
+48
View File
@@ -0,0 +1,48 @@
extends Control
signal back
@export var scroll_speed: float = 25.0
@onready var main_menu_button := $BackButton
@onready var text := $Text
@onready var tween: Tween
func _ready() -> void:
main_menu_button.grab_focus()
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if not visible: return
main_menu_button.grab_focus()
_start_scrolling()
func _start_scrolling() -> void:
var start_pos := Vector2(0, get_viewport_rect().size.y)
var end_pos := Vector2(0, -text.size.y)
var duration := (start_pos.y - end_pos.y) / scroll_speed
text.position = start_pos
tween = create_tween()
tween.tween_property(text, "position:y", end_pos.y, duration)
tween.finished.connect(_on_scroll_finished)
func _on_back_button_pressed() -> void:
if tween:
tween.kill()
back.emit()
func _on_scroll_finished() -> void:
back.emit()
+1
View File
@@ -0,0 +1 @@
uid://dclkpithyykju
+64
View File
@@ -0,0 +1,64 @@
[gd_scene load_steps=6 format=3 uid="uid://c3q3g2647qc27"]
[ext_resource type="Script" uid="uid://dclkpithyykju" path="res://game/menu/common/credits.gd" id="1_wp78b"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_nidem"]
[ext_resource type="Theme" uid="uid://cigren10ijb75" path="res://images/label.tres" id="3_x2hwc"]
[sub_resource type="InputEventAction" id="InputEventAction_wp78b"]
action = &"ui_cancel"
[sub_resource type="Shortcut" id="Shortcut_nidem"]
events = [SubResource("InputEventAction_wp78b")]
[node name="Credits" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_wp78b")
[node name="BackButton" type="Button" parent="."]
z_index = 100
layout_mode = 1
offset_left = 531.0
offset_top = 299.0
offset_right = 615.0
offset_bottom = 335.0
mouse_filter = 2
theme = ExtResource("2_nidem")
shortcut = SubResource("Shortcut_nidem")
text = "Back"
[node name="Text" type="Label" parent="."]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_top = 360.0
offset_right = 640.0
offset_bottom = 760.0
grow_horizontal = 2
theme = ExtResource("3_x2hwc")
text = "PROGRAMMING
Ruslan Ignatov
DEGIGN AND GRAPHICS
Ruslan Ignatov
PLAY TESTING
Daniil Ivashchenko
Fedor Daragan
"
horizontal_alignment = 1
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="BackButton" to="." method="_on_back_button_pressed"]
+63
View File
@@ -0,0 +1,63 @@
extends Control
signal show_credits
signal back
@onready var fullscreen_button := $%FullscreenCheckButton
@onready var window_factor_button := $%WindowFactorOptionButton
@onready var credits_button := $%CreditsButton
@onready var back_button := $%BackButton
func _ready() -> void:
_load_current_settings()
_init_focus()
_setup_neighbors()
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if not visible: return
_load_current_settings()
_init_focus()
_setup_neighbors()
func _init_focus() -> void:
fullscreen_button.grab_focus()
func _setup_neighbors() -> void:
credits_button.focus_neighbor_left = back_button.get_path()
back_button.focus_neighbor_right = credits_button.get_path()
func _load_current_settings() -> void:
fullscreen_button.button_pressed = SettingsManager.fullscreen
window_factor_button.selected = SettingsManager.window_factor
_update_window_factor_disabled()
func _update_window_factor_disabled() -> void:
window_factor_button.disabled = SettingsManager.fullscreen
func _on_fullscreen_check_button_toggled(toggled: bool) -> void:
SettingsManager.fullscreen = toggled
_update_window_factor_disabled()
func _on_window_factor_option_button_item_selected(index: int) -> void:
if not SettingsManager.fullscreen:
SettingsManager.window_factor = index
func _on_credits_button_pressed() -> void:
show_credits.emit()
func _on_back_button_pressed() -> void:
back.emit()
+1
View File
@@ -0,0 +1 @@
uid://ceng1u112aqg0
+93
View File
@@ -0,0 +1,93 @@
[gd_scene load_steps=5 format=3 uid="uid://btr60idiit4y7"]
[ext_resource type="Script" uid="uid://ceng1u112aqg0" path="res://game/menu/common/options.gd" id="1_61pji"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_1tdpy"]
[sub_resource type="InputEventAction" id="InputEventAction_61pji"]
action = &"ui_cancel"
[sub_resource type="Shortcut" id="Shortcut_1tdpy"]
events = [SubResource("InputEventAction_61pji")]
[node name="Options" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_61pji")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
top_level = true
layout_mode = 0
offset_left = 100.0
offset_top = 100.0
offset_right = 271.0
offset_bottom = 194.0
alignment = 1
[node name="OptionsGridContainer" type="GridContainer" parent="VBoxContainer"]
layout_mode = 2
columns = 2
[node name="FullscreenLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
text = "Fullscreen"
[node name="FullscreenCheckButton" type="CheckButton" parent="VBoxContainer/OptionsGridContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
[node name="WindowFactorLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
text = "Window Factor"
[node name="WindowFactorOptionButton" type="OptionButton" parent="VBoxContainer/OptionsGridContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
selected = 0
item_count = 6
popup/item_0/text = "×1"
popup/item_0/id = 0
popup/item_1/text = "×2"
popup/item_1/id = 1
popup/item_2/text = "×3"
popup/item_2/id = 2
popup/item_3/text = "×4"
popup/item_3/id = 3
popup/item_4/text = "×5"
popup/item_4/id = 4
popup/item_5/text = "×6"
popup/item_5/id = 5
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
alignment = 2
[node name="CreditsButton" type="Button" parent="VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_1tdpy")
text = "Credits"
[node name="BackButton" type="Button" parent="VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_1tdpy")
shortcut = SubResource("Shortcut_1tdpy")
text = "Back"
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="toggled" from="VBoxContainer/OptionsGridContainer/FullscreenCheckButton" to="." method="_on_fullscreen_check_button_toggled"]
[connection signal="item_selected" from="VBoxContainer/OptionsGridContainer/WindowFactorOptionButton" to="." method="_on_window_factor_option_button_item_selected"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/CreditsButton" to="." method="_on_credits_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
+21
View File
@@ -0,0 +1,21 @@
extends Control
signal show_main_menu
@onready var main_menu_button : Button = $%MainMenuButton
@onready var button_focus_timer : Timer = $ButtonFocusTimer
func _on_timer_timeout() -> void:
main_menu_button.grab_focus()
func _on_main_menu_button_pressed() -> void:
show_main_menu.emit()
func _on_visibility_changed() -> void:
if visible and button_focus_timer:
button_focus_timer.start()
+1
View File
@@ -0,0 +1 @@
uid://bkj8s7588e1ho
+45
View File
@@ -0,0 +1,45 @@
[gd_scene load_steps=3 format=3 uid="uid://duxm8n62j2qt6"]
[ext_resource type="Script" uid="uid://bkj8s7588e1ho" path="res://game/menu/ingame/game_over_screen.gd" id="1_rkkr6"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_uh3ar"]
[node name="GameOverScreen" 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_rkkr6")
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer"]
z_index = 100
layout_mode = 2
text = "Game Over"
horizontal_alignment = 1
[node name="MainMenuButton" type="Button" parent="CenterContainer/VBoxContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_uh3ar")
text = "Main Menu"
[node name="ButtonFocusTimer" type="Timer" parent="."]
one_shot = true
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
[connection signal="timeout" from="ButtonFocusTimer" to="." method="_on_timer_timeout"]
+44
View File
@@ -0,0 +1,44 @@
extends Control
signal continue_game
signal show_main_menu
signal show_options
@onready var continue_button := $%ContinueButton
@onready var main_menu_button := $%MainMenuButton
func _ready() -> void:
_init_focus()
_setup_neighbors()
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if not visible: return
_init_focus()
_setup_neighbors()
func _init_focus() -> void:
continue_button.grab_focus()
func _setup_neighbors() -> void:
continue_button.focus_neighbor_top = main_menu_button.get_path()
main_menu_button.focus_neighbor_bottom = continue_button.get_path()
func _on_continue_button_pressed() -> void:
continue_game.emit()
func _on_options_button_pressed() -> void:
show_options.emit()
func _on_main_menu_button_pressed() -> void:
show_main_menu.emit()
+1
View File
@@ -0,0 +1 @@
uid://npqs2m5g5bd6
+49
View File
@@ -0,0 +1,49 @@
[gd_scene load_steps=4 format=3 uid="uid://bclo2wl8ibrcg"]
[ext_resource type="Script" uid="uid://npqs2m5g5bd6" path="res://game/menu/ingame/pause_menu.gd" id="1_inj1j"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_vy7sn"]
[sub_resource type="Shortcut" id="Shortcut_lgp46"]
[node name="PauseMenu" type="Control"]
process_mode = 2
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_inj1j")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
top_level = true
layout_mode = 0
offset_left = 100.0
offset_top = 100.0
offset_right = 196.0
offset_bottom = 166.0
[node name="ContinueButton" type="Button" parent="VBoxContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_vy7sn")
shortcut = SubResource("Shortcut_lgp46")
text = "CONTINUE"
[node name="OptionsButton" type="Button" parent="VBoxContainer"]
z_index = 100
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_vy7sn")
text = "OPTIONS"
[node name="MainMenuButton" type="Button" parent="VBoxContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_vy7sn")
text = "MAIN MENU"
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="VBoxContainer/ContinueButton" to="." method="_on_continue_button_pressed"]
[connection signal="pressed" from="VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
+56
View File
@@ -0,0 +1,56 @@
extends Control
signal continue_game
signal show_main_menu
@onready var pause_menu : Control = $PauseMenu
@onready var options : Control = $Options
@onready var credits : Control = $Credits
func _ready() -> void:
_show_menu(pause_menu)
func _input(event: InputEvent) -> void:
if event.is_action_pressed("pause") or event.is_action_pressed("ui_cancel"):
_on_pause_menu_continue_game.call_deferred()
func _show_menu(menu: Control) -> void:
var menus : Array[Control] = [ pause_menu, options, credits ]
for m in menus:
m.hide()
menu.show()
func _on_pause_menu_continue_game() -> void:
continue_game.emit()
func _on_pause_menu_show_main_menu() -> void:
show_main_menu.emit()
func _on_pause_menu_show_options() -> void:
_show_menu(options)
func _on_options_back() -> void:
_show_menu(pause_menu)
func _on_options_show_credits() -> void:
_show_menu(credits)
func _on_credits_back() -> void:
_show_menu(options)
func _on_visibility_changed() -> void:
get_tree().paused = visible
+1
View File
@@ -0,0 +1 @@
uid://c5d2t2o53wkmt
+28
View File
@@ -0,0 +1,28 @@
[gd_scene load_steps=5 format=3 uid="uid://d34nh3lc1gpb"]
[ext_resource type="Script" uid="uid://c5d2t2o53wkmt" path="res://game/menu/ingame/pause_screen.gd" id="1_fe1q8"]
[ext_resource type="PackedScene" uid="uid://bclo2wl8ibrcg" path="res://game/menu/ingame/pause_menu.tscn" id="2_4r6ly"]
[ext_resource type="PackedScene" uid="uid://btr60idiit4y7" path="res://game/menu/common/options.tscn" id="3_3gwb3"]
[ext_resource type="PackedScene" uid="uid://c3q3g2647qc27" path="res://game/menu/common/credits.tscn" id="4_jph5s"]
[node name="PauseScreen" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_fe1q8")
[node name="PauseMenu" parent="." instance=ExtResource("2_4r6ly")]
layout_mode = 0
[node name="Options" parent="." instance=ExtResource("3_3gwb3")]
layout_mode = 0
[node name="Credits" parent="." instance=ExtResource("4_jph5s")]
layout_mode = 0
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="continue_game" from="PauseMenu" to="." method="_on_pause_menu_continue_game"]
[connection signal="show_main_menu" from="PauseMenu" to="." method="_on_pause_menu_show_main_menu"]
[connection signal="show_options" from="PauseMenu" to="." method="_on_pause_menu_show_options"]
[connection signal="back" from="Options" to="." method="_on_options_back"]
[connection signal="show_credits" from="Options" to="." method="_on_options_show_credits"]
[connection signal="back" from="Credits" to="." method="_on_credits_back"]
+21
View File
@@ -0,0 +1,21 @@
extends Control
signal show_main_menu
@onready var main_menu_button : Button = $%MainMenuButton
@onready var button_focus_timer : Timer = $ButtonFocusTimer
func _on_timer_timeout() -> void:
main_menu_button.grab_focus()
func _on_main_menu_button_pressed() -> void:
show_main_menu.emit()
func _on_visibility_changed() -> void:
if visible and button_focus_timer:
button_focus_timer.start()
+1
View File
@@ -0,0 +1 @@
uid://b0p1ewlw18ijg
+45
View File
@@ -0,0 +1,45 @@
[gd_scene load_steps=3 format=3 uid="uid://bdcs2ff85qjs4"]
[ext_resource type="Script" uid="uid://b0p1ewlw18ijg" path="res://game/menu/ingame/victory_screen.gd" id="1_asigk"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_wb4d8"]
[node name="VictoryScreen" 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_asigk")
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer"]
z_index = 100
layout_mode = 2
text = "Victory!"
horizontal_alignment = 1
[node name="MainMenuButton" type="Button" parent="CenterContainer/VBoxContainer"]
unique_name_in_owner = true
z_index = 100
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_wb4d8")
text = "Main Menu"
[node name="ButtonFocusTimer" type="Timer" parent="."]
one_shot = true
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
[connection signal="timeout" from="ButtonFocusTimer" to="." method="_on_timer_timeout"]
@@ -0,0 +1,39 @@
class_name WeaponSelectionScreen
extends Control
signal weapon_selected(weapon_data: WeaponData)
const WEAPON_SELECTOR = preload("res://game/menu/ingame/weapon_selector.tscn")
@export var world_data : WorldData:
set = _set_world_data
@onready var weapon_selectors : Control = $%WeaponSelectors
func _set_world_data(data: WorldData) -> void:
world_data = data
for child in weapon_selectors.get_children():
child.queue_free()
if world_data == null: return
var selectors : Array[WeaponSelector] = []
for weapon_data in world_data.player_start_weapons:
var selector : WeaponSelector = WEAPON_SELECTOR.instantiate()
weapon_selectors.add_child(selector)
selector.weapon_data = weapon_data
selectors.append(selector)
selector.weapon_selected.connect(_on_weapon_selected)
if selectors.size() > 0:
selectors[0].button.grab_focus()
func _on_weapon_selected(weapon_data: WeaponData) -> void:
weapon_selected.emit(weapon_data)
@@ -0,0 +1 @@
uid://6isk1tmc2ik1
@@ -0,0 +1,38 @@
[gd_scene load_steps=2 format=3 uid="uid://cv122gw47cnun"]
[ext_resource type="Script" uid="uid://6isk1tmc2ik1" path="res://game/menu/ingame/weapon_selection_screen.gd" id="1_hl2ql"]
[node name="WeaponSelectionScreen" 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_hl2ql")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 0
offset_right = 640.0
offset_bottom = 360.0
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 16
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
alignment = 1
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
text = "Select your first weapon"
[node name="WeaponSelectors" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
alignment = 1
+27
View File
@@ -0,0 +1,27 @@
class_name WeaponSelector
extends Control
signal weapon_selected(weapon_data: WeaponData)
@export var weapon_data: WeaponData:
set = _set_weapon_data
@onready var button : Button = $%Button
@onready var name_label : Label = $%NameLabel
@onready var description_label : Label = $%DescriptionLabel
func _set_weapon_data(data: WeaponData) -> void:
weapon_data = data
if weapon_data == null: return
name_label.text = weapon_data.name
description_label.text = weapon_data.description
func _on_button_pressed() -> void:
weapon_selected.emit(weapon_data)
+1
View File
@@ -0,0 +1 @@
uid://beiydi6w6gqqc
+46
View File
@@ -0,0 +1,46 @@
[gd_scene load_steps=3 format=3 uid="uid://1o3idp54lil2"]
[ext_resource type="Script" uid="uid://beiydi6w6gqqc" path="res://game/menu/ingame/weapon_selector.gd" id="1_4acia"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_g83h6"]
[node name="WeaponSelector" type="MarginContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
script = ExtResource("1_4acia")
[node name="Button" type="Button" parent="."]
unique_name_in_owner = true
layout_mode = 2
theme = ExtResource("2_g83h6")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="NameLabel" type="Label" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme = ExtResource("2_g83h6")
horizontal_alignment = 1
[node name="DescriptionLabel" type="Label" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
theme_override_font_sizes/font_size = 8
horizontal_alignment = 1
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
+65
View File
@@ -0,0 +1,65 @@
extends Control
signal continue_game
signal new_game
signal quit_game
signal show_options
@onready var continue_button := $%ContinueButton
@onready var start_button := $%StartButton
@onready var quit_button := $%QuitButton
func _ready() -> void:
_init_focus()
_setup_neighbors()
_update_continue_button()
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if not visible: return
_init_focus()
_setup_neighbors()
_update_continue_button()
func _update_continue_button() -> void:
continue_button.disabled = SaveManager.game_data.game_seed.is_empty()
func _init_focus() -> void:
if continue_button.disabled:
start_button.grab_focus()
else:
continue_button.grab_focus()
func _setup_neighbors() -> void:
if continue_button.disabled:
continue_button.focus_neighbor_top = ""
start_button.focus_neighbor_top = quit_button.get_path()
quit_button.focus_neighbor_bottom = start_button.get_path()
else:
continue_button.focus_neighbor_top = quit_button.get_path()
start_button.focus_neighbor_top = ""
quit_button.focus_neighbor_bottom = continue_button.get_path()
func _on_continue_button_pressed() -> void:
continue_game.emit()
func _on_start_button_pressed() -> void:
new_game.emit()
func _on_options_button_pressed() -> void:
show_options.emit()
func _on_quit_button_pressed() -> void:
quit_game.emit()
+1
View File
@@ -0,0 +1 @@
uid://dixdfabe2vfsj
+54
View File
@@ -0,0 +1,54 @@
[gd_scene load_steps=3 format=3 uid="uid://bxlccevt52y70"]
[ext_resource type="Script" uid="uid://dixdfabe2vfsj" path="res://game/menu/main/main_menu.gd" id="1_chmv6"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_f5okj"]
[node name="MainMenu" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_chmv6")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
top_level = true
layout_mode = 0
offset_left = 100.0
offset_top = 100.0
offset_right = 179.0
offset_bottom = 236.0
[node name="ContinueButton" type="Button" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_f5okj")
disabled = true
button_mask = 0
text = "CONTINUE"
[node name="StartButton" type="Button" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_f5okj")
button_mask = 0
text = "START"
[node name="OptionsButton" type="Button" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_f5okj")
text = "OPTIONS"
[node name="QuitButton" type="Button" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_f5okj")
text = "QUIT"
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="VBoxContainer/ContinueButton" to="." method="_on_continue_button_pressed"]
[connection signal="pressed" from="VBoxContainer/StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"]
[connection signal="pressed" from="VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"]
+96
View File
@@ -0,0 +1,96 @@
class_name SeedSelectionMenu
extends Control
signal back
const SEED_CHARS := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const DEFAULT_SEED_LENGTH := 16
var _seed_regex := RegEx.new()
var _random_seed := ""
@onready var seed_label : Label = $%SeedLabel
@onready var seed_edit : LineEdit = $%SeedEdit
@onready var use_random_button : Button = $%UseRandomButton
@onready var use_custom_button : Button = $%UseCustomButton
func _init() -> void:
var regex_pattern := "[%s]+" % SEED_CHARS
_seed_regex.compile(regex_pattern)
func _update_use_custom_button() -> void:
var disabled := seed_edit.text.is_empty()
use_custom_button.disabled = disabled
use_custom_button.focus_mode = FOCUS_NONE if disabled else FOCUS_ALL
func _init_focus() -> void:
_update_use_custom_button()
use_random_button.grab_focus()
func _get_random_seed() -> String:
var seed_chars_length := SEED_CHARS.length()
var random_seed := ""
for i in range(DEFAULT_SEED_LENGTH):
var index := randi_range(1, seed_chars_length) - 1
random_seed += SEED_CHARS[index]
return random_seed
func _start_game(game_seed: String) -> void:
SaveManager.new_game(game_seed)
get_tree().change_scene_to_file("res://game/entities/world/game.tscn")
func _on_seed_edit_text_changed(new_text: String) -> void:
var result := _seed_regex.search_all(new_text)
var filtered_text := ""
for text in result:
filtered_text += text.get_string()
if seed_edit.text != filtered_text:
var caret_position := seed_edit.caret_column
seed_edit.text = filtered_text
seed_edit.caret_column = min(caret_position, filtered_text.length())
_update_use_custom_button()
func _on_seed_edit_text_submitted(new_text: String) -> void:
if not new_text.is_empty():
use_custom_button.grab_focus()
func _on_back_button_pressed() -> void:
back.emit()
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if not visible: return
_random_seed = _get_random_seed()
seed_edit.text = ""
seed_label.text = _random_seed
_init_focus()
func _on_use_random_button_pressed() -> void:
_start_game(_random_seed)
func _on_use_custom_button_pressed() -> void:
_start_game(seed_edit.text)
@@ -0,0 +1 @@
uid://dyynshvsgnepp
+80
View File
@@ -0,0 +1,80 @@
[gd_scene load_steps=5 format=3 uid="uid://c36n317rhv8k7"]
[ext_resource type="Script" uid="uid://dyynshvsgnepp" path="res://game/menu/main/seed_selection_menu.gd" id="1_g2smo"]
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_s4s14"]
[sub_resource type="InputEventAction" id="InputEventAction_g2smo"]
action = &"ui_cancel"
[sub_resource type="Shortcut" id="Shortcut_s4s14"]
events = [SubResource("InputEventAction_g2smo")]
[node name="SeedSelectionMenu" 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_g2smo")
[node name="GridContainer" type="GridContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -107.5
offset_top = -33.0
offset_right = 107.5
offset_bottom = 33.0
grow_horizontal = 2
grow_vertical = 2
columns = 2
[node name="SeedLabel" type="Label" parent="GridContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
horizontal_alignment = 1
[node name="UseRandomButton" type="Button" parent="GridContainer"]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_s4s14")
text = "Use random seed"
[node name="SeedEdit" type="LineEdit" parent="GridContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
mouse_filter = 2
placeholder_text = "Enter seed"
alignment = 1
max_length = 16
[node name="UseCustomButton" type="Button" parent="GridContainer"]
unique_name_in_owner = true
layout_mode = 2
mouse_filter = 2
theme = ExtResource("2_s4s14")
text = "Use custom seed"
[node name="Label" type="Label" parent="GridContainer"]
layout_mode = 2
[node name="BackButton" type="Button" parent="GridContainer"]
unique_name_in_owner = true
layout_mode = 2
theme = ExtResource("2_s4s14")
shortcut = SubResource("Shortcut_s4s14")
text = "Main menu"
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="GridContainer/UseRandomButton" to="." method="_on_use_random_button_pressed"]
[connection signal="text_changed" from="GridContainer/SeedEdit" to="." method="_on_seed_edit_text_changed"]
[connection signal="text_submitted" from="GridContainer/SeedEdit" to="." method="_on_seed_edit_text_submitted"]
[connection signal="pressed" from="GridContainer/UseCustomButton" to="." method="_on_use_custom_button_pressed"]
[connection signal="pressed" from="GridContainer/BackButton" to="." method="_on_back_button_pressed"]
+53
View File
@@ -0,0 +1,53 @@
extends Control
@onready var main_menu : Control = $MainMenu
@onready var options : Control = $Options
@onready var credits : Control = $Credits
@onready var seed_selection : Control = $SeedSelection
func _ready() -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
_show_menu(main_menu)
func _show_menu(menu: Control) -> void:
var menus : Array[Control] = [ main_menu, options, credits, seed_selection ]
for m in menus:
m.hide()
menu.show()
func _on_main_menu_continue_game() -> void:
get_tree().change_scene_to_file("res://game/entities/world/game.tscn")
func _on_main_menu_new_game() -> void:
_show_menu(seed_selection)
func _get_random_weapon_id() -> String:
return AbstractShip.WEAPON_SCENES.keys().pick_random()
func _on_main_menu_quit_game() -> void:
get_tree().quit()
func _on_main_menu_show_options() -> void:
_show_menu(options)
func _on_options_show_credits() -> void:
_show_menu(credits)
func _on_credits_back() -> void:
_show_menu(options)
func _show_main_menu() -> void:
_show_menu(main_menu)
+1
View File
@@ -0,0 +1 @@
uid://bqnepsuk13qo8
+46
View File
@@ -0,0 +1,46 @@
[gd_scene load_steps=7 format=3 uid="uid://2oavbr7oaihg"]
[ext_resource type="Script" uid="uid://bqnepsuk13qo8" path="res://game/menu/main/title_screen.gd" id="1_lxdol"]
[ext_resource type="PackedScene" uid="uid://bxlccevt52y70" path="res://game/menu/main/main_menu.tscn" id="2_o0rbc"]
[ext_resource type="PackedScene" uid="uid://btr60idiit4y7" path="res://game/menu/common/options.tscn" id="3_88gnj"]
[ext_resource type="PackedScene" uid="uid://c3q3g2647qc27" path="res://game/menu/common/credits.tscn" id="4_w1y3c"]
[ext_resource type="PackedScene" uid="uid://chdrjc7c6bdpb" path="res://game/entities/world/background.tscn" id="5_88gnj"]
[ext_resource type="PackedScene" uid="uid://c36n317rhv8k7" path="res://game/menu/main/seed_selection_menu.tscn" id="5_w1y3c"]
[node name="TitleScreen" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_lxdol")
[node name="MainMenu" parent="." instance=ExtResource("2_o0rbc")]
layout_mode = 0
[node name="Options" parent="." instance=ExtResource("3_88gnj")]
layout_mode = 0
[node name="Credits" parent="." instance=ExtResource("4_w1y3c")]
layout_mode = 0
[node name="SeedSelection" parent="." instance=ExtResource("5_w1y3c")]
layout_mode = 0
anchors_preset = 0
anchor_right = 0.0
anchor_bottom = 0.0
offset_left = 320.0
offset_top = 190.0
offset_right = 320.0
offset_bottom = 190.0
grow_horizontal = 1
grow_vertical = 1
size_flags_horizontal = 4
[node name="Background" parent="." instance=ExtResource("5_88gnj")]
[connection signal="continue_game" from="MainMenu" to="." method="_on_main_menu_continue_game"]
[connection signal="new_game" from="MainMenu" to="." method="_on_main_menu_new_game"]
[connection signal="quit_game" from="MainMenu" to="." method="_on_main_menu_quit_game"]
[connection signal="show_options" from="MainMenu" to="." method="_on_main_menu_show_options"]
[connection signal="back" from="Options" to="." method="_show_main_menu"]
[connection signal="show_credits" from="Options" to="." method="_on_options_show_credits"]
[connection signal="back" from="Credits" to="." method="_on_credits_back"]
[connection signal="back" from="SeedSelection" to="." method="_show_main_menu"]