Merge pull request #2306 from MoritzBrueckner/various-node-fixes

Various node fixes
This commit is contained in:
Lubos Lenco 2021-08-20 10:34:22 +02:00 committed by GitHub
commit a8a44df249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 40 additions and 35 deletions

View file

@ -10,7 +10,7 @@ class SetParentBoneNode(ArmLogicTreeNode):
def arm_init(self, context):
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmNodeSocketObject', 'Object')
self.add_input('ArmNodeSocketObject', 'Parent', default_value='Parent')
self.add_input('ArmNodeSocketObject', 'Parent')
self.add_input('ArmStringSocket', 'Bone', default_value='Bone')
self.add_output('ArmNodeSocketAction', 'Out')

View file

@ -418,10 +418,11 @@ class ArmNodeSearch(bpy.types.Operator):
class ArmNodeCategory:
"""Represents a category (=directory) of logic nodes."""
def __init__(self, name: str, icon: str, description: str):
def __init__(self, name: str, icon: str, description: str, category_section: str):
self.name = name
self.icon = icon
self.description = description
self.category_section = category_section
self.node_sections: ODict[str, List[NodeItem]] = OrderedDict()
self.deprecated_nodes: List[NodeItem] = []
@ -502,7 +503,7 @@ def add_category(category: str, section: str = 'default', icon: str = 'BLANK1',
add_category_section(section)
if not category_exists(category):
node_category = ArmNodeCategory(category, icon, description)
node_category = ArmNodeCategory(category, icon, description, section)
category_items[section].append(node_category)
return node_category

View file

@ -122,12 +122,13 @@ class ArmColorSocket(ArmCustomSocket):
subtype='COLOR',
min=0.0,
max=1.0,
default=[0.0, 0.0, 0.0, 1.0],
description='Input value used for unconnected socket',
update=_on_update_socket
)
def draw(self, context, layout, node, text):
draw_socket_layout(self, layout)
draw_socket_layout_split(self, layout)
def draw_color(self, context, node):
return 0.78, 0.78, 0.161, 1
@ -254,6 +255,7 @@ class ArmVectorSocket(ArmCustomSocket):
default_value_raw: FloatVectorProperty(
name='Value',
size=3,
precision=3,
description='Input value used for unconnected socket',
update=_on_update_socket
)
@ -261,6 +263,7 @@ class ArmVectorSocket(ArmCustomSocket):
def draw(self, context, layout, node, text):
if not self.is_output and not self.is_linked:
col = layout.column(align=True)
col.label(text=self.name + ":")
col.prop(self, 'default_value_raw', text='')
else:
layout.label(text=self.name)

View file

@ -61,4 +61,4 @@ class GamepadNode(ArmLogicTreeNode):
if inp_gamepad.is_linked:
return f'{self.bl_label}: {self.property1}'
return f'{self.bl_label} {inp_gamepad.default_value}: {self.property1}'
return f'{self.bl_label} {inp_gamepad.default_value_raw}: {self.property1}'

View file

@ -60,14 +60,12 @@ class OnSwipeNode(ArmLogicTreeNode):
array_nodes[str(id(self))] = self
def arm_init(self, context):
self.inputs.new('ArmFloatSocket', 'Time')
self.inputs[-1].default_value = 0.15
self.inputs.new('ArmIntSocket', 'Min Length (px)')
self.inputs[-1].default_value = 100
self.outputs.new('ArmNodeSocketAction', 'Out')
self.outputs.new('ArmVectorSocket', 'Direction')
self.outputs.new('ArmIntSocket', 'Length (px)')
self.outputs.new('ArmIntSocket', 'Angle (0-360)')
self.add_input('ArmFloatSocket', 'Time', default_value=0.15)
self.add_input('ArmIntSocket', 'Min Length (px)', default_value=100)
self.add_output('ArmNodeSocketAction', 'Out')
self.add_output('ArmVectorSocket', 'Direction')
self.add_output('ArmIntSocket', 'Length (px)')
self.add_output('ArmIntSocket', 'Angle (0-360)')
# Draw node buttons
def draw_buttons(self, context, layout):

View file

