====== Differences ====== This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
script_scrollanimation [2014/12/20 11:48] lm13 created |
script_scrollanimation [2016/06/28 12:16] (current) f43nd1r |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== About the script ====== | ====== About the script ====== | ||
* Purpose : This script gives you a collection of beautiful Scrollanimations | * Purpose : This script gives you a collection of beautiful Scrollanimations | ||
- | * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | + | * Author : F43nd1r |
* Current Version : 1.4 | * Current Version : 1.4 | ||
- | * Download avialable! (Check repository) | + | * Download available! (Check repository) |
+ | * Link (with video): https://plus.google.com/115366157037831519359/posts/csLe66N4FZ7 | ||
**Note: This script may not work out of the box. It is recommended to use it only within the context of the APK** | **Note: This script may not work out of the box. It is recommended to use it only within the context of the APK** | ||
+ | |||
+ | ====== Code ======= | ||
+ | <spoiler |Setup Script> | ||
+ | <sxh javascript;> | ||
+ | LL.bindClass("android.app.AlertDialog"); | ||
+ | LL.bindClass("android.content.DialogInterface"); | ||
+ | LL.bindClass("android.view.View"); | ||
+ | LL.bindClass("android.widget.ListView"); | ||
+ | LL.bindClass("android.widget.LinearLayout"); | ||
+ | LL.bindClass("android.widget.CheckBox"); | ||
+ | LL.bindClass("android.widget.RadioGroup"); | ||
+ | LL.bindClass("android.widget.RadioButton"); | ||
+ | LL.bindClass("android.widget.SimpleAdapter"); | ||
+ | LL.bindClass("android.widget.AdapterView"); | ||
+ | LL.bindClass("android.widget.TextView"); | ||
+ | LL.bindClass("android.widget.ScrollView"); | ||
+ | LL.bindClass("android.os.Environment"); | ||
+ | LL.bindClass("android.R"); | ||
+ | LL.bindClass("java.util.HashMap"); | ||
+ | LL.bindClass("java.util.ArrayList"); | ||
+ | LL.bindClass("java.io.FileOutputStream"); | ||
+ | LL.bindClass("java.io.ObjectOutputStream"); | ||
+ | LL.bindClass("java.io.FileInputStream"); | ||
+ | LL.bindClass("java.io.ObjectInputStream"); | ||
+ | LL.bindClass("java.io.File"); | ||
+ | LL.bindClass("java.lang.reflect.Array"); | ||
+ | LL.bindClass("java.lang.Class"); | ||
+ | |||
+ | var MY_PKG="net.pierrox.lightning_launcher.llscript.animations"; | ||
+ | // install (or update) a script given its id in the package, and its clear name in the launcher data | ||
+ | function installScript(id,name){ | ||
+ | // load the script (if any) among the existing ones | ||
+ | var script=LL.getScriptByName(name); | ||
+ | |||
+ | var script_text=LL.loadRawResource(MY_PKG,id); | ||
+ | |||
+ | if(script==null){ | ||
+ | // script not found: install it | ||
+ | script=LL.createScript(name,script_text,0); | ||
+ | }else{ | ||
+ | // the script already exists: update its text | ||
+ | script.setText(script_text); | ||
+ | } | ||
+ | |||
+ | return script; | ||
+ | } | ||
+ | |||
+ | |||
+ | var title="Install Animations"; | ||
+ | var animations=new HashMap(); | ||
+ | animations.put("Bulldoze","FREE"); | ||
+ | animations.put("CardStyle","ONE"); | ||
+ | animations.put("Flip","BOTH"); | ||
+ | animations.put("In and Out","BOTH"); | ||
+ | animations.put("Shrink","BOTH"); | ||
+ | animations.put("Turn","ONE"); | ||
+ | animations.put("ZigZag","ONE"); | ||
+ | var items=[]; | ||
+ | var it=animations.keySet().iterator(); | ||
+ | while(it.hasNext()) | ||
+ | { | ||
+ | items.push(it.next()); | ||
+ | } | ||
+ | items.sort(); | ||
+ | var checked=[]; | ||
+ | for(var a=0;a<items.length;a++)checked.push(false); | ||
+ | |||
+ | function result(checkedAnimations,checkedScroll,checkedLoop) | ||
+ | { | ||
+ | var prop=c.getProperties(); | ||
+ | var cont=new HashMap(); | ||
+ | cont.put("noScrollLimit",prop.getBoolean("noScrollLimit")); | ||
+ | cont.put("pageLoop",checkedLoop); | ||
+ | cont.put("setup",false); | ||
+ | cont.put("animations",checkedAnimations); | ||
+ | cont.put("animation",checkedAnimations[0]); | ||
+ | cont.put("scrollMode",checkedScroll); | ||
+ | saveToFile(cont); | ||
+ | var editor=prop.edit(); | ||
+ | editor.setBoolean("allowDualPosition",false); | ||
+ | editor.setBoolean("noScrollLimit",cont.get("pageLoop")); | ||
+ | var script=installScript("animation","Animation"); | ||
+ | editor.setEventHandler("posChanged",EventHandler.RUN_SCRIPT,script.getId()); | ||
+ | editor.setBoolean("noDiagonalScrolling",checkedScroll!=2); | ||
+ | editor.commit(); | ||
+ | script.setTag("runSetup"); | ||
+ | LL.runScript(script.getName(),null); | ||
+ | } | ||
+ | |||
+ | var c=LL.getEvent().getContainer(); | ||
+ | try | ||
+ | { | ||
+ | var old=loadFromFile(); | ||
+ | if(old!=null && old.get("setup")) | ||
+ | { | ||
+ | var oldScript=LL.getScriptById(c.getProperties().getEventHandler("posChanged").getData()); | ||
+ | LL.runScript(oldScript.getName(),null); | ||
+ | } | ||
+ | } | ||
+ | catch(Exception) | ||
+ | { | ||
+ | LL.writeToLogFile("\nAniamtion Setup: Failed to load old Data"+LL.getEvent().getDate()+"\n",true); | ||
+ | } | ||
+ | |||
+ | |||
+ | var builder=new AlertDialog.Builder(LL.getContext()); | ||
+ | var linearView=new LinearLayout(LL.getContext()); | ||
+ | linearView.setOrientation(LinearLayout.VERTICAL); | ||
+ | linearView.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); | ||
+ | linearView.setDividerDrawable(LL.getContext().getResources().getDrawable(R.drawable.divider_horizontal_dim_dark)); | ||
+ | var listView=new ListView(LL.getContext()); | ||
+ | var arrayList=new ArrayList(); | ||
+ | var strings=[]; | ||
+ | var ids=[]; | ||
+ | for(i in items) | ||
+ | { | ||
+ | var map=new HashMap(); | ||
+ | map.put("root",items[i]); | ||
+ | arrayList.add(map); | ||
+ | } | ||
+ | var listAdapter=new SimpleAdapter(LL.getContext(),arrayList,R.layout.simple_list_item_multiple_choice,["root"],[R.id.text1]); | ||
+ | listView.setAdapter(listAdapter); | ||
+ | var l=new AdapterView.OnItemClickListener() | ||
+ | { | ||
+ | onItemClick:function(parent,view,position,id) | ||
+ | { | ||
+ | if(!view.isEnabled())parent.setItemChecked(position,false); | ||
+ | } | ||
+ | } | ||
+ | listView.setOnItemClickListener(l); | ||
+ | listView.setChoiceMode(listView.CHOICE_MODE_MULTIPLE); | ||
+ | listView.measure(View.MeasureSpec.UNSPECIFIED,View.MeasureSpec.UNSPECIFIED); | ||
+ | var params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,listView.getMeasuredHeight()*listAdapter.getCount()); | ||
+ | listView.setLayoutParams(params); | ||
+ | /*listView.setOnTouchListener(new View.OnTouchListener() | ||
+ | { | ||
+ | onTouch:function(view,touch) | ||
+ | { | ||
+ | return true; | ||
+ | } | ||
+ | });*/ | ||
+ | var loopCheck=new CheckBox(LL.getContext()); | ||
+ | loopCheck.setText("Infinite Page Loop"); | ||
+ | var radios=new RadioGroup(LL.getContext()); | ||
+ | var r1=new RadioButton(LL.getContext()); | ||
+ | var r2=new RadioButton(LL.getContext()); | ||
+ | var r3=new RadioButton(LL.getContext()); | ||
+ | r1.setText("Only horizontal scrolling"); | ||
+ | r2.setText("Horizontal and vertical scrolling"); | ||
+ | r3.setText("Free scrolling"); | ||
+ | radios.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){onCheckedChanged:function(dialog,id){ | ||
+ | switch(id) | ||
+ | { | ||
+ | case r1.getId(): | ||
+ | for(var a=0;a<listView.getChildCount();a++) | ||
+ | { | ||
+ | var child=listView.getChildAt(a); | ||
+ | if(!child.isEnabled())child.setEnabled(true); | ||
+ | } | ||
+ | break; | ||
+ | case r2.getId(): | ||
+ | for(var a=0;a<listView.getChildCount();a++) | ||
+ | { | ||
+ | var child=listView.getChildAt(a); | ||
+ | var b=(animations.get(child.getText())!="ONE"); | ||
+ | if(child.isEnabled()!=b)child.setEnabled(b); | ||
+ | if(!b)listView.setItemChecked(a,false); | ||
+ | } | ||
+ | break; | ||
+ | case r3.getId(): | ||
+ | for(var a=0;a<listView.getChildCount();a++) | ||
+ | { | ||
+ | var child=listView.getChildAt(a); | ||
+ | var b=(animations.get(child.getText())=="FREE"); | ||
+ | if(child.isEnabled()!=b)child.setEnabled(b); | ||
+ | if(!b)listView.setItemChecked(a,false); | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | return true; | ||
+ | } | ||
+ | }); | ||
+ | radios.addView(r1); | ||
+ | radios.addView(r2); | ||
+ | radios.addView(r3); | ||
+ | radios.check(r1.getId()); | ||
+ | var text=new TextView(LL.getContext()); | ||
+ | text.setText(" Hints:\n • Rotated and 1-Directional pinned Items are not supported and may cause unexpected behaviour\n • If you want to, you can toggle the animation by running the Script from anywhere"); | ||
+ | linearView.addView(text); | ||
+ | linearView.addView(loopCheck); | ||
+ | linearView.addView(radios); | ||
+ | linearView.addView(listView); | ||
+ | var rootView=new ScrollView(LL.getContext()); | ||
+ | rootView.addView(linearView); | ||
+ | builder.setView(rootView); | ||
+ | builder.setCancelable(true); | ||
+ | builder.setTitle(title); | ||
+ | builder.setNegativeButton("Cancel",new DialogInterface.OnClickListener(){onClick:function(dialog,id){dialog.cancel();}});//it has a Cancel Button | ||
+ | builder.setPositiveButton("Confirm",new DialogInterface.OnClickListener() | ||
+ | { | ||
+ | onClick:function(dialog,id) | ||
+ | { | ||
+ | var checkedItemsSparse=listView.getCheckedItemPositions(); | ||
+ | var checkedItems=[]; | ||
+ | for(var a=0;a<checkedItemsSparse.size();a++) | ||
+ | { | ||
+ | if(checkedItemsSparse.valueAt(a))checkedItems[a]=parseInt(checkedItemsSparse.keyAt(a)); | ||
+ | } | ||
+ | if(checkedItems.length==0) | ||
+ | { | ||
+ | Android.makeNewToast("You haven't selected any animation.\n Exit without load.",true).show(); | ||
+ | return; | ||
+ | } | ||
+ | var checkedRadioId=radios.getCheckedRadioButtonId(); | ||
+ | var checkedRadio=-1; | ||
+ | if(r1.getId()==checkedRadioId)checkedRadio=0; | ||
+ | else if(r2.getId()==checkedRadioId)checkedRadio=1; | ||
+ | else if(r3.getId()==checkedRadioId)checkedRadio=2; | ||
+ | setTimeout(function() | ||
+ | { | ||
+ | result(checkedItems,checkedRadio,loopCheck.isChecked()); | ||
+ | },0); | ||
+ | } | ||
+ | }); | ||
+ | var dialog=builder.create(); | ||
+ | dialog.setOnShowListener(new DialogInterface.OnShowListener(){ | ||
+ | onShow:function(){ | ||
+ | rootView.scrollTo(0,0); | ||
+ | } | ||
+ | }); | ||
+ | dialog.show(); | ||
+ | |||
+ | |||
+ | |||
+ | function saveToFile(data) | ||
+ | { | ||
+ | var dir=new File(Environment.getExternalStorageDirectory()+File.separator+"LightningLauncher"+File.separator+"Scripts"+File.separator+"data"+File.separator+c.getId()+File.separator); | ||
+ | dir.mkdirs(); | ||
+ | var file=new File(dir+File.separator+"animationContent"); | ||
+ | file.createNewFile(); | ||
+ | out=new ObjectOutputStream(new FileOutputStream(file)); | ||
+ | out.writeObject(data); | ||
+ | out.flush(); | ||
+ | out.close(); | ||
+ | } | ||
+ | |||
+ | function loadFromFile() | ||
+ | { | ||
+ | var dir=new File(Environment.getExternalStorageDirectory()+File.separator+"LightningLauncher"+File.separator+"Scripts"+File.separator+"data"+File.separator+c.getId()+File.separator); | ||
+ | var file=new File(dir+File.separator+"animationContent"); | ||
+ | if(!file.exists()||!file.canRead())return null; | ||
+ | is=new ObjectInputStream(new FileInputStream(file)); | ||
+ | try | ||
+ | { | ||
+ | var data=is.readObject(); | ||
+ | is.close(); | ||
+ | return data; | ||
+ | } | ||
+ | catch(IOException) | ||
+ | { | ||
+ | return null; | ||
+ | } | ||
+ | } | ||
+ | </sxh></spoiler> | ||
+ | |||
+ | <spoiler |Animation Script> | ||
+ | <sxh javascript;> | ||
+ | LL.bindClass("java.util.HashMap"); | ||
+ | LL.bindClass("java.io.FileOutputStream"); | ||
+ | LL.bindClass("java.io.ObjectOutputStream"); | ||
+ | LL.bindClass("java.io.FileInputStream"); | ||
+ | LL.bindClass("java.io.ObjectInputStream"); | ||
+ | LL.bindClass("java.io.File"); | ||
+ | LL.bindClass("android.os.Environment"); | ||
+ | LL.bindClass("java.lang.IllegalArgumentException"); | ||
+ | |||
+ | |||
+ | function setupPages() | ||
+ | { | ||
+ | var items=c.getItems(); | ||
+ | cont.put("pages",new HashMap()); | ||
+ | cont.put("all",[]); | ||
+ | for(var x=0;x<items.length;x++) | ||
+ | { | ||
+ | loadItem(items.getAt(x)); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function checkItem(x,y,z) | ||
+ | { | ||
+ | var page=cont.get("pages").get(asOne(x,y)); | ||
+ | var item=LL.getItemById(page[z][0]); | ||
+ | if(item==null) | ||
+ | { | ||
+ | cont.get("all").splice(cont.get("all").indexOf(page[z][0]),1); | ||
+ | page.splice(z,1); | ||
+ | loadBorders(); | ||
+ | saveToFile(); | ||
+ | return false; | ||
+ | } | ||
+ | if(Math.abs(item.getPositionX()-page[z][7])>5||Math.abs(item.getPositionY()-page[z][8])>5) | ||
+ | { | ||
+ | var posX=item.getPositionX(); | ||
+ | var posY=item.getPositionY(); | ||
+ | var rot=item.getRotation(); | ||
+ | var scaleX=item.getScaleX(); | ||
+ | var scaleY=item.getScaleY(); | ||
+ | var onGrid=page[z][6]; | ||
+ | var newX=Math.floor(posX/dWidth); | ||
+ | var newY=Math.floor(posY/dHeight); | ||
+ | var newPage=asOne(newX,newY); | ||
+ | if(newPage!=asOne(x,y)) | ||
+ | { | ||
+ | page.splice(z,1); | ||
+ | if(cont.get("pages").get(newPage)==null)cont.get("pages").put(newPage,[]); | ||
+ | cont.get("pages").get(newPage).push([item.getId(),posX,posY,rot,scaleX,scaleY,onGrid,posX,posY]); | ||
+ | loadBorders(); | ||
+ | saveToFile(); | ||
+ | return false; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | page[z]=[item.getId(),posX,posY,rot,scaleX,scaleY,onGrid,posX,posY]; | ||
+ | } | ||
+ | } | ||
+ | return true; | ||
+ | } | ||
+ | |||
+ | function loadNewItems() | ||
+ | { | ||
+ | for(var x=0;x<items.length;x++) | ||
+ | { | ||
+ | var item=items.getAt(x); | ||
+ | if(cont.get("all").indexOf(item.getId())==-1) | ||
+ | loadItem(item); | ||
+ | } | ||
+ | loadBorders(); | ||
+ | saveToFile(); | ||
+ | } | ||
+ | |||
+ | function loadItem(item) | ||
+ | { | ||
+ | var pinned=item.getProperties().getString("i.pinMode"); | ||
+ | if(pinned=="NONE") | ||
+ | { | ||
+ | //index 0: id | ||
+ | var posX=item.getPositionX();//index1 | ||
+ | var posY=item.getPositionY();//index2 | ||
+ | var rot=item.getRotation();//index3 | ||
+ | var scaleX=item.getScaleX();//index4 | ||
+ | var scaleY=item.getScaleY();//index5 | ||
+ | var onGrid=item.getProperties().getBoolean("i.onGrid");//index 6 | ||
+ | var page=asOne(Math.floor(posX/dWidth),Math.floor(posY/dHeight)); | ||
+ | if(cont.get("pages").get(page)==null)cont.get("pages").put(page,[]); | ||
+ | cont.get("pages").get(page).push([item.getId(),posX,posY,rot,scaleX,scaleY,onGrid,posX,posY]); | ||
+ | item.getProperties().edit().setBoolean("i.onGrid",false).commit(); | ||
+ | LL.save(); | ||
+ | } | ||
+ | cont.get("all").push(item.getId()); | ||
+ | } | ||
+ | |||
+ | function loadBorders() | ||
+ | { | ||
+ | if(!cont.get("stateX")&&!cont.get("stateY")) | ||
+ | { | ||
+ | if(!saved) | ||
+ | { | ||
+ | LL.save(); | ||
+ | saved=true; | ||
+ | } | ||
+ | var box=c.getBoundingBox(); | ||
+ | cont.put("minX",box.getLeft()); | ||
+ | cont.put("maxX",box.getRight()); | ||
+ | cont.put("minY",box.getTop()); | ||
+ | cont.put("maxY",box.getBottom()); | ||
+ | var maxPageX=Math.floor((cont.get("maxX")-dWidth)/dWidth); | ||
+ | var maxPageY=Math.floor((cont.get("maxY")-dHeight)/dHeight); | ||
+ | var minPageX=Math.floor(cont.get("minX")/dWidth); | ||
+ | var minPageY=Math.floor(cont.get("minY")/dHeight); | ||
+ | if(maxPageY==minPageY||cont.get("scrollMode")==0) | ||
+ | { | ||
+ | c.getProperties().edit().setString("scrollingDirection","X").commit(); | ||
+ | c.setPosition(c.getPositionX(),minPageY*dHeight,1,false); | ||
+ | } | ||
+ | else if(maxPageX==minPageX) | ||
+ | { | ||
+ | c.getProperties().edit().setString("scrollingDirection","Y").commit(); | ||
+ | c.setPosition(minPageX*dWidth,c.getPositionY(),1,false); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | c.getProperties().edit().setString("scrollingDirection","AUTO").commit(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function randInt(max) | ||
+ | { | ||
+ | return Math.floor(Math.random()*max); | ||
+ | } | ||
+ | |||
+ | function saveToFile() | ||
+ | { | ||
+ | var dir=new File(Environment.getExternalStorageDirectory()+File.separator+"LightningLauncher"+File.separator+"Scripts"+File.separator+"data"+File.separator+c.getId()+File.separator); | ||
+ | dir.mkdirs(); | ||
+ | var file=new File(dir+File.separator+"animationContent"); | ||
+ | file.createNewFile(); | ||
+ | out=new ObjectOutputStream(new FileOutputStream(file)); | ||
+ | out.writeObject(cont); | ||
+ | out.flush(); | ||
+ | out.close(); | ||
+ | } | ||
+ | |||
+ | function loadFromFile() | ||
+ | { | ||
+ | var dir=new File(Environment.getExternalStorageDirectory()+File.separator+"LightningLauncher"+File.separator+"Scripts"+File.separator+"data"+File.separator+c.getId()+File.separator); | ||
+ | var file=new File(dir+File.separator+"animationContent"); | ||
+ | if(!file.exists()||!file.canRead())throw new IllegalArgumentException("File "+file+" does not exist or is not readable"); | ||
+ | is=new ObjectInputStream(new FileInputStream(file)); | ||
+ | cont=is.readObject(); | ||
+ | is.close(); | ||
+ | } | ||
+ | |||
+ | function asOne(a,b) | ||
+ | { | ||
+ | return a*10000+b; | ||
+ | } | ||
+ | |||
+ | function asTwo(i) | ||
+ | { | ||
+ | var a=Math.round(i/10000); | ||
+ | var b=i-a*10000; | ||
+ | return [a,b]; | ||
+ | } | ||
+ | |||
+ | function center(item,r) | ||
+ | { | ||
+ | r=r*Math.PI/180; | ||
+ | var sin=Math.abs(Math.sin(r)); | ||
+ | var cos=Math.abs(Math.cos(r)); | ||
+ | var w=item.getWidth()*item.getScaleX(); | ||
+ | var h=item.getHeight()*item.getScaleY(); | ||
+ | return [(w*cos+h*sin)*0.5,(h*cos+w*sin)*0.5]; | ||
+ | } | ||
+ | |||
+ | var e=LL.getEvent(); | ||
+ | var c=e.getContainer(); | ||
+ | var items=c.getItems(); | ||
+ | var dWidth=c.getWidth(); | ||
+ | var dHeight=c.getHeight(); | ||
+ | var saved=false; | ||
+ | |||
+ | var getPossible; | ||
+ | try | ||
+ | { | ||
+ | cont.get("active"); | ||
+ | getPossible=true; | ||
+ | } | ||
+ | catch(Exception) | ||
+ | { | ||
+ | getPossible=false; | ||
+ | } | ||
+ | if(!getPossible||cont.get("active")!=c.getId()||LL.getCurrentScript().getTag()=="runSetup") | ||
+ | { | ||
+ | loadFromFile(); | ||
+ | cont.put("active",c.getId()); | ||
+ | } | ||
+ | |||
+ | if(e.getSource()!="C_POSITION_CHANGED") | ||
+ | { | ||
+ | LL.getCurrentScript().setTag(null); | ||
+ | loadBorders(); | ||
+ | jumped=false; | ||
+ | var minPageX=Math.floor(cont.get("minX")/dWidth); | ||
+ | var minPageY=Math.floor(cont.get("minY")/dHeight); | ||
+ | if(!cont.get("setup")) | ||
+ | { | ||
+ | setupPages(); | ||
+ | c.getProperties().edit().setBoolean("noScrollLimit",cont.get("pageLoop")||false).commit(); | ||
+ | cont.put("setup",true); | ||
+ | Android.makeNewToast("Animation enabled",true).show(); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | var cellWidth=c.getCellWidth(); | ||
+ | var cellHeight=c.getCellHeight(); | ||
+ | var pages=cont.get("pages").keySet().iterator(); | ||
+ | while(pages.hasNext()) | ||
+ | { | ||
+ | var page=pages.next(); | ||
+ | var two=asTwo(page); | ||
+ | var x=two[0]; | ||
+ | var y=two[1]; | ||
+ | for(var z=0;z<cont.get("pages").get(page).length;z++) | ||
+ | { | ||
+ | var data=cont.get("pages").get(page)[z]; | ||
+ | var i=LL.getItemById(data[0]); | ||
+ | if(i==null) | ||
+ | { | ||
+ | cont.get("pages").get(page).splice(z,1); | ||
+ | cont.get("all").splice(cont.all.indexOf(data[0]),1); | ||
+ | continue; | ||
+ | } | ||
+ | i.setScale(data[4],data[5]); | ||
+ | if(data[6]) | ||
+ | { | ||
+ | iWidth=i.getWidth(); | ||
+ | iHeight=i.getHeight(); | ||
+ | i.getProperties().edit().setBoolean("i.onGrid",true).commit(); | ||
+ | LL.save(); | ||
+ | //i.setCell(Math.round(data[1]/cellWidth),Math.round(data[2]/cellHeight),Math.round((data[1]+iWidth)/cellWidth),Math.round((data[2]+iHeight)/cellHeight)); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | cont.put("setup",false); | ||
+ | c.getProperties().edit().setBoolean("noScrollLimit",cont.get("noScrollLimit")).commit(); | ||
+ | Android.makeNewToast("Animation disabled",true).show(); | ||
+ | LL.save(); | ||
+ | } | ||
+ | saveToFile(); | ||
+ | } | ||
+ | |||
+ | |||
+ | if(cont==null||!cont.get("setup")||c.getPositionScale()!=1)return; | ||
+ | var dPosX=c.getPositionX(); | ||
+ | var dPosY=c.getPositionY(); | ||
+ | var currentX=Math.floor(dPosX/dWidth); | ||
+ | var pagePosX=currentX*dWidth; | ||
+ | var percentX=(dPosX-pagePosX)/dWidth; | ||
+ | var currentY=Math.floor(dPosY/dHeight); | ||
+ | var pagePosY=currentY*dHeight; | ||
+ | var percentY=(dPosY-pagePosY)/dHeight; | ||
+ | var maxPageX=Math.floor((cont.get("maxX")-dWidth)/dWidth); | ||
+ | var maxPageY=Math.floor((cont.get("maxY")-dHeight)/dHeight); | ||
+ | var minPageX=Math.floor(cont.get("minX")/dWidth); | ||
+ | var minPageY=Math.floor(cont.get("minY")/dHeight); | ||
+ | var percent=(Math.abs(0.5-percentX)<Math.abs(0.5-percentY))?percentX:percentY; | ||
+ | |||
+ | if(items.length>cont.get("all").length) | ||
+ | { | ||
+ | loadNewItems(); | ||
+ | } | ||
+ | |||
+ | if(percent>0.005&&percent<99.995&&dPosX>cont.get("minX")-dWidth&&dPosY>cont.get("minY")-dHeight) | ||
+ | { | ||
+ | jumped=false; | ||
+ | var scrollLimit=cont.get("pageLoop"); | ||
+ | if(dPosX>cont.get("maxX")-dWidth&&scrollLimit) | ||
+ | { | ||
+ | dPosX=cont.get("minX")-(dWidth*0.99); | ||
+ | c.setPosition(dPosX,dPosY,1,false); | ||
+ | jumped=true; | ||
+ | return; | ||
+ | } | ||
+ | else if(dPosY>cont.get("maxY")-dHeight&&scrollLimit) | ||
+ | { | ||
+ | dPosY=cont.get("minY")-(dHeight*0.99); | ||
+ | c.setPosition(dPosX,dPosY,1,false); | ||
+ | jumped=true; | ||
+ | return; | ||
+ | } | ||
+ | if(dPosX<cont.get("minX")&&scrollLimit) | ||
+ | cont.put("stateX",true); | ||
+ | if(dPosY<cont.get("minY")&&scrollLimit) | ||
+ | cont.put("stateY",true); | ||
+ | |||
+ | switch(parseInt(cont.get("animation"))) | ||
+ | { | ||
+ | case 0: | ||
+ | bulldoze(); | ||
+ | break; | ||
+ | case 1: | ||
+ | cardStyle(); | ||
+ | break; | ||
+ | case 2: | ||
+ | flip(); | ||
+ | break; | ||
+ | case 3: | ||
+ | inAndOut(); | ||
+ | break; | ||
+ | case 4: | ||
+ | shrink(); | ||
+ | break; | ||
+ | case 5: | ||
+ | turn(); | ||
+ | break; | ||
+ | case 6: | ||
+ | zigZag(); | ||
+ | break; | ||
+ | default: | ||
+ | alert("Internal Error: Illegal animation selection: "+cont.get("animation")); | ||
+ | } | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | c.setPosition(dPosX,dPosY); | ||
+ | if(!jumped) | ||
+ | { | ||
+ | c.setPosition(dPosX<cont.get("minX")-(dWidth*0.99)?cont.get("maxX")-dWidth:dPosX,dPosY<cont.get("minY")-(dHeight*0.99)?cont.get("maxY")-dHeight:dPosY,1,false); | ||
+ | } | ||
+ | cont.put("stateX",false); | ||
+ | cont.put("stateY",false); | ||
+ | var pages=cont.get("pages").keySet().iterator(); | ||
+ | while(pages.hasNext()) | ||
+ | { | ||
+ | var page=pages.next(); | ||
+ | var two=asTwo(page); | ||
+ | var x=two[0]; | ||
+ | var y=two[1]; | ||
+ | for(var z=cont.get("pages").get(page).length-1;z>=0;z--) | ||
+ | { | ||
+ | var data=cont.get("pages").get(page)[z]; | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | item.setRotation(data[3]); | ||
+ | item.setScale(data[4],data[5]); | ||
+ | item.setPosition(data[1],data[2]); | ||
+ | cont.get("pages").get(page)[z][7]=data[1]; | ||
+ | cont.get("pages").get(page)[z][8]=data[2]; | ||
+ | item.getProperties().edit().setInteger("i.alpha",255).commit(); | ||
+ | item.setVisibility(true); | ||
+ | } | ||
+ | } | ||
+ | var sel=randInt(cont.get("animations").length); | ||
+ | cont.put("animation",cont.get("animations")[sel]); | ||
+ | saveToFile(); | ||
+ | } | ||
+ | |||
+ | function inAndOut() | ||
+ | { | ||
+ | if(percentX==percent) | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items0=cont.get("pages").get(page); | ||
+ | if(items0!=null) | ||
+ | { | ||
+ | for(var z=0;z<items0.length;z++) | ||
+ | { | ||
+ | var data=items0[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((1-percent*0.75)*data[4],(1-percent*0.75)*data[5]); | ||
+ | item.setPosition((pagePosX+(data[1]%dWidth+dWidth)%dWidth)+(dWidth-((data[1]%dWidth+dWidth)%dWidth))*percent*0.75,data[2]+(dHeight-((data[2]%dHeight+dHeight)%dHeight)*2)*percent*0.325); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=currentX+1; | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percent*0.75+0.25)*data[4],(percent*0.75+0.25)*data[5]); | ||
+ | item.setPosition(pagePosX+dWidth+((data[1]%dWidth+dWidth)%dWidth)*(percent*0.75+0.25),data[2]+(dHeight-((data[2]%dHeight+dHeight)%dHeight)*2)*(0.325-percent*0.325)); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items0=cont.get("pages").get(page) | ||
+ | if(items0!=null) | ||
+ | { | ||
+ | for(var z=0;z<items0.length;z++) | ||
+ | { | ||
+ | var data=items0[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((1-percent*0.75)*data[4],(1-percent*0.75)*data[5]); | ||
+ | item.setPosition(data[1]+(dWidth-((data[1]%dWidth+dWidth)%dWidth)*2)*(percent*0.325),pagePosY+((data[2]%dHeight+dHeight)%dHeight)+(dHeight-((data[2]%dHeight+dHeight)%dHeight))*(percent*0.75)); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=cont.get("stateX")?maxPageX:currentX; | ||
+ | var y=currentY+1; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percent*0.75+0.25)*data[4],(percent*0.75+0.25)*data[5]); | ||
+ | item.setPosition(data[1]+(dWidth-((data[1]%dWidth+dWidth)%dWidth)*2)*(0.325-percent*0.325),pagePosY+dHeight+((data[2]%dHeight+dHeight)%dHeight)*(0.75*percent+0.25)); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function bulldoze() | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((1-percentX)*data[4],(1-percentY)*data[5]); | ||
+ | item.setPosition(dPosX+((data[1]%dWidth+dWidth)%dWidth)*(1-percentX),dPosY+((data[2]%dHeight+dHeight)%dHeight)*(1-percentY)); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=currentX+1; | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percentX>0.005?percentX:1)*data[4],(1-percentY)*data[5]); | ||
+ | item.setPosition(dPosX+dWidth-(dWidth-(data[1]%dWidth+dWidth)%dWidth)*percentX,dPosY+((data[2]%dHeight+dHeight)%dHeight)*(1-percentY)); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=currentY+1; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((1-percentX)*data[4],(percentY>0.005?percentY:1)*data[5]); | ||
+ | item.setPosition(dPosX+((data[1]%dWidth+dWidth)%dWidth)*(1-percentX),dPosY+dHeight-(dHeight-(data[2]%dHeight+dHeight)%dHeight)*percentY); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=currentX+1; | ||
+ | var y=currentY+1; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percentX>0.005?percentX:1)*data[4],(percentY>0.005?percentY:1)*data[5]); | ||
+ | item.setPosition(dPosX+dWidth-(dWidth-(data[1]%dWidth+dWidth)%dWidth)*percentX,dPosY+dHeight-(dHeight-(data[2]%dHeight+dHeight)%dHeight)*percentY); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function cardStyle() | ||
+ | { | ||
+ | var zOrder=cont.get("all").length; | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=minPageY; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale(data[4],data[5]); | ||
+ | item.setPosition(pagePosX+(data[1]%dWidth+dWidth)%dWidth,data[2]); | ||
+ | var prop=item.getProperties(); | ||
+ | if(prop.getInteger("i.alpha")!=255)prop.edit().setInteger("i.alpha",255).commit(); | ||
+ | zOrder=Math.min(zOrder,c.getItemZIndex(data[0])); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=currentX+1; | ||
+ | var y=minPageY; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(var z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | if(c.getItemZIndex(data[0])>=zOrder)c.setItemZIndex(data[0],0); | ||
+ | item.setScale((0.75+percentX/4)*data[4],(0.75+percentX/4)*data[5]); | ||
+ | item.setPosition(dPosX+dWidth/2-(dWidth/2-(data[1]%dWidth+dWidth)%dWidth)*(0.75+percent/4),dPosY+dHeight/2-(dHeight/2-(data[2]%dHeight+dHeight)%dHeight)*(0.75+percent/4)); | ||
+ | item.getProperties().edit().setInteger("i.alpha",255*percentX).commit(); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function flip() | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items0=cont.get("pages").get(page); | ||
+ | if(items0!=null) | ||
+ | { | ||
+ | for(z=0;z<items0.length;z++) | ||
+ | { | ||
+ | var data=items0[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale(((percentX>=0.5||percentY>=0.5)?1:1-percentX*2)*data[4],((percentX>=0.5||percentY>=0.5)?1:1-percentY*2)*data[5]); | ||
+ | item.setPosition(dPosX+((data[1]%dWidth+dWidth)%dWidth)+percentX*(dWidth-((data[1]%dWidth+dWidth)%dWidth)*2),dPosY+((data[2]%dHeight+dHeight)%dHeight)+percentY*(dHeight-((data[2]%dHeight+dHeight)%dHeight)*2)); | ||
+ | item.setVisibility(percentX<0.5 && percentY<0.5); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=currentX+1; | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percentX<0.5||percentY>=0.5?1:percentX*2-1)*data[4],(percentX<0.5||percentY>=0.5?1:1-percentY*2)*data[5]); | ||
+ | item.setPosition(dPosX+dWidth/2*(2-percentX*2)+((data[1]%dWidth+dWidth)%dWidth)*(percentX*2-1),dPosY+((data[2]%dHeight+dHeight)%dHeight)+percentY*(dHeight-((data[2]%dHeight+dHeight)%dHeight)*2)); | ||
+ | item.setVisibility(percentX>=0.5 && percentY<0.5); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=currentY+1; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percentX>=0.5||percentY<0.5?1:1-percentX*2)*data[4],(percentX>=0.5||percentY<0.5?1:percentY*2-1)*data[5]); | ||
+ | item.setPosition(dPosX+((data[1]%dWidth+dWidth)%dWidth)+percentX*(dWidth-((data[1]%dWidth+dWidth)%dWidth)*2),dPosY+dHeight/2*(2-percentY*2)+((data[2]%dHeight+dHeight)%dHeight)*(percentY*2-1)); | ||
+ | item.setVisibility(percentX<0.5 && percentY>=0.5); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function shrink() | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | var page=asOne(x,y); | ||
+ | var items0=cont.get("pages").get(page); | ||
+ | if(items0!=null) | ||
+ | { | ||
+ | for(z=0;z<items0.length;z++) | ||
+ | { | ||
+ | var data=items0[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percent>=0.5?1:1-percent*2)*data[4],(percent>=0.5?1:1-percent*2)*data[5]); | ||
+ | item.setPosition(dPosX+((data[1]%dWidth+dWidth)%dWidth)+percent*(dWidth-((data[1]%dWidth+dWidth)%dWidth)*2),dPosY+((data[2]%dHeight+dHeight)%dHeight)+percent*(dHeight-((data[2]%dHeight+dHeight)%dHeight)*2)); | ||
+ | item.setVisibility(percent<0.5); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | if(percentX==percent) | ||
+ | { | ||
+ | var x=currentX+1; | ||
+ | var y=(cont.get("stateY")?maxPageY:currentY); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=currentY+1; | ||
+ | } | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setScale((percent<0.5?1:2*percent-1)*data[4],(percent<0.5?1:2*percent-1)*data[5]); | ||
+ | item.setPosition(dPosX+dWidth/2*(2-percent*2)+((data[1]%dWidth+dWidth)%dWidth)*(percent*2-1),dPosY+dHeight/2*(2-percent*2)+((data[2]%dHeight+dHeight)%dHeight)*(percent*2-1)); | ||
+ | item.setVisibility(percent>=0.5); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function turn() | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=minPageY; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setRotation(90*percent+data[3]); | ||
+ | var c0=center(item,data[3]); | ||
+ | var tempX=((data[1]+c0[0])%dWidth+dWidth)%dWidth; | ||
+ | var tempY=((data[2]+c0[1])%dHeight+dHeight)%dHeight; | ||
+ | var sqrt=Math.sqrt(Math.pow(tempX,2)+Math.pow(tempY,2)); | ||
+ | var angle=((tempX==0&&tempY==0)?0:Math.acos(tempX/sqrt))+percent*Math.PI/2; | ||
+ | var c1=center(item,item.getRotation()); | ||
+ | item.setPosition(dPosX+Math.cos(angle)*sqrt-c1[0],dPosY+Math.sin(angle)*sqrt-c1[1]); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=currentX+1; | ||
+ | var y=minPageY; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setRotation(90*percent-90+data[3]); | ||
+ | var c0=center(item,data[3]); | ||
+ | var tempX=((data[1]+c0[0])%dWidth+dWidth)%dWidth; | ||
+ | var tempY=((data[2]+c0[1])%dHeight+dHeight)%dHeight; | ||
+ | var sqrt=Math.sqrt(Math.pow(tempX,2)+Math.pow(tempY,2)); | ||
+ | var angle=((tempX==0&&tempY==0)?0:Math.acos(tempX/sqrt))+(percent-1)*Math.PI/2; | ||
+ | var c1=center(item,item.getRotation()); | ||
+ | item.setPosition(dPosX+Math.cos(angle)*sqrt-c1[0],dPosY+Math.sin(angle)*sqrt-c1[1]); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function zigZag() | ||
+ | { | ||
+ | var x=(cont.get("stateX")?maxPageX:currentX); | ||
+ | var y=minPageY; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setPosition(pagePosX+((data[1]%dWidth+dWidth)%dWidth),data[2]-percent*dHeight*0.5); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | var x=currentX+1; | ||
+ | var y=minPageY; | ||
+ | var page=asOne(x,y); | ||
+ | var items=cont.get("pages").get(page); | ||
+ | if(items!=null) | ||
+ | { | ||
+ | for(z=0;z<items.length;z++) | ||
+ | { | ||
+ | var data=items[z]; | ||
+ | if(!checkItem(x,y,z)) | ||
+ | { | ||
+ | continue; | ||
+ | z--; | ||
+ | } | ||
+ | var item=LL.getItemById(data[0]); | ||
+ | item.setPosition(data[1],data[2]-dHeight*(1-percent)*0.5); | ||
+ | cont.get("pages").get(page)[z][7]=item.getPositionX(); | ||
+ | cont.get("pages").get(page)[z][8]=item.getPositionY(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </sxh></spoiler> | ||
====== Old Versions: Single Animation as Script ====== | ====== Old Versions: Single Animation as Script ====== | ||
- | [[script_animation_bulldoze|"Bulldoze"]] | + | * [[script_animation_bulldoze|"Bulldoze"]] |
- | [[script_animation_cardstyle|"Cardstyle"]] | + | * [[script_animation_cardstyle|"Cardstyle"]] |
- | [[script_animation_flip|"Flip"]] | + | * [[script_animation_flip|"Flip"]] |
- | [[script_animation_inAndOut|"In and out"]] | + | * [[script_animation_inAndOut|"In and out"]] |
- | [[script_animation_shrink|"Shrink"]] | + | * [[script_animation_shrink|"Shrink"]] |
- | [[script_animation_turn|"Turn"]] | + | * [[script_animation_turn|"Turn"]] |
- | [[script_animation_zigzag|"Zigzag"]] | + | * [[script_animation_zigzag|"Zigzag"]] |