private void updateNoticeAkashi(DockDto dock, AkashiTimer.RepairState repairState) {
   if (this.main.getAkashiNotice().getSelection()) {
     if (repairState.isFirstNotify() && AppConfig.get().isAkashiNotifyFirstStep()) {
       this.noticeAkashi.add(dock.getName() + " の泊地修理が20分経過しました");
     }
     for (AkashiTimer.ShipState state : repairState.get()) {
       if (state != null) {
         ShipDto ship = state.getShip();
         if (state.isStepNotify()) {
           int estimatedHp = state.getCurrentGain() + ship.getNowhp();
           boolean full = (estimatedHp == ship.getMaxhp());
           if (full) {
             this.noticeAkashi.add(ship.getFriendlyName() + " がまもなく修理完了します");
           }
           // 20分経過通知があるときはそれで代用する
           else if (!repairState.isFirstNotify() && AppConfig.get().isAkashiNotifyEveryStep()) {
             this.noticeAkashi.add(
                 ship.getFriendlyName()
                     + " がHP1ポイント回復("
                     + (estimatedHp - 1)
                     + "→"
                     + estimatedHp
                     + "/"
                     + ship.getMaxhp()
                     + ")");
           }
         }
       }
     }
   }
 }
Ejemplo n.º 2
0
  /** Create contents of the dialog. */
  private void createContents() {
    this.shell = new Shell(this.getParent(), SWT.SHELL_TRIM | SWT.PRIMARY_MODAL);
    this.shell.setSize(300, 275);
    this.shell.setText("Columns");
    this.shell.setLayout(new FillLayout(SWT.HORIZONTAL));

    // ヘッダー
    String[] header = this.dialog.getTableHeader();
    // カラム設定を取得
    boolean[] visibles =
        AppConfig.get().getVisibleColumnMap().get(this.dialog.getClass().getName());
    if ((visibles == null) || (visibles.length != header.length)) {
      visibles = new boolean[header.length];
      Arrays.fill(visibles, true);
      AppConfig.get().getVisibleColumnMap().put(this.dialog.getClass().getName(), visibles);
    }

    Tree tree = new Tree(this.shell, SWT.BORDER | SWT.CHECK);

    for (int i = 1; i < header.length; i++) {
      TreeItem column = new TreeItem(tree, SWT.CHECK);
      column.setText(header[i]);
      column.setChecked(visibles[i]);
      column.setExpanded(true);
    }
    this.shell.addShellListener(new TreeShellAdapter(tree, visibles, this.dialog));
  }
    /** 艦隊が出撃中で大破した場合に警告を行います */
    private void postFatal(List<ShipDto> badlyDamaged) {
      if (badlyDamaged.size() > 0) {
        if (AppConfig.get().isBalloonBybadlyDamage()) {
          StringBuilder sb = new StringBuilder();
          sb.append(AppConstants.MESSAGE_STOP_SORTIE);
          sb.append("\n");
          for (ShipDto shipDto : badlyDamaged) {
            sb.append(shipDto.getName());
            sb.append("(" + shipDto.getLv() + ")");
            sb.append(" : ");
            List<ItemInfoDto> items = shipDto.getItem();
            List<String> names = new ArrayList<String>();
            for (ItemInfoDto itemDto : items) {
              if (itemDto != null) {
                names.add(itemDto.getName());
              }
            }
            sb.append(StringUtils.join(names, ","));
            sb.append("\n");
          }
          ToolTip tip = new ToolTip(this.main.getShell(), SWT.BALLOON | SWT.ICON_ERROR);
          tip.setText("大破警告");
          tip.setMessage(sb.toString());

          this.main.getTrayItem().setToolTip(tip);
          tip.setVisible(true);
        }
        // 大破時にサウンドを再生する
        Sound.randomBadlySoundPlay();
      }
    }
 private void updateNoticeDeck(String dispname, int index, long rest) {
   if (this.main.getDeckNotice().getSelection()) {
     if ((rest <= ONE_MINUTES) && !FLAG_NOTICE_DECK[index]) {
       this.noticeMission.add(dispname + " がまもなく帰投します");
       FLAG_NOTICE_DECK[index] = true;
     } else if (AppConfig.get().isMissionRemind()
         && (rest < -1)
         && ((rest % AppConfig.get().getRemindInterbal()) == 0)) {
       // 定期的にリマインドする
       this.noticeMission.add(dispname + " がまもなく帰投します");
     } else if (rest > ONE_MINUTES) {
       FLAG_NOTICE_DECK[index] = false;
     }
   } else {
     FLAG_NOTICE_DECK[index] = false;
   }
 }
