public void addCheckBox(String text, boolean checked, Consumer<Boolean> lis) { CheckBoxStyle style = skin.get(CheckBoxStyle.class); CheckBox cb = new CheckBox(text, style); cb.setChecked(checked); if (lis != null) cb.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { lis.accept(Boolean.valueOf(cb.isChecked())); } }); table.add(cb).colspan(nbColumns).minHeight(cb.getMinHeight()).prefHeight(cb.getPrefHeight()); table.row(); }
/** * Erstellt den {@link CheckBoxStyle} für die Methode createCheckbox. * * @return {@link CheckBoxStyle} */ private CheckBoxStyle createCheckboxStyle() { Drawable on = new TextureRegionDrawable(AssetManager.getTextureRegion("ui", "on")); Drawable off = new TextureRegionDrawable(AssetManager.getTextureRegion("ui", "off")); CheckBoxStyle style = new CheckBoxStyle(); style.checkboxOn = on; style.checkboxOff = off; style.font = new BitmapFont(Gdx.files.internal("pictures/fontButton/font.fnt")); return style; }
@Override public void onFinishLoading() { Skin skin = getSkin(Assets.Skin.UI_SKIN); BitmapFont menuFont = getFont(game.deviceSettings.menuFont); BitmapFont screenTitle = getFont(game.deviceSettings.screenTitleFont); BitmapFont hudFont = getFont(game.deviceSettings.hudFont); BitmapFont rulesFont = getFont(game.deviceSettings.rulesFont); skin.get(Assets.Skin.SKIN_STYLE_MENU, TextButtonStyle.class).font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_GAME, TextButtonStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_DIALOG, TextButtonStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_MENU, ImageTextButtonStyle.class).font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_GAME, ImageTextButtonStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_MENU, SelectBoxStyle.class).font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_MENU, SelectBoxStyle.class).listStyle.font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_GAME, SelectBoxStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_GAME, SelectBoxStyle.class).listStyle.font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_DIALOG, WindowStyle.class).titleFont = hudFont; skin.get(Assets.Skin.SKIN_STYLE_MENU, LabelStyle.class).font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_SCREEN_TITLE, LabelStyle.class).font = screenTitle; skin.get(Assets.Skin.SKIN_STYLE_GAME, LabelStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_DIALOG, LabelStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_PLAYER_TAG, LabelStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_RULES, LabelStyle.class).font = rulesFont; skin.get(Assets.Skin.SKIN_STYLE_MENU, TextFieldStyle.class).font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_GAME, TextFieldStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_MENU, CheckBoxStyle.class).font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_GAME, CheckBoxStyle.class).font = hudFont; skin.get(Assets.Skin.SKIN_STYLE_MENU, ListStyle.class).font = menuFont; skin.get(Assets.Skin.SKIN_STYLE_GAME, ListStyle.class).font = hudFont; }
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); }
public void resetProperties() { properties.clear(); 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; } }
public CheckBoxStyle getCheckBoxStyle() { return skin.get(CheckBoxStyle.class); }
public void createStyles(ResourcesManager resourcesManager) { if (!initialize) { initialize=true; font = resourcesManager.get(resourcesManager.DEFAULT_FONT); font.setScale(ScaleUtil.getSizeRatio()); font.setUseIntegerPositions(false); font2 = resourcesManager.get(resourcesManager.HEADER_FONT); font2.setScale(ScaleUtil.getSizeRatio()); font2.setUseIntegerPositions(false); skin = new Skin(); skin.add("default", font); skin.add("header", font2); skin.add("lt-blue", new Color(.62f, .76f, .99f, 1f)); skin.add("lt-green", new Color(.39f, .9f, .6f, 1f)); skin.add("dark-blue", new Color(.79f, .95f, 91f, 1f)); skin.addRegions(resourcesManager.<TextureAtlas>get(resourcesManager.GUI_ATLAS)); skin.addRegions(resourcesManager.<TextureAtlas>get(resourcesManager.GUI_PACK_ATLAS)); TextureRegionDrawable touchpad_background = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.GUI_ATLAS)).findRegion("touchpad_background")); TextureRegionDrawable touchpad_thumb = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.GUI_ATLAS)).findRegion("touchpad_thumb")); TextureRegionDrawable checkox_true = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("check-on")); TextureRegionDrawable checkox_false = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("check-off")); TextureRegionDrawable slider_knob = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("default-slider-knob")); TextureRegionDrawable slider = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("default-slider")); CheckBoxStyle checkBoxStyle = new CheckBox.CheckBoxStyle(checkox_false, checkox_true, font, Color.WHITE); SpriteDrawable stats = new SpriteDrawable(new Sprite((Texture) resourcesManager.get(resourcesManager.STATS_BACKGROUND))); SliderStyle sliderStyle = new SliderStyle(slider, slider_knob); skin.add("default",new WindowStyle(font2,Color.ORANGE,skin.getDrawable("debug"))); skin.add("stats", stats); LabelStyle lbs = new LabelStyle(); lbs.font = font; lbs.fontColor = Color.WHITE; skin.add("default", lbs); LabelStyle lbsHeader = new LabelStyle(); lbsHeader.font = font2; lbsHeader.fontColor = Color.WHITE; skin.add("header", lbsHeader); TextButtonStyle tbs = new TextButtonStyle(skin.getDrawable("btnMenu"), skin.getDrawable("btnMenuPress"), skin.getDrawable("btnMenu"), font); tbs.fontColor = skin.getColor("dark-blue"); tbs.pressedOffsetX = Math.round(1f * Gdx.graphics.getDensity()); tbs.pressedOffsetY = tbs.pressedOffsetX * -1f; ImageButton.ImageButtonStyle ImageButtonLeft = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonLeft"), skin.getDrawable("buttonLeftPress"), skin.getDrawable("buttonLeft"), null, null, null); ImageButton.ImageButtonStyle ImageButtonRight = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonRight"), skin.getDrawable("buttonRightPress"), skin.getDrawable("buttonRight"), null, null, null); ImageButton.ImageButtonStyle ImageButtonUp = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonUp"), skin.getDrawable("buttonUpPress"), skin.getDrawable("buttonUp"), null, null, null); Touchpad.TouchpadStyle touchpadStyle = new Touchpad.TouchpadStyle(); touchpadStyle.background = touchpad_background; touchpadStyle.knob = touchpad_thumb; skin.add("default", tbs); skin.add("buttonLeft", ImageButtonLeft); skin.add("buttonRight", ImageButtonRight); skin.add("buttonUp", ImageButtonUp); skin.add("default", touchpadStyle); skin.add("default", checkBoxStyle); skin.add("default-horizontal", sliderStyle); } }
/** * Diese Methode erstellt eine Standard Checkbox. * * @param text * Checkbox Text * @return {@link CheckBox} */ protected CheckBox createCheckbox(final String text) { CheckBoxStyle style = createCheckboxStyle(); CheckBox box = new CheckBox(text, style); return box; }