コード例 #1
0
ファイル: Window.java プロジェクト: RaynsAS/Custom-Salem
 public void draw(GOut g) {
   g.chcolor(0, 0, 0, 160);
   if (ctl == null || csz == null) {
     return;
   }
   g.frect(ctl, csz);
   g.chcolor();
   cdraw(g.reclip(xlate(Coord.z, true), asz));
   if (cap != null) {
     topless.draw(g, new Coord(0, th), sz.sub(0, th));
     g.image(tleft, Coord.z);
     Coord tmul = new Coord(tleft.sz().x, tdh);
     Coord tmbr = new Coord(sz.x - tright.sz().x, th);
     for (int x = tmul.x; x < tmbr.x; x += tmain.sz().x) {
       g.image(tmain, new Coord(x, tdh), tmul, tmbr);
     }
     g.image(tright, new Coord(sz.x - tright.sz().x, tdh));
     g.image(cap.tex(), capc.sub(0, cap.sz().y));
   } else {
     wbox.draw(g, Coord.z, sz);
   }
   /*
   if(cap != null) {
       GOut cg = og.reclip(new Coord(0, -7), sz.add(0, 7));
       int w = cap.tex().sz().x;
       cg.image(cl, new Coord((sz.x / 2) - (w / 2) - cl.sz().x, 0));
       cg.image(cm, new Coord((sz.x / 2) - (w / 2), 0), new Coord(w, cm.sz().y));
       cg.image(cr, new Coord((sz.x / 2) + (w / 2), 0));
       cg.image(cap.tex(), new Coord((sz.x / 2) - (w / 2), 0));
   }
   */
   super.draw(g);
 }
コード例 #2
0
ファイル: Textlog.java プロジェクト: TheKrush/hafen-client
 @Override
 public void draw(GOut g) {
   Coord dc = new Coord();
   for (dc.y = 0; dc.y < sz.y; dc.y += texpap.sz().y) {
     for (dc.x = 0; dc.x < sz.x; dc.x += texpap.sz().x) {
       g.image(texpap, dc);
     }
   }
   g.chcolor();
   int y = -cury;
   synchronized (lines) {
     for (Text line : lines) {
       int dy1 = sz.y + y;
       int dy2 = dy1 + line.sz().y;
       if ((dy2 > 0) && (dy1 < sz.y)) {
         g.image(line.tex(), new Coord(margin, dy1));
       }
       y += line.sz().y;
     }
   }
   if (maxy > sz.y) {
     int fx = sz.x - sflarp.sz().x;
     int cx = fx + (sflarp.sz().x / 2) - (schain.sz().x / 2);
     for (y = 0; y < sz.y; y += schain.sz().y - 1) {
       g.image(schain, new Coord(cx, y));
     }
     double a = (double) (cury - sz.y) / (double) (maxy - sz.y);
     int fy = (int) ((sz.y - sflarp.sz().y) * a);
     g.image(sflarp, new Coord(fx, fy));
   }
 }
コード例 #3
0
ファイル: GOut.java プロジェクト: krvd/hnh_union
 public void atext(String text, Coord c, double ax, double ay) {
   Text t = Text.render(text);
   Tex T = t.tex();
   Coord sz = t.sz();
   image(T, c.add((int) ((double) sz.x * -ax), (int) ((double) sz.y * -ay)));
   T.dispose();
   checkerr();
 }
