-
Notifications
You must be signed in to change notification settings - Fork 162
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
Editor: change Sprites storage in the game project to open format #1281
Comments
That is a great plan! "Personally I doubt if subfolders within "Sprites" should correspond to the folders in the editor's sprite manager." Importing: on import the editor should just make a 1:1 copy of the sprite the user imports in the cache folder (including corresponding subfolder) and call it like the editor sprite number and according suffix. Probably with leading zeros. 00001.jpg, 00002.png etc. I think the SpriteCache folder should be treated like the current single-file with all the sprites, a place where the user usually does not interfere with (thus my suggestion to make it a hidden folder)! |
@selmiak the original idea was to have actual source sprites inside a project's subfolder, where user can work, directly editing these sprites, and editor would catch these changes up. You are speaking of a "sprite cache", which is a different thing, it contains sprites already converted into the runtime resource. We must separate these two (sources and cache), and decide how to handle both. |
I understand, so this is an open discussion and that is my take on it. Both ways have their benefits, but with my proposal the used files get renamed to their sprite number, having these besides your work files makes your work folders cluttered, especially for animations. If having only one folder means not renaming the files and just having a pointer, that would work too. atm the user has no access to the files imported into the gameproject as they are in the spritefile, and the audio import works similar if I'm not mistaken, this keeps the chances of corrupting things (by the user, not by hardware failure) low. Imho this should be kept that way, maybe a bit more open with my proposal of the hidden folder. So much for that proposal, and I agree putting together a list of all the pros and cons of either way (or maybe getting more input here and having a 3rd way with more pros and cons) is a good idea and a good base to make a decision and a plan. I hope I'll come back to that and write up some pros and cons over the next few days... |
Don't get creative with the naming, it's only going to annoy us and make it difficult to understand what the folder is for. Calling it "AnythingCache" will just be misleading since it's no longer going to be a cache. Conflicts with existing files are not really a concern since we will probably just take existing files if they exist and move them into a backup folder. This is the strategy we're already attempting to implement with a "Rooms" folder in the open room format PR. Of course that is a WIP and is not final as of right now #1278 I'm not really keen on the idea of making a hidden folder here, we're trying to move to a "open" format. Part of the goal is exactly that users can see and edit the files directly from disk without having to rely on the editor. I don't safety for user screwups is a use-case we should value because I think the a lot of people will not be brave enough to mess around with the files when they don't know or understand how to do so. |
Yes, things like the folder naming and file naming are late moment issues, we should not waste time on these now. Same goes for utility improvements, such as thumbnails, as these are not part of the game - these are completely separate problems. At first we need a general principle: what data do we keep in the project, how it is modified by the user, how it is handled by the tools (game compilation tools), how it is packed for the game. The current sprite pipeline looks like this: Source sprite + Import settings => Runtime sprite => Runtime sprite package From all this only "Source sprite + Import settings" are essential for the project, because other parts may be safely deleted and restored later from the source. One of the questions that was raised in the past was: must the "Source sprites" be considered a part of the project; if so then they should be stored inside the project folder. Another requirement made in the past was to be able to edit and then fully compile a game (and any of its components) without launching the editor. This means that the user may edit the original sprite, then run a standalone tool (or a script that calls number of tools in a sequence), and sprites go all the way from the source form to packed for the engine. |
alright, I don't want to decide how that cache folder, if it ever is needed, is called. |
I got started on a branch for this while I was awaiting feedback on the open room format PR a while back, but it has been collecting dust for a while now. I didn't get super far, it takes the sprites through the native poxy, dumps it to disk, and there's a sprite drawing that draws using sprite from disk that needs more work. I might do more on it if I can, but just to be safe, I'll try to rebase it on ags4 branch and post it here this weekend so anyone else could use it for reference if I don't have time |
I imagine one of the end goals will be to have the ability to gitignore the sprite file (this should be possible now with .crm files), so that would be absolutely relevant |
https://github.com/persn/ags/tree/feature/open-sprites I'll keep it up to date if I make any more changes |
Talked a bit with @persn, and he mentioned that his branch was showing two PRs were necessary.
|
I was going to write this for a while, but could not find spare time. I think that besides the above, there's another change that would be necessary, and unfortunately it was not mentioned in the ticket (as far as I can see). This is related to test-running the game. The spritefile compilation may take some time, if there are alot of sprites. Right now it's being updated as you import sprites and save the project in the Editor, and the long wait time only happens when you save after adding or changing sprites. But this process copies parts of the previous file to speed things up a bit. If we change this to have sprites on disk, and spritefile built only during game compilation, that raises the question about how to update a spritefile. Because if the spritefile is fully recreated each time by doing a import from separate files (let alone doing tiled import etc, - I am not fully certain how optimized the storage would be), then this process will become slower than before. Therefore, the Editor would either have to keep a record of what has changed since the last spritefile recompilation, track the time of modification of a spritefile, etc. In the second case, for the optimal workflow, it would be desired to also let Engine use that intermediate form, in such case the full recompilation would not be necessary during the test run. There is this ticket #702, which somehow got almost 50 comments in the discussion, and for the most part we discussed various options of solving similar problem for a different reason. If I recall right, the discussed methods may be summarized into following variants:
The idea here is that besides the editor, that should handle this intermediate storage, the Engine should also be taught to read from it. Since now we have a completely separate SpriteFile class that streams from a file, and SpriteCache itself does not care how the sprite data is stored on disk, it will be possible to have different implementations of the same SpriteFile interface, including one reading from separate files, etc. They likely will work slower than streaming from 1 file, but with a well-sized cache that may not be a big problem. The particular implementation may be allocated according to a game setting or a command line arg. Above is a problem overview, I think we would need a dedicated ticket for this. Note that likely this may be worked on in parallel to the other subtasks. |
Because we can recreate the spritefile from source files nowadays, I still don't quite grasp what this open format adds :/. Additionally, as sprites are sequential numbered items, a merge of branches will always entail manual sprite index adjustment or following practices from cisbetter tutorial. |
Our goal is to have fully open project source, where everything is stored in a human-readable format, without using "magic packages", where:
Additionally, although maybe less obvious:
The sprites are the last part remaining in which editor is relying on the presence of a compiled package, practically using an output format to work.
Yes, this problem still persist, and have to be addressed separately. I might suggest discussing this on forums, to see if people have any interesting ideas. One idea that I once had is to implement a workspace setting that defines a range of sprite IDs to use when importing new sprites. Then each team member could define different range for themselves, and thus avoid conflicts. If the sprite storage format changes, maybe that may also bring possible solutions, like, adding sprite id in filenames, or something like that. |
Would PR 1 be suitable for the master branch? Or the ags4 branch? |
Could you elaborate on which changes will this include? |
I believe it fits with cleaning the code, so perhaps it can be in master and then later merged to ags4. |
I don't think I can explain it anymore plainly than what's already written. It's probably easy enough to rebase, so it would make sense to just base the branch off master, and then rebase on request after a PR review if the changes got out of scope |
Problem
For historical reasons sprites in AGS game project are kept compiled in a single file (aka "sprite file"). Editor saves them there on import and reads them back from there when having to use these sprites displaying a game scene. When compiling the game this file is simply added to the data package as-is, and this is it's only benefit.
But this has a number of disadvantages:
See also: Add Git integration #468.
Solution summary
Questions and further suggestions follow...
Project storage
Need to define the subfolder to store sprites. "Sprites"?
Personally I doubt if subfolders within "Sprites" should correspond to the folders in the editor's sprite manager. IMO more no than yes. The imported sprites do not 1:1 correspond to the source images, user may import multiple sprites from one image file, even from one tile rect with different settings. Same image may be imported as multiple placeholders too.
It may be imagined that at some point editor will be able to display both source images and imported sprites in separate windows - as separate entities.
Importing sprites
On a sprite import editor checks whether the source image is withing "Sprites" project folder, if not then copies it there.
If we support subfolders, images cloned by the editor should probably go into a special "unorganized" subfolder.
Editor will also have to prevent file name conflicts.
Alternatively we may restrict sprite import to only files that were placed into "Sprite" folder by user.
Pros: user will have full control on how files are called, there's no need to guess how and where to clone files. Possibly less confusion about how import works.
Cons: possibly extra work for users if they import from other locations.
What to do with "import from clipboard" option? If supported then it must create a new source image file in the project folder.
Upgrading from older project
Existing AGS project has:
Let's suppose that the priority should be given to import original images whenever possible. If they cannot be found, then we may optionally export sprites from the compiled sprite file and save them in "Sprites" folder.
In any case, what to do if there's already a "Sprites" folder created by user and containing some data?
If we are exporting from the spritefile, we will have to deal with possible duplicate image sources and sprites cut out from the middle of an image. E.g. there may be multiple sprites referencing one source image. In such case should we try to reconstruct original image judging by the sprite tile offsets & sizes? Or should we export each sprite to its own image file and adjust source references and import settings?
Should the program ask for permission to export from the spritefile to let user opportunity to restore original images, or just warn and go on with it?
Sprites in the Editor's memory
Hypothetically, Editor may reuse existing sprite cache in C++ code with some adjustments. If it's preferable to move away from using C++ code internally in the Editor, then we would have to write another sprite cache or manager for the Editor in C#.
Editor drawing sprites
If we remake sprite cache into a C# cache/manager, then there very likely is a need to remake remaining game content drawing into C# code as well. This task may be stated in a separate ticket.
Compiling sprite file
The existing C++ code relies on sprites stored in a native C++ sprite cache object, which is going to be inconvenient.
The options here are:
Writing stand-alone tool may be picked out to a separate ticket.
The text was updated successfully, but these errors were encountered: