示例#1
0
  void sendTokenRegisterdProperties(MTWebSocket mtws, String inResponseTo, JSONObject data) {
    String tokenId = data.getString("tokenId");
    Token token = findTokenFromId(tokenId);

    if (token == null) {
      System.out.println("DEBUG: sendTokenInfo(): Unable to find token " + tokenId);
      return;
      // FIXME: log this error
    }

    JSONObject jobj = new JSONObject();
    jobj.put("tokenId", tokenId);
    jobj.put("name", token.getName());
    jobj.put("label", token.getLabel());
    jobj.put("notes", token.getNotes());

    JSONObject jprop = new JSONObject();

    for (TokenProperty tp : MapTool.getCampaign().getTokenPropertyList(token.getPropertyType())) {
      JSONObject jp = new JSONObject();
      jp.put("name", tp.getName());
      if (tp.getShortName() != null) {
        jp.put("shortName", tp.getShortName());
      }
      if (tp.getDefaultValue() != null) {
        jp.put("defaultValue", tp.getDefaultValue());
      }
      jp.put("value", token.getProperty(tp.getName()));
      jp.put("showOnStatSheet", tp.isShowOnStatSheet());

      jprop.put(tp.getName(), jp);
    }

    jobj.put("properties", jprop);

    JSONArray jmacros = new JSONArray();

    for (MacroButtonProperties macro : token.getMacroList(false)) {
      JSONObject jmb = new JSONObject();
      jmb.put("label", macro.getLabel());
      jmb.put("tooltip", macro.getEvaluatedToolTip());
      jmb.put("index", macro.getIndex());
      jmb.put("fontColor", macro.getFontColorAsHtml());
      jmb.put("displayGroup", macro.getGroupForDisplay());
      jmb.put("group", macro.getGroup());
      jmb.put("index", macro.getIndex());
      jmb.put("autoExecute", macro.getAutoExecute());
      jmb.put("maxWidth", macro.getMaxWidth());
      jmb.put("minWidth", macro.getMinWidth());
      jmb.put("applyToTokens", macro.getApplyToTokens());

      jmacros.add(jmb);
    }

    jobj.put("macros", jmacros);

    mtws.sendMessage("tokenInfo", inResponseTo, jobj);
  }
示例#2
0
  String getTokenValue(Token token, String name) {
    if (":name".equalsIgnoreCase(name)) {
      return token.getName();
    } else if (":notes".equalsIgnoreCase(name)) {
      return token.getNotes();
    } else if (":label".equalsIgnoreCase(name)) {
      return token.getLabel();
    }

    return "";
  }