style: apply gdformat formatting across the entire project
Auto-format all GDScript files using gdformat from gdtoolkit. This is a baseline formatting pass to ensure consistent style: - Normalizes indentation and spacing - Wraps long lines to 100 characters - Removes trailing whitespace - Standardizes blank lines between functions 68 files reformatted, 8 files left unchanged (3rd-party addon files with parse errors excluded).
This commit is contained in:
@@ -30,11 +30,11 @@ var search_button: Button
|
||||
|
||||
#DEPRECATED 4.5
|
||||
#class EdDock extends EditorDock:
|
||||
#func _update_layout(layout: int) -> void:
|
||||
#layout 1 vertical, 2 horizontal, 4 window
|
||||
#print("Terrain3DAssetDock: _update_layout called with: ", layout)
|
||||
#func _update_layout(layout: int) -> void:
|
||||
#layout 1 vertical, 2 horizontal, 4 window
|
||||
#print("Terrain3DAssetDock: _update_layout called with: ", layout)
|
||||
|
||||
var _dock: MarginContainer #DEPRECATED 4.5 - Use EdDock
|
||||
var _dock: MarginContainer #DEPRECATED 4.5 - Use EdDock
|
||||
var _initialized: bool = false
|
||||
var plugin: EditorPlugin
|
||||
var window: Window
|
||||
@@ -44,18 +44,18 @@ func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_ENTER_TREE:
|
||||
await get_tree().process_frame
|
||||
update_layout()
|
||||
|
||||
|
||||
|
||||
|
||||
func initialize(p_plugin: EditorPlugin) -> void:
|
||||
if p_plugin:
|
||||
plugin = p_plugin
|
||||
|
||||
_dock = ClassDB.instantiate("EditorDock") #DEPRECATED 4.5 - EdDock.new()
|
||||
_dock = ClassDB.instantiate("EditorDock") #DEPRECATED 4.5 - EdDock.new()
|
||||
_dock.title = "Terrain3D"
|
||||
_dock.dock_icon = preload("../icons/terrain3d.svg")
|
||||
_dock.default_slot = 8 #DEPRECATED 4.5 - EditorDock.DockSlot.DOCK_SLOT_BOTTOM
|
||||
_dock.default_slot = 8 #DEPRECATED 4.5 - EditorDock.DockSlot.DOCK_SLOT_BOTTOM
|
||||
_dock.closable = false
|
||||
_dock.available_layouts = 0x7 #DEPRECATED 4.5 - EditorDock.DOCK_LAYOUT_ALL
|
||||
_dock.available_layouts = 0x7 #DEPRECATED 4.5 - EditorDock.DOCK_LAYOUT_ALL
|
||||
_dock.add_child(self)
|
||||
plugin.add_dock(_dock)
|
||||
_dock.open()
|
||||
@@ -75,7 +75,7 @@ func initialize(p_plugin: EditorPlugin) -> void:
|
||||
var editor_scale: float = EditorInterface.get_editor_scale()
|
||||
search_box.custom_minimum_size = Vector2(100. * editor_scale, 30. * editor_scale)
|
||||
search_button = $Box/Buttons/SearchBox/SearchButton
|
||||
|
||||
|
||||
texture_list = ListContainer.new()
|
||||
texture_list.name = "TextureList"
|
||||
texture_list.plugin = plugin
|
||||
@@ -100,21 +100,31 @@ func initialize(p_plugin: EditorPlugin) -> void:
|
||||
size_slider.value_changed.connect(_on_slider_changed)
|
||||
plugin.ui.toolbar.tool_changed.connect(_on_tool_changed)
|
||||
|
||||
meshes_btn.add_theme_font_size_override("font_size", int(16. * EditorInterface.get_editor_scale()))
|
||||
textures_btn.add_theme_font_size_override("font_size", int(16. * EditorInterface.get_editor_scale()))
|
||||
meshes_btn.add_theme_font_size_override(
|
||||
"font_size", int(16. * EditorInterface.get_editor_scale())
|
||||
)
|
||||
textures_btn.add_theme_font_size_override(
|
||||
"font_size", int(16. * EditorInterface.get_editor_scale())
|
||||
)
|
||||
|
||||
search_box.text_changed.connect(_on_search_text_changed)
|
||||
search_button.pressed.connect(_on_search_button_pressed)
|
||||
|
||||
|
||||
confirm_dialog = ConfirmationDialog.new()
|
||||
add_child(confirm_dialog, true)
|
||||
confirm_dialog.hide()
|
||||
confirm_dialog.confirmed.connect(func(): _confirmed = true; \
|
||||
confirmation_closed.emit(); \
|
||||
confirmation_confirmed.emit() )
|
||||
confirm_dialog.canceled.connect(func(): _confirmed = false; \
|
||||
confirmation_closed.emit(); \
|
||||
confirmation_canceled.emit() )
|
||||
confirm_dialog.confirmed.connect(
|
||||
func():
|
||||
_confirmed = true
|
||||
confirmation_closed.emit()
|
||||
confirmation_confirmed.emit()
|
||||
)
|
||||
confirm_dialog.canceled.connect(
|
||||
func():
|
||||
_confirmed = false
|
||||
confirmation_closed.emit()
|
||||
confirmation_canceled.emit()
|
||||
)
|
||||
|
||||
# Setup styles
|
||||
set("theme_override_styles/panel", get_theme_stylebox("panel", "Panel"))
|
||||
@@ -155,7 +165,7 @@ func update_layout() -> void:
|
||||
if not _initialized:
|
||||
return
|
||||
if plugin.debug > 1:
|
||||
print("Terrain3DAssetDock: update_layout")
|
||||
print("Terrain3DAssetDock: update_layout")
|
||||
|
||||
## Detect if we have a new window from `Make floating` and grab it
|
||||
if not window:
|
||||
@@ -163,12 +173,12 @@ func update_layout() -> void:
|
||||
window = get_parent().get_parent().get_parent()
|
||||
_on_pin_changed(pinned_btn.button_pressed)
|
||||
plugin.godot_editor_window.mouse_entered.connect(_on_godot_window_entered)
|
||||
return # Displaying will call this function again
|
||||
return # Displaying will call this function again
|
||||
# Check if window was just freed. Freed objects have a different hash than null
|
||||
elif hash(window) != hash(null):
|
||||
window = null
|
||||
plugin.godot_editor_window.mouse_entered.disconnect(_on_godot_window_entered)
|
||||
return # Will call this function again upon display
|
||||
return # Will call this function again upon display
|
||||
|
||||
## Vertical layout: buttons on top
|
||||
if size.x < 700:
|
||||
@@ -180,7 +190,7 @@ func update_layout() -> void:
|
||||
box.move_child(size_slider, 2)
|
||||
pinned_btn.reparent(buttons)
|
||||
else:
|
||||
# Wide layout: buttons on left
|
||||
# Wide layout: buttons on left
|
||||
box.vertical = false
|
||||
buttons.vertical = true
|
||||
search_box.reparent(buttons)
|
||||
@@ -205,8 +215,8 @@ func set_selected_by_asset_id(p_id: int) -> void:
|
||||
search_box.text = ""
|
||||
_on_search_text_changed()
|
||||
current_list.set_selected_id(p_id)
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_search_text_changed() -> void:
|
||||
if plugin.debug:
|
||||
print("Terrain3DAssetDock: _on_search_text_changed: ", search_box.text)
|
||||
@@ -217,7 +227,7 @@ func _on_search_text_changed() -> void:
|
||||
search_button.icon = get_theme_icon("Close", "EditorIcons")
|
||||
else:
|
||||
search_button.icon = get_theme_icon("Search", "EditorIcons")
|
||||
|
||||
|
||||
mesh_list.search_text = search_box.text
|
||||
texture_list.search_text = search_box.text
|
||||
current_list.update_asset_list()
|
||||
@@ -298,7 +308,7 @@ func _on_tool_changed(p_tool: Terrain3DEditor.Tool, p_operation: Terrain3DEditor
|
||||
print("Terrain3DAssetDock: _on_tool_changed: ", p_tool, ", ", p_operation)
|
||||
if p_tool == Terrain3DEditor.INSTANCER:
|
||||
_on_meshes_pressed()
|
||||
elif p_tool in [ Terrain3DEditor.TEXTURE, Terrain3DEditor.COLOR, Terrain3DEditor.ROUGHNESS ]:
|
||||
elif p_tool in [Terrain3DEditor.TEXTURE, Terrain3DEditor.COLOR, Terrain3DEditor.ROUGHNESS]:
|
||||
_on_textures_pressed()
|
||||
|
||||
|
||||
@@ -307,10 +317,12 @@ func _on_tool_changed(p_tool: Terrain3DEditor.Tool, p_operation: Terrain3DEditor
|
||||
|
||||
func update_assets() -> void:
|
||||
if plugin.debug:
|
||||
print("Terrain3DAssetDock: update_assets: ", plugin.terrain.assets if plugin.terrain else "")
|
||||
print(
|
||||
"Terrain3DAssetDock: update_assets: ", plugin.terrain.assets if plugin.terrain else ""
|
||||
)
|
||||
if not _initialized:
|
||||
return
|
||||
|
||||
|
||||
# Verify signals to individual lists
|
||||
if plugin.is_terrain_valid() and plugin.terrain.assets:
|
||||
if not plugin.terrain.assets.textures_changed.is_connected(texture_list.update_asset_list):
|
||||
@@ -327,7 +339,7 @@ func update_assets() -> void:
|
||||
func load_editor_settings() -> void:
|
||||
# Remove old editor settings
|
||||
const ES_DOCK: String = "terrain3d/dock/"
|
||||
for setting in [ "slot", "floating", "window_position", "window_size" ]:
|
||||
for setting in ["slot", "floating", "window_position", "window_size"]:
|
||||
plugin.erase_setting(ES_DOCK + setting)
|
||||
pinned_btn.button_pressed = plugin.get_setting(ES_DOCK_PINNED, true)
|
||||
size_slider.value = plugin.get_setting(ES_DOCK_TILE_SIZE, 90)
|
||||
@@ -350,8 +362,9 @@ func save_editor_settings() -> void:
|
||||
## class ListContainer
|
||||
##############################################################
|
||||
|
||||
|
||||
class ListContainer extends Container:
|
||||
|
||||
class ListContainer:
|
||||
extends Container
|
||||
var plugin: EditorPlugin
|
||||
var type := Terrain3DAssets.TYPE_TEXTURE
|
||||
var entries: Array[ListEntry]
|
||||
@@ -362,7 +375,6 @@ class ListContainer extends Container:
|
||||
var _clearing_resource: bool = false
|
||||
var search_text: String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_v_size_flags(SIZE_EXPAND_FILL)
|
||||
set_h_size_flags(SIZE_EXPAND_FILL)
|
||||
@@ -371,24 +383,22 @@ class ListContainer extends Container:
|
||||
add_theme_constant_override("shadow_offset_x", 1)
|
||||
add_theme_constant_override("shadow_offset_y", 1)
|
||||
|
||||
|
||||
func clear() -> void:
|
||||
for e in entries:
|
||||
e.get_parent().remove_child(e)
|
||||
e.queue_free()
|
||||
entries.clear()
|
||||
|
||||
|
||||
func update_asset_list() -> void:
|
||||
if plugin.debug:
|
||||
print("Terrain3DListContainer ", name, ": update_asset_list")
|
||||
clear()
|
||||
|
||||
|
||||
# Grab terrain
|
||||
var t: Terrain3D = plugin.get_terrain()
|
||||
if not (t and t.assets):
|
||||
return
|
||||
|
||||
|
||||
if type == Terrain3DAssets.TYPE_TEXTURE:
|
||||
var texture_count: int = t.assets.get_texture_count()
|
||||
for i in texture_count:
|
||||
@@ -407,7 +417,6 @@ class ListContainer extends Container:
|
||||
add_item()
|
||||
set_selected_id(selected_id)
|
||||
|
||||
|
||||
func add_item(p_resource: Resource = null) -> void:
|
||||
var entry: ListEntry = ListEntry.new()
|
||||
entry.focus_style = focus_style
|
||||
@@ -423,58 +432,79 @@ class ListContainer extends Container:
|
||||
entry.type = type
|
||||
add_child(entry, true)
|
||||
entries.push_back(entry)
|
||||
|
||||
|
||||
if p_resource:
|
||||
if not p_resource.id_changed.is_connected(set_selected_after_swap):
|
||||
p_resource.id_changed.connect(set_selected_after_swap)
|
||||
|
||||
|
||||
func _on_resource_hovered(p_id: int):
|
||||
if type == Terrain3DAssets.TYPE_MESH:
|
||||
if plugin.terrain:
|
||||
plugin.terrain.assets.create_mesh_thumbnails(p_id)
|
||||
|
||||
|
||||
func set_selected_after_swap(p_type: Terrain3DAssets.AssetType, p_old_id: int, p_new_id: int) -> void:
|
||||
func set_selected_after_swap(
|
||||
p_type: Terrain3DAssets.AssetType, p_old_id: int, p_new_id: int
|
||||
) -> void:
|
||||
EditorInterface.mark_scene_as_unsaved()
|
||||
set_selected_id(clamp(p_new_id, 0, entries.size() - 2))
|
||||
|
||||
|
||||
func clicked_id(p_id: int) -> void:
|
||||
# Select Tool if clicking an asset
|
||||
plugin.select_terrain()
|
||||
if type == Terrain3DAssets.TYPE_TEXTURE and \
|
||||
not plugin.editor.get_tool() in [ Terrain3DEditor.TEXTURE, Terrain3DEditor.COLOR, Terrain3DEditor.ROUGHNESS ]:
|
||||
if (
|
||||
type == Terrain3DAssets.TYPE_TEXTURE
|
||||
and not (
|
||||
plugin.editor.get_tool()
|
||||
in [Terrain3DEditor.TEXTURE, Terrain3DEditor.COLOR, Terrain3DEditor.ROUGHNESS]
|
||||
)
|
||||
):
|
||||
var paint_btn: Button = plugin.ui.toolbar.get_node_or_null("PaintTexture")
|
||||
if paint_btn:
|
||||
paint_btn.set_pressed(true)
|
||||
plugin.ui._on_tool_changed(Terrain3DEditor.TEXTURE, Terrain3DEditor.REPLACE)
|
||||
elif type == Terrain3DAssets.TYPE_MESH and plugin.editor.get_tool() != Terrain3DEditor.INSTANCER:
|
||||
elif (
|
||||
type == Terrain3DAssets.TYPE_MESH
|
||||
and plugin.editor.get_tool() != Terrain3DEditor.INSTANCER
|
||||
):
|
||||
var instancer_btn: Button = plugin.ui.toolbar.get_node_or_null("InstanceMeshes")
|
||||
if instancer_btn:
|
||||
instancer_btn.set_pressed(true)
|
||||
plugin.ui._on_tool_changed(Terrain3DEditor.INSTANCER, Terrain3DEditor.ADD)
|
||||
set_selected_id(p_id)
|
||||
|
||||
|
||||
func set_selected_id(p_id: int) -> void:
|
||||
# "Add new" is the final entry only when search box is blank
|
||||
var max_id: int = max(0, entries.size() - (1 if search_text else 2))
|
||||
if plugin.debug:
|
||||
print("Terrain3DListContainer ", name, ": set_selected_id: ", selected_id, " to ", clamp(p_id, 0, max_id))
|
||||
print(
|
||||
"Terrain3DListContainer ",
|
||||
name,
|
||||
": set_selected_id: ",
|
||||
selected_id,
|
||||
" to ",
|
||||
clamp(p_id, 0, max_id)
|
||||
)
|
||||
selected_id = clamp(p_id, 0, max_id)
|
||||
for i in entries.size():
|
||||
var entry: ListEntry = entries[i]
|
||||
entry.set_selected(i == selected_id)
|
||||
plugin.ui._on_setting_changed()
|
||||
|
||||
|
||||
func get_selected_asset_id() -> int:
|
||||
# "Add new" is the final entry only when search box is blank
|
||||
var max_id: int = max(0, entries.size() - (1 if search_text else 2))
|
||||
var id: int = clamp(selected_id, 0, max_id)
|
||||
if plugin.debug:
|
||||
print("Terrain3DListContainer ", name, ": get_selected_asset_id: selected_id: ", selected_id, ", clamped: ", id, ", entries: ", entries.size())
|
||||
print(
|
||||
"Terrain3DListContainer ",
|
||||
name,
|
||||
": get_selected_asset_id: selected_id: ",
|
||||
selected_id,
|
||||
", clamped: ",
|
||||
id,
|
||||
", entries: ",
|
||||
entries.size()
|
||||
)
|
||||
if id >= entries.size():
|
||||
return 0
|
||||
var res: Resource = entries[id].resource
|
||||
@@ -485,18 +515,21 @@ class ListContainer extends Container:
|
||||
else:
|
||||
return (res as Terrain3DTextureAsset).id
|
||||
|
||||
|
||||
func _on_resource_inspected(p_resource: Resource) -> void:
|
||||
await get_tree().process_frame
|
||||
EditorInterface.edit_resource(p_resource)
|
||||
|
||||
|
||||
|
||||
func _on_resource_changed(p_resource: Resource, p_id: int) -> void:
|
||||
if not p_resource and _clearing_resource:
|
||||
return
|
||||
if not p_resource:
|
||||
if plugin.debug:
|
||||
print("Terrain3DListContainer ", name, ": _on_resource_changed: removing asset ID: ", p_id)
|
||||
print(
|
||||
"Terrain3DListContainer ",
|
||||
name,
|
||||
": _on_resource_changed: removing asset ID: ",
|
||||
p_id
|
||||
)
|
||||
_clearing_resource = true
|
||||
var asset_dock: Control = get_parent().get_parent().get_parent()
|
||||
if type == Terrain3DAssets.TYPE_TEXTURE:
|
||||
@@ -509,7 +542,7 @@ class ListContainer extends Container:
|
||||
update_asset_list()
|
||||
_clearing_resource = false
|
||||
return
|
||||
|
||||
|
||||
if not plugin.is_terrain_valid():
|
||||
plugin.select_terrain()
|
||||
await get_tree().process_frame
|
||||
@@ -522,19 +555,16 @@ class ListContainer extends Container:
|
||||
|
||||
# If removing an entry, clear inspector
|
||||
if not p_resource:
|
||||
EditorInterface.inspect_object(null)
|
||||
EditorInterface.inspect_object(null)
|
||||
_clearing_resource = false
|
||||
|
||||
|
||||
func set_entry_width(value: float) -> void:
|
||||
var min_width: float = 90.0 * max(1.0, EditorInterface.get_editor_scale())
|
||||
width = clamp(value, min_width, 512.0)
|
||||
redraw()
|
||||
|
||||
|
||||
func get_entry_width() -> float:
|
||||
return width
|
||||
|
||||
|
||||
func redraw() -> void:
|
||||
height = 0
|
||||
@@ -543,22 +573,24 @@ class ListContainer extends Container:
|
||||
var columns: int = 3
|
||||
columns = clamp(size.x / width, 1, 100)
|
||||
var tile_size: Vector2 = Vector2(width, width) - Vector2(separation, separation)
|
||||
var name_font_size := int(clamp(tile_size.x/12., 12., 16.) * EditorInterface.get_editor_scale())
|
||||
var name_font_size := int(
|
||||
clamp(tile_size.x / 12., 12., 16.) * EditorInterface.get_editor_scale()
|
||||
)
|
||||
for c in get_children():
|
||||
if is_instance_valid(c):
|
||||
c.size = tile_size
|
||||
c.position = Vector2(id % columns, id / columns) * width + \
|
||||
Vector2(separation / columns, separation / columns)
|
||||
c.position = (
|
||||
Vector2(id % columns, id / columns) * width
|
||||
+ Vector2(separation / columns, separation / columns)
|
||||
)
|
||||
height = max(height, c.position.y + width)
|
||||
id += 1
|
||||
c.name_label.add_theme_font_size_override("font_size", name_font_size)
|
||||
|
||||
|
||||
# Needed to enable ScrollContainer scroll bar
|
||||
func _get_minimum_size() -> Vector2:
|
||||
return Vector2(0, height)
|
||||
|
||||
|
||||
func _notification(p_what) -> void:
|
||||
if p_what == NOTIFICATION_SORT_CHILDREN:
|
||||
redraw()
|
||||
@@ -569,24 +601,25 @@ class ListContainer extends Container:
|
||||
##############################################################
|
||||
|
||||
|
||||
class ListEntry extends MarginContainer:
|
||||
signal hovered()
|
||||
signal clicked()
|
||||
class ListEntry:
|
||||
extends MarginContainer
|
||||
signal hovered
|
||||
signal clicked
|
||||
signal changed(resource: Resource)
|
||||
signal inspected(resource: Resource)
|
||||
|
||||
|
||||
var resource: Resource
|
||||
var type := Terrain3DAssets.TYPE_TEXTURE
|
||||
var _thumbnail: Texture2D
|
||||
var drop_data: bool = false
|
||||
var is_hovered: bool = false
|
||||
var is_selected: bool = false
|
||||
|
||||
|
||||
var name_label: Label
|
||||
var button_row: FlowContainer
|
||||
var button_enabled: TextureButton
|
||||
var button_edit: TextureButton
|
||||
var spacer: Control
|
||||
var spacer: Control
|
||||
var button_clear: TextureButton
|
||||
|
||||
@onready var focus_style: StyleBox = get_theme_stylebox("focus", "Button").duplicate()
|
||||
@@ -597,7 +630,6 @@ class ListEntry extends MarginContainer:
|
||||
@onready var disabled_icon: Texture2D = get_theme_icon("GuiVisibilityHidden", "EditorIcons")
|
||||
@onready var add_icon: Texture2D = get_theme_icon("Add", "EditorIcons")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
name = "ListEntry"
|
||||
custom_minimum_size = Vector2i(86., 86.)
|
||||
@@ -611,18 +643,17 @@ class ListEntry extends MarginContainer:
|
||||
focus_style.set_border_width_all(2)
|
||||
focus_style.set_border_color(Color(1, 1, 1, .67))
|
||||
|
||||
|
||||
func setup_buttons() -> void:
|
||||
destroy_buttons()
|
||||
|
||||
|
||||
button_row = FlowContainer.new()
|
||||
button_enabled = TextureButton.new()
|
||||
button_edit = TextureButton.new()
|
||||
button_enabled = TextureButton.new()
|
||||
button_edit = TextureButton.new()
|
||||
spacer = Control.new()
|
||||
button_clear = TextureButton.new()
|
||||
|
||||
|
||||
var icon_size: Vector2 = Vector2(12, 12)
|
||||
|
||||
|
||||
button_row.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
button_row.alignment = FlowContainer.ALIGNMENT_CENTER
|
||||
button_row.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
@@ -640,7 +671,7 @@ class ListEntry extends MarginContainer:
|
||||
button_enabled.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
button_enabled.pressed.connect(_on_enable)
|
||||
button_row.add_child(button_enabled, true)
|
||||
|
||||
|
||||
button_edit.set_texture_normal(edit_icon)
|
||||
button_edit.set_custom_minimum_size(icon_size)
|
||||
button_edit.set_h_size_flags(Control.SIZE_SHRINK_END)
|
||||
@@ -654,7 +685,7 @@ class ListEntry extends MarginContainer:
|
||||
spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
spacer.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
button_row.add_child(spacer, true)
|
||||
|
||||
|
||||
button_clear.set_texture_normal(clear_icon)
|
||||
button_clear.set_custom_minimum_size(icon_size)
|
||||
button_clear.set_h_size_flags(Control.SIZE_SHRINK_END)
|
||||
@@ -664,7 +695,6 @@ class ListEntry extends MarginContainer:
|
||||
button_clear.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
button_clear.pressed.connect(_on_clear)
|
||||
button_row.add_child(button_clear, true)
|
||||
|
||||
|
||||
func destroy_buttons() -> void:
|
||||
if button_row:
|
||||
@@ -683,7 +713,6 @@ class ListEntry extends MarginContainer:
|
||||
button_clear.free()
|
||||
button_clear = null
|
||||
|
||||
|
||||
func get_resource_name() -> StringName:
|
||||
if resource:
|
||||
if resource is Terrain3DMeshAsset:
|
||||
@@ -692,7 +721,6 @@ class ListEntry extends MarginContainer:
|
||||
return (resource as Terrain3DTextureAsset).get_name()
|
||||
return ""
|
||||
|
||||
|
||||
func setup_label() -> void:
|
||||
name_label = Label.new()
|
||||
name_label.name = "MeshLabel"
|
||||
@@ -700,17 +728,18 @@ class ListEntry extends MarginContainer:
|
||||
name_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
name_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_label.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
name_label.add_theme_font_size_override("font_size", int(14. * EditorInterface.get_editor_scale()))
|
||||
name_label.add_theme_font_size_override(
|
||||
"font_size", int(14. * EditorInterface.get_editor_scale())
|
||||
)
|
||||
name_label.add_theme_color_override("font_color", Color.WHITE)
|
||||
name_label.add_theme_color_override("font_shadow_color", Color.BLACK)
|
||||
name_label.add_theme_constant_override("shadow_offset_x", 1)
|
||||
name_label.add_theme_constant_override("shadow_offset_y", 1)
|
||||
name_label.visible = false
|
||||
name_label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
name_label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
name_label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
add_child(name_label, true)
|
||||
|
||||
|
||||
func _notification(p_what) -> void:
|
||||
match p_what:
|
||||
NOTIFICATION_PREDELETE:
|
||||
@@ -758,7 +787,6 @@ class ListEntry extends MarginContainer:
|
||||
drop_data = false
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _gui_input(p_event: InputEvent) -> void:
|
||||
if p_event is InputEventMouseButton:
|
||||
if p_event.is_pressed():
|
||||
@@ -780,7 +808,6 @@ class ListEntry extends MarginContainer:
|
||||
if resource:
|
||||
_on_clear()
|
||||
|
||||
|
||||
func _can_drop_data(p_at_position: Vector2, p_data: Variant) -> bool:
|
||||
drop_data = false
|
||||
if typeof(p_data) == TYPE_DICTIONARY:
|
||||
@@ -789,7 +816,6 @@ class ListEntry extends MarginContainer:
|
||||
drop_data = true
|
||||
return drop_data
|
||||
|
||||
|
||||
func _drop_data(p_at_position: Vector2, p_data: Variant) -> void:
|
||||
if typeof(p_data) == TYPE_DICTIONARY:
|
||||
var res: Resource = load(p_data.files[0])
|
||||
@@ -806,7 +832,7 @@ class ListEntry extends MarginContainer:
|
||||
set_edited_resource(res, false)
|
||||
elif res is PackedScene and type == Terrain3DAssets.TYPE_MESH:
|
||||
if not resource:
|
||||
resource = Terrain3DMeshAsset.new()
|
||||
resource = Terrain3DMeshAsset.new()
|
||||
set_edited_resource(resource, false)
|
||||
resource.set_scene_file(res)
|
||||
elif res is Terrain3DMeshAsset and type == Terrain3DAssets.TYPE_MESH:
|
||||
@@ -816,7 +842,6 @@ class ListEntry extends MarginContainer:
|
||||
emit_signal("clicked")
|
||||
emit_signal("inspected", resource)
|
||||
|
||||
|
||||
func set_edited_resource(p_res: Resource, p_no_signal: bool = true) -> void:
|
||||
resource = p_res
|
||||
if resource:
|
||||
@@ -828,20 +853,18 @@ class ListEntry extends MarginContainer:
|
||||
elif resource is Terrain3DMeshAsset:
|
||||
if not resource.instancer_setting_changed.is_connected(_on_resource_changed):
|
||||
resource.instancer_setting_changed.connect(_on_resource_changed)
|
||||
|
||||
|
||||
if button_clear:
|
||||
button_clear.set_visible(resource != null)
|
||||
|
||||
|
||||
queue_redraw()
|
||||
if not p_no_signal:
|
||||
emit_signal("changed", resource)
|
||||
|
||||
|
||||
func _on_resource_changed(_value: int = 0) -> void:
|
||||
queue_redraw()
|
||||
emit_signal("changed", resource)
|
||||
|
||||
|
||||
func set_selected(value: bool) -> void:
|
||||
if not is_inside_tree():
|
||||
#push_error("not in tree")
|
||||
@@ -851,26 +874,24 @@ class ListEntry extends MarginContainer:
|
||||
# Handle scrolling to show the selected item
|
||||
await get_tree().process_frame
|
||||
if is_inside_tree():
|
||||
get_parent().get_parent().get_v_scroll_bar().ratio = position.y / get_parent().size.y
|
||||
get_parent().get_parent().get_v_scroll_bar().ratio = (
|
||||
position.y / get_parent().size.y
|
||||
)
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _on_clear() -> void:
|
||||
if resource:
|
||||
name_label.hide()
|
||||
set_edited_resource(null, false)
|
||||
|
||||
|
||||
func _on_edit() -> void:
|
||||
emit_signal("clicked")
|
||||
emit_signal("inspected", resource)
|
||||
|
||||
|
||||
func _on_enable() -> void:
|
||||
if resource is Terrain3DMeshAsset:
|
||||
resource.set_enabled(!resource.is_enabled())
|
||||
|
||||
|
||||
func _format_number(num: int) -> String:
|
||||
var is_negative: bool = num < 0
|
||||
var str_num: String = str(abs(num))
|
||||
|
||||
Reference in New Issue
Block a user