예제 #1
0
  public BPRadSprite(float rad) {
    super(null, null);

    int per = Math.max(24, (int) (2 * Math.PI * (double) rad / 11.0D));
    FloatBuffer pa = Utils.mkfbuf(per * 3 * 2);
    FloatBuffer na = Utils.mkfbuf(per * 3 * 2);
    ShortBuffer sa = Utils.mksbuf(per * 6);

    for (int i = 0; i < per; ++i) {
      float s = (float) Math.sin(2 * Math.PI * (double) i / (double) per);
      float c = (float) Math.cos(2 * Math.PI * (double) i / (double) per);
      pa.put(i * 3 + 0, c * rad).put(i * 3 + 1, s * rad).put(i * 3 + 2, 10.0F);
      pa.put((per + i) * 3 + 0, c * rad)
          .put((per + i) * 3 + 1, s * rad)
          .put((per + i) * 3 + 2, -10.0F);
      na.put(i * 3 + 0, c).put(i * 3 + 1, s).put(i * 3 + 2, 0.0F);
      na.put((per + i) * 3 + 0, c).put((per + i) * 3 + 1, s).put((per + i) * 3 + 2, 0.0F);
      int v = i * 6;
      sa.put(v + 0, (short) i).put(v + 1, (short) (i + per)).put(v + 2, (short) ((i + 1) % per));
      sa.put(v + 3, (short) (i + per))
          .put(v + 4, (short) ((i + 1) % per + per))
          .put(v + 5, (short) ((i + 1) % per));
    }

    this.posa = new VertexArray(pa);
    this.nrma = new NormalArray(na);
    this.sidx = sa;
  }
예제 #2
0
    public BufferedImage getGridImage() {
      if (rendered) return gridImage;

      if (!loaded) throw new Loading();

      gridImage = TexI.mkbuf(cmaps);

      BufferedImage[] texes = new BufferedImage[256];

      Coord c = new Coord();
      for (c.y = 0; c.y < cmaps.y; c.y++) {
        for (c.x = 0; c.x < cmaps.x; c.x++) {
          int t = gettile(c);
          BufferedImage tex = tileimg(t, texes);
          if (tex != null)
            gridImage.setRGB(
                c.x,
                c.y,
                tex.getRGB(
                    Utils.floormod(c.x, tex.getWidth()), Utils.floormod(c.y, tex.getHeight())));
        }
      }
      for (c.y = 1; c.y < cmaps.y - 1; c.y++) {
        for (c.x = 1; c.x < cmaps.x - 1; c.x++) {
          int t = gettile(c);
          if ((gettile(c.add(-1, 0)) > t)
              || (gettile(c.add(1, 0)) > t)
              || (gettile(c.add(0, -1)) > t)
              || (gettile(c.add(0, 1)) > t)) gridImage.setRGB(c.x, c.y, Color.BLACK.getRGB());
        }
      }
      rendered = true;
      return gridImage;
    }
예제 #3
0
  public void draw(BufferedImage buf) {
    WritableRaster dst = buf.getRaster();
    blit(dst, bg.getRaster(), Coord.z);

    alphablit(dst, rmeter(sbars[0].getRaster(), lmax[0], max), mc[0]);
    alphablit(
        dst, lmeter(sbars[1].getRaster(), lmax[1], max), mc[1].sub(bars[1].getWidth() - 1, 0));
    alphablit(
        dst, lmeter(sbars[2].getRaster(), lmax[2], max), mc[2].sub(bars[2].getWidth() - 1, 0));
    alphablit(dst, rmeter(sbars[3].getRaster(), lmax[3], max), mc[3]);

    if (lfood != null) {
      double e = foodeff(lfood);
      alphablit(dst, rgmeter(lfood, e, 0), mc[0]);
      alphablit(dst, lgmeter(lfood, e, 1), mc[1].sub(bars[1].getWidth() - 1, 0));
      alphablit(dst, lgmeter(lfood, e, 2), mc[2].sub(bars[1].getWidth() - 1, 0));
      alphablit(dst, rgmeter(lfood, e, 3), mc[3]);
    }

    alphablit(dst, rmeter(bars[0].getRaster(), lev[0], max), mc[0]);
    alphablit(dst, lmeter(bars[1].getRaster(), lev[1], max), mc[1].sub(bars[1].getWidth() - 1, 0));
    alphablit(dst, lmeter(bars[2].getRaster(), lev[2], max), mc[2].sub(bars[2].getWidth() - 1, 0));
    alphablit(dst, rmeter(bars[3].getRaster(), lev[3], max), mc[3]);

    StringBuilder tbuf = new StringBuilder();
    for (int i = 0; i < 4; i++)
      tbuf.append(
          String.format(
              "%s: %s/%s\n", rnm[i], Utils.fpformat(lev[i], 3, 1), Utils.fpformat(lmax[i], 3, 1)));
    tooltip = RichText.render(tbuf.toString(), 0).tex();
  }
