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

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

Introduction

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

Prototype

public ScrollPane(Actor widget) 

Source Link

Usage

From source file:kyle.game.besiege.panels.PanelFaction.java

License:Open Source License

public PanelFaction(SidePanel panel, Faction faction) {
    this.panel = panel;
    this.faction = faction;
    this.addParentPanel(panel);

    LabelStyle lsBig = new LabelStyle();
    lsBig.font = Assets.pixel24;/*from   w w  w  . j  a v a  2 s .c  o  m*/

    ls = new LabelStyle();
    ls.font = Assets.pixel16;

    lsG = new LabelStyle();
    lsG.font = Assets.pixel16;
    lsG.fontColor = Color.GRAY;

    lsY = new LabelStyle();
    lsY.font = Assets.pixel16;
    lsY.fontColor = Color.YELLOW;

    Label castlesC = new Label("Castles:", ls);
    Label wealthC = new Label("Wealth:", ls); // maybe give this a mouseover for description.

    title = new Label("", lsBig);
    title.setAlignment(0, 0);
    title.setWrap(true);
    title.setWidth(SidePanel.WIDTH - PAD * 2 - MINI_PAD * 2);
    title.setText(faction.name);

    wealth = new Label("", ls);
    cities = new Table();

    // Create text
    text = new Table();
    //      text.debug();
    text.defaults().padTop(NEG).left();

    //      title.addListener(new InputListener() {
    //         public boolean touchDown(InputEvent event, float x,
    //               float y, int pointer, int button) {
    //            return true;
    //         }
    //         public void touchUp(InputEvent event, float x, float y,
    //               int pointer, int button) {
    //            centerCamera();
    //         }
    //      });

    text.add(title).colspan(2).fillX().expandX().padBottom(MINI_PAD);
    text.row();
    text.add().width((SidePanel.WIDTH - PAD * 2) / 2);
    text.add().width((SidePanel.WIDTH - PAD * 2) / 2);
    text.row();
    text.add(wealthC).padLeft(MINI_PAD).center();
    text.add(wealth).center();
    text.row();
    text.add().colspan(2).padTop(MINI_PAD);
    text.row();

    cities = new Table();
    //      cities.debug();
    //cities.defaults().padTop(NEG);
    cities.top();
    cities.defaults().left().padTop(NEG).expandX();

    castles = new Table();
    //      castles.debug();
    castles.top();
    castles.defaults().left().padTop(NEG).expandX();

    locations = new Table();
    //      locations.debug();
    locations.top();
    locations.defaults().left().top();
    locations.setBackground(
            new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r)));
    locations.add().width((SidePanel.WIDTH - PAD * 2) / 2);
    locations.add().width((SidePanel.WIDTH - PAD * 2) / 2);
    locations.row();
    locations.add(cities).width((SidePanel.WIDTH - PAD * 2) / 2);
    locations.add(castles).width((SidePanel.WIDTH - PAD * 2) / 2);
    locationPane = new ScrollPane(locations);
    locationPane.setScrollbarsOnTop(true);
    locationPane.setFadeScrollBars(false);

    text.add(locationPane).colspan(2).top().padTop(0);
    text.row();
    text.add().colspan(2).padTop(PAD);
    text.row();

    nobles = new Table();
    //      nobles.debug();
    nobles.top();
    nobles.defaults().padTop(NEG).left();
    noblesPane = new ScrollPane(nobles);
    noblesPane.setScrollbarsOnTop(true);
    noblesPane.setFadeScrollBars(false);
    nobles.setBackground(new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r)));
    nobles.add().width((SidePanel.WIDTH - PAD * 2) / 2);
    nobles.add().width((SidePanel.WIDTH - PAD * 2) / 2);
    nobles.row();

    text.add(noblesPane).colspan(2);
    text.row();
    text.add().colspan(2).padTop(PAD);
    text.row();

    relations = new Table();
    relations.top();
    relations.defaults().padTop(NEG).left();
    relationsPane = new ScrollPane(relations);
    relationsPane.setScrollbarsOnTop(true);
    relationsPane.setFadeScrollBars(false);
    relations.setBackground(
            new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r)));

    text.add(relationsPane).colspan(2);
    text.row();

    //      //Soldier's stats
    //      stats = new Table();
    //      stats.setVisible(false);
    //      
    //      Label levelSC = new Label("Level:", ls);
    //      Label expSC = new Label("Exp:",ls);
    //      Label nextSC = new Label("Next:",ls);
    //      Label atkSC = new Label("Atk:", ls);
    //      Label defSC = new Label("Def:", ls);
    //      Label spdSC = new Label("Spd:", ls); 
    //      Label weaponSC = new Label("Weapon: ", ls);
    //      Label equipmentSC = new Label("Armor: ", ls);
    //
    //      nameS = new Label("", ls);
    //      nameS.setAlignment(0,0);
    //      levelS = new Label("", ls);
    //      expS = new Label("", ls);
    //      nextS = new Label("", ls);
    //      atkS = new Label("" ,ls);
    //      defS = new Label("", ls);
    //      spdS = new Label("", ls);
    //      weaponS = new Label("", ls);
    //      equipmentS = new Label("", ls);
    //      
    //      stats.defaults().left().padTop(NEG);
    //      stats.add(nameS).colspan(4).width(SidePanel.WIDTH-PAD*2).fillX().expandX().padBottom(MINI_PAD);
    //      stats.row();
    //      stats.add().colspan(2).width((SidePanel.WIDTH-PAD*2)/2);
    //      stats.add().colspan(2).width((SidePanel.WIDTH-PAD*2)/2);
    //      stats.row();
    //      stats.add(levelSC).padLeft(MINI_PAD);
    //      stats.add(levelS);
    //      stats.add(atkSC).padLeft(PAD);
    //      stats.add(atkS);
    //      stats.row();
    //      stats.add(expSC).padLeft(MINI_PAD);
    //      stats.add(expS);
    //      stats.add(defSC).padLeft(PAD);
    //      stats.add(defS);
    //      stats.row();
    //      stats.add(nextSC).padLeft(MINI_PAD);
    //      stats.add(nextS);
    //      stats.add(spdSC).padLeft(PAD);
    //      stats.add(spdS);
    //      stats.row();
    //      stats.add(weaponSC).colspan(2).padLeft(MINI_PAD).padTop(0);
    //      stats.add(weaponS).colspan(2).padTop(0);
    //      stats.row();
    //      stats.add(equipmentSC).colspan(2).padLeft(MINI_PAD).padTop(0).top();
    //      stats.add(equipmentS).colspan(2).padTop(0);
    //      
    //      //stats.debug();
    //      
    ////      text.add(stats).colspan(4).padTop(PAD);

    this.addTopTable(text);

    this.setButton(4, "Back");
    updateRelations();
}

