~skykooler/swift-swf/quickly_trunk

« back to all changes in this revision

Viewing changes to bin/swift-swf

  • Committer: Skyler Lehmkuhl
  • Date: 2011-06-28 05:37:42 UTC
  • Revision ID: skykooler@yahoo.com-20110628053742-270suf1c6tqbjlaf
Creating ubuntu package

Show diffs side-by-side

added added

removed removed

Lines of Context:
922
922
        
923
923
def on_drag_data_received(widget, context, x, y, selection, target_type, timestamp):
924
924
        global pid
 
925
        global sep
925
926
        uri = selection.data.strip('\r\n\x00')
926
927
        uri_splitted = uri.split() # we may have more than one file dropped
927
928
        for uri in uri_splitted:
935
936
                        alert(path+" is not a valid image file!")
936
937
                else:
937
938
                        if not imghdr.what(path)=="png":
938
 
                                im.save("/tmp/swift"+str(pid)+"/"+path.split("/")[-1].split(".")[0]+".png")
939
 
                                path = "/tmp/swift"+str(pid)+"/"+path.split("/")[-1].split(".")[0]+".png"
 
939
                                im.save(os.environ["TEMP"]+sep+"swift"+str(pid)+sep+path.split(sep)[-1].split(".")[0]+".png")
 
940
                                path = os.environ["TEMP"]+sep+"swift"+str(pid)+sep+path.split(sep)[-1].split(".")[0]+".png"
940
941
                        f=path.split("/")[-1].split(".")
941
942
                        if f[0][0].isdigit():
942
943
                                alert("First character of filename is a digit!! Changing to \"i\".")
985
986
        global currentframe
986
987
        global level
987
988
        global objects
988
 
        keyframe_active = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/keyframe_active.png")
989
 
        keyframe_inactive = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/keyframe_inactive.png")
990
 
        frame_active_tween = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/frame_active_tween.png")
991
 
        frame_inactive_tween = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/frame_inactive_tween.png")
992
 
        keyframe_active_button = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/keyframe_active_button.png")
993
 
        keyframe_inactive_button = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/keyframe_inactive_button.png")
994
 
        frame_active_blank = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/frame_active_blank.png")
995
 
        frame_inactive_blank = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/frame_inactive_blank.png")
996
 
        frame_active_blank_5 = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/frame_active_blank_5.png")
997
 
        frame_inactive_blank_5 = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/frame_inactive_blank_5.png")
 
989
        keyframe_active = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"keyframe_active.png")
 
990
        keyframe_inactive = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"keyframe_inactive.png")
 
991
        frame_active_tween = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"frame_active_tween.png")
 
992
        frame_inactive_tween = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"frame_inactive_tween.png")
 
993
        keyframe_active_button = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"keyframe_active_button.png")
 
994
        keyframe_inactive_button = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"keyframe_inactive_button.png")
 
995
        frame_active_blank = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"frame_active_blank.png")
 
996
        frame_inactive_blank = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"frame_inactive_blank.png")
 
997
        frame_active_blank_5 = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"frame_active_blank_5.png")
 
998
        frame_inactive_blank_5 = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"frame_inactive_blank_5.png")
998
999
        if level==0 or currentfile["objects"][currentselect[level]].type == "movieclip":
999
1000
                for i in range (0, objects[currentselect[level]].frames[0][-1]+1):
1000
1001
                        try:
1026
1027
                source_id = gobject.timeout_add(100, exposeframevent, framewin, "animation-event", step+1)
1027
1028
def exposobjevent(objwin, event):
1028
1029
        global step
1029
 
        objpic = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/object_active.png")
 
1030
        objpic = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"object_active.png")
1030
1031
        objwin.window.draw_pixbuf(None, objpic, (step%16)*128, 0, 0, 0, 128, -1)
1031
1032
        source_id = gobject.timeout_add(100, exposobjevent, objwin, "expose-event")
1032
1033
def exposegradevent(gradwin, event):
1045
1046
        h1 = gb1.allocation.height
1046
1047
        h2 = gb2.allocation.height
1047
1048
        grad = [[0.0, 0, 0, 0, 1], [0.5, 1, 1, 0, 1], [1.0, 0, 0, 0, 1]]
1048
 
        grad = "/usr/share/swift-swf/media/icon.png"
 
