Class zodiac
- All Implemented Interfaces:
com.jme3.app.Application,com.jme3.system.SystemListener,iZodiacApp
Consider this a conductor - it contains a lot of references to other objects but should not be doing much actual work itself. It should only initialise and handle things that are meaningful across all application states. It is a singleton, we only expect one of these to exist at a time. Therefore all of its member fields will also only have one instance ever existing. Anything that is application-wide is created and managed here.
It listens and responds to windowevents through the eventbus. Changing between different states of the application is done through a finite state machine - window events can trigger state changes.
It is responsible for coordinating the setup of the GUI.
- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classImplements a singleton pattern.static classConnects the JME app states, a unique identifier and the finite state machine. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.google.common.collect.SetMultimap<appFSM.State,zodiac.ZSTATE>All the appstate identifiers to be enabled for each FSM state.private appFSM<appFSM.State,appFSM.Trigger>State machine that controls and transitions between the application states, enabling and disabling as required.private com.simsilica.es.EntityDataGlobal container holding all of the entities, components, setsprivate com.google.common.eventbus.AsyncEventBusThe JME application states communicate by posting and receiving gameEvents on this eventbus.private static org.slf4j.Loggerprivate sceneToImageScene processor attached to the application viewport.private com.google.common.eventbus.AsyncEventBusThe user interface communicates to JME through this eventBus.private com.thoughtworks.xstream.XStreamGlobal XStream object to interface with XML files.private zFrameThe GUI top level object.Fields inherited from class com.jme3.app.SimpleApplication
flyCam, fpsText, guiFont, guiNode, INPUT_MAPPING_CAMERA_POS, INPUT_MAPPING_EXIT, INPUT_MAPPING_HIDE_STATS, INPUT_MAPPING_MEMORY, rootNode, showSettingsFields inherited from class com.jme3.app.LegacyApplication
assetManager, audioRenderer, cam, context, guiViewPort, inputEnabled, inputManager, joyInput, keyInput, listener, lostFocusBehavior, mouseInput, paused, prof, renderer, renderManager, settings, speed, stateManager, timer, touchInput, viewPort -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatezodiac()Initialise global variables and datastructures, required before simpleInitApp() is called. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanDialog to confirm user want to exit.com.jme3.asset.AssetManagercom.google.common.eventbus.AsyncEventBusstatic zodiacImplement a singleton pattern so we only ever have one zodiac object.getSetting(gameConfig.keys key)TODO converted forms eg getIntSetting()com.jme3.system.AppSettingscom.google.common.eventbus.AsyncEventBuscom.thoughtworks.xstream.XStreamObtain the correctly configured XStream object from anywhere viazodiac.getInstance().getXstream()private voidinitGUI(int width, int height)Create the main application container - a frame with 'dockable' panels.private com.thoughtworks.xstream.XStreamInitialise the XStream system by identifying classes, converters etc.private voidonEntry(appFSM.State s)Callback from the FSM on entering a FSM state.voidrequestClose(boolean esc)voidsetSettings(com.jme3.system.AppSettings s)Annoyingly the JME application settings need to be set ~before~ we start the app so that the rendering dimensions are set correctly.voidCalled once by SimpleApplication when the application is started (zodiac.start()), prepares member fields such as XStream.voidsimpleUpdate(float tpf)This loop is empty! We moved everything cleanly into AppStates and Controls.voidstop()Shutdown all JME processing and exit the application.voidwindowEvent(windowEvent event)Listen on the eventbus for zodiac windowEvents.Methods inherited from class com.jme3.app.SimpleApplication
getFlyByCamera, getGuiNode, getRootNode, getSpeed, initialize, isShowSettings, loadGuiFont, setDisplayFps, setDisplayStatView, setShowSettings, setSpeed, simpleRender, start, updateMethods inherited from class com.jme3.app.LegacyApplication
createCanvas, destroy, destroyInput, enqueue, enqueue, gainFocus, getAppProfiler, getAudioRenderer, getCamera, getContext, getGuiViewPort, getInputManager, getListener, getLostFocusBehavior, getRenderer, getRenderManager, getStateManager, getTimer, getViewPort, handleError, isPauseOnLostFocus, loseFocus, reshape, restart, runQueuedTasks, setAppProfiler, setAssetManager, setLostFocusBehavior, setPauseOnLostFocus, setTimer, start, start, start, startCanvas, startCanvas, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface name.moore.kevin.ze.game.iZodiacApp
getRenderManager
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
allStates
All the appstate identifiers to be enabled for each FSM state. Built from ZSTATE eg State.READY ->{ ZR, ZLS, ... } -
zf
The GUI top level object. -
s2iProcessor
Scene processor attached to the application viewport. -
entityrepository
private com.simsilica.es.EntityData entityrepositoryGlobal container holding all of the entities, components, sets -
xstream
private com.thoughtworks.xstream.XStream xstreamGlobal XStream object to interface with XML files.initialised by
initXStream()when the app is initialised. -
gameBus
private com.google.common.eventbus.AsyncEventBus gameBusThe JME application states communicate by posting and receiving gameEvents on this eventbus.- See Also:
gameEvent
-
windowBus
private com.google.common.eventbus.AsyncEventBus windowBusThe user interface communicates to JME through this eventBus. -
appStateMachine
State machine that controls and transitions between the application states, enabling and disabling as required.
-
-
Constructor Details
-
zodiac
private zodiac()Initialise global variables and datastructures, required before simpleInitApp() is called.
-
-
Method Details
-
getInstance
Implement a singleton pattern so we only ever have one zodiac object.Obtain a 'new' zodiac object with zodiac.getInstance().
- Returns:
- the singleton instance
-
simpleInitApp
public void simpleInitApp()Called once by SimpleApplication when the application is started (zodiac.start()), prepares member fields such as XStream.Initialises the finite state machine, GUI, globals etal.
- Specified by:
simpleInitAppin classcom.jme3.app.SimpleApplication
-
simpleUpdate
public void simpleUpdate(float tpf)This loop is empty! We moved everything cleanly into AppStates and Controls.- Overrides:
simpleUpdatein classcom.jme3.app.SimpleApplication- Parameters:
tpf-
-
initGUI
private void initGUI(int width, int height)Create the main application container - a frame with 'dockable' panels. Setup the application viewport and scene processors.- Parameters:
width- pixels widthheight- pixels height
-
setSettings
public void setSettings(com.jme3.system.AppSettings s)Annoyingly the JME application settings need to be set ~before~ we start the app so that the rendering dimensions are set correctly.- Specified by:
setSettingsin interfacecom.jme3.app.Application- Overrides:
setSettingsin classcom.jme3.app.LegacyApplication- Parameters:
s- settings created from the gameconfig.
-
initXStream
private com.thoughtworks.xstream.XStream initXStream()Initialise the XStream system by identifying classes, converters etc.Called once when the application is initialised.
TODO can we figure a way of getting classes that need XStream to register themselves automatically? via a static? Having to hardcode in the required class names is pants. -
requestClose
public void requestClose(boolean esc)- Specified by:
requestClosein interfacecom.jme3.system.SystemListener- Overrides:
requestClosein classcom.jme3.app.LegacyApplication
-
stop
public void stop()Shutdown all JME processing and exit the application. Undo anything created in simpleInitApp(), Invoked when the GUI shuts down to also clear up JME.- Specified by:
stopin interfacecom.jme3.app.Application- Overrides:
stopin classcom.jme3.app.LegacyApplication
-
getXstream
public com.thoughtworks.xstream.XStream getXstream()Obtain the correctly configured XStream object from anywhere viazodiac.getInstance().getXstream()- Specified by:
getXstreamin interfaceiZodiacApp- Returns:
- prepared XStream object
-
getSettings
public com.jme3.system.AppSettings getSettings()- Specified by:
getSettingsin interfaceiZodiacApp- Returns:
- JMonkeyEngine application settings
-
getSetting
TODO converted forms eg getIntSetting()- Specified by:
getSettingin interfaceiZodiacApp- Parameters:
key- one of the gameConfig enums- Returns:
- a specific value from the application settings
-
getAssetManager
public com.jme3.asset.AssetManager getAssetManager()- Specified by:
getAssetManagerin interfacecom.jme3.app.Application- Specified by:
getAssetManagerin interfaceiZodiacApp- Overrides:
getAssetManagerin classcom.jme3.app.LegacyApplication- Returns:
- JMonkeyEngine assetManager
-
getGameBus
public com.google.common.eventbus.AsyncEventBus getGameBus()- Specified by:
getGameBusin interfaceiZodiacApp- Returns:
- the bus distributing gameEvents
-
getWindowBus
public com.google.common.eventbus.AsyncEventBus getWindowBus()- Specified by:
getWindowBusin interfaceiZodiacApp- Returns:
- the bus distributing windowEvents
-
windowEvent
Listen on the eventbus for zodiac windowEvents. Some events cause triggering state machine changes.- Parameters:
event-
-
doExitDialog
private boolean doExitDialog()Dialog to confirm user want to exit.- Returns:
-
onEntry
Callback from the FSM on entering a FSM state. Enable/disable appropriate application states. Its an assumption we can enter the state without restriction (the transition rules were in the FSM)- Parameters:
s- The FSM state we are entering.
-