예제 #4
0
 public float getcz(float px, float py) {
   float tw = tilesz.x, th = tilesz.y;
   Coord ul = new Coord(Utils.floordiv(px, tw), Utils.floordiv(py, th));
   float sx = Utils.floormod(px, tw) / tw;
   float sy = Utils.floormod(py, th) / th;
   return (((1.0f - sy) * (((1.0f - sx) * getz(ul)) + (sx * getz(ul.add(1, 0)))))
       + (sy * (((1.0f - sx) * getz(ul.add(0, 1))) + (sx * getz(ul.add(1, 1))))));
 }
예제 #5
0
 protected Tex find(List<ItemInfo> info) {
   GItem.NumberInfo ninf = ItemInfo.find(GItem.NumberInfo.class, info);
   if (ninf == null) return (null);
   return (new TexI(
       Utils.outline2(
           Text.render(Integer.toString(ninf.itemnum()), Color.WHITE).img,
           Utils.contrast(Color.WHITE))));
 }
예제 #6
0
 private static Color lighter(Color col) {
   int hsl[] = new int[3];
   Utils.rgb2hsl(col.getRed(), col.getGreen(), col.getBlue(), hsl);
   hsl[1] = Math.round(0.7f * hsl[1]);
   hsl[2] = 100;
   int rgb[] = Utils.hsl2rgb(hsl);
   return new Color(rgb[0], rgb[1], rgb[2]);
 }
예제 #7
0
 public void run() {
   try {
     InputStream in;
     OutputStream out;
     try {
       in = sk.getInputStream();
       out = sk.getOutputStream();
     } catch (IOException e) {
       throw (new RuntimeException(e));
     }
     while (true) {
       try {
         int len = Utils.int32d(read(in, 4), 0);
         if (!auth && (len > 256)) return;
         Message msg = new MessageBuf(read(in, len));
         String cmd = msg.string();
         Object[] args = msg.list();
         Object[] reply;
         if (auth) {
           Command cc = commands.get(cmd);
           if (cc != null) reply = cc.run(this, args);
           else reply = new Object[] {"nocmd"};
         } else {
           if (cmd.equals("nonce")) {
             reply = new Object[] {nonce};
           } else if (cmd.equals("auth")) {
             if (Arrays.equals((byte[]) args[0], ckey)) {
               reply = new Object[] {"ok"};
               auth = true;
             } else {
               reply = new Object[] {"no"};
             }
           } else {
             return;
           }
         }
         MessageBuf rb = new MessageBuf();
         rb.addlist(reply);
         byte[] rbuf = new byte[4 + rb.size()];
         Utils.uint32e(rb.size(), rbuf, 0);
         rb.fin(rbuf, 4);
         out.write(rbuf);
       } catch (IOException e) {
         return;
       }
     }
   } catch (InterruptedException e) {
   } finally {
     try {
       sk.close();
     } catch (IOException e) {
       throw (new RuntimeException(e));
     }
   }
 }
예제 #8
0
 public Spec(Indir<Resource> res, Message sdt, int num) {
   this.res = res;
   this.sdt = new MessageBuf(sdt);
   if (num >= 0)
     this.num =
         new TexI(
             Utils.outline2(
                 Text.render(Integer.toString(num), Color.WHITE).img,
                 Utils.contrast(Color.WHITE)));
   else this.num = null;
 }
