-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project Defaults/Rules/Templates #945
Comments
Hey @RPGHacker, thank you for this suggestion! Of course in fact, this issue represents many different suggestions and it's some years old, so I will try to bring it down to pieces so we can see where we stand currently. Applying rules / defaults to built-in propertiesThis is the first thing you mentioned. Only allowing a certain kind of map or tile size etc. It would indeed be a useful feature, but as you say yourself you could also use "template" files with certain presets. I think in general, while supporting rules and limits on all of the built-in properties would be nice, it also represents a somewhat large code overhead if implemented trivially, which is why I've been reluctant to add this. The addition of scripting in Tiled 1.3 should help quite a bit, especially with the additions in Tiled 1.4, which features project support where a project can ship with custom scripts. Using scripts you can for example:
There are more things the scripts should be able to do, like it should be possible to hook into more events like "object added/removed". Eventually we'll get to that. Edit: I forgot to point out, that with project / session support, the values used by dialogs like New Map and New Tileset are now persistent per-session. This also helps when you're creating maps with different settings in different projects, though it does not help for the first map created in each session. Predefined custom properties on all data typesThis is about the "scrollSpeedX/Y" custom properties on layers. I totally agree, and this is covered specifically by issue #1410. The application of limits to custom properties like the above would in my opinion be best associated with the type of the property. This then requires the ability to define custom types, which is covered by issue #2199. ScriptingSo, with Tiled 1.3 we got scripting based on JavaScript, but the scripting API does not currently include the functionality suggested here, which appears mainly to be about intercepting changes in order to correct or disallow them. When we work with functions like That said, the scripts are currently still largely unaware of any changes that are being made to an asset, which is something that should definitely be worked on. I'd just like to find some more generic approach to it rather than exposing the rather big mess of internal change signals as-is. I hope the scripting support we have now already allows you to do most of what you'd like to do. If there's anything you are missing, do let me know. I think we should close this issue now, so please let me know if there something you'd like to see explicitly covered by a new issue! |
Has indeed been quite a while since I opened this issue - completely forgot that I did, to be honest. Haha. So to keep myself relatively short here, I think I agree with pretty much everything you've said. Adding just support for templates and custom properties would already be huge and probably get my original ideas about 90% of the way there, and checking for errors/throwing issues on export would probably be enough to cover the remaining 10%. Especially if it avoids a lot of complexity and overhead in the code base. Looking back at my opening post, it kinda reads as though I was indirectly suggesting general-purpose plugin support via scripts, and that definitely seems way out of scope for the general idea that I was trying to propose. Yes, feel free to go ahead and close this! |
Alright, thanks @RPGHacker! I'm trying to get Tiled 1.4 to a release this month and have currently scheduled all the custom property enhancements for Tiled 1.5 (see the Roadmap project). |
Hi there, it's me with another suggestion for a feature. And this time I'm sure it's a feature that doesn't exist in Tiled in this form already, although it is also a more elaborate feature, so I understand if it's just too much work to implement.
Anyways, the idea I had was to have certain files, maybe XML files, that you could import when creating a new map. This file, once imported, would set certain defaults and rules on your newly created map. Like, for example, you could set a default of "format: orthogonal" and "tile size: 32x32" which would then automatically be set for your map. You could then set a few rules like "only orthogonal maps allowed", "min allowed tile size: 16x16", "max allowed tile size 64x64". With these rules active, whenever the user would try to perform an action that doesn't coincide with these rules, he would get an error. For example, with the above rules file, if a user would try to set the map format to isometric, he would get the error message "only orthographic maps are allowed by this rule set". And of course you could also set defaults and rules for all other properties like map size etc.
Aside from only setting defaults and rules on the map creation screen, though, which I admit wouldn't be that worthwile as a feature (since you could just use empty map files with the defaults already set for this), it would also allow you to set defaults and rules on pretty much all other aspects of Tiled. For example: you could add default properties to any kind of object that supports properties. Let's say I was working on a 2D platformer and my game supported layers that scroll with different speeds. I could add the properties "scrollSpeedX" and "scrollSpeedY" as default properties with a default value of "1.0" to layer objects, so that whenever I would create a new layer, it would already have the properties "scrollSpeedX" and "scrollSppedY" with a value of 1.0 listed in the properties section. Then I could add a new rule to scrollSpeedX and scrollSpeedY that would automatically clamp its value to a range between 0.0 and 2.0 since I might not want scroll speeds that are too high nor negative.
Adding this to all aspects of Tiled would already make it a great and worthwhile feature in my opinion. But it could be made even better: by adding script support. From what I know, Tiled already includes python support, so this could be expanded to literally allow you to code your own rules for your map files. For example, whenever the user would create a map and modify the tile width of the map, Tiled would look for a python function called "setMapTileSize". When not found, it would do nothing, but when present, it would call this function to adjust the value. It could be defined like this (using C-styled pseudo code since I'm not too familiar with python yet):
unsigned int setMapTileSize(IN unsigned int inputTileSize)
And in it, you could do something like:
if (inputTileSize < 16) return 16;
And then you could have another function that gets invoked once the user clicks the "create" button on the map creation screen to check for context-dependent errors. When this function would return false, Tiled would print a user defined error message. This way you could, for example, add rules like "tile width and tile height have to be equal" or "tile width and tile height have to be power of two" or something like that. The function could be defined like this:
bool createMap(IN struct mapSettings, OUT string errorMessage)
And for properties, you could have a function like this:
string setLayerPropertyValue(IN string propertyName, IN string propertyValue)
With this you could parse all your custom properties and prevent any invalid values from sneaking in there. And maybe you could even do something like adding certain picker dialogs to your custom properties (like color picker or file picker).
With all of this, when working on a team project, you would just have to distribute these rule files to your team mates and they could just start creating new maps without being able to break anything and without errors being able to sneak in there. Like, you could send them a "LevelRules.py" and an "OverworldRules.py" and they would only have to pick the correct rules file depending on what kind of map they want to design. In the long term, this could really save you a lot of time with your project since you wouldn't have to search your maps for errors and could instead prevent them from even happening. Of course you could also fix many errors with the python export function, I suppose, but in that case a map designer wouldn't get instant feedback on any wrong inputs and probably not even realise that some things were changed in the final map. With this feature you would also save a lot of time writing lenghty texts to explain what is allowed on your map and what isn't. Instead you would just provide a rules file to automatically prevent any unallowed settings on a map itself.
I hope that it's easy to understand what I am trying to suggest and what I am getting at with this feature suggestion. If that's not the case, just ask me and I'll try to clarify.
Regards
The text was updated successfully, but these errors were encountered: