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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.List. 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: DeckBuilderScreen.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
private Table scanSavedDecks(final CardshifterGame game, final List<String> savedDecks, String modName) {
    if (Gdx.files.isExternalStorageAvailable()) {
        Table saveTable = new Table();
        external = Gdx.files.external("Cardshifter/decks/" + modName + "/");
        external.mkdirs();

        if (!external.exists()) {
            Gdx.app.log("Files", external.path() + " does not exist.");
            return null;
        }

        updateSavedDeckList();

        saveTable.add(savedDecks).colspan(2).fill().row();
        return saveTable;
    }
    return null;
}
 
Example #2
Source File: MessageTests.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected CollapsableWindow addTestSelectionWindow (String title, List<String> testList, float x, float y) {
	CollapsableWindow window = new CollapsableWindow(title, skin);
	window.row();

	ScrollPane pane = new ScrollPane(testList, skin);
	pane.setFadeScrollBars(false);
	pane.setScrollX(0);
	pane.setScrollY(0);

	window.add(pane);
	window.pack();
	window.pack();
	if (window.getHeight() > stage.getHeight()) {
		window.setHeight(stage.getHeight());
	}
	window.setX(x < 0 ? stage.getWidth() - (window.getWidth() - (x + 1)) : x);
	window.setY(y < 0 ? stage.getHeight() - (window.getHeight() - (y + 1)) : y);
	window.layout();
	window.collapse();
	stage.addActor(window);

	return window;
}
 
Example #3
Source File: MessageTests.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
private List<String> createTestList () {
	// Create behavior names
	int numTests = tests.length;
	String[] testNames = new String[numTests];
	for (int i = 0; i < numTests; i++) {
		testNames[i] = tests[i].testName;
	}

	final List<String> testList = new List<String>(skin);
	testList.setItems(testNames);
	testList.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			if (!testSelectionWindow.isCollapsed() && getTapCount() == 2) {
				changeTest(testList.getSelectedIndex());
				testSelectionWindow.collapse();
			}
		}
	});
	return testList;
}
 
Example #4
Source File: PathFinderTests.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected CollapsableWindow addBehaviorSelectionWindow (String title, List<String> testList, float x, float y) {

		CollapsableWindow window = new CollapsableWindow(title, skin);
		window.row();

		ScrollPane pane = new ScrollPane(testList, skin);
		pane.setFadeScrollBars(false);
		pane.setScrollX(0);
		pane.setScrollY(0);

		window.add(pane);
		window.pack();
		window.pack();
		if (window.getHeight() > stage.getHeight()) {
			window.setHeight(stage.getHeight());
		}
		window.setX(x < 0 ? stage.getWidth() - (window.getWidth() - (x + 1)) : x);
		window.setY(y < 0 ? stage.getHeight() - (window.getHeight() - (y + 1)) : y);
		window.layout();
		window.collapse();
		stage.addActor(window);

		return window;
	}
 
Example #5
Source File: PathFinderTests.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
private List<String> createTestList () {
	// Create behavior names
	int numBehaviors = tests.length;
	String[] algorithmNames = new String[numBehaviors];
	for (int i = 0; i < numBehaviors; i++) {
		algorithmNames[i] = tests[i].testName;
	}

	final List<String> algorithmList = new List<String>(skin);
	algorithmList.setItems(algorithmNames);
	algorithmList.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			if (!algorithmSelectionWindow.isCollapsed() && getTapCount() == 2) {
				changeTest(algorithmList.getSelectedIndex());
				algorithmSelectionWindow.collapse();
			}
		}
	});
	return algorithmList;
}
 
Example #6
Source File: SteeringBehaviorsTest.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
private List<String> createTestList (final int engineIndex) {
	// Create test names
	int numTests = tests[engineIndex].length;
	String[] testNames = new String[numTests];
	for (int i = 0; i < numTests; i++) {
		testNames[i] = tests[engineIndex][i].testName;
	}

	final List<String> testList = new List<String>(skin);
	testList.setItems(testNames);
	testList.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			if (!testSelectionWindow.isCollapsed() && getTapCount() == 2) {
				changeTest(engineIndex, testList.getSelectedIndex());
				testSelectionWindow.collapse();
			}
		}
	});
	return testList;
}
 
Example #7
Source File: BehaviorTreeTests.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
private List<String> createTestList () {
	// Create behavior names
	int numTests = tests.length;
	String[] testNames = new String[numTests];
	for (int i = 0; i < numTests; i++) {
		testNames[i] = tests[i].getName();
	}

	final List<String> testList = new List<String>(skin);
	testList.setItems(testNames);
	testList.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			changeTest(testList.getSelectedIndex());
		}
	});
	return testList;
}
 
Example #8
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 #9
Source File: DeckBuilderScreen.java    From Cardshifter with Apache License 2.0 5 votes vote down vote up
private void updateSavedDeckList() {
    java.util.List<String> list = new ArrayList<String>();
    for (FileHandle handle : external.list()) {
        if (!handle.isDirectory()) {
            list.add(handle.nameWithoutExtension());
        }
    }
    savedDecks.setItems(list.toArray(new String[list.size()]));
}
 
Example #10
Source File: MessageTests.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void create () {
	Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

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

	stage = new Stage();
	stage.setDebugAll(DEBUG_STAGE);
	stageWidth = stage.getWidth();
	stageHeight = stage.getHeight();

	Gdx.input.setInputProcessor(stage);

	// Add translucent panel (it's only visible when AI is paused)
	final Image translucentPanel = new Image(skin, "translucent");
	translucentPanel.setSize(stageWidth, stageHeight);
	translucentPanel.setVisible(false);
	stage.addActor(translucentPanel);

	// Create test selection window
	List<String> testList = createTestList();
	testSelectionWindow = addTestSelectionWindow("Tests", testList, 0, -1);

	// Create status bar
	Table statusBar = new Table(skin);
	statusBar.left().bottom();
	statusBar.row().height(26);
	statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left();
	statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15);
	statusBar.add(testDescriptionLabel = new Label("", skin)).padLeft(15);
	stage.addActor(statusBar);

	// Set selected behavior
	changeTest(0);
}
 
Example #11
Source File: PathFinderTests.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void create () {
	Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

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

	// Enable color markup
	BitmapFont font = skin.get("default-font", BitmapFont.class);
	font.getData().markupEnabled = true;

	stage = new Stage();
	stage.setDebugAll(DEBUG_STAGE);
	stageWidth = stage.getWidth();
	stageHeight = stage.getHeight();

	Gdx.input.setInputProcessor(new InputMultiplexer(stage));

	Stack stack = new Stack();
	stage.addActor(stack);
	stack.setSize(stageWidth, stageHeight);
	testsTable = new Table();
	stack.add(testsTable);

	// Create behavior selection window
	List<String> testList = createTestList();
	algorithmSelectionWindow = addBehaviorSelectionWindow("Path Finder Tests", testList, 0, -1);

	// Set selected test
	changeTest(0);

	stage.addActor(new FpsLabel("FPS: ", skin));
}
 
Example #12
Source File: SteeringBehaviorsTest.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
private CollapsableWindow addTestSelectionWindow (String title, String[] tabTitles, Array<List<String>> tabLists,
	float x, float y) {
	if (tabTitles.length != tabLists.size)
		throw new IllegalArgumentException("tabTitles and tabList must have the same size.");
	CollapsableWindow window = new CollapsableWindow(title, skin);
	window.row();
	TabbedPane tabbedPane = new TabbedPane(skin);
	for (int i = 0; i < tabLists.size; i++) {
		ScrollPane pane = new ScrollPane(tabLists.get(i), skin);
		pane.setFadeScrollBars(false);
		pane.setScrollX(0);
		pane.setScrollY(0);

		tabbedPane.addTab(" " + tabTitles[i] + " ", pane);
	}
	window.add(tabbedPane);
	window.pack();
	window.pack();
	if (window.getHeight() > stage.getHeight()) {
		window.setHeight(stage.getHeight());
	}
	window.setX(x < 0 ? stage.getWidth() - (window.getWidth() - (x + 1)) : x);
	window.setY(y < 0 ? stage.getHeight() - (window.getHeight() - (y + 1)) : y);
	window.layout();
	window.collapse();
	stage.addActor(window);

	return window;
}
 
