use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class I18NHandler method getUsedKeys.
private void getUsedKeys(Scene s, ArrayList<String> usedKeys) {
for (Verb v : s.getVerbManager().getVerbs().values()) getUsedKeys(v, usedKeys);
for (BaseActor a : s.getActors().values()) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
if (ia.getDesc() != null && !ia.getDesc().isEmpty() && ia.getDesc().charAt(0) == I18N.PREFIX)
usedKeys.add(ia.getDesc().substring(1));
for (Verb v : ia.getVerbManager().getVerbs().values()) getUsedKeys(v, usedKeys);
if (a instanceof CharacterActor) {
CharacterActor ca = (CharacterActor) a;
if (ca.getDialogs() != null) {
for (Dialog d : ca.getDialogs().values()) {
for (DialogOption o : d.getOptions()) {
if (o.getText() != null && !o.getText().isEmpty() && o.getText().charAt(0) == I18N.PREFIX)
usedKeys.add(o.getText().substring(1));
if (o.getResponseText() != null && !o.getResponseText().isEmpty() && o.getResponseText().charAt(0) == I18N.PREFIX)
usedKeys.add(o.getResponseText().substring(1));
}
}
}
}
if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof TextRenderer) {
TextRenderer r = (TextRenderer) ((SpriteActor) a).getRenderer();
String k = r.getText();
if (k != null && !k.isEmpty() && k.charAt(0) == I18N.PREFIX)
usedKeys.add(k.substring(1));
}
}
}
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class InventoryUI method draw.
@Override
public void draw(Batch batch, float alpha) {
Inventory inventory = World.getInstance().getInventory();
if (!inventory.isVisible()) {
setVisible(false);
return;
}
if (style.background != null) {
style.background.draw(batch, getX(), getY(), getWidth(), getHeight());
}
// DRAW ITEMS
int capacity = cols * rows;
for (int i = 0; i < inventory.getNumItems() && i < capacity; i++) {
SpriteActor a = inventory.get(i);
ActorRenderer r = a.getRenderer();
float size = (tileSize - rowSpace) / (r.getHeight() > r.getWidth() ? r.getHeight() : r.getWidth());
float x = i % cols;
float y = (rows - 1) - i / cols;
if (style.itemBackground != null) {
style.itemBackground.draw(batch, getX() + x * tileSize + x * rowSpace + margin, getY() + y * tileSize + y * rowSpace + margin, tileSize, tileSize);
}
r.draw((SpriteBatch) batch, getX() + x * tileSize + x * rowSpace + tileSize / 2 + margin, getY() + (tileSize - r.getHeight() * size) / 2 + y * tileSize + y * rowSpace + margin, size, 0f, a.getTint());
}
super.draw(batch, alpha);
}
Aggregations