private Layer redraw(final int z) { final ArrayList<Sprite.Part> parts = new ArrayList<Sprite.Part>(); Sprite.Drawer drw = new Sprite.Drawer() { public void addpart(Sprite.Part p) { if (p.z == z) parts.add(p); } }; for (Sprite spr : sprites.values()) { if (spr != null) spr.setup(drw, Coord.z, Coord.z); } Collections.sort(parts, Sprite.partcmp); Coord ul = new Coord(0, 0); Coord lr = new Coord(0, 0); for (Sprite.Part part : parts) { if (part.ul.x < ul.x) ul.x = part.ul.x; if (part.ul.y < ul.y) ul.y = part.ul.y; if (part.lr.x > lr.x) lr.x = part.lr.x; if (part.lr.y > lr.y) lr.y = part.lr.y; } BufferedImage buf = TexI.mkbuf(lr.add(ul.inv()).add(1, 1)); Graphics g = buf.getGraphics(); /* g.setColor(java.awt.Color.RED); g.fillRect(0, 0, buf.getWidth(), buf.getHeight()); */ for (Sprite.Part part : parts) { part.cc = part.cc.add(ul.inv()); part.draw(buf, g); } g.dispose(); return (new Layer(buf, ul.inv())); }
public void update(Coord c1, Coord c2) { if (!c1.equals(this.c1) || !c2.equals(this.c2)) { olseq++; this.c1 = c1; this.c2 = c2; } }
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 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 void mousemove(Coord c) { for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) { if (!wdg.visible) continue; Coord cc = xlate(wdg.c, true); wdg.mousemove(c.add(cc.inv())); } }
public void mousemove(Coord c) { if (dm) { this.c = this.c.add(c.add(doff.inv())); } else { super.mousemove(c); } }
public int getol(Coord tc) { Grid g = getgridt(tc); int ol = g.getol(tc.sub(g.ul)); for (Overlay lol : ols) { if (tc.isect(lol.c1, lol.c2.add(lol.c1.inv()).add(new Coord(1, 1)))) ol |= lol.mask; } return (ol); }
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)))))); }
public Coord drawoff() { Coord ret = Coord.z; DrawOffset dro = getattr(DrawOffset.class); if (dro != null) ret = ret.add(dro.off); Following flw = getattr(Following.class); if (flw != null) ret = ret.add(flw.doff); return (ret); }
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 Coord contentsz() { Coord max = new Coord(0, 0); for (Widget wdg = child; wdg != null; wdg = wdg.next) { if (!wdg.visible) continue; Coord br = wdg.c.add(wdg.sz); if (br.x > max.x) max.x = br.x; if (br.y > max.y) max.y = br.y; } return (max); }
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; }
public void mousemove(Coord c) { if (dm && !Config.global_ui_lock) { if (ui.mainview != null && avagob == ui.mainview.playergob) { this.c = this.c.add(c.add(doff.inv())); } else if (parent instanceof Partyview) { ((Partyview) parent).moveparty(c.add(doff.inv())); } } else { super.mousemove(c); } }
public boolean dropthing(Widget w, Coord c, Object thing) { if (w instanceof DropTarget) { if (((DropTarget) w).dropthing(c, thing)) return (true); } for (Widget wdg = w.lchild; wdg != null; wdg = wdg.prev) { Coord cc = w.xlate(wdg.c, true); if (c.isect(cc, wdg.sz)) { if (dropthing(wdg, c.add(cc.inv()), thing)) return (true); } } return (false); }
public boolean mousewheel(Coord c, int amount) { for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) { if (!wdg.visible) continue; Coord cc = xlate(wdg.c, true); if (c.isect(cc, wdg.sz)) { if (wdg.mousewheel(c.add(cc.inv()), amount)) { return (true); } } } return (false); }
public void ivneigh(Coord nc) { Coord cc = new Coord(); for (cc.y = 0; cc.y < cutn.y; cc.y++) { for (cc.x = 0; cc.x < cutn.x; cc.x++) { if ((((nc.x < 0) && (cc.x == 0)) || ((nc.x > 0) && (cc.x == cutn.x - 1)) || (nc.x == 0)) && (((nc.y < 0) && (cc.y == 0)) || ((nc.y > 0) && (cc.y == cutn.y - 1)) || (nc.y == 0))) { buildcut(new Coord(cc)); } } } }
public void reqarea(Coord ul, Coord br) { ul = ul.div(cutsz); br = br.div(cutsz); Coord rc = new Coord(); for (rc.y = ul.y; rc.y <= br.y; rc.y++) { for (rc.x = ul.x; rc.x <= br.x; rc.x++) { try { getcut(new Coord(rc)); } catch (Loading e) { } } } }
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 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())); } }); } }
public Resource getcurs(Coord c) { Resource ret; for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) { if (!wdg.visible) continue; Coord cc = xlate(wdg.c, true); if (c.isect(cc, wdg.sz)) { if ((ret = wdg.getcurs(c.add(cc.inv()))) != null) return (ret); } } try { return ((cursor == null) ? null : cursor.get()); } catch (Loading l) { return (null); } }
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 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 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); }
public Message messageat(Coord c, Coord hc) { int y = -sb.val; synchronized (msgs) { for (Message msg : msgs) { Coord sz = msg.sz(); if ((c.y >= y) && (c.y < y + sz.y)) { if (hc != null) { hc.x = c.x; hc.y = c.y - y; } return (msg); } y += sz.y; } } return (null); }
public ChatUI(Coord c, int w, Widget parent) { super(c.add(0, -50), new Coord(w, 50), parent); chansel = new Selector(Coord.z, new Coord(selw, sz.y)); chansel.hide(); base = c; setfocusctl(true); setcanfocus(false); }
public Gob findicongob(Coord c) { 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); Coord sz = icon.tex().sz(); if (c.isect(gc.sub(sz.div(2)), sz)) return (gob); } } catch (Loading l) { } } } return (null); }
protected Coord getOptCoord(String opt, Coord def) { synchronized (Config.window_props) { try { return new Coord(Config.window_props.getProperty(name + opt, def.toString())); } catch (Exception e) { return def; } } }
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 Object tooltip(Coord c, Widget prev) { if (prev != this) prevtt = null; if (tooltip != null) { prevtt = null; return (tooltip); } for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) { if (!wdg.visible) continue; Coord cc = xlate(wdg.c, true); if (c.isect(cc, wdg.sz)) { Object ret = wdg.tooltip(c.add(cc.inv()), prevtt); if (ret != null) { prevtt = wdg; return (ret); } } } prevtt = null; return (tooltip(c, prev == this)); }
private void invalidate() { for (int y = 0; y < cutn.y; y++) { for (int x = 0; x < cutn.x; x++) buildcut(new Coord(x, y)); } fo = null; for (Coord ic : new Coord[] { new Coord(-1, -1), new Coord(0, -1), new Coord(1, -1), new Coord(-1, 0), new Coord(1, 0), new Coord(-1, 1), new Coord(0, 1), new Coord(1, 1) }) { Grid ng = grids.get(gc.add(ic)); if (ng != null) ng.ivneigh(ic.inv()); } loaded = true; }