예제 #9
0
 private void savewndstate() {
   if (prefs == null) {
     if (getExtendedState() == NORMAL)
     /* Apparent, getSize attempts to return the "outer
      * size" of the window, including WM decorations, even
      * though setSize sets the "inner size" of the
      * window. Therefore, use the Panel's size instead; it
      * ought to correspond to the inner size at all
      * times. */ {
       Dimension dim = p.getSize();
       Utils.setprefc("wndsz", new Coord(dim.width, dim.height));
     }
     Utils.setprefb("wndmax", (getExtendedState() & MAXIMIZED_BOTH) != 0);
   }
 }
예제 #10
0
 public BufferedImage drawmap(Coord ul, Coord sz) {
   BufferedImage[] texes = new BufferedImage[256];
   MCache m = ui.sess.glob.map;
   BufferedImage buf = TexI.mkbuf(sz);
   Coord c = new Coord();
   for (c.y = 0; c.y < sz.y; c.y++) {
     for (c.x = 0; c.x < sz.x; c.x++) {
       int t = m.gettile(ul.add(c));
       BufferedImage tex = tileimg(t, texes);
       int rgb = 0;
       if (tex != null)
         rgb =
             tex.getRGB(
                 Utils.floormod(c.x + ul.x, tex.getWidth()),
                 Utils.floormod(c.y + ul.y, tex.getHeight()));
       buf.setRGB(c.x, c.y, rgb);
     }
   }
   for (c.y = 1; c.y < sz.y - 1; c.y++) {
     for (c.x = 1; c.x < sz.x - 1; c.x++) {
       int t = m.gettile(ul.add(c));
       Tiler tl = m.tiler(t);
       if (tl instanceof Ridges.RidgeTile) {
         if (Ridges.brokenp(m, ul.add(c))) {
           for (int y = c.y - 1; y <= c.y + 1; y++) {
             for (int x = c.x - 1; x <= c.x + 1; x++) {
               Color cc = new Color(buf.getRGB(x, y));
               buf.setRGB(
                   x,
                   y,
                   Utils.blendcol(cc, Color.BLACK, ((x == c.x) && (y == c.y)) ? 1 : 0.1).getRGB());
             }
           }
         }
       }
     }
   }
   for (c.y = 0; c.y < sz.y; c.y++) {
     for (c.x = 0; c.x < sz.x; c.x++) {
       int t = m.gettile(ul.add(c));
       if ((m.gettile(ul.add(c).add(-1, 0)) > t)
           || (m.gettile(ul.add(c).add(1, 0)) > t)
           || (m.gettile(ul.add(c).add(0, -1)) > t)
           || (m.gettile(ul.add(c).add(0, 1)) > t)) buf.setRGB(c.x, c.y, Color.BLACK.getRGB());
     }
   }
   return (buf);
 }
예제 #11
0
 private static void main2(String[] args) {
   Config.cmdline(args);
   try {
     javabughack();
   } catch (InterruptedException e) {
     return;
   }
   setupres();
   MainFrame f = new MainFrame(null);
   if (Utils.getprefb("fullscreen", false)) f.setfs();
   f.mt.start();
   try {
     f.mt.join();
   } catch (InterruptedException e) {
     f.g.interrupt();
     return;
   }
   dumplist(Resource.remote().loadwaited(), Config.loadwaited);
   dumplist(Resource.remote().cached(), Config.allused);
   if (ResCache.global != null) {
     try {
       Writer w = new OutputStreamWriter(ResCache.global.store("tmp/allused"), "UTF-8");
       try {
         Resource.dumplist(Resource.remote().used(), w);
       } finally {
         w.close();
       }
     } catch (IOException e) {
     }
   }
   System.exit(0);
 }
예제 #12
0
  static {
    String p;
    if ((p = getprop("haven.authck", null)) != null) authck = Utils.hex2byte(p);
    File f = new File(userhome);
    if (!f.exists()) {
      f.mkdirs();
    }

    InputStream in = ErrorHandler.class.getResourceAsStream("/buildinfo");
    try {
      try {
        if (in != null) {
          Properties info = new Properties();
          info.load(in);
          for (Map.Entry<Object, Object> e : info.entrySet())
            buildinfo.put((String) e.getKey(), e.getValue());
        }
      } finally {
        in.close();
      }
    } catch (IOException e) {
      throw (new Error(e));
    }
    version = (String) buildinfo.get("git-rev");
    loadOptions();
    window_props = loadProps("windows.conf");

    Wiki.init(getFile("cache"), 3);
  }
