public class Scrollbar extends Widget { static Tex texpap = Resource.loadtex("gfx/hud/texpap"); static Tex schain = Resource.loadtex("gfx/hud/schain"); static Tex sflarp = Resource.loadtex("gfx/hud/sflarp"); public int val, min, max; private boolean drag = false; 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; } public void draw(GOut g) { if (max > min) { 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 boolean mousedown(Coord c, int button) { if (button != 1) return (false); if (max <= min) return (false); drag = true; ui.grabmouse(this); mousemove(c); return (true); } 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 boolean mouseup(Coord c, int button) { if (button != 1) return (false); if (!drag) return (false); drag = false; ui.grabmouse(null); return (true); } public void changed() {} public void ch(int a) { int val = this.val + a; if (val > max) val = max; if (val < min) val = min; this.val = val; } }
public IBox( String base, String ctl, String ctr, String cbl, String cbr, String bl, String br, String bt, String bb) { this( Resource.loadtex(base + "/" + ctl), Resource.loadtex(base + "/" + ctr), Resource.loadtex(base + "/" + cbl), Resource.loadtex(base + "/" + cbr), Resource.loadtex(base + "/" + bl), Resource.loadtex(base + "/" + br), Resource.loadtex(base + "/" + bt), Resource.loadtex(base + "/" + bb)); }
public class MenuGrid extends Widget { public static final Tex bg = Resource.loadtex("gfx/hud/invsq"); public static final Coord bgsz = bg.sz().add(-1, -1); public static final Pagina next = new Glob.Pagina(Resource.local().loadwait("gfx/hud/sc-next").indir()); public static final Pagina bk = new Glob.Pagina(Resource.local().loadwait("gfx/hud/sc-back").indir()); public static final RichText.Foundry ttfnd = new RichText.Foundry(TextAttribute.FAMILY, "SansSerif", TextAttribute.SIZE, 10); private static Coord gsz = new Coord(4, 4); private Pagina cur, pressed, dragging, layout[][] = new Pagina[gsz.x][gsz.y]; private UI.Grab grab; private int curoff = 0; private int pagseq = 0; private boolean loading = true; private Map<Character, Pagina> hotmap = new TreeMap<Character, Pagina>(); @RName("scm") public static class $_ implements Factory { public Widget create(Widget parent, Object[] args) { return (new MenuGrid()); } } public class PaginaException extends RuntimeException { public Pagina pag; public PaginaException(Pagina p) { super("Invalid pagina: " + p.res); pag = p; } } private boolean cons(Pagina p, Collection<Pagina> buf) { Pagina[] cp = new Pagina[0]; Collection<Pagina> open, close = new HashSet<Pagina>(); synchronized (ui.sess.glob.paginae) { open = new LinkedList<Pagina>(); for (Pagina pag : ui.sess.glob.paginae) { if (pag.newp == 2) { pag.newp = 0; pag.fstart = 0; } open.add(pag); } for (Pagina pag : ui.sess.glob.pmap.values()) { if (pag.newp == 2) { pag.newp = 0; pag.fstart = 0; } } } boolean ret = true; while (!open.isEmpty()) { Iterator<Pagina> iter = open.iterator(); Pagina pag = iter.next(); iter.remove(); try { AButton ad = pag.act(); if (ad == null) throw (new PaginaException(pag)); Pagina parent = paginafor(ad.parent); if ((pag.newp != 0) && (parent != null) && (parent.newp == 0)) { parent.newp = 2; parent.fstart = (parent.fstart == 0) ? pag.fstart : Math.min(parent.fstart, pag.fstart); } if (parent == p) buf.add(pag); else if ((parent != null) && !close.contains(parent) && !open.contains(parent)) open.add(parent); close.add(pag); } catch (Loading e) { ret = false; } } return (ret); } public MenuGrid() { super(bgsz.mul(gsz).add(1, 1)); } @Override protected void attach(UI ui) { super.attach(ui); Glob glob = ui.sess.glob; ObservableCollection<Pagina> p = glob.paginae; p.add(glob.paginafor(Resource.local().load("paginae/custom/plant-tree"))); p.add(glob.paginafor(Resource.local().load("paginae/custom/fill-trough"))); p.add(glob.paginafor(Resource.local().load("paginae/custom/fill-coop"))); p.add(glob.paginafor(Resource.local().load("paginae/custom/fill-tarkiln"))); p.add(glob.paginafor(Resource.local().load("paginae/custom/pick-mussels"))); p.add(glob.paginafor(Resource.local().load("paginae/custom/fill-smelter"))); p.add(glob.paginafor(Resource.local().load("paginae/custom/arrow-autoloader"))); } private static Comparator<Pagina> sorter = new Comparator<Pagina>() { public int compare(Pagina a, Pagina b) { AButton aa = a.act(), ab = b.act(); if ((aa.ad.length == 0) && (ab.ad.length > 0)) return (-1); if ((aa.ad.length > 0) && (ab.ad.length == 0)) return (1); return (aa.name.compareTo(ab.name)); } }; private void updlayout() { synchronized (ui.sess.glob.paginae) { List<Pagina> cur = new ArrayList<Pagina>(); loading = !cons(this.cur, cur); Collections.sort(cur, sorter); int i = curoff; hotmap.clear(); for (int y = 0; y < gsz.y; y++) { for (int x = 0; x < gsz.x; x++) { Pagina btn = null; if ((this.cur != null) && (x == gsz.x - 1) && (y == gsz.y - 1)) { btn = bk; } else if ((cur.size() > ((gsz.x * gsz.y) - 1)) && (x == gsz.x - 2) && (y == gsz.y - 1)) { btn = next; } else if (i < cur.size()) { Resource.AButton ad = cur.get(i).act(); if (ad.hk != 0) hotmap.put(Character.toUpperCase(ad.hk), cur.get(i)); btn = cur.get(i++); } layout[x][y] = btn; } } pagseq = ui.sess.glob.pagseq; } } private static Text rendertt(Resource res, boolean withpg) { Resource.AButton ad = res.layer(Resource.action); Resource.Pagina pg = res.layer(Resource.pagina); String tt = ad.name; int pos = tt.toUpperCase().indexOf(Character.toUpperCase(ad.hk)); if (pos >= 0) tt = tt.substring(0, pos) + "$b{$col[255,128,0]{" + tt.charAt(pos) + "}}" + tt.substring(pos + 1); else if (ad.hk != 0) tt += " [" + ad.hk + "]"; if (withpg && (pg != null)) { tt += "\n\n" + pg.text; } return (ttfnd.render(tt, 300)); } private static Map<Pagina, Tex> glowmasks = new WeakHashMap<Pagina, Tex>(); private Tex glowmask(Pagina pag) { Tex ret = glowmasks.get(pag); if (ret == null) { ret = new TexI( PUtils.glowmask( PUtils.glowmask(pag.res().layer(Resource.imgc).img.getRaster()), 4, new Color(32, 255, 32))); glowmasks.put(pag, ret); } return (ret); } 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())); } }); } } private Pagina curttp = null; private boolean curttl = false; private Text curtt = null; private long hoverstart; public Object tooltip(Coord c, Widget prev) { Pagina pag = bhit(c); long now = System.currentTimeMillis(); if ((pag != null) && (pag.act() != null)) { if (prev != this) hoverstart = now; boolean ttl = (now - hoverstart) > 500; if ((pag != curttp) || (ttl != curttl)) { curtt = rendertt(pag.res(), ttl); curttp = pag; curttl = ttl; } return (curtt); } else { hoverstart = now; return (""); } } private Pagina bhit(Coord c) { Coord bc = c.div(bgsz); if ((bc.x >= 0) && (bc.y >= 0) && (bc.x < gsz.x) && (bc.y < gsz.y)) return (layout[bc.x][bc.y]); else return (null); } public boolean mousedown(Coord c, int button) { Pagina h = bhit(c); if ((button == 1) && (h != null)) { pressed = h; grab = ui.grabmouse(this); } return (true); } public void mousemove(Coord c) { if ((dragging == null) && (pressed != null)) { Pagina h = bhit(c); if (h != pressed) dragging = pressed; } } private Pagina paginafor(Resource.Named res) { return (ui.sess.glob.paginafor(res)); } private void use(Pagina r, boolean reset) { Collection<Pagina> sub = new LinkedList<Pagina>(), cur = new LinkedList<Pagina>(); cons(r, sub); cons(this.cur, cur); if (sub.size() > 0) { this.cur = r; curoff = 0; } else if (r == bk) { this.cur = paginafor(this.cur.act().parent); curoff = 0; } else if (r == next) { if ((curoff + 14) >= cur.size()) curoff = 0; else curoff += 14; } else { r.newp = 0; use(r); if (reset) this.cur = null; curoff = 0; } updlayout(); } public boolean use(Pagina r) { String[] ad = r.act().ad; if ((ad == null) || (ad.length < 1)) { return false; } if (ad[0].equals("@")) { usecustom(ad); } else { wdgmsg("act", (Object[]) ad); } return true; } private void usecustom(String[] ad) { if (ad[1].equals("plant-tree")) { if (ui != null && ui.gui != null) { ui.gui.add(new TreePlantTool(ui.gui), 300, 200); } } else if (ad[1].equals("fill-trough")) { ui.gui.tasks.add(new FeedEdiblesTask("trough")); } else if (ad[1].equals("fill-coop")) { ui.gui.tasks.add(new FeedEdiblesTask("chickencoop")); } else if (ad[1].equals("fill-tarkiln")) { ui.gui.tasks.add(new FeedBlocksTask("tarkiln")); } else if (ad[1].equals("pick-mussels")) { ui.gui.tasks.add(new Forager(200, Integer.MAX_VALUE, "mussels")); } else if (ad[1].equals("fill-smelter")) { ui.gui.tasks.add(new FeedCoalTask("smelter", 11)); } else if (ad[1].equals("arrow-autoloader")) { Config.enableAutoloader = !Config.enableAutoloader; ui.gui.msg( String.format("Autoloader is now turned %s", Config.enableAutoloader ? "on" : "off")); } } public void tick(double dt) { if (loading || (pagseq != ui.sess.glob.pagseq)) updlayout(); } public boolean mouseup(Coord c, int button) { Pagina h = bhit(c); if ((button == 1) && (grab != null)) { if (dragging != null) { ui.dropthing(ui.root, ui.mc, dragging.res()); dragging = pressed = null; } else if (pressed != null) { if (pressed == h) use(h, false); pressed = null; } grab.remove(); grab = null; } return (true); } public void uimsg(String msg, Object... args) { if (msg == "goto") { String resnm = (String) args[0]; if (resnm.equals("")) { cur = null; } else { Resource.Named res = Resource.remote().load(resnm, (Integer) args[1]); cur = paginafor(res); } curoff = 0; updlayout(); } } public boolean globtype(char k, KeyEvent ev) { if ((k == 27) && (this.cur != null)) { this.cur = null; curoff = 0; updlayout(); return (true); } else if ((k == 8) && (this.cur != null)) { this.cur = paginafor(this.cur.act().parent); curoff = 0; updlayout(); return (true); } else if ((k == 'N') && (layout[gsz.x - 2][gsz.y - 1] == next)) { use(next, false); return (true); } Pagina r = hotmap.get(Character.toUpperCase(k)); if (r != null) { use(r, true); return (true); } return (false); } }
public class Avaview extends Widget { static final String POSKEY = "pava_pos"; public static final Coord dasz = new Coord(74, 74); private Coord asz; int avagob; boolean none = false; AvaRender myown = null; public Color color = Color.WHITE; public static final Coord unborder = new Coord(2, 2); public static final Tex missing = Resource.loadtex("gfx/hud/equip/missing"); boolean dm = false; Coord doff; static { Widget.addtype( "av", new WidgetFactory() { public Widget create(Coord c, Widget parent, Object[] args) { if (UI.instance.mainview != null && UI.instance.mainview.playergob == (Integer) args[0]) { c = new Coord(Config.window_props.getProperty(POSKEY, c.toString())); } return (new Avaview(c, parent, (Integer) args[0])); } }); Widget.addtype( "av2", new WidgetFactory() { public Widget create(Coord c, Widget parent, Object[] args) { List<Indir<Resource>> rl = new LinkedList<Indir<Resource>>(); for (Object arg : args) rl.add(parent.ui.sess.getres((Integer) arg)); return (new Avaview(c, parent, rl)); } }); } private Avaview(Coord c, Widget parent, Coord asz) { super(c, asz.add(Window.wbox.bisz()).add(unborder.mul(2).inv()), parent); this.asz = asz; } public Avaview(Coord c, Widget parent, int avagob, Coord asz) { this(c, parent, asz); this.avagob = avagob; } public Avaview(Coord c, Widget parent, int avagob) { this(c, parent, avagob, dasz); } public Avaview(Coord c, Widget parent, List<Indir<Resource>> rl) { this(c, parent, dasz); if (rl.size() == 0) none = true; else this.myown = new AvaRender(rl); } public void uimsg(String msg, Object... args) { if (msg == "upd") { this.avagob = (Integer) args[0]; return; } if (msg == "ch") { List<Indir<Resource>> rl = new LinkedList<Indir<Resource>>(); for (Object arg : args) rl.add(ui.sess.getres((Integer) arg)); if (rl.size() == 0) { this.myown = null; none = true; } else { if (myown != null) myown.setlay(rl); else myown = new AvaRender(rl); none = false; } return; } super.uimsg(msg, args); } 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 boolean mousedown(Coord c, int button) { switch (button) { case 1: ui.grabmouse(this); dm = true; doff = c; wdgmsg("click", button); break; case 3: if (parent instanceof Partyview || parent instanceof Fightview) { wdgmsg("click", button); } else if (avagob > 0 && ui.sess.glob.oc.getgob(avagob) != null && ui.sess.glob.oc.getgob(avagob).getattr(Avatar.class) != null) { new XAvaGear(this.c.add(c), ui.root, avagob); } else if (myown != null) { new XAvaGear(this.c.add(c), ui.root, myown); } } return (true); } public boolean mouseup(Coord c, int button) { if (dm) { ui.grabmouse(null); dm = false; if (ui.mainview != null && avagob == ui.mainview.playergob) { Config.setWindowOpt(POSKEY, this.c.toString()); } else if (parent instanceof Partyview) { ((Partyview) parent).saveparty(); } } else { super.mouseup(c, button); } return (true); } 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 class FlowerMenu extends Widget /* */ { /* 34 */ public static Color pink = new Color(255, 0, 128); /* */ public static IBox pbox; /* 36 */ public static Tex pbg = Resource.loadtex("gfx/hud/bgtex"); /* 37 */ static Color ptc = Color.YELLOW; /* 38 */ static Text.Foundry ptf = new Text.Foundry(new Font("SansSerif", 0, 12)); /* 39 */ static int ph = 30; static int ppl = 8; /* */ Petal[] opts; /* */ Anim anim; /* */ /* */ private static void organize(Petal[] opts) /* */ { /* 168 */ int l = 1; int p = 0; int i = 0; /* 169 */ int lr = -1; /* 170 */ for (i = 0; i < opts.length; i++) { /* 171 */ if (lr == -1) /* */ { /* 173 */ lr = 75 + 50 * (l - 1); /* */ } /* 175 */ opts[i].ta = (1.570796326794897D - p * (6.283185307179586D / (l * ppl))); /* 176 */ opts[i].tr = lr; /* 177 */ p++; if (p >= ppl * l) { /* 178 */ l++; /* 179 */ p = 0; /* 180 */ lr = -1; /* */ } /* */ } /* */ } /* */ /* */ public FlowerMenu(Coord c, Widget parent, String[] options) { /* 186 */ super(c, Coord.z, parent); /* 187 */ this.opts = new Petal[options.length]; /* 188 */ for (int i = 0; i < options.length; i++) { /* 189 */ this.opts[i] = new Petal(options[i]); /* 190 */ this.opts[i].num = i; /* */ } /* 192 */ organize(this.opts); /* 193 */ this.ui.grabmouse(this); /* 194 */ this.ui.grabkeys(this); /* 195 */ this.anim = new Opening(); /* */ } /* */ /* */ public boolean isReady() /* */ { /* 200 */ return this.anim == null; /* */ } /* */ /* */ public boolean mousedown(Coord c, int button) { /* 204 */ if (this.anim != null) /* 205 */ return true; /* 206 */ if (!super.mousedown(c, button)) /* 207 */ wdgmsg("cl", new Object[] {Integer.valueOf(-1)}); /* 208 */ return true; /* */ } /* */ /* */ public void uimsg(String msg, Object[] args) { /* 212 */ if (msg == "cancel") { /* 213 */ this.anim = new Cancel(); /* 214 */ this.ui.grabmouse(null); /* 215 */ this.ui.grabkeys(null); /* 216 */ } else if (msg == "act") { /* 217 */ this.anim = new Chosen(this.opts[((Integer) args[0]).intValue()]); /* 218 */ this.ui.grabmouse(null); /* 219 */ this.ui.grabkeys(null); /* */ } /* */ } /* */ /* */ public void update(long dt) { /* 224 */ if (this.anim != null) /* 225 */ this.anim.tick(); /* */ } /* */ /* */ public void draw(GOut g) { /* 229 */ super.draw(g); /* */ } /* */ /* */ public void SelectOpt(String OptName) /* */ { /* 234 */ for (int i = 0; i < this.opts.length; i++) /* 235 */ if (this.opts[i].name.equals(OptName)) { /* 236 */ wdgmsg(this, "cl", new Object[] {Integer.valueOf(this.opts[i].num)}); /* 237 */ break; /* */ } /* */ } /* */ /* */ public boolean type(char key, KeyEvent ev) /* */ { /* 243 */ if ((key >= '0') && (key <= '9')) { /* 244 */ int opt = key == '0' ? 10 : key - '1'; /* 245 */ if (opt < this.opts.length) /* 246 */ wdgmsg("cl", new Object[] {Integer.valueOf(opt)}); /* 247 */ this.ui.grabkeys(null); /* 248 */ return true; /* 249 */ } if (key == '\033') { /* 250 */ wdgmsg("cl", new Object[] {Integer.valueOf(-1)}); /* 251 */ this.ui.grabkeys(null); /* 252 */ return true; /* */ } /* 254 */ return false; /* */ } /* */ /* */ static /* */ { /* 44 */ Widget.addtype( "sm", new WidgetFactory() { /* */ public Widget create(Coord c, Widget parent, Object[] args) { /* 46 */ if ((c.x == -1) && (c.y == -1)) /* 47 */ c = parent.ui.lcc; /* 48 */ String[] opts = new String[args.length]; /* 49 */ for (int i = 0; i < args.length; i++) /* 50 */ opts[i] = ((String) args[i]); /* 51 */ return new FlowerMenu(c, parent, opts); /* */ } /* */ }); /* 54 */ pbox = new IBox("gfx/hud", "tl", "tr", "bl", "br", "extvl", "extvr", "extht", "exthb"); /* */ } /* */ /* */ public class Cancel extends FlowerMenu.Anim /* */ { /* */ public Cancel() /* */ { /* 154 */ super(); /* */ } /* 156 */ public void tick2() { for (FlowerMenu.Petal p : FlowerMenu.this.opts) { /* 157 */ p.move(p.ta + this.s * 3.141592653589793D, p.tr * (1.0D - this.s)); /* 158 */ p.a = (1.0D - this.s); /* */ } } /* */ /* */ public void end() /* */ { /* 163 */ FlowerMenu.this.ui.destroy(FlowerMenu.this); /* */ } /* */ } /* */ /* */ public class Chosen extends FlowerMenu.Anim /* */ { /* */ FlowerMenu.Petal chosen; /* */ /* */ Chosen(FlowerMenu.Petal c) /* */ { /* 127 */ super(); /* 128 */ this.ms = 750; /* 129 */ this.chosen = c; /* */ } /* */ /* */ public void tick2() { /* 133 */ for (FlowerMenu.Petal p : FlowerMenu.this.opts) /* 134 */ if (p == this.chosen) { /* 135 */ if (this.s > 0.6D) /* 136 */ p.a = (1.0D - (this.s - 0.6D) / 0.4D); /* 137 */ else if (this.s < 0.3D) { /* 138 */ p.move(p.ta, p.tr * (1.0D - this.s / 0.3D)); /* */ } /* */ } /* 141 */ else if (this.s > 0.3D) /* 142 */ p.a = 0.0D; /* */ else /* 144 */ p.a = (1.0D - this.s / 0.3D); /* */ } /* */ /* */ public void end() /* */ { /* 150 */ FlowerMenu.this.ui.destroy(FlowerMenu.this); /* */ } /* */ } /* */ /* */ public class Opening extends FlowerMenu.Anim /* */ { /* */ public Opening() /* */ { /* 115 */ super(); /* */ } /* 117 */ public void tick2() { for (FlowerMenu.Petal p : FlowerMenu.this.opts) { /* 118 */ p.move(p.ta + (1.0D - this.s) * 3.141592653589793D, p.tr * this.s); /* 119 */ p.a = this.s; /* */ } /* */ } /* */ } /* */ /* */ public abstract class Anim /* */ { /* 93 */ long st = System.currentTimeMillis(); /* 94 */ int ms = 50; /* 95 */ double s = 0.0D; /* */ /* */ public Anim() {} /* */ /* 98 */ public void tick() { int dt = (int) (System.currentTimeMillis() - this.st); /* 99 */ if (dt < this.ms) /* 100 */ this.s = (dt / this.ms); /* */ else /* 102 */ this.s = 1.0D; /* 103 */ if (dt >= this.ms) /* 104 */ end(); /* 105 */ tick2(); } /* */ /* */ public void end() /* */ { /* 109 */ FlowerMenu.this.anim = null; /* */ } /* */ /* */ public abstract void tick2(); /* */ } /* */ /* */ public class Petal extends Widget /* */ { /* */ public String name; /* */ public double ta; /* */ public double tr; /* */ public int num; /* */ Text text; /* 62 */ double a = 1.0D; /* */ /* */ public Petal(String name) { /* 65 */ super(Coord.z, null, FlowerMenu.this); /* 66 */ this.name = name; /* 67 */ this.text = FlowerMenu.ptf.render(name, FlowerMenu.ptc); /* 68 */ this.sz = new Coord(this.text.sz().x + 25, FlowerMenu.ph); /* */ } /* */ /* */ public void move(Coord c) { /* 72 */ this.c = c.add(this.sz.div(2).inv()); /* */ } /* */ /* */ public void move(double a, double r) { /* 76 */ move(Coord.sc(a, r)); /* */ } /* */ /* */ public void draw(GOut g) { /* 80 */ g.chcolor(new Color(255, 255, 255, (int) (255.0D * this.a))); /* 81 */ g.image( FlowerMenu.pbg, new Coord(3, 3), new Coord(3, 3), this.sz.add(new Coord(-6, -6))); /* 82 */ FlowerMenu.pbox.draw(g, Coord.z, this.sz); /* 83 */ g.image(this.text.tex(), this.sz.div(2).add(this.text.sz().div(2).inv())); /* */ } /* */ /* */ public boolean mousedown(Coord c, int button) { /* 87 */ wdgmsg(FlowerMenu.this, "cl", new Object[] {Integer.valueOf(this.num)}); /* 88 */ return true; /* */ } /* */ } /* */ }
public class Textlog extends Widget { static Tex texpap = Resource.loadtex("gfx/hud/texpap"); static Tex schain = Resource.loadtex("gfx/hud/schain"); static Tex sflarp = Resource.loadtex("gfx/hud/sflarp"); static RichText.Foundry fnd = new RichText.Foundry( TextAttribute.FAMILY, "SansSerif", TextAttribute.SIZE, 12, TextAttribute.FOREGROUND, Color.BLACK); static RichText.Foundry fndMono = new RichText.Foundry( TextAttribute.FAMILY, "Monospaced", TextAttribute.SIZE, 12, TextAttribute.FOREGROUND, Color.BLACK); RichText.Foundry foundry; List<Text> lines; int maxy, cury; int margin = 3; boolean quote = true; public int maxLines = 150; UI.Grab sdrag = null; @RName("log") public static class $_ implements Factory { @Override public Widget create(Widget parent, Object[] args) { return (new Textlog((Coord) args[0])); } } @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 Textlog(Coord sz) { super(sz); lines = new LinkedList<>(); maxy = cury = 0; foundry = fnd; } public Textlog(Coord sz, RichText.Foundry foundry) { this(sz); this.foundry = foundry; } 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; } public void append(String line) { append(line, null); } @Override public void uimsg(String msg, Object... args) { if (msg == "apnd") { append((String) args[0]); } } @Override public boolean mousewheel(Coord c, int amount) { cury += amount * 20; if (cury < sz.y) { cury = sz.y; } if (cury > maxy) { cury = maxy; } return (true); } @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); } @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 mouseup(Coord c, int button) { if ((button == 1) && (sdrag != null)) { sdrag.remove(); sdrag = null; return (true); } return (false); } public void setprog(double a) { if (a < 0) { a = 0; } if (a > 1) { a = 1; } cury = (int) (a * (maxy - sz.y)) + sz.y; } }
public class Fightsess extends Widget { public static final Tex lframe = Resource.loadtex("gfx/hud/combat/lframe"); public static final int actpitch = 50; public final Indir<Resource>[] actions; public final boolean[] dyn; public int use = -1; public Coord pcc; public int pho; private final Fightview fv; @RName("fsess") public static class $_ implements Factory { public Widget create(Widget parent, Object[] args) { int nact = (Integer) args[0]; return (new Fightsess(nact, parent.getparent(GameUI.class).fv)); } } @SuppressWarnings("unchecked") public Fightsess(int nact, Fightview fv) { this.fv = fv; pho = -40; this.actions = (Indir<Resource>[]) new Indir[nact]; this.dyn = new boolean[nact]; } public void presize() { resize(parent.sz); pcc = sz.div(2); } protected void added() { presize(); } private void updatepos() { MapView map; Gob pl; if (((map = getparent(GameUI.class).map) == null) || ((pl = map.player()) == null) || (pl.sc == null)) return; pcc = pl.sc; pho = (int) (pl.sczu.mul(20f).y) - 20; } private static final Text.Furnace ipf = new PUtils.BlurFurn( new Text.Foundry(Text.serif, 18, new Color(128, 128, 255)).aa(true), 1, 1, new Color(48, 48, 96)); private final Text.UText<?> ip = new Text.UText<Integer>(ipf) { public String text(Integer v) { return ("IP: " + v); } public Integer value() { return (fv.current.ip); } }; private final Text.UText<?> oip = new Text.UText<Integer>(ipf) { public String text(Integer v) { return ("IP: " + v); } public Integer value() { return (fv.current.oip); } }; 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; } } private Widget prevtt = null; 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 uimsg(String msg, Object... args) { if (msg == "act") { int n = (Integer) args[0]; if (args.length > 1) { Indir<Resource> res = ui.sess.getres((Integer) args[1]); actions[n] = res; dyn[n] = ((Integer) args[2]) != 0; } else { actions[n] = null; } } else if (msg == "use") { this.use = (Integer) args[0]; } else if (msg == "used") { } else if (msg == "dropped") { } else { super.uimsg(msg, args); } } public boolean globtype(char key, KeyEvent ev) { int c = ev.getKeyChar(); if ((key == 0) && (c >= KeyEvent.VK_1) && (c < KeyEvent.VK_1 + actions.length)) { int n = c - KeyEvent.VK_1; if ((ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) wdgmsg("drop", n); else wdgmsg("use", n); return (true); } return (super.globtype(key, ev)); } }
public class EquipBelt extends DraggableBelt { private static final Tex sq = Resource.loadtex("gfx/hud/belt/custom/eqsq"); private static final int keys[] = { KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_3, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_6, KeyEvent.VK_7, KeyEvent.VK_8, KeyEvent.VK_9, KeyEvent.VK_0 }; 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); } private static Coord sqroff(Coord c) { return c.div(sq.sz().add(-1, -1)); } private class EquipSlot extends Slot { private final int index; public EquipSlot(int index, int key, int mods, String text) { super(key, mods, text); this.index = index; } @Override public boolean click(Coord c, int button) { Equipory e = ui.gui.getEquipory(); if (e != null) { WItem w = e.slots[index]; if (w != null) { w.mousedown(c.add(-sqroff(c).x * sq.sz().x, 0), button); } } return true; } @Override public void draw(GOut g) { Equipory e = ui.gui.getEquipory(); if (e != null) { g.rimage(Window.bg, Coord.z, sz); g.image(sq, Coord.z); WItem w = e.slots[index]; if (w != null) { w.draw(g.reclipl(sq.sz().sub(w.sz).div(2), g.sz)); } } } @Override public boolean drop() { Equipory e = ui.gui.getEquipory(); if (e != null) { e.wdgmsg("drop", index); return true; } return false; } @Override public boolean interact(Coord cc, Coord ul) { Equipory e = ui.gui.getEquipory(); if (e != null) { WItem w = e.slots[index]; if (w != null) { return w.iteminteract(cc, ul); } } return false; } @Override public boolean isEmpty() { Equipory e = ui.gui.getEquipory(); return (e == null) || (e.slots[index] == null); } @Override public Object tooltip(Coord c, Widget prev, boolean again) { Equipory e = ui.gui.getEquipory(); if (e != null) { WItem w = e.slots[index]; if (w != null) { return w.tooltip(c, again ? w : prev); } } return null; } @Override public void keyact() { if (isEmpty()) { // try to put item in hand to the slot Equipory e = ui.gui.getEquipory(); if (e != null) { e.wdgmsg("drop", index); } } else { // try to take item Equipory e = ui.gui.getEquipory(); if (e != null) { WItem w = e.slots[index]; if (w != null) { w.item.wdgmsg("take", w.sz.div(2)); } } } } } private class HandSlot extends Slot { public HandSlot(int key, int mods, String text) { super(key, mods, text); } @Override public boolean click(Coord c, int button) { if (button == 1) { ui.gui.swapHand(); return true; } return false; } @Override public void draw(GOut g) { Equipory e = ui.gui.getEquipory(); if (e != null) { g.rimage(Window.bg, Coord.z, sz); g.image(sq, Coord.z); if (ui.gui.handSave.size() > 0) { for (GameUI.DraggedItem di : ui.gui.handSave) { GSprite spr = di.item.spr(); if (spr != null) { int w = Math.min(spr.sz().x, sq.sz().x - 5); int h = Math.min(spr.sz().y, sq.sz().y - 5); spr.draw(g.reclipl(sq.sz().sub(w, h).div(2), g.sz.sub(5, 5))); } break; } } } } @Override public boolean drop() { if (ui.gui.handSave.size() == 0) { ui.gui.swapHand(); } return true; } @Override public boolean isEmpty() { return ui.gui.handSave.size() == 0; } @Override public void keyact() { ui.gui.swapHand(); } } }
public class LoginScreen extends Widget { Login cur; Text error; IButton btn; static final Text.Foundry textf; static final Text.Foundry textfs; final Tex bg = Resource.loadtex("gfx/loginscr"); final Tex logo = Resource.loadtex("gfx/logo"); Text progress = null; static { textf = new Text.Foundry(new java.awt.Font("Sans", java.awt.Font.PLAIN, 16)); textfs = new Text.Foundry(new java.awt.Font("Sans", java.awt.Font.PLAIN, 14)); } 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); } private abstract static class Login extends Widget { private Login(Coord c, Coord sz, Widget parent) { super(c, sz, parent); } abstract Object[] data(); abstract boolean enter(); } private class Pwbox extends Login { final TextEntry user; final TextEntry pass; final CheckBox savepass; private Pwbox(String username, boolean save) { super(CustomConfig.windowCenter.add(-55, 10), new Coord(150, 150), LoginScreen.this); setfocustab(true); new Label(new Coord(0, 0), this, "User name", textf); user = new TextEntry(new Coord(0, 20), new Coord(150, 20), this, username); new Label(new Coord(0, 60), this, "Password", textf); pass = new TextEntry(new Coord(0, 80), new Coord(150, 20), this, ""); pass.pw = true; savepass = new CheckBox(new Coord(0, 110), this, "Remember me"); savepass.a = save; if (user.text.length() == 0) setfocus(user); else setfocus(pass); } public void wdgmsg(Widget sender, String name, Object... args) {} Object[] data() { return (new Object[] {user.text, pass.text, savepass.a}); } boolean enter() { if (user.text.length() == 0) { setfocus(user); return (false); } else if (pass.text.length() == 0) { setfocus(pass); return (false); } else { return (true); } } } private class Tokenbox extends Login { final Text label; final Button btn; private Tokenbox(String username) { super(CustomConfig.windowCenter.add(-105, 10), new Coord(250, 100), LoginScreen.this); label = textfs.render("Identity is saved for " + username, java.awt.Color.WHITE); btn = new Button(new Coord(75, 30), 100, this, "Forget me"); } Object[] data() { return (new Object[0]); } boolean enter() { return (true); } public void wdgmsg(Widget sender, String name, Object... args) { if (sender == btn) { LoginScreen.this.wdgmsg("forget"); return; } super.wdgmsg(sender, name, args); } public void draw(GOut g) { g.image(label.tex(), new Coord((sz.x / 2) - (label.sz().x / 2), 0)); super.draw(g); } } private void mklogin() { synchronized (ui) { btn = new IButton( CustomConfig.windowCenter.add(-27, 160), this, Resource.loadimg("gfx/hud/buttons/loginu"), Resource.loadimg("gfx/hud/buttons/logind")); progress(null); } } private void error(String error) { synchronized (ui) { if (this.error != null) this.error = null; if (error != null) this.error = textf.render(error, java.awt.Color.RED); } } private void progress(String p) { synchronized (ui) { if (progress != null) progress = null; if (p != null) progress = textfs.render(p, java.awt.Color.WHITE); } } private void clear() { if (cur != null) { ui.destroy(cur); cur = null; ui.destroy(btn); btn = null; } progress(null); } public void wdgmsg(Widget sender, String msg, Object... args) { if (sender == btn) { if (cur.enter()) super.wdgmsg("login", cur.data()); return; } super.wdgmsg(sender, msg, args); } public void uimsg(String msg, Object... args) { synchronized (ui) { if (msg.equals("passwd")) { clear(); cur = new Pwbox((String) args[0], (Boolean) args[1]); mklogin(); } else if (msg.equals("token")) { clear(); cur = new Tokenbox((String) args[0]); mklogin(); } else if (msg.equals("error")) { error((String) args[0]); } else if (msg.equals("prg")) { error(null); clear(); progress((String) args[0]); } } } public void draw(GOut g) { super.draw(g); if (error != null) g.image( error.tex(), new Coord( CustomConfig.windowCenter.x - (error.sz().x / 2), CustomConfig.windowCenter.y + 200)); if (progress != null) g.image( progress.tex(), new Coord( CustomConfig.windowCenter.x + 20 - (progress.sz().x / 2), CustomConfig.windowCenter.y + 50)); } public boolean type(char k, java.awt.event.KeyEvent ev) { if (k == 10) { if ((cur != null) && cur.enter()) wdgmsg("login", cur.data()); return (true); } return (super.type(k, ev)); } }
public class Window extends Widget implements DTarget { private static final Tex tleft = Resource.loadtex("gfx/hud/wnd/tleft"); private static final Tex tmain = Resource.loadtex("gfx/hud/wnd/tmain"); private static final Tex tright = Resource.loadtex("gfx/hud/wnd/tright"); public static final BufferedImage[] cbtni = new BufferedImage[] { Resource.loadimg("gfx/hud/wnd/cbtn"), Resource.loadimg("gfx/hud/wnd/cbtnd"), Resource.loadimg("gfx/hud/wnd/cbtnh") }; public static final BufferedImage[] lbtni = new BufferedImage[] { Resource.loadimg("gfx/hud/wnd/lbtn"), Resource.loadimg("gfx/hud/wnd/lbtnd"), Resource.loadimg("gfx/hud/wnd/lbtnh") }; public static final BufferedImage[] rbtni = new BufferedImage[] { Resource.loadimg("gfx/hud/wnd/rbtn"), Resource.loadimg("gfx/hud/wnd/rbtnd"), Resource.loadimg("gfx/hud/wnd/rbtnh") }; public static final Color cc = new Color(248, 230, 190); public static final Text.Furnace cf = new Text.Imager(new Text.Foundry(new Font("Serif", Font.BOLD, 15), cc).aa(true)) { protected BufferedImage proc(Text text) { return (rasterimg(blurmask2(text.img.getRaster(), 1, 1, Color.BLACK))); } }; public static final IBox fbox = new IBox("gfx/hud", "ftl", "ftr", "fbl", "fbr", "fl", "fr", "ft", "fb"); public static final IBox swbox = new IBox("gfx/hud", "stl", "str", "sbl", "sbr", "sl", "sr", "st", "sb"); public static final IBox wbox = new IBox("gfx/hud/wnd", "tl", "tr", "bl", "br", "vl", "vr", "ht", "hb"); private static final IBox topless = new IBox(Tex.empty, Tex.empty, wbox.cbl, wbox.cbr, wbox.bl, wbox.br, Tex.empty, wbox.bb); private static final int th = tleft.sz().y, tdh = th - tmain.sz().y, tc = tdh + 18; private static final Coord capc = new Coord(20, th - 3); public Coord mrgn = new Coord(5, 5); protected Text cap; private boolean dt = false; protected boolean dm = false; public Coord ctl, csz, atl, asz, ac; protected Coord doff; protected final IButton cbtn; private final Collection<Widget> twdgs = new LinkedList<Widget>(); // ****************************** private static final String OPT_POS = "_pos"; // static Tex bg = Resource.loadtex("gfx/hud/bgtex"); // static Tex cl = Resource.loadtex("gfx/hud/cleft"); // static Tex cm = Resource.loadtex("gfx/hud/cmain"); // static Tex cr = Resource.loadtex("gfx/hud/cright"); public Coord tlo, rbo; public boolean justclose = false; protected final String name; @RName("wnd") public static class $_ implements Factory { public Widget create(Coord c, Widget parent, Object[] args) { if (args.length < 2) return (new Window(c, (Coord) args[0], parent, null)); else return (new Window(c, (Coord) args[0], parent, (String) args[1])); } } public Window(Coord c, Coord sz, Widget parent, String cap) { super(c, new Coord(0, 0), parent); if (cap != null) { this.cap = cf.render(cap); name = cap; } else { this.cap = null; name = null; } resize(sz); setfocustab(true); parent.setfocus(this); cbtn = new IButton(Coord.z, this, cbtni[0], cbtni[1], cbtni[2]); cbtn.recthit = true; addtwdg(cbtn); loadOpts(); } public Coord contentsz() { Coord max = new Coord(0, 0); for (Widget wdg = child; wdg != null; wdg = wdg.next) { if (twdgs.contains(wdg)) continue; 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.sub(1, 1)); } protected void placetwdgs() { int x = sz.x - 5; for (Widget ch : twdgs) ch.c = xlate(new Coord(x -= ch.sz.x + 5, tc - (ch.sz.y / 2)), false); } public void addtwdg(Widget wdg) { twdgs.add(wdg); placetwdgs(); } public void resize(Coord sz) { IBox box; int th; if (cap == null) { box = wbox; th = 0; } else { box = topless; th = Window.th; } sz = sz.add(box.bisz()).add(0, th).add(mrgn.mul(2)); this.sz = sz; ctl = box.btloff().add(0, th); csz = sz.sub(box.bisz()).sub(0, th); atl = ctl.add(mrgn); asz = csz.sub(mrgn.mul(2)); ac = new Coord(); // ac = tlo.add(wbox.btloff()).add(mrgn); placetwdgs(); for (Widget ch = child; ch != null; ch = ch.next) ch.presize(); } public Coord xlate(Coord c, boolean in) { if (in) return (c.add(atl)); else return (c.sub(atl)); } public void cdraw(GOut g) {} 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 uimsg(String msg, Object... args) { if (msg == "pack") { pack(); } else if (msg == "dt") { dt = (Integer) args[0] != 0; } else { super.uimsg(msg, args); } } public boolean mousedown(Coord c, int button) { parent.setfocus(this); raise(); if (super.mousedown(c, button)) return (true); if (c.y < tdh && cap != null) return (false); if (button == 1) { ui.grabmouse(this); dm = true; doff = c; } return (true); } public boolean mouseup(Coord c, int button) { if (dm) { canceldm(); storeOpt(OPT_POS, this.c); } else { super.mouseup(c, button); } return (true); } public void canceldm() { if (dm) ui.grabmouse(null); dm = false; } public void mousemove(Coord c) { if (dm) { this.c = this.c.add(c.add(doff.inv())); } else { super.mousemove(c); } } public void wdgmsg(Widget sender, String msg, Object... args) { if (sender == cbtn) { if (justclose) ui.destroy(this); else wdgmsg("close"); } else { super.wdgmsg(sender, msg, args); } } public boolean type(char key, java.awt.event.KeyEvent ev) { if (super.type(key, ev)) return (true); if (key == 27) { if (justclose) ui.destroy(this); else wdgmsg("close"); return (true); } return (false); } public boolean drop(Coord cc, Coord ul) { if (dt) { wdgmsg("drop", cc); return (true); } return (false); } public boolean iteminteract(Coord cc, Coord ul) { return (false); } public Object tooltip(Coord c, Widget prev) { Object ret = super.tooltip(c, prev); if (ret != null) return (ret); else return (""); } protected void storeOpt(String opt, String value) { if (name == null) { return; } Config.setWindowOpt(name + opt, value); } protected void storeOpt(String opt, Coord value) { storeOpt(opt, value.toString()); } protected void storeOpt(String opt, boolean value) { if (name == null) { return; } Config.setWindowOpt(name + opt, value); } 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; } } } protected boolean getOptBool(String opt, boolean def) { synchronized (Config.window_props) { try { return Config.window_props.getProperty(name + opt, null).equals("true"); } catch (Exception e) { return def; } } } protected void loadOpts() { if (name == null) { return; } c = getOptCoord(OPT_POS, c); } }