-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
71 lines (59 loc) · 2.71 KB
/
__init__.py
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
import ast
import re
import bpy
from . import key, ops
bl_info = {
"name": "Hdr Rotation",
"description": "Rotation HDR by Shift+Right Drag in 3D View",
"author": "AIGODLIKE Community(小萌新)",
"version": (1, 0, 7),
"blender": (4, 2, 0),
"location": "3D View",
"support": "COMMUNITY",
"category": "幻之境",
}
class RotationPreferences(bpy.types.AddonPreferences):
bl_idname = __package__
def draw(self, context):
from .key import draw_keymap
column = self.layout.column()
for text in ["In 3D viewport (both renderd or material preview mode)",
"Shift + Right-Drag on empty space",
"you can rotate the enviroment texture to preview shaders and lighting more practical and faster",
"When dragging on objects, moves 3D cursor"
]:
column.label(text=text)
column.separator()
column.label(text="Keymap:")
draw_keymap(column)
def get_language_list() -> list:
"""
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
TypeError: bpy_struct: item.attr = val: enum "a" not found in ('DEFAULT', 'en_US', 'es', 'ja_JP', 'sk_SK', 'vi_VN', 'zh_HANS', 'ar_EG', 'de_DE', 'fr_FR', 'it_IT', 'ko_KR', 'pt_BR', 'pt_PT', 'ru_RU', 'uk_UA', 'zh_TW', 'ab', 'ca_AD', 'cs_CZ', 'eo', 'eu_EU', 'fa_IR', 'ha', 'he_IL', 'hi_IN', 'hr_HR', 'hu_HU', 'id_ID', 'ky_KG', 'nl_NL', 'pl_PL', 'sr_RS', 'sr_RS@latin', 'sv_SE', 'th_TH', 'tr_TR')
"""
try:
bpy.context.preferences.view.language = ""
except TypeError as e:
matches = re.findall(r'\(([^()]*)\)', e.args[-1])
return ast.literal_eval(f"({matches[-1]})")
def register():
ops.register()
key.register()
bpy.utils.register_class(RotationPreferences)
language = "ZH_CN" if "ZH_CN" in get_language_list() else "zh_HANS"
bpy.app.translations.register("hdr_rotation", {language: {
("*", "HDR Rotation"): "HDR旋转",
("*", "In 3D viewport (both renderd or material preview mode)"): "在3D视图(渲染或材质预览模式)",
("*", "Shift + Right-Drag on empty space"): "Shift+右键拖动 空白处",
("*", "you can rotate the enviroment texture to preview shaders and lighting more practical and faster",
): "您可以旋转环境纹理,以便更实用、更快速地预览着色器和照明效果",
("*",
"When dragging on objects, moves 3D cursor",): "在对象上拖动时,会移动3D游标",
("*", "Keymap:"): "快捷键:",
}})
def unregister():
ops.unregister()
key.unregister()
bpy.utils.unregister_class(RotationPreferences)
bpy.app.translations.unregister("hdr_rotation")