| 1 | -- aleXtrasMovieScript |
|---|
| 2 | --------------------------------------------------------------------- |
|---|
| 3 | -- CREATED: |
|---|
| 4 | -- 2005 |
|---|
| 5 | -- |
|---|
| 6 | -- PROPERTIES: |
|---|
| 7 | --!memberProperties: [#name: "aleXtrasMovieScript", #scripttype: #movie, #scriptSyntax: #lingo, #comments:"~/Documents/Scripts/lingo/aleXtrasMovieScript.ls"] |
|---|
| 8 | -- |
|---|
| 9 | -- DESCRIPTION: |
|---|
| 10 | -- -- LDM Xtras Moviescript -- c05 Alex da Franca -- alex@farbflash.de |
|---|
| 11 | -- store instances of scripts and bitmaps in a 'global' list (-> property pAleXtras) |
|---|
| 12 | -- and provide access to them for all scripts |
|---|
| 13 | -- |
|---|
| 14 | -- REQUIRES: |
|---|
| 15 | -- script "commonmoviescript" |
|---|
| 16 | -- |
|---|
| 17 | -- USAGE: |
|---|
| 18 | -- put it in one of your castlib, DON'T RENAME THIS MEMBER !! |
|---|
| 19 | -- use xscr(<name of script as symbol>) to get a reference to the script from |
|---|
| 20 | -- every script of the movie. It will return an instance of the script |
|---|
| 21 | -- |
|---|
| 22 | -- PARAMS: |
|---|
| 23 | -- - |
|---|
| 24 | -- |
|---|
| 25 | -- RETURNS: |
|---|
| 26 | -- - |
|---|
| 27 | -- |
|---|
| 28 | -- WARNINGS: |
|---|
| 29 | -- - |
|---|
| 30 | -- |
|---|
| 31 | -- TODO: |
|---|
| 32 | -- - |
|---|
| 33 | ----------------------------------- |
|---|
| 34 | |
|---|
| 35 | property pAleXtras |
|---|
| 36 | |
|---|
| 37 | on mGetAleXtras |
|---|
| 38 | |
|---|
| 39 | alextras = (script "aleXtrasMovieScript").pAleXtras |
|---|
| 40 | if not(objectP(alextras)) then |
|---|
| 41 | |
|---|
| 42 | cms = member("commonMovieScript") |
|---|
| 43 | if ilk(cms) <> #member then |
|---|
| 44 | alert "Script commonMovieScript missing, can't proceed" |
|---|
| 45 | halt |
|---|
| 46 | end if |
|---|
| 47 | if cms.type <> #script then |
|---|
| 48 | alert "Script commonMovieScript missing, can't proceed" |
|---|
| 49 | halt |
|---|
| 50 | end if |
|---|
| 51 | |
|---|
| 52 | if voidP(cms.script) then -- strangely enough this happened suddenly, dunno why... |
|---|
| 53 | -- until now it happened only in authoring with the stopped movie |
|---|
| 54 | -- therefore I just exit here without alert |
|---|
| 55 | halt |
|---|
| 56 | end if |
|---|
| 57 | |
|---|
| 58 | alextras = new(cms.script) |
|---|
| 59 | if ilk(alextras) <> #instance then |
|---|
| 60 | alert "Script" & QUOTE & "commonMovieScript" & QUOTE && "is missing. This movie can't proceed!" |
|---|
| 61 | halt |
|---|
| 62 | end if |
|---|
| 63 | (script "aleXtrasMovieScript").pAleXtras = alextras |
|---|
| 64 | |
|---|
| 65 | end if |
|---|
| 66 | return alextras |
|---|
| 67 | ----------------------------- |
|---|
| 68 | |
|---|
| 69 | alextras = (script "aleXtrasMovieScript").pAleXtras |
|---|
| 70 | if voidP(alextras) then |
|---|
| 71 | alextras = [:] |
|---|
| 72 | (script "aleXtrasMovieScript").pAleXtras = alextras |
|---|
| 73 | end if |
|---|
| 74 | return alextras |
|---|
| 75 | end |
|---|
| 76 | |
|---|
| 77 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 78 | |
|---|
| 79 | on xscr scrName |
|---|
| 80 | ----------------------------------- |
|---|
| 81 | -- CREATED: 11.02.2008 |
|---|
| 82 | -- ACTION: Description |
|---|
| 83 | -- INPUT: - |
|---|
| 84 | -- RETURNS: - |
|---|
| 85 | -- CALLER: - |
|---|
| 86 | -- DEBUG: - |
|---|
| 87 | -- TODO: - |
|---|
| 88 | ----------------------------------- |
|---|
| 89 | |
|---|
| 90 | return mGetXScript(scrName) |
|---|
| 91 | end |
|---|
| 92 | |
|---|
| 93 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 94 | |
|---|
| 95 | on mGetXScript scrName |
|---|
| 96 | ----------------------------------- |
|---|
| 97 | -- CREATED: 11.02.2008 |
|---|
| 98 | -- ACTION: Description |
|---|
| 99 | -- INPUT: - |
|---|
| 100 | -- RETURNS: - |
|---|
| 101 | -- CALLER: - |
|---|
| 102 | -- DEBUG: - |
|---|
| 103 | -- TODO: - |
|---|
| 104 | ----------------------------------- |
|---|
| 105 | |
|---|
| 106 | alextras = mGetAleXtras() |
|---|
| 107 | scrName = string(scrName) |
|---|
| 108 | if length(scrName) < 1 then return alextras |
|---|
| 109 | if scrName = "commonMovieScript" then return alextras |
|---|
| 110 | |
|---|
| 111 | str_scrName = alextras.mSymb2String(scrName) |
|---|
| 112 | inst = alextras.mGetInstance(str_scrName, 1) |
|---|
| 113 | if ilk(inst) <> #instance then |
|---|
| 114 | if the runmode contains "aut" then |
|---|
| 115 | put "Script" && QUOTE & str_scrName & QUOTE && "is missing! This may cause unwanted behavior" |
|---|
| 116 | end if |
|---|
| 117 | inst = [] |
|---|
| 118 | end if |
|---|
| 119 | if ilk(inst) = #instance then |
|---|
| 120 | if inst.handler(#new) = 1 then inst.new() |
|---|
| 121 | end if |
|---|
| 122 | return inst |
|---|
| 123 | ---------------------- |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | scrName = alextras.mSymbolify(scrName) |
|---|
| 127 | if ilk(scrName) <> #symbol then scrName = #commonmoviescript |
|---|
| 128 | scri = (mGetAleXtras()).getaprop(#scripts) |
|---|
| 129 | if ilk(scri) <> #proplist then |
|---|
| 130 | mLoadScripts |
|---|
| 131 | scri = (mGetAleXtras()).getaprop(#scripts) |
|---|
| 132 | end if |
|---|
| 133 | return scri.getaprop(scrName) |
|---|
| 134 | end |
|---|
| 135 | |
|---|
| 136 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 137 | -- if you have a stopmovie handler in a moviescript before this one, you should call 'mCallDestroy' yourself |
|---|
| 138 | -- if this script here is first, be aware, that your stopmovie handler might not get called |
|---|
| 139 | |
|---|
| 140 | on stopmovie |
|---|
| 141 | mCallDestroy |
|---|
| 142 | end |
|---|
| 143 | |
|---|
| 144 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 145 | |
|---|
| 146 | on mCallDestroy |
|---|
| 147 | call(#mCallDestroy, mGetXScript()) |
|---|
| 148 | -- call(#mDestroy, the actorlist) |
|---|
| 149 | end |
|---|
| 150 | |
|---|
| 151 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 152 | -- load local scripts (instead of the ones from the LDM -> authoring this movie) |
|---|
| 153 | |
|---|
| 154 | on mLoadScripts cls |
|---|
| 155 | ----------------------------------- |
|---|
| 156 | -- CREATED: 11.02.2008 |
|---|
| 157 | -- ACTION: Description |
|---|
| 158 | -- INPUT: - |
|---|
| 159 | -- RETURNS: - |
|---|
| 160 | -- CALLER: - |
|---|
| 161 | -- DEBUG: - |
|---|
| 162 | -- TODO: - |
|---|
| 163 | ----------------------------------- |
|---|
| 164 | |
|---|
| 165 | exit |
|---|
| 166 | |
|---|
| 167 | -- deprecated handler |
|---|
| 168 | -- only here for bakcward compatibility |
|---|
| 169 | -- the system is now built to load scripts only on demand |
|---|
| 170 | -- exception is mLoadScriptsFromLDM() which needs to grab all scripts |
|---|
| 171 | -- from the ldm and uses them. |
|---|
| 172 | -- be aware of the fact, that rawnew() is used on these scripts, so the ones of the LDM |
|---|
| 173 | -- won't have their new() handler called. I take care about that for you, though... |
|---|
| 174 | |
|---|
| 175 | end |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 179 | |
|---|
| 180 | on mLoadXScript whichName, dontCallDestroyHandler |
|---|
| 181 | -- overload a script, e.g. after changing at during the movie runs |
|---|
| 182 | |
|---|
| 183 | if not(symbolP(whichName)) then whichName = symbol(whichName) |
|---|
| 184 | if voidP(dontCallDestroyHandler) then dontCallDestroyHandler = 1 |
|---|
| 185 | xscr().mDeleteInstance(whichName, dontCallDestroyHandler) |
|---|
| 186 | |
|---|
| 187 | return xscr(whichName) |
|---|
| 188 | |
|---|
| 189 | end |
|---|
| 190 | |
|---|
| 191 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 192 | |
|---|
| 193 | on mLoadScriptsFromLDM whichSprite |
|---|
| 194 | |
|---|
| 195 | includes = [:] |
|---|
| 196 | |
|---|
| 197 | tell sprite(whichSprite) |
|---|
| 198 | cl = the number of castlibs |
|---|
| 199 | repeat with n = 1 to cl |
|---|
| 200 | num = the number of members of castlib cl |
|---|
| 201 | repeat with m = 1 to num |
|---|
| 202 | mem = member(m,n) |
|---|
| 203 | if length(mem.name) > 0 then |
|---|
| 204 | if mem.type = #script then |
|---|
| 205 | includes.setaProp(symbol(mem.name), rawNew(mem.script)) |
|---|
| 206 | end if |
|---|
| 207 | end if |
|---|
| 208 | end repeat |
|---|
| 209 | end repeat |
|---|
| 210 | end tell |
|---|
| 211 | |
|---|
| 212 | cms = includes.getaprop(#commonMovieScript) |
|---|
| 213 | if not(objectP(cms)) then |
|---|
| 214 | cms = member("commonMovieScript") |
|---|
| 215 | if ilk(cms) <> #member then |
|---|
| 216 | alert "Script commonMovieScript missing, can't proceed" |
|---|
| 217 | halt |
|---|
| 218 | end if |
|---|
| 219 | if cms.type <> #script then |
|---|
| 220 | alert "Script commonMovieScript missing, can't proceed" |
|---|
| 221 | halt |
|---|
| 222 | end if |
|---|
| 223 | cms = rawnew(cms.script) |
|---|
| 224 | end if |
|---|
| 225 | |
|---|
| 226 | (script "aleXtrasMovieScript").pAleXtras = cms |
|---|
| 227 | |
|---|
| 228 | globs = cms.mGetGlobalList() |
|---|
| 229 | incl = globs[#gParentScriptInstances] |
|---|
| 230 | if not(objectP(incl)) then |
|---|
| 231 | incl = [:] |
|---|
| 232 | globs[#gParentScriptInstances] = incl |
|---|
| 233 | end if |
|---|
| 234 | |
|---|
| 235 | repeat with n = count(incl) down to 1 |
|---|
| 236 | includes.setaprop(incl.getPropAt(n), incl[n]) |
|---|
| 237 | end repeat |
|---|
| 238 | includes.deleteOne(#commonMovieScript) |
|---|
| 239 | globs[#gParentScriptInstances] = includes |
|---|
| 240 | |
|---|
| 241 | exit |
|---|
| 242 | ------------------------------ deprecated: |
|---|
| 243 | |
|---|
| 244 | mediaList = mGetAleXtras() |
|---|
| 245 | |
|---|
| 246 | theScripts = mediaList.getaprop(#scripts) |
|---|
| 247 | if ilk(theScripts) <> #proplist then |
|---|
| 248 | theScripts = [:] |
|---|
| 249 | mediaList.setaprop(#scripts, theScripts) |
|---|
| 250 | end if |
|---|
| 251 | |
|---|
| 252 | theBitmaps = mediaList.getaprop(#bitmaps) |
|---|
| 253 | if ilk(theBitmaps) <> #proplist then |
|---|
| 254 | theBitmaps = [:] |
|---|
| 255 | mediaList.setaprop(#bitmaps, theBitmaps) |
|---|
| 256 | end if |
|---|
| 257 | |
|---|
| 258 | tell sprite(whichSprite) |
|---|
| 259 | cl = the number of castlibs |
|---|
| 260 | repeat with n = 1 to cl |
|---|
| 261 | num = the number of members of castlib cl |
|---|
| 262 | repeat with m = 1 to num |
|---|
| 263 | mem = member(m,n) |
|---|
| 264 | if length(mem.name) > 0 then |
|---|
| 265 | if mem.type = #script then |
|---|
| 266 | theScripts.setaProp(symbol(mem.name), mem.script) |
|---|
| 267 | else if mem.type = #bitmap then |
|---|
| 268 | theBitmaps.setaProp(symbol(mem.name), mem.image.duplicate()) |
|---|
| 269 | end if |
|---|
| 270 | end if |
|---|
| 271 | end repeat |
|---|
| 272 | end repeat |
|---|
| 273 | end tell |
|---|
| 274 | end |
|---|
| 275 | |
|---|
| 276 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 277 | |
|---|
| 278 | on mListAleXtras |
|---|
| 279 | |
|---|
| 280 | put "This handler used to put the alextras scripts only, now it puts all singletons instead" |
|---|
| 281 | |
|---|
| 282 | globs = xscr().mGetGlobalList() |
|---|
| 283 | incl = globs[#gParentScriptInstances] |
|---|
| 284 | if not(objectP(incl)) then |
|---|
| 285 | put "No scriptinstances stored" |
|---|
| 286 | exit |
|---|
| 287 | end if |
|---|
| 288 | |
|---|
| 289 | anz = count(incl) |
|---|
| 290 | repeat with n = 1 to anz |
|---|
| 291 | put RETURN & "scr = xscr().mGetInstance(" & QUOTE & incl.getPropAt(n) & QUOTE & ")" & RETURN |
|---|
| 292 | end repeat |
|---|
| 293 | put RETURN & "put scr.handlers()" & RETURN |
|---|
| 294 | put RETURN & "put call(#interface, [scr])" & RETURN |
|---|
| 295 | end |
|---|
| 296 | |
|---|
| 297 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 298 | |
|---|
| 299 | on mListScriptMemberNames |
|---|
| 300 | |
|---|
| 301 | cl = the activecastlib |
|---|
| 302 | sel = the selection of castlib cl |
|---|
| 303 | anz = sel.count |
|---|
| 304 | str = "" |
|---|
| 305 | repeat with n = 1 to anz |
|---|
| 306 | repeat with m = sel[n][1] to sel[n][2] |
|---|
| 307 | memref = member(m, cl) |
|---|
| 308 | if memref.type = #script then |
|---|
| 309 | put "Membername:" && memref.name & TAB & "("&memref.comments&")" & Return after str |
|---|
| 310 | end if |
|---|
| 311 | end repeat |
|---|
| 312 | end repeat |
|---|
| 313 | delete the last char of str |
|---|
| 314 | return str |
|---|
| 315 | |
|---|
| 316 | end |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 320 | |
|---|
| 321 | on mUpdateSelectedAlexScripts rootPath |
|---|
| 322 | |
|---|
| 323 | rootPath = string(rootPath) |
|---|
| 324 | |
|---|
| 325 | if length(rootPath) < 1 then |
|---|
| 326 | rootPath = baGetFolder("", "Please select the base folder with the scripts", 1, "Select scripts folder", -1, -1) |
|---|
| 327 | if length(rootPath) < 1 then exit |
|---|
| 328 | end if |
|---|
| 329 | |
|---|
| 330 | fio = new(xtra "fileio") |
|---|
| 331 | |
|---|
| 332 | cl = the activecastlib |
|---|
| 333 | sel = the selection of castlib cl |
|---|
| 334 | |
|---|
| 335 | |
|---|
| 336 | mp = the moviepath |
|---|
| 337 | if length(mp) < 1 then |
|---|
| 338 | if the runmode contains "plug" then |
|---|
| 339 | mp = "/" |
|---|
| 340 | else |
|---|
| 341 | mp = the applicationpath |
|---|
| 342 | end if |
|---|
| 343 | end if |
|---|
| 344 | delim = the last char of mp |
|---|
| 345 | |
|---|
| 346 | the itemdelimiter = "/" |
|---|
| 347 | |
|---|
| 348 | |
|---|
| 349 | ident = "/Documents/" |
|---|
| 350 | len = length(ident) |
|---|
| 351 | |
|---|
| 352 | repeat with sub in sel |
|---|
| 353 | repeat with mem = sub[1] to sub[2] |
|---|
| 354 | memref = member(mem,cl) |
|---|
| 355 | if memref.type = #script then |
|---|
| 356 | memname = memref.name |
|---|
| 357 | comm = memref.comments |
|---|
| 358 | if comm.length then |
|---|
| 359 | |
|---|
| 360 | offs = offset(ident, comm) |
|---|
| 361 | if offs > 0 then |
|---|
| 362 | |
|---|
| 363 | delete char 1 to (offs + len - 1) of comm |
|---|
| 364 | p = rootPath |
|---|
| 365 | anzit = comm.item.count |
|---|
| 366 | repeat with rr = 1 to anzit |
|---|
| 367 | put comm.item[rr] & delim after p |
|---|
| 368 | end repeat |
|---|
| 369 | delete the last char of comm |
|---|
| 370 | |
|---|
| 371 | fio.openFile(p, 1) |
|---|
| 372 | if fio.status() = 0 then |
|---|
| 373 | st = fio.readFile() |
|---|
| 374 | fio.closeFile() |
|---|
| 375 | memref.scripttext = st |
|---|
| 376 | put "Updated member" && memref.name && "(" & memref & ")" |
|---|
| 377 | else |
|---|
| 378 | baMsgBox("Unable to open " & p & ". Proceed with next file?", "File not found", "YesNo", "Exclamation", 2) |
|---|
| 379 | end if |
|---|
| 380 | |
|---|
| 381 | end if |
|---|
| 382 | |
|---|
| 383 | end if |
|---|
| 384 | end if |
|---|
| 385 | end repeat |
|---|
| 386 | end repeat |
|---|
| 387 | |
|---|
| 388 | fio = 0 |
|---|
| 389 | end |
|---|