1049
        grad = getdatapath()+sep+"media"+sep+"icon.png"
1049
1050
        #cr.set_line_width(2)
1050
 
        surface = cairo.ImageSurface.create_from_png("/usr/share/swift-swf/media/background_transparent.png")
 
1051
        surface = cairo.ImageSurface.create_from_png(getdatapath()+sep+"media"+sep+"background_transparent.png")
1051
1052
        pattern = cairo.SurfacePattern(surface)
1052
1053
        pattern.set_extend(cairo.EXTEND_REPEAT)
1053
1054
        cr.set_source(pattern)
1135
1136
        h1 = gb1.allocation.height
1136
1137
        h2 = gb2.allocation.height
1137
1138
        grad = [[0.0, 0, 0, 0, 1], [0.5, 1, 1, 0, 1], [1.0, 0, 0, 0, 1]]
1138
 
        grad = "/usr/share/swift-swf/media/icon.png"
1139
 
        surface = cairo.ImageSurface.create_from_png("/usr/share/swift-swf/media/background_transparent.png")
 
1139
        grad = getdatapath()+sep+"media"+sep+"icon.png"
 
1140
        surface = cairo.ImageSurface.create_from_png(getdatapath()+sep+"media"+sep+"background_transparent.png")
1140
1141
        pattern = cairo.SurfacePattern(surface)
1141
1142
        pattern.set_extend(cairo.EXTEND_REPEAT)
1142
1143
        cr1.set_source(pattern)
1818
1819
                #clean up code for saving application state should be added here
1819
1820
                #Delete any temp files so swift won't give an error on next boot
1820
1821
                global pid
1821
 
                os.system("rm /tmp/swift"+str(pid)+"/currentfile")
 
1822
                os.system("rm "+os.environ["TEMP"]+sep+"swift"+str(pid)+sep+"currentfile")
1822
1823
                gtk.main_quit()
1823
1824
        def save_dialog(self, widget, data=None):
1824
1825
                global path
1829
1830
                result = saver.run()
1830
1831
                #Filename includes path
1831
1832
                filename = saver.get_filename()
1832
 
                patharray = filename.split("/")
 
1833
                patharray = filename.split(sep)
1833
1834
                title = patharray.pop()
1834
1835
                titlearray = title.split(".")
1835
1836
                title = titlearray[0] #no extension
1836
1837
                path = ""
1837
1838
                for i in patharray:
1838
 
                        path = path+i+"/"
 
1839
                        path = path+i+sep
1839
1840
                
1840
1841
                
1841
1842
                saver.destroy()
1964
1965
                for i in patharray:
1965
1966
                        path = path+i+"/"
1966
1967
                try:
1967
 
                        ren = "/tmp/"+title+".tar.gz"
 
1968
                        ren = os.environ["TEMP"]+sep+title+".tar.gz"
1968
1969
                        shutil.copyfile(filename, ren)
1969
1970
                        tar = tarfile.open(ren, 'r:gz')
1970
1971
                        for item in tar:
1971
 
                                tar.extract(item, "/tmp/swift"+str(pid)+"/")
 
1972
                                tar.extract(item, os.environ["TEMP"]+sep+"swift"+str(pid)+sep)
1972
1973
                        os.system ("rm "+ren)
1973
1974
                except:
1974
1975
                        print "Error opening file."
1975
1976
                        alert("Error opening file!")
1976
1977
                        opener.destroy()
1977
1978
                        return 415
1978
 
                fc = open("/tmp/swift"+str(pid)+"/currentfile", "r")
 
1979
                fc = open(os.environ["TEMP"]+sep+"swift"+str(pid)+sep+"currentfile", "r")
1979
1980
                currentfilebase = []
1980
1981
                for i in fc:
1981
1982
                        currentfilebase.append(i)
1989
1990
                        currentfile["objects"][obtemp.name] = obtemp
1990
1991
                currentselect = ["root", None]
1991
1992
                for i in currentfile["colors"]["images"]:
1992
 
                        currentfile["colors"]["images"][i] = "/tmp/swift"+str(pid)+"/"+currentfile["colors"]["images"][i]
 
1993
                        currentfile["colors"]["images"][i] = os.environ["TEMP"]+sep+"swift"+str(pid)+sep+currentfile["colors"]["images"][i]
1993
1994
                level = 0
1994
1995
                fc.close()
1995
1996
                self.set_title("Swift - "+title+".swift")
2052
2053
                global doubleclick
2053
2054
                global level
2054
2055
                global objects
 
2056
                global sep
 
2057
                sep = os.sep
2055
2058
                level = 0
2056
2059
                title = "Untitled"
2057
2060
                currentfile = {"fileinfo":{"filename":"Untitled.swf", "bbox":[500, 500, 0, 0], "fps":50}, "colors":{"gradients":{}, "textures":{}, "images":{}}, "objects":{}, "sprites":{}, "buttons":{}, "actions":[""], "sounds":{}, "frames":[[0], {"sort":[], "sounds":[]}]}
2069
2072
                fiter = 0
2070
2073
                citer = 0
2071
2074
                step = 0
2072
 
                path = "/home/"+os.getlogin()+"/Desktop/"
 
2075
                path = os.environ["HOME"]+sep+"Desktop"+sep
2073
2076
                clicked = False
2074
2077
                doubleclick = False
2075
2078
                selectid=["#000000"]
2179
2182
                for i in currentfile["objects"]:
2180
2183
                        ob = currentfile["objects"][i]  
2181
2184
                        if ob.type=="button":
2182
 
                                idlefile = open("/tmp/idlefile"+i+".png", "w")
2183
 
                                hoverfile = open("/tmp/hoverfile"+i+".png", "w")
2184
 
                                pressedfile = open("/tmp/pressedfile"+i+".png", "w")
2185
 
                                hitfile = open("/tmp/hitfile"+i+".png", "w")
 
2185
                                idlefile = open(os.environ["TEMP"]+sep+"idlefile"+i+".png", "w")
 
2186
                                hoverfile = open(os.environ["TEMP"]+sep+"hoverfile"+i+".png", "w")
 
2187
                                pressedfile = open(os.environ["TEMP"]+sep+"pressedfile"+i+".png", "w")
 
2188
                                hitfile = open(os.environ["TEMP"]+sep+"hitfile"+i+".png", "w")
2186
2189
                                idlesurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
2187
2190
                                hoversurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
2188
2191
                                pressedsurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
2229
2232
                                hoverfile.close()
2230
2233
                                pressedfile.close()
2231
2234
                                hitfile.close()
2232
 
                                output = output+".png idle"+i+" \"/tmp/idlefile"+i+".png\"\n"
2233
 
                                output = output+".png hover"+i+" \"/tmp/hoverfile"+i+".png\"\n"
2234
 
                                output = output+".png pressed"+i+" \"/tmp/pressedfile"+i+".png\"\n"
2235
 
                                output = output+".png hit"+i+" \"/tmp/hitfile"+i+".png\"\n"
 
2235
                                output = output+".png idle"+i+" \""+os.environ["TEMP"]+sep+"idlefile"+i+".png\"\n"
 
2236
                                output = output+".png hover"+i+" \""+os.environ["TEMP"]+sep+"hoverfile"+i+".png\"\n"
 
2237
                                output = output+".png pressed"+i+" \""+os.environ["TEMP"]+sep+"pressedfile"+i+".png\"\n"
 
2238
                                output = output+".png hit"+i+" \""+os.environ["TEMP"]+sep+"hitfile"+i+".png\"\n"
2236
2239
                                output = output+".button "+i+"\n.show idle"+i+" as=idle\n"+"\n.show hover"+i+" as=hover\n"+"\n.show pressed"+i+" as=pressed\n.show hit"+i+" as=area\n"+".end\n"
2237
2240
 
2238
2241
                        elif ob.type=="movieclip":
2281
2284
                fc.flush()
2282
2285
                fc.close()
2283
2286
                #os.system("swfc -o"+path+title+".swf "+path+title+".sct")
2284
 
                compile = subprocess.Popen("swfc -o "+path+title+".swf "+path+title+".sct", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
 
2287
                swfc_exe_name = 'swfc' if os.sep == '/' else 'swfc.exe'         
 
2288
                compile = subprocess.Popen(swfc_exe_name+" -o "+path+title+".swf "+path+title+".sct", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=(os.sep=="/"))
2285
2289
                stdino, stdouterro = (compile.stdin, compile.stdout)
2286
2290
                print stdouterro.read()
2287
2291
                os.system("rm "+path+title+".sct")
2377
2381
                        filetype="unknown"
2378
2382
                if filetype=="image":
2379
2383
                        if not imghdr.what(filename)=="png":
2380
 
                                Image.open(filename).save("/tmp/swift"+str(pid)+"/"+f[0]+".png")
2381
 
                                filename = "/tmp/swift"+str(pid)+"/"+filename.split("/")[-1].split(".")[0]+".png"
 
2384
                                Image.open(filename).save(os.environ["TEMP"]+sep+"swift"+str(pid)+"/"+f[0]+".png")
 
2385
                                filename = os.environ["TEMP"]+sep+"swift"+str(pid)+os.sep+filename.split(os.sep)[-1].split(".")[0]+".png"
2382
2386
                elif filetype=="sound":
2383
 
                        os.system("mplayer -nolirc '"+filename+"' -ao pcm:file='/tmp/swift"+str(pid)+"/"+f[0]+".wav' -vc dummy -aid 1 -vo null")
2384
 
                        filename = "/tmp/swift"+str(pid)+"/"+f[0]+".wav"
 
2387
                        mplayer_exe_name = 'mplayer' if os.sep == '/' else 'mplayer.exe'
 
2388
                        os.system(mplayer_exe_name+" -nolirc \""+filename+"\" -ao pcm:file='"+os.environ["TEMP"]+os.sep+"swift"+str(pid)+os.sep+f[0]+".wav' -vc dummy -aid 1 -vo null")
 
2389
                        filename = os.environ["TEMP"]+sep+"swift"+str(pid)+os.sep+f[0]+".wav"
2385
2390
                        
2386
2391
                        
2387
2392
                        
2744
2749
                global currentframe
2745
2750
                if currentframe[level] in currentfile["frames"][0]:
2746
2751
                        mode = "b"
2747
 
                        pixbuf = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/cursor_paintbucket.png")
 
2752
                        pixbuf = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"cursor_paintbucket.png")
2748
2753
                        display = gtk.gdk.display_get_default()
2749
2754
                        cursor = gtk.gdk.Cursor(display, pixbuf, 0, 0)
2750
2755
                        stage = self.builder.get_object("drawingarea1")
2755
2760
                print "KSJUFG"
2756
2761
                if currentframe[level] in currentfile["frames"][0]:
2757
2762
                        mode = "p"
2758
 
                        pixbuf = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/cursor_paintbrush.png")
 
2763
                        pixbuf = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"cursor_paintbrush.png")
2759
2764
                        display = gtk.gdk.display_get_default()
2760
2765
                        cursor = gtk.gdk.Cursor(display, pixbuf, 0, 0)
2761
2766
                        stage = self.builder.get_object("drawingarea1")
2765
2770
                global currentframe
2766
2771
                if currentframe[level] in currentfile["frames"][0]:
2767
2772
                        mode = "c"
2768
 
                        pixbuf = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/cursor_curve.png")
 
2773
                        pixbuf = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"cursor_curve.png")
2769
2774
                        display = gtk.gdk.display_get_default()
2770
2775
                        cursor = gtk.gdk.Cursor(display, pixbuf, 0, 0)
2771
2776
                        stage = self.builder.get_object("drawingarea1")
2774
2779
                global mode
2775
2780
                if currentframe[level] in currentfile["frames"][0]:
2776
2781
                        mode = "s"
2777
 
                        pixbuf = gtk.gdk.pixbuf_new_from_file("/usr/share/swift-swf/media/cursor_resize.png")
 
2782
                        pixbuf = gtk.gdk.pixbuf_new_from_file(getdatapath()+sep+"media"+sep+"cursor_resize.png")
2778
2783
                        display = gtk.gdk.display_get_default()
2779
2784
                        cursor = gtk.gdk.Cursor(display, pixbuf, 0, 0)
2780
2785
                        stage = self.builder.get_object("drawingarea1")
3181
3186
                for i in currentfile["objects"]:
3182
3187
                        ob = currentfile["objects"][i]  
3183
3188
                        if ob.type=="button":
3184
 
                                idlefile = open("/tmp/idlefile"+i+".png", "w")
3185
 
                                hoverfile = open("/tmp/hoverfile"+i+".png", "w")
3186
 
                                pressedfile = open("/tmp/pressedfile"+i+".png", "w")
