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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Skin. 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: GdxPdTests.java    From gdx-pd with 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 #2
Source File: DynamicFloatRangeInputWidget.java    From talos with 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 #3
Source File: Message.java    From bladecoder-adventure-engine with 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 #4
Source File: ParallelVsSequenceTest.java    From gdx-ai with 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 #5
Source File: EnumOptionsInputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: GraphicWidget.java    From skin-composer with 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 #7
Source File: MainScreen.java    From gdx-skineditor with 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 #8
Source File: InfoTable.java    From skin-composer with 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 #9
Source File: Vector4UI.java    From gdx-gltf with 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 #10
Source File: Vector3UI.java    From gdx-gltf with 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 #11
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 #12
Source File: CreateAndroidKeystoreDialog.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
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 #13
Source File: DeckCardView.java    From Cardshifter with 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 #14
Source File: FileChooser.java    From gdx-soundboard with 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 #15
Source File: SemaphoreGuardTest.java    From gdx-ai with 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 #16
Source File: InventoryScreen.java    From libgdx-utils with 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);
}
 
Example #17
Source File: NewFileDialog.java    From gdx-soundboard with 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 #18
Source File: Scene2dUtils.java    From gdx-soundboard with MIT License 5 votes vote down vote up
public static TextField addTextField(String labelText, Table parent, Skin skin){
    Label label = new Label(labelText, skin);
    label.setAlignment(Align.left);
    parent.add(label).left();

    TextField info = new TextField("", skin);
    parent.add(info).right().fillX().expandX().row();

    return info;
}
 
Example #19
Source File: GameStage.java    From GdxDemo3D with 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 #20
Source File: BehaviorTreeTests.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
public MainScreen() {
	Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

	skin = new Skin(Gdx.files.internal("data/uiskin.json"));

	stage = new Stage(new ScreenViewport());
	stage.setDebugAll(DEBUG_STAGE);

	// Create split pane
	List<String> testList = createTestList();
	ScrollPane leftScrollPane = new ScrollPane(testList, skin);
	splitPane = new SplitPane(leftScrollPane, null, false, skin, "default-horizontal");
	splitPane.setSplitAmount(Math.min((testList.getPrefWidth() + 10) / stage.getWidth(), splitPane.getSplitAmount()));

	// Create layout
	Table t = new Table(skin);
	t.setFillParent(true);
	t.add(splitPane).colspan(3).grow();
	t.row();
	t.add(pauseButton = new PauseButton(skin)).width(90).left();
	t.add(new FpsLabel("FPS: ", skin)).left();
	t.add(testDescriptionLabel = new Label("", skin)).left();
	stage.addActor(t);

	// Set selected test
	changeTest(0);
}
 
Example #21
Source File: PageGroup.java    From gdx-texture-packer-gui with 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 #22
Source File: TextManagerUI.java    From bladecoder-adventure-engine with 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 #23
Source File: Vector2InputPanel.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
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 #24
Source File: ProgrammaticallyCreatedTreeTest.java    From gdx-ai with 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 #25
Source File: NoPageHint.java    From gdx-texture-packer-gui with 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 #26
Source File: CardDeckApplication.java    From androidsvgdrawable-plugin with Apache License 2.0 5 votes vote down vote up
@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 #27
Source File: InventoryButton.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: ResourceView.java    From Cardshifter with 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 #29
Source File: DialogList.java    From bladecoder-adventure-engine with 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 #30
Source File: TestTree.java    From vis-ui with 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();
}