void processMacro(JSONObject data) { // FIXME: need to check parameters. // FIXME: need to check permissions. if ("callMacro".equalsIgnoreCase(data.getString("command"))) { Token token = findTokenFromId(data.getString("tokenId")); MacroButtonProperties macro = token.getMacro(data.getInt("macroIndex"), false); macro.executeMacro(token.getId()); } }
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); }