Search in sources :

Example 1 with GameAction

use of com.shatteredpixel.shatteredpixeldungeon.input.GameAction in project shattered-pixel-dungeon-gdx by 00-Evan.

the class StatusPane method createChildren.

@Override
protected void createChildren() {
    bg = new NinePatch(Assets.STATUS, 0, 0, 128, 36, 85, 0, 45, 0);
    add(bg);
    add(new TouchArea<GameAction>(0, 1, 31, 31) {

        @Override
        protected void onClick(NoosaInputProcessor.Touch touch) {
            Image sprite = Dungeon.hero.sprite;
            if (!sprite.isVisible()) {
                Camera.main.focusOn(sprite);
            }
            GameScene.show(new WndHero());
        }

        @Override
        public boolean onKeyUp(NoosaInputProcessor.Key<GameAction> key) {
            boolean handled = true;
            switch(key.action) {
                case HERO_INFO:
                    onClick(null);
                    break;
                case JOURNAL:
                    GameScene.show(new WndJournal());
                    break;
                default:
                    handled = false;
                    break;
            }
            return handled;
        }
    });
    btnJournal = new JournalButton();
    add(btnJournal);
    btnMenu = new MenuButton();
    add(btnMenu);
    avatar = HeroSprite.avatar(Dungeon.hero.heroClass, lastTier);
    add(avatar);
    compass = new Compass(Statistics.amuletObtained ? Dungeon.level.entrance : Dungeon.level.exit);
    add(compass);
    rawShielding = new Image(Assets.SHLD_BAR);
    rawShielding.alpha(0.5f);
    add(rawShielding);
    shieldedHP = new Image(Assets.SHLD_BAR);
    add(shieldedHP);
    hp = new Image(Assets.HP_BAR);
    add(hp);
    exp = new Image(Assets.XP_BAR);
    add(exp);
    bossHP = new BossHealthBar();
    add(bossHP);
    level = new BitmapText(PixelScene.pixelFont);
    level.hardlight(0xFFEBA4);
    add(level);
    depth = new BitmapText(Integer.toString(Dungeon.depth), PixelScene.pixelFont);
    depth.hardlight(0xCACFC2);
    depth.measure();
    add(depth);
    danger = new DangerIndicator();
    add(danger);
    buffs = new BuffIndicator(Dungeon.hero);
    add(buffs);
    add(pickedUp = new Toolbar.PickedUpItem());
}
Also used : WndJournal(com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal) NinePatch(com.watabou.noosa.NinePatch) Image(com.watabou.noosa.Image) WndHero(com.shatteredpixel.shatteredpixeldungeon.windows.WndHero) BitmapText(com.watabou.noosa.BitmapText) NoosaInputProcessor(com.watabou.input.NoosaInputProcessor) GameAction(com.shatteredpixel.shatteredpixeldungeon.input.GameAction)

Example 2 with GameAction

use of com.shatteredpixel.shatteredpixeldungeon.input.GameAction in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndKeymap method addKey.

private void addKey(Component content, int maxWidth, Map.Entry<GameAction, KeyPair> entry) {
    final GameAction action = entry.getKey();
    final ListItem keyItem = new ListItem(action, entry.getValue());
    keyItem.setRect(0, tempPos, maxWidth, ITEM_HEIGHT);
    tempPos += ITEM_HEIGHT;
    content.add(keyItem);
    items.put(action, keyItem);
}
Also used : GameAction(com.shatteredpixel.shatteredpixeldungeon.input.GameAction)

Example 3 with GameAction

use of com.shatteredpixel.shatteredpixeldungeon.input.GameAction in project shattered-pixel-dungeon-gdx by 00-Evan.

the class DesktopInputProcessor method resetKeyMappings.

@Override
public void resetKeyMappings() {
    keyMappings.clear();
    for (GameAction action : GameAction.values()) {
        KeyPair pair = DEFAULTS.get(action);
        if (pair != null) {
            setKeyMapping(action, pair.code1, pair.code2);
        } else {
            pair = new KeyPair();
        }
        SPDSettings.put(getPrefKey(action, true), pair.code1);
        SPDSettings.put(getPrefKey(action, false), pair.code2);
    }
}
Also used : GameAction(com.shatteredpixel.shatteredpixeldungeon.input.GameAction)

Example 4 with GameAction

use of com.shatteredpixel.shatteredpixeldungeon.input.GameAction in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndKeymap method populateList.

private void populateList() {
    listContent.clear();
    tempPos = 0;
    final PDInputProcessor inputProcessor = (PDInputProcessor) Game.instance.getInputProcessor();
    final Map<Integer, PDInputProcessor.GameActionWrapper> keyMappings = inputProcessor.getKeyMappings();
    final Map<GameAction, KeyPair> mappings = new TreeMap<>();
    for (GameAction action : GameAction.values()) {
        if (action.getDescription() != null) {
            mappings.put(action, new KeyPair());
        }
    }
    for (Map.Entry<Integer, PDInputProcessor.GameActionWrapper> entry : keyMappings.entrySet()) {
        final Integer key = entry.getKey();
        final PDInputProcessor.GameActionWrapper value = entry.getValue();
        final GameAction action = value.gameAction;
        final KeyPair keyPair = mappings.get(action);
        /*	if (keyPair == null) {
				mappings.put(action, keyPair = new KeyPair());
			}*/
        if (value.defaultKey) {
            keyPair.key1 = key;
        } else {
            keyPair.key2 = key;
        }
    }
    for (Map.Entry<GameAction, KeyPair> entry : mappings.entrySet()) {
        addKey(listContent, width, entry);
    }
    listContent.setSize(0, tempPos);
}
Also used : PDInputProcessor(com.shatteredpixel.shatteredpixeldungeon.input.PDInputProcessor) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) GameAction(com.shatteredpixel.shatteredpixeldungeon.input.GameAction)

Aggregations

GameAction (com.shatteredpixel.shatteredpixeldungeon.input.GameAction)4 PDInputProcessor (com.shatteredpixel.shatteredpixeldungeon.input.PDInputProcessor)1 WndHero (com.shatteredpixel.shatteredpixeldungeon.windows.WndHero)1 WndJournal (com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal)1 NoosaInputProcessor (com.watabou.input.NoosaInputProcessor)1 BitmapText (com.watabou.noosa.BitmapText)1 Image (com.watabou.noosa.Image)1 NinePatch (com.watabou.noosa.NinePatch)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1