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

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

Introduction

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

Prototype

public Window(String title, Skin skin, String styleName) 

Source Link

Usage

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
    }/* www.jav  a  2  s .  c o 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. j av a 2  s  .c o m*/
        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();
    }//from   ww w. j  a va 2  s .co  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 .ja  v  a2s  .  c  o m*/
    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();
                }
            }
        }
    });
}

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

License:Open Source License

public Help(String newslines) {
    OrthographicCamera camera;//from   w w w .  ja v a2 s.c om
    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 buttonLogin = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonLogin");
    final Label labelStories = new Label(newslines, skin);
    labelStories.setWrap(true);
    final ScrollPane scrollPane2 = new ScrollPane(labelStories, skin.getStyle(ScrollPaneStyle.class), "scroll");

    // configures an example of a TextField in password mode.
    final Label lableNews = new Label("Basic Help: ", skin);

    Window window = new Window("Help Screen", 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);
    //build table
    window.row().fill().expandX();
    window.add();
    window.add();
    window.add();
    window.add(buttonLogin).colspan(1).align("right");

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

    buttonLogin.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("help Close pressed");
            SoundManager.playuiclick();
            if (Stardust3d.mloginOK) {
                Stardust3d.gameMode = 4;

                doneflag = true;
            } else {
                Stardust3d.gameMode = 2;
                doneflag = true;
            }
        }
    });

}

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

License:Open Source License

public InGameHelp(Stage stage, String newslines) {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));

    Gdx.input.setInputProcessor(stage);// w w w  .  j  av  a 2  s .  c o m

    // Group.debug = true;

    final Button buttonLogin = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonLogin");
    final Label labelHelpText = new Label(newslines, skin);
    labelHelpText.setWrap(true);
    final ScrollPane scrollPane2 = new ScrollPane(labelHelpText, skin.getStyle(ScrollPaneStyle.class),
            "scroll");

    // configures an example of a TextField in password mode.
    final Label lableHelpTitle = new Label("Basic Help: ", skin);

    Window window = new Window("Help Screen", skin.getStyle(WindowStyle.class), "helpWindow");
    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();
    window.add();
    window.add();
    window.add(buttonLogin).colspan(1).align("right");
    window.row();
    window.add(lableHelpTitle).align("left");
    window.row();
    window.add(scrollPane2).fill().expand().colspan(4);
    window.row();
    window.pack();
    stage.addActor(window);

    buttonLogin.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("help Close pressed");
            SoundManager.playuiclick();
            Stardust3d.stationScreen = 108;
        }
    });
}

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

License:Open Source License

