-
Notifications
You must be signed in to change notification settings - Fork 3
/
preferences.py
70 lines (47 loc) · 1.66 KB
/
preferences.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
# SPDX-FileCopyrightText: 2020-2024 Mikhail Rachinskiy
# SPDX-License-Identifier: GPL-3.0-or-later
from bpy.props import BoolProperty, EnumProperty, PointerProperty
from bpy.types import AddonPreferences, Collection, PropertyGroup
from . import problemlib, ui, var
def upd_report(self, context):
var.Report.cleanup()
if self.show_problems:
var.Report.get()
# Add-on preferences
# -----------------------------------
def _cls_Problems():
x = "class Problems:"
for code, problem in problemlib.coll.items():
x += f'\n problem_{code}: BoolProperty(name="{problem.title}", description="{code}", default=True)'
return x
exec(_cls_Problems())
class Preferences(Problems, AddonPreferences):
bl_idname = __package__
overlay_style: EnumProperty(
name="Overlay Style",
items=(
("DETAILED", "Detailed", "Show full list of problems"),
("COMPACT", "Compact", "Show only number of problems"),
),
)
def draw(self, context):
ui.prefs_ui(self, context)
# Window manager properties
# -----------------------------------
class WmProperties(PropertyGroup):
prefs_show_interface: BoolProperty(name="Interface")
prefs_show_problems: BoolProperty(name="Problems")
show_problems: BoolProperty(
name="Problems",
description="Show scene problems",
default=True,
update=upd_report,
)
# Scene properties
# ------------------------------------------
class SceneProperties(PropertyGroup):
exceptions: PointerProperty(
type=Collection,
name="Exceptions",
description="Collection of objects excluded from scene inspection",
)