Example #13
Source File: Scene2dUtils.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
/**
 * @param scrollPane widget will be scrolled
 * @param list must be child of scrollPane
 */
public static void scrollDownToSelectedListItem(ScrollPane scrollPane, List list) {
    if (list.getSelectedIndex() == -1) return;

    float y = list.getHeight() - (list.getSelectedIndex() * list.getItemHeight()) - list.getItemHeight();
    float height = list.getItemHeight();

    scrollPane.scrollTo(0, y, 0, height);
}
 
Example #14
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public static List<String> newListBox (String[] items, ChangeListener listener) {
	List<String> list = new List<String>(Art.scrSkin);
	if (listener != null) {
		list.addListener(listener);
	}

	list.setItems(items);
	return list;
}
 
Example #15
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public static List<String> newListBox (String[] items) {
	return newListBox(items, null);
}
 
Example #16
Source File: SteeringBehaviorsTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public void create () {
	Gdx.gl.glClearColor(.3f, .3f, .3f, 1);

	greenFish = new TextureRegion(new Texture("data/green_fish.png"));
	cloud = new TextureRegion(new Texture("data/particle-cloud.png"));
	badlogicSmall = new TextureRegion(new Texture("data/badlogicsmall.jpg"));
	target = new TextureRegion(new Texture("data/target.png"));

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

	stage = new Stage();
	stage.setDebugAll(DEBUG_STAGE);
	stageWidth = stage.getWidth();
	stageHeight = stage.getHeight();

	Gdx.input.setInputProcessor(new InputMultiplexer(stage));

	// Add translucent panel (it's only visible when AI is paused)
	final Image translucentPanel = new Image(skin, "translucent");
	translucentPanel.setSize(stageWidth, stageHeight);
	translucentPanel.setVisible(false);
	stage.addActor(translucentPanel);

	// Create test selection window
	Array<List<String>> engineTests = new Array<List<String>>();
	for (int k = 0; k < tests.length; k++) {
		engineTests.add(createTestList(k));
	}
	testSelectionWindow = addTestSelectionWindow("Behaviors", ENGINES, engineTests, 0, -1);

	// Create status bar
	Table statusBar = new Table(skin);
	statusBar.left().bottom();
	statusBar.row().height(26);
	statusBar.add(pauseButton = new PauseButton(translucentPanel, skin)).width(90).left();
	statusBar.add(new FpsLabel("FPS: ", skin)).padLeft(15);
	statusBar.add(testHelpLabel = new Label("", skin)).padLeft(15);
	stage.addActor(statusBar);

	// Set selected behavior
	changeTest(0, 0);
}
 
Example #17
Source File: TrackListPanel.java    From gdx-soundboard with MIT License 4 votes vote down vote up
private void enableDisable(List<Track> trackList, Button add, Button remove){
    add.setDisabled(state == null);
    remove.setDisabled(trackList.getSelected() == null || trackList.getItems().size == 0);
}
 
Example #18
Source File: TrackListPanel.java    From gdx-soundboard with MIT License 4 votes vote down vote up
private void updateTrackList(List<Track> trackList, final MusicState state) {
    trackList.getItems().clear();
    trackList.setItems(state.getTracks());
    trackList.getItems().sort(comparator);
}
 
Example #19
Source File: FilteredSelectBox.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
/** Returns the list shown when the select box is open. */
public List<T> getList() {
	return selectBoxList.list;
}
 
Example #20
Source File: EditableSelectBox.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public List<T> getList() {
	return list;
}