built more assets and started playing with foliage painting
This commit is contained in:
171
addons/dreadpon.spatial_gardener/utility/console/console.gd
Normal file
171
addons/dreadpon.spatial_gardener/utility/console/console.gd
Normal file
@@ -0,0 +1,171 @@
|
||||
extends Control
|
||||
|
||||
|
||||
const Gardener = preload("../../gardener/gardener.gd")
|
||||
|
||||
@onready var input_field:TextEdit = $VBoxContainer/InputField
|
||||
@onready var output_field:RichTextLabel = $VBoxContainer/OutputField
|
||||
|
||||
@export var block_input_PTH:Array = [] # (Array, NodePath)
|
||||
var block_input:Array = []
|
||||
|
||||
var last_mouse_mode:int
|
||||
|
||||
|
||||
|
||||
|
||||
func _ready():
|
||||
for node_pth in block_input_PTH:
|
||||
if has_node(node_pth):
|
||||
block_input.append(get_node(node_pth))
|
||||
|
||||
if visible:
|
||||
input_field.grab_focus()
|
||||
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
if is_instance_of(event, InputEventKey) && event.keycode == KEY_QUOTELEFT && !event.pressed:
|
||||
toggle_console()
|
||||
|
||||
if !visible: return
|
||||
|
||||
if is_instance_of(event, InputEventKey):
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
if !event.pressed:
|
||||
match event.keycode:
|
||||
KEY_ENTER:
|
||||
input_field.text = input_field.text.trim_suffix("\n")
|
||||
try_execute_command()
|
||||
KEY_ESCAPE:
|
||||
toggle_console()
|
||||
|
||||
|
||||
func toggle_console():
|
||||
if !visible:
|
||||
visible = true
|
||||
last_mouse_mode = Input.get_mouse_mode()
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
input_field.grab_focus()
|
||||
else:
|
||||
visible = false
|
||||
clear_command()
|
||||
Input.set_mouse_mode(last_mouse_mode)
|
||||
set_nodes_input_state(!visible)
|
||||
|
||||
|
||||
func set_nodes_input_state(state:bool):
|
||||
for node in block_input:
|
||||
node.set_process_input(state)
|
||||
|
||||
|
||||
func try_execute_command():
|
||||
if input_field.text.is_empty(): return
|
||||
var result = parse_and_execute(input_field.text)
|
||||
clear_command()
|
||||
print_output(result)
|
||||
|
||||
|
||||
func clear_command():
|
||||
input_field.text = ""
|
||||
|
||||
|
||||
func print_output(string:String):
|
||||
output_field.append_bbcode(string + "\n\n")
|
||||
|
||||
|
||||
func parse_and_execute(string:String):
|
||||
var args:PackedStringArray = string.split(" ")
|
||||
|
||||
match args[0]:
|
||||
"dump_octrees":
|
||||
return dump_octrees(args)
|
||||
"dump_scene_tree":
|
||||
return debug_scene_tree()
|
||||
"clear":
|
||||
output_field.text = ""
|
||||
return ""
|
||||
_:
|
||||
return "[color=red]Undefined command[/color]"
|
||||
|
||||
|
||||
|
||||
|
||||
func dump_octrees(args:Array = []):
|
||||
var current_scene := get_tree().get_current_scene()
|
||||
var gardener_path := ""
|
||||
var octree_index := -1
|
||||
|
||||
if args.size() > 1:
|
||||
if current_scene.has_node(args[1]) && is_instance_of(current_scene.get_node(args[1]), Gardener):
|
||||
gardener_path = args[1]
|
||||
else:
|
||||
return "[color=red]'%s' wrong node path in argument '%d'[/color]" % [args[0], 1]
|
||||
|
||||
if args.size() > 2:
|
||||
if args[2].is_valid_int():
|
||||
octree_index = args[2].to_int()
|
||||
else:
|
||||
return "[color=red]'%s' wrong type in argument '%d'[/color]" % [args[0], 2]
|
||||
|
||||
if gardener_path.is_empty():
|
||||
return dump_octrees_from_node(current_scene)
|
||||
elif octree_index < 0:
|
||||
return dump_octrees_from_gardener(current_scene.get_node(args[1]))
|
||||
else:
|
||||
return dump_octrees_at_index(current_scene.get_node(args[1]), octree_index)
|
||||
|
||||
|
||||
func dump_octrees_from_node(node:Node):
|
||||
var output := ""
|
||||
|
||||
if is_instance_of(node, Gardener):
|
||||
output += dump_octrees_from_gardener(node)
|
||||
else:
|
||||
for child in node.get_children():
|
||||
output += dump_octrees_from_node(child)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
func dump_octrees_from_gardener(gardener:Gardener):
|
||||
var output := ""
|
||||
|
||||
for i in range(0, gardener.get_node("Arborist").octree_managers.size()):
|
||||
output += dump_octrees_at_index(gardener, i)
|
||||
|
||||
return output
|
||||
|
||||
|
||||
func dump_octrees_at_index(gardener:Gardener, index:int):
|
||||
var output := ""
|
||||
|
||||
var octree_manager = gardener.get_node("Arborist").octree_managers[index]
|
||||
output += octree_manager.root_octree_node.debug_dump_tree() + "\n"
|
||||
|
||||
return output
|
||||
|
||||
|
||||
|
||||
|
||||
func debug_scene_tree():
|
||||
var current_scene := get_tree().get_current_scene()
|
||||
return dump_node_descendants(current_scene)
|
||||
|
||||
|
||||
func dump_node_descendants(node:Node, intendation:int = 0):
|
||||
var output := ""
|
||||
|
||||
var intend_str = ""
|
||||
for i in range(0, intendation):
|
||||
intend_str += " "
|
||||
var string = "%s%s" % [intend_str, str(node)]
|
||||
|
||||
output += string + "\n"
|
||||
|
||||
intendation += 1
|
||||
for child in node.get_children():
|
||||
output += dump_node_descendants(child, intendation)
|
||||
|
||||
return output
|
||||
@@ -0,0 +1,35 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cpcmbwh1aqb4x"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dreadpon.spatial_gardener/utility/console/console.gd" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/dreadpon.spatial_gardener/utility/console/console_input_field.gd" id="4"]
|
||||
[ext_resource type="Script" path="res://addons/dreadpon.spatial_gardener/utility/console/console_output.gd" id="5"]
|
||||
|
||||
[node name="Console" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="OutputField" type="RichTextLabel" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("5")
|
||||
|
||||
[node name="InputField" type="TextEdit" parent="VBoxContainer"]
|
||||
custom_minimum_size = Vector2(0, 80)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
caret_blink = true
|
||||
script = ExtResource("4")
|
||||
@@ -0,0 +1,17 @@
|
||||
@tool
|
||||
extends TextEdit
|
||||
|
||||
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if visible:
|
||||
call_deferred("_hide_scrollbar")
|
||||
|
||||
|
||||
func _hide_scrollbar():
|
||||
for child in get_children():
|
||||
if is_instance_of(child, VScrollBar):
|
||||
child.visible = false
|
||||
elif is_instance_of(child, HScrollBar):
|
||||
child.visible = false
|
||||
@@ -0,0 +1,12 @@
|
||||
@tool
|
||||
extends RichTextLabel
|
||||
|
||||
|
||||
@export var scrollbar_size = 24
|
||||
|
||||
func _ready():
|
||||
for child in get_children():
|
||||
if is_instance_of(child, VScrollBar):
|
||||
child.custom_minimum_size.x = scrollbar_size
|
||||
elif is_instance_of(child, HScrollBar):
|
||||
child.custom_minimum_size.y = scrollbar_size
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="FontFile" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/dreadpon.spatial_gardener/utility/console/fonts/ttf/AnonymousPro-Regular.ttf" type="FontFile" id=1]
|
||||
|
||||
[resource]
|
||||
size = 100
|
||||
use_filter = true
|
||||
extra_spacing_char = 4
|
||||
font_data = ExtResource( 1 )
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="FontFile" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/dreadpon.spatial_gardener/utility/console/fonts/ttf/Urbanist-Regular.ttf" type="FontFile" id=1]
|
||||
|
||||
[resource]
|
||||
size = 64
|
||||
use_filter = true
|
||||
font_data = ExtResource( 1 )
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_resource type="FontVariation" load_steps=2 format=3 uid="uid://dokuyg8sikplj"]
|
||||
|
||||
[ext_resource type="FontFile" path="res://addons/dreadpon.spatial_gardener/utility/console/fonts/dynamic/urbanist_regular.tres" id="1_h16sp"]
|
||||
|
||||
[resource]
|
||||
base_font = ExtResource("1_h16sp")
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://btfidab8p3wbu"
|
||||
path="res://.godot/imported/AnonymousPro-Regular.ttf-208ecbb66c73e515f403daaeae3d36ae.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dreadpon.spatial_gardener/utility/console/fonts/ttf/AnonymousPro-Regular.ttf"
|
||||
dest_files=["res://.godot/imported/AnonymousPro-Regular.ttf-208ecbb66c73e515f403daaeae3d36ae.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://btvadi4yk0a3y"
|
||||
path="res://.godot/imported/Urbanist-Regular.ttf-43977583ef0eb0baed07360c77f30dfb.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dreadpon.spatial_gardener/utility/console/fonts/ttf/Urbanist-Regular.ttf"
|
||||
dest_files=["res://.godot/imported/Urbanist-Regular.ttf-43977583ef0eb0baed07360c77f30dfb.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
Reference in New Issue
Block a user