Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window

Ignore:
Timestamp:
12/15/08 13:00:15 (3 years ago)
Author:
alex
Message:

only copy dir and cst files now, when doing svn update movie binaries. added function to split path in order to not assume, that the first dot is the file extension seperator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lingosource/castlib1/alexUtilities.ls

    r202 r215  
    1 -- Some of my Authoring Utility Handlers -- ©06 Alex da Franca -- alex@farbflash.de 
    2 ----------------------------------------------------------------------------------- 
     1-- alexUtilities 
     2----------------------------------- 
     3-- CREATED: 
     4-- 14.12.2008 
     5-- PROPERTIES: 
     6--!memberProperties: [#name: "alexUtilities", #scripttype: #parent, #scriptSyntax: #lingo, #comments: "~/Documents/Scripts/lingo/commonMovieScript.ls"] 
     7-- 
     8-- DESCRIPTION: 
     9--               Some of my Authoring Utility Handlers -- c06 Alex da Franca -- alex@farbflash.de 
     10-- 
     11-- REQUIRES: 
     12--               script "PseudoXMLPS" -> parse xml 
     13--               although it does not really REQUIRE shell xtra and buddyApi xtra 
     14--               still much of the functionality will gracefully fail, if those are not present 
     15--               In order to export images, the sharp image exporter is required 
     16--               if missing those functions fail gracefully 
     17-- 
     18-- USAGE: 
     19--               This script is instantiated and used in the "tell the stage" block and one of the functions 
     20--               which are defined in script "OSCmenu_Utilities" and which was selected by the user 
     21--               will be executed in "stage scope". That means, that references are made form within the stage context 
     22--               e.g. member("foo") will refer to a member in one of the stages castlibs 
     23--               sprite(x) will refere to sprite(x) in the stages score and so on 
     24-- 
     25--               Please see the descriptions of many of those handlers at: http://www.farbflash.org/trac/HandlerMenu/wiki/utilityHandlers 
     26--               (Although I started to comment each handler, I didn't reach far until now...) 
     27----------------------------------- 
    328 
    429property ancestor 
     
    1439on new me 
    1540  ancestor = new(script "PseudoXMLPS") -- we need this script later 
    16   -- and as we may already be in the scope of the stage, we have it as ancestor 
    17    
     41  -- and as we may already be in the scope of the stage, we use it as ancestor 
     42  -- because once in another scope, it will not be available as member 
    1843  return me 
    1944end 
     
    2449 
    2550on Authoring_ExchangeScriptListColorsToRGBs me 
     51  ----------------------------------- 
     52  --         ACTION: fix the score data which has #color instead of #rgb when authored with D10 
     53  --                 which fails with the older player (AUTHORING ONLY!) 
     54  --         INPUT: - 
     55  --         RETURNS: - 
     56  ----------------------------------- 
     57   
    2658  theLastFrame = the lastFrame 
    2759  theLastChannel = the lastChannel 
     
    6294 
    6395on mOpenContainingFolder me 
     96  ----------------------------------- 
     97  --         ACTION: Open the folder, where the current movie is inside in the Finder/Explorer  
     98  --         INPUT: - 
     99  --         RETURNS: - 
     100  ----------------------------------- 
     101   
    64102  if length(the moviepath) < 1 then 
    65103    alert "The movie must be saved first!" 
     
    78116 
    79117on mReadXML_2_List me, pfad 
     118  ----------------------------------- 
     119  --         ACTION: Read xml text from file and parse into lingo list using pseudoXMLPS script  
     120  --         INPUT: <pfad> ; string ; full pathname ; optional => default "" => show file selection dialog 
     121  --         RETURNS: lingo list or property list ; [:] in case of invalid xml file 
     122  ----------------------------------- 
     123   
    80124  theResult = [:] 
    81125  dertext = mGetTextFromFile(me, pfad) 
     
    91135 
    92136on mSaveList_2_XML me, theList, thePath 
     137  ----------------------------------- 
     138  --         ACTION: Convert a lingo list or property list to xml and write xml string to file 
     139  --         INPUT:  <theList> ; #list or #proplist ; required 
     140  --                 <thePath> ; string ; full pathname ; optional => default "" => show file save dialog 
     141  --         RETURNS: string => full pathname of newly created file or "", if user cancelled process 
     142  ----------------------------------- 
     143   
    93144  if not(list(theList)) then 
    94145    global gRetVal 
     
    111162 
    112163on mGetTextFromFile me, pfad 
     164  ----------------------------------- 
     165  --         ACTION: Read contents of textfile 
     166  --         INPUT:  <pfad> ; string ; full pathname ; optional => default "" => show file selection dialog 
     167  --         RETURNS: string => contents of textfile or "", if user cancelled process 
     168  ----------------------------------- 
     169   
    113170  retval = "" 
    114171   
     
    141198 
    142199on mSaveToTextFile me, theText, pfad, theTitle, theDefaultName, startfolder 
     200  ----------------------------------- 
     201  --         ACTION: Save text to textfile 
     202  --         INPUT:  <theText> ; string ; string to  save 
     203  --                 <pfad> ; string ; full pathname ; optional => default "" => show file save dialog 
     204  --                 <theTitle> ; string ; caption of the save dialog (if any => pfad == "") 
     205  --                 <theDefaultName> ; string ; default filename provided in the save dialog (if any => pfad == "") 
     206  --                 <startfolder> ; string ; startfolder of the save dialog (if any => pfad == "") 
     207  --         RETURNS: string => full pathname of newly created file or "", if user cancelled process 
     208  ----------------------------------- 
     209   
     210   
    143211  retval = 0 
    144212   
     
    215283 
    216284on mSaveTextToTempFile me, theText, pfad 
     285  ----------------------------------- 
     286  --         ACTION: Write text out to a temporary file 
     287  --                 (helper for the bbdiff and svn handler) 
     288  --         INPUT:  <theText> ; string ; string to  save 
     289  --                 <pfad> ; string ; full pathname ; optional => default "tmpfile.txt" in temporary files folder 
     290  --         RETURNS: string => full pathname of newly created file or "", if user cancelled process 
     291  ----------------------------------- 
    217292   
    218293  pfad = string(pfad) 
     
    231306 
    232307on mAppendTextToFile me, theText, pfad 
     308  ----------------------------------- 
     309  --         ACTION: Write text out to a temporary file 
     310  --                 (helper for the bbdiff and svn handler) 
     311  --         INPUT:  <theText> ; string ; string to append to file <pfad> 
     312  --                 <pfad> ; string ; full pathname ; optional => default "" => show file selection dialog 
     313  --         RETURNS: string => full pathname of newly created file or "", if user cancelled process 
     314  ----------------------------------- 
     315   
    233316  retval = 0 
    234317   
     
    312395   
    313396  if length(theType) < 1 then 
    314     if offset(".", theDefaultName) > 1 then 
    315       theType = theDefaultName.char[offset(".", theDefaultName) + 1 .. length(theDefaultName)] 
     397    splitpath = mSplitPath(me, theDefaultName) 
     398    --    if offset(".", theDefaultName) > 1 then 
     399    --      theType = theDefaultName.char[offset(".", theDefaultName) + 1 .. length(theDefaultName)] 
     400    --    end if 
     401    if length(splitpath[#extension]) > 0 then 
     402      theType = splitpath[#extension] 
     403      delete char 1 of theType 
    316404    end if 
    317405    forceType = 0 
     
    359447    len = length(pfad) 
    360448    if len < 1 then exit 
    361     basename = pfad 
    362     ext = "" 
    363     repeat with n = len down to 1 
    364       c = char n of pfad 
    365       if c = "." then exit repeat 
    366       put c before ext 
    367       if length(ext) > 4 then exit repeat 
    368     end repeat 
    369     if ["txt", "rtf", "htm", "html"].getPos(ext) > 0 then theType = ext 
     449    --    basename = pfad 
     450    --    ext = "" 
     451    --    repeat with n = len down to 1 
     452    --      c = char n of pfad 
     453    --      if c = "." then exit repeat 
     454    --      put c before ext 
     455    --      if length(ext) > 4 then exit repeat 
     456    --    end repeat 
     457    -- if ["txt", "rtf", "htm", "html"].getPos(ext) > 0 then theType = ext 
     458    splitpath = mSplitPath(me, pfad) 
     459    ext = splitpath[#extension] 
     460    if length(ext) > 0 then 
     461      if ".txt.rtf.htm.html" contains ext then 
     462        delete char 1 of ext 
     463        theType = ext 
     464      end if 
     465    end if 
    370466  end if 
    371467   
     
    630726  if (not(mac) and (theType = "pct")) then theType = "bmp" 
    631727   
    632   theDot = offset(".", thePath) 
    633   if theDot then thePath = thePath.char[1 .. (theDot - 1)] 
     728  --  theDot = offset(".", thePath) 
     729  --  if theDot then thePath = thePath.char[1 .. (theDot - 1)] 
     730  splitpath = mSplitPath(me, thePath) 
     731  thePath = splitpath[#basedir] & splitpath[#basename] 
    634732   
    635733  if not(["jpg", "png", "bmp", "pct"].getPos(theType)) then exit 
     
    755853  if (not(mac) and (theType = "pct")) then theType = "bmp" 
    756854   
    757   -- ensure the right file extension: 
    758   theDot = offset(".", thePath) 
    759   if theDot = 0 then thePath = thePath&"."&theType 
     855  -- -- ensure the right file extension: 
     856   
     857  --  theDot = offset(".", thePath) 
     858  --  if theDot = 0 then thePath = thePath&"."&theType 
     859   
     860  splitpath = mSplitPath(me, thePath) 
     861  if length(splitpath[#extension]) < 1 then splitpath[#extension] = "." & theType 
     862  thePath = splitpath[#basedir] & splitpath[#basename] & splitpath[#extension] 
     863   
    760864  -- else thePath = thePath.char[1 .. theDot]&theType 
    761865   
     
    21372241          mp = the moviepath 
    21382242          delim = the last char of mp 
    2139           od = the itemdelimiter 
    2140           the itemdelimiter = delim 
    2141           fname = the last item of pfad 
    2142           the itemdelimiter = od 
    2143           len = fname.length 
    2144           if fname.char[len - 3] = "." then 
    2145             fnameW = fname.char[1 .. len - 4] 
    2146             ext = fname.char[len - 2 .. len] 
    2147           else if fname.char[len - 4] = "." then 
    2148             fnameW = fname.char[1 .. len - 5] 
    2149             ext = fname.char[len - 3 .. len] 
    2150           else 
    2151             fnameW = fname 
    2152             ext = "" 
    2153           end if 
     2243          --          od = the itemdelimiter 
     2244          --          the itemdelimiter = delim 
     2245          --          fname = the last item of pfad 
     2246          --          the itemdelimiter = od 
     2247          --          len = fname.length 
     2248          --          if fname.char[len - 3] = "." then 
     2249          --            fnameW = fname.char[1 .. len - 4] 
     2250          --            ext = fname.char[len - 2 .. len] 
     2251          --          else if fname.char[len - 4] = "." then 
     2252          --            fnameW = fname.char[1 .. len - 5] 
     2253          --            ext = fname.char[len - 3 .. len] 
     2254          --          else 
     2255          --            fnameW = fname 
     2256          --            ext = "" 
     2257          --          end if 
     2258          splitpath = mSplitPath(me, pfad) 
     2259          fnameW = splitpath[#basename] 
     2260          ext = splitpath[#extension] 
     2261          fname = fnameW & ext 
     2262          if length(ext) > 0 then delete char 1 of ext 
    21542263           
    21552264          -- in case of field we always use the plain text: 
     
    25862695RETURN & "  -- CREATED:"&\ 
    25872696RETURN & "  -- <currentDate>"&\ 
     2697RETURN & "  -- PROPERTIES:"&\ 
     2698RETURN & "  --!memberProperties: [#name: "&QUOTE&"<scriptname>"&QUOTE&", #scripttype: #<scripttype>, #scriptSyntax: #<scriptSyntax>, #comments: "&QUOTE&"<comments>"&QUOTE&"]"&\ 
    25882699RETURN & "  --"&\ 
    25892700RETURN & "  -- DESCRIPTION:"&\ 
     
    25922703RETURN & "  -- REQUIRES:"&\ 
    25932704RETURN & "  -- (Prerequisites)"&\ 
    2594 RETURN & "  --"&\ 
     2705  RETURN & "  --"&\ 
    25952706RETURN & "  -- USAGE:"&\ 
    25962707RETURN & "  -- -"&\ 
     
    26622773      --------------------------------- for the current scriptname, which we only "know" here in this script 
    26632774      if replacePlaceHolder = 1 then 
    2664         placeholders = [["<currentDate>", the short date], ["<scriptname>", theMem.name]] 
     2775        placeholders = [["<currentDate>", the short date], ["<scriptname>", theMem.name], ["<scripttype>", theMem.scripttype], ["<scriptSyntax>", theMem.scriptSyntax], ["<comments>", theMem.comments]] 
    26652776         
    26662777        repeat with repl in placeholders 
     
    29013012end 
    29023013-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     3014 
     3015-- the following handlers are mostly duplicates from the script "commonMovieScript", 
     3016-- because we are running in the scope of the stage here, we can not use it directly 
     3017-- and therefore this script shall be completely self contained. 
    29033018 
    29043019-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     
    30383153  return memref.type 
    30393154end 
     3155 
     3156-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     3157 
     3158-- split a path into its three elements => base directory, basename and extension: 
     3159 
     3160on mSplitPath me, fname, delim -- delim optional: default = the systems pathdelimiter 
     3161   
     3162  olddelim = the itemdelimiter 
     3163  delim = string(delim) 
     3164  if length(delim) < 1 then 
     3165    delim =  the last char of the moviepath 
     3166    if length(delim) < 1 then 
     3167       
     3168      if the runmode contains "plug" then 
     3169        delim = "/" 
     3170      else 
     3171        delim = the last char of the applicationpath 
     3172      end if 
     3173       
     3174       
     3175      if length(delim) < 1 then delim = "/" 
     3176    end if 
     3177  end if 
     3178  the itemdelimiter = delim 
     3179  dateiname = the last item of fname 
     3180  delete the last item of fname 
     3181  put delim after fname 
     3182  the itemdelimiter = olddelim 
     3183   
     3184   
     3185  len = length(dateiname) 
     3186  ext = "" 
     3187  until = max(1, len-8) -- let's pretend, that a file extension is not langer than 8 chars 
     3188   
     3189  repeat with n = len down to until 
     3190    this = dateiname.char[n] 
     3191    put this before ext 
     3192    delete char n of dateiname 
     3193    if this = "." then exit repeat 
     3194  end repeat 
     3195   
     3196  if char 1 of ext <> "." then -- no extension 
     3197    put ext after dateiname 
     3198    ext = "" 
     3199  end if 
     3200   
     3201  return [#basedir:fname, #basename:dateiname, #extension:ext] 
     3202   
     3203end 
Note: See TracChangeset for help on using the changeset viewer.