so i made a litlle plugin for jMonkey SDK.
Its main (and only :P) task is to create a class with all the assets (like androids R file, i don’t know how else to describe it). give it a try if you want and pls let me know if it has a bugs and such and i’ll try to fix them.
once installed, the “Generate” action will be in the Tools menu( ctrl+alt+A is the shortcut)
btw not realy sure if this is the place to post this kind of stuff, if it isnt let me know or move it
Hope its useful to someone.
Download:
http://code.google.com/p/jmonkey-asset-mapper/
I’m not sure I see what this would be used for. Do you have some use cases that might help make it clearer?
you can access the asset with ctrl+space, so you dont have to type out the string path all the time.
say you have a model with the path like this
Models/Player/Level1/player.j3o
the plugin makes it so you can access it like this
Assets.Models.Player.Level1.player
“Assets” being a generated class and Models is a static nested class in assets and player is a static nested class in Models(and so on for each folder) and, finally, player is a static String with the value of “Models/Player/Level1/player.j3o”
I find this useful for me, since i don’t like to type out strings
Hmm, interesting. I quite like that.
glad you like the idea. and i hope it works if you (or other ppl) decide to install it :P, if not let me know pls
Will try this out. I really like how this works in Android-development. Netbeans has a similar thing going with message-handling. It is really nice.
Uhm this is kinda nice but it flattens the names of the assets… So if you have two assets named “Hull.jpg” in different folders, what does it do? * The only advantage I see in this is that it gives code completion for assets, is it that what you want? If so, you can create code completion plugins and one based on the assets folder content would be relatively easy to do I guess. If its meant for parsing the contents of the assets in runtime, something like a text file with loader would be better I guess as you can read the contents of a class only via reflection. Not trying to bash this, maybe its exactly what you need, just trying to expand the options and/or give hints for other/better solutions.
Edit: Just see it doesn’t flatten them but makes a class structure… Still whats exactly the purpose?
Installed it, menu item appears. Selec the menu item but nothing happens. Can’t find any Assets-class, don’t see any messages or logs. Where is the class supposed to end up when generated?
normen said:
Edit: Just see it doesn't flatten them but makes a class structure.. Still whats exactly the purpose?
Mainly code completion of asset names. Also it helps a somewhat in keeping asset names in sync. When I rename an asset file from 'bar' to 'baz' and regenerate the Assets class I'll get a compiler error where I load the asset instead of discovering in runtime that I forgot to change the loadTexture("foo/bar) to loadTexture("foo/baz");
This is how netbeans handles messages in bundles and how Android in eclipse handles assets. Yes you can write code completion in other ways but why not use the built in one :)
@jmaasing said:
Mainly code completion of asset names. Also it helps a somewhat in keeping asset names in sync. When I rename an asset file from 'bar' to 'baz' and regenerate the Assets class I'll get a compiler error where I load the asset instead of discovering in runtime that I forgot to change the loadTexture("foo/bar) to loadTexture("foo/baz");
This is how netbeans handles messages in bundles and how Android in eclipse handles assets. Yes you can write code completion in other ways but why not use the built in one :)
Yeah, I think this is better and more flexibly implemented via the code completion system directly.. But this is of course more compatible with other IDEs etc.
@normen said:
Yeah, I think this is better and more flexibly implemented via the code completion system directly.. But this is of course more compatible with other IDEs etc.
It has a chance to indicate asset name mismatches between asset file names and code in CI-builds so I think it brings a little more to the table than code-completion in the editor, but it won't change your life :)
Yeah. I don’t really have a use for this as most of my assets are loaded from config where this wouldn’t help - but I can see how it would be useful in other cases. Code completion won’t detect missing (for example renamed) assets - you would also need to add something to do that and that wouldn’t be straightforward as you won’t always know whether a String is intended to be an asset path or not.
@jmaasing said:
It has a chance to indicate asset name mismatches between asset file names and code in CI-builds so I think it brings a little more to the table than code-completion in the editor, but it won't change your life :)
If its in the code parser we can do even more in the SDK like asset refactoring and error checking :)
Btw I don’t want to sound too dismissive… The fact that this works in other IDEs too makes it definitely interesting for its purpose and it should surely go to the contribution repo (for now)
I think this is definitely a step in the right direction… Even shader technique names, which I use all the time, I often misspel or miss a part of the path when typing
As others have mentioned, the fact that it generates a class makes it a bonus for integration with other IDE’s. Nicely done!
@jmaasing said:
Installed it, menu item appears. Selec the menu item but nothing happens. Can't find any Assets-class, don't see any messages or logs. Where is the class supposed to end up when generated?
in generates the class in you main project in a package called "generated"
@sbook said:
I think this is definitely a step in the right direction... Even shader technique names, which I use all the time, I often misspel or miss a part of the path when typing :)
As others have mentioned, the fact that it generates a class makes it a bonus for integration with other IDE's. Nicely done!
thx. if you have any suggestions let me know.
if any1 wants to join in on this project let me know and i’ll add you as a commiter
That’s nice. First time i saw android R thing, i was a bit dubious too, but i must say that in practice it’s kinda useful.