Start refactoring ui logic+hierarchy

This commit is contained in:
Torsten 2025-09-30 10:25:53 +02:00
parent 6544c47961
commit 818ac59bb6
13 changed files with 47 additions and 40 deletions

View file

@ -1,12 +1,12 @@
[gd_scene load_steps=19 format=4 uid="uid://li0mfftily5e"]
[ext_resource type="Script" uid="uid://dnfabi8ksjvm2" path="res://scenes/MainMap/map_layer_logic.gd" id="1_74o3d"]
[ext_resource type="Script" uid="uid://rxaxc2114upf" path="res://scenes/MainMap/map_manager.gd" id="1_fax2j"]
[ext_resource type="Script" uid="uid://wvdosjbdlsjd" path="res://scenes/MainMap/btn_palette.gd" id="2_fax2j"]
[ext_resource type="Script" uid="uid://dnfabi8ksjvm2" path="res://scenes/MainMap/map/map_layer_logic.gd" id="1_74o3d"]
[ext_resource type="Script" uid="uid://rxaxc2114upf" path="res://scenes/MainMap/map/map_manager.gd" id="1_fax2j"]
[ext_resource type="Script" uid="uid://wvdosjbdlsjd" path="res://scenes/MainMap/ui/btn_palette.gd" id="2_fax2j"]
[ext_resource type="Texture2D" uid="uid://cit5dnn6eoun1" path="res://assets/spritesheets/ui_72x72_spritesheet.png" id="3_gpn0d"]
[ext_resource type="Texture2D" uid="uid://bf0ux0t00blb7" path="res://assets/spritesheets/map_buildings_72x72_spritesheet.png" id="3_kyvod"]
[ext_resource type="Script" uid="uid://bcrhouavyrrm" path="res://scenes/MainMap/cursor_map_layer.gd" id="4_qib1m"]
[ext_resource type="Script" uid="uid://bqj8p0m6qt43k" path="res://scenes/MainMap/cursor_timer.gd" id="5_8wy1m"]
[ext_resource type="Script" uid="uid://bcrhouavyrrm" path="res://scenes/MainMap/map/cursor_map_layer.gd" id="4_qib1m"]
[ext_resource type="Script" uid="uid://bqj8p0m6qt43k" path="res://scenes/MainMap/map/cursor_timer.gd" id="5_8wy1m"]
[ext_resource type="Script" uid="uid://1nbd6r3bgx6i" path="res://scenes/MainMap/resource_saver.gd" id="8_4uh5x"]
[ext_resource type="Script" uid="uid://b5v0k8cmkbrsr" path="res://scenes/MainMap/startup.gd" id="8_y3acc"]
@ -134,7 +134,6 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_fax2j")
[node name="GroundMapLayer" type="TileMapLayer" parent="Map"]
unique_name_in_owner = true
@ -156,9 +155,9 @@ script = ExtResource("4_qib1m")
unique_name_in_owner = true
script = ExtResource("5_8wy1m")
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="UI" type="CanvasLayer" parent="."]
[node name="Palette" type="PanelContainer" parent="CanvasLayer"]
[node name="Palette" type="PanelContainer" parent="UI"]
clip_contents = true
custom_minimum_size = Vector2(80, 80)
anchors_preset = 1
@ -168,12 +167,12 @@ offset_left = -80.0
offset_bottom = 640.0
grow_horizontal = 0
[node name="ScrollContainer" type="ScrollContainer" parent="CanvasLayer/Palette"]
[node name="ScrollContainer" type="ScrollContainer" parent="UI/Palette"]
layout_mode = 2
follow_focus = true
draw_focus_border = true
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/Palette/ScrollContainer"]
[node name="MarginContainer" type="MarginContainer" parent="UI/Palette/ScrollContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 4
@ -181,7 +180,7 @@ theme_override_constants/margin_top = 2
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 2
[node name="PaletteContainer" type="VBoxContainer" parent="CanvasLayer/Palette/ScrollContainer/MarginContainer"]
[node name="PaletteContainer" type="VBoxContainer" parent="UI/Palette/ScrollContainer/MarginContainer"]
unique_name_in_owner = true
clip_contents = true
custom_minimum_size = Vector2(72, 72)
@ -189,28 +188,28 @@ layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="CanvasLayer/Palette/ScrollContainer/MarginContainer/PaletteContainer"]
[node name="Label" type="Label" parent="UI/Palette/ScrollContainer/MarginContainer/PaletteContainer"]
layout_mode = 2
text = "Palette"
horizontal_alignment = 1
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/Palette/ScrollContainer/MarginContainer/PaletteContainer"]
[node name="TextureRect" type="TextureRect" parent="UI/Palette/ScrollContainer/MarginContainer/PaletteContainer"]
layout_mode = 2
mouse_default_cursor_shape = 2
texture = SubResource("CompressedTexture2D_ioj5u")
[node name="TextureRect2" type="TextureRect" parent="CanvasLayer/Palette/ScrollContainer/MarginContainer/PaletteContainer"]
[node name="TextureRect2" type="TextureRect" parent="UI/Palette/ScrollContainer/MarginContainer/PaletteContainer"]
layout_mode = 2
mouse_default_cursor_shape = 2
texture = SubResource("CompressedTexture2D_slrw0")
[node name="MenuTop" type="HBoxContainer" parent="CanvasLayer"]
[node name="MenuTop" type="HBoxContainer" parent="UI"]
offset_right = 227.0
offset_bottom = 40.0
size_flags_horizontal = 0
size_flags_vertical = 0
[node name="opt_map" type="OptionButton" parent="CanvasLayer/MenuTop"]
[node name="opt_map" type="OptionButton" parent="UI/MenuTop"]
layout_mode = 2
selected = 0
item_count = 4
@ -223,14 +222,14 @@ popup/item_2/id = 1
popup/item_3/text = "...speichern als..."
popup/item_3/id = 2
[node name="btn_palette" type="Button" parent="CanvasLayer/MenuTop"]
[node name="btn_palette" type="Button" parent="UI/MenuTop"]
layout_mode = 2
text = "Palette"
script = ExtResource("2_fax2j")
[node name="Dialogs" type="Node2D" parent="CanvasLayer"]
[node name="Dialogs" type="Node2D" parent="UI"]
[node name="FileDialog" type="FileDialog" parent="CanvasLayer/Dialogs"]
[node name="FileDialog" type="FileDialog" parent="UI/Dialogs"]
unique_name_in_owner = true
[node name="Data" type="Node" parent="."]
@ -244,10 +243,13 @@ script = ExtResource("8_4uh5x")
[node name="Startup" type="Node" parent="Logic"]
script = ExtResource("8_y3acc")
[connection signal="mouse_entered" from="CanvasLayer/Palette" to="Map/CursorTimer" method="disable_cursor"]
[connection signal="mouse_exited" from="CanvasLayer/Palette" to="Map/CursorTimer" method="enable_cursor"]
[connection signal="mouse_entered" from="CanvasLayer/MenuTop" to="Map/CursorTimer" method="disable_cursor"]
[connection signal="mouse_exited" from="CanvasLayer/MenuTop" to="Map/CursorTimer" method="enable_cursor"]
[connection signal="mouse_entered" from="CanvasLayer/MenuTop/opt_map" to="Map/CursorTimer" method="disable_cursor"]
[connection signal="mouse_exited" from="CanvasLayer/MenuTop/opt_map" to="Map/CursorTimer" method="enable_cursor"]
[node name="GroundMapManager" type="Node" parent="Logic"]
script = ExtResource("1_fax2j")
[connection signal="mouse_entered" from="UI/Palette" to="Map/CursorTimer" method="disable_cursor"]
[connection signal="mouse_exited" from="UI/Palette" to="Map/CursorTimer" method="enable_cursor"]
[connection signal="mouse_entered" from="UI/MenuTop" to="Map/CursorTimer" method="disable_cursor"]
[connection signal="mouse_exited" from="UI/MenuTop" to="Map/CursorTimer" method="enable_cursor"]
[connection signal="mouse_entered" from="UI/MenuTop/opt_map" to="Map/CursorTimer" method="disable_cursor"]
[connection signal="mouse_exited" from="UI/MenuTop/opt_map" to="Map/CursorTimer" method="enable_cursor"]
[connection signal="selected_map_for_loading" from="Logic/Startup" to="Data/ResourceSaver" method="loadMap"]

