Fix publishing with live patch enabled

This commit is contained in:
Moritz Brückner 2021-07-25 20:13:47 +02:00
parent 62ff11747b
commit 549040fc09
4 changed files with 26 additions and 15 deletions

View file

@ -2672,7 +2672,7 @@ Make sure the mesh only has tris/quads.""")
}
self.output['traits'].append(out_trait)
if wrd.arm_live_patch:
if arm.utils.is_livepatch_enabled():
if 'traits' not in self.output:
self.output['traits'] = []
out_trait = {'type': 'Script', 'class_name': 'armory.trait.internal.LivePatch'}

View file

@ -78,7 +78,7 @@ def build_node_tree(node_group: 'arm.nodes_logic.ArmLogicTree'):
f.write('\t\tname = "' + group_name + '";\n')
f.write('\t\tthis.functionNodes = new Map();\n')
f.write('\t\tthis.functionOutputNodes = new Map();\n')
if wrd.arm_live_patch:
if arm.utils.is_livepatch_enabled():
f.write(f'\t\tarmory.logicnode.LogicTree.nodeTrees["{group_name}"] = this;\n')
f.write('\t\tnotifyOnAdd(add);\n')
f.write('\t}\n\n')
@ -113,6 +113,8 @@ def build_node(node: bpy.types.Node, f: TextIO) -> Optional[str]:
global parsed_nodes
global parsed_ids
use_live_patch = arm.utils.is_livepatch_enabled()
if node.type == 'REROUTE':
if len(node.inputs) > 0 and len(node.inputs[0].links) > 0:
return build_node(node.inputs[0].links[0].from_node, f)
@ -154,7 +156,7 @@ def build_node(node: bpy.types.Node, f: TextIO) -> Optional[str]:
f.write('\t\t' + name + '.name = "' + name[1:] + '";\n')
f.write('\t\t' + name + '.watch(true);\n')
elif wrd.arm_live_patch:
elif use_live_patch:
f.write('\t\t' + name + '.name = "' + name[1:] + '";\n')
f.write(f'\t\tthis.nodes["{name[1:]}"] = {name};\n')
@ -212,8 +214,8 @@ def build_node(node: bpy.types.Node, f: TextIO) -> Optional[str]:
from_type = inp.arm_socket_type
# Add input
f.write(f'\t\t{"var __link = " if wrd.arm_live_patch else ""}armory.logicnode.LogicNode.addLink({inp_name}, {name}, {inp_from}, {idx});\n')
if wrd.arm_live_patch:
f.write(f'\t\t{"var __link = " if use_live_patch else ""}armory.logicnode.LogicNode.addLink({inp_name}, {name}, {inp_from}, {idx});\n')
if use_live_patch:
to_type = inp.arm_socket_type
f.write(f'\t\t__link.fromType = "{from_type}";')
f.write(f'\t\t__link.toType = "{to_type}";')
@ -224,8 +226,8 @@ def build_node(node: bpy.types.Node, f: TextIO) -> Optional[str]:
# Linked outputs are already handled after iterating over inputs
# above, so only unconnected outputs are handled here
if not out.is_linked:
f.write(f'\t\t{"var __link = " if wrd.arm_live_patch else ""}armory.logicnode.LogicNode.addLink({name}, {build_default_node(out)}, {idx}, 0);\n')
if wrd.arm_live_patch:
f.write(f'\t\t{"var __link = " if use_live_patch else ""}armory.logicnode.LogicNode.addLink({name}, {build_default_node(out)}, {idx}, 0);\n')
if use_live_patch:
out_type = out.arm_socket_type
f.write(f'\t\t__link.fromType = "{out_type}";')
f.write(f'\t\t__link.toType = "{out_type}";')

View file

@ -78,6 +78,15 @@ def convert_image(image, path, file_format='JPEG'):
ren.image_settings.file_format = orig_file_format
ren.image_settings.color_mode = orig_color_mode
def is_livepatch_enabled():
"""Returns whether live patch is enabled and can be used."""
wrd = bpy.data.worlds['Arm']
# If the game is published, the target is krom-[OS] and not krom,
# so there is no live patch when publishing
return wrd.arm_live_patch and state.target == 'krom'
def blend_name():
return bpy.path.basename(bpy.context.blend_data.filepath).rsplit('.', 1)[0]

View file

@ -166,10 +166,10 @@ project.addSources('Sources');
if enable_dce:
khafile.write("project.addParameter('-dce full');\n")
live_patch = wrd.arm_live_patch and state.target == 'krom'
if wrd.arm_debug_console or live_patch:
use_live_patch = arm.utils.is_livepatch_enabled()
if wrd.arm_debug_console or use_live_patch:
import_traits.append('armory.trait.internal.Bridge')
if live_patch:
if use_live_patch:
assets.add_khafile_def('arm_patch')
# Include all logic node classes so that they can later
# get instantiated