예제 #13
0
  public void draw(GOut g) {
    if (screenshot && Config.sshot_noui) {
      visible = false;
    }
    super.draw(g);
    drawcmd(g, new Coord(20, 580));
    if (screenshot && (!Config.sshot_nonames || names_ready)) {
      visible = true;
      screenshot = false;
      try {
        Coord s = MainFrame.getInnerSize();
        String stamp = Utils.sessdate(System.currentTimeMillis());
        String ext = Config.sshot_compress ? ".jpg" : ".png";
        File f = new File("screenshots/SS_" + stamp + ext);
        f.mkdirs();
        Screenshot.writeToFile(f, s.x, s.y);
      } catch (GLException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    //	if(!afk && (System.currentTimeMillis() - ui.lastevent > 300000)) {
    //	    afk = true;
    //	    Widget slen = findchild(SlenHud.class);
    //	    if(slen != null)
    //		slen.wdgmsg("afk");
    //	} else if(afk && (System.currentTimeMillis() - ui.lastevent < 300000)) {
    //	    afk = false;
    //	}
  }
예제 #14
0
 Tex nmeter() {
   if (ntext == null)
     ntext =
         new TexI(
             Utils.outline2(nfnd.render(Integer.toString(nmeter), Color.WHITE).img, Color.BLACK));
   return (ntext);
 }
예제 #15
0
 public IButton(BufferedImage up, BufferedImage down, BufferedImage hover) {
   super(Utils.imgsz(up));
   this.up = up;
   this.down = down;
   this.hover = hover;
   render();
 }
예제 #16
0
 public static WritableRaster tilemod(WritableRaster dst, Raster tile, Coord off) {
   int w = dst.getWidth(), h = dst.getHeight(), b = dst.getNumBands();
   int tw = tile.getWidth(), th = tile.getHeight(), tb = tile.getNumBands();
   for (int y = 0; y < h; y++) {
     for (int x = 0; x < w; x++) {
       int tx = Utils.floormod(x - off.x, tw), ty = Utils.floormod(y - off.y, th);
       for (int i = 0; i < b; i++)
         dst.setSample(
             x,
             y,
             i,
             (dst.getSample(x, y, i) * ((i < tb) ? tile.getSample(tx, ty, i) : 255)) / 255);
     }
   }
   return (dst);
 }
예제 #17
0
  public MainFrame(Coord isz) {
    super("Haven and Hearth");
    version = "1.6 (12.22.2015)";
    Coord sz;
    if (isz == null) {
      sz = Utils.getprefc("wndsz", new Coord(800, 600));
      if (sz.x < 640) sz.x = 640;
      if (sz.y < 480) sz.y = 480;
    } else {
      sz = isz;
    }
    this.g = new ThreadGroup(HackThread.tg(), "Haven client");
    this.mt = new HackThread(this.g, this, "Haven main thread");
    p = new HavenPanel(sz.x, sz.y);
    if (fsmode == null) {
      Coord pfm = Utils.getprefc("fsmode", null);
      if (pfm != null) fsmode = findmode(pfm.x, pfm.y);
    }
    if (fsmode == null) {
      DisplayMode cm = getGraphicsConfiguration().getDevice().getDisplayMode();
      fsmode = findmode(cm.getWidth(), cm.getHeight());
    }
    if (fsmode == null) fsmode = findmode(800, 600);
    add(p);
    pack();
    setResizable(!Utils.getprefb("wndlock", false));
    p.requestFocusInWindow();
    seticon();
    setVisible(true);
    p.init();
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            g.interrupt();
          }

          public void windowActivated(WindowEvent e) {
            p.bgmode = false;
          }

          public void windowDeactivated(WindowEvent e) {
            p.bgmode = true;
          }
        });
    if ((isz == null) && Utils.getprefb("wndmax", false))
      setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
  }
