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
13 changes: 11 additions & 2 deletions material_maker/nodes/base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var custom_button : TextureButton
var show_inputs : bool = false
var show_outputs : bool = false

static var port_tex : DPITexture

const SETTINGS_NODE_MINIMIZE_BUTTON := "node_minimize_button"

const MINIMIZE_ICON : Texture2D = preload("res://material_maker/icons/minimize.tres")
Expand Down Expand Up @@ -37,6 +39,11 @@ const TIME_BAD : int = 1000
const TIME_AVG : int = 500
const TIME_GOOD : int = 100

const PORT_SVG : String = """
<svg width="10" height="10">
<circle r="5" cx="5" cy="5" fill="white"/></svg>
"""

## Emitted when nodes are being simplified as graph is zoomed out [br]
## [param fac] denotes the current level of detail (i.e. controls' opacity)
signal lod_updated(fac : float)
Expand All @@ -61,6 +68,8 @@ func _ready() -> void:
_notification(NOTIFICATION_THEME_CHANGED)
gui_input.connect(self._on_gui_input)
update.call_deferred()
if not port_tex:
port_tex = DPITexture.create_from_string(PORT_SVG)

func init_buttons():
super.init_buttons()
Expand Down Expand Up @@ -171,7 +180,7 @@ func on_theme_changed() -> void:
portpreview_width = get_theme_constant("portpreview_width", "GraphNode")


func _draw_port(slot_index: int, pos: Vector2i, left: bool, color: Color):
func _draw_port(slot_index : int, pos : Vector2i, left : bool, color : Color) -> void:
if left:
var inputs = generator.get_input_defs()
if slot_index < inputs.size() and inputs[slot_index].has("group_size") and inputs[slot_index].group_size > 1:
Expand All @@ -186,7 +195,7 @@ func _draw_port(slot_index: int, pos: Vector2i, left: bool, color: Color):
var conn_pos1 = get_output_port_position(slot_index)
var conn_pos2 = get_output_port_position(min(slot_index+outputs[slot_index].group_size-1, outputs.size()-1))
draw_portgroup_stylebox(conn_pos1, conn_pos2)
draw_circle(pos, 5, color, true, -1, true)
draw_texture(port_tex, pos - Vector2i(5, 5), color)


func _draw() -> void:
Expand Down
2 changes: 1 addition & 1 deletion material_maker/nodes/portal/portal.gd
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func on_parameter_changed(n : String, v : Variant) -> void:
notify_redraw()

func _draw_port(_slot_index : int, pos : Vector2i, _left : bool, color : Color) -> void:
draw_circle(pos, 5, color, true, -1, true)
draw_texture(MMGraphNodeBase.port_tex, pos - Vector2i(5, 5), color)

func _exit_tree() -> void:
var source_node : MMGraphPortal = get_link_source(get_link(), get_parent())
Expand Down
4 changes: 2 additions & 2 deletions material_maker/nodes/reroute/reroute.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func set_generator(g : MMGenBase) -> void:
await set_preview(g.get_parameter("preview"))
update_node()

func _draw_port(slot_index: int, position: Vector2i, left: bool, color: Color) -> void:
draw_circle(position, 5, color, true, -1, true)
func _draw_port(_slot_index : int, pos : Vector2i, _left : bool, color : Color) -> void:
draw_texture(MMGraphNodeBase.port_tex, pos - Vector2i(5, 5), color)

#func set_theme_type(type : StringName):
#var current_theme : Theme = mm_globals.main_window.theme
Expand Down