forked from RodZill4/material-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.gd
More file actions
89 lines (76 loc) · 2.93 KB
/
Copy pathconsole.gd
File metadata and controls
89 lines (76 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
extends HBoxContainer
# Called when the node enters the scene tree for the first time.
func _ready():
if mm_globals.has_config("ui_console_height"):
custom_minimum_size.y = mm_globals.get_config("ui_console_height")
custom_minimum_size.y = clamp(custom_minimum_size.y, 100, 650)
if mm_globals.has_config("ui_console_open"):
visible = mm_globals.get_config("ui_console_open")
%ConsoleResizer.visible = visible
mm_logger.set_logger(self)
func url_data_from_string(s : String) -> Dictionary:
var fields = s.split(",")
var data : Dictionary = {}
for f in fields:
var sep = f.split(":", 1)
if sep.size() == 2:
data[sep[0]] = sep[1]
return data
func string_to_bbcode(s : String) -> String:
var changed : bool = true
while changed:
changed = false
var l : int = s.find("[[")
if l != -1:
var l2 : int = s.find("]]", l)
if l2 != -1:
changed = true
var url : String = s.substr(l+2, l2-l-2)
var url_string : String = url
var data : Dictionary = url_data_from_string(url)
if data.has("type"):
match data.type:
"nodesection":
url_string = data.section+" section of node "+data.node
s = s.left(l)+"[color=\"#5884d6\"][url="+url+"]"+url_string+"[/url][/color]"+s.right(-l2-2)
return s
func write(l: String, m : String):
if l == "":
$RichTextLabel.text += string_to_bbcode(m)+"\n"
elif l == "ERROR":
$RichTextLabel.text += "[color=red]"+l+": "+m+"[/color]\n"
else:
$RichTextLabel.text += l+": "+m+"\n"
var generator = null
func _on_rich_text_label_meta_clicked(meta):
var data : Dictionary = url_data_from_string(meta)
match data.type:
"nodesection":
generator = instance_from_id(data.nodeid.right(-1).to_int())
if generator == null:
return
if Input.is_key_pressed(KEY_ALT):
generator.edit(self, data.section)
else:
var graph : MMGraphEdit = mm_globals.main_window.get_current_graph_edit()
if graph.generator != generator.get_parent():
graph.update_view(generator.get_parent())
var node : GraphNode = graph.get_node("node_" + generator.name)
graph.scroll_offset = (node.position_offset + 0.5*node.size) * graph.zoom - 0.5*graph.size
func update_shader_generator(shader_model) -> void:
generator.set_shader_model(shader_model)
func toggle():
visible = not visible
%ConsoleResizer.visible = visible
mm_globals.set_config("ui_console_open", visible)
func _on_console_resizer_gui_input(event: InputEvent) -> void:
if event is InputEventMouseMotion and (event.button_mask & MOUSE_BUTTON_MASK_LEFT) != 0:
custom_minimum_size.y -= get_local_mouse_position().y
if custom_minimum_size.y < 10:
toggle()
custom_minimum_size.y = min(max(custom_minimum_size.y, 100),650)
mm_globals.set_config("ui_console_height", custom_minimum_size.y)
func _on_rich_text_label_meta_hover_ended(_meta: Variant) -> void:
mm_globals.set_tip_text("")
func _on_rich_text_label_meta_hover_started(_meta: Variant) -> void:
mm_globals.set_tip_text("#LMB: Show Node, Alt+#LMB: Edit Node")