! *.BAS Launcher FN.DEF RoundCornerRect (b, h, r) half_pi = 3.14159 / 2 dphi = half_pi / 8 LIST.CREATE N, S1 mx = -b/2+r my = -h/2+r FOR phi = 0 TO half_pi STEP dphi LIST.ADD s1, mx-COS(phi)*r, my-sin (phi)*r NEXT mx = b/2-r my = -h/2+r FOR phi = 0 TO half_pi STEP dphi LIST.ADD s1, mx+SIN(phi)*r, my- cos (phi)*r NEXT mx = b/2-r my = h/2-r FOR phi = 0 TO half_pi STEP dphi LIST.ADD s1, mx+COS(phi)*r, my+sin (phi)*r NEXT mx = -b/2+r my = h/2-r FOR phi = 0 TO half_pi STEP dphi LIST.ADD s1, mx-SIN(phi)*r, my+cos (phi)*r NEXT FN.RTN s1 FN.END Fn.def move(ptr, arx, ary) % move smoothly the bitmap 'ptr' to arx,ary do gr.get.position ptr,dpx,dpy ix =int((dpx-arx)/2) iy =int((dpy-ary)/2) if abs(ix)<5 & abs(iy)<5 then D_u.break gr.modify ptr, "x",dpx-ix, "y",dpy-iy gr.render pause 5 until 0 gr.modify ptr, "x",arx, "y",ary gr.render Fn.end File.Root tmp$ IstandAlone =Is_In("rfo-basic",tmp$) % to know if it's an APK for the way to exit. Device b Bundle.get b, "Language", lang$ if left$(lower$(lang$),2)="fr" then lang =2 else lang =1 % French or English GR.OPEN 255,0,148,0,0,0 % 0=paysage gr.screen w, h scx = 1280 % my device : 2560 x 1600 scy = 800 sx = w/scx sy = h/scy gr.scale sx, sy nx =5 % x cells ny =10 % y cells nc =15 % nb of characters displayed. DIM prg$[nx,ny], prg[nx,ny], clr[2] file.dir "../source/", f$[] gosub initScreen gosub loadprog gr.text.draw mess, scx-80, 45, "" DO t =clock() do gr.touch touched, x, y x/=sx y/=sy if !background() then gr.render until touched | quit if quit then D_U.break psx =int(x/(dx+8))+1 psy =int((y-80)/(dy+8))+1 if psx>0 & psx<=nx & psy>0 & psy<=ny & y>85 if prg$[psx,psy]<>"" mv =1 gr.get.position prg[psx,psy], px, py deltx =x-px delty =y-py endif else D_U.continue endif nl =0 do gr.touch touched, tx, ty tr =clock()-t tx/=sx ty/=sy if mv gr.modify prg[psx,psy], "x", tx-deltx, "y", ty-delty gr.render if nl=0 & abs(x-tx)+abs(y-ty)>20 then nl =1 endif until !touched lsx =int(tx/(dx+8))+1 lsy =int((ty-80)/(dy+8))+1 if mv if ty<80 % delete this Shortcut. gr.hide prg[psx,psy] gr.render gr.getDL dl_array[] gr.newDL dl_array[] array.delete dl_array[] prg$[psx,psy] ="" elseif psx=lsx & psy=lsy & nl=0 % launch File.Exists fich, "../source/"+prg$[psx,psy] if fich gosub saveprog gr.close RUN prg$[psx,psy] else gosub NewShortcut endif elseif prg$[lsx,lsy]<>"" % emplacement déjà occupé :swap gr.modify prg[psx,psy], "x", 20+(lsx-1)*(dx+8), "y", 123+(lsy-1)*(dy+8) move( prg[lsx,lsy] , px, py) swap prg[psx,psy], prg[lsx,lsy] swap prg$[psx,psy], prg$[lsx,lsy] else % move on an empty place gr.modify prg[psx,psy], "x", 20+(lsx-1)*(dx+8), "y", 123+(lsy-1)*(dy+8) swap prg[psx,psy], prg[lsx,lsy] swap prg$[psx,psy], prg$[lsx,lsy] endif mv =0 elseif prg$[psx,psy]="" % add new shortcut. gosub NewShortcut endif UNTIL quit gosub saveprog if IstandAlone END "Bye...!" else EXIT endif % --------------- exit --------------- OnBackKey: quit =1 Back.Resume NewShortcut: dialog.select f, f$[], "Select." if f if right$(f$[f],3)<>"(d)" array.search prg$[], f$[f], de if !de tf$ =left$(replace$(f$[f],".bas",""),nc) if prg$[psx,psy] ="" gr.text.draw prg[psx,psy], 20+(psx-1)*(dx+8), 123+(psy-1)*(dy+8), tf$ else gr.modify prg[psx,psy], "text", tf$, "paint", clr[1] endif prg$[psx,psy] =f$[f] else % shortcut already exist... show it. rx =int(de/ny)+(mod(de,ny)>0) ry =de-(rx-1)*ny gr.get.position prg[rx,ry], px, py for s=1 to 8 bd =val(word$("20 0 20 0 20 0 20 0 20 0",s)) move( prg[rx,ry], px, py-bd ) pause 40 next endif endif endif return InitScreen: dx =int(scx/nx)-10 dy =int(scy/(ny+1))-8 gr.bitmap.create btm, dx+2, dy+2 gr.bitmap.drawinto.start btm poly = RoundCornerRect ( dx-2 , dy-2 , 14) GR.SET.STROKE 5 GR.COLOR 220, 0, 102, 255, 1 GR.POLY nul, poly, dx/2, dy/2 GR.COLOR 255, 255, 255, 255 ,0 GR.POLY nul, poly, dx/2, dy/2 GR.COLOR 255, 100, 100, 100, 0 GR.POLY nul, poly, dx/2+1, dy/2+1 gr.bitmap.drawinto.end for x=1 to nx % buttons for y=1 to ny gr.bitmap.draw nul, btm, 6+(x-1)*(dx+8), 80+(y-1)*(dy+8) next next gr.set.stroke 2 gr.color 255,253,85,0,1 gr.line nul, 10, 65, scx-10, 65 gr.text.size 40 gr.color 255, 200, 200, 200,2 gr.text.draw nul, 50, 45, "*.bas Launcher... rfo-basic! v"+version$() gr.color 200,200,200,200,2 % poubelle gr.rect nul, 1100, 15, 1140, 50 gr.line nul, 1095, 15, 1145, 15 gr.circle nul, 1120, 15, 6 gr.color 255,150,150,150,2 gr.line nul, 1110, 20, 1110, 45 gr.line nul, 1120, 20, 1120, 45 gr.line nul, 1130, 20, 1130, 45 gr.text.size 32 gr.color 255,255,132,0,1 % red gr.paint.get clr[2] gr.color 255,255,255,0,1 % yellow gr.paint.get clr[1] return loadprog: File.exists fe, "BasLauncher.sav" if fe GRABFILE p$, "BasLauncher.sav" split ln$[], p$, "\n" array.length lg, ln$[] n =0 for x=1 to nx for y=1 to ny n++ if n<=lg if ln$[n]<>"" prg$[x,y] =ln$[n] tf$ =left$(replace$(ln$[n],".bas",""),nc) gr.text.draw prg[x,y], 20+(x-1)*(dx+8), 123+(y-1)*(dy+8), tf$ file.exists fi, "../source/"+ prg$[x,y] if !fi then gr.modify prg[x,y], "paint", clr[2] endif endif next next endif return saveprog: cls for x=1 to nx for y=1 to ny print prg$[x,y] next next File.exists fe, "BasLauncher.sav" if fe then File.rename "BasLauncher.sav", "BasLauncher.bak" console.save "BasLauncher.sav" cls return