Ejemplo n.º 5
0
  /** テーブルヘッダーの幅を調節する */
  protected void packTableHeader() {
    boolean[] visibles = AppConfig.get().getVisibleColumnMap().get(this.getClass().getName());

    TableColumn[] columns = this.table.getColumns();

    // 列の表示・非表示設定のサイズがカラム数と異なっている場合は破棄する
    if (visibles != null) {
      if (visibles.length != columns.length) {
        AppConfig.get().getVisibleColumnMap().remove(this.getClass().getName());
        visibles = null;
      }
    }

    for (int i = 0; i < columns.length; i++) {
      if ((visibles == null) || visibles[i]) {
        columns[i].pack();
      } else {
        columns[i].setWidth(0);
      }
    }
  }
    @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);
          }
        }
      }
    }
 private void updateNoticeCond(String dispname, int index, long rest) {
   if (this.main.getCondNotice().getSelection()) {
     if ((rest <= 0) && !FLAG_NOTICE_COND[index]) {
       if ((index == 0) || !AppConfig.get().isNoticeCondOnlyMainFleet()) {
         this.noticeCond.add(dispname + " が疲労回復しました");
       }
       FLAG_NOTICE_COND[index] = true;
     } else if (rest > 0) {
       FLAG_NOTICE_COND[index] = false;
     }
   } else {
     FLAG_NOTICE_COND[index] = false;
   }
 }
