Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Skin

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Skin. These examples are extracted from open source projects. 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 Project: gdx-soundboard   Source File: FileChooser.java    License: MIT License 6 votes vote down vote up
/**
 * Create file loading dialog.
 * 
 * @param title
 * @param skin
 * @param path
 * @return
 */
public static FileChooser createLoadDialog(String title, final Skin skin, final FileHandle path) {
    final FileChooser load = new FileChooser(title, skin, path) {
        @Override
        protected void result(Object object) {

            if (resultListener == null) {
                return;
            }

            final boolean success = (Boolean) object;
            resultListener.result(success, getResult());
        }
    }.setNewFolderEnabled(false).setFileNameEnabled(false).setOkButtonText("Load");

    return load;

}
 
Example 2
Source Project: Cardshifter   Source File: DeckCardView.java    License: Apache License 2.0 6 votes vote down vote up
public DeckCardView(Skin skin, int id, String name, DeckBuilderScreen screen) {
    super(skin);
    this.count = new Label("", skin);
    this.add(count).left().expand().fill();
    this.add(new Label(name, skin)).right();
    this.name = name;
    this.id = id;
    this.screen = screen;
    setName(name);
    
    this.setTouchable(Touchable.enabled);
    this.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            DeckCardView.this.screen.removeCardFromDeck(DeckCardView.this.id);
        }
    });
}
 
Example 3
Source Project: bladecoder-adventure-engine   Source File: ChapterList.java    License: 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 4
Source Project: gdx-ai   Source File: SemaphoreGuardTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Actor createActor (Skin skin) {
	// Create the semaphore
	NonBlockingSemaphoreRepository.clear();
	NonBlockingSemaphoreRepository.addSemaphore("dogSemaphore", 1);

	Reader reader = null;
	try {
		// Parse Buddy's tree
		reader = Gdx.files.internal("data/dogSemaphore.tree").reader();
		BehaviorTreeParser<Dog> parser = new BehaviorTreeParser<Dog>(BehaviorTreeParser.DEBUG_HIGH);
		BehaviorTree<Dog> buddyTree = parser.parse(reader, new Dog("Buddy"));

		// Clone Buddy's tree for Snoopy
		BehaviorTree<Dog> snoopyTree = (BehaviorTree<Dog>)buddyTree.cloneTask();
		snoopyTree.setObject(new Dog("Snoopy"));

		// Create split pane
		BehaviorTreeViewer<?> buddyTreeViewer = createTreeViewer(buddyTree.getObject().name, buddyTree, false, skin);
		BehaviorTreeViewer<?> snoopyTreeViewer = createTreeViewer(snoopyTree.getObject().name, snoopyTree, false, skin);
		return new SplitPane(new ScrollPane(buddyTreeViewer, skin), new ScrollPane(snoopyTreeViewer, skin), true, skin,
			"default-horizontal");
	} finally {
		StreamUtils.closeQuietly(reader);
	}
}
 
Example 5
Source Project: talos   Source File: DynamicFloatRangeInputWidget.java    License: Apache License 2.0 6 votes vote down vote up
public DynamicFloatRangeInputWidget(Skin skin) {
   setSkin(skin);

    Table container = new Table();

    highInput = new FloatRangeInputWidget("HMin", "HMax", getSkin());
    lowInput = new FloatRangeInputWidget("LMin", "LMax", getSkin());

    lowInput.setValue(0, 0);
    highInput.setValue(1, 1);

    container.add(highInput).row();
    container.add().height(3).row();
    container.add(lowInput);

    add(container).left().expandX();

    curveWidget = new CurveWidget(getSkin());
    add(curveWidget).left().growY().width(100).padTop(23).padRight(3).padLeft(4).padBottom(3);
}
 
Example 6
Source Project: bladecoder-adventure-engine   Source File: Message.java    License: Apache License 2.0 6 votes vote down vote up
public static void init(Skin skin) {
	msg = new Label("", skin, "message") {

		@Override
		public Actor hit(float x, float y, boolean touchable) {
			if (isModal)
				return this;

			return null;
		}
	};

	Message.skin = skin;
	msg.setWrap(true);
	msg.setAlignment(Align.center, Align.center);
}
 
Example 7
Source Project: gdx-gltf   Source File: Vector4UI.java    License: Apache License 2.0 6 votes vote down vote up
public Vector4UI(Skin skin, final Color value) {
	super(skin);
	this.value = value;
	for(int i=0 ; i<4 ; i++){
		final Slider slider = new Slider(0, 1, .01f, false, skin);
		add(name(i));
		add(slider).row();
		slider.setValue(get(i));
		final int index = i;
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				set(index, slider.getValue());
			}
		});
		sliders.add(slider);
	}
}
 
Example 8
Source Project: gdx-gltf   Source File: Vector3UI.java    License: Apache License 2.0 6 votes vote down vote up
public Vector3UI(Skin skin, final Vector3 value) {
	super(skin);
	this.value = value;
	for(int i=0 ; i<3 ; i++){
		final Slider slider = new Slider(-1, 1, .01f, false, skin);
		add(name(i));
		add(slider).row();
		slider.setValue(get(i));
		final int index = i;
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				set(index, slider.getValue());
			}
		});
		sliders.add(slider);
	}
}
 
Example 9
EnumOptionsInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue, Enum<?>[] options) {
	input = new SelectBox<>(skin);

	int l = options.length;
	if(!mandatory) l++;
	Enum<?>[] values = new Enum[l];

	if(!mandatory) {
		values[0] = Empty.EMPTY;
	}

	System.arraycopy(options, 0, values, mandatory ? 0 : 1, options.length);

	input.setItems(values);

	init(skin, title, desc, input, mandatory, defaultValue);
}
 
Example 10
public CreateAndroidKeystoreDialog(Skin skin) {
	super("CREATE KEY STORE FOR ANDROID", skin);

	keyStoreFile = new FileInputPanel(skin, "Select the key store", "Select the key store file name and location",
			FileInputPanel.DialogType.SAVE_FILE);

	androidKeyAlias = InputPanelFactory.createInputPanel(skin, "KeyAlias", "Select the Key ID/Alias", true);

	androidKeyStorePassword = InputPanelFactory.createInputPanel(skin, "KeyStorePasswd", "Key Store Password",
			true);
	androidKeyAliasPassword = InputPanelFactory.createInputPanel(skin, "KeyAliasPasswd", "Key Alias Password",
			true);

	addInputPanel(keyStoreFile);
	addInputPanel(androidKeyAlias);
	addInputPanel(androidKeyStorePassword);
	addInputPanel(androidKeyAliasPassword);

	setInfo(INFO);
}
 
Example 11
Source Project: gdx-skineditor   Source File: MainScreen.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
public void refreshResources() {
	
	TexturePacker.Settings settings = new TexturePacker.Settings();
	settings.combineSubdirectories = true;
	settings.maxWidth = 2048;
	settings.maxHeight = 2048;
	TexturePacker.process(settings, "projects/" + currentProject +"/assets/", "projects/" + currentProject, "uiskin");
	

	// Load project skin
	if (game.skinProject != null) {
		game.skinProject.dispose();
	}
	
	game.skinProject = new Skin();
	game.skinProject.addRegions(new TextureAtlas(Gdx.files.local("projects/" + currentProject +"/uiskin.atlas")));
	game.skinProject.load(Gdx.files.local("projects/" + currentProject +"/uiskin.json"));

	
}
 
Example 12
Source Project: skin-composer   Source File: GraphicWidget.java    License: MIT License 6 votes vote down vote up
public GraphicWidget(Skin skin) {
    super(skin);
    
    mode = Mode.START;
    
    setTouchable(Touchable.disabled);
    
    SkeletonJson skeletonJson = new SkeletonJson(new TextureAtlas(Gdx.files.internal("ui/skin-composer-installer-ui.atlas")));
    SkeletonRenderer skeletonRenderer = new SkeletonRenderer();
    skeletonRenderer.setPremultipliedAlpha(false);
    
    SpineDrawableTemplate template = new SpineDrawableTemplate();
    template.internalPath = Gdx.files.internal("ui/progress-bar.json");
    template.widthBones = new Array<>(new String[] {"resizer"});
    template.heightBones = new Array<>(new String[] {"resizer"});
    
    spineDrawable = new SpineDrawable(skeletonJson, skeletonRenderer, template);
    spineDrawable.getAnimationState().getData().setDefaultMix(0);
}
 
Example 13
Source Project: skin-composer   Source File: InfoTable.java    License: MIT License 6 votes vote down vote up
public InfoTable(final Skin skin, final Stage stage) {
    pad(10.0f);
    
    var label = new Label(Core.readAndReplace("about.txt"), skin, "small");
    label.setWrap(true);
    label.setTouchable(Touchable.disabled);
    add(label).growX().expandY().top();
    
    row();
    var textButton = new TextButton("OK", skin);
    add(textButton).growX().height(30.0f);
    textButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Core.transition(InfoTable.this, new MenuTable(skin, stage));
        }
    });
}
 
Example 14
Source Project: gdx-pd   Source File: GdxPdTests.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void create () 
{
	PdConfiguration config = new PdConfiguration();
	config.inputChannels = 1;
	Pd.audio.create(config);

	// new ScreenViewport()
	stage = new Stage(new FitViewport(800, 600));
	
	skin = new Skin(Gdx.files.internal("skins/uiskin.json"));
	
	Table root = new Table();
	root.defaults().pad(10);
	
	
	Gdx.input.setInputProcessor(stage);
}
 
Example 15
Source Project: gdx-ai   Source File: ParallelVsSequenceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Actor createActor (final Skin skin) {
	Table table = new Table();

	LabelStyle labelStyle = new LabelStyle(skin.get(LabelStyle.class));
	labelStyle.background = skin.newDrawable("white", .6f, .6f, .6f, 1);
	String branchChildren = "\n    selectTarget\n    pursue";
	table.add(new Label("parallel policy:\"sequence\" orchestrator:\"resume\"" + branchChildren, labelStyle)).pad(5);
	table.add(new Label("vs", skin)).padLeft(10).padRight(10);
	table.add(new Label("sequence" + branchChildren, labelStyle)).pad(5);

	table.row().padTop(15);

	TextButton startButton = new TextButton("Start", skin);
	startButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			oldScreen = container.getScreen();
			container.setScreen(new TestScreen(ParallelVsSequenceTest.this, skin));
		}
	});
	table.add();
	table.add(startButton);
	table.add();
	return table;
}
 
Example 16
@Override
public void create () {
    manager = new AssetManager();
    manager.load("skin.json", Skin.class);
    manager.load("skin.atlas", TextureAtlas.class);
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
}
 
Example 17
Source Project: gdx-ai   Source File: ProgrammaticallyCreatedTreeTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Actor createActor (Skin skin) {
	BehaviorTreeLibraryManager libraryManager = BehaviorTreeLibraryManager.getInstance();
	BehaviorTreeLibrary library = new BehaviorTreeLibrary(BehaviorTreeParser.DEBUG_HIGH);
	registerDogBehavior(library);
	libraryManager.setLibrary(library);
	BehaviorTree<Dog> tree = libraryManager.createBehaviorTree("dog", new Dog("Buddy"));
	BehaviorTreeViewer<?> treeViewer = createTreeViewer(tree.getObject().name, tree, true, skin);

	return new ScrollPane(treeViewer, skin);
}
 
Example 18
Vector2InputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue) {
	dimPanel = new Table(skin);
	x = new TextField("", skin);
	y = new TextField("", skin);

	dimPanel.add(new Label(" x ", skin));
	dimPanel.add(x);
	dimPanel.add(new Label("  y ", skin));
	dimPanel.add(y);

	init(skin, title, desc, dimPanel, mandatory, defaultValue);
}
 
Example 19
Source Project: bladecoder-adventure-engine   Source File: TextManagerUI.java    License: Apache License 2.0 5 votes vote down vote up
public TextManagerUI(Skin skin, World w) {
	this.world = w;
	setTouchable(Touchable.disabled);
	styles = skin.getAll(TextManagerUIStyle.class);

	for (TextManagerUIStyle style : styles.values()) {
		style.font.getData().markupEnabled = true;
	}

	setVisible(false);
}
 
