Changeset 228 for trunk/lingosource/castlib1/alexUtilities.ls
- Timestamp:
- 03/20/09 18:08:22 (3 years ago)
- File:
-
- 1 edited
-
trunk/lingosource/castlib1/alexUtilities.ls (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lingosource/castlib1/alexUtilities.ls
r221 r228 2432 2432 end 2433 2433 2434 2434 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2435 2436 on mExportScripttext me, skipIcons, convertLineBreaksToUnix, theFolder 2437 2438 2439 theFolder = string(theFolder) 2440 if length(theFolder) < 1 then theFolder = mGetFolderPathFromUser(me) 2441 if length(theFolder) < 1 then exit 2442 2443 if the last char of theFolder <> the last char of the moviepath then put the last char of the moviepath after theFolder 2444 2445 2446 cl = the activecastlib 2447 sel = the selection of castlib cl 2448 firstCastNum = cl 2449 lastCastNum = cl 2450 2451 2452 DirectImageInstance = 0 2453 if skipIcons <> 1 then 2454 if mCheckForXtra(me, "SharpExport") = 1 then 2455 SharpExportInst = new(xtra "SharpExport") 2456 else 2457 skipIcons = 1 2458 end if 2459 end if 2460 2461 2462 isMac = (the platform contains "mac") -- we need the differentiation because of the dreaded 31 char limit 2463 2464 ----------------------- 2465 resetUNames = 0 2466 if isMac then 2467 if baSysFolder("prefs") starts "/" then 2468 baReturnUnixNames(0) 2469 resetUNames = 1 2470 end if 2471 end if 2472 ----------------------- 2473 2474 doit = 0 2475 versionNum = mGetFloatVersionNumber(me, the productversion) 2476 2477 repeat with m = firstCastNum to lastCastNum 2478 2479 listOfAllFiles = [] 2480 2481 thisFolder = theFolder 2482 2483 doit = 0 2484 2485 sel = the selection of castlib m 2486 2487 repeat with sub in sel 2488 repeat with n = sub[1] to sub[2] 2489 2490 memref = member(n, m) 2491 memtype = memref.type 2492 2493 convertLineBreaksToUnixT = 0 2494 2495 if [#script, #field, #text].getPos(memtype) > 0 then 2496 2497 case memtype of 2498 2499 ----------------------- 2500 #script: 2501 ext = ".ls" 2502 scrText = memref.scripttext 2503 scrtype = memref.scripttype 2504 2505 ------------------------------ meta data 2506 infolist = [:] 2507 infolist[#name] = memref.name 2508 infolist[#scripttype] = memref.scripttype 2509 if versionNum >= 10 then infolist[#scriptSyntax] = memref.scriptSyntax 2510 comm = memref.comments 2511 offs = offset(RETURN, comm) 2512 repeat while offs 2513 put QUOTE & " & RETURN & " & QUOTE into char offs of comm 2514 end repeat 2515 infolist[#comments] = comm 2516 2517 offs2 = 0 2518 export_meta_data = scrText&"" 2519 offs = offset("--!memberProperties:", export_meta_data) 2520 if offs > 0 then 2521 delete char 1 to offs of export_meta_data 2522 offs2 = offset("]", export_meta_data) 2523 end if 2524 2525 if offs2 > 0 then 2526 put "--!memberProperties:" && infolist into char offs to offs + offs2 of scrText 2527 else 2528 put "--!memberProperties:" && infolist & RETURN before scrText 2529 end if 2530 2531 ------------------------------ 2532 2533 ----------------------- 2534 #field: 2535 ext = ".txt" 2536 scrText = memref.text 2537 scrtype = #field 2538 ----------------------- 2539 #text: 2540 ext = ".html" 2541 scrText = memref.html 2542 convertLineBreaksToUnixT = 0 2543 scrtype = #text 2544 ----------------------- 2545 otherwise: 2546 ext = ".txt" 2547 scrText = memref.text 2548 scrtype = #field 2549 end case 2550 2551 memname = memref.name 2552 2553 theDefaultName = memname 2554 2555 doit = 1 2556 2557 if length(theDefaultName) < 1 then 2558 theDefaultName = "member" & n & "_" & m 2559 memref.name = theDefaultName 2560 put "renamed member" && memref && "to member(" & QUOTE & theDefaultName & QUOTE & ") as member without names are not supported" 2561 end if 2562 2563 theDefaultName = mStripFunnyCharsFromFileName(me, theDefaultName) 2564 2565 origname = theDefaultName&"" 2566 if length(theDefaultName) > 25 and isMac then 2567 2568 ms = string(the milliseconds) 2569 mlen = length(ms) 2570 ms = char mlen - 6 to mlen of ms 2571 2572 theDefaultName = char 1 to 18 of theDefaultName 2573 theDefaultName = theDefaultName & ms -- trim filenames as the mac version of fileio wants to deal with 31 chars 2574 2575 end if 2576 2577 2578 2579 ------------------------------------------ trac subversion support works better with unix linebreaks... 2580 if voidP(convertLineBreaksToUnix) then convertLineBreaksToUnix = 1 2581 if convertLineBreaksToUnix = "" then convertLineBreaksToUnix = 1 2582 2583 if convertLineBreaksToUnix = 1 then 2584 if convertLineBreaksToUnixT <> 1 then 2585 if mCheckForXtra(me, "Pregex") = 1 then 2586 2587 scrTextLi = [scrText] 2588 pregex_replace(scrTextLi, "\x0D\x0A?", "g", "\x0A") 2589 scrText = scrTextLi[1] 2590 2591 else 2592 2593 fndStr = numToChar(13) & numToChar(10) 2594 offs = offset(fndStr, scrText) 2595 repeat while offs > 0 2596 delete char offs of scrText 2597 offs = offset(fndStr, scrText) 2598 end repeat 2599 2600 fndStr = numToChar(13) 2601 offs = offset(fndStr, scrText) 2602 repeat while offs > 0 2603 put numToChar(10) into char offs of scrText 2604 offs = offset(fndStr, scrText) 2605 end repeat 2606 end if 2607 end if 2608 end if 2609 ----------------------------------------- 2610 2611 if theDefaultName <> origname then 2612 alterText = "" 2613 snam = baShortFileName(thisFolder & origname & ext) 2614 if length(snam) > 0 then 2615 alterText = mGetTextFromFile(me, snam) 2616 else 2617 alterText = mGetTextFromFile(me, thisFolder & origname & ext) 2618 end if 2619 else 2620 alterText = mGetTextFromFile(me, thisFolder & theDefaultName & ext) 2621 end if 2622 2623 listOfAllFiles.add(mLowerCase(me, origname)) 2624 2625 if alterText <> scrText then 2626 2627 --------------------- compare without whitespaces: 2628 noChanges = (mRemoveWhiteSpaces(me, scrText&"") = mRemoveWhiteSpaces(me, alterText&"")) 2629 2630 2631 if noChanges = 0 then 2632 2633 mSaveToTextFile me, scrText, thisFolder & theDefaultName & ext 2634 2635 bmexp = 0 2636 if skipIcons <> 1 then 2637 2638 thumbmember = new(#bitmap) 2639 thumbmember.picture = memref.thumbnail 2640 2641 if thumbmember.width > 0 then 2642 bmexp = 1 2643 if baFileExists(thisFolder & theDefaultName & ".png") then baDeleteFile(thisFolder & theDefaultName & ".png") 2644 2645 if objectP(DirectImageInstance) then 2646 2647 DirectImageInstance.imageLoadFromMember(thumbmember) 2648 DirectImageInstance.imageSaveToFile(thisFolder & theDefaultName & ".png", 100, 1,1) 2649 2650 else if objectP(SharpExportInst) then 2651 mExportBM me, thumbmember, thisFolder & theDefaultName & ".png", "png", 100, SharpExportInst 2652 2653 end if 2654 end if 2655 2656 thumbmember.erase() 2657 2658 end if 2659 2660 2661 if theDefaultName <> origname then 2662 2663 snam = baShortFileName(thisFolder & origname & ext) 2664 if length(snam) > 0 then baDeleteFile(snam) 2665 erg = baRenameFile(thisFolder & theDefaultName & ext, thisFolder & origname & ext) 2666 if erg <> 1 then put "Couldn't rename file " & thisFolder & theDefaultName & ext & " to " & thisFolder & origname & ext 2667 if bmexp = 1 then 2668 snam = baShortFileName(thisFolder & origname & ".png") 2669 if length(snam) > 0 then baDeleteFile(snam) 2670 erg = baRenameFile(thisFolder & theDefaultName & ".png", thisFolder & origname & ".png") 2671 if erg <> 1 then put "Couldn't rename file " & thisFolder & theDefaultName & ".png to " & thisFolder & origname & ".png" 2672 end if 2673 2674 end if 2675 2676 if origname <> memname then 2677 put "Renamed member" && memref && "to" && origname & ". Scriptmember names must not be emoty or contain illegal characters (SPACE, /, :, \, &)" 2678 end if 2679 2680 end if 2681 end if 2682 2683 end if 2684 end repeat 2685 end repeat 2686 2687 end repeat 2688 2689 if resetUNames = 1 then baReturnUnixNames(1) 2690 2691 DirectImageInstance = 0 2692 SharpExportInst = 0 2693 2694 end 2435 2695 2436 2696 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Note: See TracChangeset
for help on using the changeset viewer.
