Skip to content

Commit d48f174

Browse files
committed
Feat: modify code
1 parent 1ff2e02 commit d48f174

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
bl_info = {
44
"name": "Development Kit Tool",
5-
"version": (1, 0),
5+
"version": (1, 0, 0),
66
"blender": (4, 0, 0),
77
"location": "All over the place",
88
"support": "COMMUNITY",

blender_manifest.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
schema_version = "1.0.0"
2+
3+
blender_version_min = "4.2.0"
4+
id = "development_kit"
5+
license = ["SPDX:GPL-3.0-or-later", ]
6+
maintainer = "小萌新"
7+
name = "Development Kit"
8+
tagline = "Development Kit"
9+
type = "add-on"
10+
version = "1.0.0"
11+
tags = ["Development"]

preferences.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def update_tool(un_register=False):
2929

3030

3131
class ToolPreferences(AddonPreferences):
32-
bl_idname = PublicClass.G_ADDON_NAME
32+
bl_idname = __package__
3333

3434
@staticmethod
3535
def update_by_tool_name(tool_name):

public.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import os
22
from functools import cache
3-
from os.path import dirname, realpath, basename
43

54
import bpy
65

76

7+
def get_pref():
8+
return bpy.context.preferences.addons[__package__].preferences
9+
10+
811
class PublicEvent:
912
not_key: bool
1013
only_ctrl: bool
@@ -44,22 +47,16 @@ class PublicPref:
4447
@staticmethod
4548
@cache
4649
def pref_():
47-
return bpy.context.preferences.addons[PublicClass.G_ADDON_NAME].preferences
50+
return get_pref()
4851

4952
@property
5053
def pref(self):
5154
return self.pref_()
5255

53-
@staticmethod
54-
def get_addon_pref(addon_name=None):
55-
addon = (PublicClass.G_ADDON_NAME if addon_name is None else addon_name)
56-
return bpy.context.preferences.addons[addon].preferences
57-
5856

5957
class PublicClass(PublicEvent,
6058
PublicPref,
6159
):
62-
G_ADDON_NAME = basename(dirname(realpath(__file__)))
6360

6461
@staticmethod
6562
def clear_cache():

tool/addon_search.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import bpy
22

3-
owner = object()
43
from bpy.app.handlers import persistent
54
from ..public import PublicPref
65

6+
owner = object()
7+
78

89
def msgbus_callback():
910
PublicPref.pref_().addon_search = bpy.context.window_manager.addon_search
@@ -19,6 +20,7 @@ def msgbus():
1920
bpy.context.window_manager.addon_search = "test"
2021

2122

23+
@persistent
2224
def load_post(self, context):
2325
msgbus()
2426

@@ -35,4 +37,3 @@ def register():
3537

3638
def unregister():
3739
bpy.msgbus.clear_by_owner(owner)
38-
bpy.app.handlers.load_post.remove(load_post)

0 commit comments

Comments
 (0)