Facade support

Mike Kienenberger

Active Member
Contributor
Architecture
GUI
One of the things I noticed about Facades is that there is no support currently for key binding and system registration (possibly other things) due to a facade being neither a module nor on the engine classpath (I'm guessing a little for the engine part). I think we need to treat whatever Facade started the engine as part of the engine module.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Yeah there is a lot of stuff to flesh out for facade structure. I'm honestly not sure how to go about it - I usually just start things that might be useful and see where they can be taken :)
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Facade should be on the engine classpath (or rather, then engine is on the facade's classpath). But only the engine jar is treated as a module. Could change this to treating the entire classpath as the engine module.
 

Mike Kienenberger

Active Member
Contributor
Architecture
GUI
It turns out this wasn't a module or classpath issue.

The facade is already included in the engine jar and if you're running it from an IDE, the engine jar isn't used, and the combination of the engine classpath, the facade classpath, and the tera-ovr.jar are used.

After much debugging, the problem turned out to be a missing call to config.getInput().getBinds().updateForChangedMods(); in the awt engine's postInitialize(). Without the call, @DefaultBinding event information is never processed.

Edit: Moving key bind conflict topic to a new thread
 

Mike Kienenberger

Active Member
Contributor
Architecture
GUI
I found a new problem with Facades. Assets cannot be resolved from a Facade as only the engine classpath is checked for assets. I found no trivial way to provide an additional asset source, so I ended up using this in AwtGraphics.postInitialise():

Code:
        ClasspathSource sourceFacade = new ClasspathSource(TerasologyConstants.ENGINE_MODULE,
                getClass().getProtectionDomain().getCodeSource(), TerasologyConstants.ASSETS_SUBDIRECTORY, TerasologyConstants.OVERRIDES_SUBDIRECTORY);
        ClasspathSource sourceEngine = new ClasspathSource(TerasologyConstants.ENGINE_MODULE,
                TerasologyConstants.class.getProtectionDomain().getCodeSource(), TerasologyConstants.ASSETS_SUBDIRECTORY, TerasologyConstants.OVERRIDES_SUBDIRECTORY);
        AssetSourceCollection source = new AssetSourceCollection(TerasologyConstants.ENGINE_MODULE, sourceFacade, sourceEngine);
        assetManager.addAssetSource(source);
I have submitted a PR for adding AssetSourceCollection. I am uncertain that AwtGraphics.postInitialize() is the best place for this. Also, it would be better if addAssetSource() did the combining if two asset sources with the same id were added. Right now, adding a second asset source for the same id replaces the existing one. I guess another option would be to allow assetManager.getSource(id) so that the caller could combine them, but that doesn't seem as clean, and the add method already implies that new asset sources are added rather than replaced.
 
Top