예제 #1
0
파일: Engine.java 프로젝트: Eway/whereigo
  /** prepares Lua state and some bookkeeping */
  protected void prepareState() throws IOException {
    ui.debugMsg("Creating state...\n");
    state = new LuaState(System.out);

    /*write("Registering base libs...\n");
    BaseLib.register(state);
    MathLib.register(state);
    StringLib.register(state);
    CoroutineLib.register(state);
    OsLib.register(state);*/

    ui.debugMsg("Building javafunc map...\n");
    savegame.buildJavafuncMap(state.getEnvironment());

    ui.debugMsg("Loading stdlib...");
    InputStream stdlib = getClass().getResourceAsStream("/cz/matejcik/openwig/stdlib.lbc");
    LuaClosure closure = LuaPrototype.loadByteCode(stdlib, state.getEnvironment());
    ui.debugMsg("calling...\n");
    state.call(closure, null, null, null);
    stdlib.close();
    stdlib = null;

    ui.debugMsg("Registering WIG libs...\n");
    WherigoLib.register(state);

    ui.debugMsg("Building event queue...\n");
    eventRunner = new BackgroundRunner(true);
    eventRunner.setQueueListener(
        new Runnable() {
          public void run() {
            ui.refresh();
          }
        });
  }
예제 #2
0
파일: Engine.java 프로젝트: Eway/whereigo
 public void run() {
   // perform the actual sync
   try {
     ui.blockForSaving();
     savegame.store(state.getEnvironment());
   } catch (IOException e) {
     log("STOR: save failed: " + e.toString(), LOG_WARN);
     ui.showError("Sync failed.\n" + e.getMessage());
   } finally {
     ui.unblock();
   }
 }
예제 #3
0
파일: Engine.java 프로젝트: Eway/whereigo
 /** invokes game restore */
 private void restoreGame() throws IOException {
   ui.debugMsg("Restoring saved state...");
   cartridge = new Cartridge();
   savegame.restore(state.getEnvironment());
 }