Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions addons/material_maker/engine/nodes/gen_comment.gd
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
@tool
extends MMGenTexture
extends MMGenBase
class_name MMGenComment


# Comments to put in the graph


var text : String = ""
var size : Vector2 = Vector2(300, 200)
var size : Vector2 = Vector2(350, 200)
var title : String = "Comment"
var autoshrink : bool = false

var attached : PackedStringArray

var color = null

func _ready() -> void:
if !parameters.has("size"):
parameters.size = 4
if color == null:
color = Color.WHITE if "light" in mm_globals.main_window.theme.resource_path else Color.BLACK
color = Color.WHITE if mm_globals.is_theme_light() else Color.BLACK

func get_type() -> String:
return "comment"

func get_type_name() -> String:
return "Comment"

func get_parameter_defs() -> Array:
return []

func get_input_defs() -> Array:
return []

func get_output_defs(_show_hidden : bool = false) -> Array:
return []

func _serialize(data: Dictionary) -> Dictionary:
func _serialize(data : Dictionary) -> Dictionary:
data.type = "comment"
data.title = title
data.color = MMType.serialize_value(color)
data.text = text
data.size = { x=size.x, y=size.y }
data.autoshrink = autoshrink
data.attached = attached
data.erase("parameters")
return data

func _deserialize(data : Dictionary) -> void:
Expand All @@ -50,3 +45,7 @@ func _deserialize(data : Dictionary) -> void:
title = data.title
if data.has("color"):
color = MMType.deserialize_value(data.color)
if data.has("autoshrink"):
autoshrink = data.autoshrink
if data.has("attached"):
attached = data.attached
8 changes: 8 additions & 0 deletions material_maker/globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,11 @@ func get_node_title_from_gen(generator : MMGenBase) -> String:
var gnode : GraphNode = graph.get_node(node_path)
return gnode.title.to_snake_case()
return "unnamed"

## Whether light theme (i.e. Default Light) is currently set.
func is_theme_light() -> bool:
return "light" in main_window.theme.resource_path

## Whether dark theme(i.e. Default Dark or Classic) is currently set.
func is_theme_dark() -> bool:
return "light" not in main_window.theme.resource_path
1 change: 1 addition & 0 deletions material_maker/main_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ func frame_nodes() -> void:
# Avoid calling resize twice
if not mm_globals.get_config("auto_size_comment"):
nodes[0].resize_to_selection()
edit_select_none()
nodes[0].selected = true
graph_edit.undoredo.end_group()

Expand Down
2 changes: 2 additions & 0 deletions material_maker/node_factory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func create_node(generator : MMGenBase) -> Node:
return node

func set_theme_overrides(node, generator : MMGenBase = null) -> void:
if node is GraphFrame:
return
var theme : Theme = mm_globals.main_window.theme
if node.theme != null && node.theme != theme:
return
Expand Down
Loading
Loading