Exemple #1
0
 void startGame(final int which, final String savedGame) {
   Log.d(
       TAG,
       "startGame: "
           + which
           + ", "
           + ((savedGame == null) ? "null" : (savedGame.length() + " bytes")));
   if (progress != null) {
     Log.e(TAG, "startGame while already starting!");
     return;
   }
   showProgress((savedGame == null) ? R.string.starting : R.string.resuming);
   if (gameRunning) {
     gameView.clear();
     stopNative();
     solveEnabled = false;
     changedState(false, false);
     customVisible = false;
     setStatusBarVisibility(false);
   }
   if (ActionBarCompat.earlyHasActionBar() && !prefs.getBoolean(UNDO_REDO_KBD_KEY, false)) {
     maybeUndoRedo = "";
   }
   setKeys("", SmallKeyboard.ARROWS_LEFT_RIGHT_CLICK);
   if (typeMenu != null) for (Integer i : gameTypes.keySet()) typeMenu.removeItem(i);
   gameTypes.clear();
   gameRunning = true;
   gameView.keysHandled = 0;
   (worker =
           new Thread("startGame") {
             public void run() {
               init(gameView, which, savedGame);
               if (!gameRunning) return; // stopNative or abort was called
               helpTopic = htmlHelpTopic();
               handler.obtainMessage(MsgType.DONE.ordinal(), htmlHelpTopic()).sendToTarget();
             }
           })
       .start();
 }
Exemple #2
0
 void requestResize(int x, int y) {
   gameView.clear();
   gameViewResized();
 }
Exemple #3
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int itemId = item.getItemId();
   if (itemId == actionBarHomeId) itemId = R.id.other;
   switch (itemId) {
     case R.id.other:
       startChooser();
       break;
     case R.id.settings:
       startActivity(new Intent(this, PrefsActivity.class));
       break;
     case R.id.newgame:
       startNewGame();
       break;
     case R.id.restart:
       restartEvent();
       break;
     case R.id.undo:
       sendKey(0, 0, 'u');
       break;
     case R.id.redo:
       sendKey(0, 0, 'r');
       break;
     case R.id.solve:
       solveEvent();
       break;
     case R.id.custom:
       configIsCustom = true;
       configEvent(CFG_SETTINGS);
       break;
     case R.id.specific:
       configIsCustom = false;
       configEvent(CFG_DESC);
       break;
     case R.id.seed:
       configIsCustom = false;
       configEvent(CFG_SEED);
       break;
     case R.id.about:
       about();
       break;
     case R.id.contents:
       showHelp("index");
       break;
     case R.id.thisgame:
       showHelp(helpTopic);
       break;
     case R.id.website:
       startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.website_url))));
       break;
     case R.id.email:
       tryEmailAuthor(this, null);
       break;
     case R.id.load:
       new FilePicker(this, storageDir, false).show();
       break;
     case R.id.save:
       new FilePicker(this, storageDir, true).show();
       break;
     default:
       final int id = item.getItemId();
       if (gameTypes.get(id) != null) {
         showProgress(R.string.changing_type);
         gameView.clear();
         Log.d(TAG, "preset: " + id + ": " + gameTypes.get(id));
         (worker =
                 new Thread("presetGame") {
                   public void run() {
                     presetEvent(id);
                     handler.sendEmptyMessage(MsgType.DONE.ordinal());
                   }
                 })
             .start();
       } else super.onOptionsItemSelected(item);
       break;
   }
   return true;
 }