Beispiel #1
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();
  }
Beispiel #2
0
 public static BufferedImage longtip(GItem item, List<ItemInfo> info) {
   BufferedImage img = ItemInfo.longtip(info);
   Resource.Pagina pg = item.res.get().layer(Resource.pagina);
   if (pg != null) img = ItemInfo.catimgs(0, img, RichText.render("\n" + pg.text, 200).img);
   return (img);
 }
Beispiel #3
0
  public Object tooltip(Coord mc, Widget prev) {
    Resource tres = null;
    Coord c;
    if (qmod != null) {
      c = new Coord(xoff, qmy);
      try {
        for (Indir<Resource> qm : qmod) {
          Tex t = qm.get().layer(Resource.imgc).tex();
          Coord sz = t.sz();
          try {
            Glob.CAttr attr = ui.gui.chrwdg.findattr(qm.get().basename());
            if (attr != null) {
              sz = sz.add(attr.comptex().sz().x + 8, 0);
            }
          } catch (Exception ignored) {
          }

          if (mc.isect(c, sz)) return (qm.get().layer(Resource.tooltip).t);
          c = c.add(sz.x + 1, 0);
        }
      } catch (Loading l) {
      }
    }
    find:
    {
      c = new Coord(xoff, 0);
      for (Spec s : inputs) {
        if (mc.isect(c, Inventory.invsq.sz())) {
          tres = s.res.get();
          break find;
        }
        c = c.add(31, 0);
      }
      c = new Coord(xoff, outy);
      for (Spec s : outputs) {
        if (mc.isect(c, Inventory.invsq.sz())) {
          tres = s.res.get();
          break find;
        }
        c = c.add(31, 0);
      }
    }
    Resource.Tooltip tt;
    if ((tres == null) || ((tt = tres.layer(Resource.tooltip)) == null)) return (null);
    if (lasttip != tres) {
      lasttip = tres;
      stip = ltip = null;
    }
    long now = System.currentTimeMillis();
    boolean sh = true;
    if (prev != this) hoverstart = now;
    else if (now - hoverstart > 1000) sh = false;
    if (sh) {
      if (stip == null) stip = Text.render(tt.t);
      return (stip);
    } else {
      if (ltip == null) {
        String t = tt.t;
        Resource.Pagina p = tres.layer(Resource.pagina);
        if (p != null) t += "\n\n" + tres.layer(Resource.pagina).text;
        ltip = RichText.render(t, 300);
      }
      return (ltip);
    }
  }