use of com.badlogic.gdx.graphics.g2d.GlyphLayout in project ultimate-java by pantinor.
the class BookScreen method addPages.
private void addPages(BitmapFont font, int pageStart, String fn, Label.LabelStyle labs) {
try {
List<String> lines = FileUtils.readLines(Gdx.files.internal(fn).file());
int page = pageStart;
GlyphLayout gl = new GlyphLayout(font, "");
StringBuilder sb = new StringBuilder();
for (String line : lines) {
sb.append(line).append("\n");
gl.setText(font, sb.toString().trim(), Color.WHITE, 450, Align.left, true);
if (gl.height > 600) {
labels.add(new Label(sb.toString().trim(), labs));
sb = new StringBuilder();
page++;
}
}
labels.add(new Label(sb.toString().trim(), labs));
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.badlogic.gdx.graphics.g2d.GlyphLayout in project ultimate-java by pantinor.
the class DeathScreen method render.
@Override
public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
long diff = System.currentTimeMillis() - initTime;
long secs = diff / 1000;
int index = (int) (secs / 4);
if (index >= deathMsgs.length) {
mainGame.setScreen(returnScreen);
} else {
String s = deathMsgs[index];
batch.begin();
float x = Ultima4.SCREEN_WIDTH / 2 - 320;
float y = 300;
float width = 640;
float height = 50;
GlyphLayout layout = new GlyphLayout(font, s, Color.WHITE, width, Align.left, true);
x += width / 2 - layout.width / 2;
y += height / 2 + layout.height / 2;
font.draw(batch, layout, x, y);
batch.end();
}
}
use of com.badlogic.gdx.graphics.g2d.GlyphLayout in project ultimate-java by pantinor.
the class CodexLogDisplay method render.
public void render(Batch batch) {
batch.draw(logbkgrnd, 200, 500);
int h = 20;
float y = 500 + 10;
synchronized (logs) {
ReverseListIterator iter = new ReverseListIterator(logs);
while (iter.hasNext()) {
String next = (String) iter.next();
GlyphLayout layout = new GlyphLayout(font, next, Color.WHITE, width - 20, Align.left, true);
y = y + layout.height + 4;
h += layout.height + 4;
if (h > height + 20) {
break;
}
font.draw(batch, layout, 220, y);
}
}
}
use of com.badlogic.gdx.graphics.g2d.GlyphLayout in project ultimate-java by pantinor.
the class LogDisplay method render.
public void render(Batch batch, Party party) {
int food = party.getSaveGame().food / 100;
font.setColor(food < 5 ? Color.RED : Color.WHITE);
font.draw(batch, "Food " + food, LOG_X + 8, 438);
font.setColor(Color.WHITE);
if (party.getContext().getTransportContext() == TransportContext.SHIP) {
font.draw(batch, "Hull " + party.getSaveGame().shiphull, LOG_X + 8 + 120, 438);
} else {
font.draw(batch, "Gold " + party.getSaveGame().gold, LOG_X + 8 + 140, 438);
}
float y = Ultima4.SCREEN_HEIGHT - 48;
for (int i = 0; i < party.getMembers().size(); i++) {
PartyMember pm = party.getMember(i);
String s = (i + 1) + " - " + pm.getPlayer().name;
String d = pm.getPlayer().hp + "" + pm.getPlayer().status.getValue();
font.setColor(i == party.getActivePlayer() ? new Color(.35f, .93f, 0.91f, 1) : Color.WHITE);
if (pm.getPlayer().status == StatusType.POISONED) {
font.setColor(Color.GREEN);
}
if (pm.getPlayer().status == StatusType.SLEEPING) {
font.setColor(Color.YELLOW);
}
if (pm.getPlayer().status == StatusType.DEAD) {
font.setColor(Color.GRAY);
}
font.draw(batch, s, LOG_X + 8, y);
font.draw(batch, d, LOG_X + 8 + 110, y);
y = y - 24;
}
font.setColor(Color.WHITE);
y = 32;
synchronized (logs) {
ReverseListIterator iter = new ReverseListIterator(logs);
while (iter.hasNext()) {
String next = (String) iter.next();
GlyphLayout layout = new GlyphLayout(font, next, Color.WHITE, LOG_AREA_WIDTH - 8, Align.left, true);
y += layout.height + 10;
if (y > LOG_AREA_TOP) {
break;
}
font.draw(batch, layout, LOG_X + 8, y);
}
}
}
use of com.badlogic.gdx.graphics.g2d.GlyphLayout in project bladecoder-adventure-engine by bladecoder.
the class FilteredSelectBox method layout.
@Override
public void layout() {
Drawable bg = style.background;
BitmapFont font = style.font;
if (bg != null) {
prefHeight = Math.max(bg.getTopHeight() + bg.getBottomHeight() + font.getCapHeight() - font.getDescent() * 2, bg.getMinHeight());
} else
prefHeight = font.getCapHeight() - font.getDescent() * 2;
float maxItemWidth = 0;
Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class);
GlyphLayout layout = layoutPool.obtain();
for (int i = 0; i < items.size; i++) {
layout.setText(font, toString(items.get(i)));
maxItemWidth = Math.max(layout.width, maxItemWidth);
}
layoutPool.free(layout);
prefWidth = maxItemWidth;
if (bg != null)
prefWidth += bg.getLeftWidth() + bg.getRightWidth();
ListStyle listStyle = style.listStyle;
ScrollPaneStyle scrollStyle = style.scrollStyle;
float listWidth = maxItemWidth + listStyle.selection.getLeftWidth() + listStyle.selection.getRightWidth();
if (scrollStyle.background != null)
listWidth += scrollStyle.background.getLeftWidth() + scrollStyle.background.getRightWidth();
if (selectBoxList == null || !selectBoxList.isScrollingDisabledY())
listWidth += Math.max(style.scrollStyle.vScroll != null ? style.scrollStyle.vScroll.getMinWidth() : 0, style.scrollStyle.vScrollKnob != null ? style.scrollStyle.vScrollKnob.getMinWidth() : 0);
prefWidth = Math.max(prefWidth, listWidth);
}
Aggregations