Example usage for com.badlogic.gdx.scenes.scene2d.ui Skin Skin

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

Introduction

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

Prototype

public Skin(FileHandle skinFile, TextureAtlas atlas) 

Source Link

Document

Creates a skin containing the resources in the specified skin JSON file and the texture regions from the specified atlas.

Usage

From source file:com.amerticum.chosenchess.Assets.java

License:Apache License

/**
 * Loads all assets required by {@link MainMenu}.
 *///from ww  w . j a va2s .c  o  m
public static void loadGame() {
    splashMusic = Gdx.audio.newMusic(Gdx.files.internal("music/fortress.ogg"));
    gameAtlas = new TextureAtlas(Gdx.files.internal("atlases/ChoSenChess.pack"));
    skin = new Skin(Gdx.files.internal("skin.json"), gameAtlas);
}

From source file:com.android.ringfly.common.Assets.java

License:Apache License

public static void load() {
    pixelDensity = calculatePixelDensity();
    String textureDir = "data/textures/" + (int) pixelDensity;
    loadTextures(textureDir);/*from  ww  w  .j  a  v a2 s  . co m*/
    createAnimations();
    loadFonts();
    loadSounds();
    uiSkin = new Skin(Gdx.files.internal("data/skin/uiskin.json"), Gdx.files.internal("data/skin/uiskin.png"));
    gradeUpSkin = new Skin(Gdx.files.internal("data/skin/gradeupskin.json"),
            Gdx.files.internal("data/skin/gradeupskin.png"));
    uiSkin.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    gradeUpSkin.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
}

From source file:com.bsencan.openchess.Assets.java

License:Apache License

public static void loadMainMenu() {
    gameAtlas = new TextureAtlas(Gdx.files.internal("atlases/open-chess-image.pack"));
    skin = new Skin(Gdx.files.internal("skin-labels.json"), gameAtlas);
    menuMusic = Gdx.audio.newMusic(Gdx.files.internal("music/fortress.ogg"));
}

From source file:com.bsencan.openchess.Assets.java

License:Apache License

/**
 * Loads all assets required by {@link GameScreen}.
 *///from  w w  w  .j  ava 2  s.  c  o m
public static void loadGame() {
    gameAtlas = new TextureAtlas(Gdx.files.internal("atlases/open-chess-image.pack"));
    skin = new Skin(Gdx.files.internal("skin-all.json"), gameAtlas);
}

From source file:com.digitale.mygdxgame.Renderer.java

License:Open Source License

public Renderer(Application app) {
    width = Gdx.graphics.getWidth();//from  w w w . j a va2s . c  om
    height = Gdx.graphics.getHeight();
    Gdx.input.setInputProcessor(null);
    spriteBatch = new SpriteBatch();
    try {
        // bindMeshes();
        try {
            bindTextures();
        } catch (GdxRuntimeException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        explosionMesh = new Mesh(true, 4 * 16, 0, new VertexAttribute(Usage.Position, 3, "a_position"),
                new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord"));
        // explosion mesh

        float[] vertices = new float[4 * 16 * (3 + 2)];
        int idx = 0;
        for (int row = 0; row < 4; row++) {
            for (int column = 0; column < 4; column++) {
                vertices[idx++] = 1;
                vertices[idx++] = 1;
                vertices[idx++] = 0;
                vertices[idx++] = 0.25f + column * 0.25f;
                vertices[idx++] = 0 + row * 0.25f;

                vertices[idx++] = -1;
                vertices[idx++] = 1;
                vertices[idx++] = 0;
                vertices[idx++] = 0 + column * 0.25f;
                vertices[idx++] = 0 + row * 0.25f;

                vertices[idx++] = -1;
                vertices[idx++] = -1;
                vertices[idx++] = 0;
                vertices[idx++] = 0f + column * 0.25f;
                vertices[idx++] = 0.25f + row * 0.25f;

                vertices[idx++] = 1;
                vertices[idx++] = -1;
                vertices[idx++] = 0;
                vertices[idx++] = 0.25f + column * 0.25f;
                vertices[idx++] = 0.25f + row * 0.25f;
            }
        }

        explosionMesh.setVertices(vertices);
        Stardust3d.manager.get("data/default.fnt", BitmapFont.class);
        fontsmall = Stardust3d.manager.get("data/small.fnt", BitmapFont.class);
        minichatFontCache = new BitmapFontCache(fontsmall);
        statusFontCache = new BitmapFontCache(fontsmall);

        fonttiny = Stardust3d.manager.get("data/smallest.fnt", BitmapFont.class);
        fontnormal = Stardust3d.manager.get("data/default.fnt", BitmapFont.class);
        // camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(),
        // Gdx.graphics.getHeight());
        camera = new PerspectiveCamera(67, 800, 480);
        skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
        stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
        Gdx.input.setInputProcessor(stage);
        new TextButton("Quick Help", skin.getStyle(TextButtonStyle.class), "buttonHelp");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.digitale.mygdxgame.SplashRenderer.java

License:Open Source License

public SplashRenderer(Application app) {

    font = new BitmapFont(Gdx.files.internal("data/default.fnt"), false);
    try {/*w  w w.j  a v  a2 s  .  co m*/
        spriteBatch = new SpriteBatch();
        skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
        stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
        InputStream in = Gdx.files.internal("data/ship02.obj").read();
        shipMesh = ObjLoader.loadObj(in, true);
        in.close();
        in = Gdx.files.internal("data/jet.obj").read();
        jetMesh = ObjLoader.loadObj(in, true);
        in.close();
        in = Gdx.files.internal("data/sun.obj").read();
        sunMesh = ObjLoader.loadObj(in, true);
        in.close();

        in = Gdx.files.internal("data/planet.obj").read();
        planetMesh = ObjLoader.loadObj(in, true);
        in.close();

        in = Gdx.files.internal("data/planet02.obj").read();
        planetMesh02 = ObjLoader.loadObj(in, true);
        in.close();

        in = Gdx.files.internal("data/shot.obj").read();
        ObjLoader.loadObj(in, false);
        in.close();
        //note use of tru to flip texture V co-ords for max OBJ files
        in = Gdx.files.internal("data/sky.obj").read();
        skyMesh = ObjLoader.loadObj(in, true);
        in.close();
        progressBarTexture = new Texture(Gdx.files.internal("data/progbar.png"), Format.RGB565, true);
        progressBarTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.digitale.screens.CharCreator.java

License:Open Source License

public CharCreator(final Integer muser) {
    Stardust3d.currencharacteruid = "" + Stardust3d.charList[0].getUid();
    // populate avatardropdown
    for (int i = 0; i < Stardust3d.avatarList.size(); i++) {
        listEntries[i] = Stardust3d.avatarList.get(i).getDescription();
        // do avatar dropdown population from db here
    }//from  www . j a  v a  2 s. co  m
    selectedAvatar = ("avatar00.jpg");
    OrthographicCamera camera;
    batch = new SpriteBatch();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true);
    xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    background = new Texture(Gdx.files.internal("data/bgpland.jpg"));
    camera = new OrthographicCamera();
    camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight());

    fadeIn();
    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;

    final Button buttonSaveCharacter = new TextButton("Save Character", skin.getStyle(TextButtonStyle.class),
            "button-save-char");
    final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "button-cancel");
    final Button buttonRandName = new TextButton("Generate Random Name", skin.getStyle(TextButtonStyle.class),
            "button-random-name");
    final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo");
    final SelectBox dropdownsex = new SelectBox(listsexEntries, skin.getStyle(SelectBoxStyle.class),
            "combosex");
    final SelectBox dropdownrace = new SelectBox(listraceEntries, skin.getStyle(SelectBoxStyle.class),
            "comborace");
    final TextField textfieldFirstName = new TextField("", "Firstname", skin.getStyle(TextFieldStyle.class),
            "textfieldfirstname");
    final TextField textfieldSurName = new TextField("", "Surname", skin.getStyle(TextFieldStyle.class),
            "textfieldsurname");
    final Label lableracepicker = new Label("Race", skin.getStyle(LabelStyle.class), "label-race-picker");
    final Label lablesexpicker = new Label("Sex", skin.getStyle(LabelStyle.class), "label-sex-picker");
    final Label lableportraitpicker = new Label("Portrait", skin.getStyle(LabelStyle.class),
            "label-portrait-picker");
    final Label lablefirstname = new Label("First name", skin.getStyle(LabelStyle.class), "label-firstname");
    final Label lablesurname = new Label("Surname", skin.getStyle(LabelStyle.class), "label-surname");

    imageActor = new Image(image0);

    final FlickScrollPane scrollPane = new FlickScrollPane(imageActor, "flickscroll");
    final List list = new List(listEntries, skin.getStyle(ListStyle.class), "list");
    final ScrollPane scrollPane2 = new ScrollPane(list, skin.getStyle(ScrollPaneStyle.class), "scroll");
    scrollPane2.setWidget(list);
    final SplitPane splitPane = new SplitPane(scrollPane, scrollPane, false,
            skin.getStyle("default-horizontal", SplitPaneStyle.class), "split");

    final Label lablerace = new Label(racetext, skin.getStyle(LabelStyle.class), "label-race");
    lablerace.setWrap(true);
    final ScrollPane scrollPanerace = new ScrollPane(lablerace, skin.getStyle(ScrollPaneStyle.class), "scroll");
    // set defaults
    selectedAvatar = (Stardust3d.avatarList.get(0).getImagename());

    racetext = "Humans small size compared to other races, nimble hands and excellent sight allows them to handle thier ships with more finesse than other races.";
    racetext = racetext + "\n\n Racial Bonus:- +1 to dexterity.";
    racetext = racetext + "\n Skilled with Human ships and weaponry.";
    PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 1 + "\nDexterity " + 2
            + "\nLeadership " + 1 + "\nRecuperation " + 1 + "";
    final Label PrimaryStatLabel = new Label(PrimaryStat + Stardust3d.myCharacter.getIntelligence(),
            skin.getStyle(LabelStyle.class), "primary-stat");
    Window window = new Window("Create Character", skin.getStyle(WindowStyle.class), "window");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.setFillParent(true);
    window.setMovable(false);
    window.defaults().pad(5);
    window.defaults().spaceBottom(5).align("top");
    window.row().fill().expandX();
    window.add(buttonCancel).colspan(2);
    window.add().colspan(2).maxWidth(200);
    window.add(buttonSaveCharacter).colspan(2);
    window.row();
    window.add(lableracepicker).align("middleleft");
    window.add(dropdownrace).colspan(1).maxHeight(32);
    window.add(lableportraitpicker).align("middleleft");
    window.add(dropdown).colspan(1).maxHeight(32);
    window.add(lablesexpicker).align("middleleft");
    window.add(dropdownsex).colspan(1).maxHeight(32);
    window.row();
    window.add(scrollPanerace).fill().expand().colspan(2).align("topleft");
    window.add(PrimaryStatLabel).colspan(2);
    window.add().minHeight(256).colspan(2);
    window.row();
    window.add(lablefirstname).align("middleleft");
    window.add(textfieldFirstName);
    window.add(lablesurname).align("middleleft");
    window.add(textfieldSurName);
    window.add(buttonRandName).colspan(2);

    window.pack();

    stage.addActor(window);

    dropdown.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            selectedAvatar = (Stardust3d.avatarList.get(index).getImagename());

        }
    });
    dropdownsex.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            selectedSex = value;

        }
    });
    dropdownrace.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            switch (index) {
            case 0:
                racetext = "Humans small size compared to other races, nimble hands and excellent sight allows them to handle thier ships with more finesse than other races.";
                racetext = racetext + "\n\n Racial Bonus:- +1 to dexterity.";
                racetext = racetext + "\n Skilled with Human ships and weaponry.";
                selectedRace = "Human";

                PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 1 + "\nDexterity " + 2
                        + "\nLeadership " + 1 + "\nRecuperation " + 1;
                break;
            case 1:
                racetext = "Jelkek are a war-like race, for generations they have subjugated the Orinians to further their technological advancement. Fearless and bloodthirsty tendencies make their combat pilots unequalled.";
                racetext = racetext + "\n\n Racial Bonus:- +1 to recuperation.";
                racetext = racetext + "\n Skilled with Jelkek ships and weaponry.";
                selectedRace = "Jelkek";
                PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 1 + "\nDexterity " + 1
                        + "\nLeadership " + 1 + "\nRecuperation " + 2;
                break;
            case 2:
                racetext = "Orinians are masters of biotechnology, their skills make them the foremost manufacturers in the universe.";
                racetext = racetext + "\n\n Racial Bonus:- +1 to intelligence.";
                racetext = racetext + "\n Skilled with Orinian ships and weaponry.";
                selectedRace = "Orinian";
                PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 2 + "\nSocial " + 1 + "\nDexterity " + 1
                        + "\nLeadership " + 1 + "\nRecuperation " + 1;
                break;
            case 3:
                racetext = "Gulhurg colonies are unarguably the most complex systems known to science. Their hive-like social structure gives them an unrivalled empathy with others, making them excellent traders.";
                racetext = racetext + "\n\n Racial Bonus:- +1 to social.";
                racetext = racetext + "\n Skilled with Gulhurg ships and weaponry.";
                selectedRace = "Gulhurg";
                PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 2 + "\nDexterity " + 1
                        + "\nLeadership " + 1 + "\nRecuperation " + 1;
                break;
            }
        }
    });
    buttonSaveCharacter.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            if (Stardust3d.DEBUG)
                System.out.println("Charmaker Complete");

            if (textfieldFirstName.getText().length() < 1) {
                SoundManager.playError();
                stage.addActor(Actors.bottomToast("Character first name cannot be blank.", 4, skin));
            } else {
                SoundManager.playuiclick();
                // populate game from db, based on this char
                // Stardust3d.gameMode = 4;

                String result = Stardust3d.MyDataOp.makeAvatar(selectedAvatar, selectedRace, selectedSex,
                        textfieldFirstName.getText(), textfieldSurName.getText(), muser);
                if (Stardust3d.DEBUG)
                    System.out.println(LOG_TAG + "Everworld: char creation result: " + result);
                if (result.trim().equals("ok")) {
                    Stardust3d.gameMode = 3;
                    // repopulate players characters
                    Stardust3d.populateCharacterlist(Stardust3d.muser);

                    doneflag = true;
                } else {
                    SoundManager.playError();
                    stage.addActor(Actors.bottomToast("This character name is taken, please choose another.", 4,
                            skin));
                }
            }

        }
    });
    buttonCancel.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {

            SoundManager.playuiclick();

            stage.addActor(Actors.bottomToast("Cancelling character creation", 4, skin));
            doneflag = true;
            Stardust3d.gameMode = 3;
        }

    });
    buttonRandName.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {

            SoundManager.playuiclick();
            // generate human female name
            if (selectedSex.equals("Female") && selectedRace.equals("Human")) {
                Stardust3d.MyDataOp.getRandomHumanFemaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);
                // generate human male name
            } else if (selectedSex.equals("Male") && selectedRace.equals("Human")) {
                Stardust3d.MyDataOp.getRandomHumanMaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);

                // generate Jelkek female name
            } else if (selectedSex.equals("Female") && selectedRace.equals("Jelkek")) {
                Stardust3d.MyDataOp.getRandomHumanMaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);
                // generate Jelkek male name
            } else if (selectedSex.equals("Male") && selectedRace.equals("Jelkek")) {
                Stardust3d.MyDataOp.getRandomHumanMaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);

                // generate Orinian female name
            } else if (selectedSex.equals("Female") && selectedRace.equals("Orinian")) {
                Stardust3d.MyDataOp.getRandomHumanMaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);
                // generate Orinain male name
            } else if (selectedSex.equals("Male") && selectedRace.equals("Orinain")) {
                Stardust3d.MyDataOp.getRandomHumanMaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);

                // generate Gulhurg female name
            } else if (selectedSex.equals("Female") && selectedRace.equals("Gulhurg")) {
                Stardust3d.MyDataOp.getRandomHumanMaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);
                // generate Gulhurg male name
            } else if (selectedSex.equals("Male") && selectedRace.equals("Gulhurg")) {
                Stardust3d.MyDataOp.getRandomHumanMaleName();
                textfieldFirstName.setText(Stardust3d.generatedFirstName);
                textfieldSurName.setText(Stardust3d.generatedSurName);
            }
        }

    });
    DialogListener dialogListener = (new DialogListener() {

        @Override
        public void optionSelected(int option) {
            if (Stardust3d.DEBUG)
                System.out.println("option " + option);
            if (option == 1) {
                if (Stardust3d.DEBUG)
                    System.out.println("no");
                stage.removeActor(dialog);
            }
            if (option == 0) {
                if (Stardust3d.DEBUG)
                    System.out.println("yes");
                stage.removeActor(dialog);
            }

        }

    });

}

From source file:com.digitale.screens.CharPicker.java

License:Open Source License

public CharPicker() {
    try {//from w w  w.ja v  a 2s.c  om
        Renderer.bindMeshes(3);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    Stardust3d.currencharacteruid = "" + Stardust3d.charList[0].getUid();
    int charListLength = 0;
    for (int i = 0; i < Stardust3d.charList.length; i++) {

        if (Stardust3d.charList[i].getFirstname() != null) {
            tempEntries[i] = new String("");
            tempEntries[i] = (Stardust3d.charList[i].getFirstname() + " "
                    + Stardust3d.charList[i].getSurname());
            tempEntries[i] = tempEntries[i] + ("  System " + Stardust3d.charList[i].getSystem()// + " Sta "
            //+ Stardust3d.charList[i].getStamina() + " Int "
            //+ Stardust3d.charList[i].getIntelligence() + " Soc " + Stardust3d.charList[i].getSocial()
            //+ " Dex " + Stardust3d.charList[i].getDexterity() + " Led "
            //+ Stardust3d.charList[i].getLeadership() + " Rec "
            //+ Stardust3d.charList[i].getRecuperation()
                    + ".  Flying: " + Util.asCapFirstChar(Stardust3d.charList[i].getShipname()));
            charListLength++;
        } else {
            tempEntries[i] = "";
        }
        listEntries = new String[charListLength];
        for (int j = 0; j < listEntries.length; j++) {
            listEntries[j] = tempEntries[j];
        }
    }

    currentAvatar = Stardust3d.charList[0].getAvatar();
    OrthographicCamera camera;
    batch = new SpriteBatch();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true);
    xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    background = new Texture(Gdx.files.internal("data/bgpland.jpg"));
    camera = new OrthographicCamera();
    camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight());

    fadeIn();
    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    Gdx.input.setInputProcessor(stage);
    final Button buttonEnterGame = new TextButton("Enter Game", skin.getStyle(TextButtonStyle.class),
            "button-enter-game");
    final Button buttonNewCharacter = new TextButton("New Character", skin.getStyle(TextButtonStyle.class),
            "button-enter-game");
    final Button buttonDeleteCharacter = new TextButton("Delete Character",
            skin.getStyle(TextButtonStyle.class), "button-enter-game");
    final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo");
    final List list = new List(listEntries, skin.getStyle(ListStyle.class), "list");
    setAvatarPicture();
    if (Stardust3d.charList[0].getFirstname() == null) {
        selectedCharacter = "    ";
    } else {
        selectedCharacter = (Stardust3d.charList[0].getFirstname() + " " + Stardust3d.charList[0].getSurname());
    }
    final Label fpsLabel = new Label(selectedCharacter, skin.getStyle(LabelStyle.class), "label");

    Window window = new Window("Choose Character", skin.getStyle(WindowStyle.class), "window");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.setFillParent(true);
    window.setMovable(false);
    window.align(Align.TOP);
    window.defaults().pad(5);
    window.defaults().spaceBottom(5).align("top");
    window.row().fill().expandX().maxHeight(28);
    window.add(buttonNewCharacter);
    window.add(buttonDeleteCharacter);
    window.add(buttonEnterGame);
    window.row();

    window.add(dropdown).colspan(3);
    window.row();
    window.add(imageActor).size(128, 128);
    window.add(fpsLabel).colspan(2).align("centre");
    window.add();
    window.pack();

    stage.addActor(window);

    dropdown.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            selectedCharacter = (Stardust3d.charList[index].getFirstname() + " "
                    + Stardust3d.charList[index].getSurname());
            Stardust3d.currencharacteruid = "" + Stardust3d.charList[index].getUid();
            currentAvatar = Stardust3d.charList[index].getAvatar();
            setAvatarPicture();
            ((Label) stage.findActor("label")).setText(selectedCharacter);

        }
    });

    buttonEnterGame.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            if (Stardust3d.DEBUG)
                System.out.println("Charpicker Close");
            SoundManager.playuiclick();
            if (Stardust3d.DEBUG)
                System.out.println("character ID" + Stardust3d.currencharacteruid);
            if (Integer.valueOf(Stardust3d.currencharacteruid) != 0) {
                //populate game from db, based on this char
                Stardust3d.gameMode = 4;
                //init character
                Stardust3d.MyDataOp.get3dChar(Integer.valueOf(Stardust3d.currencharacteruid));
                //
                if (!Stardust3d.DEBUG) {
                    String passed = Stardust3d.MyDataOp.postChat(Stardust3d.myCharacter.getFirstname() + " "
                            + Stardust3d.myCharacter.getSurname() + " has joined the game.", 1, 48);
                }
                Stardust3d.MyDataOp.getInventory(Integer.valueOf(Stardust3d.currencharacteruid), true);
                Stardust3d.MyDataOp.getSolarSystem(Stardust3d.myCharacter.getX(), Stardust3d.myCharacter.getX(),
                        Stardust3d.myCharacter.getZ());
                Stardust3d.MyDataOp.getLocalPlayers(Stardust3d.myCharacter.getX(),
                        Stardust3d.myCharacter.getY(), Stardust3d.myCharacter.getZ(), true);
                Stardust3d.MyDataOp.start();

                try {
                    Renderer.bindMeshes(4);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                doneflag = true;
            } else {
                stage.addActor(
                        Actors.bottomToast("Please select a character before entering the game.", 4, skin));
            }
        }
    });
    buttonNewCharacter.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {

            SoundManager.playuiclick();
            if (Stardust3d.numberOfCharacters >= 10) {
                SoundManager.playError();
                stage.addActor(Actors.bottomToast(
                        "You already have 10 characters, you must delete one first, before you can create a new one.",
                        4, skin));
            } else {
                // startNewCharActivity();
                Stardust3d.gameMode = 15;
                stage.addActor(Actors.bottomToast("Creating new character", 4, skin));
                doneflag = true;
            }
        }
    });

    DialogListener dialogListener = (new DialogListener() {

        @Override
        public void optionSelected(int option) {
            System.out.println("option " + option);
            if (option == 1) {
                System.out.println("no");
                stage.removeActor(dialog);
            }
            if (option == 0) {
                System.out.println("yes");
                System.out.println("DELETED" + selectedCharacter + " " + Stardust3d.currencharacteruid);
                stage.removeActor(dialog);
            }

        }

    });
    dialogTexts = ("Are you sure you wish to delete " + selectedCharacter
            + ", and all the contents of thier inventory?");
    dialog = (Actors.twoOptionsDialog(selectedCharacter, dialogListener, "Delete Character", "Yes", "No",
            skin));
    buttonDeleteCharacter.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {

            SoundManager.playuiclick();

            stage.addActor(dialog);

        }
    });
}

From source file:com.digitale.screens.Chat.java

License:Open Source License

public Chat(String chatlines, Stage stage) {
    // populate channel dropdown
    for (int i = 0; i < Stardust3d.channelList.size(); i++) {
        listEntries[i] = Stardust3d.channelList.get(i).getChannelname();
    }// w ww. j  a  v a  2s .  c  o m
    //get prefs, if no prefs (-1) use factory setting
    int temp = prefs.getInteger("selectedchatchannel", -1);
    if (temp > 0) {
        selectedChannel = temp;
    } else if (temp < -1) {
        selectedChannel = 8;
    }
    temp = prefs.getInteger("chatchanneltype", -1);
    if (temp != -1)
        selectedChannelType = temp;

    batch = new SpriteBatch();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true);
    xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    fadeIn();

    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;

    final Button buttonSend = new TextButton("Send", skin.getStyle(TextButtonStyle.class), "buttonsend");
    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonClose");
    final TextField textfieldText = new TextField("", "Type message here", skin.getStyle(TextFieldStyle.class),
            "textfield");
    final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo");

    // final List list = new List(listEntries,
    // skin.getStyle(ListStyle.class), "list");
    final Label labelchatlines = new Label("Chat:", skin.getStyle(LabelStyle.class), "labelchat");
    final Label labelchattitle = new Label("Chat:", skin.getStyle(LabelStyle.class), "labelchattitle");

    labelchatlines.setWrap(true);
    final ScrollPane scrollPane2 = new ScrollPane(labelchatlines, skin.getStyle(ScrollPaneStyle.class),
            "scroll");
    dropdown.setSelection(selectedChannel);
    final Label lableNews = new Label("Chat: ", skin);

    Window window = new Window("Chat Screen", skin.getStyle(WindowStyle.class), "chatWindow");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.setFillParent(true);
    window.setMovable(false);
    window.defaults().pad(5);
    // build table
    window.row().fill().expandX();
    window.add(dropdown).align("Centre");
    window.add();

    window.add(buttonSend).colspan(1).align("right");
    window.add(buttonClose).colspan(1).align("center");
    window.row();
    window.add(textfieldText).minWidth(100).expandX().fillX().colspan(4);

    window.row();
    window.add(labelchattitle).align("left");
    window.row();
    window.add(scrollPane2).fill().expand().colspan(4);
    window.row();
    window.pack();
    stage.addActor(window);

    textfieldText.setTextFieldListener(new TextFieldListener() {
        public void keyTyped(TextField textField, char key) {
            if (key == '\n')
                textField.getOnscreenKeyboard().show(false);
        }
    });
    dropdown.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            selectedChannelType = (Stardust3d.channelList.get(index).getChanneltype());
            selectedChannel = (Stardust3d.channelList.get(index).getUid());

            Stardust3d.chatChannel = selectedChannel;
            Stardust3d.chatChannelName = Stardust3d.channelList.get(index).getChannelname();
            prefs.putInteger("chatchanneltype", selectedChannelType);
            prefs.putInteger("selectedchatchannel", selectedChannel);
            prefs.flush();
            Stardust3d.chatListReset = true;
            Stardust3d.refreshChat(Stardust3d.chatChannel, false);

        }
    });
    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            if (Stardust3d.DEBUG)
                System.out.println("close chat button pressed");
            SoundManager.playuiclick();
            Stardust3d.stationScreen = 104;
            doneflag = true;
            isDone();
        }
    });

    buttonSend.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            SoundManager.playuiclick();

            if (Stardust3d.DEBUG)
                System.out.println("send button pressed");
            text = textfieldText.getText().toString();
            if (selectedChannelType == 0 || selectedChannelType == 8) {
                Renderer.stage
                        .addActor(Actors.bottomToast("You cannot send messages to this channel.", 4, skin));
                SoundManager.playError();

            } else if (!text.isEmpty()) {
                String passed = Stardust3d.MyDataOp.postChat(text, selectedChannel,
                        Stardust3d.myCharacter.getUid());
                textfieldText.setText("");
                Stardust3d.refreshChat(selectedChannel, false);

            }
        }
    });

}

