public SDLBitmapDrawableAdapter(int width, int height) {
   try {
     this.surface =
         SDLVideo.createRGBSurface(
             SDLVideo.SDL_SWSURFACE,
             width,
             height,
             24,
             0x000000FF,
             0x0000FF00,
             0x00FF0000,
             0xFF000000);
   } catch (SDLException e) {
     // TODO: Exception handling
   }
 }
Example #2
0
  /** Update title bar text */
  public void updateTitleBarCaption() {
    String strTitle = "NullpoMino - " + modeName;

    if ((gameManager != null)
        && (gameManager.engine != null)
        && (gameManager.engine.length > 0)
        && (gameManager.engine[0] != null)) {
      if (pause && !enableframestep) strTitle = "[PAUSE] NullpoMino - " + modeName;
      else if (gameManager.engine[0].isInGame
          && !gameManager.replayMode
          && !gameManager.replayRerecord) strTitle = "[PLAY] NullpoMino - " + modeName;
      else if (gameManager.replayMode && gameManager.replayRerecord)
        strTitle = "[RERECORD] NullpoMino - " + modeName;
      else if (gameManager.replayMode && !gameManager.replayRerecord)
        strTitle = "[REPLAY] NullpoMino - " + modeName;
      else strTitle = "[MENU] NullpoMino - " + modeName;
    }

    SDLVideo.wmSetCaption(strTitle, null);
  }
Example #3
0
  /**
   * リプレイを読み込んで再生
   *
   * @param prop リプレイ dataの入ったプロパティセット
   */
  public void startReplayGame(CustomProperties prop) {
    gameManager = new GameManager(new RendererSDL());
    gameManager.replayMode = true;
    gameManager.replayProp = prop;
    pause = false;

    try {
      gameManager.receiver.setGraphics(SDLVideo.getVideoSurface());
    } catch (SDLException e) {
      log.warn("SDLException throwed", e);
    }

    // Mode
    modeName = prop.getProperty("name.mode", "");
    GameMode modeObj = NullpoMinoSDL.modeManager.getMode(modeName);
    if (modeObj == null) {
      log.warn("Couldn't find mode:" + modeName);
    } else {
      gameManager.mode = modeObj;
    }

    gameManager.init();

    // Initialization for each player
    for (int i = 0; i < gameManager.getPlayers(); i++) {
      // ルール
      RuleOptions ruleopt = new RuleOptions();
      ruleopt.readProperty(prop, i);
      gameManager.engine[i].ruleopt = ruleopt;

      // NEXT順生成アルゴリズム
      if ((ruleopt.strRandomizer != null) && (ruleopt.strRandomizer.length() > 0)) {
        Randomizer randomizerObject = GeneralUtil.loadRandomizer(ruleopt.strRandomizer);
        gameManager.engine[i].randomizer = randomizerObject;
      }

      // Wallkick
      if ((ruleopt.strWallkick != null) && (ruleopt.strWallkick.length() > 0)) {
        Wallkick wallkickObject = GeneralUtil.loadWallkick(ruleopt.strWallkick);
        gameManager.engine[i].wallkick = wallkickObject;
      }

      // AI (リプレイ追記用)
      String aiName = NullpoMinoSDL.propGlobal.getProperty(i + ".ai", "");
      if (aiName.length() > 0) {
        DummyAI aiObj = GeneralUtil.loadAIPlayer(aiName);
        gameManager.engine[i].ai = aiObj;
        gameManager.engine[i].aiMoveDelay =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiMoveDelay", 0);
        gameManager.engine[i].aiThinkDelay =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiThinkDelay", 0);
        gameManager.engine[i].aiUseThread =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiUseThread", true);
        gameManager.engine[i].aiShowHint =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiShowHint", false);
        gameManager.engine[i].aiPrethink =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiPrethink", false);
        gameManager.engine[i].aiShowState =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiShowState", false);
      }
      gameManager.showInput = NullpoMinoSDL.propConfig.getProperty("option.showInput", false);

      // Called at initialization
      gameManager.engine[i].init();
    }

    updateTitleBarCaption();
  }