コード例 #4
0
  public void draw(GOut g) {
    Coord c = new Coord(xoff, 0);
    for (Spec s : inputs) {
      GOut sg = g.reclip(c, Inventory.invsq.sz());
      sg.image(Inventory.invsq, Coord.z);
      s.draw(sg);
      c = c.add(Inventory.sqsz.x, 0);
    }
    if (qmod != null) {
      g.image(qmodl.tex(), new Coord(0, qmy + 4));
      c = new Coord(xoff, qmy);
      int mx = -1;
      int pw = 0;
      int vl = 1;
      for (Indir<Resource> qm : qmod) {
        try {
          Tex t = qm.get().layer(Resource.imgc).tex();
          g.image(t, c);
          c = c.add(t.sz().x + 1, 0);
          if (c.x > mx) mx = c.x;

          try {
            Glob.CAttr attr = ui.gui.chrwdg.findattr(qm.get().basename());
            if (attr != null) {
              pw++;
              vl *= attr.comp;
              Tex txt = attr.comptex();
              g.image(txt, c);
              c = c.add(txt.sz().x + 8, 0);
            }
          } catch (Exception ignored) {
          }

        } catch (Loading l) {
        }
      }
      if (pw > 0) {
        g.image(
            Text.renderstroked(
                    String.format("Cap: %.0f", Math.floor(Math.pow(vl, 1.0f / pw))),
                    Color.WHITE,
                    Color.BLACK,
                    new Text.Foundry(Text.fraktur, 14).aa(true))
                .tex(),
            new Coord(mx + 30, qmy));
      }
    }
    c = new Coord(xoff, outy);
    for (Spec s : outputs) {
      GOut sg = g.reclip(c, Inventory.invsq.sz());
      sg.image(Inventory.invsq, Coord.z);
      s.draw(sg);
      c = c.add(Inventory.sqsz.x, 0);
    }
    super.draw(g);
  }
コード例 #5
0
ファイル: WItem.java プロジェクト: dolda2000/salem-client
 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
 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;
 }
コード例 #7
0
ファイル: OptWnd.java プロジェクト: EnderWiggin/hafen-client
    public CFGBox(String lbl, CFG<Boolean> cfg, String tip, boolean observe) {
      super(lbl);

      this.cfg = cfg;
      defval();
      if (tip != null) {
        tooltip = Text.render(tip).tex();
      }
      if (observe) {
        cfg.observe(this);
      }
    }
コード例 #8
0
ファイル: Gobble.java プロジェクト: dolda2000/salem-client
 public void tick(double dt) {
   if (updt) {
     nw = 0;
     int aw = 0;
     for (TypeMod m : mods) {
       if (m.rn == null) {
         try {
           BufferedImage img = m.t.get().layer(Resource.imgc).img;
           String nm = m.t.get().layer(Resource.tooltip).t;
           Text rt = tnf.render(nm);
           int h = Inventory.sqsz.y;
           BufferedImage buf = TexI.mkbuf(new Coord(img.getWidth() + 10 + rt.sz().x, h));
           Graphics g = buf.getGraphics();
           g.drawImage(img, 0, (h - img.getHeight()) / 2, null);
           g.drawImage(rt.img, img.getWidth() + 10, (h - rt.sz().y) / 2, null);
           g.dispose();
           m.rn = new TexI(rasterimg(blurmask2(buf.getRaster(), 2, 1, new Color(32, 0, 0))));
           m.rh = new TexI(rasterimg(blurmask2(buf.getRaster(), 2, 1, new Color(192, 128, 0))));
         } catch (Loading l) {
         }
       }
       if (m.ra == null) {
         Text rt =
             tnf.render(
                 (int) Math.round(m.a * 100) + "%",
                 new Color(255, (int) (255 * m.a), (int) (255 * m.a)));
         m.ra = new TexI(rasterimg(blurmask2(rt.img.getRaster(), 2, 1, new Color(0, 0, 0))));
       }
       nw = Math.max(nw, m.rn.sz().x);
       aw = Math.max(aw, m.ra.sz().x);
     }
     int h = (Inventory.sqsz.y + 5) * mods.size();
     h += levels.sz().y + 20;
     resize(new Coord(Math.max(nw + 20 + aw, boxsz.x), h));
     this.c = Gobble.this.parentpos(parent).add(boxc).add(0, boxsz.y + 5);
     updt = false;
   }
 }
コード例 #9
0
ファイル: Textlog.java プロジェクト: TheKrush/hafen-client
 public void append(String line, Color col) {
   Text rl;
   if (quote) {
     line = RichText.Parser.quote(line);
   }
   if (col == null) {
     rl = foundry.render(line, sz.x - (margin * 2) - sflarp.sz().x);
   } else {
     rl = foundry.render(line, sz.x - (margin * 2) - sflarp.sz().x, TextAttribute.FOREGROUND, col);
   }
   synchronized (lines) {
     lines.add(rl);
     if ((maxLines > 0) && (lines.size() > maxLines)) {
       Text tl = lines.remove(0);
       int dy = tl.sz().y;
       maxy -= dy;
       cury -= dy;
     }
   }
   if (cury == maxy) {
     cury += rl.sz().y;
   }
   maxy += rl.sz().y;
 }