View file

@ -3,3 +3,5 @@ extends TileMapLayer
func _unhandled_input(event):
if event is InputEventMouseButton:
print("A click reached the ui layer")
else:
print("Non UI-Layer click")

View file

@ -3,6 +3,7 @@ extends TileMapLayer
signal hex_clicked(cell_pos:Vector2, atlas_coords:Vector2)
func _unhandled_input(event):
print("Unhandled input")
if event is InputEventMouseButton:
if event.pressed==false: return
@ -17,8 +18,11 @@ func _unhandled_input(event):
#Example: Place/erase tile on click
if event.button_index == MOUSE_BUTTON_LEFT:
print("Click left")
#pass
#set_cell(cell_pos, 51, Vector2i(6, 1)) # Place tile
set_cell(cell_pos, 0, Vector2i(1, 2)) # Place tile
elif event.button_index == MOUSE_BUTTON_RIGHT:
print("Click right")
set_cell(cell_pos, -1) # Erase tile

View file

@ -1,4 +1,4 @@
extends Control
extends Node
@onready var palette: VBoxContainer = %PaletteContainer
@onready var map_layer = %GroundMapLayer

View file

@ -21,4 +21,3 @@ func loadMap(map_file_name):
for cell in map.cells:
#%GroundMapLayer.get_used_cells() = map.cells
print(cell)