Skip to content

Commit

Permalink
implemented __package__ (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshQuake authored Aug 2, 2024
1 parent 405807c commit 388f142
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/addons/send2ue/core/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from abc import abstractmethod
from ..constants import ToolInfo, Extensions, ExtensionTasks
from . import utilities
from .. import __package__ as base_package
from pathlib import Path


Expand Down Expand Up @@ -345,7 +346,7 @@ def _get_extension_classes(self):
extensions = []

# add in the additional extensions from the addons preferences
addon = bpy.context.preferences.addons.get(ToolInfo.NAME.value)
addon = bpy.context.preferences.addons.get(base_package)
if addon and addon.preferences:
if os.path.exists(addon.preferences.extensions_repo_path):
for file_name in os.listdir(addon.preferences.extensions_repo_path):
Expand Down
3 changes: 2 additions & 1 deletion src/addons/send2ue/core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tempfile
import base64
from . import settings, formatting
from .. import __package__ as base_package
from ..ui import header_menu
from ..dependencies import unreal
from ..constants import BlenderTypes, UnrealTypes, ToolInfo, PreFixToken, PathModes, RegexPresets
Expand Down Expand Up @@ -1101,7 +1102,7 @@ def setup_project(*args):
bpy.ops.send2ue.reload_extensions()

# create the scene collections
addon = bpy.context.preferences.addons.get(ToolInfo.NAME.value)
addon = bpy.context.preferences.addons.get(base_package)
if addon and addon.preferences.automatically_create_collections:
create_collections()

Expand Down
7 changes: 4 additions & 3 deletions src/addons/send2ue/dependencies/remote_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ class RemoteExecutionConfig(object):
'''
def __init__(self):
import bpy
from .. import __package__ as base_package
# The multicast group endpoint tuple that the UDP multicast socket should join (must match the "Multicast Group Endpoint" setting in the Python plugin)
self.multicast_ttl = bpy.context.preferences.addons["send2ue"].preferences.multicast_ttl
self.multicast_ttl = bpy.context.preferences.addons[base_package].preferences.multicast_ttl

# The multicast group endpoint tuple that the UDP multicast socket should join (must match the "Multicast Group Endpoint" setting in the Python plugin)
host, port = bpy.context.preferences.addons["send2ue"].preferences.multicast_group_endpoint.split(':')
host, port = bpy.context.preferences.addons[base_package].preferences.multicast_group_endpoint.split(':')
self.multicast_group_endpoint = (host, int(port))

# The endpoint tuple for the TCP command connection hosted by this client (that the remote client will connect to)
host, port = bpy.context.preferences.addons["send2ue"].preferences.command_endpoint.split(':')
host, port = bpy.context.preferences.addons[base_package].preferences.command_endpoint.split(':')
self.command_endpoint = (host, int(port))

# The adapter address that the UDP multicast socket should bind to, or 0.0.0.0 to bind to all adapters (must match the "Multicast Bind Address" setting in the Python plugin)
Expand Down
3 changes: 2 additions & 1 deletion src/addons/send2ue/dependencies/unreal.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def bootstrap_unreal_with_rpc_server():
if not os.environ.get('TEST_ENVIRONMENT'):
if not is_connected():
import bpy
rpc_response_timeout = bpy.context.preferences.addons["send2ue"].preferences.rpc_response_timeout
from .. import __package__ as base_package
rpc_response_timeout = bpy.context.preferences.addons[base_package].preferences.rpc_response_timeout
dependencies_path = os.path.dirname(__file__)
result = run_commands(
[
Expand Down
3 changes: 2 additions & 1 deletion src/addons/send2ue/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .dependencies import unreal
from .dependencies.rpc import blender_server
from .properties import register_scene_properties, unregister_scene_properties
from . import __package__ as base_package


class Send2Ue(bpy.types.Operator):
Expand Down Expand Up @@ -251,7 +252,7 @@ class ReloadExtensions(bpy.types.Operator):
bl_label = "Reload Extensions"

def execute(self, context):
addon = bpy.context.preferences.addons.get(ToolInfo.NAME.value)
addon = bpy.context.preferences.addons.get(base_package)
if addon:
extensions_repo_path = addon.preferences.extensions_repo_path
if extensions_repo_path:
Expand Down
1 change: 1 addition & 0 deletions src/addons/send2ue/resources/extensions/ue2rigify.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def set_ue2rigify_state(self):
"""
Sets the use_ue2rigify property depending on whether to use code from the ue2rigify addon or not.
"""
# TODO: I dont think this will ever be true in blender 4.2 (master poet over here)
if bpy.context.preferences.addons.get('ue2rigify'):
ue2rigify_properties = bpy.context.scene.ue2rigify
if ue2rigify_properties.selected_mode == self.control_mode:
Expand Down
3 changes: 2 additions & 1 deletion src/addons/send2ue/ui/addon_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import bpy
from ..properties import Send2UeAddonProperties
from ..constants import ToolInfo
from .. import __package__


class SendToUnrealPreferences(Send2UeAddonProperties, bpy.types.AddonPreferences):
"""
This class creates the settings interface in the send to unreal addon.
"""
bl_idname = ToolInfo.NAME.value
bl_idname = __package__

def draw(self, context):
"""
Expand Down

0 comments on commit 388f142

Please sign in to comment.