| 1 | -- thisMoviesScript |
|---|
| 2 | ----------------------------------- |
|---|
| 3 | -- DESCRIPTION: |
|---|
| 4 | -- Main movie script of this movie, with the standard moviescript handlers like: |
|---|
| 5 | -- startMovie, stopmovie, closeWindow and idle |
|---|
| 6 | -- |
|---|
| 7 | -- REQUIRES: |
|---|
| 8 | -- script "aleXtrasMovieScript" as provider for library scripts -> xscr() |
|---|
| 9 | -- script "commonMovieScript" -- standard handlers |
|---|
| 10 | -- script "GetSetPrefs" -- read and write preferences |
|---|
| 11 | -- |
|---|
| 12 | -- WARNINGS: |
|---|
| 13 | -- IMPORTANT NOTES: |
|---|
| 14 | -- This movie uses the sleep method on idle in order to prevent CPU hogging |
|---|
| 15 | -- by a movie, which is supposed ti run all the time |
|---|
| 16 | -- This means, that on mac, you will sleep one tick on idle, while on PC it is only a millisecond |
|---|
| 17 | -- While that keeps the CPU usage low, the main movie won't run at "full speed" |
|---|
| 18 | -- So in order to test the speed of the main movie close this MIAW tool! |
|---|
| 19 | -- |
|---|
| 20 | -- which xtra to use for the menu? |
|---|
| 21 | -- If you prefer to use buddyMenu xtra (which is buggy, but free) over OSControl xtra |
|---|
| 22 | -- (you need a license to use it in authoring) |
|---|
| 23 | -- simply replace the OSControl menu member with another member. |
|---|
| 24 | -- You can use the member "OSControlReplacement". |
|---|
| 25 | -- Select sprite 2 and 3 in the score window, then select |
|---|
| 26 | -- member "OSControlReplacement" in the cast window and select: |
|---|
| 27 | -- "Edit -> Exchange Cast Members" (or press Cmd + E). |
|---|
| 28 | -- You can delete the OSControl member "oscontrolMenu" afterwards. |
|---|
| 29 | -- From that time on the buddyMenu xtra is used to draw the menu instead of the OSControl xtra. |
|---|
| 30 | -- the only difference in the script is in script "OSCmenu_Utilities" and "OSCmenu_Handlers": |
|---|
| 31 | -- if sprite(me.spritenum).member.type = #OSmenu then ... |
|---|
| 32 | |
|---|
| 33 | -- Please read the readme file in order to learn how to add your own handlers to this menu |
|---|
| 34 | ----------------------------------- |
|---|
| 35 | |
|---|
| 36 | on startmovie |
|---|
| 37 | |
|---|
| 38 | mLoadScripts |
|---|
| 39 | |
|---|
| 40 | prefsScript = xscr(#GetSetPrefs) |
|---|
| 41 | if ilk(prefsScript) = #instance then |
|---|
| 42 | theResult = prefsScript.mReadPrefs("handlerMenuToolPrefs") |
|---|
| 43 | theResult = prefsScript.mGetPrefValue(#windowrect) |
|---|
| 44 | end if |
|---|
| 45 | if ilk(theResult) <> #rect then theResult = rect(0,0,(the activewindow).rect.width, (the activewindow).rect.height).offset(50, 50) |
|---|
| 46 | (the activewindow).rect = theResult |
|---|
| 47 | end |
|---|
| 48 | |
|---|
| 49 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 50 | |
|---|
| 51 | on stopmovie |
|---|
| 52 | mCallDestroy |
|---|
| 53 | end |
|---|
| 54 | |
|---|
| 55 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 56 | |
|---|
| 57 | on closewindow |
|---|
| 58 | |
|---|
| 59 | -------------- for some reason I decided NOT to write prefs, I can't remember why... |
|---|
| 60 | -------------- the only benefit of doing so, was to save the window position, but maybe there was any other problem...? |
|---|
| 61 | |
|---|
| 62 | -------------- I've put it back in now, as I am having a problem on windows anyway, that I'll need to investigate further |
|---|
| 63 | prefsScript = xscr(#GetSetPrefs) |
|---|
| 64 | if ilk(prefsScript) = #instance then |
|---|
| 65 | theResult = call(#mSetPrefValue, prefsScript, #windowrect, (the activewindow).rect) |
|---|
| 66 | theResult = call(#mSavePrefs, prefsScript, "handlerMenuToolPrefs", 1) |
|---|
| 67 | end if |
|---|
| 68 | |
|---|
| 69 | forget the activewindow |
|---|
| 70 | end |
|---|
| 71 | |
|---|
| 72 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 73 | -- the "sleep" trick to prevent CPU hogging and the fan of my PB going mad |
|---|
| 74 | |
|---|
| 75 | on idle |
|---|
| 76 | sleep 1 |
|---|
| 77 | end |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 81 | on ___________________BUILD_HANDLER_LIST |
|---|
| 82 | end |
|---|
| 83 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 84 | -- get a list of all handlers used in the current stage movie, sorted by scripttype and castlib |
|---|
| 85 | -- the more scripts you have in your main movie, the longer it takes |
|---|
| 86 | -- therefore it caches the results, so that it is only slow the first time the handler menu is opened |
|---|
| 87 | |
|---|
| 88 | on mBuildList kw |
|---|
| 89 | |
|---|
| 90 | kw = string(kw) |
|---|
| 91 | if kw starts "^" then |
|---|
| 92 | searchmode = #start |
|---|
| 93 | delete char 1 of kw |
|---|
| 94 | else if the last char of kw = "$" then |
|---|
| 95 | searchmode = #ends |
|---|
| 96 | delete the last char of kw |
|---|
| 97 | else |
|---|
| 98 | searchmode = #contains |
|---|
| 99 | end if |
|---|
| 100 | len = length(kw) |
|---|
| 101 | |
|---|
| 102 | li = [] |
|---|
| 103 | mscr = [] |
|---|
| 104 | currMScripts = [] |
|---|
| 105 | |
|---|
| 106 | pscr = [] |
|---|
| 107 | currPScripts = [] |
|---|
| 108 | |
|---|
| 109 | bscr = [] |
|---|
| 110 | currBScripts = [] |
|---|
| 111 | |
|---|
| 112 | li.add([#title: "Movie scripts", #items: mscr]) |
|---|
| 113 | li.add([#title: "Behavior scripts", #items: bscr]) |
|---|
| 114 | li.add([#title: "Parent scripts", #items: pscr]) |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | ---------------- menu divider for better readability: |
|---|
| 119 | mclnum = 0 |
|---|
| 120 | bclnum = 0 |
|---|
| 121 | pclnum = 0 |
|---|
| 122 | ---------------- // menu divider |
|---|
| 123 | |
|---|
| 124 | silscr = [] |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | li.add([#title: "Sprites", #items: silscr]) |
|---|
| 128 | |
|---|
| 129 | savelist = [:] |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | -- list to cache results for every different searchword |
|---|
| 133 | pCachedResults = xscr().mGetGlobalValue(#pCachedResults) |
|---|
| 134 | if ilk(pCachedResults) <> #proplist then |
|---|
| 135 | pCachedResults = [:] |
|---|
| 136 | xscr().mSetGlobalValue(#pCachedResults, pCachedResults) |
|---|
| 137 | end if |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | tell the stage |
|---|
| 142 | |
|---|
| 143 | repeat with n = 1 to the number of castlibs |
|---|
| 144 | repeat with z = 1 to the number of members of castlib n |
|---|
| 145 | memref = member(z, n) |
|---|
| 146 | if memref.type = #script then |
|---|
| 147 | |
|---|
| 148 | thisScriptList = mGetScriptHandlerList(memref, kw, searchmode, len, pCachedResults) |
|---|
| 149 | |
|---|
| 150 | if count(thisScriptList) > 0 then |
|---|
| 151 | |
|---|
| 152 | case memref.scripttype of |
|---|
| 153 | #movie: |
|---|
| 154 | |
|---|
| 155 | ---------------- menu divider for better readability: |
|---|
| 156 | if mclnum <> n then |
|---|
| 157 | mclnum = n |
|---|
| 158 | |
|---|
| 159 | currMScripts = [] |
|---|
| 160 | -- mscr.add([#title:"Castlib" && n &":", #items:currMScripts, #type:#divider]) |
|---|
| 161 | mscr.add([#title:"Castlib" && n && QUOTE & the name of castlib n & QUOTE & ":", #items:currMScripts, #name:"Castlib"&n]) |
|---|
| 162 | |
|---|
| 163 | end if |
|---|
| 164 | ---------------- // menu divider |
|---|
| 165 | |
|---|
| 166 | currMScripts.add(thisScriptList) |
|---|
| 167 | #parent: |
|---|
| 168 | |
|---|
| 169 | ---------------- menu divider for better readability: |
|---|
| 170 | if pclnum <> n then |
|---|
| 171 | pclnum = n |
|---|
| 172 | currPScripts = [] |
|---|
| 173 | -- pscr.add([#title:"Castlib" && n &":", #items:currPScripts, #type:#divider]) |
|---|
| 174 | pscr.add([#title:"Castlib" && n && QUOTE & the name of castlib n & QUOTE & ":", #items:currPScripts, #name:"Castlib"&n]) |
|---|
| 175 | end if |
|---|
| 176 | ---------------- // menu divider |
|---|
| 177 | |
|---|
| 178 | currPScripts.add(thisScriptList) |
|---|
| 179 | #score: |
|---|
| 180 | |
|---|
| 181 | ---------------- menu divider for better readability: |
|---|
| 182 | if bclnum <> n then |
|---|
| 183 | bclnum = n |
|---|
| 184 | currBScripts = [] |
|---|
| 185 | -- bscr.add([#title:"Castlib" && n &":", #items:currBScripts, #type:#divider]) |
|---|
| 186 | bscr.add([#title:"Castlib" && n && QUOTE & the name of castlib n & QUOTE & ":", #items:currBScripts, #name:"Castlib"&n]) |
|---|
| 187 | end if |
|---|
| 188 | ---------------- // menu divider |
|---|
| 189 | |
|---|
| 190 | currBScripts.add(thisScriptList) |
|---|
| 191 | end case |
|---|
| 192 | |
|---|
| 193 | savelist.setaprop(string(memref), thisScriptList) |
|---|
| 194 | |
|---|
| 195 | end if |
|---|
| 196 | |
|---|
| 197 | end if |
|---|
| 198 | |
|---|
| 199 | end repeat |
|---|
| 200 | end repeat |
|---|
| 201 | |
|---|
| 202 | -- quick and dirty way to check for D10 in order to check for sprite names |
|---|
| 203 | dummyMem = member("nonexistingmember" & the milliseconds) |
|---|
| 204 | |
|---|
| 205 | anz = the lastchannel |
|---|
| 206 | repeat with n = 1 to anz |
|---|
| 207 | thisSpr = sprite(n) |
|---|
| 208 | sil = thisSpr.scriptlist |
|---|
| 209 | cnt = count(sil) |
|---|
| 210 | if cnt > 0 then |
|---|
| 211 | thisSil = [] |
|---|
| 212 | repeat with m = 1 to cnt |
|---|
| 213 | thisScriptList = savelist.getaprop(string(sil[m][1])) |
|---|
| 214 | if listP(thisScriptList) then |
|---|
| 215 | if count(thisScriptList) then |
|---|
| 216 | thisScriptListDup = duplicate(thisScriptList) |
|---|
| 217 | thisScriptListDup.setaprop(#spritenum, n) |
|---|
| 218 | thisSil.add(thisScriptListDup) |
|---|
| 219 | end if |
|---|
| 220 | end if |
|---|
| 221 | end repeat |
|---|
| 222 | if count(thisSil) > 0 then |
|---|
| 223 | |
|---|
| 224 | if voidP(dummyMem) then |
|---|
| 225 | spritename = sprite(n).name |
|---|
| 226 | else |
|---|
| 227 | spritename = "" |
|---|
| 228 | end if |
|---|
| 229 | if length(spritename) < 1 then spritename = string(sendSprite(n, #mGetMyKanalName)) |
|---|
| 230 | silscr.add([#title:"sprite(" & n & ")" && spritename, #items: thisSil, #name:"sprite(" & n & ")"]) |
|---|
| 231 | end if |
|---|
| 232 | end if |
|---|
| 233 | end repeat |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | ------------------- my alextras: |
|---|
| 237 | alexmscr = member("aleXtrasMovieScript") |
|---|
| 238 | if ilk(alexmscr) = #member then |
|---|
| 239 | if alexmscr.type = #script then |
|---|
| 240 | if alexmscr.scripttype = #movie then |
|---|
| 241 | scrili = (mGetAleXtras()).getaprop(#scripts) |
|---|
| 242 | if ilk(scrili) = #proplist then |
|---|
| 243 | xscr = [] |
|---|
| 244 | |
|---|
| 245 | li.add([#title: "XScripts", #items: xscr]) |
|---|
| 246 | |
|---|
| 247 | anz = count(scrili) |
|---|
| 248 | repeat with nnn = 1 to anz |
|---|
| 249 | |
|---|
| 250 | theItems = [] |
|---|
| 251 | |
|---|
| 252 | thisScriptList = [#title: string(scrili.getPropAt(nnn)), #items: theItems] |
|---|
| 253 | |
|---|
| 254 | interfacestring = string(call(#interface, [scrili[nnn]])) |
|---|
| 255 | if offset(RETURN & "on ", interfacestring) then |
|---|
| 256 | |
|---|
| 257 | defaultItem = [#title: "", #items: [], #scripttype: #parent, #memName:string(scrili.getPropAt(nnn))] |
|---|
| 258 | found = mParseScriptText(interfacestring, theItems, defaultItem, kw, searchmode, len) |
|---|
| 259 | |
|---|
| 260 | end if |
|---|
| 261 | |
|---|
| 262 | theHandlers = scrili[nnn].handlers() |
|---|
| 263 | if ilk(theHandlers) = #list then |
|---|
| 264 | hndcnt = count(theHandlers) |
|---|
| 265 | if hndcnt > 0 then |
|---|
| 266 | if found = 1 then theItems.add([#title:"Handlers:", #items:[], #type:#divider]) |
|---|
| 267 | |
|---|
| 268 | repeat with mmm = 1 to hndcnt |
|---|
| 269 | |
|---|
| 270 | theItems.add([#title: string(theHandlers[mmm]), #items: [], #scripttype: #parent, #memName:string(scrili.getPropAt(nnn))]) |
|---|
| 271 | |
|---|
| 272 | end repeat |
|---|
| 273 | found = 1 |
|---|
| 274 | end if |
|---|
| 275 | end if |
|---|
| 276 | |
|---|
| 277 | if found = 1 then xscr.add(thisScriptList) |
|---|
| 278 | -- put RETURN & "scr = mGetXScript(#"&scripts.getPropAt(n)&")" & RETURN |
|---|
| 279 | end repeat |
|---|
| 280 | |
|---|
| 281 | end if |
|---|
| 282 | end if |
|---|
| 283 | end if |
|---|
| 284 | end if |
|---|
| 285 | ------------------- |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | end tell |
|---|
| 289 | |
|---|
| 290 | return li |
|---|
| 291 | |
|---|
| 292 | end |
|---|
| 293 | |
|---|
| 294 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 295 | -- get a list of all handlers which pass through the filter if any, in the format we need for the menu |
|---|
| 296 | |
|---|
| 297 | on mGetScriptHandlerList memref, kw, searchmode, len, pCachedResults |
|---|
| 298 | |
|---|
| 299 | scrtext = string(memref.scripttext) |
|---|
| 300 | if scrtext.length then |
|---|
| 301 | |
|---|
| 302 | theItems = [] |
|---|
| 303 | dername = memref.name |
|---|
| 304 | if not dername.length then dername = string(memref) |
|---|
| 305 | |
|---|
| 306 | thisScriptList = [#title: dername, #items: theItems] |
|---|
| 307 | |
|---|
| 308 | defaultItem = [#title: "", #items: [], #scripttype: memref.scripttype, #memName:dername, #memNum:memref.membernum, #clibNum:memref.castlibnum, #sel:[1,1]] |
|---|
| 309 | |
|---|
| 310 | if len < 1 then |
|---|
| 311 | |
|---|
| 312 | ----------- unfortunately the modified date doesn't work at all so we can't cache by modified date |
|---|
| 313 | ----------- we cache instead by scripttext length, which will fail only if the bad chance happens, |
|---|
| 314 | ----------- that the modification is exactly the same length as the original |
|---|
| 315 | |
|---|
| 316 | cached = pCachedResults.getaprop(string(memref)) |
|---|
| 317 | if ilk(cached) = #proplist then |
|---|
| 318 | theDate = cached.getaprop(#theDate) |
|---|
| 319 | -- if theDate = memref.modifiedDate then |
|---|
| 320 | if theDate = scrtext.length then |
|---|
| 321 | found = 1 |
|---|
| 322 | thisScriptList.setaprop(#items, cached.getaprop(#items)) |
|---|
| 323 | else |
|---|
| 324 | pCachedResults.deleteprop(string(memref)) |
|---|
| 325 | end if |
|---|
| 326 | end if |
|---|
| 327 | end if |
|---|
| 328 | if found <> 1 then |
|---|
| 329 | found = mParseScriptText(scrtext, theItems, defaultItem, kw, searchmode, len) |
|---|
| 330 | if len < 1 then |
|---|
| 331 | -- pCachedResults.setaprop(string(memref), [#theDate:memref.modifiedDate, #items:duplicate(theItems)]) |
|---|
| 332 | pCachedResults.setaprop(string(memref), [#theDate:scrtext.length, #items:duplicate(theItems)]) |
|---|
| 333 | end if |
|---|
| 334 | end if |
|---|
| 335 | end if |
|---|
| 336 | |
|---|
| 337 | if found <> 1 then return [:] |
|---|
| 338 | return thisScriptList |
|---|
| 339 | end |
|---|
| 340 | |
|---|
| 341 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 342 | -- parse the scripttext for handlernames, considering RETURN & "on " as beginning of a handler |
|---|
| 343 | ------ the parameters <kw> <len> and <searchmode> are for the filter |
|---|
| 344 | |
|---|
| 345 | on mParseScriptText scrtext, itemList, defaultItem, kw, searchmode, len |
|---|
| 346 | |
|---|
| 347 | if scrtext starts "on " then |
|---|
| 348 | put RETURN before scrtext |
|---|
| 349 | selOffs = 1 |
|---|
| 350 | else |
|---|
| 351 | selOffs = 0 |
|---|
| 352 | end if |
|---|
| 353 | offs = offset(RETURN&"on ", scrtext) |
|---|
| 354 | |
|---|
| 355 | found = 0 |
|---|
| 356 | repeat while offs > 0 |
|---|
| 357 | delete char 1 to (offs + 3) of scrtext |
|---|
| 358 | selOffs = selOffs + offs + 3 |
|---|
| 359 | |
|---|
| 360 | |
|---|
| 361 | ------ some programmers like to use parentheses in their handler definitions :-( |
|---|
| 362 | l1 = scrtext.line[1] |
|---|
| 363 | parentheseOffs = offset("(", l1) |
|---|
| 364 | if parentheseOffs > 0 then |
|---|
| 365 | put " " into char parentheseOffs of scrtext |
|---|
| 366 | parentheseOffs = offset(")", l1) |
|---|
| 367 | if parentheseOffs > 0 then |
|---|
| 368 | -- put " " into char parentheseOffs of scrtext |
|---|
| 369 | delete char parentheseOffs of scrtext |
|---|
| 370 | end if |
|---|
| 371 | end if |
|---|
| 372 | ------ // parentheses detach... |
|---|
| 373 | |
|---|
| 374 | addItem = 1 |
|---|
| 375 | |
|---|
| 376 | if len > 0 then |
|---|
| 377 | hnd = scrtext.word[1] |
|---|
| 378 | |
|---|
| 379 | offs = offset(kw, hnd) |
|---|
| 380 | if offs > 0 then |
|---|
| 381 | case searchmode of |
|---|
| 382 | #start: |
|---|
| 383 | addItem = (offs = 1) |
|---|
| 384 | #ends: |
|---|
| 385 | addItem = (offs = (length(hnd) - len + 1)) |
|---|
| 386 | otherwise: |
|---|
| 387 | addItem = (offs > 0) |
|---|
| 388 | end case |
|---|
| 389 | else |
|---|
| 390 | addItem = 0 |
|---|
| 391 | end if |
|---|
| 392 | end if |
|---|
| 393 | |
|---|
| 394 | if addItem then |
|---|
| 395 | |
|---|
| 396 | thisItem = duplicate(defaultItem) |
|---|
| 397 | thisItem.setaprop(#title, scrtext.line[1]) |
|---|
| 398 | thisItem.setaprop(#sel, [selOffs, selOffs+scrtext.line[1].word[1].length]) |
|---|
| 399 | |
|---|
| 400 | itemList.add(thisItem) |
|---|
| 401 | found = 1 |
|---|
| 402 | end if |
|---|
| 403 | |
|---|
| 404 | offs = offset(RETURN&"on ", scrtext) |
|---|
| 405 | |
|---|
| 406 | end repeat |
|---|
| 407 | |
|---|
| 408 | return found |
|---|
| 409 | end |
|---|
| 410 | |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 416 | on _______________MUI_DIALOG_HANDLERS |
|---|
| 417 | end |
|---|
| 418 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 419 | -- MUI dialog to get the parameter values, if required |
|---|
| 420 | -- unfortunately the mui dialog still (this is 2007) doesn't take a target instance to send the events to |
|---|
| 421 | -- therefore we always need a moviescript handler for the callbacks -- ugly :-( |
|---|
| 422 | |
|---|
| 423 | |
|---|
| 424 | on mMuiCallBack param1, param2, param3 |
|---|
| 425 | theGlobs = call(#mGetGlobalList, mGetXScript()) |
|---|
| 426 | theParams = theGlobs.getaprop(#theParams) |
|---|
| 427 | |
|---|
| 428 | if param1 = #itemChanged then |
|---|
| 429 | theParams.setaprop(param3.title, param3.value) |
|---|
| 430 | |
|---|
| 431 | -------------------------------------------- cache the last entries: |
|---|
| 432 | parameterCache = theGlobs.getaprop(#parameterCache) |
|---|
| 433 | if ilk(parameterCache) <> #proplist then |
|---|
| 434 | parameterCache = [:] |
|---|
| 435 | theGlobs.setaprop(#parameterCache, parameterCache) |
|---|
| 436 | end if |
|---|
| 437 | thisCmd = parameterCache.getaprop(theGlobs.getaprop(#cmd)) |
|---|
| 438 | if ilk(thisCmd) <> #proplist then |
|---|
| 439 | thisCmd = [:] |
|---|
| 440 | parameterCache.setaprop(theGlobs.getaprop(#cmd), thisCmd) |
|---|
| 441 | end if |
|---|
| 442 | thisCmd.setaprop(param3.title, param3.value) |
|---|
| 443 | -------------------------------------------- // cache the last entries |
|---|
| 444 | |
|---|
| 445 | else if (param3.title = "Cancel") and (param1 = #itemclicked) then |
|---|
| 446 | (theGlobs.theMuiObj).stop(0) |
|---|
| 447 | theGlobs[#theMuiObj] = void |
|---|
| 448 | |
|---|
| 449 | else if (param3.title = "OK") and (param1 = #itemclicked) then |
|---|
| 450 | (theGlobs.theMuiObj).stop(0) |
|---|
| 451 | theGlobs[#theMuiObj] = void |
|---|
| 452 | |
|---|
| 453 | xscr().mCreateTimeout("handlerlisttimeout", 5, #mDoCmd) |
|---|
| 454 | |
|---|
| 455 | end if |
|---|
| 456 | |
|---|
| 457 | end |
|---|
| 458 | |
|---|
| 459 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 460 | |
|---|
| 461 | on mShowMui str |
|---|
| 462 | theGlobs = xscr().mGetGlobalList() |
|---|
| 463 | theParams = theGlobs.getaprop(#theParams) |
|---|
| 464 | |
|---|
| 465 | if not objectP(theGlobs.getaprop(#theMuiObj)) then |
|---|
| 466 | MUIobj = new(xtra "Mui") |
|---|
| 467 | if not objectP(MUIobj) then |
|---|
| 468 | alert "Error. MUI Xtra not installed." |
|---|
| 469 | exit |
|---|
| 470 | end if |
|---|
| 471 | theGlobs[#theMuiObj] = MUIobj |
|---|
| 472 | else |
|---|
| 473 | MUIobj = theGlobs.theMuiObj |
|---|
| 474 | end if |
|---|
| 475 | |
|---|
| 476 | if not objectP(MUIobj) then |
|---|
| 477 | alert "Error. MUI Xtra not installed." |
|---|
| 478 | exit |
|---|
| 479 | end if |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | -------------------------------------------- cache the last entries: |
|---|
| 483 | parameterCache = theGlobs.getaprop(#parameterCache) |
|---|
| 484 | if ilk(parameterCache) <> #proplist then |
|---|
| 485 | parameterCache = [:] |
|---|
| 486 | theGlobs.setaprop(#parameterCache, parameterCache) |
|---|
| 487 | end if |
|---|
| 488 | thisCmd = parameterCache.getaprop(theGlobs.getaprop(#cmd)) |
|---|
| 489 | if ilk(thisCmd) <> #proplist then |
|---|
| 490 | thisCmd = [:] |
|---|
| 491 | parameterCache.setaprop(theGlobs.getaprop(#cmd), thisCmd) |
|---|
| 492 | end if |
|---|
| 493 | -------------------------------------------- // cache the last entries |
|---|
| 494 | |
|---|
| 495 | |
|---|
| 496 | |
|---|
| 497 | aWindowPropList = MUIobj.GetWindowPropList() |
|---|
| 498 | aWindowPropList.name = "Enter parameters" |
|---|
| 499 | aWindowPropList.callback = "mMuiCallBack" |
|---|
| 500 | aWindowPropList.xposition = -1 |
|---|
| 501 | aWindowPropList.yposition = -1 |
|---|
| 502 | aWindowPropList.width = 0 |
|---|
| 503 | aWindowPropList.height = 0 |
|---|
| 504 | aWindowPropList.closebox = 0 |
|---|
| 505 | |
|---|
| 506 | aWindowItemList=[] |
|---|
| 507 | |
|---|
| 508 | -- WindowBegin |
|---|
| 509 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 510 | tempItemPropList.type = #windowBegin |
|---|
| 511 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 512 | |
|---|
| 513 | -- Group V begin |
|---|
| 514 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 515 | tempItemPropList.type = #groupvBegin |
|---|
| 516 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 517 | |
|---|
| 518 | olddelim = the itemdelimiter |
|---|
| 519 | the itemdelimiter = "," |
|---|
| 520 | wcnt = str.item.count |
|---|
| 521 | repeat with n = 1 to wcnt |
|---|
| 522 | thisW = str.item[n] |
|---|
| 523 | |
|---|
| 524 | if thisW = "spritenum" then |
|---|
| 525 | if integerP(theGlobs.getaprop(#spritenum)) then thisCmd.setaprop(thisW, theGlobs.getaprop(#spritenum)) |
|---|
| 526 | end if |
|---|
| 527 | |
|---|
| 528 | -- Group H begin |
|---|
| 529 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 530 | tempItemPropList.type = #grouphBegin |
|---|
| 531 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 532 | |
|---|
| 533 | -- Label |
|---|
| 534 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 535 | tempItemPropList.type = #label |
|---|
| 536 | tempItemPropList.value = thisW |
|---|
| 537 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 538 | |
|---|
| 539 | -- editText |
|---|
| 540 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 541 | tempItemPropList.type = #editText |
|---|
| 542 | tempItemPropList.value = string(thisCmd.getaprop(thisW)) |
|---|
| 543 | tempItemPropList.title = thisW |
|---|
| 544 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 545 | |
|---|
| 546 | -- Group H end |
|---|
| 547 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 548 | tempItemPropList.type = #grouphend |
|---|
| 549 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 550 | |
|---|
| 551 | theParams.addProp(thisW, string(thisCmd.getaprop(thisW))) |
|---|
| 552 | |
|---|
| 553 | end repeat |
|---|
| 554 | the itemdelimiter = olddelim |
|---|
| 555 | |
|---|
| 556 | -- Group H begin |
|---|
| 557 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 558 | tempItemPropList.type = #grouphBegin |
|---|
| 559 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 560 | |
|---|
| 561 | -- Cancel button |
|---|
| 562 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 563 | tempItemPropList.type = #cancelPushButton |
|---|
| 564 | tempItemPropList.title = "Cancel" |
|---|
| 565 | tempItemPropList.attributes=[#layoutStyle : [#right]] |
|---|
| 566 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 567 | |
|---|
| 568 | -- OK button |
|---|
| 569 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 570 | tempItemPropList.type = #defaultPushButton |
|---|
| 571 | tempItemPropList.title = "OK" |
|---|
| 572 | tempItemPropList.attributes=[#layoutStyle : [#right]] |
|---|
| 573 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 574 | |
|---|
| 575 | -- Group H end |
|---|
| 576 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 577 | tempItemPropList.type = #grouphend |
|---|
| 578 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 579 | |
|---|
| 580 | -- Group V end |
|---|
| 581 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 582 | tempItemPropList.type = #groupVend |
|---|
| 583 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 584 | |
|---|
| 585 | -- Last, set up end of window |
|---|
| 586 | tempItemPropList = MUIobj.GetItemPropList() |
|---|
| 587 | tempItemPropList.type = #windowEnd |
|---|
| 588 | aWindowItemList.add(tempItemPropList.duplicate()) |
|---|
| 589 | |
|---|
| 590 | MUIobj.Initialize([#windowPropList:aWindowPropList, #windowItemList:aWindowItemList]) |
|---|
| 591 | run(MUIobj) |
|---|
| 592 | end |
|---|
| 593 | |
|---|
| 594 | |
|---|
| 595 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 596 | on _____________________OSC_UTILITIES |
|---|
| 597 | end |
|---|
| 598 | -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|---|
| 599 | -- the whole thing started with buddyMenu. here's a handler, which just converts a list in "buddyMenu-format" to OSControls format |
|---|
| 600 | |
|---|
| 601 | on mConvertToOSC li |
|---|
| 602 | isSubmenu = 0 |
|---|
| 603 | repeat with n = count(li) down to 1 |
|---|
| 604 | if listP(li[n]) then |
|---|
| 605 | mConvertToOSC li[n] |
|---|
| 606 | isSubmenu = li[n] |
|---|
| 607 | li.deleteAt(n) |
|---|
| 608 | else |
|---|
| 609 | if listP(isSubmenu) then |
|---|
| 610 | li[n] = [#text: li[n], #submenu:isSubmenu] |
|---|
| 611 | else |
|---|
| 612 | if li[n] = "" then |
|---|
| 613 | li[n] = [#text: "(-"] |
|---|
| 614 | else |
|---|
| 615 | li[n] = [#text: li[n]] |
|---|
| 616 | end if |
|---|
| 617 | end if |
|---|
| 618 | |
|---|
| 619 | isSubmenu = 0 |
|---|
| 620 | end if |
|---|
| 621 | end repeat |
|---|
| 622 | |
|---|
| 623 | end |
|---|