@Override public void build() { table = new table("loadDim"){{ touchable(Touchable.enabled); get().addImage("white").growX() .height(3f).pad(4f).growX().get().setColor(Colors.get("accent")); row(); new label("$text.loading"){{ get().setName("namelabel"); }}.pad(10); row(); get().addImage("white").growX() .height(3f).pad(4f).growX().get().setColor(Colors.get("accent")); }}.end().get(); table.setVisible(false); }
@Override public void draw(Batch batch, float alpha){ super.draw(batch, alpha); float scaleX = getScaleX(); float scaleY = getScaleY(); Draw.color(Colors.get("accent")); Draw.thick(Unit.dp.scl(thickness)); Draw.linerect(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY); Draw.reset(); }
public FloatingDialog(String title){ super(title, "dialog"); setFillParent(true); title().setAlignment(Align.center); getTitleTable().row(); getTitleTable().addImage("white", Colors.get("accent")) .growX().height(3f).pad(4f); }
public ControlsDialog(){ setDialog(); setFillParent(true); title().setAlignment(Align.center); getTitleTable().row(); getTitleTable().add(new Image("white")) .growX().height(3f).pad(4f).get().setColor(Colors.get("accent")); }
@Override public void create () { spriteBatch = new SpriteBatch(); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false); multiPageFont = new BitmapFont(Gdx.files.internal("data/multipagefont.fnt")); // Add user defined color Colors.put("PERU", Color.valueOf("CD853F")); renderer = new ShapeRenderer(); renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix()); stage = new Stage(); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); BitmapFont labelFont = skin.get("default-font", BitmapFont.class); labelFont.setMarkupEnabled(true); // Notice that the last [] has been deliberately added to test the effect of excessive pop operations. // They are silently ignored, as expected. Label label = new Label("<<[BLUE]M[RED]u[YELLOW]l[GREEN]t[OLIVE]ic[]o[]l[]o[]r[]*[MAROON]Label[][]>>", skin); label.setPosition(200, 200); stage.addActor(label); Window window = new Window("[RED]Multicolor[GREEN] Title", skin); window.setPosition(400, 200); window.pack(); stage.addActor(window); }
@Override public void dispose () { spriteBatch.dispose(); renderer.dispose(); font.dispose(); // Restore predefined colors Colors.reset(); }
private void addColors() { Colors.put("VOID_PURPLE", new Color(123f / 255f, 0, 1, 1)); // text related Colors.put("DANGER", new Color(1, 0, 0, 1)); // red Colors.put("OBJECT", new Color(1, 217 / 255f, 0, 1)); // yellow Colors.put("KEY", new Color(0, 204 / 255f, 0, 1)); // green }
@Override public void draw(Batch batch, float alpha){ float ratio = 1f / ((float)editor.pixmap().getWidth() / editor.pixmap().getHeight()); float size = Math.min(width, height); float sclwidth = size * zoom; float sclheight = size * zoom * ratio; float centerx = x + width/2 + offsetx * zoom; float centery = y + height/2 + offsety * zoom; image.setImageSize(editor.pixmap().getWidth(), editor.pixmap().getHeight()); batch.flush(); boolean pop = ScissorStack.pushScissors(Tmp.r1.set(x + width/2 - size/2, y + height/2 - size/2, size, size)); batch.draw(editor.texture(), centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight); if(grid){ Draw.color(Color.GRAY); image.setBounds(centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight); image.draw(batch, alpha); Draw.color(); } if(tool == EditorTool.line && drawing){ Vector2 v1 = unproject(startx, starty).add(x, y); float sx = v1.x, sy = v1.y; Vector2 v2 = unproject(lastx, lasty).add(x, y); Draw.color(Tmp.c1.set(ColorMapper.getColor(editor.getDrawBlock()))); Draw.thick(Unit.dp.scl(3f * zoom)); Draw.line(sx, sy, v2.x, v2.y); Draw.polygon(sx, sy, 40, editor.getBrushSize() * zoom * 3); Draw.polygon(v2.x, v2.y, 40, editor.getBrushSize() * zoom * 3); } batch.flush(); if(pop) ScissorStack.popScissors(); Draw.color(Colors.get("accent")); Draw.thick(Unit.dp.scl(3f)); Draw.linerect(x + width/2 - size/2, y + height/2 - size/2, size, size); Draw.reset(); }
public SettingsMenuDialog(){ setStyle(Core.skin.get("dialog", WindowStyle.class)); hidden(()->{ if(!GameState.is(State.menu)){ if(!wasPaused || Net.active()) GameState.set(State.playing); } }); shown(()->{ if(!GameState.is(State.menu)){ wasPaused = GameState.is(State.paused); if(menu.getScene() != null){ wasPaused = ((PausedDialog)menu).wasPaused; } if(!Net.active()) GameState.set(State.paused); Vars.ui.paused.hide(); } }); setFillParent(true); title().setAlignment(Align.center); getTitleTable().row(); getTitleTable().add(new Image("white")) .growX().height(3f).pad(4f).get().setColor(Colors.get("accent")); content().clearChildren(); content().remove(); buttons().remove(); menu = new Table(); Consumer<SettingsTable> s = table -> { table.row(); table.addImageTextButton("$text.back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f); }; game = new SettingsTable(s); graphics = new SettingsTable(s); sound = new SettingsTable(s); prefs = new Table(); prefs.top(); prefs.margin(14f); menu.defaults().size(300f, 60f).pad(3f); menu.addButton("$text.settings.game", () -> visible(0)); menu.row(); menu.addButton("$text.settings.graphics", () -> visible(1)); menu.row(); menu.addButton("$text.settings.sound", () -> visible(2)); if(!Vars.android) { menu.row(); menu.addButton("$text.settings.controls", Vars.ui.controls::show); } prefs.clearChildren(); prefs.add(menu); ScrollPane pane = new ScrollPane(prefs, "clear"); pane.setFadeScrollBars(false); row(); add(pane).grow().top(); row(); add(buttons()).fillX(); hidden(this::back); addSettings(); }
public UI() { Dialog.setShowAction(()-> sequence( alpha(0f), originCenter(), moveToAligned(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, Align.center), scaleTo(0.0f, 1f), parallel( scaleTo(1f, 1f, 0.1f, Interpolation.fade), fadeIn(0.1f, Interpolation.fade) ) )); Dialog.setHideAction(()-> sequence( parallel( scaleTo(0.01f, 0.01f, 0.1f, Interpolation.fade), fadeOut(0.1f, Interpolation.fade) ) )); TooltipManager.getInstance().animations = false; Settings.setErrorHandler(()-> Timers.run(1f, ()-> showError("[crimson]Failed to access local storage.\nSettings will not be saved."))); Settings.defaults("pixelate", true); Dialog.closePadR = -1; Dialog.closePadT = 5; Colors.put("description", Color.WHITE); Colors.put("turretinfo", Color.ORANGE); Colors.put("iteminfo", Color.LIGHT_GRAY); Colors.put("powerinfo", Color.YELLOW); Colors.put("liquidinfo", Color.ROYAL); Colors.put("craftinfo", Color.LIGHT_GRAY); Colors.put("missingitems", Color.SCARLET); Colors.put("health", Color.YELLOW); Colors.put("healthstats", Color.SCARLET); Colors.put("interact", Color.ORANGE); Colors.put("accent", Color.valueOf("f4ba6e")); Colors.put("place", Color.PURPLE); Colors.put("placeInvalid", Color.RED); Colors.put("placeRotate", Color.ORANGE); Colors.put("break", Color.CORAL); Colors.put("breakStart", Color.YELLOW); Colors.put("breakInvalid", Color.RED); }
@Override public void postinit(LuaTable table, LuaValue environment) { Colors.getColors().forEach(entry -> { table.set(entry.key.toLowerCase(), of(entry.value)); }); }