From source file:kyle.game.besiege.panels.PanelHire.java

License:Open Source License

public PanelHire(SidePanel panel, Location location) {
    this.panel = panel;
    this.location = location;
    this.addParentPanel(panel);

    LabelStyle lsBig = new LabelStyle();
    lsBig.font = Assets.pixel24;/*from  w w w  .  j  a  v  a2 s .c  o m*/

    LabelStyle lsMB = new LabelStyle();
    lsMB.font = Assets.pixel22;

    LabelStyle lsMed = new LabelStyle();
    lsMed.font = Assets.pixel18;

    LabelStyle lsSmall = new LabelStyle();
    lsSmall.font = Assets.pixel14;

    LabelStyle lsMicro = new LabelStyle();
    lsMicro.font = Assets.pixel14;

    ls = new LabelStyle();
    ls.font = Assets.pixel16;

    ButtonStyle bs = new ButtonStyle();
    bs = new ButtonStyle();
    bs.up = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(upTexture), r, r, r, r));
    bs.down = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(downTexture), r, r, r, r));
    bs.pressedOffsetX = OFFSET;
    bs.pressedOffsetY = -OFFSET;

    Label playerPartyC = new Label("Party: ", ls);
    Label playerWealthC = new Label("Wealth: ", ls);

    title = new Label("For Hire", lsBig);
    title.setAlignment(0, 0);
    title.setWrap(true);
    title.setWidth(SidePanel.WIDTH - PAD * 2 - MINI_PAD * 2);
    cityName = new Label("", lsMed);
    cityName.setAlignment(0, 0);
    cityName.setText(location.getName());
    playerParty = new Label("", ls);
    playerWealth = new Label("", ls);

    // Create text
    text = new Table();
    //text.debug();
    text.defaults().padTop(NEG).left();

    text.add(title).colspan(4).fillX().expandX().padBottom(0);
    text.row();
    text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    text.row();
    text.add(cityName).colspan(4).padBottom(MINI_PAD).fillX().expandX();
    text.row();
    text.add(playerWealthC).padLeft(MINI_PAD);
    text.add(playerWealth);
    text.add(playerPartyC).padLeft(PAD);
    text.add(playerParty);
    text.row();

    soldierTable = new Table();
    //soldierTable.debug();
    soldierTable.defaults().padTop(NEG);
    soldierTable.top();
    soldierTable.setBackground(
            new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r)));
    text.row();
    text.add().colspan(4).padBottom(PAD);
    text.row();

    soldierPane = new ScrollPane(soldierTable);
    soldierPane.setScrollbarsOnTop(true);
    soldierPane.setFadeScrollBars(false);
    text.add(soldierPane).colspan(4).top().padTop(0);

    text.row();

    // Soldier's stats
    stats = new Table();
    stats.setVisible(false);

    Label levelSC = new Label("Level:", ls);
    Label expSC = new Label("Exp:", ls);
    Label nextSC = new Label("Next:", ls);
    Label atkSC = new Label("Atk:", ls);
    Label defSC = new Label("Def:", ls);
    Label spdSC = new Label("Spd:", ls);
    Label weaponSC = new Label("Weapon: ", ls);
    Label equipmentSC = new Label("Armor: ", ls);

    nameS = new Label("", ls);
    nameS.setAlignment(0, 0);
    levelS = new Label("", ls);
    expS = new Label("", ls);
    nextS = new Label("", ls);
    atkS = new Label("", ls);
    defS = new Label("", ls);
    spdS = new Label("", ls);
    weaponS = new Label("", ls);
    equipmentS = new Label("", ls);
    hireLabel = new SoldierLabel("", ls, null);
    hireLabel.setTouchable(Touchable.disabled);
    hireButton = new Button(bs);
    hireButton.add(hireLabel).padLeft(MINI_PAD).padRight(MINI_PAD);
    hireButton.addListener(new ClickListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            hireSelected();
        }
    });

    stats.defaults().left().padTop(NEG);
    stats.add(nameS).colspan(4).width(SidePanel.WIDTH - PAD * 2).fillX().expandX().padBottom(MINI_PAD);
    stats.row();
    stats.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    stats.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    stats.row();
    stats.add(levelSC).padLeft(MINI_PAD);
    stats.add(levelS);
    stats.add(atkSC).padLeft(PAD);
    stats.add(atkS);
    stats.row();
    stats.add(expSC).padLeft(MINI_PAD);
    stats.add(expS);
    stats.add(defSC).padLeft(PAD);
    stats.add(defS);
    stats.row();
    stats.add(nextSC).padLeft(MINI_PAD);
    stats.add(nextS);
    stats.add(spdSC).padLeft(PAD);
    stats.add(spdS);
    stats.row();
    stats.add(weaponSC).colspan(2).padLeft(MINI_PAD).padTop(0);
    stats.add(weaponS).colspan(2).padTop(0);
    stats.row();
    stats.add(equipmentSC).colspan(2).padLeft(MINI_PAD).padTop(0).top();
    stats.add(equipmentS).colspan(2).padTop(0);
    stats.row();
    stats.add(hireButton).colspan(4).center().padTop(PAD);

    //stats.debug();

    text.add(stats).colspan(4).padTop(PAD);

    this.addTopTable(text);
    this.setButton(2, "Hire All");
    this.setButton(4, "Back");
}

