-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path__init__.py
176 lines (144 loc) · 5.8 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
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
165
166
167
168
169
170
171
172
173
174
175
176
bl_info = {
"name": "Screenwriter",
"author": "Tintwotin, Samy Tichadou, Gabriel Montagné, Andrea Monzini, Colton J. Provias, Manuel Senfft, Martin Vilcans, Nima Yousefi & John August",
"version": (0, 1),
"blender": (2, 81, 0),
"location": "Text Editor > Sidebar",
"description": "Write screenplays and convert to them 3D scenes or export to PDF, Final Draft or HTML",
"warning": "",
"wiki_url": "",
"category": "Text Editor",
}
import bpy, subprocess
import sys
from bpy.types import Panel, PropertyGroup, UIList, Operator, OperatorFileListElement
from bpy.props import IntProperty, BoolProperty, PointerProperty, StringProperty, EnumProperty, CollectionProperty
# load and reload submodules
##################################
# import importlib, inspect
# from . import developer_utils
# importlib.reload(developer_utils)
# modules = developer_utils.setup_addon_modules(__path__, __name__, "bpy" in locals())
# classes = []
# for module in modules:
# for name, obj in inspect.getmembers(module):
# if debug: print("registered --- " + name)
# if inspect.isclass(obj) and name != "persistent":
# classes.append(obj)
from .operators.dual_view import *
from .operators.fountain_export import *
from .operators.preview_fountain import *
from .operators.mindmap_fountain import *
from .operators.scene_to_strip import *
from .operators.switch_to_scene import *
from .operators.insert import *
from .operators.assign_keyword_to_objects import *
#from .operators.screenwriter_fountain import *
from .gui import *
from .properties import *
# screenplain
pybin = sys.executable #bpy.app.binary_path_python
try:
subprocess.call([pybin, "-m", "ensurepip"])
except ImportError:
pass
try:
import screenplain.parsers.fountain as fountain
except ImportError:
subprocess.check_call([pybin, '-m', 'pip', 'install', 'screenplain[PDF]'])
try:
import screenplain.parsers.fountain as fountain
except ImportError:
print("Installation of Screenplain failed. Try running Blender as admin, or install Screenplain manually.")
class ObjectProperties(PropertyGroup):
objectname: StringProperty(name="Name")
objecttype: StringProperty(name="Type")
runnable: BoolProperty(name="Visible", default=True)
class KeywordProperties(PropertyGroup):
name: StringProperty(name="Name")
objects: CollectionProperty(type=ObjectProperties)
object_index: IntProperty(update=on_object_index_change)
class AssignKeywordsProperties(PropertyGroup):
keywords: CollectionProperty(type=KeywordProperties)
keyword_index: IntProperty(update=on_object_index_change)
new_keyword: StringProperty(name="Name")
classes = (SCREENWRITER_PT_panel,
#SCREENWRITER_PT_keywords,
#SCREENWRITER_PT_objects,
SCREENWRITER_OT_preview_fountain,
SCREENWRITER_OT_mindmap_fountain,
SCREENWRITER_OT_return_mindmap,
SCREENWRITER_OT_dual_view,
SCREENWRITER_OT_export,
#TEXT_OT_scenes_to_strips,
TextReplaceProperties,
SCREENWRITER_PT_preview_panel,
SCREENWRITER_PT_layout_panel,
SCREENWRITER_PT_screenplayer_panel,
SCREENWRITER_PT_navigation_panel,
SCREENWRITER_PT_mindmap_panel,
SCREENWRITER_OT_switch_to_scene,
SCREENWRITER_OT_switch_to_master,
SCREENWRITER_OT_insert_titlepage,
SCREENWRITER_OT_insert_scene_numbers,
SCREENWRITER_OT_insert_shot,
SCREENWRITER_OT_correct_caps,
GetKeyword,
RenameKeyword,
AddKeyword,
RemoveKeyword,
MoveKeywordUp,
MoveKeywordDown,
AddObjects,
RemoveObject,
MoveObjectUp,
MoveObjectDown,
#SCREENWRITER_PT_keywords,
#SCREENWRITER_PT_objects,
OBJECT_UL_screenwriter_keywords,
OBJECT_UL_screenwriter_objects,
ObjectProperties,
KeywordProperties,
AssignKeywordsProperties,
SCREENWRITER_OT_to_strips,
SCREENWRITER_OT_specific_to_strips,
SCREENWRITER_OT_strips_to_markers,
SCREENWRITER_OT_clear_markers
)
# import specific
##################################
# reg/unreg
##################################
def register():
### OPERATORS ###
from bpy.utils import register_class
from bpy.types import Scene
for cls in classes :
register_class(cls)
Scene.keywords_assigner = PointerProperty(type=AssignKeywordsProperties)
bpy.types.Scene.screenwriter_channel = bpy.props.IntProperty(default=0, min=0)
### MENU ###
bpy.types.TEXT_MT_text.append(screenwriter_menu_export)
### PROPERTIES ###
bpy.types.Scene.last_character = IntProperty(default=0)
bpy.types.Scene.last_line = StringProperty(default="")
bpy.types.Scene.last_line_index = IntProperty(default=0)
bpy.types.Scene.text_replace = PointerProperty(type=TextReplaceProperties)
bpy.types.Scene.title_page_index = IntProperty(default=0)
bpy.types.Scene.master_sequence = StringProperty(default="")
def unregister():
### OPERATORS ###
from bpy.utils import unregister_class
from bpy.types import Scene
for cls in classes :
unregister_class(cls)
del Scene.keywords_assigner
del bpy.types.Scene.screenwriter_channel
### MENU ###
bpy.types.TEXT_MT_text.remove(screenwriter_menu_export)
### PROPERTIES ###
del bpy.types.Scene.last_character
del bpy.types.Scene.last_line
del bpy.types.Scene.last_line_index
del bpy.types.Scene.text_replace
del bpy.types.Scene.title_page_index