private void updateOtherTimer() {
      Label condTimerLabel = this.main.getCondTimerLabel();
      Text condTimerText = this.main.getCondTimerTime();

      CondTiming timing = GlobalContext.getCondTiming();
      Date nextUpdateTime = timing.getNextUpdateTime(this.now);

      // 疲労のある艦娘はいる?
      boolean needTimer = false;
      for (ShipDto ship : GlobalContext.getShipMap().values()) {
        if (ship.getCond() < 49) {
          needTimer = true;
          break;
        }
      }

      if (needTimer == false) {
        condTimerLabel.setText("");
        condTimerText.setToolTipText(null);
        condTimerText.setText("");
      } else if (nextUpdateTime == null) {
        condTimerLabel.setText("次の疲労回復まで");
        condTimerText.setToolTipText("十分な情報がありません");
        condTimerText.setText("???");
      } else {
        int accuracy = (int) timing.getCurrentAccuracy() / 2000;
        condTimerLabel.setText("次の疲労回復まで(±" + accuracy + "秒)");

        long rest = TimeLogic.getRest(this.now, nextUpdateTime);

        // ツールチップテキストで時刻を表示する
        condTimerText.setToolTipText(this.format.format(nextUpdateTime));
        condTimerText.setText(TimeLogic.toDateRestString(rest, true));
      }

      // 泊地修理タイマー
      Label akashiTimerLabel = this.main.getAkashiTimerLabel();
      Text akashiTimerText = this.main.getAkashiTimerTime();

      AkashiTimer akashiTimer = GlobalContext.getAkashiTimer();
      if (akashiTimer.getStartTime() == null) {
        // 不明
        akashiTimerText.setText("???");
        akashiTimerText.setToolTipText("十分な情報がありません");
        akashiTimerText.setBackground(ColorManager.getColor(SWT.COLOR_WHITE));
      } else {
        long elapsed = this.now.getTime() - akashiTimer.getStartTime().getTime();
        String time = TimeLogic.toDateRestString(elapsed / 1000, true);
        akashiTimerText.setText(time);
        akashiTimerText.setToolTipText(null);
        akashiTimerText.setBackground(ColorManager.getColor(AppConstants.AKASHI_REPAIR_COLOR));
      }
    }
 @Override
 public void run() {
   if (this.main.getShell().isDisposed()) {
     return;
   }
   Button itemList = this.main.getItemList();
   String setText =
       "所有装備(" + GlobalContext.getItemMap().size() + "/" + GlobalContext.maxSlotitem() + ")";
   if (!setText.equals(itemList.getText())) {
     itemList.setText(setText);
     itemList.getParent().layout();
   }
 }
    /**
     * 入渠を更新する
     *
     * @param now
     * @param notice
     * @return
     */
    private void updateNdock() {
      Map<Integer, ShipDto> shipMap = GlobalContext.getShipMap();

      Label[] ndockNameLabels = {
        this.main.getNdock1name(),
        this.main.getNdock2name(),
        this.main.getNdock3name(),
        this.main.getNdock4name()
      };
      Text[] ndockTimeTexts = {
        this.main.getNdock1time(),
        this.main.getNdock2time(),
        this.main.getNdock3time(),
        this.main.getNdock4time()
      };

      NdockDto[] ndocks = GlobalContext.getNdocks();

      for (int i = 0; i < ndocks.length; i++) {
        String name = "";
        String time = "";

        if (ndocks[i].getNdockid() != 0) {
          ShipDto ship = shipMap.get(ndocks[i].getNdockid());
          if (ship != null) {
            name = ship.getFriendlyName();
            long rest = TimeLogic.getRest(this.now, ndocks[i].getNdocktime());

            // ツールチップテキストで時刻を表示する
            ndockTimeTexts[i].setToolTipText(this.format.format(ndocks[i].getNdocktime()));

            // 20分前、10分前、5分前になったら背景色を変更する
            ndockTimeTexts[i].setBackground(getBackgroundColor(rest));

            // 通知生成
            this.updateNdockNotice(name, i, rest);

            time = TimeLogic.toDateRestString(rest);
            if (time == null) {
              time = "まもなくお風呂からあがります";
            }
          }
        } else {
          ndockTimeTexts[i].setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
          ndockTimeTexts[i].setToolTipText(null);
        }
        ndockNameLabels[i].setText(name);
        ndockTimeTexts[i].setText(time);
      }
    }
  /**
   * ドロップ報告書の内容
   *
   * @return 内容
   */
  public static List<String[]> getBattleResultBody() {
    List<BattleResultDto> results = GlobalContext.getBattleResultList();
    List<Object[]> body = new ArrayList<Object[]>();

    SimpleDateFormat format = new SimpleDateFormat(AppConstants.DATE_FORMAT);

    for (int i = 0; i < results.size(); i++) {
      BattleResultDto item = results.get(i);
      BattleDto battle = item.getBattle();

      body.add(
          new Object[] {
            Integer.toString(i + 1),
            format.format(item.getBattleDate()),
            item.getQuestName(),
            item.getMapCellNo(),
            item.getBossText(),
            item.getRank(),
            battle.getIntercept(),
            battle.getFriendFormation(),
            battle.getEnemyFormation(),
            item.getEnemyName(),
            item.getDropType(),
            item.getDropName()
          });
    }
    return toListStringArray(body);
  }
  /**
   * 任務一覧の内容
   *
   * @return
   */
  public static List<String[]> getQuestBody() {
    List<Object[]> body = new ArrayList<Object[]>();

    for (Entry<Integer, QuestDto> entry : GlobalContext.getQuest().entrySet()) {
      QuestDto quest = entry.getValue();

      String state = "";
      switch (quest.getState()) {
        case 2:
          state = "遂行中";
          break;
        case 3:
          state = "達成";
          break;
        default:
          continue;
      }

      body.add(
          new Object[] {
            quest.getNo(),
            state,
            quest.getTitle(),
            quest.getDetail(),
            quest.getFuel(),
            quest.getAmmo(),
            quest.getMetal(),
            quest.getBauxite()
          });
    }
    return toListStringArray(body);
  }
    @Override
    public void run() {
      if (this.main.getShell().isDisposed()) {
        return;
      }
      // タブを更新する
      CTabItem maintab = this.main.getTabFolder().getItem(0);
      maintab.setToolTipText(
          "装備:"
              + GlobalContext.getItemMap().size()
              + "/"
              + GlobalContext.maxSlotitem()
              + " 艦娘:"
              + GlobalContext.getShipMap().size()
              + "/"
              + GlobalContext.maxChara());

      boolean combinedFleetBadlyDamaed = false;
      if (GlobalContext.isCombined()) {
        combinedFleetBadlyDamaed =
            GlobalContext.getDock("1").isBadlyDamaged()
                || GlobalContext.getDock("2").isBadlyDamaged();
      }

      List<ShipDto> badlyDamaged = new ArrayList<>();

      FleetWindow[] fleetWindows = this.main.getFleetWindows();
      for (int i = 0; i < fleetWindows.length; i++) {
        fleetWindows[i].updateFleet(combinedFleetBadlyDamaed, badlyDamaged);
      }

      this.postFatal(badlyDamaged);
    }
    @Override
    public void run() {
      if (this.main.getShell().isDisposed()) {
        return;
      }
      Button shipList = this.main.getShipList();
      String setText =
          "所有艦娘(" + GlobalContext.getShipMap().size() + "/" + GlobalContext.maxChara() + ")";
      if (setText.equals(shipList.getText())) {
        return;
      }

      shipList.setText(setText);
      shipList.getParent().layout();

      if (AppConfig.get().isUseTaskbarNotify()) {
        TaskItem item = SwtUtils.getTaskBarItem(this.main.getShell());
        if (item != null) {
          int max = GlobalContext.maxChara();
          int size = GlobalContext.getShipMap().size();
          int locked = 0;
          for (Entry<Integer, ShipDto> entry : GlobalContext.getShipMap().entrySet()) {
            if (entry.getValue().getLocked()) {
              locked++;
            }
          }
          int r = Math.round(((float) (size - locked) / (float) (max - locked)) * 100);

          item.setProgress(r);

          if (max <= (size + AppConfig.get().getNotifyFully())) {
            item.setProgressState(SWT.PAUSED);
          } else {
            item.setProgressState(SWT.NORMAL);
          }
        }
      }
    }
 public void updateContents(ShipFilterDto filter, boolean panelVisible, boolean etcVisible) {
   this.changeEnabled = false;
   Set<String> items = new TreeSet<String>();
   for (ItemDto entry : GlobalContext.getItemMap().values()) {
     items.add(entry.getName());
   }
   this.nametext.remove(0, this.nametext.getItemCount() - 1);
   for (String name : items) {
     this.nametext.add(name);
   }
   this.recreateGroupButtons();
   this.recreateShipTypeButtonos();
   this.applyFilter(filter);
   this.setPanelVisible(panelVisible, etcVisible);
   this.changeEnabled = true;
 }
 /** エラー表示を更新 */
 private void updateErrorLabel() {
   int state = GlobalContext.getState();
   Label errorLabel = ApplicationMain.main.getErrorLabel();
   boolean printLabel = false;
   String errorText = "正常";
   if ((state != 0) && (state != 1)) {
     errorText = "データが不完全です(理由不明)";
     if (state == 2) {
       errorText = "艦これのリロードが必要です";
     } else if (state == 3) {
       errorText = "航海日誌の再起動が必要です\r\n(アカウントが変更されたため)";
     }
     printLabel = true;
   }
   if ((errorLabel.getText().equals(errorText) == false)
       || (errorLabel.getVisible() != printLabel)) {
     errorLabel.setText(errorText);
     LayoutLogic.hide(errorLabel, !printLabel);
     errorLabel.setVisible(printLabel);
     ApplicationMain.main.getMainComposite().layout();
   }
 }
Exemple #10
0
  /**
   * 戦闘フェーズ結果を読み込む
   *
   * @param object 受け取ったJSON
   * @param kind 戦闘の種別
   * @return 作成されたPhaseオブジェクト
   */
  public Phase addPhase(JsonObject object, BattlePhaseKind kind) {
    if (this.phaseList.size() == 0) {
      // 最初のフェーズ
      String dockId;

      if (object.containsKey("api_dock_id")) {
        dockId = object.get("api_dock_id").toString();
      } else {
        dockId = object.get("api_deck_id").toString();
      }

      JsonArray nowhps = object.getJsonArray("api_nowhps");
      JsonArray maxhps = object.getJsonArray("api_maxhps");
      JsonArray nowhpsCombined = object.getJsonArray("api_nowhps_combined");
      JsonArray maxhpsCombined = object.getJsonArray("api_maxhps_combined");
      boolean isCombined = (nowhpsCombined != null);

      int numFships = 6;
      int numFshipsCombined = 0;

      for (int i = 1; i <= 6; ++i) {
        if (maxhps.getInt(i) == -1) {
          numFships = i - 1;
          break;
        }
      }
      if (object.containsKey("api_fParam_combined")) {
        numFshipsCombined = 6;
        for (int i = 1; i <= 6; ++i) {
          if (maxhpsCombined.getInt(i) == -1) {
            numFshipsCombined = i - 1;
            break;
          }
        }
      }

      if (this.friends.size() == 0) { // 再読み込みの場合はスキップ
        this.friends.add(GlobalContext.getDock(dockId));
        if (numFshipsCombined > 0) {
          this.friends.add(GlobalContext.getDock("2"));
        }
      }

      JsonArray shipKe = object.getJsonArray("api_ship_ke");
      JsonArray eSlots = object.getJsonArray("api_eSlot");
      JsonArray eParams = object.getJsonArray("api_eParam");
      JsonArray eLevel = object.getJsonArray("api_ship_lv");
      for (int i = 1; i < shipKe.size(); i++) {
        int id = shipKe.getInt(i);
        if (id != -1) {
          int[] slot = JsonUtils.toIntArray(eSlots.getJsonArray(i - 1));
          int[] param = JsonUtils.toIntArray(eParams.getJsonArray(i - 1));
          this.enemy.add(new EnemyShipDto(id, slot, param, eLevel.getInt(i)));
        }
      }
      int numEships = this.enemy.size();

      this.startFriendHp = new int[numFships];
      this.startEnemyHp = new int[numEships];
      this.maxFriendHp = new int[numFships];
      this.maxEnemyHp = new int[numEships];
      if (isCombined) {
        this.startFriendHpCombined = new int[numFshipsCombined];
        this.maxFriendHpCombined = new int[numFshipsCombined];
      } else {
        this.maxFriendHpCombined = null;
      }

      // 陣形
      if (object.containsKey("api_formation")) {
        JsonArray formation = object.getJsonArray("api_formation");
        for (int i = 0; i < 2; ++i) {
          switch (formation.get(i).getValueType()) {
            case NUMBER:
              this.formation[i] = toFormation(formation.getInt(i));
              break;
            default:
              this.formation[i] = toFormation(Integer.parseInt(formation.getString(i)));
          }
        }
        this.formationMatch = toMatch(formation.getInt(2));
      }

      // 索敵
      JsonArray jsonSearch = object.getJsonArray("api_search");
      if (jsonSearch != null) {
        this.sakuteki =
            new String[] {toSearch(jsonSearch.getInt(0)), toSearch(jsonSearch.getInt(1))};
      }

      // この戦闘の開始前HPを取得
      for (int i = 1; i < nowhps.size(); i++) {
        int hp = nowhps.getInt(i);
        int maxHp = maxhps.getInt(i);
        if (i <= 6) {
          if (i <= numFships) {
            this.maxFriendHp[i - 1] = maxHp;
            this.friendGaugeMax += this.startFriendHp[i - 1] = hp;
          }
        } else {
          if ((i - 6) <= numEships) {
            this.maxEnemyHp[i - 1 - 6] = maxHp;
            this.enemyGaugeMax += this.startEnemyHp[i - 1 - 6] = hp;
          }
        }
      }
      if (isCombined) {
        for (int i = 1; i < nowhpsCombined.size(); i++) {
          int hp = nowhpsCombined.getInt(i);
          int maxHp = maxhpsCombined.getInt(i);
          if (i <= numFshipsCombined) {
            this.maxFriendHpCombined[i - 1] = maxHp;
            this.friendGaugeMax += this.startFriendHpCombined[i - 1] = hp;
          }
        }

        // 退避
        this.escaped = new boolean[12];
        if (JsonUtils.hasKey(object, "api_escape_idx")) {
          for (JsonValue jsonShip : object.getJsonArray("api_escape_idx")) {
            this.escaped[((JsonNumber) jsonShip).intValue() - 1] = true;
          }
        }
        if (JsonUtils.hasKey(object, "api_escape_idx_combined")) {
          for (JsonValue jsonShip : object.getJsonArray("api_escape_idx_combined")) {
            this.escaped[(((JsonNumber) jsonShip).intValue() - 1) + 6] = true;
          }
        }
        for (int i = 0; i < 2; ++i) {
          this.friends.get(i).setEscaped(Arrays.copyOfRange(this.escaped, i * 6, (i + 1) * 6));
        }
      }
    }

    if (this.phaseList.size() > 0) {
      Phase phase = this.phaseList.get(0);
      this.completeDamageAndAddPhase(
          new Phase(
              this,
              object,
              kind,
              phase.getNowFriendHp(),
              phase.getNowFriendHpCombined(),
              phase.getNowEnemyHp()),
          kind);
    } else {
      this.completeDamageAndAddPhase(
          new Phase(
              this,
              object,
              kind,
              this.startFriendHp,
              this.startFriendHpCombined,
              this.startEnemyHp),
          kind);
    }
    return this.phaseList.get(this.phaseList.size() - 1);
  }
    /**
     * 遠征を更新する
     *
     * @param now
     * @param notice
     * @return
     */
    private void updateDeck() {
      BasicInfoDto basicDto = GlobalContext.getBasicInfo();
      if (AppConfig.get().isNameOnTitlebar() && (basicDto != null)) {
        String titlebarText = basicDto.getNickname() + " - 航海日誌";
        this.main.setTitleText(titlebarText);
      } else {
        this.main.setTitleText(AppConstants.TITLEBAR_TEXT);
      }

      Label[] deckNameLabels = {
        this.main.getDeck1name(), this.main.getDeck2name(),
        this.main.getDeck3name(), this.main.getDeck4name()
      };
      Text[] deckTimeTexts = {
        this.main.getDeck1time(), this.main.getDeck2time(),
        this.main.getDeck3time(), this.main.getDeck4time()
      };

      DeckMissionDto[] deckMissions = GlobalContext.getDeckMissions();
      Map<Integer, Date> ndockMap = GlobalContext.getNDockCompleteTimeMap();

      for (int i = 0; i < 4; i++) {
        String time = "";
        String dispname = "";
        String tooltip = null;
        Color backColor = SWTResourceManager.getColor(SWT.COLOR_WHITE);

        DockDto dock = GlobalContext.getDock(String.valueOf(i + 1));

        if (dock != null) {
          String dockName = dock.getName();
          if ((i >= 1) && (deckMissions[i - 1].getMission() != null)) {
            // 遠征中
            DeckMissionDto mission = deckMissions[i - 1];
            dispname = dockName + " (" + mission.getDisplayText("missioncheck_" + (i + 1)) + ")";

            if (mission.getTime() != null) {
              long rest = TimeLogic.getRest(this.now, mission.getTime());

              // ツールチップテキストで時刻を表示する
              tooltip = this.format.format(mission.getTime());

              // 20分前、10分前、5分前になったら背景色を変更する
              backColor = getBackgroundColor(rest);

              // 通知生成
              this.updateNoticeDeck(dispname, i - 1, rest);

              time = TimeLogic.toDateRestString(rest);
              if (time == null) {
                time = "まもなく帰投します";
              }
            }
          } else {
            // 遠征中でない
            // 疲労回復時刻を計算
            CondTiming condTiming = GlobalContext.getCondTiming();
            Date condClearTime = null;
            long condRest = -1;
            for (ShipDto ship : dock.getShips()) {
              Date clearTime =
                  ship.getCondClearTime(
                      condTiming, ndockMap.get(ship.getId()), AppConfig.get().getOkCond());
              if (clearTime != null) {
                if ((condClearTime == null) || condClearTime.before(clearTime)) {
                  condClearTime = clearTime;
                }
                condRest = Math.max(condRest, TimeLogic.getRest(this.now, clearTime));
              }
            }
            if (condClearTime != null) {
              // 疲労回復通知生成
              this.updateNoticeCond(dockName, i, condRest);
            }

            // 泊地修理タイマー更新
            AkashiTimer.RepairState repairState = TimerContext.get().getAkashiRepairState(i);
            if (repairState.isRepairing()) {
              // 泊地修理中
              dispname = dockName + " (泊地修理中)";
              time = TimeLogic.toDateRestString(repairState.getElapsed() / 1000, true);
              backColor = ColorManager.getColor(AppConstants.AKASHI_REPAIR_COLOR);

              // ツールチップで詳細表示
              for (AkashiTimer.ShipState state : repairState.get()) {
                if (state != null) {
                  ShipDto ship = state.getShip();
                  long rest = TimeLogic.getRest(this.now, state.getFinish());
                  String txt = ship.getFriendlyName();
                  String remainStr = TimeLogic.toDateRestString(rest);
                  if (remainStr == null) {
                    txt += ":まもなく修理完了します";
                  } else {
                    txt += ":残り" + remainStr + "(" + this.format.format(state.getFinish()) + ")";
                  }
                  if (tooltip == null) {
                    tooltip = txt;
                  } else {
                    tooltip += "\n" + txt;
                  }
                }
              }

              this.updateNoticeAkashi(dock, repairState);
            } else if (!GlobalContext.isSortie(dock.getId()) && (condClearTime != null)) {
              dispname = dockName + " (疲労回復中)";

              // ツールチップテキストで時刻を表示する
              tooltip = this.format.format(condClearTime);

              // 20分前、10分前、5分前になったら背景色を変更する
              backColor = getCondBackgroundColor(condRest);

              time = TimeLogic.toDateRestString(condRest);
              if (time == null) {
                time = "疲労回復しました";
              }
            }
          }
        }

        deckNameLabels[i].setText(dispname);
        deckNameLabels[i].setToolTipText(dispname);
        deckTimeTexts[i].setText(time);
        deckTimeTexts[i].setToolTipText(tooltip);
        deckTimeTexts[i].setBackground(backColor);
      }
    }