コード例 #10
0
ファイル: Widget.java プロジェクト: lcy03406/amber
  public void uimsg(String msg, Object... args) {
    if (msg == "tabfocus") {
      setfocustab(((Integer) args[0] != 0));
    } else if (msg == "act") {
      canactivate = (Integer) args[0] != 0;
    } else if (msg == "cancel") {
      cancancel = (Integer) args[0] != 0;
    } else if (msg == "autofocus") {
      autofocus = (Integer) args[0] != 0;
    } else if (msg == "focus") {
      Widget w = ui.widgets.get((Integer) args[0]);
      if (w != null) {
        if (w.canfocus) setfocus(w);
      }
    } else if (msg == "curs") {
      if (args.length == 0) cursor = null;
      else cursor = Resource.remote().load((String) args[0], (Integer) args[1]);
    } else if (msg == "tip") {
      int a = 0;
      Object tt = args[a++];
      if (tt instanceof String) {
        tooltip = Text.render((String) tt);
      } else if (tt instanceof Integer) {
        final Indir<Resource> tres = ui.sess.getres((Integer) tt);
        tooltip =
            new Indir<Tex>() {
              Text t = null;

              public Tex get() {
                if (t == null) {
                  Resource.Pagina pag;
                  try {
                    pag = tres.get().layer(Resource.pagina);
                  } catch (Loading e) {
                    return (null);
                  }
                  t = RichText.render(pag.text, 300);
                }
                return (t.tex());
              }
            };
      }
    } else {
      System.err.println("Unhandled widget message: " + msg);
    }
  }
コード例 #11
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);
      }
    }
  }
コード例 #12
0
ファイル: HavenPanel.java プロジェクト: ProPuke/hafen-client
  void rootdraw(GLState.Applier state, UI ui, BGL gl) {
    GLState.Buffer ibuf = new GLState.Buffer(state.cfg);
    gstate.prep(ibuf);
    ostate.prep(ibuf);
    GOut g = new GOut(gl, state.cgl, state.cfg, state, ibuf, new Coord(w, h));
    state.set(ibuf);

    g.state(ostate);
    g.apply();
    gl.glClearColor(0, 0, 0, 1);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    synchronized (ui) {
      ui.draw(g);
    }

    if (Config.dbtext) {
      int y = h - 150;
      FastText.aprintf(
          g,
          new Coord(10, y -= 15),
          0,
          1,
          "FPS: %d (%d%%, %d%% idle)",
          fps,
          (int) (uidle * 100.0),
          (int) (ridle * 100.0));
      Runtime rt = Runtime.getRuntime();
      long free = rt.freeMemory(), total = rt.totalMemory();
      FastText.aprintf(
          g,
          new Coord(10, y -= 15),
          0,
          1,
          "Mem: %,011d/%,011d/%,011d/%,011d",
          free,
          total - free,
          total,
          rt.maxMemory());
      FastText.aprintf(g, new Coord(10, y -= 15), 0, 1, "Tex-current: %d", TexGL.num());
      FastText.aprintf(g, new Coord(10, y -= 15), 0, 1, "GL progs: %d", g.st.numprogs());
      GameUI gi = ui.root.findchild(GameUI.class);
      if ((gi != null) && (gi.map != null)) {
        try {
          FastText.aprintf(
              g, new Coord(10, y -= 15), 0, 1, "MV pos: %s (%s)", gi.map.getcc(), gi.map.camera);
        } catch (Loading e) {
        }
        if (gi.map.rls != null)
          FastText.aprintf(
              g,
              new Coord(10, y -= 15),
              0,
              1,
              "Rendered: %,d+%,d(%,d)",
              gi.map.rls.drawn,
              gi.map.rls.instanced,
              gi.map.rls.instancified);
      }
      if (Resource.remote().qdepth() > 0)
        FastText.aprintf(
            g,
            new Coord(10, y -= 15),
            0,
            1,
            "RQ depth: %d (%d)",
            Resource.remote().qdepth(),
            Resource.remote().numloaded());
    }
    Object tooltip;
    try {
      synchronized (ui) {
        tooltip = ui.root.tooltip(mousepos, ui.root);
      }
    } catch (Loading e) {
      tooltip = "...";
    }
    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 Indir<?>) {
        Indir<?> t = (Indir<?>) tooltip;
        Object o = t.get();
        if (o instanceof Tex) tt = (Tex) o;
      } 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);
    }
    ui.lasttip = tooltip;
    Resource curs = ui.root.getcurs(mousepos);
    if (curs != null) {
      if (cursmode == "awt") {
        if (curs != lastcursor) {
          try {
            setCursor(makeawtcurs(curs.layer(Resource.imgc).img, curs.layer(Resource.negc).cc));
            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);
      }
    }
    state.clean();
    GLObject.disposeall(state.cgl, gl);
  }