From source file:kyle.game.besiege.panels.PanelLocation.java

License:Open Source License

public PanelLocation(SidePanel panel, Location location) {
    this.panel = panel;
    this.location = location;
    this.party = location.getParty();
    this.addParentPanel(panel);
    this.playerTouched = false;

    LabelStyle lsBig = new LabelStyle();
    lsBig.font = Assets.pixel22;/* ww w. j  a v  a2s .  c o  m*/

    lsMed = new LabelStyle();
    lsMed.font = Assets.pixel18;

    ls = new LabelStyle();
    ls.font = Assets.pixel16;

    lsG = new LabelStyle();
    lsG.font = Assets.pixel16;
    lsG.fontColor = Color.GRAY;

    Label garrisonC = new Label("Garrison:", ls);
    Label populationC = new Label("Pop:", ls);
    Label wealthC = new Label("Wealth:", ls);

    title = new Label(location.getName(), lsBig);
    title.setAlignment(0, 0);
    //      title.setWrap(true); // wrapping messes up click listeners... WTF?
    title.setWidth(SidePanel.WIDTH - PAD * 2 - MINI_PAD * 2);
    title.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            centerCamera();
        }
    });
    faction = new Label("", ls);
    faction.setAlignment(0, 0);
    faction.setText(location.getFactionName());
    type = new Label("", ls);
    type.setAlignment(Align.center); // large city, village, etc
    type.setText(location.getTypeStr());

    garrisonSize = new Label("", ls);
    garrisonSize.setWrap(false);
    population = new Label("", ls);
    wealth = new Label("", ls);

    // Create text
    text = new Table();
    //      text.debug();
    text.defaults().padTop(NEG).left();
    faction.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            setActiveFaction();
        }
    });
    text.add(title).colspan(4).center().padBottom(0);
    text.row();
    text.add().width((SidePanel.WIDTH - PAD * 2) / 4);
    text.add().width((SidePanel.WIDTH - PAD * 2) / 4);
    text.add().width((SidePanel.WIDTH - PAD * 2) / 4);
    text.add().width((SidePanel.WIDTH - PAD * 2) / 4);
    text.row();
    text.add(faction).colspan(4).fillX().expandX();
    text.row();
    text.add(type).colspan(4).fillX().expandX();
    text.row();
    text.add(garrisonC).colspan(2).padLeft(MINI_PAD);
    text.add(garrisonSize).colspan(2).center();
    text.row();
    text.add(populationC).padLeft(MINI_PAD);
    text.add(population).center();
    text.add(wealthC).padLeft(PAD);
    text.add(wealth).center();

    soldierTable = new Table();
    //soldierTable.debug();
    soldierTable.defaults().padTop(NEG);
    soldierTable.top();
    soldierTable.setBackground(
            new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r)));
    text.row();
    text.add().colspan(4).padBottom(PAD);
    text.row();

    soldierPane = new ScrollPane(soldierTable);
    soldierPane.setScrollbarsOnTop(true);
    soldierPane.setFadeScrollBars(false);
    text.add(soldierPane).colspan(4).top().padTop(0);

    text.row();

    // Soldier's stats
    stats = new Table();
    stats.setVisible(false);

    Label levelSC = new Label("Level:", ls);
    Label expSC = new Label("Exp:", ls);
    Label nextSC = new Label("Next:", ls);
    Label atkSC = new Label("Atk:", ls);
    Label defSC = new Label("Def:", ls);
    Label spdSC = new Label("Spd:", ls);
    Label weaponSC = new Label("Weapon: ", ls);
    Label equipmentSC = new Label("Armor: ", ls);

    nameS = new Label("", ls);
    nameS.setAlignment(0, 0);
    levelS = new Label("", ls);
    expS = new Label("", ls);
    nextS = new Label("", ls);
    atkS = new Label("", ls);
    defS = new Label("", ls);
    spdS = new Label("", ls);
    weaponS = new Label("", ls);
    equipmentS = new Label("", ls);

    stats.defaults().left().padTop(NEG);
    stats.add(nameS).colspan(4).width(SidePanel.WIDTH - PAD * 2).fillX().expandX().padBottom(MINI_PAD);
    stats.row();
    stats.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    stats.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    stats.row();
    stats.add(levelSC).padLeft(MINI_PAD);
    stats.add(levelS);
    stats.add(atkSC).padLeft(PAD);
    stats.add(atkS);
    stats.row();
    stats.add(expSC).padLeft(MINI_PAD);
    stats.add(expS);
    stats.add(defSC).padLeft(PAD);
    stats.add(defS);
    stats.row();
    stats.add(nextSC).padLeft(MINI_PAD);
    stats.add(nextS);
    stats.add(spdSC).padLeft(PAD);
    stats.add(spdS);
    stats.row();
    stats.add(weaponSC).colspan(2).padLeft(MINI_PAD).padTop(0);
    stats.add(weaponS).colspan(2).padTop(0);
    stats.row();
    stats.add(equipmentSC).colspan(2).padLeft(MINI_PAD).padTop(0).top();
    stats.add(equipmentS).colspan(2).padTop(0);

    //stats.debug();

    text.add(stats).colspan(4).padTop(PAD);

    text.padLeft(MINI_PAD);
    this.addTopTable(text);

    playerIn = false;
    //      this.hireMode = false;
    this.panelHire = new PanelHire(panel, location);

    this.setButton(4, "Back");
}

From source file:kyle.game.besiege.panels.PanelParty.java

License:Open Source License

public PanelParty(SidePanel panel, Army army) {
    this.panel = panel;
    this.army = army;
    this.party = army.getParty();
    this.addParentPanel(panel);

    LabelStyle lsBig = new LabelStyle();
    lsBig.font = Assets.pixel24;// w  w w  .jav a 2s . c  o  m

    LabelStyle lsFaction = new LabelStyle();
    lsFaction.font = Assets.pixel18;

    ls = new LabelStyle();
    ls.font = Assets.pixel16;

    lsG = new LabelStyle();
    lsG.font = Assets.pixel16;
    lsG.fontColor = Color.GRAY;

    lsY = new LabelStyle();
    lsY.font = Assets.pixel16;
    lsY.fontColor = Color.YELLOW;

    Label sizeC = new Label("Size:", ls);
    Label moraleC = new Label("Morale:", ls);
    Label moneyC = new Label("Money:", ls);
    Label atkC = new Label("Atk:", ls);
    Label defC = new Label("Def:", ls);
    Label spdC = new Label("Spd:", ls);

    title = new Label("", lsBig);
    title.setAlignment(0, 0);
    title.setWrap(true);
    title.setWidth(SidePanel.WIDTH - PAD * 2 - MINI_PAD * 2);
    faction = new Label("", lsFaction);
    faction.setAlignment(0, 0);

    // testing
    title.setText(army.getName());

    faction.setText(army.getFactionName());

    faction.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            setActiveFaction();
        }
    });
    action = new Label("", ls);
    action.setWrap(true);
    action.setAlignment(Align.center);
    size = new Label("", ls);
    morale = new Label("", ls);
    money = new Label("", ls);
    atk = new Label("", ls);
    def = new Label("", ls);
    spd = new Label("", ls);

    // Create text
    text = new Table();
    //text.debug();
    text.defaults().padTop(NEG).left();

    title.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            centerCamera();
        }
    });
    text.add(title).colspan(4).fillX().expandX().padBottom(0);
    text.row();
    text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    text.row();
    text.add(faction).colspan(4).padBottom(MINI_PAD).fillX().expandX();
    text.row();
    text.add(action).colspan(4).padBottom(MINI_PAD).fillX().expandX();
    text.row();
    text.add(sizeC).padLeft(MINI_PAD);
    text.add(size);
    text.add(atkC).padLeft(PAD);
    text.add(atk);
    text.row();
    text.add(moraleC).padLeft(MINI_PAD);
    text.add(morale);
    text.add(defC).padLeft(PAD);
    text.add(def);
    text.row();
    text.add(moneyC).padLeft(MINI_PAD);
    text.add(money);
    text.add(spdC).padLeft(PAD);
    text.add(spd);

    soldierTable = new Table();
    //soldierTable.debug();
    soldierTable.defaults().padTop(NEG);
    soldierTable.top();
    soldierTable.setBackground(
            new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r)));
    text.row();
    text.add().colspan(4).padBottom(PAD);
    text.row();

    soldierPane = new ScrollPane(soldierTable);
    soldierPane.setScrollbarsOnTop(true);
    soldierPane.setFadeScrollBars(false);
    text.add(soldierPane).colspan(4).top().padTop(0);

    text.row();

    // Soldier's stats
    stats = new Table();
    stats.setVisible(false);

    Label levelSC = new Label("Level:", ls);
    Label expSC = new Label("Exp:", ls);
    Label nextSC = new Label("Next:", ls);
    Label atkSC = new Label("Atk:", ls);
    Label defSC = new Label("Def:", ls);
    Label spdSC = new Label("Spd:", ls);
    Label weaponSC = new Label("Weapon: ", ls);
    Label equipmentSC = new Label("Armor: ", ls);

    nameS = new Label("", ls);
    nameS.setAlignment(0, 0);
    levelS = new Label("", ls);
    expS = new Label("", ls);
    nextS = new Label("", ls);
    atkS = new Label("", ls);
    defS = new Label("", ls);
    spdS = new Label("", ls);
    weaponS = new Label("", ls);
    equipmentS = new Label("", ls);

    stats.defaults().left().padTop(NEG);
    stats.add(nameS).colspan(4).width(SidePanel.WIDTH - PAD * 2).fillX().expandX().padBottom(MINI_PAD);
    stats.row();
    stats.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    stats.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    stats.row();
    stats.add(levelSC).padLeft(MINI_PAD);
    stats.add(levelS);
    stats.add(atkSC).padLeft(PAD);
    stats.add(atkS);
    stats.row();
    stats.add(expSC).padLeft(MINI_PAD);
    stats.add(expS);
    stats.add(defSC).padLeft(PAD);
    stats.add(defS);
    stats.row();
    stats.add(nextSC).padLeft(MINI_PAD);
    stats.add(nextS);
    stats.add(spdSC).padLeft(PAD);
    stats.add(spdS);
    stats.row();
    stats.add(weaponSC).colspan(2).padLeft(MINI_PAD).padTop(0);
    stats.add(weaponS).colspan(2).padTop(0);
    stats.row();
    stats.add(equipmentSC).colspan(2).padLeft(MINI_PAD).padTop(0).top();
    stats.add(equipmentS).colspan(2).padTop(0);

    //stats.debug();

    text.add(stats).colspan(4).padTop(PAD);

    this.addTopTable(text);

    if (this.army == panel.getPlayer()) {
        this.setButton(1, "Upgrades");
        this.setButton(2, "Inventory");
        this.setButton(3, "Character");
    }
    playerTouched = false;

    updateSoldierTable();

    if (!this.party.player)
        this.setButton(4, "Back");
}