Example 20
Source Project: gdx-texture-packer-gui   Source File: PageGroup.java    License: Apache License 2.0 5 votes vote down vote up
public PageGroup(Skin skin, PageModel page) {
    this.page = page;
    setTransform(false);

    borderFrame = new NinePatchDrawable(skin.getPatch("custom/white_frame")).tint(Color.BLACK);

    setSize(page.getWidth(), page.getHeight());
    setTouchable(Touchable.disabled);

    addActor(new RegionSpotlight(skin));
}
 
Example 21
Source Project: GdxDemo3D   Source File: GameStage.java    License: Apache License 2.0 5 votes vote down vote up
public MouseNavMeshCoordTable(Skin skin) {
	align(Align.topLeft); // Fix flickering due to the variable width of rows

	// Create label X
	FloatValueLabel mouseLabelX = new FloatValueLabel("x: ", 0, skin) {
		@Override
		public float getValue() {
			return worldInputProcessor.mouseNavMeshPos.x;
		}
	};
	// Create label Y
	FloatValueLabel mouseLabelY = new FloatValueLabel("y: ", 0, skin) {
		@Override
		public float getValue() {
			return worldInputProcessor.mouseNavMeshPos.y;
		}
	};
	// Create label Z
	FloatValueLabel mouseLabelZ = new FloatValueLabel("z: ", 0, skin) {
		@Override
		public float getValue() {
			return worldInputProcessor.mouseNavMeshPos.z;
		}
	};
	// This should be floating
	add(mouseLabelX).left();
	row();
	add(mouseLabelY).left();
	row();
	add(mouseLabelZ).left();
}
 
Example 22
Source Project: talos   Source File: NoiseImage.java    License: Apache License 2.0 5 votes vote down vote up
public NoiseImage(Skin skin) {
    this.skin = skin;
    white = new Texture(Gdx.files.internal("white.png")); //TODO: not cool
    shaderProgram = new ShaderProgram(Gdx.files.internal("shaders/ui/default.vert"), Gdx.files.internal("shaders/ui/noise.frag"));

    pixmap = new Pixmap(165, 100, Pixmap.Format.RGB888);
}
 
Example 23
Source Project: gdx-soundboard   Source File: NewFileDialog.java    License: MIT License 5 votes vote down vote up
public NewFileDialog(String title, Skin skin) {
    super(title, skin);
    
    Table content = this.getContentTable();
    
    fileName = new TextField("", skin);
    content.add(fileName).fillX().expandX();
    
    button("Create", true);
    button("Cancel", false);
    
    key(Keys.ENTER, true);
    key(Keys.ESCAPE, false);
}
 
Example 24
Source Project: gdx-texture-packer-gui   Source File: NoPageHint.java    License: Apache License 2.0 5 votes vote down vote up
public NoPageHint(Skin skin) {
    String text = App.inst().getI18n().get("atlasPreviewNoPageMsg");

    Label lblMessage = new Label(text, new Label.LabelStyle(skin.getFont("default-font"), Color.WHITE));
    lblMessage.setAlignment(Align.center);
    lblMessage.getColor().a = 0.25f;
    setActor(lblMessage);

    setFillParent(true);
    align(Align.center);
    setTouchable(Touchable.disabled);
    setBackground(skin.getDrawable("noPreviewFill"));
}
 
Example 25
Source Project: vis-ui   Source File: TestTree.java    License: Apache License 2.0 5 votes vote down vote up
private void addNormalWidgets () {
	Skin skin = VisUI.getSkin();

	Tree tree = new Tree(skin);
	TestNode item1 = new TestNode(new Label("item 1", skin));
	TestNode item2 = new TestNode(new Label("item 2", skin));
	TestNode item3 = new TestNode(new Label("item 3", skin));

	item1.add(new TestNode(new Label("item 1.1", skin)));
	item1.add(new TestNode(new Label("item 1.2", skin)));
	item1.add(new TestNode(new Label("item 1.3", skin)));

	item2.add(new TestNode(new Label("item 2.1", skin)));
	item2.add(new TestNode(new Label("item 2.2", skin)));
	item2.add(new TestNode(new Label("item 2.3", skin)));

	item3.add(new TestNode(new Label("item 3.1", skin)));
	item3.add(new TestNode(new Label("item 3.2", skin)));
	item3.add(new TestNode(new Label("item 3.3", skin)));

	item1.setExpanded(true);

	tree.add(item1);
	tree.add(item2);
	tree.add(item3);

	add(tree).expand().fill();
}
 
