Improved menu system
This commit is contained in:
parent
da78e7f287
commit
c95b8186ab
12 changed files with 181 additions and 111 deletions
|
|
@ -69,8 +69,6 @@ func _process(delta):
|
|||
if position.length() > world_distance_limit:
|
||||
position = position.normalized() * world_distance_limit
|
||||
|
||||
|
||||
|
||||
if azimuth_pivot.rotation_degrees.x > -min_camera_angle:
|
||||
azimuth_pivot.rotation_degrees.x = -min_camera_angle
|
||||
if azimuth_pivot.rotation_degrees.x < -max_camera_angle:
|
||||
|
|
|
|||
12
Game.tscn
12
Game.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=22 format=3 uid="uid://bx0bbrwdr0h40"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://bx0bbrwdr0h40"]
|
||||
|
||||
[ext_resource type="Script" path="res://Game.gd" id="1_dgt1j"]
|
||||
[ext_resource type="Script" path="res://CameraPivot.gd" id="2_71xp1"]
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
[ext_resource type="Texture2D" uid="uid://d2i5vboeyq8qx" path="res://UI/hex_white.svg" id="11_cl0he"]
|
||||
[ext_resource type="Script" path="res://GameOverMenu.gd" id="11_ffmss"]
|
||||
[ext_resource type="Script" path="res://MenuButtons.gd" id="11_urihv"]
|
||||
[ext_resource type="PackedScene" uid="uid://8ffmln680deh" path="res://UI/Rules/Rules.tscn" id="12_g7rxm"]
|
||||
[ext_resource type="Script" path="res://TurnTexture.gd" id="12_kjwp8"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_cu5ir"]
|
||||
|
|
@ -63,7 +62,7 @@ script = ExtResource("1_dgt1j")
|
|||
script = ExtResource("2_71xp1")
|
||||
|
||||
[node name="AzimuthPivot" type="Node3D" parent="CameraPivot"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.374607, 0.927184, 0, -0.927184, 0.374607, 0, 0, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 0.642788, 0.766045, 0, -0.766045, 0.642788, 0, 0, 0)
|
||||
|
||||
[node name="SpringArm3D" type="SpringArm3D" parent="CameraPivot/AzimuthPivot"]
|
||||
collision_mask = 0
|
||||
|
|
@ -259,10 +258,8 @@ text = "Menu"
|
|||
layout_mode = 2
|
||||
text = "Rules"
|
||||
|
||||
[node name="Rules" parent="." instance=ExtResource("12_g7rxm")]
|
||||
visible = false
|
||||
|
||||
[node name="GameOverMenu" type="CanvasLayer" parent="."]
|
||||
visible = false
|
||||
script = ExtResource("11_ffmss")
|
||||
|
||||
[node name="Control" type="Control" parent="GameOverMenu"]
|
||||
|
|
@ -295,7 +292,6 @@ horizontal_alignment = 1
|
|||
layout_mode = 2
|
||||
text = "Back to menu"
|
||||
|
||||
[node name="PauseMenu" type="CanvasLayer" parent="."]
|
||||
|
||||
[connection signal="pressed" from="MenuButtons/VBoxContainer/MenuButton" to="MenuButtons" method="_on_menu_button_pressed"]
|
||||
[connection signal="pressed" from="MenuButtons/VBoxContainer/RulesButton" to="MenuButtons" method="_on_rules_button_pressed"]
|
||||
[connection signal="pressed" from="GameOverMenu/Control/PanelContainer/VBoxContainer/Button" to="GameOverMenu" method="_on_button_pressed"]
|
||||
|
|
|
|||
|
|
@ -140,8 +140,6 @@ func get_neighbours(coords: Vector4i, ground_layer: bool = false) -> Array[Vecto
|
|||
Vector4i(coords.x, coords.y + 1, coords.z - 1, layer)
|
||||
]
|
||||
|
||||
var current_tile: Node3D
|
||||
|
||||
const HEX_OUTLINE = preload("res://hex_outline.tscn")
|
||||
|
||||
func get_placeable_positions(button: InsectButton) -> Array[Vector4i]:
|
||||
|
|
@ -237,6 +235,10 @@ func can_reach(start: Vector4i, target: Vector4i, exclude: Array[Vector4i] = [])
|
|||
|
||||
func _on_insect_selected(button: InsectButton, is_black: bool) -> void:
|
||||
var positions = get_placeable_positions(button)
|
||||
|
||||
for child in placement_visualizer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
for p in positions:
|
||||
var outline = HEX_OUTLINE.instantiate()
|
||||
var hex_pos = cube_to_world_pos(p)
|
||||
|
|
@ -247,84 +249,8 @@ func _on_insect_selected(button: InsectButton, is_black: bool) -> void:
|
|||
outline.coordinates = p
|
||||
outline.map_reference = self
|
||||
placement_visualizer.add_child(outline)
|
||||
#placements[p] = outline
|
||||
|
||||
# create a hexagon with insect resource data
|
||||
#var tile = INSECT_TILE.instantiate()
|
||||
#tile.resource = insect_resource
|
||||
#tile.is_black = is_black
|
||||
#current_tile = tile
|
||||
#add_child(tile)
|
||||
#var insect_resource: TileResource = button.insect_resource
|
||||
#
|
||||
## spawn possible placement locations :)
|
||||
#if used_cells.size() == 0: # we have no cells placed, display a placement outline at 0, 0
|
||||
#var outline = HEX_OUTLINE.instantiate()
|
||||
#var cubepos = Vector4i.new(0, 0, 0)
|
||||
#var hex_pos = cube_to_world_pos(cubepos)
|
||||
#outline.position = Vector3(hex_pos.x, 0.0, hex_pos.y)
|
||||
#outline.visible = true
|
||||
#outline.insect_resource = insect_resource
|
||||
#outline.is_black = is_black
|
||||
#outline.coordinates = cubepos
|
||||
#outline.map_reference = self
|
||||
#placement_visualizer.add_child(outline)
|
||||
#placements[hex_pos] = outline
|
||||
#elif used_cells.size() == 1: # we have ONE cell placed, this is a special case in which
|
||||
## the opposing player is allowed to place a tile that touches the enemy color
|
||||
## We display outline placement around all spaces of this single cell
|
||||
#var single_cell = used_cells.keys().front()
|
||||
#var neighbours = get_neighbours(Vector4i.new(single_cell.x, single_cell.y, single_cell.z))
|
||||
#for neighbour in neighbours:
|
||||
#var outline = HEX_OUTLINE.instantiate()
|
||||
#var hex_pos = cube_to_world_pos(neighbour)
|
||||
#outline.position = Vector3(hex_pos.x, 0.0, hex_pos.y)
|
||||
#outline.visible = true
|
||||
#outline.insect_resource = insect_resource
|
||||
#outline.is_black = is_black
|
||||
#outline.coordinates = neighbour
|
||||
#outline.map_reference = self
|
||||
#placement_visualizer.add_child(outline)
|
||||
#placements[hex_pos] = outline
|
||||
#else:
|
||||
## iterate over all used_cells, get all empty cells surrounding those cells
|
||||
## iterate over all those empty cells, check if they only neighbour the same color
|
||||
#var possible_placements: Dictionary = {}
|
||||
#
|
||||
#for hex in used_cells.keys():
|
||||
##var eligible: bool = true
|
||||
#for neighbour in get_empty_neighbours(Vector4i.new(hex.x, hex.y, hex.z)):
|
||||
#if not used_cells.has(Vector4(neighbour.q, neighbour.r, neighbour.s, 0)):
|
||||
#possible_placements[Vector4i(neighbour.q, neighbour.r, neighbour.s, 0)] = true
|
||||
#
|
||||
#for p in possible_placements:
|
||||
#var eligible: bool = true
|
||||
#
|
||||
#for neighbour in get_neighbours(Vector4i.new(p.x, p.y, p.z)):
|
||||
#if not used_cells.has(Vector4i(neighbour.q, neighbour.r, neighbour.s, 0)):
|
||||
#continue
|
||||
#
|
||||
#if used_cells[Vector4i(neighbour.q, neighbour.r, neighbour.s, 0)].is_black != is_black:
|
||||
#eligible = false
|
||||
#break
|
||||
#
|
||||
#if eligible:
|
||||
#var outline = HEX_OUTLINE.instantiate()
|
||||
#var hex_pos = cube_to_world_pos(Vector4i.new(p.x, p.y, p.z))
|
||||
#outline.position = Vector3(hex_pos.x, 0.0, hex_pos.y)
|
||||
#outline.visible = true
|
||||
#outline.insect_resource = insect_resource
|
||||
#outline.is_black = is_black
|
||||
#outline.coordinates = Vector4i.new(p.x, p.y, p.z)
|
||||
#outline.map_reference = self
|
||||
#placement_visualizer.add_child(outline)
|
||||
#placements[p] = outline
|
||||
|
||||
func _on_insect_placement_cancelled() -> void:
|
||||
if current_tile:
|
||||
current_tile.queue_free()
|
||||
current_tile = null
|
||||
|
||||
for child in placement_visualizer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
|
|
@ -366,6 +292,9 @@ func can_move(tile: InsectTile) -> bool:
|
|||
return can_hive_exist_without_tile(tile)
|
||||
|
||||
func _on_insect_tile_selected(tile: InsectTile) -> void:
|
||||
for child in placement_visualizer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
if not can_hive_exist_without_tile(tile):
|
||||
print("Would break hive")
|
||||
return
|
||||
|
|
|
|||
58
InGameMenu.gd
Normal file
58
InGameMenu.gd
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
extends Control
|
||||
|
||||
@onready var panel_container = $PanelContainer
|
||||
@onready var margin_container2 = $Pivot/MarginContainer
|
||||
|
||||
const SETTINGS = preload("res://UI/Settings/Settings.tscn")
|
||||
|
||||
var mat: ShaderMaterial
|
||||
|
||||
func show_panel() -> void:
|
||||
margin_container2.position.y = 700
|
||||
mat.set_shader_parameter("lod", 0)
|
||||
|
||||
visible = true
|
||||
|
||||
var tween = get_tree().create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_method(tween_blur, 0.0, 1.0, 0.5).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT)
|
||||
tween.tween_property(margin_container2, "position:y", 0.0, 0.5).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
mat = panel_container.material
|
||||
pass # Replace with function body.
|
||||
|
||||
func tween_blur(val: float) -> void:
|
||||
mat.set_shader_parameter("lod", val)
|
||||
pass
|
||||
|
||||
func hide_panel() -> void:
|
||||
var tween = get_tree().create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_method(tween_blur, 1.0, 0.0, 0.5).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT)
|
||||
tween.tween_property(margin_container2, "position:y", 700, 0.5).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_IN)
|
||||
|
||||
tween.finished.connect(_on_panel_hidden)
|
||||
|
||||
|
||||
|
||||
func _on_panel_hidden() -> void:
|
||||
visible = false
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_close_button_pressed():
|
||||
hide_panel()
|
||||
|
||||
|
||||
func _on_settings_pressed():
|
||||
var settings = SETTINGS.instantiate()
|
||||
|
||||
get_tree().root.add_child(settings)
|
||||
settings.show_panel()
|
||||
|
||||
|
||||
func _on_exit_button_pressed():
|
||||
get_tree().change_scene_to_file("res://UI/main_menu.tscn")
|
||||
queue_free()
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
extends Control
|
||||
|
||||
@onready var rules = $"../Rules"
|
||||
|
||||
|
||||
const IN_GAME_MENU = preload("res://UI/InGameMenu/InGameMenu.tscn")
|
||||
const RULES = preload("res://UI/Rules/Rules.tscn")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
|
@ -14,4 +13,15 @@ func _process(delta):
|
|||
|
||||
|
||||
func _on_rules_button_pressed():
|
||||
var rules = RULES.instantiate()
|
||||
|
||||
get_tree().root.add_child(rules)
|
||||
|
||||
rules.show_panel()
|
||||
|
||||
func _on_menu_button_pressed():
|
||||
var in_game_menu = IN_GAME_MENU.instantiate()
|
||||
|
||||
get_tree().root.add_child(in_game_menu)
|
||||
|
||||
in_game_menu.show_panel()
|
||||
|
|
|
|||
|
|
@ -3,19 +3,21 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cilgpyanfb3a8"
|
||||
path="res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.ctex"
|
||||
path.s3tc="res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.s3tc.ctex"
|
||||
path.etc2="res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.etc2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": ["s3tc_bptc", "etc2_astc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Testbed/textures/wood_table_001_diff_4k.jpg"
|
||||
dest_files=["res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.ctex"]
|
||||
dest_files=["res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.s3tc.ctex", "res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.etc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
|
|
|
|||
78
UI/InGameMenu/InGameMenu.tscn
Normal file
78
UI/InGameMenu/InGameMenu.tscn
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://ddr6rgskqfh8o"]
|
||||
|
||||
[ext_resource type="Script" path="res://InGameMenu.gd" id="1_q28o4"]
|
||||
[ext_resource type="Shader" path="res://Testbed/UIBlur.gdshader" id="2_tx6hg"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hbvdu"]
|
||||
shader = ExtResource("2_tx6hg")
|
||||
shader_parameter/lod = 1.0
|
||||
|
||||
[node name="InGameMenu" 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_q28o4")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
self_modulate = Color(1, 1, 1, 0.392157)
|
||||
material = SubResource("ShaderMaterial_hbvdu")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Pivot" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Pivot"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 450
|
||||
theme_override_constants/margin_top = 250
|
||||
theme_override_constants/margin_right = 450
|
||||
theme_override_constants/margin_bottom = 250
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Pivot/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Pivot/MarginContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 15
|
||||
theme_override_constants/margin_top = 15
|
||||
theme_override_constants/margin_right = 15
|
||||
theme_override_constants/margin_bottom = 15
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Settings" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Settings"
|
||||
|
||||
[node name="ExitButton" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Exit"
|
||||
|
||||
[node name="CloseButton" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Close"
|
||||
|
||||
[connection signal="pressed" from="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/Settings" to="." method="_on_settings_pressed"]
|
||||
[connection signal="pressed" from="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"]
|
||||
[connection signal="pressed" from="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/CloseButton" to="." method="_on_close_button_pressed"]
|
||||
|
|
@ -49,6 +49,7 @@ func hide_panel() -> void:
|
|||
|
||||
func _on_panel_hidden() -> void:
|
||||
visible = false
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_close_button_pressed():
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ func show_panel() -> void:
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
mat = panel_container.material
|
||||
mat = panel_container.material.duplicate()
|
||||
pass # Replace with function body.
|
||||
|
||||
func tween_blur(val: float) -> void:
|
||||
|
|
@ -35,6 +35,7 @@ func hide_panel() -> void:
|
|||
|
||||
func _on_panel_hidden() -> void:
|
||||
visible = false
|
||||
queue_free()
|
||||
|
||||
func _on_cancel_pressed():
|
||||
hide_panel()
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ extends Control
|
|||
@onready var exit_button = $PanelContainer/MarginContainer/VBoxContainer/ExitButton
|
||||
@onready var lan_button = $PanelContainer/MarginContainer/VBoxContainer/LANButton
|
||||
|
||||
@onready var rules = $Rules
|
||||
@onready var settings = $Settings
|
||||
const SETTINGS = preload("res://UI/Settings/Settings.tscn")
|
||||
const RULES = preload("res://UI/Rules/Rules.tscn")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
|
@ -35,6 +35,10 @@ func _on_exit_button_pressed():
|
|||
|
||||
|
||||
func _on_rules_button_pressed():
|
||||
var rules = RULES.instantiate()
|
||||
|
||||
get_tree().root.add_child(rules)
|
||||
|
||||
rules.show_panel()
|
||||
|
||||
|
||||
|
|
@ -52,5 +56,8 @@ func _on_local_button_pressed():
|
|||
|
||||
|
||||
func _on_settings_button_pressed():
|
||||
var settings = SETTINGS.instantiate()
|
||||
|
||||
get_tree().root.add_child(settings)
|
||||
|
||||
settings.show_panel()
|
||||
pass # Replace with function body.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dogu37xma5vsp"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dogu37xma5vsp"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/main_menu.gd" id="1_q3q3u"]
|
||||
[ext_resource type="Script" path="res://DisconnectInfo.gd" id="2_2fkdc"]
|
||||
[ext_resource type="PackedScene" uid="uid://8ffmln680deh" path="res://UI/Rules/Rules.tscn" id="2_7qmw6"]
|
||||
[ext_resource type="PackedScene" uid="uid://cua6l3r0yh82y" path="res://UI/Settings/Settings.tscn" id="3_2m2r5"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_47fa1"]
|
||||
bg_color = Color(0, 0, 0, 1)
|
||||
|
|
@ -101,14 +99,6 @@ text = "Rules"
|
|||
layout_mode = 2
|
||||
text = "Exit"
|
||||
|
||||
[node name="Rules" parent="." instance=ExtResource("2_7qmw6")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="Settings" parent="." instance=ExtResource("3_2m2r5")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="DisconnectInfo" type="Control" parent="."]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ custom_template/debug=""
|
|||
custom_template/release=""
|
||||
variant/extensions_support=false
|
||||
vram_texture_compression/for_desktop=true
|
||||
vram_texture_compression/for_mobile=true
|
||||
vram_texture_compression/for_mobile=false
|
||||
html/export_icon=true
|
||||
html/custom_html_shell=""
|
||||
html/head_include=""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue