985
986
global currentframe
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):
1026
1027
source_id = gobject.timeout_add(100, exposeframevent, framewin, "animation-event", step+1)
1027
1028
def exposobjevent(objwin, event):
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)
1964
1965
for i in patharray:
1965
1966
path = path+i+"/"
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)
1974
1975
print "Error opening file."
1975
1976
alert("Error opening file!")
1976
1977
opener.destroy()
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 = []
1981
1982
currentfilebase.append(i)
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"
2238
2241
elif ob.type=="movieclip":
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"
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"
3240
3245
elif ob.type=="movieclip":
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"
3894
3900
elif ob.type=="movieclip":
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/"
4228
path = os.environ["HOME"]+sep+"Desktop"+sep
4230
path = os.environ["HOMEPATH"]+sep+"Desktop"+sep
4221
4231
title = "Untitled"
4222
4232
clicked = False
4223
4233
middleclick = False
4330
4344
for i in patharray:
4331
4345
path = path+i+"/"
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)
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 = []
4345
4359
currentfilebase.append(i)