From d5f8fdfacab1ab0446f576eeaa379e82b5fb8124 Mon Sep 17 00:00:00 2001 From: IzaZed Date: Thu, 12 Oct 2023 17:35:59 +0200 Subject: [PATCH] add version select --- __init__.py | 12 ++++++++++-- ops/__init__.py | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index ce3dde8..442f000 100644 --- a/__init__.py +++ b/__init__.py @@ -515,8 +515,14 @@ def execute(self, context): return {"FINISHED"} +_uplogic_versions = [ + ('1.9.5', '1.9.5', 'Suitable for Logic Nodes 2.3 or lower') +] + + class LogicNodesAddonPreferences(bpy.types.AddonPreferences): bl_idname = __name__ + uplogic_version: bpy.props.EnumProperty(items=_uplogic_versions) def draw(self, context): layout = self.layout @@ -528,6 +534,7 @@ def draw(self, context): ) row = col.row(align=True) row.operator('bge_netlogic.install_uplogic_module', icon='IMPORT') + row.prop(self, 'uplogic_version', text='') # col.operator('bge_netlogic.install_fake_bge_module', icon='IMPORT') main_row = layout.row() col = layout.column() @@ -679,8 +686,9 @@ def _get_key_for_class(c): def update_uplogic_module(): try: + prefs = bpy.context.preferences.addons['bge_netlogic'].preferences os.system(f'"{sys.executable}" -m ensurepip') - os.system(f'"{sys.executable}" -m pip install uplogic --upgrade') + os.system(f'"{sys.executable}" -m pip install uplogic=={prefs.uplogic_version}') global UPLOGIC_INSTALLED UPLOGIC_INSTALLED = True except Exception: @@ -690,7 +698,7 @@ def update_uplogic_module(): def get_uplogic_module(): try: os.system(f'"{sys.executable}" -m ensurepip') - os.system(f'"{sys.executable}" -m pip install uplogic') + os.system(f'"{sys.executable}" -m pip install uplogic==1.9.5') global UPLOGIC_INSTALLED UPLOGIC_INSTALLED = True except Exception: diff --git a/ops/__init__.py b/ops/__init__.py index fe1e144..e9d2bde 100644 --- a/ops/__init__.py +++ b/ops/__init__.py @@ -57,8 +57,9 @@ class NLInstallUplogicModuleOperator(bpy.types.Operator): def execute(self, context): utils.notify('Installing uplogic module...') try: + prefs = bpy.context.preferences.addons['bge_netlogic'].preferences os.system(f'"{sys.executable}" -m ensurepip') - os.system(f'"{sys.executable}" -m pip install uplogic --upgrade') + os.system(f'"{sys.executable}" -m pip install uplogic=={prefs.uplogic_version}') bge_netlogic.UPLOGIC_INSTALLED = True utils.success('Installed.') except Exception as e: