Start refactoring ui logic+hierarchy
This commit is contained in:
parent
6544c47961
commit
818ac59bb6
13 changed files with 47 additions and 40 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
@ -36,4 +36,4 @@ func disable_cursor() -> void:
|
|||
is_enabled = false
|
||||
|
||||
func enable_cursor() -> void:
|
||||
is_enabled = true
|
||||
is_enabled = true
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -16,9 +17,12 @@ func _unhandled_input(event):
|
|||
hex_clicked.emit(cell_pos, atlas_coords)
|
||||
|
||||
#Example: Place/erase tile on click
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
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
|
||||
#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
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
extends Control
|
||||
extends Node
|
||||
|
||||
@onready var palette: VBoxContainer = %PaletteContainer
|
||||
@onready var map_layer = %GroundMapLayer
|
||||
|
|
@ -19,7 +19,7 @@ func _ready():
|
|||
atlas_texture.atlas = ImageTexture.create_from_image(atlas_image)
|
||||
atlas_texture.region = Rect2(Vector2(0,73),Vector2(72,72)) # x,y,width,height
|
||||
|
||||
var tr = TextureRect.new()
|
||||
var tr = TextureRect.new()
|
||||
tr.texture = atlas_texture
|
||||
|
||||
palette.add_child(tr)
|
||||
|
|
@ -21,4 +21,3 @@ func loadMap(map_file_name):
|
|||
for cell in map.cells:
|
||||
#%GroundMapLayer.get_used_cells() = map.cells
|
||||
print(cell)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ func _ready():
|
|||
|
||||
func load_settings():
|
||||
if FileAccess.file_exists("user://settings.tres"):
|
||||
Global.settings = load("user://settings.tres") as Settings
|
||||
print("Current project dir: {0}".format([Global.settings.current_project_dir]))
|
||||
print("Current map: {0}".format([Global.settings.current_map_name]))
|
||||
Global.settings = load("user://settings.tres") as Settings
|
||||
print("Current project dir: {0}".format([Global.settings.current_project_dir]))
|
||||
print("Current map: {0}".format([Global.settings.current_map_name]))
|
||||
else:
|
||||
# Global data not found, writing default settings
|
||||
# Global data not found, writing default settings
|
||||
save_settings()
|
||||
|
||||
var cur_dir = Global.settings.current_project_dir
|
||||
|
|
@ -26,7 +26,7 @@ func load_settings():
|
|||
print("Loading Map: ({0})".format([full_map_name]))
|
||||
else:
|
||||
if DirAccess.dir_exists_absolute(cur_dir) and len(cur_dir)>0:
|
||||
print("Select Map Dialog, because Dir exists: {0}".format([cur_dir]))
|
||||
print("Select Map Dialog, because Dir exists: {0}".format([cur_dir]))
|
||||
choose_current_map()
|
||||
|
||||
|
||||
|
|
@ -39,8 +39,8 @@ func choose_project_folder():
|
|||
%FileDialog.file_mode = FileDialog.FILE_MODE_OPEN_DIR
|
||||
%FileDialog.set_current_dir( OS.get_system_dir(OS.SYSTEM_DIR_DOCUMENTS) ) # or any other path
|
||||
|
||||
%FileDialog.popup_centered()
|
||||
%FileDialog.dir_selected.connect(func(dir_path):
|
||||
%FileDialog.popup_centered()
|
||||
%FileDialog.dir_selected.connect(func(dir_path):
|
||||
print("Selected directory: ", dir_path)
|
||||
Global.settings.current_project_dir = dir_path
|
||||
save_settings()
|
||||
|
|
@ -65,7 +65,7 @@ func choose_current_map():
|
|||
if not full_filename.ends_with(".tres"): full_filename = full_filename + ".tres"
|
||||
print("Selected file: ", full_filename)
|
||||
var filename:String = full_filename.split("/")[-1]
|
||||
print("Shortname: ", filename)
|
||||
print("Shortname: ", filename)
|
||||
Global.settings.current_map_name = filename
|
||||
save_settings()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue