com.badlogic.gdx.scenes.scene2d.ui.ImageButton Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.ImageButton. 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: GameSpeedController.java    From GdxDemo3D with Apache License 2.0 6 votes vote down vote up
public GameSpeedController(TextureAtlas buttonAtlas) {
	btnPauseStyle = new ImageButton.ImageButtonStyle();
	btnPauseStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("pause-up"));
	btnPauseStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("pause-down"));

	btnPlayStyle = new ImageButton.ImageButtonStyle();
	btnPlayStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("play-up"));
	btnPlayStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("play-down"));

	btnSlowStyle = new ImageButton.ImageButtonStyle();
	btnSlowStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("slow-up"));
	btnSlowStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("slow-down"));

	imageButton = new ImageButton(btnPauseStyle);

	add(imageButton);

	imageButton.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			setGameSpeed();
			event.cancel();
		}
	});
}
 
Example #2
Source File: ItemBox.java    From TerraLegion with MIT License 6 votes vote down vote up
public ItemBox(ItemStack stack, int inventoryX, int inventoryY, String extra) {
	this.stack = stack;
	this.inventoryX = inventoryX;
	this.inventoryY = inventoryY;
	this.extra = extra;

	btnGroup = CachePool.getGroup();
	btnGroup.setBounds(0, 0, 60, 60);

	style = new ImageButton.ImageButtonStyle();
	style.up = inventoryBoxDrawable;
	btn = new ImageButton(style);
	btn.setBounds(0, 0, 60, 60);
	btn.setName(extra);
	btnGroup.addActor(btn);

	setupBox();
	add(btnGroup);
}
 
Example #3
Source File: CCButtonTest.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #4
Source File: AttachmentTypeToggle.java    From talos with Apache License 2.0 6 votes vote down vote up
public AttachmentTypeToggle(Skin skin) {
    setSkin(skin);
    setBackground(getSkin().getDrawable("panel_button_bg"));

    drawableMap.put(AttachmentPoint.AttachmentType.POSITION, getSkin().getDrawable("icon-target"));
    drawableMap.put(AttachmentPoint.AttachmentType.ROTATION, getSkin().getDrawable("icon-angle"));
    drawableMap.put(AttachmentPoint.AttachmentType.TRANSPARENCY, getSkin().getDrawable("icon-transparency"));
    drawableMap.put(AttachmentPoint.AttachmentType.COLOR, getSkin().getDrawable("icon-color"));

    button = new ImageButton(drawableMap.get(AttachmentPoint.AttachmentType.POSITION));

    addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            currentType = currentType.next();
            setButtonDrawable();
        }
    });

    setButtonDrawable();
}
 
Example #5
Source File: ProjectToolbar.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: EditToolbar.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public EditToolbar(Skin skin) {
super();

this.skin = skin;
pad(0);

      createBtn = new ImageButton(skin);
      editBtn = new ImageButton(skin);
      deleteBtn = new ImageButton(skin);
      copyBtn = new ImageButton(skin);
      pasteBtn = new ImageButton(skin);

      addToolBarButton(createBtn, "ic_add","New", "Create a new Element");
      addToolBarButton(editBtn, "ic_edit","Edit", "Edit the selected Element");
      addToolBarButton(deleteBtn, "ic_delete","Delete", "Delete and put in the clipboard"); 
      addToolBarButton(copyBtn, "ic_copy","Copy", "Copy to the clipboard");
      addToolBarButton(pasteBtn, "ic_paste","Paste", "Paste from the clipboard");
  }
 
Example #7
Source File: EditToolbar.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #8
Source File: ChapterList.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public ChapterList(Skin skin) {
	super(skin);

	list.setCellRenderer(listCellRenderer);

	initBtn = new ImageButton(skin);
	toolbar.addToolBarButton(initBtn, "ic_check", "Set init chapter", "Set init chapter");

	initBtn.setDisabled(false);
	toolbar.hideCopyPaste();

	initBtn.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			setDefault();
		}
	});

}
 
Example #9
Source File: ButtonCheckedImageLmlAttribute.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final ImageButton actor,
                    final String rawAttributeData) {
    final ImageButtonStyle style = new ImageButtonStyle(actor.getStyle());
    style.imageChecked = parser.getData().getDefaultSkin().getDrawable(parser.parseString(rawAttributeData, actor));
    actor.setStyle(style);
}
 
Example #10
Source File: VerbUI.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void sizeChanged() {
	super.sizeChanged();

	for (Actor a : arrowPanel.getChildren()) {
		ImageButton b = (ImageButton) a;
		float h = (getHeight() / 2) - style.infoLineLabelStyle.font.getLineHeight() / 2 - DPIUtils.getSpacing();
		float ih = b.getImage().getDrawable().getMinHeight();
		float iw = b.getImage().getDrawable().getMinWidth() * h / ih;
		b.getImageCell().maxSize(iw, h);
	}

	arrowPanel.invalidateHierarchy();
}
 
Example #11
Source File: MenuExtensionScreen.java    From Unlucky with MIT License 5 votes vote down vote up
public MenuExtensionScreen(final Unlucky game, final ResourceManager rm) {
    super(game, rm);

    // init exit button
    ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
    style.imageUp = new TextureRegionDrawable(rm.menuExitButton[0][0]);
    style.imageDown = new TextureRegionDrawable(rm.menuExitButton[1][0]);
    exitButton = new ImageButton(style);
    exitButton.setSize(18, 18);
    exitButton.setPosition(177, 99);
}
 
Example #12
Source File: ResourceManager.java    From Unlucky with MIT License 5 votes vote down vote up
/**
 * Loads the ImageButton styles for buttons with up and down image effects
 *
 * @param numButtons
 * @param sprites
 * @return a style array for ImageButtons
 */
public ImageButton.ImageButtonStyle[] loadImageButtonStyles(int numButtons, TextureRegion[][] sprites) {
    ImageButton.ImageButtonStyle[] ret = new ImageButton.ImageButtonStyle[numButtons];
    for (int i = 0; i < numButtons; i++) {
        ret[i] = new ImageButton.ImageButtonStyle();
        ret[i].imageUp = new TextureRegionDrawable(sprites[0][i]);
        ret[i].imageDown = new TextureRegionDrawable(sprites[1][i]);
    }
    return ret;
}
 
Example #13
Source File: UIWindow.java    From Norii with Apache License 2.0 5 votes vote down vote up
private void updateSizeImageButtons(Actor actor) {
	final ImageButton button = (ImageButton) actor;
	if (button.getImage() != null) {
		final Cell<Actor> cell = this.getCell(actor);
		cell.size(Gdx.graphics.getWidth() / BUTTON_WIDTH_FACTOR, Gdx.graphics.getHeight() / BUTTON_HEIGHT_FACTOR);
		button.setBounds(cell.getActorX(), cell.getActorY(), Gdx.graphics.getWidth() / BUTTON_WIDTH_FACTOR, Gdx.graphics.getHeight() / BUTTON_HEIGHT_FACTOR);
	}
}
 
Example #14
Source File: UIWindow.java    From Norii with Apache License 2.0 5 votes vote down vote up
protected void updateSize() {
	for (final Actor actor : this.getChildren()) {
		if (actor.getClass() == Label.class) {
			updateSizeLabels(actor);
		}

		if (actor.getClass() == ImageButton.class) {
			updateSizeImageButtons(actor);
		}
	}
}
 
Example #15
Source File: ActionUIButton.java    From Norii with Apache License 2.0 5 votes vote down vote up
public ActionUIButton(String imageFileName) {
	Utility.loadTextureAsset(imageFileName);
	tr = new TextureRegion(Utility.getTextureAsset(imageFileName));
	buttonImage = new TextureRegionDrawable(tr);
	btnStyle = new ImageButtonStyle();
	btnStyle.up = buttonImage;
	button = new ImageButton(btnStyle);
}
 
Example #16
Source File: WidgetsBar.java    From gdx-skineditor with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
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);
	}
	
	
}
 
Example #17
Source File: BackgroundButton.java    From talos with Apache License 2.0 5 votes vote down vote up
public BackgroundButton(Skin skin, Drawable drawable) {
    setSkin(skin);
    setBackground(getSkin().getDrawable("panel_button_bg"));

    button = new ImageButton(drawable);

    add(button);
}
 
Example #18
Source File: BackgroundButton.java    From talos with Apache License 2.0 5 votes vote down vote up
public BackgroundButton(Skin skin, Drawable on, Drawable off) {
    setSkin(skin);
    setBackground(getSkin().getDrawable("panel_button_bg"));

    button = new ImageButton(on, on, off);

    add(button);
}
 
Example #19
Source File: ImageButtons.java    From Cubes with MIT License 4 votes vote down vote up
public static ImageButton.ImageButtonStyle chatButton() {
  TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/ChatButtonUp.png"));
  TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/ChatButtonDown.png"));
  return new ImageButton.ImageButtonStyle(up, down, null, null, null, null);
}
 
Example #20
Source File: ImageButtons.java    From Cubes with MIT License 4 votes vote down vote up
public static ImageButton.ImageButtonStyle blocksButton() {
  TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/BlocksButtonUp.png"));
  TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/BlocksButtonDown.png"));
  return new ImageButton.ImageButtonStyle(up, down, null, null, null, null);
}
 
Example #21
Source File: ImageButtons.java    From Cubes with MIT License 4 votes vote down vote up
public static ImageButton.ImageButtonStyle descendButton() {
  TextureRegionDrawable t = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/DescendButton.png"));
  return new ImageButton.ImageButtonStyle(t, t, null, null, null, null);
}
 
Example #22
Source File: ImageButtons.java    From Cubes with MIT License 4 votes vote down vote up
public static ImageButton.ImageButtonStyle jumpButton() {
  TextureRegionDrawable t = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/JumpButton.png"));
  return new ImageButton.ImageButtonStyle(t, t, null, null, null, null);
}
 
Example #23
Source File: ImageButtons.java    From Cubes with MIT License 4 votes vote down vote up
public static ImageButton.ImageButtonStyle debugButton() {
  TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/DebugButtonUp.png"));
  TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/DebugButtonDown.png"));
  return new ImageButton.ImageButtonStyle(up, down, null, null, null, null);
}
 
Example #24
Source File: ImageButtons.java    From Cubes with MIT License 4 votes vote down vote up
public static ImageButton.ImageButtonStyle inventoryModifierButton() {
  TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/InventoryModifierButtonUp.png"));
  TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/InventoryModifierButtonDown.png"));
  return new ImageButton.ImageButtonStyle(up, down, null, null, null, null);
}
 
Example #25
Source File: OptionsPane.java    From gdx-skineditor with Apache License 2.0 4 votes vote down vote up
/**
 * 
 */
public void refreshSelection() {

	String key = listStyles.getSelected();
	
	ImageButton button = (ImageButton) game.screenMain.barWidgets.group.getChecked();
	String widget = button.getUserObject().toString();
	String widgetStyle = "com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style";
	Gdx.app.log("OptionsPane", "Fetching style:" + widgetStyle);
	
	listItems.clear();

	try {
		Class<?> style = Class.forName(widgetStyle);

		styles = game.skinProject.getAll(style);
		if (styles == null) {
			Gdx.app.error("OptionsPane", "No styles defined for this widget type");

			tableFields.clear();
		} else {
			Keys<String> keys = styles.keys();

			for (String k : keys) {
				listItems.add(k);

			}
			
		}
		listItems.sort();
		listStyles.setItems(listItems);

	} catch (Exception e) {
		e.printStackTrace();
	}

	
	currentStyle = styles.get(key);
	updateTableFields(key);

}
 
Example #26
Source File: ButtonCheckedImageLmlAttribute.java    From gdx-vfx with Apache License 2.0 4 votes vote down vote up
@Override
public Class<ImageButton> getHandledType() {
    return ImageButton.class;
}
 