From source file:kyle.game.besiege.panels.PanelUpgrades.java

License:Open Source License

public PanelUpgrades(SidePanel panel, Army army) {
    this.panel = panel;
    this.army = army;
    this.party = army.getParty();
    this.addParentPanel(panel);

    LabelStyle lsBig = new LabelStyle();
    lsBig.font = Assets.pixel24;// ww  w  . jav  a 2 s  .  c om

    LabelStyle lsMB = new LabelStyle();
    lsMB.font = Assets.pixel22;

    LabelStyle lsMed = new LabelStyle();
    lsMed.font = Assets.pixel18;

    LabelStyle lsSmall = new LabelStyle();
    lsSmall.font = Assets.pixel14;

    LabelStyle lsMicro = new LabelStyle();
    lsMicro.font = Assets.pixel14;

    ls = new LabelStyle();
    ls.font = Assets.pixel16;

    Label sizeC = new Label("Size:", ls);
    Label moraleC = new Label("Morale:", ls);
    Label moneyC = new Label("Money:", ls);
    Label atkC = new Label("Atk:", ls);
    Label defC = new Label("Def:", ls);
    Label spdC = new Label("Spd:", ls);

    title = new Label("Upgrades", lsBig);
    title.setAlignment(0, 0);
    title.setWrap(true);
    title.setWidth(SidePanel.WIDTH - PAD * 2 - MINI_PAD * 2);
    faction = new Label("", lsMed);
    faction.setAlignment(0, 0);
    size = new Label("", ls);
    morale = new Label("", ls);
    money = new Label("", ls);
    atk = new Label("", ls);
    def = new Label("", ls);
    spd = new Label("", ls);

    // Create text
    text = new Table();
    //text.debug();
    text.defaults().padTop(NEG).left();

    text.add(title).colspan(4).fillX().expandX().padBottom(MINI_PAD);
    text.row();
    text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    text.add().colspan(2).width((SidePanel.WIDTH - PAD * 2) / 2);
    text.row();
    text.add(faction).colspan(4).padBottom(MINI_PAD).fillX().expandX();
    text.row();
    text.add(sizeC).padLeft(MINI_PAD);
    text.add(size);
    text.add(atkC).padLeft(PAD);
    text.add(atk);
    text.row();
    text.add(moraleC).padLeft(MINI_PAD);
    text.add(morale);
    text.add(defC).padLeft(PAD);
    text.add(def);
    text.row();
    text.add(moneyC).padLeft(MINI_PAD);
    text.add(money);
    text.add(spdC).padLeft(PAD);
    text.add(spd);

    soldierTable = new Table();
    //soldierTable.debug();
    soldierTable.defaults().padTop(NEG);
    soldierTable.top();
    soldierTable.setBackground(
            new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(tablePatch), r, r, r, r)));
    text.row();
    text.add().colspan(4).padBottom(PAD);
    text.row();

    soldierPane = new ScrollPane(soldierTable);
    soldierPane.setScrollbarsOnTop(true);
    soldierPane.setFadeScrollBars(false);
    text.add(soldierPane).colspan(4).top().padTop(0);

    text.row();

    // Soldier's stats
    upgrades = new Table();
    upgrades.setVisible(false);
    upgrades.padLeft(MINI_PAD);

    Label equippedSC = new Label("Equipped with:", lsMed);
    equippedSC.setAlignment(0, 0);
    Label upgradeSC = new Label("Upgrade with:", lsMed);
    upgradeSC.setAlignment(0, 0);

    nameS = new Label("", lsMB);
    nameS.setAlignment(0, 0);
    upgradeS = new Label("", ls);
    upgradeS.setAlignment(0, 0);
    naturalS = new Label("", ls);
    naturalS.setAlignment(0, 0);
    equippedS = new Label("", lsMed);
    equippedStatsS = new Label("", ls);
    upgrade1S = new Label("", lsMicro);
    upgrade2S = new Label("", lsMicro);
    upgrade3S = new Label("", lsMicro);
    upgrade1S.setTouchable(Touchable.disabled);
    upgrade2S.setTouchable(Touchable.disabled);
    upgrade3S.setTouchable(Touchable.disabled);
    upgrade1StatsS = new Label("", lsSmall);
    upgrade2StatsS = new Label("", lsSmall);
    upgrade3StatsS = new Label("", lsSmall);
    upgrade1StatsS.setWrap(true);
    upgrade2StatsS.setWrap(true);
    upgrade3StatsS.setWrap(true);
    //      upgrade1StatsS.setAlignment(Align.right,Align.right);
    //      upgrade2StatsS.setAlignment(Align.right,Align.right);
    //      upgrade3StatsS.setAlignment(Align.right,Align.right);

    ButtonStyle bs = new ButtonStyle();
    bs = new ButtonStyle();
    bs.up = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(upTexture), r, r, r, r));
    bs.down = new NinePatchDrawable(new NinePatch(Assets.atlas.findRegion(downTexture), r, r, r, r));
    bs.pressedOffsetX = OFFSET;
    bs.pressedOffsetY = -OFFSET;

    up1B = new WeaponButton(upgrade1S, bs, null);
    up1B.addListener(new ClickListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            upgradeCurrent(((WeaponButton) event.getTarget()).weapon);
        }
    });
    up2B = new WeaponButton(upgrade2S, bs, null);
    up2B.addListener(new ClickListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            upgradeCurrent(((WeaponButton) event.getTarget()).weapon);
        }
    });
    up3B = new WeaponButton(upgrade3S, bs, null);
    up3B.addListener(new ClickListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            upgradeCurrent(((WeaponButton) event.getTarget()).weapon);
        }
    });
    up1B.setVisible(false);
    up2B.setVisible(false);
    up3B.setVisible(false);

    upgrades.defaults().left();
    upgrades.add(nameS).colspan(2).width(SidePanel.WIDTH - PAD * 2).fillX().expandX();
    //      upgrades.row();
    //      upgrades.add(equippedSC).fillX().expandX();
    //      upgrades.row();
    //      upgrades.add(equippedS).left();
    //      upgrades.row();
    //      upgrades.add(equippedStatsS).padTop(NEG);
    upgrades.row();
    upgrades.add(upgradeS).padBottom(NEG).expandX().fillX().colspan(2);
    upgrades.row();
    upgrades.add(naturalS).padBottom(MINI_PAD).expandX().fillX().colspan(2);
    upgrades.row();
    upgrades.add(upgradeSC).fillX().expandX().padBottom(MINI_PAD).colspan(2);
    upgrades.row();
    upgrades.add(up1B).padRight(MINI_PAD).fillX().padBottom(MINI_PAD).padTop(MINI_PAD);
    upgrades.add(upgrade1StatsS).fillX().expandX();
    upgrades.row();
    upgrades.add(up2B).padRight(MINI_PAD).fillX().padTop(MINI_PAD).padBottom(MINI_PAD);
    upgrades.add(upgrade2StatsS).fillX().expandX();
    upgrades.row();
    upgrades.add(up3B).padRight(MINI_PAD).fillX().padTop(MINI_PAD).padTop(MINI_PAD);
    upgrades.add(upgrade3StatsS).fillX().expandX();

    //upgrades.debug();

    text.add(upgrades).colspan(4).padTop(PAD);

    this.addTopTable(text);

    //      this.addButton(null);
    //      this.addButton(null);
    //
    //      this.addButton(null);
    this.setButton(4, "Back");
}

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

