public Drawable findDrawable(ObjectData option, String name) { if (option.isScale9Enable()) {// 九宫格支持 TextureRegion textureRegion = findTextureRegion(option, name); NinePatch np = new NinePatch(textureRegion, option.getScale9OriginX(), textureRegion.getRegionWidth() - option.getScale9Width() - option.getScale9OriginX(), option.getScale9OriginY(), textureRegion.getRegionHeight() - option.getScale9Height() - option.getScale9OriginY()); np.setColor(getColor(option.getCColor(), option.getAlpha())); return new NinePatchDrawable(np); } TextureRegion tr = findTextureRegion(option, name); if (tr == null) { return null; } return new TextureRegionDrawable(tr); }
@Test @NeedGL public void shouldParseSingleButtonWithImages() throws Exception { FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf"); CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("single-button/MainScene.json"), null, null, defaultFont, null); Group group = editor.createGroup(); Actor actor = group.findActor("Button_1"); assertThat(actor, not(nullValue())); assertThat(actor, instanceOf(ImageButton.class)); ImageButton imageButton = (ImageButton) actor; assertThat(imageButton.getScaleX(), is(1.7958f)); assertThat(imageButton.getScaleY(), is(1.8041f)); ImageButton.ImageButtonStyle style = imageButton.getStyle(); assertThat(style.imageDisabled, instanceOf(NinePatchDrawable.class)); assertThat(style.up, instanceOf(NinePatchDrawable.class)); assertThat(style.down, instanceOf(NinePatchDrawable.class)); }
private void addWindowStyles() { final Color backgroundColor = new Color(0, 0.3f, 0.6f, 1f); final Color borderColor = new Color(backgroundColor).lerp(Color.WHITE, 0.2f); final int borderBorder = 4; final int borderWidth = 4; final int pixmapSize = 2 * (borderBorder + borderWidth) + 1; Pixmap windowBackground = new Pixmap(pixmapSize, pixmapSize, Pixmap.Format.RGBA8888); windowBackground.setColor(backgroundColor); windowBackground.fill(); windowBackground.setColor(borderColor); windowBackground.fillRectangle(borderBorder, borderBorder, pixmapSize - 2 * borderBorder, pixmapSize - 2 * borderBorder); windowBackground.setColor(backgroundColor); windowBackground.fillRectangle(borderBorder + borderWidth, borderBorder + borderWidth, pixmapSize - 2 * (borderBorder + borderWidth), pixmapSize - 2 * (borderBorder + borderWidth)); Texture backgroundWindow = new Texture(windowBackground); NinePatch backgroundPatch = new NinePatch(backgroundWindow, borderBorder + borderWidth, borderBorder + borderWidth, borderBorder + borderWidth, borderBorder + borderWidth); Drawable background = new NinePatchDrawable(backgroundPatch); BitmapFont font = get("normal", BitmapFont.class); WindowStyle window = new WindowStyle(font, Color.WHITE, background); add("default", window); }
public static void init() { BUTTON_DEFAULT_ACTIVE.font = SharedAssetManager.getInstance().get(Assets.FONT_BYOM_32, BitmapFont.class); BUTTON_DEFAULT_ACTIVE.fontColor = Colors.COLOR_UI_ACTIVE.cpy(); BUTTON_DEFAULT_ACTIVE.overFontColor = Colors.COLOR_UI_ACTIVE.add(-0.2f, -0.2f, -0.2f, 0f); Texture buttonTexture = SharedAssetManager.getInstance().get(Assets.BUTTON_DEFAULT, Texture.class); BUTTON_DEFAULT_ACTIVE.up = new NinePatchDrawable( GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_ACTIVE.fontColor)); BUTTON_DEFAULT_ACTIVE.over = new NinePatchDrawable( GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_ACTIVE.overFontColor)); BUTTON_DEFAULT_INACTIVE.font = SharedAssetManager.getInstance().get(Assets.FONT_BYOM_32, BitmapFont.class); BUTTON_DEFAULT_INACTIVE.fontColor = Colors.COLOR_UI_INACTIVE.cpy(); BUTTON_DEFAULT_INACTIVE.overFontColor = Colors.COLOR_UI_INACTIVE.add(-0.2f, -0.2f, -0.2f, 0f); BUTTON_DEFAULT_INACTIVE.up = new NinePatchDrawable( GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_INACTIVE.fontColor)); BUTTON_DEFAULT_INACTIVE.over = new NinePatchDrawable( GraphicsFactory.createNinePatch(buttonTexture, 10, BUTTON_DEFAULT_INACTIVE.overFontColor)); }
private void addExit() { NinePatchDrawable draw = new NinePatchDrawable(Assets.hotkey.button); TextButtonStyle style = new ImageTextButtonStyle(); style.up = draw; style.down = draw.tint(Color.DARK_GRAY); style.checked = draw; style.font = Assets.fonts.font; TextButton btn = new TextButton("Exit", style); btn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); Gdx.app.exit(); } }); table.add(btn); table.row(); }
public void add(String title, final AbstractScreen screen) { NinePatchDrawable draw = new NinePatchDrawable(Assets.hotkey.button); TextButtonStyle style = new ImageTextButtonStyle(); style.up = draw; style.down = draw.tint(Color.DARK_GRAY); style.checked = draw; style.font = Assets.fonts.font; TextButton btn = new TextButton(title, style); btn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); GameManager.setScreen(screen); } }); table.add(btn); table.row(); }
public AudioControl(TextureAtlas hudAtlas) { super(new NinePatchDrawable(new NinePatch(hudAtlas.findRegion("audio-on"), WHITE)), new NinePatchDrawable(new NinePatch( hudAtlas.findRegion("audio-on"), ICS_BLUE)), new NinePatchDrawable(new NinePatch(hudAtlas.findRegion("audio-off"), WHITE))); layout(); GameSoundController.runAfterInit(new Runnable() { @Override public void run() { setChecked(!DroidTowersGame.getSoundController().isAudioState()); addListener(new VibrateClickListener() { public void onClick(InputEvent event, float x, float y) { DroidTowersGame.getSoundController().toggleAudio(); } }); } }); }
private boolean initialize() { if (SharedAssetManager.isLoaded(Assets.TEX_PANEL_TRANSPARENT_9patch) && SharedAssetManager.isLoaded(Assets.FNT_MONO) && Styles.TXT_COMMANDLINE != null && Styles.TXT_COMMANDLINE.font != null) { setBackground(new NinePatchDrawable(GraphicsFactory.createNinePatch(Assets.TEX_PANEL_TRANSPARENT_9patch, Sizes.panelTransparentRadius()))); textField = new TextField("", Styles.TXT_COMMANDLINE); textField.setWidth(getWidth()); LabelStyle consoleStyle = new LabelStyle(); consoleStyle.font = SharedAssetManager.get(Assets.FNT_MONO, BitmapFont.class); consoleStyle.fontColor = Color.GRAY; add(new Label("$ ", consoleStyle)); add(textField).width(getWidth()); setY(Sizes.worldHeight() - textField.getHeight()); setHeight(textField.getHeight()); return true; } else { return false; } }
/** * Adds a tile to represent a ShipCoordinate. */ public void addTile( ShipCoordinate coord ) { if ( coord.v != 0 ) return; TextureAtlas floorAtlas = assetManager.get( OVDConstants.FLOORPLAN_ATLAS, TextureAtlas.class ); TextureRegion tileRegion = floorAtlas.findRegion( "floor-line" ); NinePatchDrawable tileDrawable = new NinePatchDrawable( new NinePatch( tileRegion, 1, 1, 1, 1 ) ); Image tileImage = new Image( tileDrawable ); tileImage.setPosition( calcTileX( coord ), calcTileY( coord ) ); tileImage.setSize( tileSize, tileSize ); tiles.add( tileImage ); // These are different floats which can cause gaps when mixed. // (x * size + size) != ((x+1) * size) }
/** * Adds a tile to represent a ShipCoordinate. */ public void addTile( ShipCoordinate coord ) { if ( coord.v != 0 ) return; TextureAtlas floorAtlas = assetManager.get( OVDConstants.FLOORPLAN_ATLAS, TextureAtlas.class ); TextureRegion tileRegion = floorAtlas.findRegion( "floor-tile" ); NinePatchDrawable tileDrawable = new NinePatchDrawable( new NinePatch( tileRegion, 1, 1, 1, 1 ) ); Image tileImage = new Image( tileDrawable ); tileImage.setPosition( calcTileX( coord ), calcTileY( coord ) ); tileImage.setSize( tileSize, tileSize ); this.addActor( tileImage ); // These are different floats which can cause gaps when mixed. // (x * size + size) != ((x+1) * size) }
private void textWindowDemo() { BitmapFont plotFont = context.getAssetManager().get( PLOT_FONT, BitmapFont.class ); String loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "; loremIpsum += "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; loremIpsum += "\n\nThis window is draggable."; rootAtlas = context.getAssetManager().get( ROOT_ATLAS, TextureAtlas.class ); TextureRegion plotDlgRegion = rootAtlas.findRegion( "box-text1" ); NinePatchDrawable plotDlgBgDrawable = new NinePatchDrawable( new NinePatch( plotDlgRegion, 20, 20, 35, 20 ) ); Window plotDlg = new Window( "", new Window.WindowStyle( plotFont, new Color( 1f, 1f, 1f, 1f ), plotDlgBgDrawable ) ); plotDlg.setKeepWithinStage( true ); plotDlg.setMovable( true ); plotDlg.setSize( 200, 250 ); plotDlg.setPosition( 765, 60 ); plotDlg.row().top().expand().fill(); Label plotLbl = new Label( loremIpsum, new Label.LabelStyle( plotFont, new Color( 1f, 1f, 1f, 1f ) ) ); plotLbl.setAlignment( Align.top|Align.left, Align.center|Align.left ); plotLbl.setWrap( true ); plotDlg.add( plotLbl ); // setKeepWithinStage() only applies if added to the stage root. :/ popupStage.addActor( plotDlg ); }
public Drawable newDrawable(String paramString, Color paramColor) { Drawable localDrawable = getDrawable(paramString); if ((localDrawable instanceof TextureRegionDrawable)) { Sprite localSprite1 = new Sprite(((TextureRegionDrawable)localDrawable).getRegion()); localSprite1.setColor(paramColor); return new SpriteDrawable(localSprite1); } if ((localDrawable instanceof NinePatchDrawable)) { NinePatchDrawable localNinePatchDrawable = new NinePatchDrawable((NinePatchDrawable)localDrawable); localNinePatchDrawable.setPatch(new NinePatch(localNinePatchDrawable.getPatch(), paramColor)); return localNinePatchDrawable; } if ((localDrawable instanceof SpriteDrawable)) { SpriteDrawable localSpriteDrawable = new SpriteDrawable((SpriteDrawable)localDrawable); Sprite localSprite2 = new Sprite(localSpriteDrawable.getSprite()); localSprite2.setColor(paramColor); localSpriteDrawable.setSprite(localSprite2); return localSpriteDrawable; } throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + localDrawable.getClass()); }
public final void layout() { Object localObject = null; if (needsLayout()) { float f1 = l.a(12.0F) / 2.0F; this.f.clear(); a(null, null); Iterator localIterator = this.d.iterator(); while (localIterator.hasNext()) { Integer localInteger = (Integer)localIterator.next(); Button localButton = new Button(com.nianticproject.ingress.common.b.c.a(this.b, localInteger.intValue())); com.nianticproject.ingress.common.ui.widget.d locald = new com.nianticproject.ingress.common.ui.widget.d(new NinePatchDrawable(this.b.getPatch("avatar-color-picker-button-up")), new NinePatchDrawable(this.b.getPatch("avatar-color-picker-button-down")), new NinePatchDrawable(this.b.getPatch("avatar-color-picker-button-checked"))); locald.addListener(new b(this, locald, localInteger)); if (localObject == null) localObject = locald; this.f.stack(new Actor[] { localButton, locald }).b(this.h).c(this.h).i(f1).k(f1); if ((this.e.a != null) && (ag.a(this.e.a, localInteger))) a(locald, Integer.valueOf(localInteger.intValue())); } if ((this.e.b == null) && (localObject != null)) a(localObject, (Integer)this.d.get(0)); super.layout(); } }
private static Actor a(com.nianticproject.ingress.shared.playerprofile.a parama, Skin paramSkin, WidgetCarousel paramWidgetCarousel, e parame, a parama1) { Table localTable1 = new Table(); localTable1.setBackground(new NinePatchDrawable(paramSkin.getPatch("avatar-color-picker-button-up"))); Label.LabelStyle localLabelStyle = (Label.LabelStyle)paramSkin.get("profiles-avatar-selection-layer-name", Label.LabelStyle.class); localTable1.add(new Label(parama.name() + ":", localLabelStyle)).o(); paramWidgetCarousel.a(parame); localTable1.row(); localTable1.add(paramWidgetCarousel).h(l.a(8.0F)).j(l.a(8.0F)).o().g(); localTable1.row(); localTable1.add(new Image(com.nianticproject.ingress.common.b.c.a(paramSkin, 46783))).o().g().c(l.a(1.0F)); localTable1.row(); localTable1.add(parama1).g(parama1.a()).o().g(); Table localTable2 = new Table(); Table localTable3 = new Table(); localTable3.setBackground(paramSkin.getTiledDrawable("tile-diag")); localTable2.stack(new Actor[] { localTable3, localTable1 }).o().g(); return localTable2; }
public final void a(Skin paramSkin, Stage paramStage) { Label.LabelStyle localLabelStyle = (Label.LabelStyle)paramSkin.get("default", Label.LabelStyle.class); ProgressIndicator localProgressIndicator = new ProgressIndicator(paramSkin); ScrollLabel localScrollLabel = new ScrollLabel("Obtaining Fix on Portal...", localLabelStyle, (byte)0); localScrollLabel.addAction(a.a(localScrollLabel, 2.0F)); localProgressIndicator.a(true); this.a = new Table(); this.a.setBackground(new NinePatchDrawable(new NinePatch(paramSkin.getPatch("item-button-outline"), new Color(1.0F, 1.0F, 1.0F, 0.5F)))); this.a.add(localProgressIndicator).n().a(Integer.valueOf(17)).g(10.0F); this.a.add(localScrollLabel).n().a(Integer.valueOf(9)); this.a.setWidth(1.05F * this.a.getPrefWidth()); this.a.setHeight(this.a.getPrefHeight()); this.a.setX((paramStage.getWidth() - this.a.getWidth()) / 2.0F); this.a.setY((paramStage.getHeight() - this.a.getHeight()) / 2.0F); this.a.getColor().a = 0.0F; this.a.addAction(Actions.fadeIn(0.5F)); paramStage.addActor(this.a); }
protected final Actor b(Skin paramSkin, Stage paramStage) { this.h = new Table(); float f1 = paramStage.getWidth(); float f2 = paramStage.getHeight(); float f3 = f1 - this.b - this.d; float f4 = f2 - this.c - this.e; float f5 = this.b; float f6 = this.e; this.h.setX(f5); this.h.setY(f6); this.h.setWidth(f3); this.h.setHeight(f4); Table localTable1 = new Table(); localTable1.setBackground(new az(new NinePatchDrawable(paramSkin.getPatch("remote-portal-bracket")), 16744494)); Table localTable2 = new Table(); this.i = new TextButton("REMOTE PORTAL VIEW", (TextButton.TextButtonStyle)paramSkin.get("remote-portal", TextButton.TextButtonStyle.class)); this.i.setTouchable(Touchable.disabled); localTable2.add(this.i).n().j().k(); this.h.stack(new Actor[] { localTable1, localTable2 }).n().f(); return this.h; }
@Override public void setNineDrawable(NineDrawableEvent event) { Actor curActor = selectedGroup.getLastSelectActor(); if (curActor instanceof Image) { Image image = (Image) curActor; if (image.getDrawable() instanceof NinePatchDrawable) { Gdx.app.log("app", "set nine-----------------111"); NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) image.getDrawable(); ninePatchDrawable.setPatch(new NinePatch(ninePatchDrawable.getPatch().getTexture() , event.nines[0], event.nines[1], event.nines[2], event.nines[3])); } } }
private void initGuiInGame() { mGuiStage = new Stage(new ScreenViewport()); Table gameScore = new Table(); if (DEBUG_RENDERER) { gameScore.debug(); } float scorePanelWidth = Gdx.graphics.getWidth() * 0.8f; // 80 % of screen float scorePanelHeight = Gdx.graphics.getHeight() * 0.2f; // 20 % of screen gameScore.setWidth(scorePanelWidth); gameScore.setHeight(scorePanelHeight); gameScore.setY(Gdx.graphics.getHeight() - (scorePanelHeight + 30.f)); gameScore.setX((Gdx.graphics.getWidth() - scorePanelWidth) * 0.5f); gameScore.setBackground(new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("red_button13.png")), 24, 24, 24, 24))); gameScore.pad(32.f); Label scoreLabel = new Label("Score", new Label.LabelStyle( mDefaultFont, COLOR_FONT)); scoreLabel.setFontScale(1.2f); gameScore.add(scoreLabel).expand(); gameScore.row(); mScoreLabel = new Label("" + mPointTotal, new Label.LabelStyle( mDefaultFont, COLOR_FONT)); mScoreLabel.setFontScale(2.0f); gameScore.add(mScoreLabel).expand(); mGuiStage.addActor(gameScore); }
public void create() { Stage stage = new Stage(new ScreenViewport()); getComponentByType(GuiComponent.class).stage = stage; Table gameScore = new Table(); float scorePanelWidth = Gdx.graphics.getWidth() * 0.8f; // 80 % of screen float scorePanelHeight = Gdx.graphics.getHeight() * 0.2f; // 20 % of screen gameScore.setWidth(scorePanelWidth); gameScore.setHeight(scorePanelHeight); gameScore.setY(Gdx.graphics.getHeight() - (scorePanelHeight + 30.f)); gameScore.setX((Gdx.graphics.getWidth() - scorePanelWidth) * 0.5f); gameScore.setBackground(new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("red_button13.png")), 24, 24, 24, 24))); gameScore.pad(32.f); Label scoreLabel = new Label("Score", new Label.LabelStyle( mFont, COLOR_FONT)); scoreLabel.setFontScale(1.2f); gameScore.add(scoreLabel).expand(); gameScore.row(); mScoreLabel = new Label("" + 0, new Label.LabelStyle(mFont, COLOR_FONT)); mScoreLabel.setFontScale(2.0f); gameScore.add(mScoreLabel).expand(); stage.addActor(gameScore); }
public PageGroup(Skin skin, AtlasModel.Page page) { this.page = page; setTransform(false); borderFrame = new NinePatchDrawable(skin.getPatch("custom/white_frame")).tint(Color.BLACK); setSize(page.getTexture().getWidth(), page.getTexture().getHeight()); setTouchable(Touchable.disabled); addActor(new RegionSpotlight(skin)); }
private NinePatchDrawable generateButton(Color color, Color down) { Pixmap pixmap = new Pixmap(9, 9, Pixmap.Format.RGBA8888); pixmap.setColor(down); pixmap.fill(); pixmap.setColor(color); pixmap.fillRectangle(0, 0, 9, 5); Texture texture = new Texture(pixmap); NinePatch ninePatch = new NinePatch(texture, 4, 4, 4, 4); return new NinePatchDrawable(ninePatch); }
public void styleSkin(Skin skin, TextureAtlas atlas) { BitmapFont font = new BitmapFont(Gdx.files.internal("data/lucida-console-21.fnt"), false); skin.add("default", font); skin.add("lt-blue", new Color(.6f, .8f, 1f, 1f)); skin.add("lt-green", new Color(.6f, .9f, .6f, 1f)); skin.add("dark-blue", new Color(.1f, .3f, 1f, 1f)); skin.add("button-text", Color.valueOf("DDFF35FF")); NinePatchDrawable btn1up = new NinePatchDrawable(atlas.createPatch("patchThick")); NinePatchDrawable btn1down = new NinePatchDrawable(atlas.createPatch("patchThickDown")); NinePatch window1patch = atlas.createPatch("window1"); skin.add("btn1up", btn1up); skin.add("btn1down", btn1down); skin.add("window1", window1patch); skin.add("white-pixel", atlas.findRegion("white-pixel"), TextureRegion.class); LabelStyle lbs = new LabelStyle(); lbs.font = font; lbs.fontColor = Color.WHITE; skin.add("default", lbs); TextButtonStyle tbs = new TextButtonStyle(btn1up, btn1down, btn1down, font); tbs.fontColor = skin.getColor("button-text"); tbs.pressedOffsetX = Math.round(1f * Gdx.graphics.getDensity()); tbs.pressedOffsetY = tbs.pressedOffsetX * -1f; skin.add("default", tbs); }
public void init(){ Drawable imageButton = new NinePatchDrawable(new NinePatch(Assets.getManager().get(Assets.VANNEBUTTON, Texture.class))); Button.ButtonStyle bts = new Button.ButtonStyle(imageButton,imageButton,imageButton); augmenter.setStyle(bts); augmenter.setSize(32, 64); augmenter.addListener(new VanneButton()); diminuer.setStyle(bts); diminuer.setSize(32, 64); diminuer.addListener(new VanneButton()); table.add(diminuer); table.add(augmenter); table.setPosition(x*64+32,y*64+32); //les 2 (+32) sont la pour être bien aligné avec le centre de la vanne }
public static NinePatchDrawable ninePatch(String region) { final NinePatch patch = skin.createPatch(region); if (patch == null) { throw new NullPointerException("9patch not found: " + region + ". Regions Available: " + skin.getRegions()); } return new NinePatchDrawable(patch); }
public ListActor(Array<Interpolator> interpolators, Assets assets) { this.table = new Table(); BitmapFont font = assets.am.get(Assets.FILE_FONT_VERDANA39, BitmapFont.class); font.getData().setScale(0.5f); font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); TextureAtlas textureAtlas = assets.am.get(Assets.FILE_ATLAS_BTN, TextureAtlas.class); NinePatch normal = textureAtlas.createPatch("btn_default_normal_holo_light"); NinePatch pressed = textureAtlas.createPatch("btn_default_pressed_holo_light"); TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle(); buttonStyle.font = font; buttonStyle.fontColor = Color.BLACK; buttonStyle.up = new NinePatchDrawable(normal); buttonStyle.down = new NinePatchDrawable(pressed); float contentWidth = 0; for (final Interpolator interpolator : interpolators) { String simpleName = interpolator.getClass().getSimpleName(); TextButton button = new TextButton(simpleName, buttonStyle); ClickListener listener = new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { onSelectedInterpolator(interpolator); } }; button.addListener(listener); table.add(button).align(Align.left); table.row(); contentWidth = Math.max(contentWidth, button.getWidth()); } scrollPane = new ScrollPane(table); scrollPane.setWidth(contentWidth); this.addActor(scrollPane); setWidth(contentWidth); }
/** Returns a copy of the specified drawable. */ public Drawable newDrawable (Drawable drawable) { if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable); if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable); if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable); throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); }
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); }
/** Returns a copy of the specified drawable. */ public Drawable newDrawable(Drawable drawable) { if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable) drawable); if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable) drawable); if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable) drawable); throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); }
public Drawable newDrawable(String paramString) { Drawable localDrawable = getDrawable(paramString); if ((localDrawable instanceof TextureRegionDrawable)) return new TextureRegionDrawable((TextureRegionDrawable)localDrawable); if ((localDrawable instanceof NinePatchDrawable)) return new NinePatchDrawable((NinePatchDrawable)localDrawable); if ((localDrawable instanceof SpriteDrawable)) return new SpriteDrawable((SpriteDrawable)localDrawable); throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + localDrawable.getClass()); }
public void setBackground(Drawable paramDrawable) { if (this.background == paramDrawable) return; this.background = paramDrawable; if (paramDrawable == null) { pad(null); return; } float f1 = paramDrawable.getTopHeight(); float f2 = paramDrawable.getLeftWidth(); float f3 = paramDrawable.getBottomHeight(); float f4 = paramDrawable.getRightWidth(); if ((paramDrawable instanceof NinePatchDrawable)) { Padding localPadding = ((NinePatchDrawable)paramDrawable).getPadding(); if (localPadding != null) { f1 = localPadding.topPadding; f2 = localPadding.leftPadding; f3 = localPadding.bottomPadding; f4 = localPadding.rightPadding; } } pad(f1, f2, f3, f4); invalidate(); }
public static Drawable a(Drawable paramDrawable, n paramn) { ShaderProgram localShaderProgram = ag.aW; if ((paramDrawable instanceof NinePatchDrawable)) return new l((NinePatchDrawable)paramDrawable, localShaderProgram, paramn); return new com.nianticproject.ingress.common.ui.widget.j(paramDrawable, localShaderProgram, paramn); }
public static Drawable getRectLineDrawable(String ninePath) { NinePatchDrawable nine = new NinePatchDrawable(new NinePatch( EditorManager.getInstance().assetManager.get(ninePath,Texture.class), 2,2, 2, 2)); return nine; }
/** Creates an image stretched, and aligned center. * @param patch May be null. */ public BouncingImage (NinePatch patch) { this(new NinePatchDrawable(patch), Scaling.stretch, Align.center); }
private void initGuiGameOver() { mGuiGameOverStage = new Stage(new ScreenViewport()); Table rootTable = new Table(); if (DEBUG_RENDERER) { rootTable.debug(); } // add margin on the bottom for iOS final float dialogBottomOffset = (Gdx.app.getType() == Application.ApplicationType.iOS) ? 220 : 0; final float dialogMargin = 50.f; final float dialogWidth = Gdx.graphics.getWidth() - (dialogMargin * 2.f); final float dialogHeight = Gdx.graphics.getHeight() - (dialogMargin * 2.f) - dialogBottomOffset; rootTable.setWidth(dialogWidth); rootTable.setHeight(dialogHeight); rootTable.setPosition(dialogMargin, dialogMargin + dialogBottomOffset); rootTable.background( new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("blue_panel.png")), 24, 24, 24, 24))); Label label = new Label("GAME OVER", mSkin); label.setFontScale(2.f); label.setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT)); rootTable.add(label).expand().padTop(dialogHeight * 0.025f); rootTable.row(); TextButton restartButton = new TextButton("RESTART", mSkin); restartButton.getLabel().setFontScale(1.f); restartButton.getLabel().setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT)); restartButton.addCaptureListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { onStartGame(); } }); Array<Integer> highScores = fetchHighScores(); mHighScoreLabel = new Array<Label>(); for (int i = 0; i < highScores.size; i++) { Label scoreLabel = new Label("high score: " + highScores.get(i), mSkin); scoreLabel.setFontScale(1.0f); scoreLabel.setStyle(new Label.LabelStyle(mDefaultFont, COLOR_FONT)); rootTable.add(scoreLabel).expand(); rootTable.row(); mHighScoreLabel.add(scoreLabel); } // don't like the scene2d interface, if has bad defaults and documentation // try to correctly position the bottom restart button rootTable.add(restartButton).expand().width( dialogWidth - (dialogMargin * 4.f)).height(dialogHeight * 0.1f).bottom().padBottom(dialogHeight * 0.05f); mGuiGameOverStage.addActor(rootTable); }
@Override public void create() { Stage stage = new Stage(new ScreenViewport()); getComponentByType(GuiComponent.class).stage = stage; Table rootTable = new Table(); // add margin on the bottom for iOS final float dialogBottomOffset = (Gdx.app.getType() == Application.ApplicationType.iOS) ? 220 : 0; final float dialogMargin = 50.f; final float dialogWidth = Gdx.graphics.getWidth() - (dialogMargin * 2.f); final float dialogHeight = Gdx.graphics.getHeight() - (dialogMargin * 2.f) - dialogBottomOffset; mDefaultMargin = dialogWidth * 0.03f; rootTable.setWidth(dialogWidth); rootTable.setHeight(dialogHeight); rootTable.setPosition(dialogMargin, dialogMargin + dialogBottomOffset); rootTable.background( new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("blue_panel.png")), 24, 24, 24, 24))); // HEADER Label label = new Label("LEADERBOARD", mSkin); label.setFontScale(1.6f); label.setStyle(new Label.LabelStyle(mFont, COLOR_FONT)); rootTable.add(label) .expand(true, false) .padTop(dialogHeight * 0.05f) .padBottom(mDefaultMargin * 0.5f); rootTable.row(); mScrollPaneTable = new Table(mSkin); ScrollPane scrollPane = new ScrollPane(mScrollPaneTable); rootTable.add(scrollPane) .fill() .expand() .padTop(mDefaultMargin * 0.5f) .padBottom(mDefaultMargin * 0.5f); rootTable.row(); // RESTART button TextButton restartButton = new TextButton("RESTART", mSkin); restartButton.getLabel().setFontScale(1.f); restartButton.getLabel().setStyle(new Label.LabelStyle(mFont, COLOR_FONT)); restartButton.addCaptureListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { mEngine.getFirstEntityOfType(GameStateEntity.class).onStartGame(); } }); // try to correctly position the bottom restart button rootTable.add(restartButton) .expand(true, false) .width(dialogWidth - (dialogMargin * 4.f)) .height(dialogHeight * 0.08f) .padTop(mDefaultMargin * 0.5f) .padBottom(mDefaultMargin) .padLeft(mDefaultMargin) .padRight(mDefaultMargin) .center(); stage.addActor(rootTable); }
public static Drawable createDrawable(Assets.Textures texture, Color color) { NinePatch patch = GraphicsFactory.createNinePatch(texture, 14); patch.setColor(color.cpy()); return new NinePatchDrawable(patch); }
private void updatePreviewNinePatch() { int[] patches = model.readPatchValues(); NinePatch ninePatch = new NinePatch(model.texture, patches[0], patches[1], patches[2], patches[3]); previewImage.setDrawable(new NinePatchDrawable(ninePatch)); }
public static void init() { ICON_UP = new SpriteDrawable( new Sprite(new Texture(Gdx.files.internal(Config.IMAGE_PATH + "upIcon.png")))); ICON_DOWN = new SpriteDrawable( new Sprite(new Texture(Gdx.files.internal(Config.IMAGE_PATH + "downIcon.png")))); ICON_LAYER = new SpriteDrawable( new Sprite(new Texture(Gdx.files.local(Config.IMAGE_PATH + "icon_layer.png")))); ICON_MASK = new SpriteDrawable( new Sprite(new Texture(Gdx.files.local(Config.IMAGE_PATH + "icon_mask.png")))); ICON_NOISE = new SpriteDrawable( new Sprite(new Texture(Gdx.files.local(Config.IMAGE_PATH + "icon_noise.png")))); ICON_COMBINED = new SpriteDrawable( new Sprite(new Texture(Gdx.files.local(Config.IMAGE_PATH + "icon_combined.png")))); ICON_FLAT = new SpriteDrawable( new Sprite(new Texture(Gdx.files.local(Config.IMAGE_PATH + "icon_flat.png")))); ICON_ISLANDS = new SpriteDrawable( new Sprite(new Texture(Gdx.files.local(Config.IMAGE_PATH + "icon_islands.png")))); ICON_CONTINENT = new SpriteDrawable( new Sprite(new Texture(Gdx.files.local(Config.IMAGE_PATH + "icon_continent.png")))); SAMPLER_ICON.put(Layer.class, ICON_LAYER); SAMPLER_ICON.put(MaskedSampler.class, ICON_MASK); SAMPLER_ICON.put(NoiseSampler.class, ICON_NOISE); SAMPLER_ICON.put(Combined.class, ICON_COMBINED); SAMPLER_ICON.put(FlatSampler.class, ICON_FLAT); SAMPLER_ICON.put(AContinent.class, ICON_CONTINENT); NinePatch patch = new NinePatch(new Texture(Gdx.files.internal(Config.IMAGE_PATH + "background.png")), 1, 1, 1, 1); NinePatch patch2 = new NinePatch(new Texture(Gdx.files.internal(Config.IMAGE_PATH + "background2.png")), 1, 1, 1, 1); NinePatch patch3 = new NinePatch(new Texture(Gdx.files.internal(Config.IMAGE_PATH + "background3.png")), 1, 1, 1, 1); NinePatch patch4 = new NinePatch(new Texture(Gdx.files.internal(Config.IMAGE_PATH + "selectedBG.png")), 0, 0, 0, 0); NinePatch patch5 = new NinePatch(new Texture(Gdx.files.internal(Config.IMAGE_PATH + "transparentBG.png")), 0, 0, 0, 0); STANDARD_BACKGROUND = new NinePatchDrawable(patch2); INNER_BACKGROUND = new NinePatchDrawable(patch); ITEM_BACKGROUND = new NinePatchDrawable(patch3); SELECTED_BACKGROUND = new NinePatchDrawable(patch4); TRANSPARENT_BACKGROUND = new NinePatchDrawable(patch5); UI_SKIN = new Skin(Gdx.files.internal(Config.SKIN_PATH)); SAMPLER_SELECT_BOX_SKIN = new Skin(Gdx.files.internal(Config.SKIN_PATH)); SelectBox.SelectBoxStyle selectBoxStyleSampler = SAMPLER_SELECT_BOX_SKIN.get(SelectBox.SelectBoxStyle.class); selectBoxStyleSampler.fontColor = SAMPLER_COLOR; INTERPRETER_SELECT_BOX_SKIN = new Skin(Gdx.files.internal(Config.SKIN_PATH)); SelectBox.SelectBoxStyle selectBoxStyleInterpreter = INTERPRETER_SELECT_BOX_SKIN.get(SelectBox.SelectBoxStyle.class); selectBoxStyleInterpreter.fontColor = INTERPRETER_COLOR; TEXT_FIELD_STYLE_FAIL = new TextField.TextFieldStyle( UI_SKIN.getFont("default-font"), Color.RED, UI_SKIN.getDrawable("cursor"), UI_SKIN.getDrawable("selection"), UI_SKIN.getDrawable("textfield")); TEXT_FIELD_STYLE = new TextField.TextFieldStyle( UI_SKIN.getFont("default-font"), Color.WHITE, UI_SKIN.getDrawable("cursor"), UI_SKIN.getDrawable("selection"), UI_SKIN.getDrawable("textfield")); }
public static void init(TextureAtlas atlas) { UI_SKIN = new Skin(); FONT_DOSIS_SMALL = createFont("fonts/Dosis-Medium.ttf", 18, Color.WHITE, null, 0); FONT_DOSIS_MEDIUM_BORDER = createFont("fonts/Dosis-Medium.ttf", 26, Color.WHITE, Color.BLACK, 2); FONT_DOSIS_SMALL_DIALOG_HEADLINE = createFont("fonts/Dosis-Medium.ttf", 18, COLOR_DARK_BROWN, null, 0); FONT_DOSIS_PROGRESS_TYPE = createFont("fonts/Dosis-Medium.ttf", 22, COLOR_LIGHT_YELLOW, null, 0); FONT_ENTSANS_SMALL = createFont("fonts/entsans.ttf", 26, COLOR_LIGHT_YELLOW, null, 0); FONT_LIBERATION_SMALL_BORDER = createFont("fonts/LiberationMono-Bold.ttf", 22, Color.WHITE, Color.BLACK, 2); FONT_ENTSANS_TIME = createFont("fonts/entsans.ttf", 36, COLOR_LIGHT_YELLOW, null, 0); loadDefaultSkin(FONT_DOSIS_SMALL); NINE_PATCH_POPUP_BG_01 = new NinePatchDrawable(new NinePatch(atlas.findRegion("popupbg01"),16, 16, 16, 16)); NINE_PATCH_BUTTON_BG_01 = new NinePatchDrawable(new NinePatch(atlas.findRegion("buttonbg01"),32, 32, 32, 32)); NINE_PATCH_DIALOG_01 = new NinePatchDrawable(new NinePatch(atlas.findRegion("dialogBg01"), 33, 33, 42, 21)); NINE_PATCH_STANDARD_BUTTON = new NinePatchDrawable(new NinePatch(atlas.findRegion("buttonStandard9patch"), 18, 18, 18, 18)); TextButton.TextButtonStyle textButtonStyle = UI_SKIN.get(TextButton.TextButtonStyle.class); STYLE_BUTTON_01 = new TextButton.TextButtonStyle(textButtonStyle); // copy from default values STYLE_BUTTON_01.up = Styles.NINE_PATCH_BUTTON_BG_01; STYLE_BUTTON_01.down = Styles.NINE_PATCH_BUTTON_BG_01; STYLE_BUTTON_01.checked = Styles.NINE_PATCH_BUTTON_BG_01; STYLE_BUTTON_01.fontColor = COLOR_01; STYLE_BUTTON_02 = new TextButton.TextButtonStyle(textButtonStyle); STYLE_BUTTON_02.up = Styles.NINE_PATCH_STANDARD_BUTTON; STYLE_BUTTON_02.down = Styles.NINE_PATCH_STANDARD_BUTTON; STYLE_BUTTON_02.checked = Styles.NINE_PATCH_STANDARD_BUTTON; STYLE_BUTTON_02.font = FONT_DOSIS_SMALL_DIALOG_HEADLINE; Label.LabelStyle standardLabelStyle = UI_SKIN.get(Label.LabelStyle.class); LABEL_01 = new Label.LabelStyle(standardLabelStyle); LABEL_01.font = FONT_DOSIS_SMALL; LABEL_PROPERTY = new Label.LabelStyle(standardLabelStyle); LABEL_PROPERTY.font = FONT_DOSIS_SMALL; LABEL_PROPERTY.fontColor = Color.BLACK; LABEL_02 = new Label.LabelStyle(standardLabelStyle); LABEL_02.font = FONT_DOSIS_MEDIUM_BORDER; LABEL_DEV = new Label.LabelStyle(standardLabelStyle); LABEL_DEV.font = FONT_DOSIS_SMALL; LABEL_HUD_NUMBERS = new Label.LabelStyle(standardLabelStyle); LABEL_HUD_NUMBERS.font = FONT_ENTSANS_SMALL; LABEL_VALUE_ARTIFACT = new Label.LabelStyle(standardLabelStyle); LABEL_VALUE_ARTIFACT.font = FONT_ENTSANS_SMALL; LABEL_VALUE_ARTIFACT.fontColor = Color.BLACK; LABEL_DIALOG_HEADLINE = new Label.LabelStyle(standardLabelStyle); LABEL_DIALOG_HEADLINE.font = FONT_DOSIS_SMALL_DIALOG_HEADLINE; LABEL_PROGRESS_TYPE = new Label.LabelStyle(standardLabelStyle); LABEL_PROGRESS_TYPE.font = FONT_DOSIS_PROGRESS_TYPE; LABEL_RACE_TIME = new Label.LabelStyle(standardLabelStyle); LABEL_RACE_TIME.font = FONT_ENTSANS_TIME; TextField.TextFieldStyle standardTextFieldStyle = UI_SKIN.get(TextField.TextFieldStyle.class); TEXT_FIELD_STYLE_FAIL = new TextField.TextFieldStyle(standardTextFieldStyle); TEXT_FIELD_STYLE_FAIL.fontColor = Color.RED; TEXT_FIELD_STYLE = new TextField.TextFieldStyle(standardTextFieldStyle); IMAGE_BUTTON_STYLE = new ImageButton.ImageButtonStyle(); IMAGE_BUTTON_STYLE.checked = new TextureRegionDrawable(atlas.findRegion("checkboxChecked")); IMAGE_BUTTON_STYLE.up = new TextureRegionDrawable(atlas.findRegion("checkbox")); //standardCheckBoxStyle.checked = //standardCheckBoxStyle.disabled = }