-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
164 lines (119 loc) · 4.77 KB
/
__init__.py
File metadata and controls
164 lines (119 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "DKS UI",
"description": "UI Customisations",
"author": "DigiKrafting.Studio",
"version": (0, 8, 3),
"blender": (5, 1, 0),
"location": "Properties > Scene, Info Toolbar, 3D View Toolbar",
"wiki_url": "https://github.com/DigiKrafting/blender_addon_ui/wiki",
"tracker_url": "https://github.com/DigiKrafting/blender_addon_ui/issues",
"category": "System",
}
import bpy
from bpy.utils import register_class, unregister_class
from os import path, makedirs
from . import dks_ui
from . import dks_globals
import bpy.utils.previews
class dks_ui_quit(bpy.types.Operator):
bl_idname = "dks_ui.quit"
bl_label = "Quit"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
def execute(self, context):
bpy.ops.wm.save_userpref()
if bpy.data.is_dirty:
bpy.ops.wm.quit_blender('INVOKE_DEFAULT')
else:
bpy.ops.wm.quit_blender()
return {'FINISHED'}
class dks_ui_cycles(bpy.types.Operator):
bl_idname = "dks_ui.cycles"
bl_label = "Set Render Engine to CYCLES"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
def execute(self, context):
bpy.context.scene.render.engine = 'CYCLES'
return {'FINISHED'}
class dks_ui_addon_prefs(bpy.types.AddonPreferences):
bl_idname = __package__
# Global Options
option_active_workspace : bpy.props.StringProperty(name="active_workspace",default="Modeling",)
option_ui_mode : bpy.props.EnumProperty(
items=[('Modeling', "Modeling", "Modeling"),('UV Editing', "UV Editing", "UV Editing"),('Animation', "Animation", "Animation"),],
name="UI Mode",
default='Modeling',
)
option_ui_menu_toggle_state : bpy.props.BoolProperty(
name="Menu Toggle State",
default=False,
)
option_active_armature : bpy.props.StringProperty(name="active_armature",default="",)
def draw(self, context):
layout = self.layout
box=layout.box()
box.prop(self, 'option_ui_mode')
class dks_ui_menu_toggle(bpy.types.Operator):
bl_idname = "dks_ui.menu_toggle"
bl_label = "SP"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
def execute(self, context):
if not bpy.context.preferences.addons[__package__].preferences.option_ui_menu_toggle_state:
bpy.context.preferences.addons[__package__].preferences.option_ui_menu_toggle_state=True
else:
bpy.context.preferences.addons[__package__].preferences.option_ui_menu_toggle_state=False
return {'FINISHED'}
classes = (
dks_ui_addon_prefs,
dks_ui_quit,
dks_ui_menu_toggle,
)
def register():
for cls in classes:
register_class(cls)
global icons
icons = bpy.utils.previews.new()
icons_dir = path.join(path.dirname(__file__), "icons")
icons.load("DKS_VIEW_FRONT", path.join(icons_dir, "view_front.png"), 'IMAGE')
icons.load("DKS_VIEW_BACK", path.join(icons_dir, "view_back.png"), 'IMAGE')
icons.load("DKS_VIEW_LEFT", path.join(icons_dir, "view_left.png"), 'IMAGE')
icons.load("DKS_VIEW_RIGHT", path.join(icons_dir, "view_right.png"), 'IMAGE')
icons.load("DKS_VIEW_TOP", path.join(icons_dir, "view_top.png"), 'IMAGE')
icons.load("DKS_VIEW_BOTTOM", path.join(icons_dir, "view_bottom.png"), 'IMAGE')
dks_ui.register()
from . import dks_rigging
dks_rigging.register()
from . import dks_modeling
dks_modeling.register()
from . import space_view3d
space_view3d.preview_collections["main"] = icons
register_class(space_view3d.VIEW3D_HT_header)
def unregister():
dks_ui.unregister()
for cls in reversed(classes):
unregister_class(cls)
from . import dks_rigging
dks_rigging.unregister()
from . import dks_modeling
dks_modeling.unregister()
from . import space_view3d
unregister_class(space_view3d.VIEW3D_HT_header)
space_view3d.preview_collections.clear()