Example #1
0
 public void draw(GOut g) {
   long now = System.currentTimeMillis();
   for (int y = 0; y < gsz.y; y++) {
     for (int x = 0; x < gsz.x; x++) {
       Coord p = bgsz.mul(new Coord(x, y));
       g.image(bg, p);
       Pagina btn = layout[x][y];
       if (btn != null) {
         Tex btex = btn.img.tex();
         g.image(btex, p.add(1, 1));
         if (btn.meter > 0) {
           double m = btn.meter / 1000.0;
           if (btn.dtime > 0) m += (1 - m) * (double) (now - btn.gettime) / (double) btn.dtime;
           m = Utils.clip(m, 0, 1);
           g.chcolor(255, 255, 255, 128);
           g.fellipse(p.add(bgsz.div(2)), bgsz.div(2), 90, (int) (90 + (360 * m)));
           g.chcolor();
         }
         if (btn.newp != 0) {
           if (btn.fstart == 0) {
             btn.fstart = now;
           } else {
             double ph = ((now - btn.fstart) / 1000.0) - (((x + (y * gsz.x)) * 0.15) % 1.0);
             if (ph < 1.25) {
               g.chcolor(255, 255, 255, (int) (255 * ((Math.cos(ph * Math.PI * 2) * -0.5) + 0.5)));
               g.image(glowmask(btn), p.sub(4, 4));
               g.chcolor();
             } else {
               g.chcolor(255, 255, 255, 128);
               g.image(glowmask(btn), p.sub(4, 4));
               g.chcolor();
             }
           }
         }
         if (btn == pressed) {
           g.chcolor(new Color(0, 0, 0, 128));
           g.frect(p.add(1, 1), btex.sz());
           g.chcolor();
         }
       }
     }
   }
   super.draw(g);
   if (dragging != null) {
     final Tex dt = dragging.img.tex();
     ui.drawafter(
         new UI.AfterDraw() {
           public void draw(GOut g) {
             g.image(dt, ui.mc.add(dt.sz().div(2).inv()));
           }
         });
   }
 }
Example #2
0
 private boolean cons(Pagina p, Collection<Pagina> buf) {
   Pagina[] cp = new Pagina[0];
   Collection<Pagina> open, close = new HashSet<Pagina>();
   synchronized (ui.sess.glob.paginae) {
     open = new LinkedList<Pagina>();
     for (Pagina pag : ui.sess.glob.paginae) {
       if (pag.newp == 2) {
         pag.newp = 0;
         pag.fstart = 0;
       }
       open.add(pag);
     }
     for (Pagina pag : ui.sess.glob.pmap.values()) {
       if (pag.newp == 2) {
         pag.newp = 0;
         pag.fstart = 0;
       }
     }
   }
   boolean ret = true;
   while (!open.isEmpty()) {
     Iterator<Pagina> iter = open.iterator();
     Pagina pag = iter.next();
     iter.remove();
     try {
       AButton ad = pag.act();
       if (ad == null) throw (new PaginaException(pag));
       Pagina parent = paginafor(ad.parent);
       if ((pag.newp != 0) && (parent != null) && (parent.newp == 0)) {
         parent.newp = 2;
         parent.fstart = (parent.fstart == 0) ? pag.fstart : Math.min(parent.fstart, pag.fstart);
       }
       if (parent == p) buf.add(pag);
       else if ((parent != null) && !close.contains(parent) && !open.contains(parent))
         open.add(parent);
       close.add(pag);
     } catch (Loading e) {
       ret = false;
     }
   }
   return (ret);
 }