void drawPlayerNames(){ GlyphLayout layout = Pools.obtain(GlyphLayout.class); Draw.tscl(0.25f/2); for(Player player : Vars.control.playerGroup.all()){ if(!player.isLocal){ layout.setText(Core.font, player.name); Draw.color(0f, 0f, 0f, 0.3f); Draw.rect("blank", player.x, player.y + 8 - layout.height/2, layout.width + 2, layout.height + 2); Draw.color(); Draw.tcolor(NetClient.colorArray[player.id % NetClient.colorArray.length]); Draw.text(player.name, player.x, player.y + 8); Draw.tcolor(); } } Pools.free(layout); Draw.tscl(Vars.fontscale); }
public TextActor(String string,Color color,float targetwidth,TextAlign align,float scaleXY ,float x ,float y) { // TODO Auto-generated constructor stub font = book.base_font; text_string = string ; xpos = x; ypos = y; width = targetwidth ; text_color = (color==null?Color.BLACK:color) ; this.align = align; scale = scaleXY; font.getData().setScale(scaleXY); //font.setColor(Color.BLUE); best_score_text_layout = new GlyphLayout( font, text_string, text_color, width, this.align == TextAlign.align_cinter?Align.center:(this.align==TextAlign.align_right?Align.right:Align.left), true); }
/** * Initialisierung. * * @param game Zugriff auf die Spielinstanz * @param level Zugriff auf die aktive Levelinstanz */ public IngameMenu(SchoolGame game, Level level) { this.game = game; this.level = level; titleFont = game.getTitleFont(); textFont = game.getDefaultFont(); smallFont = game.getLongTextFont(); selectSound = game.getAudioManager().createSound("menu", "select.wav", true); changeSound = game.getAudioManager().createSound("menu", "change.wav", true); batch = new SpriteBatch(); shapeRenderer = new ShapeRenderer(); localeBundle = level.getLocaleBundle(); fontLayout = new GlyphLayout(); projection = new Matrix4(); }
public MenuNewSlot(String label, String detail, SaveData saveData) { super(label); this.saveData = saveData; this.detail = detail; setCustomRendering(true); setHeight(100); used = saveData.isUsed() ? 1 : 0; id = saveData.getSlot().ordinal() + 1; playerName = saveData.getPlayerName(); gender = saveData.isMale() ? "M" : "W"; levelName = saveData.getLevelName(); formatPlaytime(saveData.getPlayTime()); fontLayout = new GlyphLayout(); }
/** * Initialisierung. * * @param game zeigt auf das SchoolGame, dass das Spiel verwaltet */ @Override public void create(SchoolGame game) { Gdx.app.getApplicationLogger().log("INFO", "Menu init..."); this.game = game; entries = new ArrayList<MenuEntry>(); this.setupMenu(); batch = new SpriteBatch(); font = game.getDefaultFont(); fontLayout = new GlyphLayout(); selectSound = game.getAudioManager().createSound("menu", "select.wav", true); changeSound = game.getAudioManager().createSound("menu", "change.wav", true); game.getAudioManager().selectMusic(MUSIC_NAME, 0f); FileHandle baseFileHandle = Gdx.files.internal("data/I18n/" + getI18nName()); localeBundle = I18NBundle.createBundle(baseFileHandle); Gdx.app.getApplicationLogger().log("INFO", "Menu finished..."); }
/** * Initialisierung. * * @param game zeigt auf das SchoolGame, dass das Spiel verwaltet */ @Override public void create(SchoolGame game) { this.game = game; batch = new SpriteBatch(); font = game.getDefaultFont(); fontLayout = new GlyphLayout(); offset -= Gdx.graphics.getHeight() / 2 - 35; FileHandle credits = Gdx.files.internal("data/misc/credits.txt"); if (credits.exists() && !credits.isDirectory()) { prepareCredits(credits); } }
/** * Initialisierung * * @param game zeigt auf das SchoolGame, dass das Spiel verwaltet */ @Override public void create(SchoolGame game) { this.game = game; saveData = new SaveData(this.game, this.slot); batch = new SpriteBatch(); font = game.getDefaultFont(); smallFont = game.getLongTextFont(); fontLayout = new GlyphLayout(); FileHandle baseFileHandle = Gdx.files.internal("data/I18n/GameMenu"); localeBundle = I18NBundle.createBundle(baseFileHandle); }
public MenuLoadSlot(String label, String detail, SaveData saveData) { super(label); this.saveData = saveData; this.detail = detail; setEnabled(saveData.isUsed()); setCustomRendering(true); setHeight(100); used = saveData.isUsed() ? 1 : 0; id = saveData.getSlot().ordinal() + 1; playerName = saveData.getPlayerName(); gender = saveData.isMale() ? "M" : "W"; levelName = saveData.getLevelName(); formatPlaytime(saveData.getPlayTime()); fontLayout = new GlyphLayout(); }
public Crafting(int x, int y, int wid, int hei) { this.x = x; this.y = y; this.wid = wid; this.hei = hei; shapes = new ShapeRenderer(); this.active = true; fontHandler = new FontHandler(); layoutSave = new GlyphLayout(fontHandler.font32, "SAVE"); widthSave = layoutSave.width; heightSave = layoutSave.height; layoutExit = new GlyphLayout(fontHandler.font32, "X"); widthExit = layoutExit.width; heightExit = layoutExit.height; }
public MainMenu(JGame game) { this.game = game; this.batch = game.batch; playY = (game.screenY / 2) + 200; loadY = (game.screenY / 2) + 100; exitY = (game.screenY / 2); shapes = new ShapeRenderer(); fontHandler = new FontHandler(); layoutPlay = new GlyphLayout(fontHandler.font90, "PLAY"); widthPlay = layoutPlay.width; heightPlay = layoutPlay.height; layoutLoad = new GlyphLayout(fontHandler.font90, "LOAD"); widthLoad = layoutLoad.width; heightLoad = layoutLoad.height; layoutExit = new GlyphLayout(fontHandler.font90, "EXIT"); widthExit = layoutExit.width; heightExit = layoutExit.height; }
@Override protected void initialize() { super.initialize(); glyphLayout = new GlyphLayout(); buildLabel = createLabel(12 * G.ZOOM, 4 * G.ZOOM + 18 * G.ZOOM, "FFFFFFFF", "Build progress", "000000FF", 4000); scoreLabel = createLabel(80 * G.ZOOM, 4 * G.ZOOM + 18 * G.ZOOM, "FFFFFFFF", "Score:", "000000FF", 4000); progressButton = new DynastyEntityBuilder(world) .with(Tint.class).with( new Bounds(0, 0, 26*G.ZOOM, 16*G.ZOOM), new Clickable(), new Button("btn-turn-up", "btn-turn-hover", "btn-turn-down", new ButtonListener() { @Override public void run() { progressAlgorithmSystem.progress(); } }) ) .group("progress") .anim("btn-test-up") .renderable(920) .pos(7 * G.ZOOM + AssetSystem.PROGRESS_BAR_BACKGROUND_WIDTH * G.ZOOM, 4 * G.ZOOM) .scale(G.ZOOM) .build(); }
private List<GlyphLayout> paginateText(final FontSet fontSet, final String text) { List<GlyphLayout> results = new LinkedList<>(); Queue<String> words = new LinkedList<>(); words.addAll(Arrays.asList(text.split(" "))); String pageText = null; GlyphLayout layout = generateGlyphLayout(fontSet, ""); while (!words.isEmpty()) { pageText = (pageText == null) ? words.peek() : String.join(" ", pageText, words.peek()); GlyphLayout nextLayout = generateGlyphLayout(fontSet, pageText); if (nextLayout.height < getHeight()) { layout = nextLayout; words.remove(); } else { results.add(layout); pageText = null; layout = generateGlyphLayout(fontSet, ""); } } results.add(layout); return results; }
@Override public void show() { Map<String, Sprite> loadingSprites = GraphicsLoader.getCommonBackground(); background = loadingSprites.get("background"); logo = loadingSprites.get("logo_faded"); labelFont = FontsHandler.getDefaultBitmapFont((int) (DimensionHandler.getScreenHeight() / 15)); selectTextLayout = new GlyphLayout(labelFont, "Select Trumps"); textX = DimensionHandler.getScreenWidth()/8; textY = DimensionHandler.getScreenHeight()/6*5; suits = GraphicsLoader.getSuits(); prepareSuits(); spriteBatch = new SpriteBatch(); stage = new Stage(); stage.clear(); stage.addActor(suits.get(Suit.HEARTS)); stage.addActor(suits.get(Suit.SPADES)); stage.addActor(suits.get(Suit.DIAMONDS)); stage.addActor(suits.get(Suit.CLUBS)); Gdx.input.setInputProcessor(stage); }
@Override public void show() { Map<String, Sprite> loadingSprites = GraphicsLoader.getCommonBackground(); background = loadingSprites.get("background"); logo = loadingSprites.get("logo_faded"); labelFont = FontsHandler.getDefaultBitmapFont((int) (DimensionHandler.getScreenHeight() / 15)); selectTextLayout = new GlyphLayout(labelFont, "Select Friendly Player"); textX = DimensionHandler.getScreenWidth()/8; textY = DimensionHandler.getScreenHeight()/6*5; playerFont = FontsHandler.getDefaultBitmapFont((int) (DimensionHandler.getScreenHeight() / 20)); style = new Label.LabelStyle(playerFont, Color.WHITE); setLabels(); spriteBatch = new SpriteBatch(); stage = new Stage(); stage.clear(); stage.addActor(p1Label); stage.addActor(p2Label); stage.addActor(p3Label); Gdx.input.setInputProcessor(stage); }
@Override public void draw(Batch batch,float parentAlpha){ AssetLoader.font.getData().setScale(getScaleX()); timer+=Gdx.graphics.getDeltaTime(); FPSCount++; String text="FPS: "+fps; GlyphLayout layout=new GlyphLayout(); layout.setText(AssetLoader.font, text); float height=layout.height; AssetLoader.font.draw(batch, text, 0, height); if(FPSCount>=60) { fps=(int) ((float)FPSCount/timer); timer=0; FPSCount=0; } }
@Override public void draw (SpriteBatch batch) { Matrix4 oldTransformMatrix = batch.getTransformMatrix().cpy(); fontMatrix.set(resetMatrix); fontMatrix.rotate(Vector3.Z, getParent().transform.getRotation()); Vector2 position = getParent().transform.getPosition(); fontMatrix.trn(position.x, position.y, 0); batch.setTransformMatrix(fontMatrix); font.setColor(tint); font.getData().setScale(0.05f * xScale, 0.05f * yScale); GlyphLayout layout = font.draw(batch, text, centered ? -xOffset / 2 : 0, centered ? yOffset / 2 : 0); xOffset = layout.width; yOffset = layout.height; batch.setTransformMatrix(oldTransformMatrix); }
@Override public void show() { super.show(); layout = new GlyphLayout(); font = new NativeFont(new NativeFontPaint(25)); font.appendText("正在加载...0123456789%"); font.setColor(Color.BLACK); layout.setText(font, "正在加载...100%"); stage = new Stage(new StretchViewport(1280, 720)); assetManager = new AssetManager(); assetManager.setLogger(new Logger("log", Logger.DEBUG)); assetManager.setLoader(CocosScene.class, new CocosLoader(new InternalFileHandleResolver())); assetManager.load("mainscene/MenuScene.json", CocosScene.class); }
public Button(String texture, int x, int y, String content, boolean haveDarkEffect) { super(texture, x, y); pressed = false; justSound = false; this.content = content; this.haveDarkEffect = haveDarkEffect; //Si tenemos un texto para contenido, lo centramos en el botón if (content != null) { GlyphLayout layout = new GlyphLayout(); layout.setText(FontManager.text, FontManager.getFromBundle(content)); contentX = x + (this.getWidth() - layout.width) / 2; contentY = y + (this.getHeight() + layout.height) / 2; } }
private <E extends Enum<?>> void initItemsPositions(Class<E> menuEnumClass) { offset = new Vector2(0, 0); float verticalMenuSize = font.getXHeight() * (menuEnumClass.getEnumConstants().length) + verticalMenuSpacing * (menuEnumClass.getEnumConstants().length - 1); verticalMenuStart = Gdx.graphics.getHeight() - (Gdx.graphics.getHeight() - verticalMenuSize) / 2; float letterMaxWidth = 0; for (E enumValue : menuEnumClass.getEnumConstants()) { GlyphLayout layout = new GlyphLayout(); layout.setText(font, enumValue.toString()); letterMaxWidth = layout.width > letterMaxWidth ? layout.width : letterMaxWidth; menuItems.add(new MenuItem(enumValue, new Vector2((Gdx.graphics.getWidth() - layout.width) / 2, 0))); } horizontalMenuStart = (Gdx.graphics.getWidth() - letterMaxWidth) / 2; }
@Override public void show() { // TODO Auto-generated method stub img_ini01 = new Texture("T120SOFT_02.png"); p_width = Gdx.graphics.getWidth(); p_height = Gdx.graphics.getHeight(); camara = new OrthographicCamera(p_width,p_height); layout = new GlyphLayout(); fuente = new BitmapFont(Gdx.files.internal("font001.fnt"),false); str_inicio[0] = " T120 Soft Apps "; str_inicio[1] = "EMPEZAR"; str_inicio[2] = "OPCIONES"; str_inicio[3] = "SALIR"; count = 0; }
@Override public void show() { // TODO Auto-generated method stub img_ini01 = new Texture("T120SOFT_01.png"); p_width = Gdx.graphics.getWidth(); p_height = Gdx.graphics.getHeight(); camara = new OrthographicCamera(p_width,p_height); layout = new GlyphLayout(); fuente = new BitmapFont(Gdx.files.internal("font000.fnt"),false); str_inicio[0] = " T120 Soft Apps "; str_inicio[1] = "Pulsa para continuar"; count = 0; }
public Button(String text, float x, float y, int key) { font = new BitmapFont(); layout = new GlyphLayout(); this.key = key; this.text = text; setX(x); setY(y); layout.setText(font, text); setWidth((2 * offset) + layout.width); setHeight(11 + (2 * offset)); np = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np.png")), 16, 16, 16, 16); np_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_hover.png")), 16, 16, 16, 16); np_checked = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked.png")), 16, 16, 16, 16); np_checked_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked_hover.png")), 16, 16, 16, 16); checkbox = false; checked = false; }
public Button(String text, float x, float y) { font = new BitmapFont(); layout = new GlyphLayout(); this.text = text; setX(x); setY(y); key = -1; layout.setText(font, text); setWidth((2 * offset) + layout.width); setHeight(11 + (2 * offset)); np = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np.png")), 16, 16, 16, 16); np_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_hover.png")), 16, 16, 16, 16); np_checked = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked.png")), 16, 16, 16, 16); np_checked_hover = new NinePatch(new Texture(Gdx.files.internal("gfx/ui/np_checked_hover.png")), 16, 16, 16, 16); checkbox = false; checked = false; }
public void create() { shooter = this; if(Gdx.app.getType() == Application.ApplicationType.Android){ GUI_SCALE = 0.75F; } layout = new GlyphLayout(); prefs = Gdx.app.getPreferences("settings"); reloadSettings(); keys = (int[])InterScreenData.getInstance("desktop_keys").getData(); if(keys != null){ useKeys = true; } else { useKeys = false; } setScreen(new SplashScreen()); new CompletedLevel(); new OptionsScreen(); new DownloadScreen(); new PackScreen(); }
private Texture preprocess(Entity e) { TextBox box = boxes.get(e); box.text = box.generator.get(); Empire empire = empires.get(e); GlyphLayout bounds = font.getCache().setText(box.text, 0, 0); Pixmap pm = new Pixmap((int) bounds.width + PAD * 2, (int) bounds.height + PAD * 2, Pixmap.Format.RGBA8888); pm.setColor(empire.backColor); pm.fill(); pm.setColor(empire.color); pm.drawRectangle(0, 0, pm.getWidth(), pm.getHeight()); box.texture = new Texture(pm); box.color = empire.color; return box.texture; }
public MainMenuScreen(MaryoGame game) { super(game); this.game = game; batch = new SpriteBatch(); drawCam = new OrthographicCamera(Constants.MENU_CAMERA_WIDTH, Constants.MENU_CAMERA_HEIGHT); drawCam.position.set(Constants.MENU_CAMERA_WIDTH / 2 + (Constants.MENU_DRAW_WIDTH - Constants.MENU_CAMERA_WIDTH) / 2, Constants.MENU_CAMERA_HEIGHT / 2, 0); drawCam.update(); debugCam = new OrthographicCamera(1280, 720); debugCam.position.set(1280 / 2, 720 / 2, 0); debugCam.update(); hudCam = new OrthographicCamera(screenWidth, screenHeight); hudCam.position.set(screenWidth / 2, screenHeight / 2, 0); hudCam.update(); loader = new LevelLoader("main_menu"); debugFont = new BitmapFont(); debugFont.setColor(Color.RED); debugFont.getData().setScale(1.3f); debugGlyph = new GlyphLayout(); world = new World(this); selectionAdapter = new SelectionAdapter(loadSelectionItems(), this); exitDialog = new ConfirmDialog(this, hudCam); settingsDialog = new SettingsDialog(this, hudCam); }
@Override public void show() { super.show(); layout = new GlyphLayout(); tempVector = new Vector3(); campaignWorlds = new ArrayList<CampaignWorld>(); campaignWorlds.add(new CampaignWorld(new Texture("theme/basic/Icon.png"), "World 0's Name", "Put description here for basic")); campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 1","Put description here for fallback1")); campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 2","Put description here for fallback2")); campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 3","Put description here for fallback3")); campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 4","Put description here for fallback4")); campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 5","Put description here for fallback5")); campaignWorlds.add(new CampaignWorld(new Texture("theme/Fallback/Icon.png"), "Put Name Here 6","Put description here for fallback6")); halfFreeWidth = (int)((viewport.getWorldWidth() - ICON_SIZE) / 2); segmentWidth = ICON_SIZE + halfFreeWidth; length = segmentWidth * (campaignWorlds.size() - 1); background = new Texture("menus/Background_Campaign.png"); textBack = new Texture("menus/text_back_campaign.png"); addDisposables(background, textBack); addInputProcessor(this); }
public static void drawText(Batch batch, float x, float y, ItemStack itemStack) { if (itemStack == null || itemStack.item.getStackCountMax() == 1) return; BitmapFontCache cache = Fonts.smallHUD.getCache(); cache.clear(); GlyphLayout layout = cache.addText(Integer.toString(itemStack.count), x, y, 32f, Align.right, false); cache.translate(0, layout.height); cache.draw(batch); }
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); BitmapFontCache cache = Fonts.hud.getCache(); cache.clear(); GlyphLayout layout = cache.addText(String.format(format, getValue()), getX(), getY(), getWidth(), Align.center, false); cache.translate(0, (layout.height / 2) + (getHeight() / 2)); cache.draw(batch); }
/** Adds cached glyphs to the active BitmapFontCache as the char index progresses. */ private void addMissingGlyphs () { // Add additional glyphs to layout array, if any int glyphLeft = glyphCharIndex - cachedGlyphCharIndex; if (glyphLeft < 1) return; // Get runs GlyphLayout layout = super.getGlyphLayout(); Array<GlyphRun> runs = layout.runs; // Iterate through GlyphRuns to find the next glyph spot int glyphCount = 0; for (int runIndex = 0; runIndex < glyphRunCapacities.size; runIndex++) { int runCapacity = glyphRunCapacities.get(runIndex); if ((glyphCount + runCapacity) < cachedGlyphCharIndex) { glyphCount += runCapacity; continue; } // Get run and increase glyphCount up to its current size Array<Glyph> glyphs = runs.get(runIndex).glyphs; glyphCount += glyphs.size; // Next glyphs go here while (glyphLeft > 0) { // Skip run if this one is full int runSize = glyphs.size; if (runCapacity == runSize) { break; } // Put new glyph to this run cachedGlyphCharIndex++; glyphCount++; glyphLeft--; glyphs.add(glyphCache.get(cachedGlyphCharIndex)); } } }
public void update_text (String text){ text_string = text;/* font.getData().setScale(scale);*/ best_score_text_layout = new GlyphLayout( font, text_string, text_color, width, this.align == TextAlign.align_left?Align.left:(this.align==TextAlign.align_right?Align.right:Align.center), true); }
public MenuLabel(String label) { super(label); setEnabled(false); setCustomRendering(true); fontLayout = new GlyphLayout(); }
public MenuTitle(String label) { super(label); setEnabled(false); setCustomRendering(true); setHeight(85); fontLayout = new GlyphLayout(); }
/** * Initialisierung * * Wird automatisch aufgerufen. * Erfasst auch gleich die Liste aller Level. * * @param game zeigt auf das SchoolGame, dass das Spiel verwaltet. */ @Override public void create(SchoolGame game) { this.game = game; if (lastSlot == null) { game.setGameState(new MainMenu()); return; } saveData = new SaveData(game, lastSlot); batch = new SpriteBatch(); font = game.getDefaultFont(); smallFont = game.getLongTextFont(); fontLayout = new GlyphLayout(); FileHandle baseFileHandle = Gdx.files.internal("data/I18n/Cheats"); localeBundle = I18NBundle.createBundle(baseFileHandle); Set<String> levelIdSet = levelMap.keySet(); levelIds = levelIdSet.toArray(new String[levelIdSet.size()]); Arrays.sort(levelIds); cols = (levelIds.length - (levelIds.length % MAX_ROWS)) / MAX_ROWS; if (levelIds.length % MAX_ROWS > 0) cols++; }
private float getTitleScale() { float screenWidth = getFrame().width; GlyphLayout layout = new GlyphLayout(titleFont, TITLE_TEXT); float titleWidth = layout.width; float scale = screenWidth / (titleWidth); return scale; }
@Override public void create () { spriteBatch = new SpriteBatch(); glyphLayout = new GlyphLayout(); SettingsUtil.load(); AssetsUtil.load(); setScreen(new MainScreen(this)); }
private void initDebugRenderer() { if (!DEBUG_RENDERER) { return; } mDebugRenderer = new Box2DDebugRenderer(); mDebugFont = new BitmapFont(); mDebugTextLayout = new GlyphLayout(mDebugFont, "test"); }