Example usage for com.badlogic.gdx.scenes.scene2d.ui List getSelected

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui List getSelected

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui List getSelected.

Prototype

public T getSelected() 

Source Link

Document

Returns the first selected item, or null.

Usage

From source file:at.hid.tabletopsimulator.screens.About.java

License:Apache License

@Override
public void show() {
    TableTopSimulator.debug(this.getClass().toString(), "creating About screen");
    stage = new Stage(new ExtendViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));

    Gdx.input.setInputProcessor(stage);/*from www  .  jav a  2  s . c om*/

    // creating skin
    TableTopSimulator.debug(this.getClass().toString(), "creating skin");
    skin = TableTopSimulator.assets.get("ui/gui.json", Skin.class);

    table = new Table(skin);
    //      table.setFillParent(true);
    //      table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    // creating heading
    TableTopSimulator.debug(this.getClass().toString(), "creating heading");
    Label lblHeading = new Label(TableTopSimulator.getLangBundle().format("About.lblHeading.text"), skin);

    final Label lblContent = new Label("http://libgdx.badlogicgames.com/\r\n" + "\r\n"
            + "libGDX is licensed under the Apache 2 License,\r\n"
            + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n"
            + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!", skin,
            "content");

    // creating list

    final List<String> listAbout = new List<String>(skin, "content");
    ArrayList<String> newItems = new ArrayList<String>();
    newItems.add("libgdx");
    newItems.add("libgdx-utils");
    newItems.add("flare gameart");
    String[] data = new String[newItems.size()];
    listAbout.setItems(newItems.toArray(data));
    listAbout.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (listAbout.getSelected().equals("libgdx")) {
                lblContent.clear();
                lblContent.setText("http://libgdx.badlogicgames.com/\r\n" + "\r\n"
                        + "libGDX is licensed under the Apache 2 License,\r\n"
                        + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n"
                        + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!");
            } else if (listAbout.getSelected().equals("libgdx-utils")) {
                lblContent.clear();
                lblContent.setText("https://bitbucket.org/dermetfan/libgdx-utils/wiki/Home\r\n" + "\r\n"
                        + "/* Copyright (c) 2014 PixelScientists\r\n" + "*\r\n" + "* The MIT License (MIT)\r\n"
                        + "*\r\n"
                        + "* Permission is hereby granted, free of charge, to any person obtaining a copy of\r\n"
                        + "* this software and associated documentation files (the \"Software\"), to deal in\r\n"
                        + "* the Software without restriction, including without limitation the rights to\r\n"
                        + "* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r\n"
                        + "* the Software, and to permit persons to whom the Software is furnished to do so,\r\n"
                        + "* subject to the following conditions:\r\n" + "*\r\n"
                        + "* The above copyright notice and this permission notice shall be included in all\r\n"
                        + "* copies or substantial portions of the Software.\r\n" + "*\r\n"
                        + "* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n"
                        + "* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r\n"
                        + "* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r\n"
                        + "* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r\n"
                        + "* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n"
                        + "* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n"
                        + "*/");
            } else if (listAbout.getSelected().equals("flare gameart")) {
                lblContent.clear();
                lblContent.setText("https://github.com/clintbellanger/flare-game\r\n" + "\r\n"
                        + "Flare (the game) is Copyright 2010-2013 Clint Bellanger. Contributors retain copyrights to their original contributions.\r\n"
                        + "\r\n" + "The Flare Engine is released under GPL version 3 or later.\r\n" + "\r\n"
                        + "All of Flare's art and data files are released under CC-BY-SA 3.0. Later versions are permitted.\r\n"
                        + "\r\n"
                        + "The Liberation Sans fonts version 2 are released under the SIL Open Font License, Version 1.1.\r\n"
                        + "\r\n"
                        + "The GNU Unifont font is released under GPL v2, with the exception that embedding the font in a document does not in itself bind that document to the terms of the GPL.");
            }
        }
    });

    // creating buttons
    TableTopSimulator.debug(this.getClass().toString(), "creating buttons");
    TextButton btnBack = new TextButton(TableTopSimulator.getLangBundle().format("About.btnBack.text"), skin);
    btnBack.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            TableTopSimulator.debug(this.getClass().toString(), "switching to Options screen");
            ((Game) Gdx.app.getApplicationListener()).setScreen(new Options());
            dispose();
        }
    });
    btnBack.pad(10);

    ScrollPane spAboutList = new ScrollPane(null, skin);
    ScrollPane spAboutContent = new ScrollPane(null, skin);

    SplitPane splitAbout = new SplitPane(spAboutList, spAboutContent, false, skin);
    splitAbout.setSplitAmount(0.2f);

    spAboutList.setWidget(listAbout);
    spAboutContent.setWidget(lblContent);

    // building ui
    TableTopSimulator.debug(this.getClass().toString(), "building ui");
    table.add(lblHeading).spaceBottom(100).row();
    table.add(splitAbout).spaceBottom(15).width(1200).row();
    table.add(btnBack).spaceBottom(15).row();
    if (TableTopSimulator.DEBUG) {
        table.debug(); // draw debug lines 
        splitAbout.debug(); // draw debug lines 
    }
    stage.addActor(table);
}

From source file:free.hacknet.game.tests.ListTestsScreen.java

License:Open Source License

public ListTestsScreen() {

    FreeTypeFontLoaderParameter size1Params = new FreeTypeFontLoaderParameter();
    size1Params.fontFileName = Assets.FontPath;
    size1Params.fontParameters.size = 30;
    size1Params.fontParameters.magFilter = TextureFilter.Linear;
    size1Params.fontParameters.minFilter = TextureFilter.Linear;
    Assets.manager.load("size10.ttf", BitmapFont.class, size1Params);
    Assets.manager.finishLoading();//w  ww  . j a va 2 s  .  c o m
    Assets.manager.load(Assets.uiskin, Skin.class);
    Assets.manager.finishLoading();
    skin = new Skin();
    skin.addRegions(new TextureAtlas(Gdx.files.internal("data/uiskin.atlas")));
    skin.add("default-font", Assets.manager.get("size10.ttf", BitmapFont.class), BitmapFont.class);
    skin.load(Gdx.files.internal("data/uiskin.json"));
    stage = new Stage(new ScreenViewport());
    table = new Table();
    Label label = new Label("lol", skin);
    table.add(label).row();
    TextButton button = new TextButton("start test", skin);
    table.setFillParent(true);
    Gdx.input.setInputProcessor(stage);
    final List list = new List(skin);
    table.add(list).expandX().fill().padLeft(20).padRight(20);
    table.add(button).width(100).height(50).row();
    Array<String> items = new Array<String>();
    items.add(test1);
    items.add(test2);
    button.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Gdx.app.log("ListTestsScreen", "button clicked");
            Gdx.app.log("ListTestsScreen", list.getSelected().toString());
        }

    });
    list.setItems(items);
    stage.addActor(table);
    stage.setDebugAll(true);
}