コード例 #13
0
ファイル: Widget.java プロジェクト: lcy03406/amber
 public void settip(String text) {
   tooltip = Text.render(text);
 }
コード例 #14
0
ファイル: ChatUI.java プロジェクト: Trojanz/Custom-Salem
 public Coord sz() {
   return (t.sz());
 }
コード例 #15
0
ファイル: ChatUI.java プロジェクト: Trojanz/Custom-Salem
 public Coord sz() {
   if (r == null) return (text().sz());
   else return (r.sz());
 }
コード例 #16
0
ファイル: ChatUI.java プロジェクト: Trojanz/Custom-Salem
 public Tex tex() {
   return (t.tex());
 }
コード例 #17
0
public class Makewindow extends Widget {
  Widget obtn, cbtn;
  List<Spec> inputs = Collections.emptyList();
  List<Spec> outputs = Collections.emptyList();
  List<Indir<Resource>> qmod = null;
  static final Text qmodl = Text.render("Quality:");
  static Coord boff = new Coord(7, 9);
  final int xoff = 45, qmy = 38, outy = 65;
  public static final Text.Foundry nmf = new Text.Foundry(Text.serif, 20).aa(true);

  @RName("make")
  public static class $_ implements Factory {
    public Widget create(Widget parent, Object[] args) {
      return (new Makewindow((String) args[0]));
    }
  }

  public class Spec implements GSprite.Owner {
    public Indir<Resource> res;
    public MessageBuf sdt;
    public Tex num;
    private GSprite spr;

    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;
    }

    public void draw(GOut g) {
      try {
        if (spr == null) spr = GSprite.create(this, res.get(), sdt.clone());
        spr.draw(g);
      } catch (Loading e) {
      }
      if (num != null) g.aimage(num, Inventory.sqsz, 1.0, 1.0);
    }

    private Random rnd = null;

    public Random mkrandoom() {
      if (rnd == null) rnd = new Random();
      return (rnd);
    }

    public Resource getres() {
      return (res.get());
    }

