Skip to content

Commit 0a3e34e

Browse files
committed
Improve comment node
1 parent a8efcee commit 0a3e34e

File tree

12 files changed

+473
-268
lines changed

12 files changed

+473
-268
lines changed

addons/material_maker/engine/nodes/gen_comment.gd

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
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:
1920
color = Color.WHITE if "light" in mm_globals.main_window.theme.resource_path else Color.BLACK
2021

@@ -33,12 +34,14 @@ func get_input_defs() -> Array:
3334
func get_output_defs(_show_hidden : bool = false) -> Array:
3435
return []
3536

36-
func _serialize(data: Dictionary) -> Dictionary:
37+
func _serialize(data : Dictionary) -> Dictionary:
3738
data.type = "comment"
3839
data.title = title
3940
data.color = MMType.serialize_value(color)
4041
data.text = text
4142
data.size = { x=size.x, y=size.y }
43+
data.autoshrink = MMType.serialize_value(autoshrink)
44+
data.attached = attached
4245
return data
4346

4447
func _deserialize(data : Dictionary) -> void:
@@ -50,3 +53,7 @@ func _deserialize(data : Dictionary) -> void:
5053
title = data.title
5154
if data.has("color"):
5255
color = MMType.deserialize_value(data.color)
56+
if data.has("autoshrink"):
57+
autoshrink = MMType.deserialize_value(data.autoshrink)
58+
if data.has("attached"):
59+
attached = data.attached

material_maker/globals.gd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,11 @@ func interpret_file_name(file_name: String, path:="", file_extension:="",additio
235235
file_name = file_name.replace("$idx", str(1).pad_zeros(2))
236236

237237
return file_name
238+
239+
## Whether light theme (i.e. Default Light) is currently set.
240+
func is_theme_light() -> bool:
241+
return "light" in main_window.theme.resource_path
242+
243+
## Whether dark theme(i.e. Default Dark or Classic) is currently set.
244+
func is_theme_dark() -> bool:
245+
return "light" not in main_window.theme.resource_path

material_maker/main_window.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,6 @@ func frame_nodes() -> void:
10551055
# Avoid calling resize twice
10561056
if not mm_globals.get_config("auto_size_comment"):
10571057
nodes[0].resize_to_selection()
1058-
nodes[0].selected = true
10591058

10601059
func make_selected_nodes_editable() -> void:
10611060
var selected_nodes = get_selected_nodes()

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)