Example 26
Source Project: bladecoder-adventure-engine   Source File: DialogList.java    License: Apache License 2.0 5 votes vote down vote up
public DialogList(Skin skin) {
  	super(skin, true);
  	
  	options = new OptionList(skin);
  	row();
  	add(options).expand().fill();

list.addListener(new ChangeListener() {
	@Override
	public void changed(ChangeEvent event, Actor actor) {
		int pos = list.getSelectedIndex();
		
		addOptions();
		
		toolbar.disableEdit(pos == -1);
	}
});

list.setCellRenderer(listCellRenderer);
listCellRenderer.layout(list.getStyle());
container.minHeight(listCellRenderer.getItemHeight() * 5);
container.maxHeight(listCellRenderer.getItemHeight() * 5);

Ctx.project.addPropertyChangeListener(Project.NOTIFY_ELEMENT_CREATED, new PropertyChangeListener() {
	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		if (evt.getNewValue() instanceof Dialog && !(evt.getSource() instanceof EditDialogDialog) && parent instanceof CharacterActor) {
			addElements(parent, Arrays.asList(parent.getDialogs().values().toArray(new Dialog[0])));
		}
	}
});
  }
 
Example 27
Source Project: Cardshifter   Source File: ResourceView.java    License: Apache License 2.0 5 votes vote down vote up
public ResourceView(Skin skin, List<ResView> views) {
    this.actor = new HorizontalGroup();
    this.skin = skin;
    this.views = new ArrayList<ResView>(views);
    for (ResView view : views) {
        this.actor.addActor(view.getActor());
    }
}
 
Example 28
public InventoryButton(Skin skin, World w, InventoryUI inv) {
	super(getDefaultStyle(skin));
	this.inventory = inv;
	this.world = w;

	addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			if (!inventory.isVisible())
				inventory.show();
			else
				inventory.hide();
		}
	});
}
 
Example 29
public CreateProjectDialog(Skin skin) {
	super("CREATE PROJECT", skin);

	setInfo(INFO);

	projectName = InputPanelFactory.createInputPanel(skin, "Project Name", "Set the name of the project", true);

	pkg = InputPanelFactory.createInputPanel(skin, "Package",
			"The package will be used as package ID in Android and IOS. The launchers will be in this package too.",
			Param.Type.STRING, true, "com.myadv.game");

	spinePlugin = InputPanelFactory.createInputPanel(skin, "Spine animation support",
			"The game can use Spine animations, require Spine License to distribute the game. See http://www.esotericsoftware.com for more info.",
			Param.Type.BOOLEAN, true, "false");

	location = new FileInputPanel(skin, "Location", "Select the folder location for the project",
			FileInputPanel.DialogType.DIRECTORY);

	androidSdk = new FileInputPanel(skin, "Android SDK",
			"Select the Android SDK folder to create the Android package. If empty, the ANDROID_HOME variable will be used.",
			FileInputPanel.DialogType.DIRECTORY, false);

	addInputPanel(projectName);
	addInputPanel(pkg);
	addInputPanel(location);
	addInputPanel(spinePlugin);
	addInputPanel(androidSdk);

	String sdkprop = Ctx.project.getEditorConfig().getProperty(ANDROID_SDK_PROP);

	if (sdkprop != null && new File(sdkprop).exists()) {
		androidSdk.setText(sdkprop);
	}

	// getStage().setKeyboardFocus(projectName.getField());
}
 
Example 30
Source Project: libgdx-utils   Source File: InventoryScreen.java    License: MIT License 5 votes vote down vote up
@Override
public void show() {
	stage = new Stage();
	Gdx.input.setInputProcessor(stage);

	Skin skin = LibgdxUtils.assets.get("skins/uiskin.json", Skin.class);
	DragAndDrop dragAndDrop = new DragAndDrop();
	inventoryActor = new InventoryActor(new Inventory(), dragAndDrop, skin);
	stage.addActor(inventoryActor);
}