com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle Java Examples
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BottomMenu.java From Norii with Apache License 2.0 | 6 votes |
private void updateStatsMenu() { final float statsWidth = Gdx.graphics.getWidth() - (HERO_PORTRAIT_WIDTH_TILES * tileWidthPixel); final float statsHeight = BOTTOM_MENU_HEIGHT_TILES * tileHeightPixel; statsGroup.setHeight(statsHeight); statsGroup.setWidth(statsWidth); final LabelStyle labelStyle = Utility.createLabelStyle("fonts/BreatheFireIi-2z9W.ttf", 105, 1, Color.LIGHT_GRAY, 1, 1); for (final Actor actor : statsGroup.getChildren()) { if (actor.getClass() == Label.class) { final Label label = (Label) actor; label.setStyle(labelStyle); label.setFontScale(Gdx.graphics.getWidth() * LABEL_FONT_SCALE, Gdx.graphics.getHeight() * LABEL_FONT_SCALE); } } statsGroup.setPosition(HERO_PORTRAIT_WIDTH_TILES * tileWidthPixel, 0); }
Example #2
Source File: ResumeVsJoinTest.java From gdx-ai with Apache License 2.0 | 6 votes |
@Override public Actor createActor (final Skin skin) { Table table = new Table(); LabelStyle labelStyle = new LabelStyle(skin.get(LabelStyle.class)); labelStyle.background = skin.newDrawable("white", .6f, .6f, .6f, 1); String branchChildren = "\n spinAround\n selectTarget\n pursue"; table.add(new Label("parallel policy:\"sequence\" orchestrator:\"resume\"" + branchChildren, labelStyle)).pad(5); table.add(new Label("vs", skin)).padLeft(10).padRight(10); table.add(new Label("parallel policy:\"sequence\" orchestrator:\"join\"" + branchChildren, labelStyle)).pad(5); table.row().padTop(15); TextButton startButton = new TextButton("Start", skin); startButton.addListener(new ChangeListener() { @Override public void changed (ChangeEvent event, Actor actor) { oldScreen = container.getScreen(); container.setScreen(new TestScreen(ResumeVsJoinTest.this, skin)); } }); table.add(); table.add(startButton); table.add(); return table; }
Example #3
Source File: ParallelVsSequenceTest.java From gdx-ai with Apache License 2.0 | 6 votes |
@Override public Actor createActor (final Skin skin) { Table table = new Table(); LabelStyle labelStyle = new LabelStyle(skin.get(LabelStyle.class)); labelStyle.background = skin.newDrawable("white", .6f, .6f, .6f, 1); String branchChildren = "\n selectTarget\n pursue"; table.add(new Label("parallel policy:\"sequence\" orchestrator:\"resume\"" + branchChildren, labelStyle)).pad(5); table.add(new Label("vs", skin)).padLeft(10).padRight(10); table.add(new Label("sequence" + branchChildren, labelStyle)).pad(5); table.row().padTop(15); TextButton startButton = new TextButton("Start", skin); startButton.addListener(new ChangeListener() { @Override public void changed (ChangeEvent event, Actor actor) { oldScreen = container.getScreen(); container.setScreen(new TestScreen(ParallelVsSequenceTest.this, skin)); } }); table.add(); table.add(startButton); table.add(); return table; }
Example #4
Source File: InventoryActor.java From Cubes with MIT License | 6 votes |
public InventoryActor(Inventory inventory) { defaults().space(4f); add(new Label(inventory.getDisplayName(), new LabelStyle(Fonts.hud, Color.WHITE))).colspan(inventory.width); row(); for (int i = 0; i < inventory.itemStacks.length; i++) { SlotActor slotActor = new SlotActor(inventory, i); add(slotActor); if ((i + 1) % inventory.width == 0) { row(); } } pack(); }
Example #5
Source File: ScrollInventoryActor.java From Cubes with MIT License | 6 votes |
public ScrollInventoryActor(Inventory inventory, int slots) { defaults().space(4f); add(new Label(inventory.getDisplayName(), new LabelStyle(Fonts.hud, Color.WHITE))); row(); inner = new Table(); inner.defaults().space(4f); for (int i = 0; i < inventory.itemStacks.length; i++) { SlotActor slotActor = new SlotActor(inventory, i); inner.add(slotActor); if ((i + 1) % inventory.width == 0) { inner.row(); } } inner.pack(); scrollPane = new ScrollPane(inner); scrollPane.setScrollingDisabled(true, false); add(scrollPane).height(slots * CALIBRATION_PER_ROW).fill(); row(); pack(); }
Example #6
Source File: VisImageTextButton.java From vis-ui with Apache License 2.0 | 6 votes |
private void init (String text) { defaults().space(3); image = new Image(); image.setScaling(Scaling.fit); add(image); label = new Label(text, new LabelStyle(style.font, style.fontColor)); label.setAlignment(Align.center); add(label); setStyle(style); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisImageTextButton.this); return false; } }); }
Example #7
Source File: MainListener.java From skin-composer with MIT License | 6 votes |
@Override public void stylePropertyChanged(StyleProperty styleProperty, Actor styleActor) { if (styleProperty.type == Drawable.class) { dialogFactory.showDialogDrawables(styleProperty, dialogListener); } else if (styleProperty.type == Color.class) { dialogFactory.showDialogColors(styleProperty, dialogListener); } else if (styleProperty.type == BitmapFont.class) { dialogFactory.showDialogFonts(styleProperty, dialogListener); } else if (styleProperty.type == Float.TYPE) { main.getUndoableManager().addUndoable(new UndoableManager.DoubleUndoable(main, styleProperty, ((Spinner) styleActor).getValue()), false); } else if (styleProperty.type == ScrollPaneStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true); } else if (styleProperty.type == LabelStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true); } else if (styleProperty.type == ListStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root, styleProperty, (SelectBox) styleActor), true); } }
Example #8
Source File: DialogBitmapFont.java From skin-composer with MIT License | 6 votes |
private void updateLabelHighlight(String requiredLabelName) { var normalStyle = skin.get(LabelStyle.class); var requiredStyle = skin.get("dialog-required", LabelStyle.class); var actors = new Array<Actor>(); actors.addAll(getChildren()); for (int i = 0; i < actors.size; i++) { var actor = actors.get(i); if (actor instanceof Group) { actors.addAll(((Group) actor).getChildren()); } if (actor instanceof Label) { Label label = (Label) actor; if (label.getStyle().equals(requiredStyle)) { label.setStyle(normalStyle); } if (requiredLabelName != null && label.getName() != null && label.getName().equals(requiredLabelName)) { label.setStyle(requiredStyle); } } } }
Example #9
Source File: VisImageTextButton.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void setStyle (ButtonStyle style) { if (!(style instanceof VisImageTextButtonStyle)) throw new IllegalArgumentException("style must be a VisImageTextButtonStyle."); super.setStyle(style); this.style = (VisImageTextButtonStyle) style; if (image != null) updateImage(); if (label != null) { VisImageTextButtonStyle textButtonStyle = (VisImageTextButtonStyle) style; LabelStyle labelStyle = label.getStyle(); labelStyle.font = textButtonStyle.font; labelStyle.fontColor = textButtonStyle.fontColor; label.setStyle(labelStyle); } }
Example #10
Source File: MessageTestBase.java From gdx-ai with Apache License 2.0 | 5 votes |
protected void addSeparator (Table table) { Label lbl = new Label("", container.skin); lbl.setColor(0.75f, 0.75f, 0.75f, 1); lbl.setStyle(new LabelStyle(lbl.getStyle())); lbl.getStyle().background = container.skin.newDrawable("white"); table.add(lbl).colspan(2).height(1).width(220).pad(5, 1, 5, 1); }
Example #11
Source File: LogMenu.java From Cubes with MIT License | 5 votes |
public LogMenu() { label = new Label("", new LabelStyle(Fonts.smallHUD, Color.BLACK)); label.setWrap(true); Drawable background = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/LogBackground.png")); scrollPane = new ScrollPane(label, new ScrollPaneStyle(background, null, null, null, null)); scrollPane.setScrollingDisabled(true, false); back = MenuTools.getBackButton(this); stage.addActor(scrollPane); stage.addActor(back); refresh(); }
Example #12
Source File: InfoMenu.java From Cubes with MIT License | 5 votes |
public InfoMenu(String labelText, boolean back) { super(); text = new Label(labelText, new LabelStyle(Fonts.hud, Color.WHITE)); text.setAlignment(Align.center, Align.center); stage.addActor(text); if (back) { button = MenuTools.getBackButton(this); stage.addActor(button); } }
Example #13
Source File: InfoMenu.java From Cubes with MIT License | 5 votes |
public InfoMenu(String labelText, String buttonText) { super(); text = new Label(labelText, new LabelStyle(Fonts.hud, Color.WHITE)); text.setAlignment(Align.center, Align.center); button = new TextButton(buttonText, skin); stage.addActor(text); stage.addActor(button); }
Example #14
Source File: SteeringTestBase.java From gdx-ai with Apache License 2.0 | 5 votes |
protected void addSeparator (Table table) { Label lbl = new Label("", container.skin); lbl.setColor(0.75f, 0.75f, 0.75f, 1); lbl.setStyle(new LabelStyle(lbl.getStyle())); lbl.getStyle().background = container.skin.newDrawable("white"); table.add(lbl).colspan(2).height(1).width(220).pad(5, 1, 5, 1); }
Example #15
Source File: PathFinderTestBase.java From gdx-ai with Apache License 2.0 | 5 votes |
protected void addSeparator (Table table) { Label lbl = new Label("", container.skin); lbl.setColor(0.75f, 0.75f, 0.75f, 1); lbl.setStyle(new LabelStyle(lbl.getStyle())); lbl.getStyle().background = container.skin.newDrawable("white"); table.add(lbl).colspan(2).height(1).width(220).pad(5, 1, 5, 1); }
Example #16
Source File: Utility.java From Norii with Apache License 2.0 | 5 votes |
public static LabelStyle createLabelStyle(final String fontPath, final int size, final int borderWidth, final Color color, final int shadowX, final int shadowY) { final FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(fontPath)); final FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = size; parameter.borderWidth = borderWidth; parameter.color = color; parameter.shadowOffsetX = shadowX; parameter.shadowOffsetY = shadowY; final BitmapFont font = generator.generateFont(parameter); final LabelStyle labelStyle = new LabelStyle(); labelStyle.font = font; return labelStyle; }
Example #17
Source File: InputPanel.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
protected void init(Skin skin, String title, String desc, Actor c, boolean mandatory, String defaultValue) { // debug(); this.mandatory = mandatory; this.setSkin(skin); LabelStyle style = new LabelStyle(skin.get(LabelStyle.class)); this.title = new Label(title, style); this.desc = new Label(desc, skin, "subtitle"); this.desc.setWrap(false); this.field = c; // row().expand(); float titleWidth = this.title.getStyle().font.getSpaceXadvance() * 35; add(this.title).width(titleWidth).left().top(); this.title.setWidth(titleWidth); this.title.setWrap(true); // row().expand(); add(field).expandX().left().top(); if (USE_TOOLTIPS) { TextTooltip t = new TextTooltip(desc, skin); this.title.addListener(t); this.field.addListener(t); } else { row().expand(); add(this.desc).colspan(2).left(); } if (defaultValue != null) setText(defaultValue); }
Example #18
Source File: DialogTenPatch.java From skin-composer with MIT License | 5 votes |
public void validateName() { var valid = drawableData.name != null && !drawableData.name.matches("^\\d.*|^-.*|.*\\s.*|.*[^a-zA-Z\\d\\s-_ñáéíóúüÑÁÉÍÓÚÜ].*|^$"); if (valid && main.getProjectData().getAtlasData().getDrawable(drawableData.name) != null) { if (!drawableData.name.equals(originalName)) { valid = false; } } Button button = findActor("okayButton"); button.setDisabled(!valid); Label label = findActor("nameLabel"); label.setStyle(valid ? skin.get(LabelStyle.class) : skin.get("dialog-required", LabelStyle.class)); }
Example #19
Source File: MenuItem.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void setStyle (ButtonStyle style) { if (!(style instanceof MenuItemStyle)) throw new IllegalArgumentException("style must be a MenuItemStyle."); super.setStyle(style); this.style = (MenuItemStyle) style; if (label != null) { TextButtonStyle textButtonStyle = (TextButtonStyle) style; LabelStyle labelStyle = label.getStyle(); labelStyle.font = textButtonStyle.font; labelStyle.fontColor = textButtonStyle.fontColor; label.setStyle(labelStyle); } }
Example #20
Source File: MainMenuScreen.java From Norii with Apache License 2.0 | 5 votes |
private void createButtons() { final Skin statusUISkin = Utility.getStatusUISkin(); final LabelStyle labelStyle = createTitleStyle(); title = new Label("Norii:", labelStyle); newGameButton = new TextButton("New Game", statusUISkin); exitButton = new TextButton("Exit", statusUISkin); }
Example #21
Source File: CocoStudioUIEditor.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
public TTFLabelStyle createLabelStyle(ObjectData option, String text, Color color) { FileHandle fontFile = null; if (ttfs != null && option.getFontResource() != null) { fontFile = ttfs.get(option.getFontResource().getPath()); } if (fontFile == null) {// 使用默认字体文件 fontFile = defaultFont; } if (fontFile == null) { debug(option, "ttf字体不存在,使用默认字体"); } BitmapFont font = null; if (fontFile == null) { String name = "nativefont" + option.getFontSize(); NativeFont nativeFont = fonts.get(name); if (nativeFont == null) { nativeFont = new NativeFont(new NativeFontPaint(option.getFontSize())); nativeFont.appendText(DEFAULT_CHARS); fonts.put(name, nativeFont); } nativeFont.appendText(option.getLabelText()); LogUtil.log(option.getLabelText()); font = nativeFont; } else { font = FontUtil.createFont(fontFile, text, option.getFontSize()); } return new TTFLabelStyle(new LabelStyle(font, color), fontFile, option.getFontSize()); }
Example #22
Source File: MainMenuInterface.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
private void setUpSkin() { Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888); pixmap.setColor(Color.LIGHT_GRAY); pixmap.fill(); skin.add("grey", new Texture(pixmap)); titleSprite.setX(TITLE_SPRITE_POS_X); titleSprite.setY(TITLE_SPRITE_POS_Y); LabelStyle labelStyle = new LabelStyle(); skin.add("default", finePrint); labelStyle.font = skin.getFont("default"); skin.add("default", labelStyle); CheckBoxStyle checkBoxStyle = new CheckBoxStyle(); checkBoxStyle.checkboxOff = skin.newDrawable("grey", Color.LIGHT_GRAY); checkBoxStyle.checkboxOn = skin.newDrawable("grey", Color.LIGHT_GRAY); checkBoxStyle.font = skin.getFont("default"); checkBoxStyle.checkboxOff = new TextureRegionDrawable(unchecked); checkBoxStyle.checkboxOn = new TextureRegionDrawable(checked); skin.add("default", checkBoxStyle); SliderStyle sliderStyle = new SliderStyle(); sliderStyle.background = new TextureRegionDrawable(background); sliderStyle.knob = new TextureRegionDrawable(knob); skin.add("default-horizontal", sliderStyle); ButtonStyle buttonStyle = new ButtonStyle(); skin.add("default", buttonStyle); TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.font = skin.getFont("default"); textButtonStyle.up = new NinePatchDrawable(patchBox); skin.add("default", textButtonStyle); }
Example #23
Source File: CraftingInventoryActor.java From Cubes with MIT License | 4 votes |
public CraftingInventoryActor(boolean name) { c = new CraftingInventory(); defaults().space(4f); if (name) { add(new Label(c.getDisplayName(), new LabelStyle(Fonts.hud, Color.WHITE))).colspan(9); row(); } add().uniform(); add().uniform(); add(s(0)).uniform(); add(s(1)).uniform(); add(s(2)).uniform(); add().uniform(); add().uniform(); add().uniform(); add().uniform(); row(); add().uniform(); add().uniform(); add(s(3)).uniform(); add(s(4)).uniform(); add(s(5)).uniform(); add().uniform(); add(new SlotActor(c.output, 0)).uniform(); add().uniform(); add().uniform(); row(); add().uniform(); add().uniform(); add(s(6)).uniform(); add(s(7)).uniform(); add(s(8)).uniform(); add().uniform(); add().uniform(); add().uniform(); add().uniform(); row(); pack(); }
Example #24
Source File: StatusUI.java From Norii with Apache License 2.0 | 4 votes |
private void createFont() { final BitmapFont font = Utility.getFreeTypeFontAsset("fonts/BreatheFireIi-2z9W.ttf"); labelStyle = new LabelStyle(); labelStyle.font = font; }
Example #25
Source File: MainMenuScreen.java From Norii with Apache License 2.0 | 4 votes |
private LabelStyle createTitleStyle() { return Utility.createLabelStyle("fonts/BreatheFireIi-2z9W.ttf", 105, 1, Color.LIGHT_GRAY, 1, 1); }
Example #26
Source File: StyleData.java From skin-composer with MIT License | 4 votes |
public void resetProperties() { properties.clear(); parent = null; if (clazz.equals(Button.class)) { newStyleProperties(ButtonStyle.class); } else if (clazz.equals(CheckBox.class)) { newStyleProperties(CheckBoxStyle.class); properties.get("checkboxOn").optional = false; properties.get("checkboxOff").optional = false; properties.get("font").optional = false; } else if (clazz.equals(ImageButton.class)) { newStyleProperties(ImageButtonStyle.class); } else if (clazz.equals(ImageTextButton.class)) { newStyleProperties(ImageTextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(Label.class)) { newStyleProperties(LabelStyle.class); properties.get("font").optional = false; } else if (clazz.equals(List.class)) { newStyleProperties(ListStyle.class); properties.get("font").optional = false; properties.get("fontColorSelected").optional = false; properties.get("fontColorUnselected").optional = false; properties.get("selection").optional = false; } else if (clazz.equals(ProgressBar.class)) { newStyleProperties(ProgressBarStyle.class); //Though specified as optional in the doc, there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(ScrollPane.class)) { newStyleProperties(ScrollPaneStyle.class); } else if (clazz.equals(SelectBox.class)) { newStyleProperties(SelectBoxStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; properties.get("scrollStyle").optional = false; properties.get("scrollStyle").value = "default"; properties.get("listStyle").optional = false; properties.get("listStyle").value = "default"; } else if (clazz.equals(Slider.class)) { newStyleProperties(SliderStyle.class); //Though specified as optional in the doc, there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(SplitPane.class)) { newStyleProperties(SplitPaneStyle.class); properties.get("handle").optional = false; } else if (clazz.equals(TextButton.class)) { newStyleProperties(TextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(TextField.class)) { newStyleProperties(TextFieldStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; } else if (clazz.equals(TextTooltip.class)) { newStyleProperties(TextTooltipStyle.class); properties.get("label").optional = false; properties.get("label").value = "default"; } else if (clazz.equals(Touchpad.class)) { newStyleProperties(TouchpadStyle.class); } else if (clazz.equals(Tree.class)) { newStyleProperties(TreeStyle.class); properties.get("plus").optional = false; properties.get("minus").optional = false; } else if (clazz.equals(Window.class)) { newStyleProperties(WindowStyle.class); properties.get("titleFont").optional = false; } }
Example #27
Source File: ServerConnectGUI.java From Radix with MIT License | 4 votes |
@Override public void init() { stage = new Stage(); // TODO memory manage background = new Texture(Gdx.files.internal("textures/block/obsidian.png")); background.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); errorLabel = new Label(null, new LabelStyle(new BitmapFont(), Color.RED)); TextFieldStyle fieldStyle = new TextFieldStyle(); fieldStyle.font = new BitmapFont(); fieldStyle.fontColor = Color.WHITE; TextField ipField = new TextField("IP:Port", fieldStyle); ImageTextButtonStyle btnStyle = RadixClient.getInstance().getSceneTheme().getButtonStyle(); TextButton connectButton = new TextButton("Connect", btnStyle); connectButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { String[] ipPort = ipField.getText().split(":"); if(ipPort.length != 2) { invalidIpSyntax(); return; } try { RadixClient.getInstance().enterRemoteWorld(ipPort[0], Short.parseShort(ipPort[1])); } catch (NumberFormatException ex) { invalidPort(); } } }); Table table = new Table(); table.setFillParent(true); table.add(ipField); table.row(); table.add(errorLabel); table.row(); table.add(connectButton); stage.addActor(table); }
Example #28
Source File: TTFLabelStyle.java From cocos-ui-libgdx with Apache License 2.0 | 4 votes |
public TTFLabelStyle(LabelStyle labelStyle, FileHandle fontFileHandle, int fontSize) { super(labelStyle); this.fontFileHandle = fontFileHandle; this.fontSize = fontSize; }
Example #29
Source File: BrowseField.java From skin-composer with MIT License | 4 votes |
public BrowseFieldStyle(ImageButtonStyle imageButtonStyle, TextButtonStyle textButtonStyle, LabelStyle labelStyle) { this.mainButtonStyle = textButtonStyle; this.rightButtonStyle = imageButtonStyle; this.labelStyle = labelStyle; }