Skip to content

Commit

Permalink
Merge pull request #4279 from Jmr3366/develop
Browse files Browse the repository at this point in the history
new functions - getMapVision(), setMapVision("off/day/night")
  • Loading branch information
cwisniew authored Sep 6, 2023
2 parents fb94caa + 2bf217f commit e6bc74d
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ private MapFunctions() {
"copyMap",
"createMap",
"getMapName",
"setMapSelectButton");
"setMapSelectButton",
"getMapVision",
"setMapVision");
}

public static MapFunctions getInstance() {
Expand Down Expand Up @@ -397,6 +399,26 @@ public Object childEvaluate(
return (MapTool.getFrame().getToolbarPanel().getMapselect().isVisible()
? BigDecimal.ONE
: BigDecimal.ZERO);
} else if ("setMapVision".equalsIgnoreCase(functionName)) {
FunctionUtil.blockUntrustedMacro(functionName);
FunctionUtil.checkNumberParam(functionName, parameters, 1, 1);
Zone currentZR = MapTool.getFrame().getCurrentZoneRenderer().getZone();
if (currentZR == null) {
throw new ParserException(I18N.getText("macro.function.map.none", functionName));
}
switch (parameters.get(0).toString().toLowerCase()) {
case "off" -> MapTool.serverCommand().setVisionType(currentZR.getId(), Zone.VisionType.OFF);
case "day" -> MapTool.serverCommand().setVisionType(currentZR.getId(), Zone.VisionType.DAY);
case "night" -> MapTool.serverCommand()
.setVisionType(currentZR.getId(), Zone.VisionType.NIGHT);
default -> throw new ParserException(
I18N.getText("macro.function.general.argumentTypeInvalid", functionName));
}
return "";
} else if ("getMapVision".equalsIgnoreCase(functionName)) {
FunctionUtil.checkNumberParam(functionName, parameters, 0, 0);
ZoneRenderer currentZR = MapTool.getFrame().getCurrentZoneRenderer();
return currentZR.getZone().getVisionType().toString();
}

throw new ParserException(I18N.getText("macro.function.general.unknownFunction", functionName));
Expand Down

0 comments on commit e6bc74d

Please sign in to comment.