Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo committed Jan 15, 2022
2 parents e01004f + f47e801 commit cf7e560
Show file tree
Hide file tree
Showing 15 changed files with 1,901 additions and 12,572 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist/
/uplogic.egg-info/
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 2.0 (unreleased)

- Create python package to be installed with pip into site packages for
deployment to avoid multiple copies of logic nodes.

- Split up logic nodes for deployment in ``uplogic`` package.

## 1.0 (2021-05-26)

- Write me
340 changes: 340 additions & 0 deletions GPL-license.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# License

uplogic uses the GNU General Public License, which describes the rights
to distribute or change the code.

Please read this file for the full license.
GPL-license.txt
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include *.md
include GPL-license.txt
recursive-include uplogic *
recursive-exclude uplogic *.pyc *.pyo
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ How to use:

# Discord Server

https://discord.gg/uuBbNmPK2Z
https://discord.gg/6xmPJ7ZZ69

# If you want to support this project

Expand Down
87 changes: 67 additions & 20 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def update_current_tree_code(*ignored):


def update_tree_name(tree, old_name):
return
utils.set_compile_status(utils.TREE_MODIFIED)
new_name = tree.name
_tree_to_name_map[tree] = new_name
Expand Down Expand Up @@ -97,8 +98,9 @@ def update_tree_name(tree, old_name):
if c.module == comp_name:
try:
ops.tree_code_generator.TreeCodeGenerator().write_code_for_tree(tree)
except Exception:
except Exception as e:
utils.error(f"Couldn't compile tree {tree.name}!")
utils.error(e)
text = bpy.data.texts.get(f'{comp_name}.py')
if text:
bpy.data.texts.remove(text)
Expand Down Expand Up @@ -141,24 +143,39 @@ def _update_all_logic_tree_code():
except Exception:
utils.error("Unknown Error, abort generating Network code")


@persistent
def _reload_texts(self, context):
if not hasattr(bpy.types.Scene, 'logic_node_settings'):
return
if not bpy.context or not bpy.context.scene:
return
if not bpy.context.scene.logic_node_settings.use_reload_text:
return
else:
for t in bpy.data.texts:
if t.filepath:
with open(t.filepath) as f:
t.clear()
t.write(f.read())


@persistent
def _generate_on_game_start(self, context):
utils.notify('Building Logic Trees on Startup...')
bpy.ops.bge_netlogic.generate_logicnetwork_all()


def _consume_update_tree_code_queue():
edit_tree = getattr(bpy.context.space_data, "edit_tree", None)
if _generate_on_game_start not in bpy.app.handlers.game_pre:
bpy.app.handlers.game_pre.append(_generate_on_game_start)
if edit_tree:
# edit_tree = bpy.context.space_data.edit_tree
old_name = _tree_to_name_map.get(edit_tree)
if not old_name:
_tree_to_name_map[edit_tree] = edit_tree.name
else:
if old_name != edit_tree.name:
update_tree_name(edit_tree, old_name)
# edit_tree = getattr(bpy.context.space_data, "edit_tree", None)
# if edit_tree:
# # edit_tree = bpy.context.space_data.edit_tree
# old_name = _tree_to_name_map.get(edit_tree)
# if not old_name:
# _tree_to_name_map[edit_tree] = edit_tree.name
# else:
# if old_name != edit_tree.name:
# update_tree_name(edit_tree, old_name)
if not _update_queue:
return
now = time.time()
Expand Down Expand Up @@ -400,6 +417,7 @@ class NLAddonSettings(bpy.types.PropertyGroup):
)
use_node_debug: bpy.props.BoolProperty(default=True)
use_node_notify: bpy.props.BoolProperty(default=True)
use_reload_text: bpy.props.BoolProperty(default=False)
use_generate_on_open: bpy.props.BoolProperty(default=False)
use_generate_all: bpy.props.BoolProperty(default=True)
auto_compile: bpy.props.BoolProperty(default=False)
Expand Down Expand Up @@ -438,6 +456,8 @@ class LogicNodesAddonPreferences(bpy.types.AddonPreferences):

