Token Snap to Grid behaviour
The ability to specify as a token attribute, whether to snap to grid based upon the layer, token centre or top and left. Ideally with appropriate script commands. Default behaviour would be (as now) "based upon the layer".
In my opinion this is a missing piece of token control and management. When I build a token in a graphic tool I often have to consider on which layer it will be used most, which is not always clear, and adjust the transparent border accordingly. Current behaviour can also get in the way of some map automation, when I want to move things between some layers (a less frequent issue).
FEATURE: Token Snap to Grid behaviour
Moderators: dorpond, trevor, Azhrei
Forum rules
Posting now open to all registered forum users.
Posting now open to all registered forum users.
FEATURE: setSnapToGrid
This is what I have so far:
I have a couple of questions though. A) How does/should the parser handle boolean parameters? Right now scripters have to use a string "true" or "false" in my code. B) What should those internationalization strings actually be?
Code: Select all
/* Sets whether the token should snap to the grid or not*/
if (functionName.equals("setTokenSnapToGrid")) {
checkNumberOfParameters(functionName, parameters, 1, 2);
Object param = parameters.get(0);
String snapToGridString;
if (param instanceof String) {
snapToGridString = (String) param;
} else {
//TODO: should use the correct I18N string
throw new ParserException(I18N.getText("macro.function.general.xxx", functionName, 0, param.toString()));
}
boolean snapToGrid;
if (snapToGridString.equalsIgnoreCase("true")) {
snapToGrid = true;
} else if (snapToGridString.equalsIgnoreCase("false")) {
snapToGrid = false;
} else {
//TODO: should use the correct I18N string
throw new ParserException(I18N.getText("macro.function.general.xxx", functionName, 0, param.toString()));
}
Token token = getTokenFromParam((MapToolVariableResolver) parser.getVariableResolver(), functionName, parameters, 1);
token.setSnapToGrid(snapToGrid);
return "";
}
Re: FEATURE: setSnapToGrid
Duplicate thread: http://forums.rptools.net/viewtopic.php?f=86&t=25828
Perhaps one of the nice Mods will merge this for us?
Regarding the Parse Handler, this will be difficult to test at the moment because it appears as though ParserExceptions are not being handled by the Line Parser at the moment. Made a short post about it here
Perhaps one of the nice Mods will merge this for us?
Regarding the Parse Handler, this will be difficult to test at the moment because it appears as though ParserExceptions are not being handled by the Line Parser at the moment. Made a short post about it here
Re: FEATURE: setSnapToGrid
Uhm, that code had nothing to do with the OP. It's just a new macro for scripters to set whether a token should snap to grid or not. It doesn't change anything about the behaviour of the snap-to-grid functionality.Jagged wrote:Duplicate thread: http://forums.rptools.net/viewtopic.php?f=86&t=25828
Perhaps one of the nice Mods will merge this for us?
Regarding the Parse Handler, this will be difficult to test at the moment because it appears as though ParserExceptions are not being handled by the Line Parser at the moment. Made a short post about it here
- JamzTheMan
- Great Wyrm
- Posts: 1872
- Joined: Mon May 10, 2010 12:59 pm
- Location: Chicagoland
- Contact:
Re: FEATURE: Token Snap to Grid behaviour
FYI, all other functions can typically use 0 and 1 as well as true and false. And true/false are keywords so shouldn't be translated, no more than function names.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork
Re: FEATURE: Token Snap to Grid behaviour
Was this ever submitted as a pull request? I see one for a snaptogrid function but this one is different.
Re: FEATURE: Token Snap to Grid behaviour
Due to a mistake on my part, two threads have been merged here. One about setting "snap to grid" and one about "snap to grid behaviour". Which one did you mean?
Apologies again to Darkalf
Apologies again to Darkalf