License:Apache License

/**
 * @param widget//from  ww w  .  j  a  v a  2s.co  m
 * @param name
 * @return
 */
public static ScrollPane flickScrollPane(Actor widget, String name) {
    if (S3Constans.INFO) {
        S3Log.log(TAG, "Create FlickScrollPane: " + name);
    }
    ScrollPane scrollPane = new ScrollPane(widget);
    scrollPane.setFlickScroll(true);
    scrollPane.setName(name);
    return scrollPane;
}

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

License:Apache License

/**
 * @param region//www . j a va  2  s  . c om
 * @param name
 * @return
 */
public static ScrollPane flickScrollPane(TextureRegion region, String name) {
    if (S3Constans.INFO) {
        S3Log.log(TAG, "Create FlickScrollPane: " + name);
    }
    ScrollPane scrollPane = new ScrollPane(new Image(region));
    scrollPane.setFlickScroll(true);
    scrollPane.setName(name);
    return scrollPane;
}

From source file:net.ivang.axonix.main.screens.LevelsScreen.java

License:Apache License

@Inject
private LevelsScreen(final AxonixGame game, InputMultiplexer inputMultiplexer, EventBus eventBus) {
    super(game, inputMultiplexer, eventBus);

    levelsTable = new Table();

    for (int levelNumber = 1; levelNumber <= game.getLevelsFiles().size(); levelNumber++) {
        LevelButton button = new LevelButton(levelNumber, style.button, eventBus);
        levelsTable.add(button);/*from   ww w  .  java 2s .  c  o  m*/
        if (levelNumber % LEVELS_TABLE_COLS == 0) {
            levelsTable.row();
        }
    }

    ScrollPane scrollPane = new ScrollPane(levelsTable);
    scrollPane.setFillParent(true);
    stage.addActor(scrollPane);
}

