Example #1
0
 public void draw(GOut g) {
   try {
     Resource res = item.res.get();
     Tex tex = res.layer(Resource.imgc).tex();
     drawmain(g, tex);
     if (item.num >= 0) {
       g.atext(Integer.toString(item.num), tex.sz(), 1, 1);
     } else if (itemnum.get() != null) {
       g.aimage(itemnum.get(), tex.sz(), 1, 1);
     }
     if (item.meter > 0) {
       double a = ((double) item.meter) / 100.0;
       g.chcolor(255, 255, 255, 64);
       Coord half = Inventory.isqsz.div(2);
       g.prect(half, half.inv(), half, a * Math.PI * 2);
       g.chcolor();
     }
     if (olcol.get() != null) {
       if (cmask != res) {
         mask = null;
         if (tex instanceof TexI) mask = ((TexI) tex).mkmask();
         cmask = res;
       }
       if (mask != null) {
         g.chcolor(olcol.get());
         g.image(mask, Coord.z);
         g.chcolor();
       }
     }
   } catch (Loading e) {
     missing.loadwait();
     g.image(missing.layer(Resource.imgc).tex(), Coord.z, sz);
   }
 }
Example #2
0
 public void text(String text, Coord c) {
   atext(text, c, 0, 0);
 }
  void redraw(GL gl) {
    GOut g = new GOut(gl, getContext(), MainFrame.getInnerSize());
    synchronized (ui) {
      ui.update();
    }
    if (Config.render_enable) {
      gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glLoadIdentity();
      gl.glOrtho(0, getWidth(), 0, getHeight(), -1, 1);
      TexRT.renderall(g);
      if (curf != null) curf.tick("texrt");

      gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glLoadIdentity();
      gl.glOrtho(0, getWidth(), getHeight(), 0, -1, 1);
      gl.glClearColor(0, 0, 0, 1);
      gl.glClear(GL.GL_COLOR_BUFFER_BIT);
      if (curf != null) curf.tick("cls");
      synchronized (ui) {
        ui.draw(g);
      }
      if (curf != null) curf.tick("draw");

      if (Config.dbtext) {
        g.atext("FPS: " + fps, new Coord(10, 545), 0, 1);
        g.atext("Texhit: " + dth, new Coord(10, 530), 0, 1);
        g.atext("Texmiss: " + dtm, new Coord(10, 515), 0, 1);
        Runtime rt = Runtime.getRuntime();
        long free = rt.freeMemory(), total = rt.totalMemory();
        g.atext(
            String.format(
                "Mem: %,011d/%,011d/%,011d/%,011d", free, total - free, total, rt.maxMemory()),
            new Coord(10, 500),
            0,
            1);
        g.atext(
            String.format("LCache: %d/%d", Layered.cache.size(), Layered.cache.cached()),
            new Coord(10, 485),
            0,
            1);
        g.atext(
            String.format("RT-current: %d", TexRT.current.get(gl).size()),
            new Coord(10, 470),
            0,
            1);
        if (Resource.qdepth() > 0)
          g.atext(
              String.format("RQ depth: %d (%d)", Resource.qdepth(), Resource.numloaded()),
              new Coord(10, 455),
              0,
              1);
      }
      Object tooltip = ui.root.tooltip(mousepos, true);
      Tex tt = null;
      if (tooltip != null) {
        if (tooltip instanceof Text) {
          tt = ((Text) tooltip).tex();
        } else if (tooltip instanceof Tex) {
          tt = (Tex) tooltip;
        } else if (tooltip instanceof String) {
          if (((String) tooltip).length() > 0) tt = (Text.render((String) tooltip)).tex();
        }
      }
      if (tt != null) {
        Coord sz = tt.sz();
        Coord pos = mousepos.add(sz.inv());
        if (pos.x < 0) pos.x = 0;
        if (pos.y < 0) pos.y = 0;
        g.chcolor(244, 247, 21, 192);
        g.rect(pos.add(-3, -3), sz.add(6, 6));
        g.chcolor(35, 35, 35, 192);
        g.frect(pos.add(-2, -2), sz.add(4, 4));
        g.chcolor();
        g.image(tt, pos);
      }
    }
    Resource curs = ui.root.getcurs(mousepos);
    if (!curs.loading) {
      if (cursmode == "awt") {
        if (curs != lastcursor) {
          try {
            setCursor(makeawtcurs(curs.layer(Resource.imgc).img, curs.layer(Resource.negc).cc));
            ark.bot.cursor_name = curs.name;
            ark.bot.cursor_name = ark.bot.cursor_name.replace("gfx/hud/curs/", "");
            lastcursor = curs;
          } catch (Exception e) {
            cursmode = "tex";
          }
        }
      } else if (cursmode == "tex") {
        Coord dc = mousepos.add(curs.layer(Resource.negc).cc.inv());
        g.image(curs.layer(Resource.imgc), dc);
      }
    }
  }