Skip to content

Commit 3975fa7

Browse files
committed
Improve comment node
1 parent 7c7e91c commit 3975fa7

12 files changed

Lines changed: 466 additions & 316 deletions

File tree

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
11
@tool
2-
extends MMGenTexture
2+
extends MMGenBase
33
class_name MMGenComment
44

55

66
# Comments to put in the graph
77

88

99
var text : String = ""
10-
var size : Vector2 = Vector2(300, 200)
10+
var size : Vector2 = Vector2(350, 200)
1111
var title : String = "Comment"
12+
var autoshrink : bool = false
13+
14+
var attached : PackedStringArray
1215

1316
var color = null
1417

1518
func _ready() -> void:
16-
if !parameters.has("size"):
17-
parameters.size = 4
1819
if color == null:
19-
color = Color.WHITE if "light" in mm_globals.main_window.theme.resource_path else Color.BLACK
20+
color = Color.WHITE if mm_globals.is_theme_light() else Color.BLACK
2021

2122
func get_type() -> String:
2223
return "comment"
2324

2425
func get_type_name() -> String:
2526
return "Comment"
2627

27-
func get_parameter_defs() -> Array:
28-
return []
29-
30-
func get_input_defs() -> Array:
31-
return []
32-
33-
func get_output_defs(_show_hidden : bool = false) -> Array:
34-
return []
35-
36-
func _serialize(data: Dictionary) -> Dictionary:
28+
func _serialize(data : Dictionary) -> Dictionary:
3729
data.type = "comment"
3830
data.title = title
3931
data.color = MMType.serialize_value(color)
4032
data.text = text
4133
data.size = { x=size.x, y=size.y }
34+
data.autoshrink = autoshrink
35+
data.attached = attached
36+
data.erase("parameters")
4237
return data
4338

4439
func _deserialize(data : Dictionary) -> void:
@@ -50,3 +45,7 @@ func _deserialize(data : Dictionary) -> void:
5045
title = data.title
5146
if data.has("color"):
5247
color = MMType.deserialize_value(data.color)
48+
if data.has("autoshrink"):
49+
autoshrink = data.autoshrink
50+
if data.has("attached"):
51+
attached = data.attached

material_maker/globals.gd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,11 @@ func get_node_title_from_gen(generator : MMGenBase) -> String:
251251
var gnode : GraphNode = graph.get_node(node_path)
252252
return gnode.title.to_snake_case()
253253
return "unnamed"
254+
255+
## Whether light theme (i.e. Default Light) is currently set.
256+
func is_theme_light() -> bool:
257+
return "light" in main_window.theme.resource_path
258+
259+
## Whether dark theme(i.e. Default Dark or Classic) is currently set.
260+
func is_theme_dark() -> bool:
261+
return "light" not in main_window.theme.resource_path

material_maker/main_window.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ func frame_nodes() -> void:
10531053
# Avoid calling resize twice
10541054
if not mm_globals.get_config("auto_size_comment"):
10551055
nodes[0].resize_to_selection()
1056+
edit_select_none()
10561057
nodes[0].selected = true
10571058
graph_edit.undoredo.end_group()
10581059

material_maker/node_factory.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func create_node(generator : MMGenBase) -> Node:
2121
return node
2222

2323
func set_theme_overrides(node, generator : MMGenBase = null) -> void:
24+
if node is GraphFrame:
25+
return
2426
var theme : Theme = mm_globals.main_window.theme
2527
if node.theme != null && node.theme != theme:
2628
return

0 commit comments

Comments
 (0)