From source file:net.noviden.towerdefense.MapEditor.MapEditorSelectorScreen.java

License:Open Source License

public MapEditorSelectorScreen(final TowerDefense towerDefense) {
    this.towerDefense = towerDefense;

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

    Texture texture = new Texture(Gdx.files.internal("selectedMap.png"));
    _selectedMapIdentifierImage = new Image(texture);

    stage = new Stage();

    rootTable = new Table();
    rootTable.setFillParent(true);// w w w  .j a  v  a  2 s.  c  o m

    Table containerTable = new Table();
    _mapListTable = new Table();

    updateMapList();

    ScrollPane scrollPane = new ScrollPane(_mapListTable);
    scrollPane.layout();
    scrollPane.setFadeScrollBars(false);

    Table operationsTable = new Table();
    TextButton createButton = new TextButton("Create", skin);
    TextButton selectButton = new TextButton("Edit", skin);
    TextButton cloneButton = new TextButton("Clone", skin);
    TextButton deleteButton = new TextButton("Delete", skin);

    TextButton exitButton = new TextButton("Main Menu", skin);

    Label screenTitleLabel = new Label("Map Editor Browser", skin);

    containerTable.add(scrollPane).fillX().fillY();

    operationsTable.add(screenTitleLabel).pad(5.0f);
    operationsTable.add(createButton).pad(5.0f);
    operationsTable.add(selectButton).pad(5.0f);
    operationsTable.add(cloneButton).pad(5.0f);
    operationsTable.add(deleteButton).pad(5.0f);
    operationsTable.add(exitButton).pad(5.0f);

    rootTable.add(operationsTable).expandY().top().expandX().right();
    rootTable.row();
    rootTable.add(containerTable).top();
    rootTable.center();

    stage.addActor(rootTable);

    Gdx.input.setInputProcessor(stage);

    // set up input listeners
    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MainMenuScreen(towerDefense));
        }
    });

    createButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MapCreatorScreen(towerDefense));
        }
    });

    selectButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (_selectedMap != null)
                towerDefense.setScreen(new MapEditorScreen(towerDefense, _selectedMap));
        }
    });

    cloneButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (_selectedMap != null) {
                towerDefense.maps.add(_selectedMap.clone());
                updateMapList();
            }
        }
    });

    deleteButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (_selectedMap != null) {
                towerDefense.maps.remove(_selectedMap);
                updateMapList();

                _selectedMap = null;
            }
        }
    });
}