public InGameOptions(Stage stage) {
    originalsfxVolume = Stardust3d.sfxVolume;
    originalMusicVolume = Stardust3d.musicVolume;
    originalaccellXsensitivity = Stardust3d.accelXsensitivity;
    originalaccellYsensitivity = Stardust3d.accelYsensitivity;
    originalDeadzoneX = Stardust3d.deadzoneX;
    originalDeadzoneY = Stardust3d.deadzoneY;
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));

    Gdx.input.setInputProcessor(stage);//from  ww w.  j av  a  2  s. c om

    // Group.debug = true;

    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonClose");
    final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "buttonCancel");
    ;
    final CheckBox checkBoxSFX = new CheckBox("Sound Effects", skin.getStyle(CheckBoxStyle.class), "checkbox");
    final CheckBox checkBoxFontsize = new CheckBox("Use Small Font", skin.getStyle(CheckBoxStyle.class),
            "checkboxfont");

    final Slider slidersfx = new Slider(0, 2, .1f, skin.getStyle(SliderStyle.class), "slidersfx");

    final Slider sliderdzy = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdzy");
    final Slider sliderdzx = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdzx");
    //sensitivty
    final Slider slidersy = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdsy");
    final Slider slidersx = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdsx");
    //stardust
    final Slider sliderdust = new Slider(20, 500, 10f, skin.getStyle(SliderStyle.class), "sliderdust");

    final Slider slidermusic = new Slider(0, 1, .01f, skin.getStyle(SliderStyle.class), "slidersmusic");
    final Slider slidergfxquality = new Slider(0, 10, 1, skin.getStyle(SliderStyle.class), "slidergfx");

    slidersfx.setValue(Stardust3d.sfxVolume);
    slidermusic.setValue(Stardust3d.musicVolume);
    sliderdzx.setValue(Stardust3d.deadzoneX);
    sliderdzy.setValue(Stardust3d.deadzoneY);
    sliderdust.setValue(Stardust3d.dustsize);
    slidersx.setValue(Stardust3d.accelXsensitivity);
    slidersy.setValue(Stardust3d.accelYsensitivity);
    final Label lablesfx = new Label("Sound effect volume", skin.getStyle(LabelStyle.class), "lablesfx");
    final Label lablemusic = new Label("Music volume", skin.getStyle(LabelStyle.class), "lablemusic");
    final Label lablegfx = new Label("Graphics quality", skin.getStyle(LabelStyle.class), "lablegfx");

    final Label lablesliderdzx = new Label("Horizontal Deadzone", skin.getStyle(LabelStyle.class),
            "lablesliderdzx");
    final Label lablesliderdzy = new Label("Vertical Deadzone", skin.getStyle(LabelStyle.class),
            "lablesliderdzy");
    final Label lableslidersx = new Label("Horizontal Sensitivity", skin.getStyle(LabelStyle.class),
            "lableslidersx");
    final Label lableslidersy = new Label("Vertical Sensitivity", skin.getStyle(LabelStyle.class),
            "lableslidersy");
    final Label lablesliderdust = new Label("Spacedust Density", skin.getStyle(LabelStyle.class),
            "lablesliderdust");
    final Preferences prefs = Gdx.app.getPreferences("stardustpreferences");
    final Label lablestilt = new Label("Android Tilt Settings", skin.getStyle(LabelStyle.class), "labletilt");

    Window window = new Window("Options Screen", skin.getStyle(WindowStyle.class), "optionsWindow");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.defaults().pad(2);
    window.setFillParent(true);
    window.setMovable(false);
    // build table
    window.row().fill().expandX().maxHeight(28);
    window.add();
    window.add();
    window.add(buttonCancel).colspan(1);
    window.add(buttonClose).colspan(1);
    // audio slider lables
    window.row().fill().expandX().maxHeight(28);
    window.add(checkBoxFontsize);
    window.add();
    window.add(lablestilt).maxWidth(350).fillX().colspan(2);

    window.row().fill().expandX().maxHeight(28);
    //top row 
    window.add(lablesfx).maxWidth(350).fillX().colspan(2);
    window.add(lablesliderdzx).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(slidersfx).fillX().colspan(2);
    window.add(sliderdzx).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add(lablemusic).maxWidth(350).fillX().colspan(2);
    window.add(lablesliderdzy).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(slidermusic).fillX().colspan(2);
    window.add(sliderdzy).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add(lablesliderdust).maxWidth(350).fillX().colspan(2);
    window.add(lableslidersx).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(sliderdust).fillX().colspan(2);
    window.add(slidersx).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add().minWidth(100).maxWidth(350).fillX().colspan(2);
    window.add(lableslidersy).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add().fillX().colspan(2);
    window.add(slidersy).fillX().colspan(2);
    window.row();
    // audio sliders

    window.pack();
    stage.addActor(window);

    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            prefs.putFloat("musicvolume", Stardust3d.musicVolume);
            prefs.putFloat("sfxvolume", Stardust3d.sfxVolume);

            prefs.putFloat("dzx", Stardust3d.deadzoneX);
            prefs.putFloat("dzy", Stardust3d.deadzoneY);
            prefs.putFloat("sx", Stardust3d.accelXsensitivity);
            prefs.putFloat("sy", Stardust3d.accelYsensitivity);

            prefs.putFloat("dustsize", Stardust3d.dustsize);
            Simulation.populateDust();
            prefs.flush();
            Stardust3d.stationScreen = 107;
        }
    });

    checkBoxFontsize.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            SoundManager.playuiclick();
            if (Stardust3d.DEBUG)
                System.out.println("smallfont");
            Stardust3d.tinyfont = checkBoxFontsize.isChecked();
            // if user wants to change fontsize
            prefs.putBoolean("fontsize", Stardust3d.tinyfont);
            prefs.flush();
        }
    });

    buttonCancel.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            resetSettings();
            Stardust3d.stationScreen = 107;
        }
    });

    slidersfx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.sfxVolume = value;
            SoundManager.setSFXVolume();
            SoundManager.playconfirm();
        }
    });

    slidermusic.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.musicVolume = value;

            SoundManager.setMusicVolume();

        }
    });

    sliderdzx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.deadzoneX = value;
        }
    });
    sliderdzy.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.deadzoneY = value;
        }
    });

    slidersx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.accelXsensitivity = value;
        }
    });

    slidersy.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.accelYsensitivity = value;
        }
    });
    sliderdust.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.dustsize = value;
            SoundManager.setMusicVolume();
        }
    });
}

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

License:Open Source License

public Login(String newslines) {
    //all sounds loaded, now bind them 

    try {//w  w  w  . j  ava  2  s .  c o  m
        Renderer.bindMeshes(0);
    } catch (IOException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    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 buttonLogin = new TextButton("Log in", skin.getStyle(TextButtonStyle.class), "buttonLogin");
    final Button buttonHelp = new TextButton("Quick Help", skin.getStyle(TextButtonStyle.class), "buttonHelp");
    final Button buttonNewAccount = new TextButton("New Account", skin.getStyle(TextButtonStyle.class),
            "buttonNewAccount");
    final Button buttonOptions = new TextButton("Options", skin.getStyle(TextButtonStyle.class),
            "buttonOptions");
    final CheckBox checkBox = new CheckBox("Remember account name and password.",
            skin.getStyle(CheckBoxStyle.class), "checkbox");
    final TextField textfieldUserName = new TextField("", "Account Name", skin.getStyle(TextFieldStyle.class),
            "textfield");
    // final List list = new List(listEntries,
    // skin.getStyle(ListStyle.class), "list");
    final Label labelStories = new Label(newslines, skin);
    labelStories.setWrap(true);
    final ScrollPane scrollPane2 = new ScrollPane(labelStories, skin.getStyle(ScrollPaneStyle.class), "scroll");

    // configures an example of a TextField in password mode.
    final Label lableNews = new Label("News: ", skin);
    final TextField passwordTextField = new TextField("", "password", skin);
    passwordTextField.setPasswordCharacter('*');
    passwordTextField.setPasswordMode(true);
    textfieldUserName.getOnscreenKeyboard().show(true);

    Boolean booltemp = prefs.getBoolean("nopoly", false);
    //is save account checked in prefs
    if (booltemp) {
        //if preferences account is too short to have been set to a valid account name
        checkBox.setChecked(true);
        String temp = prefs.getString("un", "");
        ac = temp;
        textfieldUserName.setText(ac);
        temp = prefs.getString("cullingtree", "");
        String pw = null;
        try {
            pw = new String(mcrypt.decrypt(temp.trim()));
            pw = pw.replace('~', ' ').trim();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        passwordTextField.setText(pw);
    }
    Window window = new Window("Login Screen", 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);
    //build table
    window.row().fill().expandX();
    window.add(buttonNewAccount).colspan(1).align("Centre");
    window.add(buttonOptions).colspan(1).align("center");
    window.add(buttonHelp).colspan(1).align("center");
    window.add(buttonLogin).colspan(1).align("right");
    window.row();

    window.add(textfieldUserName).minWidth(100).expandX().fillX().colspan(2);
    window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2);
    window.row();
    window.add(lableNews).align("left");
    window.row();
    window.add(scrollPane2).fill().expand().colspan(4);
    window.row();
    window.add(checkBox).colspan(4);
    window.row();
    window.pack();
    stage.addActor(window);
    SoundManager.init();
    try {
        Renderer.bindMeshes(1);
    } catch (IOException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }

    textfieldUserName.setTextFieldListener(new TextFieldListener() {

        public void keyTyped(TextField textField, char key) {
            if (key == '\n')
                textField.getOnscreenKeyboard().show(false);
        }

    });

    buttonLogin.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            try {
                Renderer.bindMeshes(2);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (Stardust3d.DEBUG)
                System.out.println("login button pressed");
            SoundManager.playuiclick();

            ac = textfieldUserName.getText().toString();
            String pw = passwordTextField.getText().toString();

            if (checkpass(pw, pw) && checkuser(ac)) {

                String passed = Stardust3d.MyDataOp.login(ac, pw);
                if (Stardust3d.DEBUG)
                    System.out.println("passed " + passed);
                if (passed.equals("true")) {
                    SoundManager.playconfirm();
                    stage.addActor(Actors.bottomToast("Login sucessful", 4, skin));

                    Stardust3d.mloginOK = true;
                    Stardust3d.gameMode = 3;
                    //get players characters
                    Stardust3d.populateCharacterlist(Stardust3d.muser);

                    doneflag = true;
                    isDone();
                } else if (passed.equals("NOT_ACTIVE")) {
                    SoundManager.playError();
                    stage.addActor(Actors.bottomToast(
                            "Login failed, this account is not active, check your Email.", 4, skin));

                } else if (passed.equals("false")) {
                    SoundManager.playError();
                    stage.addActor(Actors.bottomToast(
                            "Login failed, please check your account name and password.", 4, skin));
                }
            }

        }
    });

    buttonOptions.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            if (Stardust3d.DEBUG)
                System.out.println("options button pressed");
            SoundManager.playuiclick();
            Stardust3d.gameMode = 6;
            doneflag = true;
        }
    });
    buttonNewAccount.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            if (Stardust3d.DEBUG)
                System.out.println("New account button pressed");
            SoundManager.playuiclick();
            Stardust3d.gameMode = 14;
            doneflag = true;
        }
    });
    buttonHelp.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            if (Stardust3d.DEBUG)
                System.out.println("help button pressed");
            SoundManager.playuiclick();
            Stardust3d.gameMode = 9;
            doneflag = true;
        }
    });
    checkBox.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            SoundManager.playuiclick();
            String encrypted = null;
            if (Stardust3d.DEBUG)
                System.out.println("remeber account name pressed");
            Stardust3d.mremeberAccountname = checkBox.isChecked();
            //if user wants to save login
            if (Stardust3d.mremeberAccountname) {
                String pw = passwordTextField.getText().toString();
                String acc = textfieldUserName.getText().toString();
                //check user has entered account details before saving
                if (pw.length() > 8 && acc.length() > 8) {

                    /* Encrypt */
                    try {
                        encrypted = (mcrypt.encrypt(pw));
                    } catch (Exception e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                    prefs.putBoolean("nopoly", Stardust3d.mremeberAccountname);
                    prefs.putString("un", acc);
                    prefs.putString("cullingtree", encrypted);
                    prefs.flush();
                } else {
                    stage.addActor(Actors.bottomToast(
                            "You need to enter your account name and password before trying to save them.", 4,
                            skin));
                    checkBox.setChecked(false);
                }
            } else {
                stage.addActor(Actors.bottomToast("Saved account details cleared.", 4, skin));
                //clear saved account details
                prefs.putBoolean("nopoly", Stardust3d.mremeberAccountname);
                prefs.putString("un", "");
                prefs.putString("cullingtree", "");
                prefs.flush();
            }
        }
    });
}

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

