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); }
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); } }
public LoginScreen(Widget parent) { super(Coord.z, CustomConfig.windowSize, parent); setfocustab(true); parent.setfocus(this); new Img(CustomConfig.windowCenter.sub(bg.sz().div(2)), bg, this); new Img(CustomConfig.windowCenter.add(20, -85).sub(logo.sz().div(2)), logo, this); }
public void draw(GOut g) { Tex at = null; if (none) { } else if (myown != null) { at = myown; } else { Gob gob = ui.sess.glob.oc.getgob(avagob); Avatar ava = null; if (gob != null) ava = gob.getattr(Avatar.class); if (ava != null) at = ava.rend; } GOut g2 = g.reclip(Window.wbox.tloff().add(unborder.inv()), asz); int yo; if (at == null) { at = missing; yo = 0; } else { g2.image(Equipory.bg, new Coord(Equipory.bg.sz().x / 2 - asz.x / 2, 20).inv()); yo = (20 * asz.y) / dasz.y; } Coord tsz = new Coord((at.sz().x * asz.x) / dasz.x, (at.sz().y * asz.y) / dasz.y); g2.image(at, new Coord(tsz.x / 2 - asz.x / 2, yo).inv(), tsz); g.chcolor(color); Window.wbox.draw(g, Coord.z, asz.add(Window.wbox.bisz()).add(unborder.mul(2).inv())); }
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(); }
public void mousemove(Coord c) { if (drag) { double a = (double) (c.y - (sflarp.sz().y / 2)) / (double) (sz.y - sflarp.sz().y); if (a < 0) a = 0; if (a > 1) a = 1; val = (int) Math.round(a * (max - min)) + min; changed(); } }
public void draw(GOut g) { if (vis()) { int cx = (sflarp.sz().x / 2) - (schain.sz().x / 2); for (int y = 0; y < sz.y; y += schain.sz().y - 1) g.image(schain, new Coord(cx, y)); double a = (double) val / (double) (max - min); int fy = (int) ((sz.y - sflarp.sz().y) * a); g.image(sflarp, new Coord(0, fy)); } }
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); }
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())); } }); } }
@Override public void mousemove(Coord c) { if (sdrag != null) { double a = (double) (c.y - (sflarp.sz().y / 2)) / (double) (sz.y - sflarp.sz().y); if (a < 0) { a = 0; } if (a > 1) { a = 1; } cury = (int) (a * (maxy - sz.y)) + sz.y; } }
@Override public boolean mousedown(Coord c, int button) { if (button != 1) { return (false); } int fx = sz.x - sflarp.sz().x; int cx = fx + (sflarp.sz().x / 2) - (schain.sz().x / 2); if ((maxy > sz.y) && (c.x >= fx)) { sdrag = ui.grabmouse(this); mousemove(c); return (true); } return (false); }
public void drawicons(GOut g) { OCache oc = ui.sess.glob.oc; synchronized (oc) { for (Gob gob : oc) { try { GobIcon icon = gob.getattr(GobIcon.class); if (icon != null) { Coord gc = p2c(gob.rc); Tex tex = icon.tex(); g.image(tex, gc.sub(tex.sz().div(2))); } } catch (Loading l) { } } } }
public void drawmain(GOut g, Tex tex) { g.image(tex, Coord.z); if (tex != ltex) { resize(upsize(tex.sz())); ltex = tex; } }
public EquipBelt(String name, int... slotIndexes) { super(name, sq.sz()); List<Slot> slots = new ArrayList<Slot>(slotIndexes.length); for (int i = 0; i < slotIndexes.length; i++) slots.add(new EquipSlot(slotIndexes[i], keys[i], 1, "Shift " + (i + 1) % 10)); slots.add(new HandSlot(KeyEvent.VK_E, 0, "E")); addSlots(slots); }
@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)); } }
public Sprite create(Owner owner, Resource res, Message sdt) { int m = sdt.uint8(); GrowingPlant spr = new GrowingPlant(owner, res); spr.addnegative(); Random rnd = owner.mkrandoom(); int n = Config.simple_plants ? 1 : num; for (int i = 0; i < n; i++) { Coord c; if (Config.simple_plants) { c = neg.bc.add(neg.bs).sub(5, 5); } else { c = new Coord(rnd.nextInt(neg.bs.x), rnd.nextInt(neg.bs.y)).add(neg.bc); } Tex s = strands[m][rnd.nextInt(strands[m].length)]; spr.add(s, 0, MapView.m2s(c), new Coord(s.sz().x / 2, s.sz().y).inv()); } return (spr); }
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())); } }); } }
public void draw(GOut g) { updatepos(); double now = System.currentTimeMillis() / 1000.0; for (Buff buff : fv.buffs.children(Buff.class)) buff.draw( g.reclip( pcc.add(-buff.c.x - Buff.cframe.sz().x - 20, buff.c.y + pho - Buff.cframe.sz().y), buff.sz)); if (fv.current != null) { for (Buff buff : fv.current.buffs.children(Buff.class)) buff.draw(g.reclip(pcc.add(buff.c.x + 20, buff.c.y + pho - Buff.cframe.sz().y), buff.sz)); g.aimage(ip.get().tex(), pcc.add(-75, 0), 1, 0.5); g.aimage(oip.get().tex(), pcc.add(75, 0), 0, 0.5); } if (now < fv.atkct) { int w = (int) ((fv.atkct - now) * 20); g.chcolor(255, 0, 128, 255); g.frect(pcc.add(-w, 20), new Coord(w * 2, 15)); g.chcolor(); } Coord ca = pcc.add(-(actions.length * actpitch) / 2, 45); for (int i = 0; i < actions.length; i++) { Indir<Resource> act = actions[i]; try { if (act != null) { Tex img = act.get().layer(Resource.imgc).tex(); g.image(img, ca); g.image(dyn[i] ? lframe : Buff.frame, ca.sub(Buff.imgoff)); if (i == use) { g.chcolor(255, 0, 128, 255); Coord cc = ca.add(img.sz().x / 2, img.sz().y + 5); g.frect(cc.sub(2, 2), new Coord(5, 5)); g.chcolor(); } } } catch (Loading l) { } ca.x += actpitch; } }
/* Draw texture at c, clipping everything outside ul to ul + sz. */ public void image(Tex tex, Coord c, Coord ul, Coord sz) { if (tex == null) return; st.set(cur2d); ul = ul.add(this.tx); Coord br = ul.add(sz); if (ul.x < this.ul.x) ul.x = this.ul.x; if (ul.y < this.ul.y) ul.y = this.ul.y; if (br.x > this.ul.x + this.sz.x) br.x = this.ul.x + this.sz.x; if (br.y > this.ul.y + this.sz.y) br.y = this.ul.y + this.sz.y; tex.crender(this, c.add(this.tx), ul, br.sub(ul)); checkerr(); }
public Object tooltip(Coord c, Widget prev) { for (Buff buff : fv.buffs.children(Buff.class)) { Coord dc = pcc.add(-buff.c.x - Buff.cframe.sz().x - 20, buff.c.y + pho - Buff.cframe.sz().y); if (c.isect(dc, buff.sz)) { Object ret = buff.tooltip(c.sub(dc), prevtt); if (ret != null) { prevtt = buff; return (ret); } } } if (fv.current != null) { for (Buff buff : fv.current.buffs.children(Buff.class)) { Coord dc = pcc.add(buff.c.x + 20, buff.c.y + pho - Buff.cframe.sz().y); if (c.isect(dc, buff.sz)) { Object ret = buff.tooltip(c.sub(dc), prevtt); if (ret != null) { prevtt = buff; return (ret); } } } } Coord ca = pcc.add(-(actions.length * actpitch) / 2, 45); for (int i = 0; i < actions.length; i++) { Indir<Resource> act = actions[i]; try { if (act != null) { Tex img = act.get().layer(Resource.imgc).tex(); if (c.isect(ca, img.sz())) { if (dyn[i]) return ("Combat discovery"); return (act.get().layer(Resource.tooltip).t); } } } catch (Loading l) { } ca.x += actpitch; } return (null); }
public void draw(GOut g) { super.draw(g); if (lvlmask != null) { long now = System.currentTimeMillis(); if (now - lvltime > 1000) { lvlmask.dispose(); lvlmask = null; } else { g.chcolor(255, 255, 255, 255 - (int) ((255 * (now - lvltime)) / 1000)); g.image(lvlmask, Coord.z); } } }
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; }
/* XXX: Some strange javac bug seems to make it resolve the * trans() references to the wrong signature, thus the name * distinction. */ public void _faces( MapMesh m, Tile t, int z, Surface.Vertex[] v, float[] tcx, float[] tcy, int[] f) { Tex tex = t.tex(); float tl = tex.tcx(0), tt = tex.tcy(0), tw = tex.tcx(tex.sz().x) - tl, th = tex.tcy(tex.sz().y) - tt; GLState st = stfor(tex, z, t.t != 'g'); MeshBuf buf = MapMesh.Model.get(m, st); MeshBuf.Tex btex = buf.layer(MeshBuf.tex); MeshVertex[] mv = new MeshVertex[v.length]; for (int i = 0; i < v.length; i++) { mv[i] = new MeshVertex(buf, v[i]); btex.set(mv[i], new Coord3f(tl + (tw * tcx[i]), tt + (th * tcy[i]), 0)); } for (int i = 0; i < f.length; i += 3) buf.new Face(mv[f[i]], mv[f[i + 1]], mv[f[i + 2]]); }
public void image(BufferedImage img, Coord c) { if (img == null) return; Tex tex = new TexI(img); image(tex, c); tex.dispose(); }
public void image(Tex tex, Coord c, Coord ul, Coord sz) { if (tex == null) return; tex.crender(this, c.add(this.ul), this.ul.add(ul), sz); checkerr(); }
public void aimage(Tex tex, Coord c, double ax, double ay) { Coord sz = tex.sz(); image(tex, c.add((int) ((double) sz.x * -ax), (int) ((double) sz.y * -ay))); }
public void move(Coord c) { this.c = c.add(-sflarp.sz().x, 0); }
public void resize(int h) { super.resize(new Coord(sflarp.sz().x, h)); }
public Scrollbar(Coord c, int h, Widget parent, int min, int max) { super(c.add(-sflarp.sz().x, 0), new Coord(sflarp.sz().x, h), parent); this.min = min; this.max = max; val = min; }
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); }