예제 #18
0
 public TexCube(BufferedImage img) {
   Coord sz = Utils.imgsz(img);
   tdim = sz.x / 4;
   if ((tdim * 4) != sz.x)
     throw (new RuntimeException("Cube-mapped texture has width undivisible by 4"));
   if ((tdim * 3) != sz.y) throw (new RuntimeException("Cube-mapped texture is not 4:3"));
   this.back = img;
 }
예제 #19
0
 public static void cmdline(String[] args) {
   PosixArgs opt = PosixArgs.getopt(args, "hdPU:r:A:u:C:m:");
   if (opt == null) {
     usage(System.err);
     System.exit(1);
   }
   for (char c : opt.parsed()) {
     switch (c) {
       case 'h':
         usage(System.out);
         System.exit(0);
         break;
       case 'd':
         dbtext = true;
         break;
       case 'P':
         profile = true;
         break;
       case 'r':
         resdir = opt.arg;
         break;
       case 'A':
         int p = opt.rest[0].indexOf(':');
         if (p >= 0) {
           authserv = opt.arg.substring(0, p);
           authport = Integer.parseInt(opt.arg.substring(p + 1));
         } else {
           authserv = opt.arg;
         }
         break;
       case 'U':
         try {
           resurl = new URL(opt.arg);
         } catch (java.net.MalformedURLException e) {
           System.err.println(e);
           System.exit(1);
         }
         break;
       case 'u':
         authuser = opt.arg;
         break;
       case 'C':
         authck = Utils.hex2byte(opt.arg);
         break;
       case 'm':
         authmech = opt.arg;
     }
   }
   if (opt.rest.length > 0) {
     int p = opt.rest[0].indexOf(':');
     if (p >= 0) {
       defserv = opt.rest[0].substring(0, p);
       mainport = Integer.parseInt(opt.rest[0].substring(p + 1));
     } else {
       defserv = opt.rest[0];
     }
   }
 }
예제 #20
0
 private void uglyjoglhack() throws InterruptedException {
   try {
     display();
   } catch (RuntimeException e) {
     InterruptedException ie = Utils.hascause(e, InterruptedException.class);
     if (ie != null) throw (ie);
     else throw (e);
   }
 }
예제 #21
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()));
           }
         });
   }
 }
예제 #22
0
파일: Widget.java 프로젝트: lcy03406/amber
 public <T extends Widget> T add(T child, Coord c) {
   child.c = c;
   if (child instanceof Window) {
     try {
       Window wnd = (Window) child;
       if (Window.persistentwnds.contains(wnd.cap.text))
         child.c = Utils.getprefc(wnd.cap.text + "_c", c);
     } catch (Exception e) {
     }
   }
   return (add(child));
 }
예제 #23
0
 public Text text() {
   BuddyWnd.Buddy b = getparent(GameUI.class).buddies.find(from);
   String nm = (b == null) ? "???" : (b.name);
   if ((r == null) || !nm.equals(cn)) {
     String msg = RichText.Parser.quote(String.format("%s: %s", nm, text));
     if (Config.timestamp) {
       msg = Utils.timestamp(msg);
     }
     r = fnd.render(msg, w, TextAttribute.FOREGROUND, col);
     cn = nm;
   }
   return (r);
 }
예제 #24
0
파일: Text.java 프로젝트: TuGu/hnh_union
 public Line render(String text, Color c) {
   Line t = new Line(text);
   Coord sz = strsize(text);
   if (sz.x < 1) sz = sz.add(1, 0);
   t.img = TexI.mkbuf(sz);
   Graphics g = t.img.createGraphics();
   if (aa) Utils.AA(g);
   g.setFont(font);
   g.setColor(c);
   t.m = g.getFontMetrics();
   g.drawString(text, 0, t.m.getAscent());
   g.dispose();
   return (t);
 }