Example #27
Source File: OptionsPane.java    From gdx-skineditor with Apache License 2.0 4 votes vote down vote up
/**
 * 
 */
public void refresh() {

	Gdx.app.log("OptionsPane", "Refresh");

	ImageButton button = (ImageButton) game.screenMain.barWidgets.group.getChecked();
	String widget = button.getUserObject().toString();
	String widgetStyle = "com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style";
	Gdx.app.log("OptionsPane", "Fetching style:" + widgetStyle);
	
	listItems.clear();
	int selection = -1;

	try {
		Class<?> style = Class.forName(widgetStyle);

		styles = game.skinProject.getAll(style);
		if (styles == null) {
			Gdx.app.error("OptionsPane", "No styles defined for this widget type");

			tableFields.clear();
		} else {
			Keys<String> keys = styles.keys();
			boolean first = true;

			for (String key : keys) {
				listItems.add(key);

				if (first == true) {

					currentStyle = styles.get(key);
					updateTableFields(key);
					selection = listItems.size-1;
					first = false;
				}

			}

		}
		listItems.sort();
		listStyles.setItems(listItems);
		
		if (selection != -1) {
			listStyles.setSelectedIndex(selection);
		}
		
	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
Example #28
Source File: LevelUpScreen.java    From Unlucky with MIT License 4 votes vote down vote up
public LevelUpScreen(GameScreen gameScreen, TileMap tileMap, Player player, ResourceManager rm) {
    super(gameScreen, tileMap, player, rm);

    // create bg
    ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
    style.imageUp = new TextureRegionDrawable(rm.levelupscreen400x240);
    ui = new ImageButton(style);
    ui.setSize(200, 120);
    ui.setPosition(0, 0);
    ui.setTouchable(Touchable.disabled);
    stage.addActor(ui);

    handleClick();

    // create animation
    levelUpAnim = new AnimationManager(rm.levelUp96x96, 4, 0, 1 / 4f);

    // create labels
    BitmapFont font = rm.pixel10;
    Label.LabelStyle titleFont = new Label.LabelStyle(font, new Color(0, 205 / 255.f, 20 / 255.f, 1));
    Label.LabelStyle stdWhite = new Label.LabelStyle(font, new Color(1, 1, 1, 1));
    Label.LabelStyle yellow = new Label.LabelStyle(font, new Color(1, 212 / 255.f, 0, 1));
    Label.LabelStyle blue = new Label.LabelStyle(font, new Color(0, 190 / 255.f, 1, 1));

    title = new Label("LEVEL UP!", titleFont);
    title.setSize(200, 20);
    title.setPosition(0, 95);
    title.setFontScale(2.5f);
    title.setAlignment(Align.center);
    title.setTouchable(Touchable.disabled);
    stage.addActor(title);

    levelDesc = new Label("You reached level 1", stdWhite);
    levelDesc.setSize(200, 20);
    levelDesc.setPosition(0, 80);
    levelDesc.setAlignment(Align.center);
    levelDesc.setTouchable(Touchable.disabled);
    stage.addActor(levelDesc);

    statsDescs = new Label[statNames.length];
    stats = new Label[statNames.length];
    increases = new Label[statNames.length];

    for (int i = 0; i < statNames.length; i++) {
        statsDescs[i] = new Label(statNames[i], stdWhite);
        statsDescs[i].setSize(10, 10);
        statsDescs[i].setFontScale(1.3f / 2);
        statsDescs[i].setPosition(100, 17 + (i * 12));
        statsDescs[i].setAlignment(Align.left);
        statsDescs[i].setTouchable(Touchable.disabled);
        stage.addActor(statsDescs[i]);

        stats[i] = new Label("1330", blue);
        stats[i].setSize(10, 10);
        stats[i].setFontScale(1.3f / 2);
        stats[i].setPosition(140, 17 + (i * 12));
        stats[i].setAlignment(Align.left);
        stats[i].setTouchable(Touchable.disabled);
        stage.addActor(stats[i]);

        increases[i] = new Label("+20", yellow);
        increases[i].setSize(10, 10);
        increases[i].setFontScale(1.3f / 2);
        increases[i].setPosition(170, 17 + (i * 12));
        increases[i].setAlignment(Align.left);
        increases[i].setTouchable(Touchable.disabled);
        stage.addActor(increases[i]);
    }

    clickToContinue = new Label("Click to continue", stdWhite);
    clickToContinue.setSize(200, 10);
    clickToContinue.setFontScale(0.5f);
    clickToContinue.setPosition(0, 2);
    clickToContinue.setAlignment(Align.center);
    clickToContinue.setTouchable(Touchable.disabled);
    stage.addActor(clickToContinue);
}
 
Example #29
Source File: InventoryUI.java    From Unlucky with MIT License 4 votes vote down vote up
public InventoryUI(final Unlucky game, Player player, final ResourceManager rm) {
    super(game, player, rm);

    ui = new MovingImageUI(rm.inventoryui372x212, new Vector2(200, 7), new Vector2(7, 7), 225.f, 186, 106);
    ui.setTouchable(Touchable.enabled);

    // create exit button
    ImageButton.ImageButtonStyle exitStyle = new ImageButton.ImageButtonStyle();
    exitStyle.imageUp = new TextureRegionDrawable(rm.exitbutton18x18[0][0]);
    exitStyle.imageDown = new TextureRegionDrawable(rm.exitbutton18x18[1][0]);
    exitButton = new ImageButton(exitStyle);
    exitButton.setSize(9, 9);

    // Fonts and Colors
    Label.LabelStyle[] labelColors = new Label.LabelStyle[] {
        new Label.LabelStyle(rm.pixel10, new Color(1, 1, 1, 1)), // white
        new Label.LabelStyle(rm.pixel10, new Color(0, 190 / 255.f, 1, 1)), // blue
        new Label.LabelStyle(rm.pixel10, new Color(1, 212 / 255.f, 0, 1)), // yellow
        new Label.LabelStyle(rm.pixel10, new Color(0, 1, 60 / 255.f, 1)), // green
        new Label.LabelStyle(rm.pixel10, new Color(220 / 255.f, 0, 0, 1)) // red
    };

    // create headers
    headers = new Label[3];
    for (int i = 0; i < headers.length; i++) {
        headers[i] = new Label(headerStrs[i], labelColors[0]);
        headers[i].setSize(62, 4);
        headers[i].setFontScale(0.5f);
        headers[i].setTouchable(Touchable.disabled);
        headers[i].setAlignment(Align.left);
    }

    // create stats
    stats = new Label[5];
    for (int i = 0; i < stats.length; i++) {
        stats[i] = new Label("", labelColors[0]);
        stats[i].setSize(62, 4);
        stats[i].setFontScale(0.5f);
        stats[i].setTouchable(Touchable.disabled);
        stats[i].setAlignment(Align.left);
    }
    stats[0].setStyle(labelColors[3]);
    stats[1].setStyle(labelColors[4]);
    stats[2].setStyle(labelColors[1]);
    stats[3].setStyle(labelColors[2]);
    stats[4].setStyle(labelColors[2]);

    selectedSlot = new Image(rm.selectedslot28x28);
    selectedSlot.setVisible(false);
    tooltip = new ItemTooltip(rm.skin);
    tooltip.setPosition(90, 15);

    enabled = new ImageButton.ImageButtonStyle();
    enabled.imageUp = new TextureRegionDrawable(rm.invbuttons92x28[0][0]);
    enabled.imageDown = new TextureRegionDrawable(rm.invbuttons92x28[1][0]);
    disabled = new ImageButton.ImageButtonStyle();
    disabled.imageUp = new TextureRegionDrawable(rm.invbuttons92x28[2][0]);
    invButtons = new ImageButton[2];
    invButtonLabels = new Label[2];
    String[] texts = { "ENCHANT", "SELL" };
    for (int i = 0; i < 2; i++) {
        invButtons[i] = new ImageButton(disabled);
        invButtons[i].setTouchable(Touchable.disabled);
        invButtonLabels[i] = new Label(texts[i], labelColors[0]);
        invButtonLabels[i].setFontScale(0.5f);
        invButtonLabels[i].setTouchable(Touchable.disabled);
        invButtonLabels[i].setSize(46, 14);
        invButtonLabels[i].setAlignment(Align.center);
    }

    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            end();
            if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume);
            if (inMenu) {
                removeInventoryActors();
                game.menuScreen.transitionIn = 1;
                renderHealthBars = false;
                game.inventoryScreen.setSlideScreen(game.menuScreen, true);
            }
            else {
                Gdx.input.setInputProcessor(gameScreen.multiplexer);
            }
        }
    });

    handleStageEvents();
    handleInvButtonEvents();
}
 