From source file:net.noviden.towerdefense.Screens.GameSettingsScreen.java

License:Open Source License

public GameSettingsScreen(final TowerDefense pTowerDefense) {
    _towerDefense = pTowerDefense;/*from  www . j a v  a 2s .c om*/

    _modifiedKeyboardShortcutsMap = new HashMap<Integer, GameSettings.Actions>();

    _currentlySelectedActionLabel = null;
    _currentlySelectedShortcut = null;
    _previouslySelectedKey = -1;

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

    _mainStage = new Stage();

    Table rootTable = new Table();
    rootTable.setFillParent(true);

    _mainStage.addActor(rootTable);

    // set up ui elements
    Label musicVolumeLabel = new Label("Music Volume", skin);
    final Slider musicVolumeSlider = new Slider(0.0f, 1.0f, 0.1f, false, skin);
    musicVolumeSlider.setValue(GameSettings.getMusicVolume());

    Label sfxVolumeLabel = new Label("Sound Effects Volume", skin);
    final Slider sfxVolumeSlider = new Slider(0.0f, 1.0f, 0.1f, false, skin);
    sfxVolumeSlider.setValue(GameSettings.getSoundVolume());

    Table volumeTable = new Table();
    volumeTable.add(musicVolumeLabel);
    volumeTable.add(musicVolumeSlider);
    volumeTable.row();
    volumeTable.add(sfxVolumeLabel);
    volumeTable.add(sfxVolumeSlider).pad(8.0f);

    Table keyboardShortcutsTable = new Table();

    HashMap<Integer, GameSettings.Actions> currentShortcutMap = GameSettings.getShortcutMap();

    // for sorting the settings on screen
    Collection<GameSettings.Actions> values = currentShortcutMap.values();
    ArrayList<String> valueNames = new ArrayList<String>();
    for (GameSettings.Actions action : values) {
        valueNames.add(action.toString());
    }

    Collections.sort(valueNames);

    for (String s : valueNames) {
        final Label actionLabel = new Label(s, skin);
        final TextButton shortcutButton = new TextButton(
                Input.Keys.toString(GameSettings.getReverse(GameSettings.Actions.valueOf(s))), skin);

        keyboardShortcutsTable.add(actionLabel).pad(10.0f);
        keyboardShortcutsTable.add(shortcutButton);
        keyboardShortcutsTable.row();

        shortcutButton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {

                if (_currentlySelectedShortcut == null) {
                    _currentlySelectedActionLabel = actionLabel;
                    _currentlySelectedShortcut = shortcutButton;
                    _previouslySelectedKey = Input.Keys.valueOf(shortcutButton.getText().toString());

                    shortcutButton.setText("Press any un-set key!");
                }
            }
        });
    }

    ScrollPane keyboardShortcutsScrollPane = new ScrollPane(keyboardShortcutsTable);
    keyboardShortcutsScrollPane.layout();

    // add in save and exit buttons
    Table exitFunctionalityTable = new Table();

    TextButton saveAndExitButton = new TextButton("Save and Exit", skin);
    TextButton exitWithoutSavingButton = new TextButton("Exit Without Saving", skin);

    exitFunctionalityTable.add(saveAndExitButton).pad(10.0f);
    exitFunctionalityTable.add(exitWithoutSavingButton);

    // finally, construct display table
    rootTable.add(volumeTable);
    rootTable.row();
    rootTable.add(keyboardShortcutsScrollPane);
    rootTable.row();
    rootTable.add(exitFunctionalityTable);

    InputMultiplexer multiplexer = new InputMultiplexer(_mainStage, new MyInputProcessor());

    Gdx.input.setInputProcessor(multiplexer);

    // add in event listeners here

    exitWithoutSavingButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            _towerDefense.setScreen(new net.noviden.towerdefense.Screens.MainMenuScreen(_towerDefense));
        }
    });

    saveAndExitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            // attempt to save settings

            GameSettings.setMusicVolume(musicVolumeSlider.getPercent());

            GameSettings.setSoundVolume(sfxVolumeSlider.getPercent());

            // save keyboard shortcuts
            GameSettings.putShortcuts(_modifiedKeyboardShortcutsMap);

            // return to main menu
            _towerDefense.setScreen(new net.noviden.towerdefense.Screens.MainMenuScreen(_towerDefense));

            dispose();
        }
    });
}