Maescool/Catacomb-Snatch — Issue #854: Major refactoring of MojamComponent
Author: fierydrake
Created: 2012-03-08 12:36:50+00:00
State: open

Cross-posted from #840:

I have a huge refactor of MojamComponent I'm working on in my local copy. You may or may not think this is a good idea.
Basically, it splits into a bunch of bits:
* GameLogic (most of tick())
* GameInput (interface)
* GameView (interface)
* CanvasGameView (implements GameInput & GameView)
* GameSound (interface)
* SoundPlayer (implements GameSound)
* Menus (a Deque to hold GuiMenus)
* LabelledClickableComponent (for locale-aware buttons, checkboxes and sliders)
* LocaleChangeListener (interface)
* ButtonAdapter (convenience class implementing ButtonListener with empty implementations)

Other changes:
* Texts now (statically) owns setLocale(), registers LocaleChangeListeners, informing them of locale changes
* GuiMenu listens to locale changes and tells all LabelledClickableComponents to update
* Buttons, Sliders and Checkboxes no longer have ids
* Subclasses of GuiMenu now define the effect of pressing buttons using ButtonListeners

This is a means to an end: that is to allow an easy interface (GameInput/GameView) to making adding SynchronizedNetworkView and UDPNetworkView (and corresponding RemoteGameLogic and potentially LocalGameLogic and ServerGameLogic -- may make these the same).

That way the RemoteGameLogic can implement response prediction and ServerGameLogic can inherit from LocalGameLogic and additionally implement lag compensation (in their UDP implementations, at least.) The SynchronizedNetworkView would use the current synchronized random approach.

This should also allow for other elements to be replaced. I might try and create a split-screen mode to test that the abstractions work okay.