Example #30
Source File: MoveUI.java    From Unlucky with MIT License 4 votes vote down vote up
/**
 * Creates the UI for the Run and ______ buttons
 * Run will have some random low percentage to escape the battle
 */
private void createOptionUI() {
    // make buttons
    optionButtons = new ImageButton[2];
    disabled = new ImageButton.ImageButtonStyle[2];
    optionStyles = rm.loadImageButtonStyles(2, rm.stdmedbutton110x50);
    for (int i = 0; i < 2; i++) {
        optionButtons[i] = new ImageButton(optionStyles[1 - i]);
        disabled[i] = new ImageButton.ImageButtonStyle();
        disabled[i].imageUp = new TextureRegionDrawable(rm.stdmedbutton110x50[1][1 - i]);
    }

    // set pos
    // ____ button
    optionButtons[0].setPosition(2 * Util.MOVE_WIDTH, Util.MOVE_HEIGHT);
    // run button
    optionButtons[1].setPosition(2 * Util.MOVE_WIDTH, 0);

    // make labels
    optionNameLabels = new Label[2];
    optionDescLabels = new Label[2];

    BitmapFont bitmapFont = rm.pixel10;
    Label.LabelStyle font = new Label.LabelStyle(bitmapFont, new Color(255, 255, 255, 255));

    optionNameLabels[0] = new Label("", font);
    optionNameLabels[0].setAlignment(Align.topLeft);
    optionNameLabels[0].setSize(55, 25);
    optionNameLabels[0].setFontScale(0.62f);
    optionNameLabels[0].setTouchable(Touchable.disabled);
    optionNameLabels[0].setPosition(2 * Util.MOVE_WIDTH + 7, Util.MOVE_HEIGHT - 6);

    optionDescLabels[0] = new Label("", font);
    optionDescLabels[0].setAlignment(Align.topLeft);
    optionDescLabels[0].setSize(55, 25);
    optionDescLabels[0].setFontScale(0.7f / 2);
    optionDescLabels[0].setTouchable(Touchable.disabled);
    optionDescLabels[0].setPosition(2 * Util.MOVE_WIDTH + 7, Util.MOVE_HEIGHT - 12);

    optionNameLabels[1] = new Label("Run", font);
    optionNameLabels[1].setAlignment(Align.topLeft);
    optionNameLabels[1].setSize(55, 25);
    optionNameLabels[1].setFontScale(0.62f);
    optionNameLabels[1].setTouchable(Touchable.disabled);
    optionNameLabels[1].setPosition(2 * Util.MOVE_WIDTH + 7, -6);

    optionDescLabels[1] = new Label("7% chance to run\nfrom a battle", font);
    optionDescLabels[1].setAlignment(Align.topLeft);
    optionDescLabels[1].setSize(55, 25);
    optionDescLabels[1].setFontScale(0.7f / 2);
    optionDescLabels[1].setTouchable(Touchable.disabled);
    optionDescLabels[1].setPosition(2 * Util.MOVE_WIDTH + 7, -12);

    for (int i = 0; i < 2; i++) {
        stage.addActor(optionButtons[i]);
        stage.addActor(optionNameLabels[i]);
        stage.addActor(optionDescLabels[i]);
    }

    handleOptionEvents();
}