Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Image#setScaling()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Image#setScaling() . 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: AbilityIconCounter.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
public AbilityIconCounter(Ability ability, int value) {
    if (ability == null) {
        ability = Config.abilities.get("skip-turn");
    }
    image = new Image(Config.skin.getDrawable("ability/" + ability.name + "-icon"));
    if (ability.cost <0) image.setColor(AbilityIcon.unique);
    image.setScaling(Scaling.none);
    image.setAlign(Align.left | Align.top);
    image.moveBy(0, 1);

    counter = new Label("", Config.skin, "default", "inventory-counter");
    counter.setAlignment(Align.right | Align.bottom);
    setCount(value);

    addActor(image);
    addActor(counter);

    setSize(image.getPrefWidth(), image.getPrefHeight());
}
 
Example 2
Source File: VisImageButton.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private void init () {
	image = new Image();
	image.setScaling(Scaling.fit);
	add(image);
	setSize(getPrefWidth(), getPrefHeight());

	addListener(new InputListener() {
		@Override
		public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
			if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisImageButton.this);
			return false;
		}
	});

	updateImage();
}
 
Example 3
Source File: SlotActor.java    From Cubes with MIT License 6 votes vote down vote up
public SlotActor(Inventory inventory, int num) {
  super(new ButtonStyle());

  Image image = new Image();
  image.setScaling(Scaling.fit);
  image.setDrawable(new SlotDrawable());
  image.setTouchable(Touchable.disabled);
  add(image);
  setSize(getPrefWidth(), getPrefHeight());

  this.inventory = inventory;
  this.num = num;

  InventoryManager.newSlot(this);
  addListener(new SlotTooltipListener(this));
}
 
Example 4
Source File: GLTFDemoUI.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
private void addMaterialTextureSwitch(String name, final Material material, long type){
	final PBRTextureAttribute attribute = material.get(PBRTextureAttribute.class, type);
	if(attribute != null){
		final TextButton bt = new TextButton(name, getSkin(), "toggle");
		bt.setChecked(true);
		materialTable.add(bt);
		
		Image pict = new Image(attribute.textureDescription.texture);
		
		pict.setScaling(Scaling.fit);
		
		materialTable.add(pict).size(64);
		
		materialTable.row();
		
		bt.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				if(bt.isChecked()){
					material.set(attribute);
				}else{
					material.remove(attribute.type);
				}
			}
		});
	}
	
}
 
Example 5
Source File: GLTFDemoUI.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public void setImage(Texture texture){
	if(texture != null){
		Image img = new Image(texture);
		img.setScaling(Scaling.fit);
		screenshotsTable.add(img).height(100);
	}
}
 
Example 6
Source File: CreatureQueueWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void initialize() {
    creaturesList.defaults().pad(2);
    creaturesList.padTop(12);

    Image left = new Image(Config.skin, "ui-creature-queue-gradient-left");
    left.setScaling(Scaling.stretchY);
    left.setAlign(Align.left);
    left.setTouchable(Touchable.disabled);

    Image right = new Image(Config.skin, "ui-creature-queue-gradient-right");
    right.setScaling(Scaling.stretchY);
    right.setAlign(Align.right);
    right.setTouchable(Touchable.disabled);

    Stack stack = new Stack();
    stack.add(new ScrollPane(creaturesList, new ScrollPane.ScrollPaneStyle()));
    stack.add(left);
    stack.add(right);

    Table content = new Table(Config.skin);
    content.setTouchable(Touchable.enabled);
    content.setBackground("ui-inventory-ability-window-background");
    content.defaults().pad(2);
    content.add(new LocLabel("ui-turns-order")).row();
    content.add(new Image(Config.skin, "ui-creature-info-line")).width(100).row();
    content.add(stack).maxWidth(table.getStage().getWidth() - 45).padRight(4).padLeft(4).row();

    table.add(content);
}
 
Example 7
Source File: DieSettingsWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private void updateChangeNameButton(Button button, Params params) {
    final Item coin = Config.items.get("coin");
    button.setDisabled(params.die.renames == 0 && params.userData.getItemCount(coin) == 0);
    button.clearChildren();
    if (params.die.renames == 0) {
        button.add(new LocLabel("ui-change-name-for")).padLeft(4);
        Image image = new Image(Config.skin, "item/coin");
        image.setScaling(Scaling.none);
        button.add(image).padTop(0).padBottom(-4);
        button.add("1").padRight(4);
    } else {
        button.add(new LocLabel("ui-change-name"));
    }
}
 
Example 8
Source File: SourceImage.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public SourceImage(Pixmap pixmap) {
    this.pixmap = pixmap;
    image = new Image();
    image.setScaling(Scaling.stretch);
    addActor(image);
}
 
Example 9
Source File: Editor.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void create() {

	if (EditorLogger.debugMode()) {
		EngineLogger.setDebug();
	}

	Gdx.graphics.setWindowedMode(Math.max((int) (Gdx.graphics.getDisplayMode().width * 0.9), 1920 / 2),
			Math.max((int) (Gdx.graphics.getDisplayMode().height * 0.9), 1080 / 2));

	skin = new BladeSkin(Gdx.files.internal(SKIN));
	VisUI.load();
	FileChooser.setDefaultPrefsName("com.bladecoder.engineeditor.filechooser");

	/*** STAGE SETUP ***/
	stage = new Stage(new ScreenViewport());
	Gdx.input.setInputProcessor(stage);

	setCtx();

	Message.init(skin);

	scnEditor = new ScnEditor(skin);
	scnEditor.setBackground("background");
	skin.getFont("default-font").getData().markupEnabled = true;

	// RIGHT PANEL
	ScenePanel scenePanel = new ScenePanel(skin);
	ActorPanel actorPanel = new ActorPanel(skin);

	Table rightPanel = new Table(skin);
	rightPanel.top().left();
	rightPanel.add(actorPanel).expand().fill().left();
	rightPanel.setBackground("background");

	SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin);

	splitPaneRight.setSplitAmount(0.75f);

	// LEFT PANEL
	ProjectPanel projectPanel = new ProjectPanel(skin);
	Image img = new Image(Ctx.assetManager.getIcon("title"));
	img.setScaling(Scaling.none);
	img.setAlign(Align.left);

	Table leftPanel = new Table(skin);
	leftPanel.top().left().padLeft(10);
	leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(0).left();
	leftPanel.row();
	leftPanel.add(new ProjectToolbar(skin)).expandX().fill().left();
	leftPanel.row();
	leftPanel.add(projectPanel).expand().fill().left();
	leftPanel.row();
	leftPanel.add(scenePanel).expand().fill().left();
	leftPanel.setBackground("background");

	SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin);
	splitPaneLeft.setFillParent(true);
	splitPaneLeft.setSplitAmount(0.25f);
	stage.addActor(splitPaneLeft);

	// LOAD LAST OPEN PROJECT
	String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, "");
	final File lastProjectFile = new File(lastProject);

	if (!lastProject.isEmpty() && lastProjectFile.exists()) {
		EditorLogger.debug("Loading previous project: " + lastProject);

		try {
			EditorUtils.checkVersionAndLoadProject(lastProjectFile, stage, skin);
		} catch (Exception e) {
			EditorLogger.error("Error loading previous project.", e);
			Ctx.project.closeProject();
		}
	}

	stage.setScrollFocus(scnEditor.getScnWidget());
	stage.setKeyboardFocus(scnEditor.getScnWidget());

	// TooltipManager.getInstance().instant();
	TooltipManager.getInstance().initialTime = 0.2f;
	TooltipManager.getInstance().hideAll();
	TooltipManager.getInstance().subsequentTime = 0.2f;
}