@ -1,6 +1,6 @@
from arm.logicnode.arm_nodes import *
# Class OnTapScreen
class OnTapScreen(ArmLogicTreeNode):
"""Activates the output on tap screen event.
@ -19,12 +19,9 @@ class OnTapScreen(ArmLogicTreeNode):
arm_version = 1
def arm_init(self, context):
self.add_input('ArmFloatSocket', 'Duration')
self.inputs[-1].default_value = 0.3
self.add_input('ArmFloatSocket', 'Interval')
self.inputs[-1].default_value = 0.0
self.add_input('ArmIntSocket', 'Repeat')
self.inputs[-1].default_value = 2
self.add_input('ArmFloatSocket', 'Duration', default_value=0.3)
self.add_input('ArmFloatSocket', 'Interval', default_value=0.0)
self.add_input('ArmIntSocket', 'Repeat', default_value=2)
self.add_output('ArmNodeSocketAction', 'Done')
self.add_output('ArmNodeSocketAction', 'Fail')

View file

@ -35,7 +35,7 @@ class LoopNode(ArmLogicTreeNode):
if inp_from.is_linked and inp_to.is_linked:
return self.bl_label
val_from = 'x' if inp_from.is_linked else inp_from.default_value
val_to = 'y' if inp_to.is_linked else inp_to.default_value
val_from = 'x' if inp_from.is_linked else inp_from.default_value_raw
val_to = 'y' if inp_to.is_linked else inp_to.default_value_raw
return f'{self.bl_label}: {val_from}...{val_to}'

View file

@ -16,8 +16,7 @@ class SetDebugConsoleSettings(ArmLogicTreeNode):
def arm_init(self, context):
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmBoolSocket', 'Visible')
self.add_input('ArmFloatSocket', 'Scale')
self.inputs[-1].default_value = 1.0
self.add_input('ArmFloatSocket', 'Scale', default_value=1.0)
self.add_output('ArmNodeSocketAction', 'Out')

View file

@ -27,4 +27,4 @@ class TimerNode(ArmLogicTreeNode):
if inp_duration.is_linked or inp_repeat.is_linked:
return self.bl_label
return f'{self.bl_label}: {round(inp_duration.default_value, 3)}s ({inp_repeat.default_value} R.)'
return f'{self.bl_label}: {round(inp_duration.default_value_raw, 3)}s ({inp_repeat.default_value_raw} R.)'

View file

@ -10,8 +10,7 @@ class SetVibrateNode(ArmLogicTreeNode):
def arm_init(self, context):
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmIntSocket', 'Milliseconds')
self.inputs[-1].default_value = 100
self.add_input('ArmIntSocket', 'Milliseconds', default_value=100)
self.add_output('ArmNodeSocketAction', 'Out')
# Add permission for target android

View file

@ -12,6 +12,6 @@ class SetParentNode(ArmLogicTreeNode):
def arm_init(self, context):
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmNodeSocketObject', 'Object')
self.add_input('ArmNodeSocketObject', 'Parent', default_value='Parent')
self.add_input('ArmNodeSocketObject', 'Parent')
self.add_output('ArmNodeSocketAction', 'Out')

View file

@ -106,7 +106,7 @@ class AddRigidBodyNode(ArmLogicTreeNode):
self.inputs.remove(i)
# Add dynamic input sockets
if self.property1_:
if self.property1:
self.add_input('ArmBoolSocket', 'Collision Margin', False)
self.add_input('ArmFloatSocket', 'Margin', 0.04)
self.add_input('ArmFloatSocket', 'Linear Damping', 0.04)

View file

@ -204,6 +204,7 @@ class ArmOpenNodeHaxeSource(bpy.types.Operator):
webbrowser.open(f'https://github.com/armory3d/armory/tree/{version}/Sources/armory/logicnode/{name}.hx')
return{'FINISHED'}
class ArmOpenNodePythonSource(bpy.types.Operator):
"""Expose Python source"""
bl_idname = 'arm.open_node_python_source'
@ -221,24 +222,31 @@ class ArmOpenNodePythonSource(bpy.types.Operator):
webbrowser.open(f'https://github.com/armory3d/armory/tree/{version}/blender/{rel_path}.py')
return{'FINISHED'}
class ArmOpenNodeWikiEntry(bpy.types.Operator):
"""Open the node's documentation in the wiki"""
bl_idname = 'arm.open_node_documentation'
bl_label = 'Open Node Documentation'
def to_wiki_id(self, node_name):
"""convert from the conventional node name to its wiki counterpart's anchor or id
expected node_name format: LN_[a-z_]+
@staticmethod
def to_wiki_id(node_name):
"""Convert from the conventional node name to its wiki counterpart's anchor or id.
Expected node_name format: LN_[a-z_]+
"""
return node_name.replace('_','-')[3:]
return node_name.replace('_', '-')[3:]
def execute(self, context):
if context.selected_nodes is not None:
if len(context.selected_nodes) == 1:
node = context.selected_nodes[0]
if node.bl_idname.startswith('LN') and node.arm_version is not None:
wiki_id = self.to_wiki_id(node.__module__.rsplit('.', 2).pop())
webbrowser.open(f'https://github.com/armory3d/armory/wiki/reference#{wiki_id}')
wiki_id = ArmOpenNodeWikiEntry.to_wiki_id(node.__module__.rsplit('.', 2).pop())
category = node.arm_category
if category == arm_nodes.PKG_AS_CATEGORY:
category = node.__module__.rsplit('.', 2)[-2].capitalize()
category_section = arm_nodes.get_category(category).category_section
webbrowser.open(f'https://github.com/armory3d/armory/wiki/reference_{category_section}#{wiki_id}')
return{'FINISHED'}