private void setStatusButton(int priority, int state) {
   String tooltip = Resources.get("Standard Priority");
   ImageIcon icon = standardIcon;
   if (state == TrainModel.STATE_STOPPED) {
     icon = stoppedIcon;
     tooltip = Resources.get("Stopped");
   } else {
     switch (priority) {
       case TrainModel.PRIORITY_EXPRESS:
         icon = expressIcon;
         tooltip = Resources.get("Express Priority");
         break;
       case TrainModel.PRIORITY_NORMAL:
         icon = standardIcon;
         tooltip = Resources.get("Standard Priority");
         break;
       case TrainModel.PRIORITY_SLOW:
         icon = slowIcon;
         tooltip = Resources.get("Slow Priority");
         break;
       default:
         throw new IllegalStateException();
     }
   }
   statusJButton.setToolTipText(tooltip);
   statusJButton.setIcon(icon);
 }
Esempio n. 2
0
  public HelpMenu(GUIRoot gr) {
    super(Resources.get("Help"));
    guiRoot = gr;

    JMenuItem about = new JMenuItem(Resources.get("About"));
    about.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) dbc.showAbout();
          }
        });

    JMenuItem how2play = new JMenuItem(Resources.get("Getting started"));
    how2play.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) dbc.showHow2Play();
          }
        });

    JMenuItem showControls = new JMenuItem(Resources.get("Show game controls"));
    showControls.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) dbc.showGameControls();
          }
        });

    JMenuItem modInfo = new JMenuItem(Resources.get("Modding Info"));
    modInfo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            DialogueBoxController dbc = guiRoot.getDialogueBoxController();
            if (dbc != null) {
              dbc.showContent(new ModInfoPanel(guiRoot));
            }
          }
        });

    add(showControls);
    add(how2play);
    add(about);
    add(modInfo);
  }
  private void setStatusLabel(TrainModel trainModel) {
    if (trainModel == null) {
      statusJLabel.setIcon((Icon) null);
      statusJLabel.setToolTipText("");
      return;
    }

    switch (trainModel.getState()) {
      case TrainModel.STATE_RUNNABLE:
        if (trainModel.isBlocked()) {
          statusJLabel.setIcon(blockedIcon);
          statusJLabel.setToolTipText(Resources.get("Track blocked"));
        } else if (trainModel.getTrainMotionModel().isLost()) {
          statusJLabel.setIcon(noRouteIcon);
          statusJLabel.setToolTipText(Resources.get("No route to destination"));
        } else if (trainModel.getTrainMotionModel().isOutOfWater()) {
          statusJLabel.setIcon(outOfWaterIcon);
          statusJLabel.setToolTipText(Resources.get("No water"));
        } else {
          statusJLabel.setIcon((Icon) null);
          statusJLabel.setToolTipText("");
        }
        break;
      case TrainModel.STATE_LOADING:
        statusJLabel.setIcon(loadingIcon);
        statusJLabel.setToolTipText(Resources.get("Loading"));
        break;
      case TrainModel.STATE_UNLOADING:
        statusJLabel.setIcon(unloadingIcon);
        statusJLabel.setToolTipText(Resources.get("Unloading"));
        break;
      default:
        statusJLabel.setIcon((Icon) null);
        statusJLabel.setToolTipText("");
        break;
    }
  }