    public Glob glob() {
      return (ui.sess.glob);
    }
  }

  public void tick(double dt) {
    for (Spec s : inputs) {
      if (s.spr != null) s.spr.tick(dt);
    }
    for (Spec s : outputs) {
      if (s.spr != null) s.spr.tick(dt);
    }
  }

  public Makewindow(String rcpnm) {
    add(new Label("Input:"), new Coord(0, 8));
    add(new Label("Result:"), new Coord(0, outy + 8));
    obtn = add(new Button(85, "Craft"), new Coord(265, 75));
    cbtn = add(new Button(85, "Craft All"), new Coord(360, 75));
    pack();
    adda(new Label(rcpnm, nmf), sz.x, 0, 1, 0);
  }

  public void uimsg(String msg, Object... args) {
    if (msg == "inpop") {
      List<Spec> inputs = new LinkedList<Spec>();
      for (int i = 0; i < args.length; ) {
        int resid = (Integer) args[i++];
        Message sdt =
            (args[i] instanceof byte[]) ? new MessageBuf((byte[]) args[i++]) : MessageBuf.nil;
        int num = (Integer) args[i++];
        inputs.add(new Spec(ui.sess.getres(resid), sdt, num));
      }
      this.inputs = inputs;
    } else if (msg == "opop") {
      List<Spec> outputs = new LinkedList<Spec>();
      for (int i = 0; i < args.length; ) {
        int resid = (Integer) args[i++];
        Message sdt =
            (args[i] instanceof byte[]) ? new MessageBuf((byte[]) args[i++]) : MessageBuf.nil;
        int num = (Integer) args[i++];
        outputs.add(new Spec(ui.sess.getres(resid), sdt, num));
      }
      this.outputs = outputs;
    } else if (msg == "qmod") {
      List<Indir<Resource>> qmod = new ArrayList<Indir<Resource>>();
      for (Object arg : args) qmod.add(ui.sess.getres((Integer) arg));
      this.qmod = qmod;
    } else {
      super.uimsg(msg, args);
    }
  }

  public void draw(GOut g) {
    Coord c = new Coord(xoff, 0);
    for (Spec s : inputs) {
      GOut sg = g.reclip(c, Inventory.invsq.sz());
      sg.image(Inventory.invsq, Coord.z);
      s.draw(sg);
      c = c.add(Inventory.sqsz.x, 0);
    }
    if (qmod != null) {
      g.image(qmodl.tex(), new Coord(0, qmy + 4));
      c = new Coord(xoff, qmy);
      int mx = -1;
      int pw = 0;
      int vl = 1;
      for (Indir<Resource> qm : qmod) {
        try {
          Tex t = qm.get().layer(Resource.imgc).tex();
          g.image(t, c);
          c = c.add(t.sz().x + 1, 0);
          if (c.x > mx) mx = c.x;

          try {
            Glob.CAttr attr = ui.gui.chrwdg.findattr(qm.get().basename());
            if (attr != null) {
              pw++;
              vl *= attr.comp;
              Tex txt = attr.comptex();
              g.image(txt, c);
              c = c.add(txt.sz().x + 8, 0);
            }
          } catch (Exception ignored) {
          }

        } catch (Loading l) {
        }
      }
      if (pw > 0) {
        g.image(
            Text.renderstroked(
                    String.format("Cap: %.0f", Math.floor(Math.pow(vl, 1.0f / pw))),
                    Color.WHITE,
                    Color.BLACK,
                    new Text.Foundry(Text.fraktur, 14).aa(true))
                .tex(),
            new Coord(mx + 30, qmy));
      }
    }
    c = new Coord(xoff, outy);
    for (Spec s : outputs) {
      GOut sg = g.reclip(c, Inventory.invsq.sz());
      sg.image(Inventory.invsq, Coord.z);
      s.draw(sg);
      c = c.add(Inventory.sqsz.x, 0);
    }
    super.draw(g);
  }

  private long hoverstart;
  private Resource lasttip;
  private Object stip, ltip;

  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);
    }
  }

  public void wdgmsg(Widget sender, String msg, Object... args) {
    if (sender == obtn) {
      if (msg == "activate") wdgmsg("make", 0);
      return;
    }
    if (sender == cbtn) {
      if (msg == "activate") wdgmsg("make", 1);
      return;
    }
    super.wdgmsg(sender, msg, args);
  }

  public boolean globtype(char ch, java.awt.event.KeyEvent ev) {
    if (ch == '\n') {
      wdgmsg("make", ui.modctrl ? 1 : 0);
      return (true);
    }
    return (super.globtype(ch, ev));
  }

  public void resize(Coord sz) {
    super.resize(sz);
    cbtn.c = sz.sub(cbtn.sz);
    obtn.c = sz.sub(obtn.sz).sub(cbtn.sz.x + 10, 0);
  }

  public static class MakePrep extends ItemInfo implements GItem.ColorInfo {
    private static final Color olcol = new Color(0, 255, 0, 64);

    public MakePrep(Owner owner) {
      super(owner);
    }

    public Color olcol() {
      return (olcol);
    }
  }
}
コード例 #18
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);
    }
  }
コード例 #19
0
 public Petal(String name) {
   super(Coord.z);
   this.name = name;
   text = ptf.render(name, ptc);
   resize(text.sz().x + 25, ph);
 }
コード例 #20
0
 public void draw(GOut g) {
   g.chcolor(new Color(255, 255, 255, (int) (255 * a)));
   g.image(pbg, new Coord(3, 3), new Coord(3, 3), sz.add(new Coord(-6, -6)));
   pbox.draw(g, Coord.z, sz);
   g.image(text.tex(), sz.div(2).sub(text.sz().div(2)));
 }