Exemplo n.º 1
0
 public final void beforeLoop() throws Exception {
   final Pangine engine = Pangine.getEngine();
   initBeforeEngine();
   engine.init();
   engine.setIcon(
       "org/pandcorps/res/img/PandcorpsIcon32.png", "org/pandcorps/res/img/PandcorpsIcon16.png");
   init(); // Don't know why this happens after engine.init; can't set window size here; don't know
           // what steps should happen here; adding initBeforeEngine
 }
Exemplo n.º 2
0
 public final void start() throws Panception {
   final Pangine engine = Pangine.getEngine();
   try {
     beforeLoop();
     engine.loop();
   } catch (final Exception e) {
     fatal(engine);
     throw new Panception(e);
   } finally {
     destroy(engine);
   }
 }
Exemplo n.º 3
0
 private final void destroy(final Pangine engine) {
   try {
     engine.destroy();
   } catch (final Exception e) {
     // e.printStackTrace();
   }
 }
Exemplo n.º 4
0
 private final void fatal(final Pangine engine) {
   try {
     engine.exit();
   } catch (final Exception e) {
     // e.printStackTrace();
   }
 }
Exemplo n.º 5
0
 protected Panroom getFirstRoom() throws Exception {
   /*
   Games can override this and retrieve the first room however they want.
   They can throw UnsupportedOperationExceptions in getFirstRoomSize and init if they don't want to use them.
   Nothing else will.
   This method allows init to call methods that use Pangame.getCurrentRoom().
   If it's overridden, the game will need to be careful about that.
   */
   final Panroom room = Pangine.getEngine().createRoom(Pantil.vmid(), getFirstRoomSize());
   setCurrentRoomIfNeeded(room);
   init(room);
   return room;
 }
Exemplo n.º 6
0
 public final void recreate() throws Exception {
   Pangine.getEngine().recreate();
 }
Exemplo n.º 7
0
 protected static final void setSoundEnabled(final boolean soundEnabled) {
   Config.soundEnabled = soundEnabled;
   Pangine.getEngine().getAudio().setSoundEnabled(soundEnabled);
 }
Exemplo n.º 8
0
 protected static final void setMusicEnabled(final boolean musicEnabled) {
   Config.musicEnabled = musicEnabled;
   Pangine.getEngine().getAudio().setMusicEnabled(musicEnabled);
 }
Exemplo n.º 9
0
 @Override
 protected final void focus() {
   label.setCursorEnabled(true);
   initChr(buf.length());
   final Pangine engine = Pangine.getEngine();
   final Panput sub, adv, bak, up, down;
   if (ctrl == null) {
     final Panteraction in = engine.getInteraction();
     sub = in.KEY_ENTER;
     adv = in.KEY_SPACE;
     bak = in.KEY_ESCAPE;
     up = in.KEY_UP;
     down = in.KEY_DOWN;
   } else {
     sub = ctrl.getSubmit();
     adv = ctrl.get1();
     bak = ctrl.get2();
     up = ctrl.getUp();
     down = ctrl.getDown();
   }
   Panput.inactivate(sub, adv, bak, up, down);
   final ActionStartListener upListener =
       new ActionStartListener() {
         @Override
         public void onActionStart(final ActionStartEvent event) {
           if (value == chars.length) {
             value = 0;
             buf.append(' ');
           } else {
             value++;
           }
           if (value != chars.length) {
             buf.setCharAt(index, chars[value]);
           } else {
             buf.setLength(index);
           }
           change();
         }
       };
   final ActionStartListener downListener =
       new ActionStartListener() {
         @Override
         public void onActionStart(final ActionStartEvent event) {
           if (value == 0) {
             value = chars.length;
           } else {
             if (value == chars.length) {
               buf.append(' ');
             }
             value--;
           }
           if (value != chars.length) {
             buf.setCharAt(index, chars[value]);
           } else {
             buf.setLength(index);
           }
           change();
         }
       };
   final ActionStartListener advListener =
       new ActionStartListener() {
         @Override
         public void onActionStart(final ActionStartEvent event) {
           if (value != chars.length && (max <= 0 || buf.length() < max)) {
             initChr(index + 1);
           }
         }
       };
   final ActionStartListener bakListener =
       new ActionStartListener() {
         @Override
         public void onActionStart(final ActionStartEvent event) {
           if (index == 0) {
             return;
           } else if (value != chars.length) {
             buf.setLength(buf.length() - 1);
             change();
           }
           initChr(index - 1, getValue(buf.charAt(buf.length() - 1)));
         }
       };
   final ActionStartListener subListener =
       new ActionStartListener() {
         @Override
         public void onActionStart(final ActionStartEvent event) {
           close();
           sub.inactivate();
           submit();
         }
       };
   label.register(up, upListener);
   label.register(down, downListener);
   label.register(adv, advListener);
   label.register(bak, bakListener);
   label.register(sub, subListener);
 }