built more assets and started playing with foliage painting

This commit is contained in:
derek
2024-12-04 17:02:46 -06:00
parent dd960cc00e
commit 478e2822d2
359 changed files with 34172 additions and 178 deletions

View File

@@ -0,0 +1,13 @@
@tool
extends LineEdit
# Release focus from a child node when pressing enter
func _gui_input(event):
if has_focus():
if is_instance_of(event, InputEventKey) && !event.pressed:
if event.keycode == KEY_ENTER || event.keycode == KEY_ESCAPE:
release_focus()
if is_instance_of(self, LineEdit):
caret_column = 0

View File

@@ -0,0 +1,31 @@
@tool
extends Button
#-------------------------------------------------------------------------------
# A button that accepts drop events
# Kind of surprised I need to attach a separate script for that functionality :/
#-------------------------------------------------------------------------------
signal dropped
func _init():
set_meta("class", "UI_DropButton")
#-------------------------------------------------------------------------------
# Drag'n'drop handling
#-------------------------------------------------------------------------------
func _can_drop_data(position, data):
if typeof(data) == TYPE_DICTIONARY && data.has("files") && data["files"].size() == 1:
return true
func _drop_data(position, data):
dropped.emit(data["files"][0])

View File

@@ -0,0 +1,60 @@
@tool
extends GridContainer
#-------------------------------------------------------------------------------
# A grid that automatically changes number of columns based on it's max width
# For now works only when inside a ScrollContainer with both size flags set to SIZE_EXPAND_FILL
# lol
#-------------------------------------------------------------------------------
# TODO make this independent from a ScrollContainer or replace with someone else's solution
#-------------------------------------------------------------------------------
# Lifecycle
#-------------------------------------------------------------------------------
func _init():
set_meta("class", "UI_FlexGridContainer")
func _ready():
resized.connect(on_resized)
get_parent().resized.connect(on_resized)
func _enter_tree():
on_resized()
#-------------------------------------------------------------------------------
# Resize
#-------------------------------------------------------------------------------
func on_resized():
recalc_columns()
func recalc_columns():
var target_size := get_parent_area_size()
var factual_size := size
if columns > 1 && factual_size.x > target_size.x:
columns -= 1
var biggest_child_size := Vector2.ZERO
for child in get_children():
if child.size.x > biggest_child_size.x:
biggest_child_size.x = child.size.x
if child.size.y > biggest_child_size.y:
biggest_child_size.y = child.size.y
if biggest_child_size.x * (columns + 1) + get_theme_constant("h_separation") * columns < target_size.x:
columns += 1