License:Open Source License

public MapScreen(Stage stage) {

    for (int i = 0; i < Stardust3d.charList.length; i++) {
        listEntries[i] = (Stardust3d.charList[i].getFirstname() + " \n" + Stardust3d.charList[i].getSurname()
                + " \n " + "10000c ");
        listEntries[i] = listEntries[i] + ("System " + Stardust3d.charList[i].getSystem() + " \nSta "
                + 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() + " \nFlying: "
                + Util.asCapFirstChar(Stardust3d.charList[i].getShipname()));
    }/*from w w w.j  av a 2 s.  co m*/

    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    texture1 = new Texture(Gdx.files.internal("data/stickleback.png"));
    texture2 = new Texture(Gdx.files.internal("data/salx.png"));
    TextureRegion image = new TextureRegion(texture1);
    TextureRegion image2 = new TextureRegion(texture2);

    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;
    final Label nameLabel = new Label(
            Stardust3d.myCharacter.getFirstname() + Stardust3d.myCharacter.getSurname(),
            skin.getStyle(LabelStyle.class), "namelable");
    final Label IntelligenceLabel = new Label("PLACEHOLDER " + Stardust3d.myCharacter.getIntelligence(),
            skin.getStyle(LabelStyle.class), "intelligencelable");

    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "button-close");

    final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo");
    final Image imageActor = new Image(image2);
    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, scrollPane2, false,
            skin.getStyle("default-horizontal", SplitPaneStyle.class), "split");

    final Label fpsLabel = new Label("fps:", skin.getStyle(LabelStyle.class), "label");

    selectedCharacter = ("Character: " + Stardust3d.charList[0].getFirstname() + " \n"
            + Stardust3d.charList[0].getSurname());

    Window window = new Window("Map Screen", skin.getStyle(WindowStyle.class), "mapWindow");
    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();
    window.add(buttonClose).colspan(1);
    window.row();
    window.add(nameLabel);
    window.add();
    window.add();
    window.add();
    window.row();
    window.add(IntelligenceLabel);

    window.row();
    // window.add(setWidget(list));
    window.row();
    window.add(splitPane).colspan(4);
    window.row();
    window.row();

    window.pack();

    // stage.addActor(new Button("Behind Window", skin));
    stage.addActor(window);

    dropdown.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            selectedCharacter = ("Character: " + Stardust3d.charList[index].getFirstname() + " \n"
                    + Stardust3d.charList[index].getSurname());
            Stardust3d.currencharacteruid = "" + Stardust3d.charList[index].getUid();

        }
    });

    buttonClose.setClickListener(new ClickListener() {
        public void click(Actor actor, float x, float y) {
            System.out.println("mapscreen Close");
            SoundManager.playuiclick();
            Stardust3d.stationScreen = 112;
            doneflag = true;

        }
    });
}

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

License:Open Source License

public Market(Stage stage) {

    for (int i = 0; i < Stardust3d.charList.length; i++) {
        listEntries[i] = (Stardust3d.charList[i].getFirstname() + " \n" + Stardust3d.charList[i].getSurname()
                + " \n " + "10000c ");
        listEntries[i] = listEntries[i] + ("System " + Stardust3d.charList[i].getSystem() + " \nSta "
                + 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() + " \nFlying: "
                + Util.asCapFirstChar(Stardust3d.charList[i].getShipname()));
    }/*from   ww w . ja v a2  s .  c o m*/
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    texture1 = new Texture(Gdx.files.internal("data/beer.png"));
    texture2 = new Texture(Gdx.files.internal("data/blueprint.png"));
    TextureRegion image = new TextureRegion(texture1);
    TextureRegion image2 = new TextureRegion(texture2);

    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;
    final Label nameLabel = new Label(
            Stardust3d.myCharacter.getFirstname() + " \n" + Stardust3d.myCharacter.getSurname(),
            skin.getStyle(LabelStyle.class), "namelable");
    final Label IntelligenceLabel = new Label("PLACEHOLDER " + Stardust3d.myCharacter.getIntelligence(),
            skin.getStyle(LabelStyle.class), "intelligencelable");

    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "button-close");

    final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo");
    final Image imageActor = new Image(image2);
    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, scrollPane2, false,
            skin.getStyle("default-horizontal", SplitPaneStyle.class), "split");

    final Label fpsLabel = new Label("fps:", skin.getStyle(LabelStyle.class), "label");

    selectedCharacter = ("Character: " + Stardust3d.charList[0].getFirstname() + " \n"
            + Stardust3d.charList[0].getSurname());

    // window.debug();
    Window window = new Window("Market Screen", skin.getStyle(WindowStyle.class), "marketWindow");
    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();
    window.add(buttonClose).colspan(1);
    window.row();
    window.add(nameLabel);
    window.add();
    window.add();
    window.add();
    window.row();
    window.add(IntelligenceLabel);
    window.row();
    // window.add(setWidget(list));
    window.row();
    window.add(splitPane).colspan(4);
    window.row();
    window.row();
    window.add(fpsLabel).colspan(4);
    window.pack();

    // stage.addActor(new Button("Behind Window", skin));
    stage.addActor(window);

    dropdown.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            selectedCharacter = ("Character: " + Stardust3d.charList[index].getFirstname() + " \n"
                    + Stardust3d.charList[index].getSurname());
            Stardust3d.currencharacteruid = "" + Stardust3d.charList[index].getUid();

        }
    });

    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Market Close");
            SoundManager.playuiclick();
            Stardust3d.stationScreen = 109;

        }
    });
}