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

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

Introduction

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

Prototype

public void setItems(Array newItems) 

Source Link

Document

Sets the current items, clearing the selection if it is no longer valid.

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 w  w  w.  jav a 2s  .  c o m

    // 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:ateamproject.kezuino.com.github.render.screens.StoreScreen.java

public StoreScreen(Game game) {
    super(game);/*w  w  w  . j a v a 2  s .  c  om*/
    Sound sound = Assets.manager.get("sounds/menu.mp3", Sound.class);
    if (sound != null) {
        sound.loop();
    }

    TextButton btnBack = new TextButton("Terug", skin);
    btnBack.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (sound != null) {
                sound.dispose();
            }
            game.setScreen(new MainScreen(game));

        }
    });
    float x = 240;
    float y = stage.getHeight() / 4;
    btnBack.setSize(200, 40);
    btnBack.setPosition(x, y);

    Label lblStore = new Label("Winkel", skin);
    lblStore.setColor(Color.YELLOW);
    lblStore.setPosition(x, y + 300);

    List listStoreItems = new List(skin);
    String[] skinsArray = { "Skin pack", "Minecraft pack" };
    listStoreItems.setItems((Object) skinsArray);
    listStoreItems.setPosition(x, y + 200);

    TextButton btnBuy = new TextButton("Koop item", skin);
    btnBuy.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            // game.setScreen(new HomeScreen(game));
        }
    });
    btnBuy.setSize(200, 40);
    btnBuy.setPosition(x - 50, y + 50);

    TextButton btnSelect = new TextButton("Selecteer item", skin);
    btnSelect.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            // game.setScreen(new HomeScreen(game));
        }
    });
    btnSelect.setSize(200, 40);
    btnSelect.setPosition(x + 50, y + 50);

    stage.addActor(btnBack);
    stage.addActor(lblStore);
    stage.addActor(listStoreItems);

    backgroundMusic = Assets.getMusicStream("menu.mp3");
}

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();//from ww w  .  j a va2 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);
}

From source file:mobi.shad.s3lib.gui.GuiResource.java

License:Apache License

/**
 * @param listItem/*from  w ww .  ja  va  2  s .c  o  m*/
 * @param name
 * @return
 */
public static List<String> list(String[] listItem, String name) {
    if (S3Constans.INFO) {
        S3Log.log(TAG, "Create List: " + name);
    }
    if (listItem == null) {
        listItem = new String[] { "-= Select =-" };
    }
    List<String> list = new List<String>(S3Skin.skin.get(ListStyle.class));
    list.setItems(listItem);
    list.setName(name);
    return list;
}