Ejemplo n.º 8
0
  /** Open the dialog. */
  public void open() {
    // シェルを作成
    this.shell = new Shell(this.getParent(), this.getStyle());
    this.shell.setSize(this.getSize());
    // ウインドウ位置を復元
    LayoutLogic.applyWindowLocation(this.getClass(), this.shell);
    // 閉じた時にウインドウ位置を保存
    this.shell.addShellListener(new SaveWindowLocationAdapter(this.getClass()));

    this.shell.setText(this.getTitle());
    this.shell.setLayout(new FillLayout());
    // メニューバー
    this.menubar = new Menu(this.shell, SWT.BAR);
    this.shell.setMenuBar(this.menubar);
    // テーブルより前に作成する必要があるコンポジットを作成
    this.createContentsBefore();
    // テーブル
    this.table = new Table(this.getTableParent(), SWT.FULL_SELECTION | SWT.MULTI);
    this.table.addKeyListener(new TableKeyShortcutAdapter(this.header, this.table));
    this.table.setLinesVisible(true);
    this.table.setHeaderVisible(true);
    // メニューバーのメニュー
    MenuItem fileroot = new MenuItem(this.menubar, SWT.CASCADE);
    fileroot.setText("ファイル");
    this.filemenu = new Menu(fileroot);
    fileroot.setMenu(this.filemenu);

    MenuItem savecsv = new MenuItem(this.filemenu, SWT.NONE);
    savecsv.setText("CSVファイルに保存(&S)\tCtrl+S");
    savecsv.setAccelerator(SWT.CTRL + 'S');
    savecsv.addSelectionListener(
        new TableToCsvSaveAdapter(this.shell, this.getTitle(), this.getTableHeader(), this.table));

    MenuItem operoot = new MenuItem(this.menubar, SWT.CASCADE);
    operoot.setText("操作");
    this.opemenu = new Menu(operoot);
    operoot.setMenu(this.opemenu);

    MenuItem reload = new MenuItem(this.opemenu, SWT.NONE);
    reload.setText("再読み込み(&R)\tF5");
    reload.setAccelerator(SWT.F5);
    reload.addSelectionListener(new TableReloadAdapter());

    Boolean isCyclicReload = AppConfig.get().getCyclicReloadMap().get(this.getClass().getName());
    MenuItem cyclicReload = new MenuItem(this.opemenu, SWT.CHECK);
    cyclicReload.setText("定期的に再読み込み(&A)\tCtrl+F5");
    cyclicReload.setAccelerator(SWT.CTRL + SWT.F5);
    if ((isCyclicReload != null) && isCyclicReload.booleanValue()) {
      cyclicReload.setSelection(true);
    }
    CyclicReloadAdapter adapter = new CyclicReloadAdapter(cyclicReload);
    cyclicReload.addSelectionListener(adapter);
    adapter.setCyclicReload(cyclicReload);

    MenuItem selectVisible = new MenuItem(this.opemenu, SWT.NONE);
    selectVisible.setText("列の表示・非表示(&V)");
    selectVisible.addSelectionListener(new SelectVisibleColumnAdapter());

    new MenuItem(this.opemenu, SWT.SEPARATOR);

    // テーブル右クリックメニュー
    this.tablemenu = new Menu(this.table);
    this.table.setMenu(this.tablemenu);
    MenuItem sendclipbord = new MenuItem(this.tablemenu, SWT.NONE);
    sendclipbord.addSelectionListener(new TableToClipboardAdapter(this.header, this.table));
    sendclipbord.setText("クリップボードにコピー(&C)");
    MenuItem reloadtable = new MenuItem(this.tablemenu, SWT.NONE);
    reloadtable.setText("再読み込み(&R)");
    reloadtable.addSelectionListener(new TableReloadAdapter());
    // テーブルにヘッダーをセット
    this.setTableHeader();
    // テーブルに内容をセット
    this.updateTableBody();
    this.setTableBody();
    // 列幅を整える
    this.packTableHeader();

    // 閉じた時に設定を保存
    this.shell.addShellListener(
        new ShellAdapter() {
          @Override
          public void shellClosed(ShellEvent e) {
            AppConfig.get()
                .getCyclicReloadMap()
                .put(AbstractTableDialog.this.getClass().getName(), cyclicReload.getSelection());
          }
        });

    this.createContents();
    this.shell.open();
    this.shell.layout();
    this.display = this.getParent().getDisplay();
    while (!this.shell.isDisposed()) {
      if (!this.display.readAndDispatch()) {
        this.display.sleep();
      }
    }
    // タスクがある場合キャンセル
    if (this.future != null) {
      this.future.cancel(false);
    }
  }
    /**
     * 遠征を更新する
     *
     * @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);
      }
    }
Ejemplo n.º 10
0
    @Override
    public void run() {
      if (this.main.getShell().isDisposed()) {
        return;
      }
      // 現在時刻
      boolean visibleHome = false;
      // 遠征を更新する
      this.updateDeck();
      // 入渠を更新する
      this.updateNdock();
      // その他の時間を更新
      this.updateOtherTimer();

      // 遠征通知
      if (this.noticeMission.size() > 0) {
        Sound.randomExpeditionSoundPlay();
        visibleHome |= AppConfig.get().isVisibleOnReturnMission();

        // Push通知 遠征
        if (AppConfig.get().getPushMission()) {
          PushNotify.add(
              StringUtils.join(this.noticeMission, "\r\n"),
              "遠征",
              AppConfig.get().getPushPriorityMission());
        }
      }

      // 入渠通知
      if (this.noticeNdock.size() > 0) {
        Sound.randomDockSoundPlay();
        visibleHome |= AppConfig.get().isVisibleOnReturnBathwater();

        // Push通知 入渠
        if (AppConfig.get().getPushNdock()) {
          PushNotify.add(
              StringUtils.join(this.noticeNdock, "\r\n"),
              "入渠",
              AppConfig.get().getPushPriorityNdock());
        }
      }

      // 疲労回復通知
      if (this.noticeCond.size() > 0) {
        Sound.randomCondSoundPlay();

        // Push通知 疲労回復
        if (AppConfig.get().isPushCond()) {
          PushNotify.add(
              StringUtils.join(this.noticeCond, "\r\n"),
              "疲労回復",
              AppConfig.get().getPushPriorityCond());
        }
      }

      // 泊地修理通知
      if (this.noticeAkashi.size() > 0) {
        Sound.randomAkashiSoundPlay();

        // Push通知 泊地修理
        if (AppConfig.get().isPushAkashi()) {
          PushNotify.add(
              StringUtils.join(this.noticeAkashi, "\r\n"),
              "泊地修理",
              AppConfig.get().getPushPriorityAkashi());
        }
      }

      if (visibleHome) {
        this.main.getTabFolder().setSelection(0);
      }

      if (AppConfig.get().isUseBalloon()) {
        // バルーンツールチップを表示する
        try {
          // 遠征・入渠のお知らせ
          List<String> title = new ArrayList<String>();
          List<String> notice = new ArrayList<String>();
          this.addNotice(notice, title, this.noticeMission, "遠征");
          this.addNotice(notice, title, this.noticeNdock, "入渠");
          this.addNotice(notice, title, this.noticeCond, "疲労回復");
          this.addNotice(notice, title, this.noticeAkashi, "泊地修理");
          if (notice.size() > 0) {
            ToolTip tip = new ToolTip(this.main.getShell(), SWT.BALLOON | SWT.ICON_INFORMATION);
            tip.setText(StringUtils.join(title, "・"));
            tip.setMessage(StringUtils.join(notice, "\r\n"));
            this.main.getTrayItem().setToolTip(tip);
            tip.setVisible(true);
          }
        } catch (Exception e) {
          LOG.get().warn("お知らせの表示に失敗しました", e);
        }
      }

      // エラー表示を更新(入渠遠征とは関係ないけど)
      this.updateErrorLabel();
    }