This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name FileSystemU | |
const NodeU = preload("node.gd") | |
static func get_tree(plugin:EditorPlugin): | |
var dock = plugin.get_editor_interface().get_file_system_dock() | |
return NodeU.get_child_by_class_path(dock, ['VSplitContainer','Tree']) | |
static func get_path(item:TreeItem)->String: | |
var res = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func get_main_screen(plugin:EditorPlugin)->int: | |
var idx = -1 | |
var base:Panel = plugin.get_editor_interface().get_base_control() | |
var button:ToolButton = find_node_by_class_path( | |
base, ['VBoxContainer', 'HBoxContainer', 'HBoxContainer', 'ToolButton'], false | |
) | |
if not button: | |
return idx | |
for b in button.get_parent().get_children(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func bankers_round_py(num:float)->float: | |
var rounded = round(num) | |
if abs(num-rounded) == 0.5: | |
rounded = 2.0*round(num/2.0) | |
return rounded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func bankers_round(num:float)->float: | |
if fmod(num, 0.5): | |
return round(num) | |
var floor_ = floor(num) | |
if floor_==num: | |
return num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NodeWalkWithDepth: | |
var stack = [] | |
var depth_stack = [] | |
var current | |
var max_depth:int | |
func _init(node:Node, max_depth_:int): | |
stack.append(node) | |
depth_stack.append(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name NodeWalk | |
extends StackIterator | |
func _init(node).(node): | |
pass | |
func _iter_(current): | |
for i in current.get_children(): | |
stack.push_back(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func snake2camel(string:String)->String: | |
var result = PoolStringArray() | |
var prev_is_underscore = false | |
for ch in string: | |
if ch=='_': | |
prev_is_underscore = true | |
else: | |
if prev_is_underscore: | |
result.append(ch.to_upper()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends LineEdit | |
var regex: = RegEx.new() | |
var oldtext: = "" | |
func _ready(): | |
regex.compile("^[0-9]*$") | |
connect("text_changed", self, "_on_LineEdit_text_changed") | |
func _on_LineEdit_text_changed(new_text:String): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name TreeUtils | |
static func get_child_by_text(item:TreeItem, text: String, col = 0): | |
item = item.get_children() | |
while item: | |
if item.get_text(col) == text: | |
return item | |
item = item.get_next() |