Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
Implements #3505
Description of the Change
First up there is some supporting refactoring to bring paint string parsing and asset ID/URL parsing into
FunctionUtil
.DrawingFunctions
and its children, andLookupTableFunction
now use these common methods instead of using their own. These will also be used bycreateMap()
.Second is a tweak to
MapTool.addZone()
to fix an edge case I encountered while testingcreateMap()
. In the case that we replace the default map, there were two undesirable effects of how we did the replacement:The behaviour is now changed so that we add the new map first, then delete the default map. We also always force a map change on the originating client if adding the map results in deleting the default map.
Third is a change to
getInfo("map")
/getInfo("zone")
to include more information via new keys. The new keys hold info that will be useful when callingcreateMap()
, so I wanted easy access to these values. The new keys are:"lighting style"
"has fog"
"ai rounding"
"background paint"
"fog paint"
"map asset"
Finally is the main change:
createMap()
. This trusted macro function builds brand new maps given only a name and some options. This will allow add-ons and other macros to create new maps from nothing, which can then be populated using existing macros, e.g.,createToken()
, etc. ThecreateMap()
function supports every option in the Map Properties dialog, and also every meaningful property returned bygetInfo("map")
(inlcuding the newly added ones). I aimed for alignment betweencreateMap()
keys andgetInfo("map")
keys to make it easier to build a configuration object for use withcreateMap()
. The documentation notes below detail the exact set of keys that are supported in the configuration.Possible Drawbacks
Should be none
Documentation Notes
createMap
Usage
Parameters
name
The name of the new map.config
A JSON object of options to apply to the new map.config parameter
config
is a JSON Object that can contain any of the following fields. Field names are case-sensitive, and all fields are optional:display name
: defaults to noneplayer visible
: defaults to user preferencesvision type
: defaults to user preferencesvision distance
: defaults to user preferenceslighting style
: defaults to"OVERTOP"
background paint
: defaults to built-in Grassfog paint
: defaults to blackhas fog
: defaults to user preferences (TODO Implement it)map asset
: defaults to nonegrid
: JSON object, see belowThe
grid
value is another JSON object, with these optional keys:type
: defaults to user preferencescolor
: defaults to user preferencesunits per cell
: defaults to user preferencessize
: defaults to user preferencesx offset
: defaults to 0y offset
: defaults to 0Examples
Release Notes
getInfo("map")
/getInfo("zone")
:"lighting style"
,"has fog"
,"ai rounding"
,"background paint"
,"fog paint"
,"map asset"
createMap(name, [config])
function to create new maps with configurable options.This change is