protected float addDescrip(String descrip, float x, float y, float width) { ImageLayer layer = createDescripLayer(descrip, width); game.rootLayer.addAt(layer, Math.round(x + (width - layer.width())/2), y); return y + layer.height(); }
@Override protected void paintImpl (Surface surf) { if (tile != null) { float dwidth = width(), dheight = height(); if (region == null) surf.draw(tile, 0, 0, dwidth, dheight); else surf.draw(tile, 0, 0, dwidth, dheight, region.x, region.y, region.width, region.height); } }
private void addTestLayer(String descrip, int width, int height, Layer layer) { // if this layer won't fit in this row, wrap down to the next if (nextX + width > game.graphics.viewSize.width()) { nextY += (maxY + GAP); nextX = GAP; maxY = 0; } // add the layer and its description below game.rootLayer.addAt(layer, nextX, nextY); ImageLayer dlayer = createDescripLayer(descrip, width); game.rootLayer.addAt(dlayer, nextX + Math.round((width-dlayer.width())/2), nextY + height + 2); // update our positioning info nextX += (width + GAP); maxY = Math.max(maxY, height+dlayer.height()+2); }
protected void addToRow (ImageLayer layer) { game.rootLayer.add(layer.setTranslation(row.x + row.width, row.y)); row.width += layer.width() + 45; row.height = Math.max(row.height, layer.height()); if (row.width > game.graphics.viewSize.width() * .6f) newRow(); }
@Override public void init () { float spacing = 5; float y = spacing, x = spacing, nextX = spacing; for (Mode mode : host.enumerateModes()) { ImageLayer button = game.ui.createButton(mode.toString(), () -> host.setMode(mode)); game.rootLayer.add(button); if (y + button.height() + spacing >= game.graphics.viewSize.height()) { x = nextX + spacing; y = spacing; } button.setTranslation(x, y); y += button.height() + spacing; nextX = Math.max(nextX, x + button.width()); } } }
@Override public boolean onVisit (String parentLayer, Instance instance, int depth) { String instanceDesc; if (instance instanceof Movie) { instanceDesc = ((Movie) instance).symbol().name(); } else if (instance instanceof Texture) { ImageLayer tLayer = ((Texture) instance).layer(); instanceDesc = "Texture (" + tLayer.width() + " x " + tLayer.height() + ")"; if (tLayer.disposed()) instanceDesc += " (DISPOSED)"; } else if (instance != null) { instanceDesc = instance.toString(); } else { instanceDesc = "(null)"; } printChild(depth, parentLayer + ": " + instanceDesc); return false; } protected void printChild (int depth, String description) {
public void setMessage (String text) { if (_msg != null) _msg.close(); if (text != null) { _msg = StyledText.span(graphics(), text, MSG_STYLE).toLayer(); _msg.setDepth(1); stage.addAt(_msg, (swidth-_msg.width())/2, (sheight-_msg.height())/2); } }
Box (String text, int color, float wid, float hei) { layer = new GroupLayer(wid, hei); layer.add(new Layer() { protected void paintImpl (Surface surface) { surface.setFillColor(0xff000000); float t = 0.5f, l = 0.5f, b = layer.height() - 0.5f, r = layer.width() - 0.5f; surface.drawLine(l, t, l, b, 1); surface.drawLine(r, t, r, b, 1); surface.drawLine(l, b, r, b, 1); surface.drawLine(l, t, r, t, 1); } }); label = createLabel(text, layer, 0xff000000, color, 0, 0, 40); layer.addAt(label, (wid - label.width()) / 2, (hei - label.height()) / 2); layer.setHitTester(this); }
void displayMenu() { clearTest(); rootLayer.disposeAll(); rootLayer.add(createWhiteBackground()); float gap = 20, x = gap, y = gap, maxHeight = 0; String info = "Renderer: gl (batch=" + defaultBatch + ")" + " / Screen: " + graphics.screenSize() + " / Window: " + graphics.viewSize; Texture infoTex = ui.formatText(info, false); rootLayer.addAt(new ImageLayer(infoTex), x, y); y += infoTex.displayHeight + gap; for (final Test test : tests) { if (!test.available()) continue; ImageLayer button = ui.createButton(test.name, () -> startTest(test)); if (x + button.width() > graphics.viewSize.width() - gap) { x = gap; y += maxHeight + gap; maxHeight = 0; } maxHeight = Math.max(maxHeight, button.height()); rootLayer.addAt(button, x, y); x += button.width() + gap; } }
y += preventDefault.layer.height() + 5; x = 20; y += createLabel("Event Log", 0, x, y).height(); logger = new TextLogger(375, 15, logFormat); logger.layer.setTranslation(x, y); y += createLabel("Motion Log", 0, x, y).height(); motionLabel = new TextMapper(375, 6, logFormat); motionLabel.layer.setTranslation(x, y);