Exemplo n.º 1
0
 public MinimapTile get(final Coord c, final MCache.Grid grid, final int seq) {
   Coord key = new Coord(c);
   MinimapTile tile = tiles.get(key);
   if ((tile == null || tile.seq != seq) && (grid != null)) {
     Defer.Future<BufferedImage> f = rendering.get(key);
     if (f == null) {
       f =
           Defer.later(
               new Defer.Callable<BufferedImage>() {
                 @Override
                 public BufferedImage call() {
                   BufferedImage img = renderer.draw(grid.ul, MCache.cmaps);
                   if (Config.minimapEnableSave.get()) store(img, grid.gc);
                   return img;
                 }
               });
       rendering.put(key, f);
     }
     if (f.done()) {
       BufferedImage img = f.get();
       if (tile == null) {
         tile = createTile(key, seq, img);
         tiles.put(key, tile);
       } else {
         tile.img.update(img);
       }
       rendering.remove(key);
     }
   }
   return tile;
 }
Exemplo n.º 2
0
 private void buildcut(final Coord cc) {
   final Cut cut = geticut(cc);
   final int deftag = ++cut.deftag;
   cut.dmesh =
       Defer.later(
           new Defer.Callable<MapMesh>() {
             public MapMesh call() {
               Random rnd = new Random(id);
               rnd.setSeed(rnd.nextInt() ^ cc.x);
               rnd.setSeed(rnd.nextInt() ^ cc.y);
               return (MapMesh.build(MCache.this, rnd, ul.add(cc.mul(cutsz)), cutsz));
             }
           });
 }
Exemplo n.º 3
0
 public void draw(GOut g) {
   if (cc == null) return;
   map:
   {
     final Grid plg;
     try {
       plg = ui.sess.glob.map.getgrid(cc.div(cmaps));
     } catch (Loading l) {
       break map;
     }
     final int seq = plg.seq;
     if ((cur == null) || (plg != cur.grid) || (seq != cur.seq)) {
       Defer.Future<MapTile> f;
       synchronized (cache) {
         f = cache.get(new Pair<Grid, Integer>(plg, seq));
         if (f == null) {
           f =
               Defer.later(
                   new Defer.Callable<MapTile>() {
                     public MapTile call() {
                       Coord ul = plg.ul.sub(cmaps).add(1, 1);
                       return (new MapTile(
                           new TexI(drawmap(ul, cmaps.mul(3).sub(2, 2))), ul, plg, seq));
                     }
                   });
           cache.put(new Pair<Grid, Integer>(plg, seq), f);
         }
       }
       if (f.done()) {
         cur = f.get();
         if (save != null) save.update(ui.sess.glob.map, cur.grid.gc);
       }
     }
   }
   if (cur != null) {
     g.image(MiniMap.bg, Coord.z);
     g.image(cur.img, cur.ul.sub(cc).add(sz.div(2)));
     try {
       synchronized (ui.sess.glob.party.memb) {
         for (Party.Member m : ui.sess.glob.party.memb.values()) {
           Coord ptc;
           try {
             ptc = m.getc();
           } catch (MCache.LoadingMap e) {
             ptc = null;
           }
           if (ptc == null) continue;
           ptc = p2c(ptc);
           g.chcolor(m.col.getRed(), m.col.getGreen(), m.col.getBlue(), 128);
           g.image(
               MiniMap.plx.layer(Resource.imgc).tex(),
               ptc.add(MiniMap.plx.layer(Resource.negc).cc.inv()));
           g.chcolor();
         }
       }
     } catch (Loading l) {
     }
   } else {
     g.image(MiniMap.nomap, Coord.z);
   }
   drawicons(g);
 }