def draw(self, context):
layout = self.layout
uplogic_row = layout.box()
uplogic_row.operator('bge_netlogic.install_uplogic_module', icon='IMPORT')
main_row = layout.row()
col = layout.column()
debug_col = main_row.column()
Expand All @@ -448,6 +468,11 @@ def draw(self, context):
'use_custom_node_color',
text="Dark Node Color"
)
ui_col.prop(
context.scene.logic_node_settings,
'use_reload_text',
text="Reload Texts on Game Start"
)
debug_col.prop(
context.scene.logic_node_settings,
'use_node_notify',
Expand Down Expand Up @@ -486,6 +511,7 @@ def draw(self, context):
basicnodes = _abs_import("basicnodes", _abs_path("basicnodes", "__init__.py"))
_registered_classes = [
ui.BGELogicTree,
ops.NLInstallUplogicModuleOperator,
ops.NLSelectTreeByNameOperator,
ops.NLRemoveTreeByNameOperator,
ops.NLApplyLogicOperator,
Expand Down Expand Up @@ -515,6 +541,7 @@ def draw(self, context):
ops.NLRemoveGlobalOperator,
ops.NLAddGlobalCatOperator,
ops.NLRemoveGlobalCatOperator,
ops.NLResetEmptySize,
NLNodeTreeReference
]

Expand All @@ -533,13 +560,14 @@ def draw(self, context):
ui.NL_UL_glvalue,
ui.BGE_PT_LogicPanel,
ui.BGE_PT_LogicTreeInfoPanel,
# ui.BGE_PT_ObjectTreeInfoPanel,
ui.BGE_PT_GlobalValuePanel,
ui.BGE_PT_NLEditorPropertyPanel,
ui.BGE_PT_HelpPanel,
ui.BGE_PT_GameComponentPanel,
# ui.BGE_PT_NLEditorPropertyPanel,
# ui.BGE_PT_HelpPanel,
# ui.BGE_PT_GameComponentPanel,
ui.BGE_PT_LogicNodeSettingsObject,
ui.BGE_PT_LogicTreeOptions,
ui.BGE_PT_GamePropertyPanel3DView,
# ui.BGE_PT_GamePropertyPanel3DView,
ui.BGE_PT_PropertiesPanelObject,
ui.BGE_PT_LogicTreeGroups
])
Expand Down Expand Up @@ -621,8 +649,8 @@ def get_node_item(node):

# blender add-on registration callback
def register():
if _generate_on_game_start not in bpy.app.handlers.game_pre:
bpy.app.handlers.game_pre.append(_generate_on_game_start)
bpy.app.handlers.game_pre.append(_generate_on_game_start)
bpy.app.handlers.game_pre.append(_reload_texts)
for cls in _registered_classes:
# print("Registering... {}".format(cls.__name__))
bpy.utils.register_class(cls)
Expand All @@ -637,7 +665,7 @@ def register():
bpy.types.Object.sound_occluder = bpy.props.BoolProperty(
default=True,
name='Sound Occluder',
description='Wether this object will dampen sound played from Logic Nodes'
description='Whether this object will dampen sound'
)
bpy.types.Object.sound_blocking = bpy.props.FloatProperty(
min=0.0,
Expand All @@ -646,6 +674,18 @@ def register():
name='Sound Blocking',
description='The amount of sound blocking caused by this wall. A value of 1 will block all sound'
)
bpy.types.Object.reverb_volume = bpy.props.BoolProperty(
default=False,
name='Reverb Volume',
description='Whether this volume will cause sound to reverberate (Range Limit: 50m)'
)
bpy.types.Object.reverb_samples = bpy.props.IntProperty(
min=0,
max=30,
default=10,
name='Reverb Bounces',
description='Samples used by this reverb volume. More samples mean a longer reverberation'
)

bpy.types.Object.bgelogic_treelist = bpy.props.CollectionProperty(
type=NLNodeTreeReference
Expand All @@ -670,7 +710,14 @@ def register():
# blender add-on unregistration callback
def unregister():
utils.debug('Removing Game Start Compile handler...')
filter(lambda a: a is not _generate_on_game_start, bpy.app.handlers.game_pre)
remove_f = []
filter(lambda a: a.__name__ == '_generate_on_game_start', bpy.app.handlers.game_pre)
filter(lambda a: a.__name__ == '_reload_texts', bpy.app.handlers.game_pre)
for f in bpy.app.handlers.game_pre:
if f.__name__ == '_generate_on_game_start' or f.__name__ == '_reload_texts':
remove_f.append(f)
for f in remove_f:
bpy.app.handlers.game_pre.remove(f)
# print("Unregister node category [{}]".format("NETLOGIC_NODES"))
nodeitems_utils.unregister_node_categories("NETLOGIC_NODES")
for cls in reversed(_registered_classes):
Expand Down
Loading

0 comments on commit cf7e560

Please sign in to comment.