예제 #25
0
 public Line render(String text, Color c) {
   text = Translate.get(text);
   Coord sz = strsize(text);
   if (sz.x < 1) sz = sz.add(1, 0);
   BufferedImage img = TexI.mkbuf(sz);
   Graphics g = img.createGraphics();
   if (aa) Utils.AA(g);
   g.setFont(font);
   g.setColor(c);
   FontMetrics m = g.getFontMetrics();
   g.drawString(text, 0, m.getAscent());
   g.dispose();
   return (new Line(text, img, m));
 }
 /*    */ public Factory(int stages, int variants, int num, boolean rev) /*    */ {
   /* 39 */ Resource res = Utils.myres(getClass());
   /* 40 */ this.neg = ((Resource.Neg) res.layer(Resource.negc));
   /* 41 */ this.num = num;
   /* 42 */ this.strands = new Tex[stages][variants];
   /* 43 */ if (rev) {
     /* 44 */ for (Resource.Image img : res.layers(Resource.imgc))
       /* 45 */ if (img.id != -1)
         /* 46 */ this.strands[(img.id / variants)][(img.id % variants)] = img.tex();
     /*    */ }
   /*    */ else
     /* 49 */ for (Resource.Image img : res.layers(Resource.imgc))
       /* 50 */ if (img.id != -1)
         /* 51 */ this.strands[(img.id % stages)][(img.id / stages)] = img.tex();
   /*    */ }
 public Factory(int stages, int variants, int num, boolean rev) {
   Resource res = Utils.myres(this.getClass());
   this.neg = res.layer(Resource.negc);
   this.num = num;
   strands = new Tex[stages][variants];
   if (rev) {
     for (Resource.Image img : res.layers(Resource.imgc)) {
       if (img.id != -1) strands[img.id / variants][img.id % variants] = img.tex();
     }
   } else {
     for (Resource.Image img : res.layers(Resource.imgc)) {
       if (img.id != -1) strands[img.id % stages][img.id / stages] = img.tex();
     }
   }
 }
예제 #28
0
  public boolean type(char key, java.awt.event.KeyEvent ev) {
    if (Config.userazerty) key = Utils.azerty2qwerty(key);

    if ((key >= '0') && (key <= '9')) {
      int opt = (key == '0') ? 10 : (key - '1');
      if (opt < opts.length) {
        choose(opts[opt]);
        kg.remove();
      }
      return (true);
    } else if (key == 27) {
      choose(null);
      kg.remove();
      return (true);
    }
    return (false);
  }
예제 #29
0
 public void draw(GOut g) {
   long now = System.currentTimeMillis();
   int t = (int) (now % 1000);
   int b = (int) (255 * ((t < 500) ? (t) : (1000 - t)) / 500.0f);
   Inventory.invsq(g, Coord.z, gsz);
   for (int y = 0; y < gsz.y; y++) {
     for (int x = 0; x < gsz.x; x++) {
       Coord p = Inventory.sqoff(new Coord(x, y));
       Pagina btn = layout[x][y];
       if (btn != null) {
         Tex btex = btn.img.tex();
         if (btn.newp) {
           g.chcolor(b, 255, b, 255);
         }
         g.image(btex, p);
         g.chcolor();
         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(Inventory.isqsz.div(2)), Inventory.isqsz.div(2), 90, (int) (90 + (360 * m)));
           g.chcolor();
         }
         if (btn == pressed) {
           g.chcolor(new Color(0, 0, 0, 128));
           g.frect(p, 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()));
           }
         });
   }
 }
예제 #30
0
  public static void main(final String[] args) {

    File logdir = new File(LOG_DIR);
    if (!logdir.exists()) logdir.mkdirs();
    File log = new File(logdir, "client.log");
    // redirect all console output to the file
    try {
      PrintStream out = new PrintStream(new FileOutputStream(log, true), true);
      out.format("[%s] ===== Client started =====%n", timestampf.format(new Date()));
      System.setOut(out);
      System.setErr(out);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    /* Set up the error handler as early as humanly possible. */
    ThreadGroup g = new ThreadGroup("Haven main group");
    String ed;
    if (!(ed = Utils.getprop("haven.errorurl", "")).equals("")) {
      try {
        final haven.error.ErrorHandler hg = new haven.error.ErrorHandler(new java.net.URL(ed));
        hg.sethandler(
            new haven.error.ErrorGui(null) {
              public void errorsent() {
                hg.interrupt();
              }
            });
        g = hg;
      } catch (java.net.MalformedURLException e) {
      }
    }
    Thread main =
        new HackThread(
            g,
            new Runnable() {
              public void run() {
                main2(args);
              }
            },
            "Haven main thread");
    main.start();
  }