Skip to content

Commit

Permalink
Convert to Extension Add-on
Browse files Browse the repository at this point in the history
  • Loading branch information
UuuNyaa committed Jun 16, 2024
1 parent cd39e74 commit 03b8bdb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
run: rm -rf mmd_tools/typings

- name: Create a zip
run: zip -r -9 mmd_tools-${GITHUB_REF_NAME}.zip mmd_tools/
run: (cd mmd_tools && find . -type f ! -path "*/.*" ! -path "*/__pycache__/*" -print | zip -9r "../mmd_tools-${GITHUB_REF_NAME}.zip" -@)

- name: Create a Release
id: create_release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
Expand Down
32 changes: 10 additions & 22 deletions mmd_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


bl_info = {
"name": "mmd_tools",
"author": "sugiany",
"version": (4, 2, 2),
"blender": (4, 2, 0),
"location": "View3D > Sidebar > MMD Panel",
"description": "Utility tools for MMD model editing. (UuuNyaa's forked version)",
"warning": "",
"doc_url": "https://mmd-blender.fandom.com/wiki/MMD_Tools",
"wiki_url": "https://mmd-blender.fandom.com/wiki/MMD_Tools",
"tracker_url": "https://github.com/UuuNyaa/blender_mmd_tools/issues",
"support": "COMMUNITY",
"category": "Object",
}

MMD_TOOLS_VERSION = ".".join(map(str, bl_info["version"]))

import os

PACKAGE_PATH = os.path.dirname(__file__)
PACKAGE_NAME = __package__
PACKAGE_PATH = os.path.dirname(__file__)

with open(os.path.join(PACKAGE_PATH, "blender_manifest.toml"), "rb") as f:
import tomllib

manifest = tomllib.load(f)
MMD_TOOLS_VERSION = manifest["version"]


from . import auto_load

auto_load.init()
auto_load.init(PACKAGE_NAME)


def register():
Expand All @@ -54,7 +42,7 @@ def register():
# pylint: disable=import-outside-toplevel
from .m17n import translation_dict

bpy.app.translations.register(bl_info["name"], translation_dict)
bpy.app.translations.register(PACKAGE_NAME, translation_dict)

handlers.MMDHanders.register()

Expand All @@ -66,7 +54,7 @@ def unregister():

handlers.MMDHanders.unregister()

bpy.app.translations.unregister(bl_info["name"])
bpy.app.translations.unregister(PACKAGE_NAME)

auto_load.unregister()

Expand Down
8 changes: 4 additions & 4 deletions mmd_tools/auto_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
modules = None
ordered_classes = None

def init():
def init(package_name):
global modules
global ordered_classes

modules = get_all_submodules(Path(__file__).parent)
modules = get_all_submodules(Path(__file__).parent, package_name)
ordered_classes = get_ordered_classes_to_register(modules)

def register():
Expand All @@ -49,8 +49,8 @@ def unregister():
# Import modules
#################################################

def get_all_submodules(directory):
return list(iter_submodules(directory, directory.name))
def get_all_submodules(directory, package_name):
return list(iter_submodules(directory, package_name))

def iter_submodules(path, package_name):
for name in sorted(iter_submodule_names(path)):
Expand Down

0 comments on commit 03b8bdb

Please sign in to comment.