New base menu template
This commit is contained in:
parent
545da7be1f
commit
f2cff37a22
12 changed files with 185 additions and 16 deletions
104
scenes/Base/base_menu.tscn
Normal file
104
scenes/Base/base_menu.tscn
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://crq284yed2if5"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/Base/base_menu.gd" id="1_3hgu4"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://db4euprxhape0" path="res://sprites/9s.png" id="1_uf5rv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://hxrx87gda3uf" path="res://sprites/Bases/Menu/end_communications.png" id="2_ceeiv"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/Base/close_button.gd" id="4_68ool"]
|
||||||
|
|
||||||
|
[node name="BaseMenu" 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_3hgu4")
|
||||||
|
|
||||||
|
[node name="MenuBackground" type="NinePatchRect" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 40.0
|
||||||
|
offset_top = 40.0
|
||||||
|
offset_right = 1240.0
|
||||||
|
offset_bottom = 640.0
|
||||||
|
texture = ExtResource("1_uf5rv")
|
||||||
|
region_rect = Rect2(0, 0, 5, 5)
|
||||||
|
patch_margin_left = 2
|
||||||
|
patch_margin_top = 2
|
||||||
|
patch_margin_right = 2
|
||||||
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
|
[node name="HeaderBackground" type="NinePatchRect" parent="MenuBackground"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 2.0
|
||||||
|
offset_top = 2.0
|
||||||
|
offset_right = 1198.0
|
||||||
|
offset_bottom = 76.0
|
||||||
|
texture = ExtResource("1_uf5rv")
|
||||||
|
region_rect = Rect2(0, 0, 5, 5)
|
||||||
|
patch_margin_left = 2
|
||||||
|
patch_margin_top = 2
|
||||||
|
patch_margin_right = 2
|
||||||
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
|
[node name="PortraitBackground" type="NinePatchRect" parent="MenuBackground"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 2.0
|
||||||
|
offset_top = 77.0
|
||||||
|
offset_right = 324.0
|
||||||
|
offset_bottom = 598.0
|
||||||
|
texture = ExtResource("1_uf5rv")
|
||||||
|
region_rect = Rect2(0, 0, 5, 5)
|
||||||
|
patch_margin_left = 2
|
||||||
|
patch_margin_top = 2
|
||||||
|
patch_margin_right = 2
|
||||||
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
|
[node name="DialogueBackground" type="NinePatchRect" parent="MenuBackground"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 325.0
|
||||||
|
offset_top = 77.0
|
||||||
|
offset_right = 1198.0
|
||||||
|
offset_bottom = 399.0
|
||||||
|
texture = ExtResource("1_uf5rv")
|
||||||
|
region_rect = Rect2(0, 0, 5, 5)
|
||||||
|
patch_margin_left = 2
|
||||||
|
patch_margin_top = 2
|
||||||
|
patch_margin_right = 2
|
||||||
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
|
[node name="ActionsBackground" type="NinePatchRect" parent="MenuBackground"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 325.0
|
||||||
|
offset_top = 400.0
|
||||||
|
offset_right = 1198.0
|
||||||
|
offset_bottom = 598.0
|
||||||
|
texture = ExtResource("1_uf5rv")
|
||||||
|
region_rect = Rect2(0, 0, 5, 5)
|
||||||
|
patch_margin_left = 2
|
||||||
|
patch_margin_top = 2
|
||||||
|
patch_margin_right = 2
|
||||||
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
|
[node name="CloseButtonBackground" type="NinePatchRect" parent="MenuBackground"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 1124.0
|
||||||
|
offset_top = 2.0
|
||||||
|
offset_right = 1198.0
|
||||||
|
offset_bottom = 76.0
|
||||||
|
texture = ExtResource("1_uf5rv")
|
||||||
|
region_rect = Rect2(0, 0, 5, 5)
|
||||||
|
patch_margin_left = 2
|
||||||
|
patch_margin_top = 2
|
||||||
|
patch_margin_right = 2
|
||||||
|
patch_margin_bottom = 2
|
||||||
|
|
||||||
|
[node name="CloseButton" type="Button" parent="MenuBackground/CloseButtonBackground"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 1.0
|
||||||
|
offset_top = 1.0
|
||||||
|
offset_right = 73.0
|
||||||
|
offset_bottom = 73.0
|
||||||
|
icon = ExtResource("2_ceeiv")
|
||||||
|
script = ExtResource("4_68ool")
|
||||||
|
|
||||||
|
[connection signal="button_up" from="MenuBackground/CloseButtonBackground/CloseButton" to="MenuBackground/CloseButtonBackground/CloseButton" method="_on_button_up"]
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://dk3nvl8f0v24e"]
|
[gd_scene load_steps=6 format=3 uid="uid://dk3nvl8f0v24e"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/Base/base.gd" id="1_dr4wr"]
|
[ext_resource type="Script" path="res://scripts/Base/base.gd" id="1_dr4wr"]
|
||||||
[ext_resource type="Texture2D" uid="uid://3x77t3kd6v0x" path="res://sprites/Bases/triangle_base.png" id="1_nrkxw"]
|
[ext_resource type="Texture2D" uid="uid://3x77t3kd6v0x" path="res://sprites/Bases/triangle_base.png" id="1_nrkxw"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://crq284yed2if5" path="res://scenes/Base/base_menu.tscn" id="2_n6qqo"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4e5h0"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4e5h0"]
|
||||||
size = Vector2(357, 4)
|
size = Vector2(357, 4)
|
||||||
|
|
@ -15,6 +16,7 @@ collision_layer = 2
|
||||||
collision_mask = 7
|
collision_mask = 7
|
||||||
input_pickable = true
|
input_pickable = true
|
||||||
script = ExtResource("1_dr4wr")
|
script = ExtResource("1_dr4wr")
|
||||||
|
menu = ExtResource("2_n6qqo")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
position = Vector2(0.5, 0.5)
|
position = Vector2(0.5, 0.5)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://bxtd2ij1dc1d3" path="res://sprites/Ships/shooter.png" id="2_gvwov"]
|
[ext_resource type="Texture2D" uid="uid://bxtd2ij1dc1d3" path="res://sprites/Ships/shooter.png" id="2_gvwov"]
|
||||||
|
|
||||||
[node name="Hull" instance=ExtResource("1_7i1ve")]
|
[node name="Hull" instance=ExtResource("1_7i1ve")]
|
||||||
|
collision_mask = 11
|
||||||
max_hp = 10.0
|
max_hp = 10.0
|
||||||
|
|
||||||
[node name="Sprite" parent="." index="0"]
|
[node name="Sprite" parent="." index="0"]
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ position = Vector2(19, 10)
|
||||||
position = Vector2(1706, -5)
|
position = Vector2(1706, -5)
|
||||||
|
|
||||||
[node name="KamikazeShip" parent="FactionAggressive" index="0" instance=ExtResource("4_i6rbg")]
|
[node name="KamikazeShip" parent="FactionAggressive" index="0" instance=ExtResource("4_i6rbg")]
|
||||||
position = Vector2(-244, -914)
|
position = Vector2(-1712, -608)
|
||||||
|
|
||||||
[node name="ShooterShip" parent="FactionAggressive" index="1" instance=ExtResource("5_o3ny8")]
|
[node name="ShooterShip" parent="FactionAggressive" index="1" instance=ExtResource("5_o3ny8")]
|
||||||
position = Vector2(-833, 1073)
|
position = Vector2(-1852, 618)
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ script = ExtResource("1_xx8w2")
|
||||||
pause_controller_scene = ExtResource("6_61vq5")
|
pause_controller_scene = ExtResource("6_61vq5")
|
||||||
|
|
||||||
[node name="Stars" parent="." instance=ExtResource("2_iqrn0")]
|
[node name="Stars" parent="." instance=ExtResource("2_iqrn0")]
|
||||||
|
stars_amount = 400
|
||||||
|
|
||||||
[node name="ProjectileContainer" type="Node" parent="."]
|
[node name="ProjectileContainer" type="Node" parent="."]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,25 @@ extends StaticBody2D
|
||||||
|
|
||||||
class_name Base
|
class_name Base
|
||||||
|
|
||||||
enum DockState { Ready, Process, Busy }
|
enum DockState { Ready, Process, Busy, Leave }
|
||||||
|
|
||||||
signal dock_requested
|
signal dock_requested
|
||||||
|
|
||||||
## Reference to star system
|
## Reference to star system
|
||||||
@onready var star_system: StarSystem = get_tree().current_scene
|
@onready var star_system: StarSystem = get_tree().current_scene
|
||||||
|
## Physical gate
|
||||||
@onready var gate_static = $Gate
|
@onready var gate_static = $Gate
|
||||||
|
## Logical gate for docking
|
||||||
@onready var gate_area = $GateArea
|
@onready var gate_area = $GateArea
|
||||||
|
## Docking area
|
||||||
@onready var dock_area = $DockingArea
|
@onready var dock_area = $DockingArea
|
||||||
|
|
||||||
|
## Menu which will instantiate on docking
|
||||||
|
@export var menu: PackedScene
|
||||||
|
|
||||||
@export var faction: Game.Faction
|
@export var faction: Game.Faction
|
||||||
|
|
||||||
|
## Decides whether ship is docked or in process
|
||||||
var dock_state: DockState = DockState.Ready
|
var dock_state: DockState = DockState.Ready
|
||||||
|
|
||||||
var touching_gate = false
|
var touching_gate = false
|
||||||
|
|
@ -66,6 +70,9 @@ func _process(_delta):
|
||||||
dock_busy()
|
dock_busy()
|
||||||
if !touching_dock and !touching_gate and distance_to_player > 2048:
|
if !touching_dock and !touching_gate and distance_to_player > 2048:
|
||||||
dock_ready()
|
dock_ready()
|
||||||
|
if dock_state == DockState.Leave:
|
||||||
|
if !touching_dock and !touching_gate:
|
||||||
|
dock_ready()
|
||||||
|
|
||||||
## Sets dock state to Ready
|
## Sets dock state to Ready
|
||||||
func dock_ready():
|
func dock_ready():
|
||||||
|
|
@ -74,8 +81,6 @@ func dock_ready():
|
||||||
gate_static.process_mode = Node.PROCESS_MODE_INHERIT
|
gate_static.process_mode = Node.PROCESS_MODE_INHERIT
|
||||||
gate_area.visible = false
|
gate_area.visible = false
|
||||||
dock_area.visible = false
|
dock_area.visible = false
|
||||||
touching_gate = false
|
|
||||||
touching_dock = false
|
|
||||||
## Sets dock state to Process
|
## Sets dock state to Process
|
||||||
func dock_process():
|
func dock_process():
|
||||||
dock_state = DockState.Process
|
dock_state = DockState.Process
|
||||||
|
|
@ -83,8 +88,6 @@ func dock_process():
|
||||||
gate_static.process_mode = Node.PROCESS_MODE_DISABLED
|
gate_static.process_mode = Node.PROCESS_MODE_DISABLED
|
||||||
gate_area.visible = true
|
gate_area.visible = true
|
||||||
dock_area.visible = true
|
dock_area.visible = true
|
||||||
touching_gate = false
|
|
||||||
touching_dock = false
|
|
||||||
## Sets dock state to Busy
|
## Sets dock state to Busy
|
||||||
func dock_busy():
|
func dock_busy():
|
||||||
dock_state = DockState.Busy
|
dock_state = DockState.Busy
|
||||||
|
|
@ -92,6 +95,14 @@ func dock_busy():
|
||||||
gate_static.process_mode = Node.PROCESS_MODE_INHERIT
|
gate_static.process_mode = Node.PROCESS_MODE_INHERIT
|
||||||
gate_area.visible = false
|
gate_area.visible = false
|
||||||
dock_area.visible = false
|
dock_area.visible = false
|
||||||
touching_gate = false
|
# opening base menu
|
||||||
touching_dock = true
|
var menu_instance = menu.instantiate()
|
||||||
# TODO: implement opening the base menu
|
menu_instance.base = self
|
||||||
|
player_ship.non_colorable_gui.add_child(menu_instance)
|
||||||
|
|
||||||
|
func dock_leave():
|
||||||
|
dock_state = DockState.Leave
|
||||||
|
gate_static.visible = false
|
||||||
|
gate_static.process_mode = Node.PROCESS_MODE_DISABLED
|
||||||
|
gate_area.visible = true
|
||||||
|
dock_area.visible = true
|
||||||
|
|
|
||||||
4
scripts/Base/base_menu.gd
Normal file
4
scripts/Base/base_menu.gd
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
## Base which provided this menu
|
||||||
|
var base: Base
|
||||||
7
scripts/Base/close_button.gd
Normal file
7
scripts/Base/close_button.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
@onready var menu = $"../../.."
|
||||||
|
|
||||||
|
func _on_button_up():
|
||||||
|
menu.base.dock_leave()
|
||||||
|
menu.queue_free()
|
||||||
|
|
@ -15,6 +15,11 @@ var expected_rotation: float = 0.0:
|
||||||
expected_rotation = value
|
expected_rotation = value
|
||||||
|
|
||||||
func _physics_process(_delta) -> void:
|
func _physics_process(_delta) -> void:
|
||||||
|
if ship.selected_node is Base:
|
||||||
|
if Input.is_action_just_released("dock"):
|
||||||
|
ship.selected_node.dock_requested.emit()
|
||||||
|
if ship.selected_node.dock_state == Base.DockState.Busy:
|
||||||
|
return
|
||||||
ship.engine.acceleration_axis = Input.get_axis("deccelerate", "accelerate")
|
ship.engine.acceleration_axis = Input.get_axis("deccelerate", "accelerate")
|
||||||
ship.engine.rotation_axis = Input.get_axis("rotateleft", "rotateright")
|
ship.engine.rotation_axis = Input.get_axis("rotateleft", "rotateright")
|
||||||
for weapon in ship.weapons.list:
|
for weapon in ship.weapons.list:
|
||||||
|
|
@ -29,5 +34,3 @@ func _physics_process(_delta) -> void:
|
||||||
weapon.gun_rotation = expected_rotation
|
weapon.gun_rotation = expected_rotation
|
||||||
if Input.is_action_just_released("select_target"):
|
if Input.is_action_just_released("select_target"):
|
||||||
ship.selected_node = star_system.targeted_node
|
ship.selected_node = star_system.targeted_node
|
||||||
if ship.selected_node is Base and Input.is_action_just_released("dock"):
|
|
||||||
ship.selected_node.dock_requested.emit()
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ class_name PlayerShip
|
||||||
@onready var camera = $Camera
|
@onready var camera = $Camera
|
||||||
## Player colorable GUI reference
|
## Player colorable GUI reference
|
||||||
@onready var colorable_gui = $ColorableGUI
|
@onready var colorable_gui = $ColorableGUI
|
||||||
|
## Player non-colorable GUI reference
|
||||||
|
@onready var non_colorable_gui = $NonColorableGUI
|
||||||
## Node which was selected by input
|
## Node which was selected by input
|
||||||
var selected_node: Node2D = null
|
var selected_node: Node2D = null
|
||||||
## Currency variable
|
## Currency variable
|
||||||
|
|
|
||||||
BIN
sprites/Bases/Menu/end_communications.png
Normal file
BIN
sprites/Bases/Menu/end_communications.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
34
sprites/Bases/Menu/end_communications.png.import
Normal file
34
sprites/Bases/Menu/end_communications.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://hxrx87gda3uf"
|
||||||
|
path="res://.godot/imported/end_communications.png-c197820e4b93073e795d9c65af448f6a.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://sprites/Bases/Menu/end_communications.png"
|
||||||
|
dest_files=["res://.godot/imported/end_communications.png-c197820e4b93073e795d9c65af448f6a.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue