Add menu for tile type changing
This commit is contained in:
parent
ea387c1bbb
commit
c50caefc6f
|
@ -81,7 +81,12 @@ LMC={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":84,"key_label":0,"unicode":116,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":84,"key_label":0,"unicode":116,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
ingame_menu={
|
game_menu={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
escape_menu={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://csfa8wr1fbfb2"]
|
[gd_scene load_steps=3 format=3 uid="uid://csfa8wr1fbfb2"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/ingame_menu.gd" id="1_swq50"]
|
[ext_resource type="Script" path="res://scripts/ingame_menu.gd" id="1_ln8gu"]
|
||||||
[ext_resource type="Script" path="res://scripts/m_button.gd" id="2_cehp5"]
|
[ext_resource type="Script" path="res://scripts/m_button.gd" id="2_tsmj0"]
|
||||||
|
|
||||||
[node name="ingame_menu" type="Control"]
|
[node name="ingame_menu" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
|
@ -10,7 +10,7 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_swq50")
|
script = ExtResource("1_ln8gu")
|
||||||
|
|
||||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||||
modulate = Color(1, 1, 1, 0.501961)
|
modulate = Color(1, 1, 1, 0.501961)
|
||||||
|
@ -48,7 +48,7 @@ offset_bottom = -14.0
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
text = "Save world"
|
text = "Save world"
|
||||||
script = ExtResource("2_cehp5")
|
script = ExtResource("2_tsmj0")
|
||||||
|
|
||||||
[node name="save_exit_button" type="Button" parent="Buttons"]
|
[node name="save_exit_button" type="Button" parent="Buttons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@ -59,7 +59,7 @@ offset_bottom = 53.0
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
text = "Save and exit game"
|
text = "Save and exit game"
|
||||||
script = ExtResource("2_cehp5")
|
script = ExtResource("2_tsmj0")
|
||||||
|
|
||||||
[node name="exit_nosave_button" type="Button" parent="Buttons"]
|
[node name="exit_nosave_button" type="Button" parent="Buttons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@ -70,4 +70,4 @@ offset_bottom = 243.0
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
text = "exit without saving"
|
text = "exit without saving"
|
||||||
script = ExtResource("2_cehp5")
|
script = ExtResource("2_tsmj0")
|
|
@ -1,8 +1,20 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://bs7ctvbx7xov5"]
|
[gd_scene load_steps=7 format=3 uid="uid://bs7ctvbx7xov5"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/ingame_menu.gd" id="1_6fvrf"]
|
[ext_resource type="Script" path="res://scripts/ingame_menu.gd" id="1_6fvrf"]
|
||||||
[ext_resource type="Script" path="res://scripts/menu_button.gd" id="2_n0jsa"]
|
[ext_resource type="Script" path="res://scripts/menu_button.gd" id="2_n0jsa"]
|
||||||
|
|
||||||
|
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_0ge5s"]
|
||||||
|
size = Vector2(64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_pitss"]
|
||||||
|
size = Vector2(64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_j1lo1"]
|
||||||
|
size = Vector2(64, 64)
|
||||||
|
|
||||||
|
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_23dg4"]
|
||||||
|
size = Vector2(64, 64)
|
||||||
|
|
||||||
[node name="UI" type="Control"]
|
[node name="UI" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
@ -12,7 +24,7 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
|
||||||
[node name="ingame_menu" type="Control" parent="."]
|
[node name="escape_menu" type="Control" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
@ -22,7 +34,7 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_6fvrf")
|
script = ExtResource("1_6fvrf")
|
||||||
|
|
||||||
[node name="PanelContainer" type="PanelContainer" parent="ingame_menu"]
|
[node name="PanelContainer" type="PanelContainer" parent="escape_menu"]
|
||||||
modulate = Color(1, 1, 1, 0.501961)
|
modulate = Color(1, 1, 1, 0.501961)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
@ -35,7 +47,7 @@ offset_bottom = -93.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="Buttons" type="Control" parent="ingame_menu"]
|
[node name="Buttons" type="Control" parent="escape_menu"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
@ -49,7 +61,7 @@ offset_bottom = 20.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="save_world_button" type="Button" parent="ingame_menu/Buttons"]
|
[node name="save_world_button" type="Button" parent="escape_menu/Buttons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_left = -45.0
|
offset_left = -45.0
|
||||||
offset_top = -45.0
|
offset_top = -45.0
|
||||||
|
@ -60,7 +72,7 @@ size_flags_vertical = 4
|
||||||
text = "Save world"
|
text = "Save world"
|
||||||
script = ExtResource("2_n0jsa")
|
script = ExtResource("2_n0jsa")
|
||||||
|
|
||||||
[node name="save_exit_button" type="Button" parent="ingame_menu/Buttons"]
|
[node name="save_exit_button" type="Button" parent="escape_menu/Buttons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_left = -71.0
|
offset_left = -71.0
|
||||||
offset_top = 22.0
|
offset_top = 22.0
|
||||||
|
@ -71,7 +83,7 @@ size_flags_vertical = 4
|
||||||
text = "Save and exit game"
|
text = "Save and exit game"
|
||||||
script = ExtResource("2_n0jsa")
|
script = ExtResource("2_n0jsa")
|
||||||
|
|
||||||
[node name="exit_nosave_button" type="Button" parent="ingame_menu/Buttons"]
|
[node name="exit_nosave_button" type="Button" parent="escape_menu/Buttons"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_left = 334.0
|
offset_left = 334.0
|
||||||
offset_top = 212.0
|
offset_top = 212.0
|
||||||
|
@ -82,33 +94,80 @@ size_flags_vertical = 4
|
||||||
text = "exit without saving"
|
text = "exit without saving"
|
||||||
script = ExtResource("2_n0jsa")
|
script = ExtResource("2_n0jsa")
|
||||||
|
|
||||||
[node name="velocity_label" type="Label" parent="."]
|
[node name="game_overlay" type="Control" parent="."]
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
mouse_filter = 1
|
||||||
|
|
||||||
|
[node name="velocity_label" type="Label" parent="game_overlay"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 1
|
anchors_preset = 1
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
offset_left = -40.0
|
offset_left = 1060.0
|
||||||
|
offset_right = 1112.0
|
||||||
offset_bottom = 23.0
|
offset_bottom = 23.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
text = "Speed:"
|
text = "Speed:"
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="."]
|
[node name="Panel" type="Panel" parent="game_overlay"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
offset_left = -4.0
|
offset_left = 552.0
|
||||||
offset_top = -4.0
|
offset_top = 300.0
|
||||||
offset_right = 4.0
|
offset_right = 560.0
|
||||||
offset_bottom = 4.0
|
offset_bottom = 308.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
|
||||||
[node name="tile_type_label" type="Label" parent="."]
|
[node name="tile_type_label" type="Label" parent="game_overlay"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 40.0
|
offset_right = 113.0
|
||||||
offset_bottom = 23.0
|
offset_bottom = 23.0
|
||||||
text = "Tile type: Plain"
|
text = "Tile type: Plain"
|
||||||
|
|
||||||
|
[node name="game_menu" type="Control" parent="."]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_6fvrf")
|
||||||
|
|
||||||
|
[node name="Panel" type="Panel" parent="game_menu"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 40.0
|
||||||
|
offset_top = 40.0
|
||||||
|
offset_right = -40.0
|
||||||
|
offset_bottom = -40.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="powers_list" type="ItemList" parent="game_menu/Panel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 9
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_right = 387.0
|
||||||
|
grow_vertical = 2
|
||||||
|
allow_reselect = true
|
||||||
|
item_count = 4
|
||||||
|
max_columns = 3
|
||||||
|
item_0/text = "Empty"
|
||||||
|
item_0/icon = SubResource("PlaceholderTexture2D_0ge5s")
|
||||||
|
item_1/text = "Plain"
|
||||||
|
item_1/icon = SubResource("PlaceholderTexture2D_pitss")
|
||||||
|
item_2/text = "Forest"
|
||||||
|
item_2/icon = SubResource("PlaceholderTexture2D_j1lo1")
|
||||||
|
item_3/text = "Lake"
|
||||||
|
item_3/icon = SubResource("PlaceholderTexture2D_23dg4")
|
||||||
|
|
|
@ -8,6 +8,9 @@ var walk = 0.25
|
||||||
@onready var ui = $"./UI"
|
@onready var ui = $"./UI"
|
||||||
@onready var velocity_label: Label = ui.find_child("velocity_label")
|
@onready var velocity_label: Label = ui.find_child("velocity_label")
|
||||||
@onready var tile_type_label: Label = ui.find_child("tile_type_label")
|
@onready var tile_type_label: Label = ui.find_child("tile_type_label")
|
||||||
|
@onready var escape_menu: Control = ui.find_child("escape_menu")
|
||||||
|
@onready var game_menu: Control = ui.find_child("game_menu")
|
||||||
|
@onready var powers_list: ItemList = ui.find_child("powers_list")
|
||||||
|
|
||||||
@onready var eye_raycast: RayCast3D = $"./Camera/eye"
|
@onready var eye_raycast: RayCast3D = $"./Camera/eye"
|
||||||
@onready var earth = $"../Earth"
|
@onready var earth = $"../Earth"
|
||||||
|
@ -19,11 +22,12 @@ enum TileType {
|
||||||
Lake
|
Lake
|
||||||
}
|
}
|
||||||
|
|
||||||
var creating_tile_type = TileType.Plain
|
var creating_tile_type = TileType.Empty
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
camera.make_current()
|
camera.make_current()
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
setup_ui()
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if Input.is_action_pressed("MWU"):
|
if Input.is_action_pressed("MWU"):
|
||||||
|
@ -38,27 +42,34 @@ func _unhandled_input(event):
|
||||||
camera.rotate_x(-event.relative.y * SENSETIVITY)
|
camera.rotate_x(-event.relative.y * SENSETIVITY)
|
||||||
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-90), deg_to_rad(90))
|
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-90), deg_to_rad(90))
|
||||||
|
|
||||||
func _physics_process(delta):
|
func switch_tile_type(type, _a, _b):
|
||||||
|
game_menu.visible = false
|
||||||
|
creating_tile_type = type
|
||||||
|
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
func setup_ui():
|
||||||
|
powers_list.item_clicked.connect(switch_tile_type)
|
||||||
|
|
||||||
|
func update_ui():
|
||||||
velocity_label.text = "Velocity: " + str(walk)
|
velocity_label.text = "Velocity: " + str(walk)
|
||||||
|
tile_type_label.text = "Tile type: " + str(TileType.keys()[creating_tile_type])
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
update_ui()
|
||||||
|
|
||||||
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
||||||
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
var velocity = Vector3.ZERO
|
var velocity = Vector3.ZERO
|
||||||
var speed
|
var speed
|
||||||
|
|
||||||
if Input.is_action_just_pressed("tile type loop"):
|
if Input.is_action_just_pressed("LMC") and eye_raycast.is_colliding():
|
||||||
creating_tile_type = wrap(creating_tile_type + 1, 0, TileType.size())
|
|
||||||
tile_type_label.text = "Tile type: " + str(TileType.keys()[creating_tile_type])
|
|
||||||
|
|
||||||
if Input.is_action_just_pressed("LMC") and eye_raycast.is_colliding() and !get_node("UI/ingame_menu").visible:
|
|
||||||
var target = eye_raycast.get_collider()
|
var target = eye_raycast.get_collider()
|
||||||
if "TileType" in target:
|
if "TileType" in target:
|
||||||
#earth.mark_free_tiles()
|
|
||||||
target.tile_type = creating_tile_type
|
target.tile_type = creating_tile_type
|
||||||
target.update_tile()
|
target.update_tile()
|
||||||
earth.mark_empty_tiles()
|
earth.mark_empty_tiles()
|
||||||
|
|
||||||
|
|
||||||
if Input.is_action_pressed("run"):
|
if Input.is_action_pressed("run"):
|
||||||
speed = walk * 2
|
speed = walk * 2
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
func _ready():
|
@onready var God = get_tree().root.get_node("world/God")
|
||||||
#visible = false
|
|
||||||
pass
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if Input.is_action_just_pressed("ingame_menu"):
|
if Input.is_action_just_pressed(name):
|
||||||
self.visible = !self.visible
|
self.visible = !self.visible
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE if self.visible else Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE if self.visible else Input.MOUSE_MODE_CAPTURED)
|
||||||
|
God.get_node("Camera/eye").enabled = !self.visible
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue