diff --git a/Globals/GameData.gd b/Globals/GameData.gd new file mode 100644 index 0000000..11eca81 --- /dev/null +++ b/Globals/GameData.gd @@ -0,0 +1,3 @@ +extends Node + +var is_player_black: bool = false diff --git a/Globals/GameEvents.gd b/Globals/GameEvents.gd index d58749b..8b1dd01 100644 --- a/Globals/GameEvents.gd +++ b/Globals/GameEvents.gd @@ -6,7 +6,7 @@ signal insect_placement_cancelled signal insect_tile_selected(tile) signal insect_tile_deselected(tile) -signal insect_tile_moved(tile, from, to) +signal insect_tile_moved(tile, to) signal turn_started signal turn_ended diff --git a/HexGrid3D/HexGrid3D.gd b/HexGrid3D/HexGrid3D.gd index 174ae2b..f489ef9 100644 --- a/HexGrid3D/HexGrid3D.gd +++ b/HexGrid3D/HexGrid3D.gd @@ -1,4 +1,5 @@ extends Node3D +class_name HexGrid @onready var placement_visualizer = $PlacementVisualizer @@ -17,8 +18,22 @@ const size: float = 0.5 var used_cells: Dictionary = {} @export var layer_height: float = 0.4 + +# have all used_cells be saved as Vector4i (q, r, s, y) - +class CellStorage: + var cells: Dictionary = {} + + func add_cell(coords: CubeCoordinates, layer: int = 0) -> void: + pass + + func remove_cell(coords: CubeCoordinates, layer: int = 0) -> void: + pass + + func has_cell(cords: CubeCoordinates, layer: int = 0) -> bool: + return false + + class CubeCoordinates: var q: float @@ -103,6 +118,12 @@ func get_3d_pos(position2D: Vector2): var placements: Dictionary = {} +func is_cell_empty(coords: Vector2i) -> bool: + return !used_cells.has(coords) + +func get_empty_neighbours(coords: Vector2i) -> Array[Vector2i]: + return get_neighbours(coords).filter(is_cell_empty) + func get_neighbours(coords: Vector2i) -> Array[Vector2i]: return [ Vector2i(coords.x + 1, coords.y), Vector2i(coords.x + 1, coords.y - 1), Vector2i(coords.x, coords.y - 1), @@ -209,6 +230,7 @@ func _on_insect_placed(resource: TileResource, is_black: bool, pos: Vector2i) -> tile_copy.position = Vector3(hex_pos.x, 20.0, hex_pos.y) tile_copy.resource = resource tile_copy.is_black = is_black + tile_copy.coordinates = pos var target_pos = Vector3(hex_pos.x, 0.0, hex_pos.y) used_cells[Vector2i(pos.x, pos.y)] = tile_copy @@ -218,11 +240,53 @@ func _on_insect_placed(resource: TileResource, is_black: bool, pos: Vector2i) -> var tween = get_tree().create_tween() tween.tween_property(tile_copy, "position", target_pos, 1.0).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_EXPO) +func _on_insect_tile_selected(tile: InsectTile) -> void: + if tile.resource.movement_behaviour == null: + return + + var pos = world_to_hex_tile(Vector2(tile.position.x, tile.position.z)) + var spaces = tile.resource.movement_behaviour.get_available_spaces(Vector2i(pos.q, pos.r), self) + + for space in spaces: + var outline = HEX_OUTLINE.instantiate() + var hex_pos = flat_hex_to_world_position(AxialCoordinates.new(space.x, space.y)) + outline.position = Vector3(hex_pos.x, 0.0, hex_pos.y) + outline.hex_pos = space + outline.visible = true + outline.insect_tile = tile + outline.is_moving = true + outline.insect_resource = tile.resource + outline.is_black = tile.is_black + placement_visualizer.add_child(outline) + placements[space] = outline + + +func _on_insect_tile_moved(tile: InsectTile, target: Vector2i) -> void: + used_cells.erase(tile.coordinates) + + var new_hex_pos = flat_hex_to_world_position(AxialCoordinates.new(target.x, target.y)) + var sky_new_hex_pos = Vector3(new_hex_pos.x, 20.0, new_hex_pos.y) + var ground_new_hex_pos = Vector3(new_hex_pos.x, 0.0, new_hex_pos.y) + # + var current_hex_pos = tile.position + var sky_current_hex_pos = tile.position + Vector3(0.0, 20.0, 0.0) +# + var tween = get_tree().create_tween() + tween.tween_property(tile, "position", sky_current_hex_pos, 0.5).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_EXPO) + tween.tween_property(tile, "position", sky_new_hex_pos, 0.0) + tween.tween_property(tile, "position", ground_new_hex_pos, 1.0).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_EXPO) + + tile.coordinates = target + + used_cells[target] = tile + func _ready() -> void: GameEvents.insect_selected.connect(_on_insect_selected) GameEvents.insect_placement_cancelled.connect(_on_insect_placement_cancelled) GameEvents.insect_placed.connect(_on_insect_placed) - + GameEvents.insect_tile_selected.connect(_on_insect_tile_selected) + GameEvents.insect_tile_moved.connect(_on_insect_tile_moved) + return for x in range(-6, 5): diff --git a/HexOutline.gd b/HexOutline.gd index 6f525fc..d76a793 100644 --- a/HexOutline.gd +++ b/HexOutline.gd @@ -5,10 +5,14 @@ var hovered: bool = false var insect_resource: TileResource var is_black: bool = false +var insect_tile: InsectTile + var hex_pos: Vector2i = Vector2i.ZERO var tile: Node3D +var is_moving: bool = false + const BUILD_GHOST = preload("res://InsectTiles/BuildGhost.tscn") # Called when the node enters the scene tree for the first time. func _ready(): @@ -16,7 +20,13 @@ func _ready(): print("Should not happen!") return - GameEvents.insect_placed.connect(_on_insect_placed) + if is_moving: + GameEvents.insect_tile_moved.connect(_on_insect_tile_moved) + else: + GameEvents.insect_placed.connect(_on_insect_placed) + +func _on_insect_tile_moved(tile: InsectTile, to: Vector2i) -> void: + queue_free() func _on_insect_placed(resource: TileResource, is_black: bool, pos: Vector2i) -> void: queue_free() @@ -25,11 +35,11 @@ func _on_insect_placed(resource: TileResource, is_black: bool, pos: Vector2i) -> func _process(delta): if Input.is_action_just_pressed("place_tile"): if hovered: - GameEvents.insect_placed.emit(insect_resource, is_black, hex_pos) - print("Place me pls") - pass - - + if is_moving: + GameEvents.insect_tile_moved.emit(insect_tile, hex_pos) + else: + GameEvents.insect_placed.emit(insect_resource, is_black, hex_pos) + func _on_mouse_entered(): hovered = true diff --git a/InsectTiles/Assets/Roughness/ant_roughness.png b/InsectTiles/Assets/Roughness/ant_roughness.png index 9de3d50..0c66bc8 100644 Binary files a/InsectTiles/Assets/Roughness/ant_roughness.png and b/InsectTiles/Assets/Roughness/ant_roughness.png differ diff --git a/InsectTiles/Assets/Roughness/bee_roughness.png b/InsectTiles/Assets/Roughness/bee_roughness.png index 0795330..9d0a523 100644 Binary files a/InsectTiles/Assets/Roughness/bee_roughness.png and b/InsectTiles/Assets/Roughness/bee_roughness.png differ diff --git a/InsectTiles/Assets/Roughness/beetle_roughness.png b/InsectTiles/Assets/Roughness/beetle_roughness.png index 5bddbac..968b8e9 100644 Binary files a/InsectTiles/Assets/Roughness/beetle_roughness.png and b/InsectTiles/Assets/Roughness/beetle_roughness.png differ diff --git a/InsectTiles/Assets/Roughness/grasshopper_roughness.png b/InsectTiles/Assets/Roughness/grasshopper_roughness.png index 31e9a5f..5f33fcb 100644 Binary files a/InsectTiles/Assets/Roughness/grasshopper_roughness.png and b/InsectTiles/Assets/Roughness/grasshopper_roughness.png differ diff --git a/InsectTiles/Assets/Roughness/ladybug_roughness.png b/InsectTiles/Assets/Roughness/ladybug_roughness.png index 5fa7e09..8a1bdb1 100644 Binary files a/InsectTiles/Assets/Roughness/ladybug_roughness.png and b/InsectTiles/Assets/Roughness/ladybug_roughness.png differ diff --git a/InsectTiles/Assets/Roughness/mosquito_roughness.png b/InsectTiles/Assets/Roughness/mosquito_roughness.png index 8c3cea5..77a2556 100644 Binary files a/InsectTiles/Assets/Roughness/mosquito_roughness.png and b/InsectTiles/Assets/Roughness/mosquito_roughness.png differ diff --git a/InsectTiles/Assets/Roughness/pillbug_roughness.png b/InsectTiles/Assets/Roughness/pillbug_roughness.png index fe24d42..ab447d7 100644 Binary files a/InsectTiles/Assets/Roughness/pillbug_roughness.png and b/InsectTiles/Assets/Roughness/pillbug_roughness.png differ diff --git a/InsectTiles/Assets/Roughness/spider_roughness.png b/InsectTiles/Assets/Roughness/spider_roughness.png index bbd0a76..bb8c648 100644 Binary files a/InsectTiles/Assets/Roughness/spider_roughness.png and b/InsectTiles/Assets/Roughness/spider_roughness.png differ diff --git a/InsectTiles/Assets/Textures/ant_black.png b/InsectTiles/Assets/Textures/ant_black.png index c08ac2d..d8c2916 100644 Binary files a/InsectTiles/Assets/Textures/ant_black.png and b/InsectTiles/Assets/Textures/ant_black.png differ diff --git a/InsectTiles/Assets/Textures/ant_white.png b/InsectTiles/Assets/Textures/ant_white.png index c312f93..43c1dcb 100644 Binary files a/InsectTiles/Assets/Textures/ant_white.png and b/InsectTiles/Assets/Textures/ant_white.png differ diff --git a/InsectTiles/Assets/Textures/bee_black.png b/InsectTiles/Assets/Textures/bee_black.png index c869a2a..86c51da 100644 Binary files a/InsectTiles/Assets/Textures/bee_black.png and b/InsectTiles/Assets/Textures/bee_black.png differ diff --git a/InsectTiles/Assets/Textures/bee_white.png b/InsectTiles/Assets/Textures/bee_white.png index e8c4a43..cc431a4 100644 Binary files a/InsectTiles/Assets/Textures/bee_white.png and b/InsectTiles/Assets/Textures/bee_white.png differ diff --git a/InsectTiles/Assets/Textures/beetle_black.png b/InsectTiles/Assets/Textures/beetle_black.png index 42f5aff..7b38196 100644 Binary files a/InsectTiles/Assets/Textures/beetle_black.png and b/InsectTiles/Assets/Textures/beetle_black.png differ diff --git a/InsectTiles/Assets/Textures/beetle_white.png b/InsectTiles/Assets/Textures/beetle_white.png index 45fa832..126f9f2 100644 Binary files a/InsectTiles/Assets/Textures/beetle_white.png and b/InsectTiles/Assets/Textures/beetle_white.png differ diff --git a/InsectTiles/Assets/Textures/grasshopper_black.png b/InsectTiles/Assets/Textures/grasshopper_black.png index d7730b2..7b4042c 100644 Binary files a/InsectTiles/Assets/Textures/grasshopper_black.png and b/InsectTiles/Assets/Textures/grasshopper_black.png differ diff --git a/InsectTiles/Assets/Textures/grasshopper_white.png b/InsectTiles/Assets/Textures/grasshopper_white.png index 3081383..c7442b5 100644 Binary files a/InsectTiles/Assets/Textures/grasshopper_white.png and b/InsectTiles/Assets/Textures/grasshopper_white.png differ diff --git a/InsectTiles/Assets/Textures/ladybug_black.png b/InsectTiles/Assets/Textures/ladybug_black.png index 06b81c2..7d8fe31 100644 Binary files a/InsectTiles/Assets/Textures/ladybug_black.png and b/InsectTiles/Assets/Textures/ladybug_black.png differ diff --git a/InsectTiles/Assets/Textures/ladybug_white.png b/InsectTiles/Assets/Textures/ladybug_white.png index f1f800a..b51bb44 100644 Binary files a/InsectTiles/Assets/Textures/ladybug_white.png and b/InsectTiles/Assets/Textures/ladybug_white.png differ diff --git a/InsectTiles/Assets/Textures/mosquito_black.png b/InsectTiles/Assets/Textures/mosquito_black.png index 8e29677..a28c83e 100644 Binary files a/InsectTiles/Assets/Textures/mosquito_black.png and b/InsectTiles/Assets/Textures/mosquito_black.png differ diff --git a/InsectTiles/Assets/Textures/mosquito_white.png b/InsectTiles/Assets/Textures/mosquito_white.png index a1f2d97..e177a24 100644 Binary files a/InsectTiles/Assets/Textures/mosquito_white.png and b/InsectTiles/Assets/Textures/mosquito_white.png differ diff --git a/InsectTiles/Assets/Textures/pillbug_black.png b/InsectTiles/Assets/Textures/pillbug_black.png index 0dba77a..b6ff31d 100644 Binary files a/InsectTiles/Assets/Textures/pillbug_black.png and b/InsectTiles/Assets/Textures/pillbug_black.png differ diff --git a/InsectTiles/Assets/Textures/pillbug_white.png b/InsectTiles/Assets/Textures/pillbug_white.png index f8cb507..4f25626 100644 Binary files a/InsectTiles/Assets/Textures/pillbug_white.png and b/InsectTiles/Assets/Textures/pillbug_white.png differ diff --git a/InsectTiles/Assets/Textures/spider_black.png b/InsectTiles/Assets/Textures/spider_black.png index a068600..2c7f086 100644 Binary files a/InsectTiles/Assets/Textures/spider_black.png and b/InsectTiles/Assets/Textures/spider_black.png differ diff --git a/InsectTiles/Assets/Textures/spider_white.png b/InsectTiles/Assets/Textures/spider_white.png index f277c1e..b029ada 100644 Binary files a/InsectTiles/Assets/Textures/spider_white.png and b/InsectTiles/Assets/Textures/spider_white.png differ diff --git a/InsectTiles/Assets/UI/ant.png b/InsectTiles/Assets/UI/ant.png index 6c45dd6..188eed2 100644 Binary files a/InsectTiles/Assets/UI/ant.png and b/InsectTiles/Assets/UI/ant.png differ diff --git a/InsectTiles/Assets/UI/bee.png b/InsectTiles/Assets/UI/bee.png index 98e8e8c..14911b4 100644 Binary files a/InsectTiles/Assets/UI/bee.png and b/InsectTiles/Assets/UI/bee.png differ diff --git a/InsectTiles/Assets/UI/beetle.png b/InsectTiles/Assets/UI/beetle.png index 84cae50..8c7690c 100644 Binary files a/InsectTiles/Assets/UI/beetle.png and b/InsectTiles/Assets/UI/beetle.png differ diff --git a/InsectTiles/Assets/UI/grasshopper.png b/InsectTiles/Assets/UI/grasshopper.png index 6ce56b1..e42f6d4 100644 Binary files a/InsectTiles/Assets/UI/grasshopper.png and b/InsectTiles/Assets/UI/grasshopper.png differ diff --git a/InsectTiles/Assets/UI/ladybug.png b/InsectTiles/Assets/UI/ladybug.png index 00e36d7..aa35633 100644 Binary files a/InsectTiles/Assets/UI/ladybug.png and b/InsectTiles/Assets/UI/ladybug.png differ diff --git a/InsectTiles/Assets/UI/mosquito.png b/InsectTiles/Assets/UI/mosquito.png index 83748fb..fb001a3 100644 Binary files a/InsectTiles/Assets/UI/mosquito.png and b/InsectTiles/Assets/UI/mosquito.png differ diff --git a/InsectTiles/Assets/UI/pillbug.png b/InsectTiles/Assets/UI/pillbug.png index 3797de2..fee70c7 100644 Binary files a/InsectTiles/Assets/UI/pillbug.png and b/InsectTiles/Assets/UI/pillbug.png differ diff --git a/InsectTiles/Assets/UI/spider.png b/InsectTiles/Assets/UI/spider.png index 7ddaed2..59fd103 100644 Binary files a/InsectTiles/Assets/UI/spider.png and b/InsectTiles/Assets/UI/spider.png differ diff --git a/InsectTiles/HoverShader.gdshader b/InsectTiles/HoverShader.gdshader new file mode 100644 index 0000000..47357d6 --- /dev/null +++ b/InsectTiles/HoverShader.gdshader @@ -0,0 +1,24 @@ +shader_type spatial; +//Simple 3D shader to create a force-field effect inspired by Faultless Defense from Guilty Gear Xrd. +//In summary, it takes logic used for simple rim lighting and uses it to create the alpha instead. + +render_mode unshaded;//depth_test_disable; +uniform vec4 albedo : source_color; +uniform vec4 emission_color : source_color; +uniform float emission_amount: hint_range(0.0, 16.0) = 5.0f; +uniform float rim_steepness : hint_range(0.0f, 16.0f) = 3.0f; //higher values mean a smaller rim. + + +void vertex() { + //UV=UV*uv_scale.xy+uv_offset.xy; +} + +void fragment() { + vec2 base_uv = UV; + ALBEDO = albedo.rgb; + EMISSION = emission_color.rgb * emission_amount; + //float PI = 3.14159265359; + float NdotV = dot(NORMAL, VIEW); + float rim_light = pow(1.0 - NdotV, rim_steepness); + ALPHA = rim_light * emission_color.a; +} \ No newline at end of file diff --git a/InsectTiles/HoverShader.tres b/InsectTiles/HoverShader.tres new file mode 100644 index 0000000..1d737b1 --- /dev/null +++ b/InsectTiles/HoverShader.tres @@ -0,0 +1,11 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://v74ro6pmr4hw"] + +[ext_resource type="Shader" path="res://InsectTiles/HoverShader.gdshader" id="1_pk3ok"] + +[resource] +render_priority = 0 +shader = ExtResource("1_pk3ok") +shader_parameter/albedo = Color(0, 0, 0, 1) +shader_parameter/emission_color = Color(0, 0, 0, 1) +shader_parameter/emission_amount = 5.0 +shader_parameter/rim_steepness = 0.214 diff --git a/InsectTiles/InsectTile.tscn b/InsectTiles/InsectTile.tscn index 3d94fb1..5424783 100644 --- a/InsectTiles/InsectTile.tscn +++ b/InsectTiles/InsectTile.tscn @@ -22,3 +22,6 @@ surface_material_override/0 = SubResource("StandardMaterial3D_80f17") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("ConcavePolygonShape3D_oy7nn") + +[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] +[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"] diff --git a/MovementBehaviour/MovementBehaviourResource.gd b/MovementBehaviour/MovementBehaviourResource.gd index 2229689..7be5346 100644 --- a/MovementBehaviour/MovementBehaviourResource.gd +++ b/MovementBehaviour/MovementBehaviourResource.gd @@ -1,5 +1,5 @@ extends Resource class_name MovementBehaviour -func get_available_spaces() -> Array: +func get_available_spaces(pos: Vector2i, map: HexGrid) -> Array[Vector2i]: return [] diff --git a/MovementBehaviour/Prefabs/MovementBehaviourBee.gd b/MovementBehaviour/Prefabs/MovementBehaviourBee.gd index 515c3b8..7f8cdef 100644 --- a/MovementBehaviour/Prefabs/MovementBehaviourBee.gd +++ b/MovementBehaviour/Prefabs/MovementBehaviourBee.gd @@ -1,2 +1,38 @@ extends MovementBehaviour class_name MovementBehaviourBee + +func can_reach(start: Vector2i, target: Vector2i, map: HexGrid) -> bool: + # if we have 5 potential spaces it can never be blocked + var cubepos: HexGrid.CubeCoordinates = map.axial_to_cube(HexGrid.AxialCoordinates.new(start.x, start.y)) + var cubecoord = map.axial_to_cube(HexGrid.AxialCoordinates.new(target.x, target.y)) + + var cubetest: HexGrid.CubeCoordinates = map.axial_to_cube(HexGrid.AxialCoordinates.new(0, 0)) + + cubetest.q = cubecoord.q - cubepos.q + cubetest.r = cubecoord.r - cubepos.r + cubetest.s = cubecoord.s - cubepos.s + + var left = get_left_neighbour(Vector3i(cubetest.q, cubetest.r, cubetest.s)) + var right = get_right_neighbour(Vector3i(cubetest.q, cubetest.r, cubetest.s)) + + var left_coord = map.cube_to_axial(HexGrid.CubeCoordinates.new(left.x + cubepos.q, left.y + cubepos.r, left.z + cubepos.s)) + var right_coord = map.cube_to_axial(HexGrid.CubeCoordinates.new(right.x + cubepos.q, right.y + cubepos.r, right.z + cubepos.s)) + + return map.is_cell_empty(Vector2i(left_coord.q, left_coord.r)) or map.is_cell_empty(Vector2i(right_coord.q, right_coord.r)) + +func get_left_neighbour(pos: Vector3i) -> Vector3i: + return Vector3(-pos.z, -pos.x, -pos.y) + +func get_right_neighbour(pos: Vector3i) -> Vector3i: + return Vector3(-pos.y, -pos.z, -pos.x) + +func get_available_spaces(pos: Vector2i, map: HexGrid) -> Array[Vector2i]: + var potential_spaces = map.get_empty_neighbours(pos) + + var target_spaces: Array[Vector2i] = [] + + for neighbour in potential_spaces: + if can_reach(pos, neighbour, map): + target_spaces.append(neighbour) + + return target_spaces diff --git a/Tile/Prefabs/Bee.tres b/Tile/Prefabs/Bee.tres index 355cff5..102cbaf 100644 --- a/Tile/Prefabs/Bee.tres +++ b/Tile/Prefabs/Bee.tres @@ -1,13 +1,18 @@ -[gd_resource type="Resource" script_class="TileResource" load_steps=5 format=3 uid="uid://b70uxn2ofij8y"] +[gd_resource type="Resource" script_class="TileResource" load_steps=7 format=3 uid="uid://b70uxn2ofij8y"] [ext_resource type="Material" uid="uid://b5rer8wc62ck3" path="res://InsectTiles/Materials/Bee_Black.tres" id="1_0fgqy"] [ext_resource type="Script" path="res://Tile/TileResource.gd" id="1_o55be"] [ext_resource type="Material" uid="uid://d4hyq81yydmpr" path="res://InsectTiles/Materials/Bee_White.tres" id="2_qr48e"] +[ext_resource type="Script" path="res://MovementBehaviour/Prefabs/MovementBehaviourBee.gd" id="3_eudvd"] [ext_resource type="Texture2D" uid="uid://dkfybq7qex2og" path="res://InsectTiles/Assets/UI/bee.png" id="4_1he20"] +[sub_resource type="Resource" id="Resource_puwjs"] +script = ExtResource("3_eudvd") + [resource] script = ExtResource("1_o55be") tile_name = "Bee" +movement_behaviour = SubResource("Resource_puwjs") material_black = ExtResource("1_0fgqy") material_white = ExtResource("2_qr48e") ui_texture = ExtResource("4_1he20") diff --git a/Tile/Tile.gd b/Tile/Tile.gd index d1f645d..3f821f3 100644 --- a/Tile/Tile.gd +++ b/Tile/Tile.gd @@ -1,13 +1,38 @@ -extends Node +extends Area3D +class_name InsectTile -@export var coordinates: Vector4i + +@export var coordinates: Vector2i @export var is_black: bool = false @export var resource: TileResource @onready var hexagon_small = $HexagonSmall -func _ready() -> void: +var hovered: bool = false + +var hover_shader: ShaderMaterial = preload("res://InsectTiles/HoverShader.tres") + +var mat: StandardMaterial3D + +func _ready() -> void: if is_black: - hexagon_small.set_surface_override_material(0, resource.material_black) + hexagon_small.set_surface_override_material(0, resource.material_black.duplicate()) else: - hexagon_small.set_surface_override_material(0, resource.material_white) + hexagon_small.set_surface_override_material(0, resource.material_white.duplicate()) + + mat = hexagon_small.get_surface_override_material(0) + +func _process(delta): + if Input.is_action_just_pressed("place_tile"): + if hovered: + GameEvents.insect_tile_selected.emit(self) + +func _on_mouse_entered(): + if GameData.is_player_black == is_black: + mat.next_pass = hover_shader + hovered = true + +func _on_mouse_exited(): + hovered = false + mat.next_pass = null + diff --git a/addons/script-ide/LICENSE b/addons/script-ide/LICENSE new file mode 100644 index 0000000..ffc9cf2 --- /dev/null +++ b/addons/script-ide/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Marius Hanl + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/addons/script-ide/Popup.gd b/addons/script-ide/Popup.gd new file mode 100644 index 0000000..400a3f3 --- /dev/null +++ b/addons/script-ide/Popup.gd @@ -0,0 +1,6 @@ +extends PopupPanel + +var input_listener: Callable + +func _input(event: InputEvent) -> void: + input_listener.call(event) diff --git a/addons/script-ide/README.md b/addons/script-ide/README.md new file mode 100644 index 0000000..8c434a0 --- /dev/null +++ b/addons/script-ide/README.md @@ -0,0 +1,34 @@ +# Script IDE + +Transforms the Script UI into an IDE like UI. Tabs are used for navigating between scripts. The default Outline got an overhaul and now shows all members of the script (not just methods) with unique icons for faster navigation. + +Features: +- Scripts are now shown as Tabs inside a TabContainer (No Script List by default, but can be toggled on again) +- The Outline is on the right side (can be changed to be on the left side again) +- The Outline got an overhaul and shows more than just the methods of the script. It includes the following members with a unique icon: + - Classes (Red Square) + - Constants (Red Circle) + - Signals (Yellow) + - Export variables (Orange) + - (Static) Variables (Red) + - Engine callback functions (Blue) + - (Static) Functions (Green) +- All the different members of the script can be hidden or made visible again. This allows fine control what should be visible (e.g. only signals, functions, ...) +- There is also the possibility to hide private members, this is all members starting with a '_' +- The Outline can be opened as Popup with a defined shortcut (more below). This allows to quickly search for a specific member and scroll to it +- You can navigate through the Outline with the arrow keys and scroll to the selected item by pressing `ENTER` +- The Outline (and Script List) can be toggled via `File -> Toggle Scripts Panel`. This will hide or show it +- The plugin is written with performance in mind, everything is very fast and works without any lags or stuttering. + +All settings can be changed in the `Editor Settings` under `Plugin` -> `Script Ide`: +- `Open Outline Popup` = Shortcut to control how the Outline Popup should be triggered (default=CTRL+O or META+O) +- `Outline Position Right` = Flag to control whether the outline should be on the right or on the left side of the script editor (default=true) +- `Hide Private Members` = Flag to control whether private members (methods/variables/constants starting with '_') should be hidden in the Outline or not (default=false) +- `Script List Visible` = Flag to control whether the script list should still be visible or not (above the outline) +- All outline visibility settings + +![Example of the outline](https://github.com/godotengine/godot/assets/66004280/30d04924-ba53-415d-b796-92b2fc086ff9) + +![Example of the outline popup](https://github.com/godotengine/godot/assets/66004280/cad0e00e-dbb6-4d3d-980b-c36da6af2cb8) + +![Example of the editor settings](https://github.com/godotengine/godot/assets/66004280/9cec7454-1a38-428b-97cc-886d0ce415bb) diff --git a/addons/script-ide/icon/class.svg b/addons/script-ide/icon/class.svg new file mode 100644 index 0000000..51cd478 --- /dev/null +++ b/addons/script-ide/icon/class.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/class.svg.import b/addons/script-ide/icon/class.svg.import new file mode 100644 index 0000000..811536d --- /dev/null +++ b/addons/script-ide/icon/class.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://csik7oxvt7tq3" +path="res://.godot/imported/class.svg-e6f2816a1f06041fb421c2af52817a4a.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/class.svg" +dest_files=["res://.godot/imported/class.svg-e6f2816a1f06041fb421c2af52817a4a.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/constant.svg b/addons/script-ide/icon/constant.svg new file mode 100644 index 0000000..b81f2c0 --- /dev/null +++ b/addons/script-ide/icon/constant.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/constant.svg.import b/addons/script-ide/icon/constant.svg.import new file mode 100644 index 0000000..60a64e5 --- /dev/null +++ b/addons/script-ide/icon/constant.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cawc456ja8vf5" +path="res://.godot/imported/constant.svg-f6e857276565573c7540f3c32801842a.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/constant.svg" +dest_files=["res://.godot/imported/constant.svg-f6e857276565573c7540f3c32801842a.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/export.svg b/addons/script-ide/icon/export.svg new file mode 100644 index 0000000..866bd5d --- /dev/null +++ b/addons/script-ide/icon/export.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/export.svg.import b/addons/script-ide/icon/export.svg.import new file mode 100644 index 0000000..b0036dc --- /dev/null +++ b/addons/script-ide/icon/export.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bvu2gnj8fv2kw" +path="res://.godot/imported/export.svg-d2d18132258a7a219ec1af1f0316c91c.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/export.svg" +dest_files=["res://.godot/imported/export.svg-d2d18132258a7a219ec1af1f0316c91c.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/func.svg b/addons/script-ide/icon/func.svg new file mode 100644 index 0000000..85161ba --- /dev/null +++ b/addons/script-ide/icon/func.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/func.svg.import b/addons/script-ide/icon/func.svg.import new file mode 100644 index 0000000..233870a --- /dev/null +++ b/addons/script-ide/icon/func.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rni04cl446ov" +path="res://.godot/imported/func.svg-139842caa5b4b7e4839711b6c756d0f7.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/func.svg" +dest_files=["res://.godot/imported/func.svg-139842caa5b4b7e4839711b6c756d0f7.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/func_get.svg b/addons/script-ide/icon/func_get.svg new file mode 100644 index 0000000..e5ac92a --- /dev/null +++ b/addons/script-ide/icon/func_get.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/func_get.svg.import b/addons/script-ide/icon/func_get.svg.import new file mode 100644 index 0000000..59de1a0 --- /dev/null +++ b/addons/script-ide/icon/func_get.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c2a3aowyhxj5x" +path="res://.godot/imported/func_get.svg-093f0ce02889d1f102ff9cc3e7f72654.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/func_get.svg" +dest_files=["res://.godot/imported/func_get.svg-093f0ce02889d1f102ff9cc3e7f72654.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/func_set.svg b/addons/script-ide/icon/func_set.svg new file mode 100644 index 0000000..9ed3107 --- /dev/null +++ b/addons/script-ide/icon/func_set.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/func_set.svg.import b/addons/script-ide/icon/func_set.svg.import new file mode 100644 index 0000000..cedc130 --- /dev/null +++ b/addons/script-ide/icon/func_set.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bvjkrti6kj6o2" +path="res://.godot/imported/func_set.svg-c31168d90866ff1707ad9834754bd2c9.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/func_set.svg" +dest_files=["res://.godot/imported/func_set.svg-c31168d90866ff1707ad9834754bd2c9.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/keyword.svg b/addons/script-ide/icon/keyword.svg new file mode 100644 index 0000000..2082823 --- /dev/null +++ b/addons/script-ide/icon/keyword.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/keyword.svg.import b/addons/script-ide/icon/keyword.svg.import new file mode 100644 index 0000000..673e34a --- /dev/null +++ b/addons/script-ide/icon/keyword.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cupb0polhqrwj" +path="res://.godot/imported/keyword.svg-15ea12cc9eda85ed385533fe57e3bba8.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/keyword.svg" +dest_files=["res://.godot/imported/keyword.svg-15ea12cc9eda85ed385533fe57e3bba8.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/property.svg b/addons/script-ide/icon/property.svg new file mode 100644 index 0000000..dc32112 --- /dev/null +++ b/addons/script-ide/icon/property.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/property.svg.import b/addons/script-ide/icon/property.svg.import new file mode 100644 index 0000000..cdf7a95 --- /dev/null +++ b/addons/script-ide/icon/property.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dbwlgnwv5e8kl" +path="res://.godot/imported/property.svg-9e228499f30651faad74aa99e4499d7e.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/property.svg" +dest_files=["res://.godot/imported/property.svg-9e228499f30651faad74aa99e4499d7e.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/icon/signal.svg b/addons/script-ide/icon/signal.svg new file mode 100644 index 0000000..1eb6d9f --- /dev/null +++ b/addons/script-ide/icon/signal.svg @@ -0,0 +1 @@ + diff --git a/addons/script-ide/icon/signal.svg.import b/addons/script-ide/icon/signal.svg.import new file mode 100644 index 0000000..16dc07d --- /dev/null +++ b/addons/script-ide/icon/signal.svg.import @@ -0,0 +1,38 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bnccvnaloqnte" +path="res://.godot/imported/signal.svg-97182e1498b520a1ff5b8b9017c3b480.ctex" +metadata={ +"has_editor_variant": true, +"vram_texture": false +} + +[deps] + +source_file="res://addons/script-ide/icon/signal.svg" +dest_files=["res://.godot/imported/signal.svg-97182e1498b520a1ff5b8b9017c3b480.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 +svg/scale=0.8 +editor/scale_with_editor_scale=true +editor/convert_colors_with_editor_theme=false diff --git a/addons/script-ide/plugin.cfg b/addons/script-ide/plugin.cfg new file mode 100644 index 0000000..dfe43e5 --- /dev/null +++ b/addons/script-ide/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Script-IDE" +description="Transforms the Script UI into an IDE like UI. Tabs are used for navigating between scripts. The default Outline got an overhaul and now shows all members of the script (not just methods) with unique icons for faster navigation." +author="Marius Hanl" +version="1.2.7" +script="plugin.gd" diff --git a/addons/script-ide/plugin.gd b/addons/script-ide/plugin.gd new file mode 100644 index 0000000..07a34b8 --- /dev/null +++ b/addons/script-ide/plugin.gd @@ -0,0 +1,878 @@ +@tool +extends EditorPlugin + +## Editor setting path +const SCRIPT_IDE: StringName = &"plugin/script_ide/" +## Editor setting for the outline position +const OUTLINE_POSITION_RIGHT: StringName = SCRIPT_IDE + &"outline_position_right" +## Editor setting to control whether private members (annotated with '_' should be hidden or not) +const HIDE_PRIVATE_MEMBERS: StringName = SCRIPT_IDE + &"hide_private_members" +## Editor setting to control whether the script list should be visible or not +const SCRIPT_LIST_VISIBLE: StringName = SCRIPT_IDE + &"script_list_visible" +## Editor setting for the 'Open Outline Popup' shortcut +const OPEN_OUTLINE_POPUP: StringName = SCRIPT_IDE + &"open_outline_popup" + +#region Outline icons +const keyword_icon: Texture2D = preload("res://addons/script-ide/icon/keyword.svg") +const func_icon: Texture2D = preload("res://addons/script-ide/icon/func.svg") +const func_get_icon: Texture2D = preload("res://addons/script-ide/icon/func_get.svg") +const func_set_icon: Texture2D = preload("res://addons/script-ide/icon/func_set.svg") +const property_icon: Texture2D = preload("res://addons/script-ide/icon/property.svg") +const export_icon: Texture2D = preload("res://addons/script-ide/icon/export.svg") +const signal_icon: Texture2D = preload("res://addons/script-ide/icon/signal.svg") +const constant_icon: Texture2D = preload("res://addons/script-ide/icon/constant.svg") +const class_icon: Texture2D = preload("res://addons/script-ide/icon/class.svg") +#endregion + +const POPUP_SCRIPT: GDScript = preload("res://addons/script-ide/Popup.gd") + +#region Editor settings +var is_outline_right: bool = true +var is_script_list_visible: bool = false +var hide_private_members: bool = false +var open_outline_popup: Shortcut +#endregion + +var suppress_settings_sync: bool = false + +#region Existing controls we modify +var outline_container: Control +var outline_parent: Node +var scripts_tab_container: TabContainer +var scripts_tab_bar: TabBar +var scripts_item_list: ItemList +var split_container: HSplitContainer +var old_outline: ItemList +var filter_txt: LineEdit +var sort_btn: Button +#endregion + +#region Own controls we add +var outline: ItemList +var outline_popup: PopupPanel +var filter_box: HBoxContainer + +var class_btn: Button +var constant_btn: Button +var signal_btn: Button +var property_btn: Button +var export_btn: Button +var func_btn: Button +var engine_func_btn: Button +#endregion + +var keywords: Dictionary = {} # Basically used as Set, since Godot has none. [String, int = 0] +var outline_cache: OutlineCache +var tab_state: TabStateCache + +var old_script_editor_base: ScriptEditorBase +var old_script_type: StringName + +var selected_tab: int = -1 +var last_tab_hovered: int = -1 +var sync_script_list: bool + +#region Enter / Exit -> Plugin setup +## Change the Godot script UI and transform into an IDE like UI +func _enter_tree() -> void: + is_outline_right = get_setting(OUTLINE_POSITION_RIGHT, is_outline_right) + hide_private_members = get_setting(HIDE_PRIVATE_MEMBERS, hide_private_members) + is_script_list_visible = get_setting(SCRIPT_LIST_VISIBLE, is_script_list_visible) + + var editor_settings: EditorSettings = get_editor_settings() + if (!editor_settings.has_setting(OPEN_OUTLINE_POPUP)): + var shortcut: Shortcut = Shortcut.new() + var event: InputEventKey = InputEventKey.new() + event.device = -1 + event.ctrl_pressed = true + event.keycode = KEY_O + + var event2: InputEventKey = InputEventKey.new() + event2.device = -1 + event2.meta_pressed = true + event2.keycode = KEY_O + + shortcut.events = [ event, event2 ] + editor_settings.set_setting(OPEN_OUTLINE_POPUP, shortcut) + editor_settings.set_initial_value(OPEN_OUTLINE_POPUP, shortcut, false) + + open_outline_popup = editor_settings.get_setting(OPEN_OUTLINE_POPUP) + + # Update on filesystem changed (e.g. save operation). + var file_system: EditorFileSystem = get_editor_interface().get_resource_filesystem() + file_system.filesystem_changed.connect(schedule_update) + + # Make tab container visible + var script_editor: ScriptEditor = get_editor_interface().get_script_editor() + scripts_tab_container = find_or_null(script_editor.find_children("*", "TabContainer", true, false)) + if (scripts_tab_container != null): + scripts_tab_bar = scripts_tab_container.get_tab_bar() + + tab_state = TabStateCache.new() + tab_state.save(scripts_tab_container, scripts_tab_bar) + + scripts_tab_container.tabs_visible = true + scripts_tab_container.drag_to_rearrange_enabled = true + + if (scripts_tab_bar != null): + scripts_tab_bar.tab_close_display_policy = TabBar.CLOSE_BUTTON_SHOW_ACTIVE_ONLY + scripts_tab_bar.drag_to_rearrange_enabled = true + scripts_tab_bar.select_with_rmb = true + scripts_tab_bar.tab_close_pressed.connect(on_tab_close) + scripts_tab_bar.tab_rmb_clicked.connect(on_tab_rmb) + scripts_tab_bar.tab_hovered.connect(on_tab_hovered) + scripts_tab_bar.mouse_exited.connect(on_tab_bar_mouse_exited) + scripts_tab_bar.active_tab_rearranged.connect(on_active_tab_rearranged) + scripts_tab_bar.gui_input.connect(on_tab_bar_gui_input) + + scripts_tab_bar.tab_changed.connect(on_tab_changed) + + # Change script item list visibility + scripts_item_list = find_or_null(script_editor.find_children("*", "ItemList", true, false)) + if (scripts_item_list != null): + update_script_list_visibility() + + # Remove existing outline and add own outline + split_container = find_or_null(script_editor.find_children("*", "HSplitContainer", true, false)) + if (split_container != null): + outline_container = split_container.get_child(0) + + if (is_outline_right): + update_outline_position() + + old_outline = find_or_null(outline_container.find_children("*", "ItemList", true, false), 1) + outline_parent = old_outline.get_parent() + outline_parent.remove_child(old_outline) + + outline = ItemList.new() + outline.allow_reselect = true + outline.size_flags_vertical = Control.SIZE_EXPAND_FILL + outline_parent.add_child(outline) + + outline.item_selected.connect(scroll_to_index) + + # Add a filter box for all kind of members + filter_box = HBoxContainer.new() + + engine_func_btn = create_filter_btn(keyword_icon, "Engine callbacks") + filter_box.add_child(engine_func_btn) + + func_btn = create_filter_btn(func_icon, "Functions") + filter_box.add_child(func_btn) + + signal_btn = create_filter_btn(signal_icon, "Signals") + filter_box.add_child(signal_btn) + + export_btn = create_filter_btn(export_icon, "Exported properties") + filter_box.add_child(export_btn) + + property_btn = create_filter_btn(property_icon, "Properties") + filter_box.add_child(property_btn) + + class_btn = create_filter_btn(class_icon, "Classes") + filter_box.add_child(class_btn) + + constant_btn = create_filter_btn(constant_icon, "Constants") + filter_box.add_child(constant_btn) + + outline.get_parent().add_child(filter_box) + outline.get_parent().move_child(filter_box, outline.get_index()) + + # Callback when the filter changed + filter_txt = find_or_null(outline_container.find_children("*", "LineEdit", true, false), 1) + filter_txt.text_changed.connect(update_outline.unbind(1)) + + # Callback when the sorting changed + sort_btn = find_or_null(outline_container.find_children("*", "Button", true, false)) + sort_btn.pressed.connect(update_outline) + + get_editor_settings().settings_changed.connect(sync_settings) + + on_tab_changed(scripts_tab_bar.current_tab) + +## Restore the old Godot script UI and free everything we created +func _exit_tree() -> void: + var file_system: EditorFileSystem = get_editor_interface().get_resource_filesystem() + file_system.filesystem_changed.disconnect(schedule_update) + + if (old_script_editor_base != null): + old_script_editor_base.edited_script_changed.disconnect(update_selected_tab) + + if (split_container != null): + if (split_container != outline_container.get_parent()): + split_container.add_child(outline_container) + + # Try to restore the previous split offset. + if (is_outline_right): + var split_offset: float = split_container.get_child(1).size.x + split_container.split_offset = split_offset + + split_container.move_child(outline_container, 0) + + filter_txt.text_changed.disconnect(update_outline) + sort_btn.pressed.disconnect(update_outline) + + outline.item_selected.disconnect(scroll_to_index) + + outline_parent.remove_child(filter_box) + outline_parent.remove_child(outline) + outline_parent.add_child(old_outline) + outline_parent.move_child(old_outline, 1) + + filter_box.free() + outline.free() + + if (scripts_tab_container != null): + tab_state.restore(scripts_tab_container, scripts_tab_bar) + + if (scripts_tab_bar != null): + scripts_tab_bar.mouse_exited.disconnect(on_tab_bar_mouse_exited) + scripts_tab_bar.gui_input.disconnect(on_tab_bar_gui_input) + scripts_tab_bar.tab_close_pressed.disconnect(on_tab_close) + scripts_tab_bar.tab_rmb_clicked.disconnect(on_tab_rmb) + scripts_tab_bar.tab_hovered.disconnect(on_tab_hovered) + scripts_tab_bar.active_tab_rearranged.disconnect(on_active_tab_rearranged) + + scripts_tab_bar.tab_changed.disconnect(on_tab_changed) + + if (scripts_item_list != null): + scripts_item_list.get_parent().visible = true + + if (outline_popup != null): + outline_popup.hide() + + get_editor_settings().settings_changed.disconnect(sync_settings) +#endregion + +## Lazy pattern to update the editor only once per frame +func _process(delta: float) -> void: + update_editor() + set_process(false) + +#region Input handling -> Popup +## Add navigation to the Outline +func _input(event: InputEvent) -> void: + if (!filter_txt.has_focus()): + return + + if (event.is_action_pressed("ui_text_submit")): + var items: PackedInt32Array = outline.get_selected_items() + + if (items.is_empty()): + return + + var index: int = items[0] + scroll_to_index(index) + + if (event.is_action_pressed("ui_down", true)): + var items: PackedInt32Array = outline.get_selected_items() + + var index: int + if (items.is_empty()): + index = -1 + else: + index = items[0] + + if (index == outline.item_count - 1): + return + + index += 1 + + outline.select(index) + outline.ensure_current_is_visible() + get_viewport().set_input_as_handled() + elif (event.is_action_pressed("ui_up", true)): + var items: PackedInt32Array = outline.get_selected_items() + + var index: int + if (items.is_empty()): + index = outline.item_count + else: + index = items[0] + + if (index == 0): + return + + index -= 1 + outline.select(index) + outline.ensure_current_is_visible() + get_viewport().set_input_as_handled() + +## Triggers the Outline popup +func _unhandled_key_input(event: InputEvent) -> void: + if !(event is InputEventKey): + return + + if (open_outline_popup.matches_event(event)): + get_viewport().set_input_as_handled() + + var button_flags: Array[bool] = [] + for child in filter_box.get_children(): + var btn: Button = child + button_flags.append(btn.button_pressed) + + btn.button_pressed = true + + var old_text: String = filter_txt.text + filter_txt.text = "" + + outline_popup = POPUP_SCRIPT.new() + outline_popup.input_listener = _input + + var outline_initially_closed: bool = !outline_container.visible + if (outline_initially_closed): + outline_container.visible = true + + outline_container.reparent(outline_popup) + + var script_editor: ScriptEditor = get_editor_interface().get_script_editor() + outline_popup.popup_hide.connect(func(): + if outline_initially_closed: + outline_container.visible = false + + outline_container.reparent(split_container) + if (!is_outline_right): + split_container.move_child(outline_container, 0) + + filter_txt.text = old_text + + var index: int = 0 + for flag in button_flags: + var btn: Button = filter_box.get_child(index) + btn.button_pressed = flag + index += 1 + + outline_popup.queue_free() + outline_popup = null + + update_outline() + ) + + var window_rect: Rect2 + if (script_editor.get_parent().get_parent() is Window): + # Popup mode + var window: Window = script_editor.get_parent().get_parent() + window_rect = window.get_visible_rect() + else: + window_rect = get_editor_interface().get_base_control().get_rect() + + var size: Vector2i = Vector2i(400, 550) + var x: int = window_rect.size.x / 2 - size.x / 2 + var y: int = window_rect.size.y / 2 - size.y / 2 + var position: Vector2i = Vector2i(x, y) + + outline_popup.popup_exclusive_on_parent(script_editor, Rect2i(position, size)) + + filter_txt.grab_focus() + + update_outline() +#endregion + +## Schedules an update on the frame +func schedule_update(): + set_process(true) + +## Updates all parts of the editor needed to be synchronized with the file system. +func update_editor(): + if (sync_script_list): + sync_tab_with_script_list() + sync_script_list = false + + update_tabs() + update_outline_cache() + update_outline() + +func get_current_script() -> Script: + var script_editor: ScriptEditor = get_editor_interface().get_script_editor() + return script_editor.get_current_script() + +func scroll_to_index(selected_idx: int): + if (outline_popup != null): + outline_popup.hide.call_deferred() + + var script: Script = get_current_script() + if (!script): + return + + var text: String = outline.get_item_text(selected_idx) + var metadata: Dictionary = outline.get_item_metadata(selected_idx) + var modifier: String = metadata["modifier"] + var type: String = metadata["type"] + + var type_with_text: String = type + " " + text + if (type == "func"): + type_with_text = type_with_text + "(" + + var source_code: String = script.get_source_code() + var lines: PackedStringArray = source_code.split("\n") + + var index: int = 0 + for line in lines: + # Easy case, like 'var abc' + if (line.begins_with(type_with_text)): + goto_line(index) + return + + # We have an modifier, e.g. 'static' + if (modifier != "" && line.begins_with(modifier)): + if (line.begins_with(modifier + " " + type_with_text)): + goto_line(index) + return + # Special case: An 'enum' is treated different. + elif (modifier == "enum" && line.contains("enum " + text)): + goto_line(index) + return + + # Hard case, probably something like '@onready var abc' + if (type == "var" && line.contains(type_with_text)): + goto_line(index) + return + + index += 1 + + push_error(type_with_text + " or " + modifier + " not found in source code") + +func goto_line(index: int): + var script_editor: ScriptEditor = get_editor_interface().get_script_editor() + script_editor.goto_line(index) + + var code_edit: CodeEdit = script_editor.get_current_editor().get_base_editor() + code_edit.set_caret_line(index) + code_edit.set_caret_column(0) + code_edit.set_v_scroll(index) + code_edit.set_h_scroll(0) + +func create_filter_btn(icon: Texture2D, title: String) -> Button: + var btn: Button = Button.new() + btn.toggle_mode = true + btn.icon = icon + btn.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER + btn.tooltip_text = title + + var property: StringName = as_setting(title) + btn.set_meta("property", property) + btn.button_pressed = get_setting(property, true) + + btn.toggled.connect(on_filter_button_pressed.bind(btn)) + + btn.add_theme_color_override("icon_pressed_color", Color.WHITE) + btn.add_theme_color_override("icon_hover_color", Color.WHITE) + btn.add_theme_color_override("icon_focus_color", Color.WHITE) + + var style_box_empty: StyleBoxEmpty = StyleBoxEmpty.new() + style_box_empty.set_content_margin_all(4 * get_editor_scale()) + btn.add_theme_stylebox_override("normal", style_box_empty) + + var style_box: StyleBoxFlat = StyleBoxFlat.new() + style_box.draw_center = false + style_box.border_color = Color(0.41, 0.61, 0.91) + style_box.set_border_width_all(1 * get_editor_scale()) + style_box.set_corner_radius_all(3 * get_editor_scale()) + btn.add_theme_stylebox_override("focus", style_box) + + return btn + +func on_filter_button_pressed(pressed: bool, btn: Button): + set_setting(btn.get_meta("property"), pressed) + + update_outline() + +func update_outline_position(): + if (is_outline_right): + # Try to restore the previous split offset. + var split_offset: float = split_container.get_child(1).size.x + split_container.split_offset = split_offset + split_container.move_child(outline_container, 1) + else: + split_container.move_child(outline_container, 0) + +func update_script_list_visibility(): + scripts_item_list.get_parent().visible = is_script_list_visible + +func sync_settings(): + if (suppress_settings_sync): + return + + var changed_settings: PackedStringArray = get_editor_settings().get_changed_settings() + for setting in changed_settings: + if (!setting.begins_with(SCRIPT_IDE)): + continue + + if (setting == OUTLINE_POSITION_RIGHT): + # Update outline position. + var new_outline_right: bool = get_setting(OUTLINE_POSITION_RIGHT, is_outline_right) + if (new_outline_right != is_outline_right): + is_outline_right = new_outline_right + + update_outline_position() + elif (setting == HIDE_PRIVATE_MEMBERS): + # Update cache and outline to reflect the private members setting. + var new_hide_private_members: bool = get_setting(HIDE_PRIVATE_MEMBERS, hide_private_members) + if (new_hide_private_members != hide_private_members): + hide_private_members = new_hide_private_members + + update_outline_cache() + update_outline() + elif (setting == OPEN_OUTLINE_POPUP): + # Update show outline popup shortcut. + open_outline_popup = get_editor_settings().get_setting(OPEN_OUTLINE_POPUP) + elif (setting == SCRIPT_LIST_VISIBLE): + # Update the script list visibility + var new_script_list_visible: bool = get_setting(SCRIPT_LIST_VISIBLE, is_script_list_visible) + if (new_script_list_visible != is_script_list_visible): + is_script_list_visible = new_script_list_visible + + update_script_list_visibility() + else: + # Update filter buttons. + for btn_node in filter_box.get_children(): + var btn: Button = btn_node + var property: StringName = btn.get_meta("property") + + btn.button_pressed = get_setting(property, btn.button_pressed) + +func as_setting(property: String) -> StringName: + return SCRIPT_IDE + property.to_lower().replace(" ", "_") + +func get_setting(property: StringName, alt: bool) -> bool: + var editor_settings: EditorSettings = get_editor_settings() + if (editor_settings.has_setting(property)): + return editor_settings.get_setting(property) + else: + editor_settings.set_setting(property, alt) + editor_settings.set_initial_value(property, alt, false) + return alt + +func set_setting(property: StringName, value: bool): + var editor_settings: EditorSettings = get_editor_settings() + + suppress_settings_sync = true + editor_settings.set_setting(property, value) + suppress_settings_sync = false + +func on_tab_changed(idx: int): + selected_tab = idx; + + if (old_script_editor_base != null): + old_script_editor_base.edited_script_changed.disconnect(update_selected_tab) + old_script_editor_base = null + + var script_editor: ScriptEditor = get_editor_interface().get_script_editor() + var script_editor_base: ScriptEditorBase = script_editor.get_current_editor() + + if (script_editor_base != null): + script_editor_base.edited_script_changed.connect(update_selected_tab) + + old_script_editor_base = script_editor_base + + sync_script_list = true + schedule_update() + +func update_selected_tab(): + if (selected_tab == -1): + return + + if (scripts_item_list.item_count == 0): + return + + scripts_tab_container.set_tab_title(selected_tab, scripts_item_list.get_item_text(selected_tab)) + scripts_tab_container.set_tab_icon(selected_tab, scripts_item_list.get_item_icon(selected_tab)) + +func update_tabs(): + for index in scripts_tab_container.get_tab_count(): + scripts_tab_container.set_tab_title(index, scripts_item_list.get_item_text(index)) + scripts_tab_container.set_tab_icon(index, scripts_item_list.get_item_icon(index)) + +#region Outline (cache) update +func update_keywords(script: Script): + if (script == null): + return + + var new_script_type: StringName = script.get_instance_base_type() + if (old_script_type != new_script_type): + old_script_type = new_script_type + + keywords.clear() + keywords["_static_init"] = 0 + register_virtual_methods(new_script_type) + +func register_virtual_methods(clazz: String): + for method in ClassDB.class_get_method_list(clazz): + if method.flags & METHOD_FLAG_VIRTUAL > 0: + keywords[method.name] = 0 + +func update_outline_cache(): + outline_cache = null + + var script: Script = get_current_script() + if (!script): + return + + update_keywords(script) + + # Check if built-in script. In this case we need to duplicate it. + if (script.get_path().contains(".tscn::GDScript")): + script = script.duplicate() + + outline_cache = OutlineCache.new() + + # Collect all script members. + for_each_script_member(script, func(array: Array[String], item: String): array.append(item)) + + # Remove script members that only exist in the base script (which includes the base of the base etc.). + # Note: The method that only collects script members without including the base script(s) + # is not exposed to GDScript. + var base_script: Script = script.get_base_script() + if (base_script != null): + for_each_script_member(base_script, func(array: Array[String], item: String): array.erase(item)) + +func for_each_script_member(script: Script, consumer: Callable): + # Functions / Methods + for dict in script.get_script_method_list(): + var func_name: String = dict["name"] + + if (keywords.has(func_name)): + consumer.call(outline_cache.engine_funcs, func_name) + else: + if hide_private_members && func_name.begins_with("_"): + continue + + # Inline getter/setter will normally be shown as '@...getter', '@...setter'. + # Since we already show the variable itself, we will skip those. + if (func_name.begins_with("@")): + continue + + consumer.call(outline_cache.funcs, func_name) + + # Properties / Exported variables + for dict in script.get_script_property_list(): + var property: String = dict["name"] + if hide_private_members && property.begins_with("_"): + continue + + var usage: int = dict["usage"] + + if (usage & PROPERTY_USAGE_SCRIPT_VARIABLE): + if (usage & PROPERTY_USAGE_STORAGE && usage & PROPERTY_USAGE_EDITOR): + consumer.call(outline_cache.exports, property) + else: + consumer.call(outline_cache.properties, property) + + # Static variables (are separated for whatever reason) + for dict in script.get_property_list(): + var property: String = dict["name"] + if hide_private_members && property.begins_with("_"): + continue + + var usage: int = dict["usage"] + + if (usage & PROPERTY_USAGE_SCRIPT_VARIABLE): + consumer.call(outline_cache.properties, property) + + # Signals + for dict in script.get_script_signal_list(): + var signal_name: String = dict["name"] + + consumer.call(outline_cache.signals, signal_name) + + # Constants / Classes + for name_key in script.get_script_constant_map(): + if hide_private_members && name_key.begins_with("_"): + continue + + var object: Variant = script.get_script_constant_map().get(name_key) + if (object is GDScript && object.get_instance_base_type() == "RefCounted"): + consumer.call(outline_cache.classes, name_key) + else: + consumer.call(outline_cache.constants, name_key) + +func update_outline(): + outline.clear() + + if (outline_cache == null): + return + + # Classes + if (class_btn.button_pressed): + add_to_outline(outline_cache.classes, class_icon, "class") + + # Constants + if (constant_btn.button_pressed): + add_to_outline(outline_cache.constants, constant_icon, "const", "enum") + + # Properties + if (property_btn.button_pressed): + add_to_outline(outline_cache.properties, property_icon, "var") + + # Exports + if (export_btn.button_pressed): + add_to_outline(outline_cache.exports, export_icon, "var", "@export") + + # Signals + if (signal_btn.button_pressed): + add_to_outline(outline_cache.signals, signal_icon, "signal") + + # Functions + if (func_btn.button_pressed): + add_to_outline_ext(outline_cache.funcs, get_icon, "func", "static") + + # Engine functions + if (engine_func_btn.button_pressed): + add_to_outline(outline_cache.engine_funcs, keyword_icon, "func") + +func add_to_outline(items: Array[String], icon: Texture2D, type: String, modifier: String = ""): + add_to_outline_ext(items, func(str: String): return icon, type, modifier) + +func add_to_outline_ext(items: Array[String], icon_callable: Callable, type: String, modifier: String = ""): + var text: String = filter_txt.get_text() + var move_index: int = 0 + + if (is_sorted()): + items = items.duplicate() + items.sort_custom(func(a, b): return a.naturalnocasecmp_to(b) < 0) + + for item in items: + if (text.is_empty() || text.is_subsequence_ofn(item)): + var icon: Texture2D = icon_callable.call(item) + outline.add_item(item, icon, true) + + var dict: Dictionary = { + "type": type, + "modifier": modifier + } + outline.set_item_metadata(outline.item_count - 1, dict) + # Only activate the tooltip when we do not show the outline in the popup. + outline.set_item_tooltip_enabled(outline.item_count - 1, outline_popup == null) + outline.move_item(outline.item_count - 1, move_index) + + move_index += 1 + +func get_icon(func_name: String) -> Texture2D: + var icon: Texture2D = func_icon + if (func_name.begins_with("get")): + icon = func_get_icon + elif (func_name.begins_with("set")): + icon = func_set_icon + + return icon +#endregion + +func sync_tab_with_script_list(): + # For some reason the selected tab is wrong. Looks like a Godot bug. + if (selected_tab >= scripts_item_list.item_count): + selected_tab = scripts_tab_bar.current_tab + + # Hide filter and outline for non .gd scripts. + var is_script: bool = get_current_script() != null + filter_box.visible = is_script + outline.visible = is_script + + # Sync with script item list. + if (selected_tab != -1 && scripts_item_list.item_count > 0 && !scripts_item_list.is_selected(selected_tab)): + scripts_item_list.select(selected_tab) + scripts_item_list.item_selected.emit(selected_tab) + + scripts_item_list.ensure_current_is_visible() + +func trigger_script_editor_update_script_names(): + var script_editor: ScriptEditor = get_editor_interface().get_script_editor() + # for now it is the only way to trigger script_editor._update_script_names + script_editor.notification(Control.NOTIFICATION_THEME_CHANGED) + +#region Tab Handling +func on_tab_bar_mouse_exited(): + last_tab_hovered = -1 + +func on_tab_hovered(idx: int): + last_tab_hovered = idx + +func on_tab_bar_gui_input(event: InputEvent): + if last_tab_hovered == -1: + return + + if event is InputEventMouseMotion: + scripts_tab_bar.tooltip_text = get_res_path(last_tab_hovered) + + if event is InputEventMouseButton: + if event.is_pressed() and event.button_index == MOUSE_BUTTON_MIDDLE: + simulate_item_clicked(last_tab_hovered, MOUSE_BUTTON_MIDDLE) + +func on_active_tab_rearranged(idx_to: int): + var control: Control = scripts_tab_container.get_tab_control(selected_tab) + if (!control): + return + + scripts_tab_container.move_child(control, idx_to) + scripts_tab_container.current_tab = scripts_tab_container.current_tab + selected_tab = scripts_tab_container.current_tab + trigger_script_editor_update_script_names() + +func get_res_path(idx: int) -> String: + var tab_control: Control = scripts_tab_container.get_tab_control(idx) + if (tab_control == null): + return '' + + var path_var: Variant = tab_control.get("metadata/_edit_res_path") + if (path_var == null): + return '' + + return path_var + +func on_tab_rmb(tab_idx: int): + simulate_item_clicked(tab_idx, MOUSE_BUTTON_RIGHT) + +func on_tab_close(tab_idx: int): + simulate_item_clicked(tab_idx, MOUSE_BUTTON_MIDDLE) + +func simulate_item_clicked(tab_idx: int, mouse_idx: int): + scripts_item_list.item_clicked.emit(tab_idx, scripts_item_list.get_local_mouse_position(), mouse_idx) +#endregion + +func get_editor_scale() -> float: + return get_editor_interface().get_editor_scale() + +func is_sorted() -> bool: + return get_editor_settings().get_setting("text_editor/script_list/sort_members_outline_alphabetically") + +func get_editor_settings() -> EditorSettings: + return get_editor_interface().get_editor_settings() + +static func find_or_null(arr: Array[Node], index: int = 0) -> Node: + if arr.is_empty(): + return null + + return arr[index] + +class OutlineCache: + var classes: Array[String] = [] + var constants: Array[String] = [] + var signals: Array[String] = [] + var exports: Array[String] = [] + var properties: Array[String] = [] + var funcs: Array[String] = [] + var engine_funcs: Array[String] = [] + +class TabStateCache: + var tabs_visible: bool + var drag_to_rearrange_enabled: bool + var tab_bar_drag_to_rearrange_enabled: bool + var tab_close_display_policy: TabBar.CloseButtonDisplayPolicy + var select_with_rmb: bool + + func save(tab_container: TabContainer, tab_bar: TabBar): + if (tab_container != null): + tabs_visible = tab_container.tabs_visible + drag_to_rearrange_enabled = tab_container.drag_to_rearrange_enabled + if (tab_bar != null): + tab_bar_drag_to_rearrange_enabled = tab_bar.drag_to_rearrange_enabled + tab_close_display_policy = tab_bar.tab_close_display_policy + select_with_rmb = tab_bar.select_with_rmb + + func restore(tab_container: TabContainer, tab_bar: TabBar): + if (tab_container != null): + tab_container.tabs_visible = tabs_visible + tab_container.drag_to_rearrange_enabled = drag_to_rearrange_enabled + if (tab_bar != null): + tab_bar.drag_to_rearrange_enabled = drag_to_rearrange_enabled + tab_bar.tab_close_display_policy = tab_close_display_policy + tab_bar.select_with_rmb = select_with_rmb diff --git a/node_3d.tscn b/node_3d.tscn index 9ad1d53..b972be0 100644 --- a/node_3d.tscn +++ b/node_3d.tscn @@ -82,8 +82,8 @@ camera_attributes = SubResource("CameraAttributesPractical_41x5h") [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] transform = Transform3D(0.843961, -0.46784, 0.262404, -0.0775016, 0.377705, 0.922677, -0.530777, -0.79904, 0.28251, 0.262159, 3.27869, -0.104568) -light_bake_mode = 0 shadow_enabled = true +directional_shadow_blend_splits = true script = ExtResource("6_uu0ab") [node name="BuildMenu" type="Control" parent="."] diff --git a/project.godot b/project.godot index b19cc9d..a1fc87e 100644 --- a/project.godot +++ b/project.godot @@ -18,6 +18,11 @@ config/icon="res://icon.svg" [autoload] GameEvents="*res://Globals/GameEvents.gd" +GameData="*res://Globals/GameData.gd" + +[editor_plugins] + +enabled=PackedStringArray("res://addons/script-ide/plugin.cfg") [input] @@ -71,3 +76,12 @@ deselect_tile={ "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":32,"key_label":0,"unicode":32,"echo":false,"script":null) ] } +select_tile={ +"deadzone": 0.5, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) +] +} + +[rendering] + +mesh_lod/lod_change/threshold_pixels=0.0