Example #4
0
  /**
   * Start a new game
   *
   * @param strRulePath Rule file path (null if you want to use user-selected one)
   */
  public void startNewGame(String strRulePath) {
    gameManager = new GameManager(new RendererSDL());
    pause = false;

    try {
      gameManager.receiver.setGraphics(SDLVideo.getVideoSurface());
    } catch (SDLException e) {
      log.warn("SDLException throwed", e);
    }

    // Mode
    modeName = NullpoMinoSDL.propGlobal.getProperty("name.mode", "");
    GameMode modeObj = NullpoMinoSDL.modeManager.getMode(modeName);
    if (modeObj == null) {
      log.warn("Couldn't find mode:" + modeName);
    } else {
      gameManager.mode = modeObj;
    }

    gameManager.init();

    // Initialization for each player
    for (int i = 0; i < gameManager.getPlayers(); i++) {
      // チューニング設定
      gameManager.engine[i].owRotateButtonDefaultRight =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owRotateButtonDefaultRight", -1);
      gameManager.engine[i].owSkin = NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owSkin", -1);
      gameManager.engine[i].gSkin =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.gSkin", gameManager.engine[i].owSkin);
      gameManager.engine[i].owMinDAS =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owMinDAS", -1);
      gameManager.engine[i].owMaxDAS =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owMaxDAS", -1);
      gameManager.engine[i].owDasDelay =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owDasDelay", -1);
      gameManager.engine[0].owReverseUpDown =
          NullpoMinoSDL.propGlobal.getProperty(0 + ".tuning.owReverseUpDown", false);
      gameManager.engine[i].owMoveDiagonal =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owMoveDiagonal", -1);
      gameManager.engine[i].owBlockOutlineType =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owBlockOutlineType", -1);
      gameManager.engine[i].owBlockShowOutlineOnly =
          NullpoMinoSDL.propGlobal.getProperty(i + ".tuning.owBlockShowOutlineOnly", -1);

      // ルール
      RuleOptions ruleopt = null;
      String rulename = strRulePath;
      if (rulename == null) {
        rulename = NullpoMinoSDL.propGlobal.getProperty(i + ".rule", "");
        if (gameManager.mode.getGameStyle() > 0) {
          rulename =
              NullpoMinoSDL.propGlobal.getProperty(
                  i + ".rule." + gameManager.mode.getGameStyle(), "");
        }
      }
      if ((rulename != null) && (rulename.length() > 0)) {
        log.debug("Load rule options from " + rulename);
        ruleopt = GeneralUtil.loadRule(rulename);
      } else {
        log.debug("Load rule options from setting file");
        ruleopt = new RuleOptions();
        ruleopt.readProperty(NullpoMinoSDL.propGlobal, i);
      }
      gameManager.engine[i].ruleopt = ruleopt;

      // NEXT順生成アルゴリズム
      if ((ruleopt.strRandomizer != null) && (ruleopt.strRandomizer.length() > 0)) {
        Randomizer randomizerObject = GeneralUtil.loadRandomizer(ruleopt.strRandomizer);
        gameManager.engine[i].randomizer = randomizerObject;
      }

      // Wallkick
      if ((ruleopt.strWallkick != null) && (ruleopt.strWallkick.length() > 0)) {
        Wallkick wallkickObject = GeneralUtil.loadWallkick(ruleopt.strWallkick);
        gameManager.engine[i].wallkick = wallkickObject;
      }

      // AI
      String aiName = NullpoMinoSDL.propGlobal.getProperty(i + ".ai", "");
      if (aiName.length() > 0) {
        DummyAI aiObj = GeneralUtil.loadAIPlayer(aiName);
        gameManager.engine[i].ai = aiObj;
        gameManager.engine[i].aiMoveDelay =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiMoveDelay", 0);
        gameManager.engine[i].aiThinkDelay =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiThinkDelay", 0);
        gameManager.engine[i].aiUseThread =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiUseThread", true);
        gameManager.engine[i].aiShowHint =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiShowHint", false);
        gameManager.engine[i].aiPrethink =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiPrethink", false);
        gameManager.engine[i].aiShowState =
            NullpoMinoSDL.propGlobal.getProperty(i + ".aiShowState", false);
      }
      gameManager.showInput = NullpoMinoSDL.propConfig.getProperty("option.showInput", false);

      // Called at initialization
      gameManager.engine[i].init();
    }

    updateTitleBarCaption();
  }