-
Notifications
You must be signed in to change notification settings - Fork 1
/
UI.ls
319 lines (283 loc) · 8.78 KB
/
UI.ls
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
global nextBtn, backBtn
on initUI
global dropXtra
set nextBtn = sprite "NextButton"
set backBtn = sprite "BackButton"
repeat with btn in [nextBtn, backBtn]
if the visible of btn then btn.setStyle("fontSize", 18)
end repeat
-- DropXtra does not work in authoring
if voidP(dropXtra) and the runMode = "Projector" then
set dropXtra = xtra("DropXtra").new(#itemsDropped)
dropXtra.dropStart()
end if
-- Setting Flash sprite properties does not work until after the first stage update
updateStage()
initScreen()
updateScreen()
end
on initScreen
case the frameLabel of
"Choose Files": initFileChooserScreen()
"Options": initOptionsScreen()
"Export": initExportScreen()
end case
end
on updateScreen
case the frameLabel of
"Choose Files": updateFileChooserScreen()
"Options": updateOptionsScreen()
"Export": updateExportScreen()
end case
end
on nextScreen
go next
initScreen()
end
on prevScreen
go previous
initScreen()
end
on gotoScreen screenName
go to screenName
initScreen()
updateScreen()
end
on initFileChooserScreen
global movieFiles, castFiles
set the visible of backBtn = False
set the visible of nextBtn = True
set the label of nextBtn = "Next >"
addFiles(movieFiles)
addFiles(castFiles)
end
on updateFileChooserScreen
set listObj = sprite "FileList"
set removeBtn = sprite "RemoveButton"
set removeAllBtn = sprite "RemoveAllButton"
-- Very ugly hack to check from Lingo whether a Flash variable is undefined
set the enabled of removeBtn = not voidP(listObj["selectedIndices"])
set notEmpty = the length of listObj > 0
set the enabled of removeAllBtn = notEmpty
set the enabled of nextBtn = notEmpty
if notEmpty then setSelectedFiles(the data of listObj)
end
on initOptionsScreen
global exportFolder
set the visible of backBtn = True
set the label of backBtn = "< Back"
set the visible of nextBtn = True
set the label of nextBtn = "Export"
setDefaultExportFolder()
set the text of sprite "FolderPathBox" = exportFolder
initCheckboxes()
end
on updateOptionsScreen
updateCheckboxes()
set the enabled of nextBtn = setExportFolder(the text of sprite "FolderPathBox")
end
on initExportScreen
set the visible of nextBtn = False
set the text of field "StatusHeading" = "Exporting..."
initExport()
end
on updateExportScreen
global currFilename, currMemberId
if stringP(currFilename) and stringP(currMemberId) then
if the text of field "CurrentFile" <> currFilename then
set the text of field "CurrentFile" = currFilename
end if
if the text of field "CurrentMember" <> currMemberId then
set the text of field "CurrentMember" = currMemberId
end if
end if
updateProgressBar()
end
on showButtons
if not voidP(backBtn) then set the visible of backBtn = True
if not voidP(nextBtn) then set the visible of nextBtn = True
end
on clickButton buttonName
case buttonName of
"NextButton": nextScreen()
"BackButton": prevScreen()
"AddButton": addFiles()
"RemoveButton": removeFiles()
"RemoveAllButton": removeAllFiles()
"BrowseButton": chooseFolder()
end case
updateScreen()
end
on clickCheckbox boxSprite
global exportFormats, exportOptions
set optName = the opt of boxSprite
if the enabled of boxSprite then
set boxState = the selected of boxSprite
setOpt(optName, boxState)
updateScreen()
else
case optName of
#shockwave3d: missingToolAlert(#castRipper)
#decompile: missingToolAlert(#projectorRays)
otherwise: nothing
end case
end if
end
on initCheckboxes
repeat with i = 1 to the lastChannel
set sp = sprite i
if the name of sp contains "Checkbox" then
set the selected of sp = getOpt(the opt of sp)
end if
end repeat
end
on updateCheckboxes
repeat with i = 1 to the lastChannel
set sp = sprite i
if the name of sp contains "Checkbox" then
set the enabled of sp = canEnable(the opt of sp)
end if
end repeat
end
on getCheckbox opt
if stringP(opt) then
return sprite (opt & "Checkbox")
else if symbolP(opt) then
repeat with i = 1 to the lastChannel
set sp = sprite i
if the name of sp contains "Checkbox" then
if the opt of sp = opt then return sp
end if
end repeat
end if
end
on getCheckboxGroup groupName
set sprites = list()
set labelSprite = sprite (groupName & "Label")
if not voidP(labelSprite) then
set startNum = the spriteNum of labelSprite + 1
repeat with i = startNum to the lastChannel
set sp = sprite i
if the name of sp contains "Checkbox" then
sprites.append(sp)
else
exit repeat
end if
end repeat
end if
return sprites
end
on addFiles selectedFiles
set listObj = sprite "FileList"
set listData = the data of listObj
set listLabels = the labels of listObj
if not listP(selectedFiles) then set selectedFiles = fileMultiSelect()
repeat with filePath in selectedFiles
if listData.getPos(filePath) = 0 then
listData.add(filePath)
listLabels.add(getFilename(filePath))
end if
end repeat
set the data of listObj = listData
set the labels of listObj = listLabels
end
on removeFiles
set listObj = sprite "FileList"
set listData = the data of listObj
set listLabels = the labels of listObj
-- Flash lists are zero-indexed but at least Lingo has a nice shorthand to fix it
set highlighted = (the selectedIndices of listObj) + 1
repeat with i in highlighted
listData.setAt(i, EMPTY)
listLabels.setAt(i, EMPTY)
end repeat
repeat while listData.deleteOne(EMPTY)
listLabels.deleteOne(EMPTY)
end repeat
set the data of listObj = listData
set the labels of listObj = listLabels
end
on removeAllFiles
set listObj = sprite "FileList"
set the data of listObj = list()
set the labels of listObj = list()
end
on chooseFolder
set folderPath = folderSelect()
if folderPath <> EMPTY then set the text of sprite "FolderPathBox" to folderPath
end
on itemsDropped items
case the frameLabel of
"Choose Files":
addFiles(getDirFiles(items.getaProp(#Files)))
"Options":
set the text of sprite "FolderPathBox" to items.getaProp(#Folders).getAt(1)
end case
updateScreen()
end
on updateProgressBar
set fraction = getProgress()
set progBarRect = the rect of sprite "ProgressBar"
-- Only fill the inner area of the progress bar, excluding the 1-pixel border
set fillRect = rect(topLeft(progBarRect) + 1, bottomRight(progBarRect) - 1)
set fillWidth = fraction * the width of fillRect
set the right of fillRect = the left of fillRect + fillWidth
set the rect of sprite "ProgBarFill" = fillRect
updateStage()
end
on muiDialog muiOptions
set muiObj = new xtra("mui")
set choice = muiObj.Alert(muiOptions)
set muiObj = 0
return choice
end
on infoDialog title, message, icon
set muiOptions = [#buttons: #Ok, #default: 1, #icon: icon, \
#message: message, #movable: True, #title: title]
muiDialog(muiOptions)
end
on errorDialog message
put RETURN & "Continue exporting?" after message
set muiOptions = [#buttons: #YesNo, #default: 2, #icon: #error, \
#message: message, #movable: True, #title: "Export Error"]
set choice = muiDialog(muiOptions)
if choice = 2 then
if the frameLabel <> "Choose Files" then gotoScreen("Choose Files")
else halt()
end if
end
on missingToolAlert toolName
set toolInfo = getaProp(the value of field "ToolInfo", toolName)
set msg = toolInfo.getaProp(#msg) & RETURN & "Download it now?"
set goURL = toolInfo.getaProp(#url)
set muiOptions = [#buttons: #YesNo, #default: 1, #icon: #question, \
#message: msg, #movable: True, #title: "Software Download"]
set choice = muiDialog(muiOptions)
if choice = 1 then gotoNetPage goURL
end
on finishExport
global numWarnings, exportFolder, exportOptions, fileFolders
if exportOptions.getaProp(#dismissDialogs) then closeAutoclicker()
unlink()
-- Make sure the progress bar shows as full before the dialog appears
updateScreen()
updateStage()
set title = "Finished"
set message = "Export completed"
if numWarnings then
set icon = #caution
put SPACE & "with warnings" after title
put SPACE & "with" && numWarnings && "warnings. See the Export.log file for details." after message
else
set icon = #note
put "!" after title
put "." after message
end if
resetLog()
set fileFolders = propList()
infoDialog(title, message, icon)
resetProgress()
openPath(exportFolder)
set exportFolder = VOID
gotoScreen("Choose Files")
end