3187
 
                                hitfile = open("/tmp/hitfile"+i+".png", "w")
 
3189
                                idlefile = open(os.environ["TEMP"]+sep+"idlefile"+i+".png", "w")
 
3190
                                hoverfile = open(os.environ["TEMP"]+sep+"hoverfile"+i+".png", "w")
 
3191
                                pressedfile = open(os.environ["TEMP"]+sep+"pressedfile"+i+".png", "w")
 
3192
                                hitfile = open(os.environ["TEMP"]+sep+"hitfile"+i+".png", "w")
3188
3193
                                idlesurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
3189
3194
                                hoversurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
3190
3195
                                pressedsurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
3231
3236
                                hoverfile.close()
3232
3237
                                pressedfile.close()
3233
3238
                                hitfile.close()
3234
 
                                output = output+".png idle"+i+" \"/tmp/idlefile"+i+".png\"\n"
3235
 
                                output = output+".png hover"+i+" \"/tmp/hoverfile"+i+".png\"\n"
3236
 
                                output = output+".png pressed"+i+" \"/tmp/pressedfile"+i+".png\"\n"
3237
 
                                output = output+".png hit"+i+" \"/tmp/hitfile"+i+".png\"\n"
 
3239
                                output = output+".png idle"+i+" \""+os.environ["TEMP"]+sep+"idlefile"+i+".png\"\n"
 
3240
                                output = output+".png hover"+i+" \""+os.environ["TEMP"]+sep+"hoverfile"+i+".png\"\n"
 
3241
                                output = output+".png pressed"+i+" \""+os.environ["TEMP"]+sep+"pressedfile"+i+".png\"\n"
 
3242
                                output = output+".png hit"+i+" \""+os.environ["TEMP"]+sep+"hitfile"+i+".png\"\n"
3238
3243
                                output = output+".button "+i+"\n.show idle"+i+" as=idle\n"+"\n.show hover"+i+" as=hover\n"+"\n.show pressed"+i+" as=pressed\n.show hit"+i+" as=area\n"+".end\n"
3239
3244
 
3240
3245
                        elif ob.type=="movieclip":
3281
3286
                fc.flush()
3282
3287
                fc.close()
3283
3288
                #os.system("swfc -o"+path+title+".swf "+path+title+".sct")
3284
 
                compile = subprocess.Popen("swfc -o "+path+title+".swf "+path+title+".sct", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
 
3289
                swfc_exe_name = 'swfc' if os.sep == '/' else 'swfc.exe'         
 
3290
                compile = subprocess.Popen(swfc_exe_name+" -o "+path+title+".swf "+path+title+".sct", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=(os.sep=="/"))
3285
3291
                stdino, stdouterro = (compile.stdin, compile.stdout)
3286
3292
                print stdouterro.read()
3287
3293
                os.system("rm "+path+title+".sct")
3835
3841
                for i in currentfile["objects"]:
3836
3842
                        ob = currentfile["objects"][i]  
3837
3843
                        if ob.type=="button":
3838
 
                                idlefile = open("/tmp/idlefile"+i+".png", "w")
3839
 
                                hoverfile = open("/tmp/hoverfile"+i+".png", "w")
3840
 
                                pressedfile = open("/tmp/pressedfile"+i+".png", "w")
3841
 
                                hitfile = open("/tmp/hitfile"+i+".png", "w")
 
3844
                                idlefile = open(os.environ["TEMP"]+sep+"idlefile"+i+".png", "w")
 
3845
                                hoverfile = open(os.environ["TEMP"]+sep+"hoverfile"+i+".png", "w")
 
3846
                                pressedfile = open(os.environ["TEMP"]+sep+"pressedfile"+i+".png", "w")
 
3847
                                hitfile = open(os.environ["TEMP"]+sep+"hitfile"+i+".png", "w")
3842
3848
                                idlesurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
3843
3849
                                hoversurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
3844
3850
                                pressedsurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, ob.width, ob.height)
3885
3891
                                hoverfile.close()
3886
3892
                                pressedfile.close()
3887
3893
                                hitfile.close()
3888
 
                                output = output+".png idle"+i+" \"/tmp/idlefile"+i+".png\"\n"
3889
 
                                output = output+".png hover"+i+" \"/tmp/hoverfile"+i+".png\"\n"
