/** Draw score counters */ private void drawScore(SpriteBatch batch) { BitmapFont font = getFont(); if (!bareScoreCnt.isStopped()) { bareScoreCnt.update(Gdx.graphics.getDeltaTime()); String str = "" + bareScoreCnt.getValue(); font.draw( batch, str, -(str.length() * font.getSpaceWidth()) / 2.0f, font.getXHeight() + 150.0f); } else if (!additionalPointsCnt.isStopped()) { additionalPointsCnt.update(Gdx.graphics.getDeltaTime()); String str = bareScoreCnt.getValue() + " + " + additionalPointsCnt.getValue(); font.draw( batch, str, -(str.length() * font.getSpaceWidth()) / 2.0f, font.getXHeight() + 150.0f); } else { String str = bareScoreCnt.getValue() + " + " + additionalPointsCnt.getValue() + scoreText; font.draw( batch, str, -(str.length() * font.getSpaceWidth()) / 2.0f, font.getXHeight() + 150.0f); } }
/** Draw score counters and badges */ private void drawStats(SpriteBatch batch) { BitmapFont font = getFont(); /* Level cleared text */ font.draw( batch, levelClearedText, -(levelClearedText.length() * font.getSpaceWidth()) / 2.0f, font.getXHeight() + 250.0f); drawScore(batch); drawBadges(batch); }
public void drawUnits() { Texture curTexture = null; for (Coordinate c : unitMap.keySet()) { Unit curUnit = unitMap.get(c); // unit deleted by other player, hashmap already updated if (curUnit == null) continue; curTexture = resolveTexture(curUnit); spriteBatch.draw( curTexture, c.getX() * Game.BLOCK_WIDTH + Game.TILE_OFFSET, c.getY() * Game.BLOCK_HEIGHT + Game.TILE_OFFSET, Game.BLOCK_WIDTH - Game.TILE_OFFSET, Game.BLOCK_HEIGHT - Game.TILE_OFFSET); String hpString = String.valueOf(curUnit.getHp()); hpFont.draw( spriteBatch, hpString, (c.getX() + 1) * Game.BLOCK_WIDTH - hpFont.getSpaceWidth() * 3, c.getY() * Game.BLOCK_HEIGHT + hpFont.getLineHeight()); } }
public void render(Batch b) { if (!isVisible()) { return; } if (Cvars.Client.Console.Height.getValue() == 0.0f) { b.draw( modelBackgroundTexture, 0.0f, 0.0f, getClient().getVirtualWidth(), getClient().getVirtualHeight()); b.draw(underlineBackgroundTexture, 0.0f, height, getClient().getVirtualWidth(), 2.0f); } else { b.draw( modelBackgroundTexture, 0.0f, height, getClient().getVirtualWidth(), getClient().getVirtualHeight() - height); b.draw( underlineBackgroundTexture, 0.0f, height + font.getLineHeight() + 2.0f, getClient().getVirtualWidth(), 2.0f); } String bufferSnapshot = getBuffer(); GlyphLayout glyphs = font.draw(b, getBufferPrefix() + " " + bufferSnapshot, 0, height + font.getLineHeight()); glyphs.setText(font, getBufferPrefix() + " " + bufferSnapshot.substring(0, getPosition())); float x = glyphs.width; float width; if (!isBufferEmpty() && getPosition() < getBufferLength()) { char c = bufferSnapshot.charAt(getPosition()); if (Character.isSpaceChar(c)) { width = font.getSpaceWidth(); } else { glyphs.setText(font, Character.toString(c)); width = glyphs.width - 4; } } else { width = font.getSpaceWidth(); } CARET.render(b, font, glyphs, x, height + 4, width, 1.0f); float lineY; if (Cvars.Client.Console.Height.getValue() == 0.0f) { lineY = font.getLineHeight(); } else { lineY = height + 4.0f + (font.getLineHeight() * 2); } int skip = outputOffset; for (String line : getOutput()) { if (Cvars.Client.Console.Height.getValue() == 0.0f && lineY >= height + font.getLineHeight()) { break; } if (skip > 0) { skip--; continue; } font.draw(b, line, 0.0f, lineY); lineY += font.getLineHeight(); } int position = getPosition(); Set<String> suggestions = new TreeSet<String>(); for (CommandProcessor commandProcessor : getCommandProcessors()) { for (Command command : commandProcessor.getSuggestions(bufferSnapshot, position)) { suggestions.add(command.toString()); } } if (!suggestions.isEmpty()) { glyphs.setText(font, getBufferPrefix() + " " + bufferSnapshot.substring(0, getPosition())); x = glyphs.width; float y = height; if (Cvars.Client.Console.Height.getValue() == 1.0f) { y += suggestions.size() * font.getLineHeight() + font.getLineHeight(); } float maxWidth = 0.0f; for (String suggestion : suggestions) { glyphs.setText(font, suggestion); maxWidth = Math.max(maxWidth, glyphs.width); } b.draw( suggestionBackgroundTexture, x, y - suggestions.size() * font.getLineHeight(), maxWidth, suggestions.size() * font.getLineHeight()); for (String suggestion : suggestions) { font.draw(b, suggestion, x, y); y -= font.getLineHeight(); } } }
public int getSpaceWidth() { return (int) bitmapFont.getSpaceWidth(); }