Skip to content

Commit

Permalink
smaller updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo committed Mar 12, 2021
1 parent 548adcf commit c097eb3
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 32 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": (0, 9, 9),
"blender": (2, 91, 0),
"location": "View Menu",
"warning": "Beta",
"warning": "Now actually Beta",
"category": "Game Engine"
}

Expand Down
49 changes: 37 additions & 12 deletions basicnodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,13 +896,13 @@ class NLAbstractNode(NetLogicStatementGenerator):
def poll(cls, node_tree):
pass

def insert_link(self, link):
to_socket = link.to_socket
from_socket = link.from_socket
try:
link.is_valid = to_socket.validate(from_socket)
except Exception:
utils.debug('Receiving Node not a Logic Node Type, skipping validation.')
#def insert_link(self, link):
# to_socket = link.to_socket
# from_socket = link.from_socket
# try:
# link.is_valid = to_socket.validate(from_socket)
# except Exception:
# utils.debug('Receiving Node not a Logic Node Type, skipping validation.')

def free(self):
pass
Expand All @@ -919,8 +919,8 @@ def draw_buttons_ext(self, context, layout):
def update(self):
update_tree_code(self, bpy.context)

def draw_label(self):
return self.__class__.bl_label
#def draw_label(self):
# return self.__class__.bl_label


###############################################################################
Expand Down Expand Up @@ -3796,6 +3796,31 @@ def get_output_socket_varnames(self):
_nodes.append(NLGetRandomListIndex)


class NLDuplicateList(bpy.types.Node, NLParameterNode):
bl_idname = "NLDuplicateList"
bl_label = "Duplicate"
bl_icon = 'CON_TRANSLIKE'
nl_category = "Python"
nl_subcat = 'List'

def init(self, context):
NLParameterNode.init(self, context)
self.inputs.new(NLListSocket.bl_idname, "List")
self.outputs.new(NLListSocket.bl_idname, "List")

def get_netlogic_class_name(self):
return "bgelogic.DuplicateList"

def get_input_sockets_field_names(self):
return ["items"]

def get_output_socket_varnames(self):
return [OUTCELL]


_nodes.append(NLDuplicateList)


class NLGetListIndexNode(bpy.types.Node, NLParameterNode):
bl_idname = "NLGetListIndexNode"
bl_label = "Get Index"
Expand Down Expand Up @@ -3918,7 +3943,7 @@ class NLGetActuatorValue(bpy.types.Node, NLParameterNode):

def init(self, context):
NLParameterNode.init(self, context)
self.inputs.new(NLLogicBrickSocket.bl_idname, "Actuator Name")
self.inputs.new(NLLogicBrickSocket.bl_idname, "Actuator")
self.inputs.new(NLQuotedStringFieldSocket.bl_idname, "Field")
self.outputs.new(NLParameterSocket.bl_idname, "Value")

Expand Down Expand Up @@ -6202,9 +6227,9 @@ def init(self, context):
def update_draw(self):
numerics = ['INTEGER', 'FLOAT']
self.inputs[2].enabled = (
self.inputs[0].value_type in numerics or self.inputs[0].is_linked
(self.inputs[0].value_type in numerics or self.inputs[0].is_linked)
and
self.inputs[1].value_type in numerics or self.inputs[1].is_linked
(self.inputs[1].value_type in numerics or self.inputs[1].is_linked)
)

def get_netlogic_class_name(self):
Expand Down
29 changes: 19 additions & 10 deletions game/bgelogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,20 @@ def evaluate(self):
self._set_value(random.choice(list_d))


class DuplicateList(ParameterCell):
def __init__(self):
ParameterCell.__init__(self)
self.condition = None
self.items = None

def evaluate(self):
list_d = self.get_parameter_value(self.items)
if is_invalid(list_d):
return
self._set_ready()
self._set_value(list_d.copy())


class GetActuator(ParameterCell):

@classmethod
Expand Down Expand Up @@ -4093,14 +4107,14 @@ def evaluate(self):
b = self.get_parameter_value(self.param_b)
threshold = self.get_parameter_value(self.threshold)
operator = self.get_parameter_value(self.operator)
if is_waiting(a, b, threshold, operator):
return
self._set_ready()
if operator > 1: # eq and neq are valid for None
if a is None:
return
if b is None:
return
if threshold is None:
threshold = 0
if threshold > 0 and abs(a - b) < threshold:
a = b
if operator is None:
Expand Down Expand Up @@ -5630,24 +5644,19 @@ def setup(self, network):
def evaluate(self):
self.done = False
condition = self.get_parameter_value(self.condition)
if not_met(condition):
return
target_object = self.get_parameter_value(self.target_object)
tree_name = self.get_parameter_value(self.tree_name)
if target_object is LogicNetworkCell.STATUS_WAITING:
return
if tree_name is LogicNetworkCell.STATUS_WAITING:
return
self._set_ready()
if is_invalid(target_object):
return
if tree_name not in target_object:
added_network = target_object.get(tree_name, None)
if not added_network:
self._network.install_subnetwork(
target_object,
tree_name,
False
)
added_network = target_object.get(tree_name)
added_network = target_object.get(tree_name, None)
if condition:
added_network.stopped = False
else:
Expand Down
8 changes: 4 additions & 4 deletions ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ def execute(self, context):

class NLAddGlobalOperator(bpy.types.Operator):
bl_idname = "bge_netlogic.add_global"
bl_label = "Add Global"
bl_label = "Add Global Value"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Add a value accessible from anywhere"

Expand All @@ -926,7 +926,7 @@ def execute(self, context):

class NLRemoveGlobalOperator(bpy.types.Operator):
bl_idname = "bge_netlogic.remove_global"
bl_label = "Remove Global"
bl_label = "Remove Global Value"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Remove a value accessible from anywhere"

Expand All @@ -944,7 +944,7 @@ def execute(self, context):

class NLAddGlobalCatOperator(bpy.types.Operator):
bl_idname = "bge_netlogic.add_global_cat"
bl_label = "Add Global"
bl_label = "Add Global Category"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Add a global value category"

Expand All @@ -964,7 +964,7 @@ def execute(self, context):

class NLRemoveGlobalCatOperator(bpy.types.Operator):
bl_idname = "bge_netlogic.remove_global_cat"
bl_label = "Remove Global"
bl_label = "Remove Global Category"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Remove a global value category"

Expand Down
Binary file removed ui/IconsBright/Icon4Keys.png
Binary file not shown.
Binary file removed ui/IconsBright/IconApply.png
Binary file not shown.
10 changes: 5 additions & 5 deletions ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def draw(self, context):
else:
layout.operator(
bge_netlogic.ops.NLAddGlobalCatOperator.bl_idname,
text='Add Global Value',
text='Add Global Category',
icon='PLUS'
)

Expand Down Expand Up @@ -846,9 +846,9 @@ class BGELogicTree(bpy.types.NodeTree):
def poll(cls, context):
return True

def update(self):
if not getattr(bpy.context.scene.logic_node_settings, 'auto_compile'):
return
bge_netlogic.update_current_tree_code()
#def update(self):
# if not getattr(bpy.context.scene.logic_node_settings, 'auto_compile'):
# return
# bge_netlogic.update_current_tree_code()
# for link in self.links:
# print(link.is_valid)

0 comments on commit c097eb3

Please sign in to comment.