3890
 
                                output = output+".png pressed"+i+" \"/tmp/pressedfile"+i+".png\"\n"
3891
 
                                output = output+".png hit"+i+" \"/tmp/hitfile"+i+".png\"\n"
 
3894
                                output = output+".png idle"+i+" \""+os.environ["TEMP"]+sep+"idlefile"+i+".png\"\n"
 
3895
                                output = output+".png hover"+i+" \""+os.environ["TEMP"]+sep+"hoverfile"+i+".png\"\n"
 
3896
                                output = output+".png pressed"+i+" \""+os.environ["TEMP"]+sep+"pressedfile"+i+".png\"\n"
 
3897
                                output = output+".png hit"+i+" \""+os.environ["TEMP"]+sep+"hitfile"+i+".png\"\n"
3892
3898
                                output = output+".button "+i+"\n.show idle"+i+" as=idle\n"+"\n.show hover"+i+" as=hover\n"+"\n.show pressed"+i+" as=pressed\n.show hit"+i+" as=area\n"+".end\n"
3893
3899
 
3894
3900
                        elif ob.type=="movieclip":
4136
4142
        #look for the ui file that describes the ui
4137
4143
        ui_filename = os.path.join(getdatapath(), 'ui', 'SwiftSwfWindow.ui')  
4138
4144
        if not os.path.exists(ui_filename):
4139
 
                ui_filename = None
 
4145
                ui_filename = "C:\\trunk\\data\ui\\SwiftSwfWindow.ui"
4140
4146
 
4141
4147
        global scale
4142
4148
        global currentfile
4178
4184
        global lastinput
4179
4185
        global playing
4180
4186
        global sounds
 
4187
        global sep
4181
4188
        #specify the current version and what version files it can still open
4182
4189
        SWIFT_VERSION = "1.0-alpha4"
4183
4190
        SWIFT_COMPAT = ["1.0-alpha4"]
4211
4218
        e0 = ellipse("e0", 300, 100, "root", "turquoise")
4212
4219
        s0 = shape("s0", 300, 300, "root", "turquoise")
4213
4220
        s0.shapedata = [["M", 0, 0], ["L", 300, 0], ["L", 300, 300], ["C", 0, 300, 300, 0, 0, 0]]
4214
 
        currentfile = {"fileinfo":{"fps":25, "bbox":[500, 500, 0, 0]}, "colors":{"gradients":{"gr1":[[0.0, 0.0, 0.0, 1.0, 1], [0.5, 0.0, 1.0, 0.0, 1], [1.0, 1.0, 0.0, 0.0, 1]]}, "textures":{"t1":{"type":"gradient", "fill":"gr1"}, "t2":{"type":"image", "fill":"i1"}, "turquoise":{"type":"color", "fill":[0.0, 1.0, 1.0]}}, "images":{"i1":"/usr/share/swift-swf/media/icon.png"}}, "objects":{"b0":b0, "e0":e0, "s0":s0}, "sprites":{}, "buttons":{}, "sounds":{}, "actions":[""], "frames":[[0], {"sort":["s0", "b0", "e0"], "s0":{"put":True, "x":20, "y":20, "rotate":10, "xscale":1.0, "yscale":1.0}, "b0":{"put":True, "x":100, "y":100, "rotate":0, "xscale":1.0, "yscale":1.0}, "e0":{"put":True, "x":200, "y":300, "rotate":-0.5, "xscale":1.0, "yscale":1.0}, "sounds":[]}]}
 
4221
        currentfile = {"fileinfo":{"fps":25, "bbox":[500, 500, 0, 0]}, "colors":{"gradients":{"gr1":[[0.0, 0.0, 0.0, 1.0, 1], [0.5, 0.0, 1.0, 0.0, 1], [1.0, 1.0, 0.0, 0.0, 1]]}, "textures":{"t1":{"type":"gradient", "fill":"gr1"}, "t2":{"type":"image", "fill":"i1"}, "turquoise":{"type":"color", "fill":[0.0, 1.0, 1.0]}}, "images":{"i1":getdatapath()+sep+"media"+sep+"icon.png"}}, "objects":{"b0":b0, "e0":e0, "s0":s0}, "sprites":{}, "buttons":{}, "sounds":{}, "actions":[""], "frames":[[0], {"sort":["s0", "b0", "e0"], "s0":{"put":True, "x":20, "y":20, "rotate":10, "xscale":1.0, "yscale":1.0}, "b0":{"put":True, "x":100, "y":100, "rotate":0, "xscale":1.0, "yscale":1.0}, "e0":{"put":True, "x":200, "y":300, "rotate":-0.5, "xscale":1.0, "yscale":1.0}, "sounds":[]}]}
4215
4222
        objects = currentfile["objects"]
4216
4223
        objects["root"] = theoneroot
4217
4224
        objects["root"].frames = currentfile["frames"]
4218
4225
        objects["root"].actions = currentfile["actions"]
4219
4226
        currentselect = ["root", None]
4220
 
        path = "/home/"+os.getlogin()+"/Desktop/"
 
4227
        try:
 
4228
                path = os.environ["HOME"]+sep+"Desktop"+sep
 
4229
        except KeyError:
 
4230
                path = os.environ["HOMEPATH"]+sep+"Desktop"+sep
4221
4231
        title = "Untitled"
4222
4232
        clicked = False
4223
4233
        middleclick = False
4239
4249
        return window
4240
4250
 
4241
4251
if __name__ == "__main__":
 
4252
        if not "TEMP" in os.environ:
 
4253
                os.environ["TEMP"]="/tmp"
4242
4254
        global pid
 
4255
        global sep
4243
4256
        pid = os.getpid()
 
4257
        sep = os.sep
4244
4258
        TARGET_TYPE_URI_LIST = 80
4245
4259
        dnd_list = [ ( 'text/uri-list', 0, TARGET_TYPE_URI_LIST ) ]
4246
4260
        #support for command line options
4256
4270
                logging.debug('logging enabled')        
4257
4271
 
4258
4272
        #run the application
4259
 
        if not "currentfile" in os.listdir("/tmp"):
 
4273
        if not "currentfile" in os.listdir(os.environ["TEMP"]):
4260
4274
                window = NewSwiftSwfWindow()
4261
4275
                window.show()
4262
4276
        
4320
4334
                hadj.set_value(500)
4321
4335
                vadj = sw.get_vadjustment()
4322
4336
                vadj.set_value(500)
4323
 
                os.mkdir("/tmp/swift"+str(pid))
 
4337
                os.mkdir(os.environ["TEMP"]+sep+"swift"+str(pid))
4324
4338
                if len(args)>0:
4325
4339
                        patharray = args[0].split("/")
4326
4340
                        title = patharray.pop()
4330
4344
                        for i in patharray:
4331
4345
                                path = path+i+"/"
4332
4346
                        try:
4333
 
                                ren = "/tmp/"+title+".tar.gz"
 
4347
                                ren = os.environ["TEMP"]+sep+""+title+".tar.gz"
4334
4348
                                shutil.copyfile(args[0], ren)
4335
4349
                                tar = tarfile.open(ren, 'r:gz')
4336
4350
                                for item in tar:
4337
 
                                        tar.extract(item, "/tmp/swift"+str(pid))
 
4351
                                        tar.extract(item, os.environ["TEMP"]+sep+"swift"+str(pid))
4338
4352
                                os.system ("rm "+ren)
4339
4353
                        except:
4340
4354
                                print "Error opening file."
4341
4355
                                alert("Error opening file!", True)
4342
 
                        fc = open("/tmp/swift"+str(pid)+"/currentfile", "r")
 
4356
                        fc = open(os.environ["TEMP"]+sep+"swift"+str(pid)+"/currentfile", "r")
4343
4357
                        currentfilebase = []
4344
4358
                        for i in fc:
4345
4359
                                currentfilebase.append(i)
4352
4366
                                currentfile["objects"][obtemp.name] = obtemp
4353
4367
                        currentselect = ["root", None]
4354
4368
                        for i in currentfile["colors"]["images"]:
4355
 
                                currentfile["colors"]["images"][i] = "/tmp/swift"+str(pid)+"/"+currentfile["colors"]["images"][i]
 
4369
                                currentfile["colors"]["images"][i] = os.environ["TEMP"]+sep+"swift"+str(pid)+"/"+currentfile["colors"]["images"][i]
4356
4370
                        level = 0
4357
4371
                        fc.close()
4358
4372
                        window.set_title("Swift - "+title+".swift")