Esempio n. 4
0
  /** config.yml を再読み込みする */
  public void reloadConfig() {

    File configFile = new File(LunaChat.getInstance().getDataFolder(), "config.yml");
    if (!configFile.exists()) {
      // LunaChat.instance.saveDefaultConfig();
      Utility.copyFileFromJar(LunaChat.getPluginJarFile(), configFile, "config_ja.yml", false);
    }

    LunaChat.getInstance().reloadConfig();
    FileConfiguration config = LunaChat.getInstance().getConfig();

    enableChannelChat = config.getBoolean("enableChannelChat", true);
    playerChatEventListenerPriority =
        getEventPriority(config.getString("playerChatEventListenerPriority"), EventPriority.HIGH);
    noJoinAsGlobal = config.getBoolean("noJoinAsGlobal", true);
    loggingChat = config.getBoolean("loggingChat", true);
    loggingChatToHawkEye = config.getBoolean("loggingChatToHawkEye", true);
    loggingChatToPrism = config.getBoolean("loggingChatToPrism", true);
    displayChatOnConsole = config.getBoolean("displayChatOnConsole", true);
    globalMarker = config.getString("globalMarker", "!");
    zeroMemberRemove = config.getBoolean("zeroMemberRemove", false);
    showListOnJoin = config.getBoolean("showListOnJoin", false);
    createChannelOnJoinCommand = config.getBoolean("createChannelOnJoinCommand", false);

    // チャンネルチャット有効のときだけ、globalChannel設定を読み込む
    // (see issue #58)
    if (enableChannelChat) {
      globalChannel = config.getString("globalChannel", "");
    } else {
      globalChannel = "";
    }
    // チャンネルチャット有効のときだけ、forceJoinChannels設定を読み込む
    // (see issue #58)
    if (enableChannelChat) {
      forceJoinChannels = config.getStringList("forceJoinChannels");
    } else {
      forceJoinChannels = new ArrayList<String>();
    }

    if (config.contains("formatConstraint")) {
      formatConstraint = config.getStringList("formatConstraint");
    } else {
      formatConstraint = new ArrayList<String>();
      formatConstraint.add("%username");
      formatConstraint.add("%msg");
    }

    defaultFormat =
        config.getString("defaultFormat", "&f[%color%ch&f]%prefix%username%suffix&a:&f %msg");
    defaultFormatForPrivateMessage =
        config.getString("defaultFormatForPrivateMessage", "&7[%player -> %to]&f %msg");

    opListenAllChannel = config.getBoolean("opListenAllChannel", false);

    minChannelNameLength = config.getInt("minChannelNameLength", 4);
    maxChannelNameLength = config.getInt("maxChannelNameLength", 20);

    enableQuickChannelChat = config.getBoolean("enableQuickChannelChat", true);
    quickChannelChatSeparator = config.getString("quickChannelChatSeparator", ":");

    sendBroadcastChannelChatToDynmap = config.getBoolean("sendBroadcastChannelChatToDynmap", true);
    sendFormattedMessageToDynmap = config.getBoolean("sendFormattedMessageToDynmap", false);
    dynmapChannel = config.getString("dynmapChannel", "");
    ngword = config.getStringList("ngword");
    ngwordAction = NGWordAction.fromID(config.getString("ngwordAction", "mask"));

    ngwordCompiled = new ArrayList<Pattern>();
    for (String word : ngword) {
      ngwordCompiled.add(Pattern.compile(word));
    }

    enableNormalChatMessageFormat = config.getBoolean("enableNormalChatMessageFormat", true);
    normalChatMessageFormat =
        config.getString("normalChatMessageFormat", "&f%prefix%username%suffix&a:&f %msg");
    enableNormalChatColorCode = config.getBoolean("enableNormalChatColorCode", true);

    japanizeType = JapanizeType.fromID(config.getString("japanizeType"), JapanizeType.KANA);
    japanizeDisplayLine = config.getInt("japanizeDisplayLine", 2);
    if (japanizeDisplayLine != 1 && japanizeDisplayLine != 2) {
      japanizeDisplayLine = 2;
    }
    japanizeLine1Format = config.getString("japanizeLine1Format", "%msg &6(%japanize)");
    japanizeLine2Format = config.getString("japanizeLine2Format", "&6[JP] %japanize");
    japanizeIgnorePlayerName = config.getBoolean("japanizeIgnorePlayerName", true);
    noneJapanizeMarker = config.getString("noneJapanizeMarker", "#");
    japanizeWait = config.getInt("japanizeWait", 1);

    // globalチャンネルが、使用可能なチャンネル名かどうかを調べる
    if (!globalChannel.equals("") && !globalChannel.matches("[0-9a-zA-Z\\-_]{1,20}")) {
      String msg = String.format(Resources.get("errmsgCannotUseForGlobal"), globalChannel);
      LunaChat.getInstance().getLogger().warning(msg);
      globalChannel = "";
    }
  }