From source file:com.digitale.screens.FactoryScreen.java

License:Open Source License

public FactoryScreen(Stage stage) {

    Stardust3d.myInventory.clear();//from   ww  w  .  j  ava 2s. com
    Stardust3d.MyDataOp.get3dChar(Integer.valueOf(Stardust3d.currencharacteruid));
    Stardust3d.MyDataOp.getInventory(Integer.valueOf(Stardust3d.currencharacteruid), false);

    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;
    final Label tradegoodsLabel = new Label("Your Tradegoods", skin.getStyle(LabelStyle.class),
            "tradegoodslable");
    final Label blueprintsLabel = new Label("Your Blueprints", skin.getStyle(LabelStyle.class),
            "blueprintslable");
    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "button-close");
    final Button buttonBuild = new TextButton("Build", skin.getStyle(TextButtonStyle.class), "buttonbuild");
    final Label balance = new Label(Stardust3d.myCharacter.getCredits() + " $D",
            skin.getStyle(LabelStyle.class), "balancelable");
    final Table gridCargo = initBlueprints();

    final Table gridWarehouse = initTradegoods();
    final ScrollPane paneCargo = new ScrollPane(gridCargo, skin.getStyle(ScrollPaneStyle.class), "blueprints");
    final ScrollPane paneWarehouse = new ScrollPane(gridWarehouse, skin.getStyle(ScrollPaneStyle.class),
            "tradegoods");
    final SplitPane splitPane = new SplitPane(paneCargo, paneWarehouse, false,
            skin.getStyle("default-horizontal", SplitPaneStyle.class), "split");

    Window window = new Window("Factory Screen", skin.getStyle(WindowStyle.class), "factoryWindow");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.setFillParent(true);
    window.setMovable(false);
    window.defaults().pad(5);
    window.defaults().spaceBottom(5);
    window.row().fill().expandX();
    window.add(balance);
    window.add();
    window.add(buttonBuild).minWidth(150);
    window.add(buttonClose).minWidth(150);
    window.row();
    window.add(blueprintsLabel).colspan(2);
    window.add(tradegoodsLabel).colspan(2);
    window.row().fill().expandY();
    window.add(splitPane).colspan(4);
    window.pack();

    stage.addActor(window);
    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("factory Close");
            SoundManager.playuiclick();
            Stardust3d.MyDataOp.getInventory(Integer.valueOf(Stardust3d.currencharacteruid), false);
            Stardust3d.stationScreen = 111;
            //Renderer.stage.clear();
        }
    });
    buttonBuild.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("build item");
            SoundManager.playuiclick();
            //Stardust3d.MyDataOp.newRequest("movealltowarehouse#");
            for (int i = 0; i < Stardust3d.myInventory.size(); i++) {
                Inventory item = Stardust3d.myInventory.get(i);
                if (item.getSlot_id() == 0) {

                    //Renderer.stage.findActor(""+item.getInventoryid()).remove();
                }
            }
        }
    });
}