コード例 #1
0
    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));
      }
    }
コード例 #2
0
    /**
     * 入渠を更新する
     *
     * @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);
      }
    }
コード例 #3
0
    /**
     * 遠征を更新する
     *
     * @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);
      }
    }