private ImageButton createFormationButton(FormationPatternType pattern, Skin skin){ ImageButtonStyle style = new ImageButtonStyle(skin.get("default", ButtonStyle.class)); Sprite sprite = new Sprite(Assets.ui.formationIcons.get(pattern.ordinal())); sprite.setSize(26, 26); sprite.setColor(Color.BLUE); SpriteDrawable drawable = new SpriteDrawable(sprite); style.imageUp = drawable; // style.imageDown = drawable.tint(Color.CYAN); style.imageChecked = drawable.tint(Color.RED); ImageButton button = new ImageButton(style); button.setUserObject(pattern); return button; }
private void addToolBarButton(Skin skin, ImageButton button, String icon, String text, String tooltip) { ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class)); TextureRegion image = Ctx.assetManager.getIcon(icon); style.imageUp = new TextureRegionDrawable(image); try { TextureRegion imageDisabled = Ctx.assetManager.getIcon(icon + "_disabled"); if(imageDisabled != null) style.imageDisabled = new TextureRegionDrawable(imageDisabled); } catch (Exception e) { } button.setStyle(style); // button.row(); // button.add(new Label(text, skin)); add(button); button.setDisabled(true); TextTooltip t = new TextTooltip(tooltip, skin); button.addListener(t); }
public void addToolBarButton(ImageButton button, String icon, String text, String tooltip) { TextureRegion image = Ctx.assetManager.getIcon(icon); TextureRegion imageDisabled = Ctx.assetManager.getIcon(icon + "_disabled"); ImageButtonStyle style = new ImageButtonStyle(skin.get("plain", ButtonStyle.class)); style.imageUp = new TextureRegionDrawable(image); if(imageDisabled != null) style.imageDisabled = new TextureRegionDrawable(imageDisabled); button.setStyle(style); button.pad(6,3,6,3); addActor(button); button.setDisabled(true); TextTooltip t = new TextTooltip(tooltip, skin); button.addListener(t); }
private ImageButtonStyle generateTabStyle(String iconId, boolean active) { ImageButtonStyle origin = Styles.BTN_TAB; if (active) { origin = Styles.BTN_TAB_ACTIVE; } ImageButtonStyle style = new ImageButtonStyle(origin); Sprite sprite = new Sprite(SharedAssetManager.get(iconId, Texture.class)); sprite.setAlpha(0.8f); OffsetDrawable drawable = new OffsetDrawable(new SpriteDrawable(sprite)); drawable.setOffsetX(-Sizes.panelRadius() - 1f); style.imageUp = drawable; style.imageOver = drawable; style.imageUp.setMinHeight(70); style.imageUp.setMinWidth(70); style.imageOver.setMinHeight(70); style.imageOver.setMinWidth(70); return style; }
public SiggdImageButton(String down, String disabled, String metaData) { Texture texture2 = new Texture(Gdx.files.internal(down)); Texture texture3 = new Texture(Gdx.files.internal(disabled)); TextureRegion imageDown = new TextureRegion(texture2); TextureRegion imageDisabled = new TextureRegion(texture3); TextureRegionDrawable drawableDown = new TextureRegionDrawable(imageDown); TextureRegionDrawable drawableDisabled = new TextureRegionDrawable(imageDisabled); ImageButtonStyle imageButtonStyle = new ImageButtonStyle(drawableDown, drawableDown, drawableDown, drawableDown, drawableDown, drawableDown); imageButtonStyle.imageDisabled = drawableDisabled; mImageButton = new ImageButton(imageButtonStyle); mImageButton.setName(metaData); if (GLOW == null) GLOW = new Texture("data/gfx/glow.png"); mGlow = new Image(GLOW); }
/** * Ajoute un bouton pause à l'interface. */ private void addPause() { ImageButtonStyle pauseStyle = new ImageButtonStyle(); pauseStyle.up = skin.getDrawable("button"); pauseStyle.imageUp = skin.getDrawable("pause"); pauseStyle.down = skin.getDrawable("button_pressed"); skin.add("pause", pauseStyle); pause = new ImageButton(skin, "pause"); pauseContainer.setActor(pause); pauseContainer.size(64, 64); }
@Override public void process(final LmlParser parser, final LmlTag tag, final ImageButton actor, final String rawAttributeData) { final ImageButtonStyle style = new ImageButtonStyle(actor.getStyle()); style.imageUp = parser.getData().getDefaultSkin().getDrawable(parser.parseString(rawAttributeData, actor)); actor.setStyle(style); }
public Tab(String id, Actor content, ImageButtonStyle style, ImageButtonStyle activeStyle) { super(style); this.id = id; this.content = content; otherStyle = activeStyle; this.active = false; }
public void setActive(boolean active) { if (active != this.active) { ImageButtonStyle style = otherStyle; otherStyle = getStyle(); setStyle(style); this.active = active; } }
/** * */ public void initializeButtons() { group = new ButtonGroup(); Tooltips.TooltipStyle styleTooltip = new Tooltips.TooltipStyle(game.skin.getFont("default-font"), game.skin.getDrawable("default-round"), game.skin.getColor("white")); String[] widgets = SkinEditorGame.widgets; for (String widget : widgets) { ImageButtonStyle style = new ImageButtonStyle(); style.checked = game.skin.getDrawable("default-round-down"); style.down = game.skin.getDrawable("default-round-down"); style.up = game.skin.getDrawable("default-round"); style.imageUp = game.skin.getDrawable("widgets/" + widget); ImageButton button = new ImageButton(style); button.setUserObject(widget); Tooltips tooltip = new Tooltips(styleTooltip, getStage()); tooltip.registerTooltip(button, (String) button.getUserObject()); button.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.screenMain.panePreview.refresh(); game.screenMain.paneOptions.refresh(); } }); group.add(button); add(button).pad(5); } }
public static ImageButton circleButton(String icon) { ButtonStyle circleStyle = skin.get(SkinConstants.STYLE_CIRCLE, ButtonStyle.class); ImageButtonStyle imageButtonStyle = new ImageButtonStyle(circleStyle); imageButtonStyle.imageUp = skin.getDrawable(icon); ImageButton imageButton = new ImageButton(imageButtonStyle); imageButton.setName(icon); return imageButton; }
private void init() { ImageButtonStyle style = new ImageButtonStyle(skin.get( SkinConstants.STYLE_MARKER, ImageButtonStyle.class)); style.imageUp = skin.getDrawable(SkinConstants.IC_ONE); initialSceneMarker = new ImageButton(style); initialSceneMarker.pad(WidgetBuilder.dpToPixels(8)); }
public SearchWidget(Skin skin) { super(true); SearchWidgetStyle style = skin.get(SearchWidgetStyle.class); background(style.background); label = new Label("", new LabelStyle(style.font, style.fontColor)); ImageButtonStyle buttonStyle = new ImageButtonStyle( skin.get(ButtonStyle.class)); buttonStyle.imageUp = style.searchIcon; searchButton = new ImageButton(buttonStyle); add(label).expand(true, true); add(searchButton); }
public final void clicked(InputEvent paramInputEvent, float paramFloat1, float paramFloat2) { o.a().a(bs.aO); this.c.a.c(); if (this.c.a.b()); for (String str = "audio-pause"; ; str = "audio-play") { this.a.setStyle((Button.ButtonStyle)this.b.get(str, ImageButton.ImageButtonStyle.class)); return; } }
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 BrowseFieldStyle(ImageButtonStyle imageButtonStyle, TextButtonStyle textButtonStyle, LabelStyle labelStyle) { this.mainButtonStyle = textButtonStyle; this.rightButtonStyle = imageButtonStyle; this.labelStyle = labelStyle; }
private ImageButtonStyle buildImageButton(TextButtonStyle source, String region) { ImageButtonStyle style = new ImageButtonStyle(source); style.imageUp = new TextureRegionDrawable(getRegion(region)); return style; }
/** * Konstruktor der Worldmap. Initialisiert Objekte und startet direkt die * Eingangsanimation. * * @throws LevelNotFoundException * Wenn Level zu dem navigiert werden soll nicht existiert. */ public WorldMap() throws LevelNotFoundException { super(); stage = new Stage(getViewport()); camera = getCam(); uiViewport = new FitViewport(width, height); uiStage = new Stage(uiViewport); InputManager.addInputProcessor(uiStage); InputManager.addInputProcessor(stage); player = new PlayerImpl(); getJasonCities(); prefs = Gdx.app.getPreferences("WorldMapPrefs"); if (!prefs.contains("lastCity")) { prefs.putString("lastCity", cities[0]); // setze die erste Stadt als } // Standartort falls nicht // gesetzt prefs.flush(); selectedCityIndex = Arrays.asList(cities).indexOf( prefs.getString("lastCity")); if (selectedCityIndex == -1) { selectedCityIndex = 0; prefs.putString("lastCity", cities[0]); prefs.flush(); } Gdx.app.log( "INFO", "Zuletzt gewählte Stadt hat Index " + String.valueOf(selectedCityIndex)); cityChanged = true; germanyImg = new Image(AssetManager.getTextureRegion("worldmap", "germanymap_scaled")); germanyImg.toBack(); worldImg = new Image(AssetManager.getTextureRegion("worldmap", "erde-und-sterne")); worldImg.toBack(); pointImg = new Image(AssetManager.getTextureRegion("worldmap", "shadedLight28")); state = State.INIT; textFont = AssetManager.getTextFont(FontSize.SIXTY); flagStyle = new ImageButtonStyle(); createButtons(); createCityPoints(); initAnimation(); AssetManager.loadMusic("mainMenu"); AssetManager.loadSounds("worldmap"); music = audioManager.getMusic("mainMenu", "belotti.mp3"); if (!music.isPlaying()) { music.setLooping(true); music.play(); } }
public GameScreen(AssetManager manager) { super("Splash", manager); // Create buttons mainStage = new Stage(new StretchViewport(GlobalVars.width, GlobalVars.height)); buttonAtlas = manager.get("gfx/ui/buttons.pack", TextureAtlas.class); buttonSkin = new Skin(buttonAtlas); Gdx.input.setInputProcessor(mainStage); ImageButtonStyle imgBtnStyle = new ImageButtonStyle(); imgBtnStyle.imageUp = buttonSkin.getDrawable("ExitButton"); ImageButton exitButton = new ImageButton(imgBtnStyle); exitButton.setPosition(GlobalVars.width - (exitButton.getWidth() + 5f), GlobalVars.height - (exitButton.getHeight() + 5f)); mainStage.addActor(exitButton); exitButton.addListener(new ChangeListener() { public void changed(ChangeEvent e, Actor a) { setNextScreen("MainMenu"); setDone(true); } }); // Setup draw stuff camera = new OrthographicCamera(GlobalVars.width, GlobalVars.height); camera.position.set(GlobalVars.width / 2, GlobalVars.height / 2, 0f); camera.update(); batch = new SpriteBatch(); spaceshipAtlas = manager.get("gfx/sprites/spaceships.pack", TextureAtlas.class); bulletAtlas = manager.get("gfx/sprites/bullets.pack", TextureAtlas.class); pickupAtlas = manager.get("gfx/sprites/pickups.pack", TextureAtlas.class); font = new BitmapFont(); font.scale(0.01f); // Create ship if(GlobalVars.ship == 0) { player = new Player(spaceshipAtlas.findRegion("bluedestroyer"), 160, 50, 1, 1000, 250, 0.5f); } else if(GlobalVars.ship == 1) { player = new Player(spaceshipAtlas.findRegion("bluecarrier"), 160, 50, 0, 2000, 250, 0.5f); } else { player = new Player(spaceshipAtlas.findRegion("bluecruiser"), 160, 50, 0, 1000, 500, 0.5f); } // Setup enemies enemies = new Enemy[NUM_ENEMIES]; for(int i = 0; i < NUM_ENEMIES; i++) { enemies[i] = null; } currentMaxEnemies = 1; currentEnemies = 0; // Setup bullets bullets = new Bullet[NUM_BULLETS]; for(int i = 0; i < NUM_BULLETS; i++) { bullets[i] = null; } // Setup pickups pickup = null; pickupTimer = 0; rapidTimer = 0; speed = false; speedTimer = 0; invTimer = 0; // Setup Particle Effects ParticleEffect explosionEffect = new ParticleEffect(); explosionEffect.load(Gdx.files.internal("gfx/particles/Explosion.p"), Gdx.files.internal("gfx/particles/")); explosionEffectPool = new ParticleEffectPool(explosionEffect, 1, 2); // Setup stars stars = new Star[NUM_STARS]; for(int i = 0; i < NUM_STARS; i++) { RandomXS128 rand = new RandomXS128(); stars[i] = new Star(rand.nextFloat() * GlobalVars.width, rand.nextFloat() * GlobalVars.height); } shapeRenderer = new ShapeRenderer(); // Setup sound laserShot = Gdx.audio.newSound(Gdx.files.internal("sfx/laser5.mp3")); explode = Gdx.audio.newSound(Gdx.files.internal("sfx/explosion.mp3")); }
@Override public void setUI(final PinnableWindow window, Object... params) { window.row().pad(0).colspan(50).padRight(-10).fillX(); final List<Job> jobs = new List<Job>(Vloxlands.skin); jobs.setItems(new IdleJob(this)); jobs.addAction(new Action() { @Override public boolean act(float delta) { if (jobQueue.size == 0 && jobs.getItems().get(0) instanceof IdleJob) return false; if (!jobQueue.equals(jobs.getItems())) { if (jobQueue.size > 0) jobs.setItems(jobQueue); else jobs.setItems(new IdleJob(Human.this)); jobs.getSelection().setDisabled(true); jobs.setSelectedIndex(-1); window.pack(); } return false; } }); jobs.getSelection().setDisabled(true); jobs.setSelectedIndex(-1); jobs.getStyle().selection.setLeftWidth(10); jobs.getStyle().selection.setTopHeight(3); final ScrollPane jobsWrap = new ScrollPane(jobs, Vloxlands.skin); jobsWrap.setVisible(false); jobsWrap.setScrollbarsOnTop(false); jobsWrap.setFadeScrollBars(false); final Cell<?> cell = window.add(jobsWrap).height(0); window.row(); ItemSlot tool = new ItemSlot(window.getStage(), this.tool); window.left().add(tool).spaceRight(2); ItemSlot slot = new ItemSlot(window.getStage(), carryingItemStack); window.add(slot).spaceRight(2); ItemSlot armor = new ItemSlot(window.getStage(), new ItemStack()); window.add(armor).spaceRight(2); ImageButtonStyle style = new ImageButtonStyle(Vloxlands.skin.get("image_toggle", ButtonStyle.class)); style.imageUp = Vloxlands.skin.getDrawable("queue"); style.imageUp.setMinWidth(ItemSlot.size); style.imageUp.setMinHeight(ItemSlot.size); style.imageDown = Vloxlands.skin.getDrawable("queue"); style.imageDown.setMinWidth(ItemSlot.size); style.imageDown.setMinHeight(ItemSlot.size); final TooltipImageButton job = new TooltipImageButton(style); window.getStage().addActor(job.getTooltip()); job.setName("job"); ClickListener cl = new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { cell.height(cell.getMinHeight() == 100 ? 0 : 100); jobsWrap.setVisible(!jobsWrap.isVisible()); window.invalidateHierarchy(); window.pack(); } }; job.addListener(cl); job.getTooltip().set("Job Queue", "Toggle Job Queue display"); window.add(job).padRight(-10); if (params[0] == Boolean.TRUE) { job.setChecked(true); cl.clicked(null, 0, 0); } }
public static ImageButton imageButton(String icon, String buttonStyle) { ButtonStyle style = skin.get(buttonStyle, ButtonStyle.class); ImageButtonStyle imageButtonStyle = new ImageButtonStyle(style); imageButtonStyle.imageUp = skin.getDrawable(icon); return new ImageButton(imageButtonStyle); }
public final void clicked(InputEvent paramInputEvent, float paramFloat1, float paramFloat2) { o.a().a(bs.aO); this.c.a.d(); this.a.setStyle((Button.ButtonStyle)this.b.get("audio-pause", ImageButton.ImageButtonStyle.class)); }
/** * Gets the style of the image button. * * @return the image button's style */ public ImageButtonStyle getImageButtonStyle() { return skin.get(ImageButtonStyle.class); }
/** * Returns the style for an image button with the given icon as image. * * @param icon * the identifier of the icon in the texture atlas * @return */ public ImageButtonStyle getImageButtonStyle(String icon) { ImageButtonStyle style = new ImageButtonStyle(getImageButtonStyle()); style.imageUp = skin.getDrawable(icon); return style; }