Drag[en]gine Script Module DragonScript  1.21
Dragengine.BaseGameApp Class Reference

Base class for game applications. More...

Inheritance diagram for Dragengine.BaseGameApp:
Dragengine.Game Dragengine.TestSystem.TestGameApp

Classes

class  CollisionFilterBit
 Collision filter bits. More...
 
class  WorldLayerBit
 Layer masks. More...
 

Public Member Functions

void cancelLoadGameWorld ()
 Cancel loading game world. More...
 
void cleanUp ()
 Called by the game engine to clean up before the game exits. More...
 
BaseConversationPlayback createConversationPlayback (Conversation conversation)
 Create conversation playback. More...
 
InputProcessor createInputProcessorBindings ()
 Create input processor to forward events to binding manager. More...
 
InputProcessor createInputProcessorDesktop ()
 Create input processor to forward events to desktop widget. More...
 
DefaultBindingHelper defaultBindings ()
 Create default bindings. More...
 
void desktopLoadGuiTheme (String filename)
 Load gui theme and assign it to desktop widget. More...
 
void finishLoadGameWorld ()
 Finish loading game world. More...
 
BindingManager getBindingManager ()
 Binding manager. More...
 
CommandManager getCommandManager ()
 Command Manager. More...
 
ParameterTree getConfiguration ()
 Game configuration. More...
 
ConnectionTracker getConnectionTracker ()
 Connection tracker. More...
 
Console getConsole ()
 Console object. More...
 
ConsoleCommandList getConsoleCommands ()
 Console command list. More...
 
Desktop getDesktop ()
 Desktop widget. More...
 
ElementClassList getElementClassList ()
 Element classes list. More...
 
GameWorldLoader getGameWorldLoader ()
 Game world loader or null. More...
 
GlobalEvents getGlobalEvents ()
 Global event manager. More...
 
MutableID getIDGenerator ()
 ID Generator. More...
 
InputProcessor getInputProcessor ()
 Input Processor. More...
 
bool getInverseLookVertical ()
 Invert looking up-down. More...
 
Loaders getLoaders ()
 Loaders. More...
 
float getMouseSensitivity ()
 Mouse sensitivity. More...
 
NetworkStateTracker getNetworkStateTracker ()
 Network state tracker. More...
 
PanelHud getPanelHud ()
 Game world HUD panel or null. More...
 
ECBehaviorPlayerControllable.Tracker getPlayerControlledActor ()
 Player controlled actor tracker. More...
 
ScreenshotCreator getScreenshotCreator ()
 Screenshot creator. More...
 
ParameterTree getSettings ()
 Saved settings. More...
 
SkinAnnotations getSkinAnnotations ()
 Skin annotations. More...
 
TranslationManager getTranslationManager ()
 Translation manager. More...
 
TSTriggerTable getTriggerTable ()
 Trigger table. More...
 
WindowConsole getWindowConsole ()
 Console window toggled using CommandToggleConsole or null if absent. More...
 
WindowGameWorld getWindowGameWorld ()
 Game world window or null. More...
 
WindowPlayerChoice getWindowPlayerChoice ()
 PlayerChoice window or null if absent. More...
 
WindowSubTitle getWindowSubTitle ()
 SubTitle window or null if absent. More...
 
void initGame ()
 Called by game engine to init game. More...
 
void initSettings ()
 Init settings with default values. More...
 
void inputEvent (InputEvent event)
 Process input event. More...
 
BaseGameApp new ()
 Create game application. More...
 
void onFrameUpdate ()
 Called by the game engine at the beginning of each frame update. More...
 
void onResizeRenderWindow ()
 Render window size changed. More...
 
void quitGame ()
 Quit game. More...
 
void saveBindings ()
 Save bindings to the bindings file. More...
 
void saveSettings ()
 Save settings to the settings file. More...
 
void setDesktop (Desktop desktop)
 Set desktop widget. More...
 
void setInputProcessor (InputProcessor inputProcessor)
 Set input processor. More...
 
void setInputProcessorBindings ()
 Set input processor to forward events to binding manager. More...
 
void setInputProcessorDesktop ()
 Set input processor to forward events to desktop widget. More...
 
void setInputProcessorNothing ()
 Set input processor to nothing. More...
 
void setInverseLookVertical (bool inverseLookVertical)
 Set if looking up-down is inverted. More...
 
void setMouseSensitivity (float sensitivity)
 Set mouse sensitivity. More...
 
void startLoadGameWorld (GameWorldLoader loader)
 Start loading game world. More...
 
void userRequestedQuit ()
 User requested window to be closed. More...
 
- Public Member Functions inherited from Dragengine.Game
int getArgumentCount ()
 Number of command line arguments given to the game. More...
 
String getArgumentAt (int index)
 Command line argument given to the game. More...
 

Static Public Member Functions

static BaseGameApp getApp ()
 The one and only application object. More...
 

Static Public Attributes

static final String defaultPathGuiTheme = "/shareddata/guithemes/modern/modern.guitheme.xml"
 Path of default gui theme provided by the DragonScript module. More...
 
static String eventDeviceAttachedDetached = "deviceAttachedDetached"
 Global event send if input devices have been attached or detached. More...
 
static String eventDeviceParamsChanged = "deviceParamsChanged"
 Global event send if input device parameters have changed. More...
 
static final String settingInputInvertLookVertical = "input.invertLookVertical"
 Invert looking up-down setting key. More...
 
static final String settingInputMouseSensitivity = "input/mouseSensitivity"
 Mouse sensitivity. More...
 

Protected Member Functions

void createAndAddCommands ()
 Create commands and add them to command list. More...
 
void createAndAddConsoleCommands ()
 Create console commands and add them to console command list. More...
 
void createAndAddElementClasses ()
 Create element classes and add them to element class list. More...
 
void createAndSetDesktop ()
 Create and set desktop. More...
 
ConnectionTracker createConnectionTracker ()
 Create connection tracker. More...
 
NetworkStateTracker createNetworkStateTracker ()
 Create network state tracker. More...
 
PanelHud createPanelHud ()
 Create game world hud panel. More...
 
ScreenshotCreator createScreenshotCreator ()
 Create screen shot creater. More...
 
SkinAnnotations createSkinAnnotations ()
 Create skin annotations. More...
 
TranslationManager createTranslationManager ()
 Create translation manager. More...
 
TSTriggerTable createTriggerTable ()
 Create trigger table. More...
 
WindowConsole createWindowConsole ()
 Create console window. More...
 
WindowGameWorld createWindowGameWorld ()
 Create game world window. More...
 
WindowPlayerChoice createWindowPlayerChoice ()
 Create player choice window. More...
 
WindowSubTitle createWindowSubTitle ()
 Create sub title window. More...
 
void initLanguages ()
 Load language packs and select active language pack. More...
 
void loadBindings ()
 Load bindings from saved configuration or create default bindings. More...
 
void loadConfiguration ()
 Load configuration from parameter tree XML file if present. More...
 
void loadSettings ()
 Load settings from saved settings or set default settings. More...
 
void registerPersistencyFactories ()
 Register persistency factories. More...
 
Constructors

Protected Attributes

int defaultConsoleBufferSize
 Default console buffer size. More...
 
float defaultInputMouseAxisScale
 Default binding input processor mouse axis scale factor. More...
 
float defaultInputMouseWheelScale
 Default binding input processor mouse wheel scale factor. More...
 
String defaultLanguagePackIdentifier
 Name of default language pack to activate. More...
 
UnicodeString defaultLanguagePackName
 Name of default language pack to activate. More...
 
String pathConfiguration
 Configuration file path property. More...
 
String pathDesktopGuiTheme
 Desktop gui theme path property. More...
 
String pathLanguagePacks
 Path to directory containing language packs. More...
 
String pathSavedBindings
 Binding save file path property. More...
 
String pathSavedSettings
 Application settings file path property. More...
 

Detailed Description

Base class for game applications.

Basic implementation for game applications to use as super class. Provides various objects typically required to create a game with. This superclass can be used for 3D and 2D oriented projects alike. This class implements management logic but no game logic in any way. A typical subclass implementation looks like this:

pin Dragengine.Gui
pin Dragengine.Scenery
class ExampleApp extends BaseGameApp
// handles loading the game world and handing control over to the player
class LoadExampleGame extends WindowGameWorld.Loader
public func new(WindowGameWorld window, String path) super(window)
setPathWorld(path)
setDecalBuilder(MyExampleDecalBuilder.new())
end
public func void onLoadWorldFinished()
var BaseGameApp app = BaseGameApp.getApp()
var GameWorld gameWorld = getStubWorld().getGameWorld()
// do your game specific init work on gameWorld after loading
// spawn player actor and take control of it
var ElementClass elementClass = app.getElementClassList().getNamed("Actor")
var UniqueID uid = app.getIDGenerator().nextID()
var BaseActor player = StubElement.new(elementClass, uid).createElement() cast BaseActor
gameWorld.getSpawnPoints().getNamed("player").spawn(gameWorld, player)
player.getPlayerControllable().activate()
// make camera and microphone track player actor automatically
getWindow().setCameraDirector(PlayerControlledActorCameraDirector.new())
// finish up and switch control to be processed by bindings
super.onLoadWorldFinished()
end
public func void onLoadWorldFailed()
super.onLoadWorldFailed()
BaseGameApp.getApp().cancelLoadGameWorld()
// fall back to main menu for example
end
end
public func new()
pathDesktopGuiTheme = "/content/ui/main.guitheme.xml"
// set more properties here if required. do all init work in initGame()
end
public func void initGame()
super.initGame()
// do all your initialization work here load the game world.
// control will be handed to player once loading finished
startLoadGameWorld(LoadExampleGame.new(getWindowGameWorld(), "/content/world/game.deworld"))
end
public func void cleanUp()
// clean and everything
super.cleanUp()
end
end
static BaseGameApp getApp()
The one and only application object.
void finishLoadGameWorld()
Finish loading game world.
void startLoadGameWorld(GameWorldLoader loader)
Start loading game world.
ElementClassList getElementClassList()
Element classes list.
String pathDesktopGuiTheme
Desktop gui theme path property.
Definition: BaseGameApp.ds:293
MutableID getIDGenerator()
ID Generator.
void setInputProcessorBindings()
Set input processor to forward events to binding manager.
void cancelLoadGameWorld()
Cancel loading game world.
BaseGameApp new()
Create game application.
void cleanUp()
Called by the game engine to clean up before the game exits.
void initGame()
Called by game engine to init game.

This initializes the game and starts loading a game world. Once the loading finishes the control is handed over to the player. Instead of directly loading the game a main menu can be shown instead in initGame() which then does the game loading in time.

This class is designed to be used as singleton. Use the getApp() method everywhere to obtain the one and only game application instance.

Member Function Documentation

◆ cancelLoadGameWorld()

void Dragengine.BaseGameApp.cancelLoadGameWorld ( )

Cancel loading game world.

If no game world loader is active this method does nothing. Otherwise cancelLoading() and dispose() is called on the active game world. After this call returns no game world loader is active.

◆ cleanUp()

void Dragengine.BaseGameApp.cleanUp ( )

Called by the game engine to clean up before the game exits.

Subclas has to super-call this method last after cleaing up.

After this super-call BaseGameApp.getApp() returns null.

Reimplemented from Dragengine.Game.

◆ createAndAddCommands()

void Dragengine.BaseGameApp.createAndAddCommands ( )
protected

Create commands and add them to command list.

Commands are used by the BindingInputProcessor to bind player actions to player input. Default implementation creates and adds these commands:

  • CommandQuitGame named "quit"
  • CommandScreenshot named "screenshot"
  • Commands from CommandsBAAMovement
  • Commands from CommandsBAAInteract

If WindowConsole is present this command is also added:

  • CommandToggleConsole named "toggleConsole"

◆ createAndAddConsoleCommands()

void Dragengine.BaseGameApp.createAndAddConsoleCommands ( )
protected

Create console commands and add them to console command list.

Console commands are used by WindowConsole (more precisely the ConsoleInputField inside) to allow players and mostly developers to run actions not supposed to be bound to player input. Default implementation creates and adds these console commands:

  • HelpConsoleCommand named "help"
  • GraSysConsoleCommand named "graphicSystem"
  • PhySysConsoleCommand named "physicsSystem"
  • AISysConsoleCommand named "aiSystem"
  • LanguageConsoleCommand named "language"

◆ createAndAddElementClasses()

void Dragengine.BaseGameApp.createAndAddElementClasses ( )
protected

Create element classes and add them to element class list.

Element classes list contains all element classes world files are allowed to be used. Default implementation creates and adds these element classes:

  • AnimatedElementClass named "AnimatedElement"
  • AttachableBaseLightClass named "AttachableBaseLight"
  • AttachableBaseSpeakerClass named "AttachableBaseSpeaker"
  • AttachableBaseParticleEmitterClass named "AttachableBaseParticleEmitter"
  • AttachableBaseForceFieldClass named "AttachableBaseForceField"
  • AttachableBillboardClass named "AttachableBillboard"
  • BaseActorClass named "Actor"
  • BaseVRActorClass named "VRActor" (since version 1.6)
  • BaseSpeakerClass named "BaseSpeaker"
  • BaseParticleEmitterClass named "BaseParticleEmitter"
  • BaseSkyClass named "BaseSky"
  • BaseLightClass named "BaseLight"
  • BaseForceFieldClass named "BaseForceField"
  • EnvironmentMapClass named "EnvironmentMap"
  • HiddenElementClass named "HiddenElement"
  • IgnoreElementClass named "MapperNote" (helper IGDE class)
  • IgnoreElementClass named "VirtualElement" (helper IGDE class)
  • InfoConvoCoordSystem named "InfoConvoCoordSystem"
  • RailCornerClass named "RailCorner"
  • RandomElementClass named "RandomElement"
  • SimpleElementClass named "SimpleElement"
  • PhysicsElementClass named "PhysicsElement"
  • SimpleElementOnRailClass named "SimpleElementOnRail"
  • BaseBillboardClass named "BaseBillboard"
  • SpawnPointClass named "SpawnPoint"
  • TriggerConversationClass named "TriggerConversation"
  • TriggerEvaluateClass named "TriggerEvaluate"
  • TriggerShoutClass named "TriggerShout"
  • TriggerTimerClass named "TriggerTimer"
  • TriggerToggleClass named "TriggerToggle"
  • TriggerTouchClass named "TriggerTouch"
  • TwoStateAnimatedElement named "TwoStateAnimatedElement"

If you do not want one of these classes to be available you can remove them after super-calling createAndAddElementClasses() by using ElementClassList.removeNamed(). Optionally you can not super-call createAndAddElementClasses() to add the element classes above manually according to your needs.

◆ createAndSetDesktop()

void Dragengine.BaseGameApp.createAndSetDesktop ( )
protected

Create and set desktop.

◆ createConnectionTracker()

ConnectionTracker Dragengine.BaseGameApp.createConnectionTracker ( )
protected

Create connection tracker.

Creates instance of ConnectionTracker.

◆ createConversationPlayback()

BaseConversationPlayback Dragengine.BaseGameApp.createConversationPlayback ( Conversation  conversation)

Create conversation playback.

Create instance of BaseConversationPlayback. Overwrite to create playback supporting game specific features like obtaining conversation actors and coordinate system by identifier and running game commands and conditions.

For many game projects the base BaseConversationPlayback implementation is enough with game specific behavior defined by adding game commands and game conditions. This example shows a typical subclass implementation for this common scenario.

public func BaseConversationPlayback createConversationPlayback(Conversation conversation)
var BaseConversationPlayback playback = super.createConversationPlayback(conversation)
playback.addCommand("player", PlayerGameCommand.new())
playback.addCondition("player", PlayerGameCondition.new())
return playback
end
BaseConversationPlayback createConversationPlayback(Conversation conversation)
Create conversation playback.

Where PlayerGameCommand implements BaseConversationPlayback.ConversationCommand and PlayerGameCondition implements BaseConversationPlayback.ConversationCondition. Conversation scripts can then use "player arg1 arg2 ... argN" game command and game condition with the classes above receiving the command conveniently as Array of String.

Any number of commands and conditions can be added easily this way without needing to subclass BaseConversationPlayback.

◆ createInputProcessorBindings()

InputProcessor Dragengine.BaseGameApp.createInputProcessorBindings ( )

Create input processor to forward events to binding manager.

Version
1.18

◆ createInputProcessorDesktop()

InputProcessor Dragengine.BaseGameApp.createInputProcessorDesktop ( )

Create input processor to forward events to desktop widget.

Version
1.18

◆ createNetworkStateTracker()

NetworkStateTracker Dragengine.BaseGameApp.createNetworkStateTracker ( )
protected

Create network state tracker.

Creates instance of NetworkStateTracker.

◆ createPanelHud()

PanelHud Dragengine.BaseGameApp.createPanelHud ( )
protected

Create game world hud panel.

Default implementation creates an instance of PanelHud. Subclass can return null to not use a game world hud panel or changing parameters.

◆ createScreenshotCreator()

ScreenshotCreator Dragengine.BaseGameApp.createScreenshotCreator ( )
protected

Create screen shot creater.

Version
1.19

Creates instance of ScreenshotCreator and assigns console.

◆ createSkinAnnotations()

SkinAnnotations Dragengine.BaseGameApp.createSkinAnnotations ( )
protected

Create skin annotations.

Creates instance of SkinAnnotations. Subclass can overwrite to load skin annotations into the newly created object like this:

protected func SkinAnnotations createSkinAnnotations()
var sa = super.createSkinAnnotations()
getLoaders().getSkinAnnotations().loadFromFiles(sa, "/content/materials", true)
return sa
end
SkinAnnotations getSkinAnnotations()
Skin annotations.
SkinAnnotations createSkinAnnotations()
Create skin annotations.
Loaders getLoaders()
Loaders.

See LoadSkinAnnotations.loadFromFiles for details about the *.deskinann files.

◆ createTranslationManager()

TranslationManager Dragengine.BaseGameApp.createTranslationManager ( )
protected

Create translation manager.

Version
1.21

Creates instance of TranslationManager.

◆ createTriggerTable()

TSTriggerTable Dragengine.BaseGameApp.createTriggerTable ( )
protected

Create trigger table.

Creates instance of TSTriggerTable.

◆ createWindowConsole()

WindowConsole Dragengine.BaseGameApp.createWindowConsole ( )
protected

Create console window.

Default implementation creates an instance of WinowConsole and assigns getConsole(). Subclass can return null to not use a console window.

◆ createWindowGameWorld()

WindowGameWorld Dragengine.BaseGameApp.createWindowGameWorld ( )
protected

Create game world window.

Default implementation creates an instance of WindowGameWorld. Subclass can return null to not use a game world window or changing window parameters for example to hide it if a main menu requires

◆ createWindowPlayerChoice()

WindowPlayerChoice Dragengine.BaseGameApp.createWindowPlayerChoice ( )
protected

Create player choice window.

Default implementation creates an instance of WindowPlayerChoice. Subclass can return null to not use a player choise window. For conversations to work an instance implementing the conversation player choice interface is required. WindowPlayerChoice does fulfill this requirement.

◆ createWindowSubTitle()

WindowSubTitle Dragengine.BaseGameApp.createWindowSubTitle ( )
protected

Create sub title window.

Default implementation creates an instance of WindowSubTitle. Subclass can return null to not use a subtitle window. For conversations to work an instance implementing the conversation subtitle interface is required. WindowSubTitle does fulfill this requirement.

◆ defaultBindings()

DefaultBindingHelper Dragengine.BaseGameApp.defaultBindings ( )

Create default bindings.

Default implementation creates instance of DefaultBindingHelper with these bindings:

  • "quit" mapped to key "Escape" and "Q"
  • "screenshot" mapped to key "F10"

If WindowConsole is present these additional bindings are added:

  • "toggleConsole" mapped to "F1"

If any of these commands are not present no binding is added form them.

Typical subclass implementation can look like this:

var DefaultBindingHelper helper = DefaultBindingHelper.new()
// or use the super-call created helper
if helper.hasMouse()
helper.mouseBindMove("analogTurn", "analogLook")
helper.mouseBindWheel(0, "prevItem", "nextItem")
helper.mouseBindLMR("use", "putAwayItem", "equipItem")
end
if helper.hasKeyboard()
helper.keyboardBindKeyCode(InputEventKey.escape, "showMainMenu")
// more keyboard bindings
end
if helper.hasGamepad()
helper.gamepadBindStick(0, "turnLeft", "turnRight", "lookUp", "lookDown")
helper.gamepadBindButton(0, "use")
// more game pad button and axis bindings
end

◆ desktopLoadGuiTheme()

void Dragengine.BaseGameApp.desktopLoadGuiTheme ( String  filename)

Load gui theme and assign it to desktop widget.

◆ finishLoadGameWorld()

void Dragengine.BaseGameApp.finishLoadGameWorld ( )

Finish loading game world.

If no game world loader is active this method does nothing. Otherwise calls dispose() on the active game world. After this call returns no game world loader is active.

◆ getApp()

static BaseGameApp Dragengine.BaseGameApp.getApp ( )
static

The one and only application object.

◆ getBindingManager()

BindingManager Dragengine.BaseGameApp.getBindingManager ( )

Binding manager.

◆ getCommandManager()

CommandManager Dragengine.BaseGameApp.getCommandManager ( )

Command Manager.

◆ getConfiguration()

ParameterTree Dragengine.BaseGameApp.getConfiguration ( )

Game configuration.

◆ getConnectionTracker()

ConnectionTracker Dragengine.BaseGameApp.getConnectionTracker ( )

Connection tracker.

◆ getConsole()

Console Dragengine.BaseGameApp.getConsole ( )

Console object.

◆ getConsoleCommands()

ConsoleCommandList Dragengine.BaseGameApp.getConsoleCommands ( )

Console command list.

◆ getDesktop()

Desktop Dragengine.BaseGameApp.getDesktop ( )

Desktop widget.

◆ getElementClassList()

ElementClassList Dragengine.BaseGameApp.getElementClassList ( )

Element classes list.

◆ getGameWorldLoader()

GameWorldLoader Dragengine.BaseGameApp.getGameWorldLoader ( )

Game world loader or null.

◆ getGlobalEvents()

GlobalEvents Dragengine.BaseGameApp.getGlobalEvents ( )

Global event manager.

◆ getIDGenerator()

MutableID Dragengine.BaseGameApp.getIDGenerator ( )

ID Generator.

◆ getInputProcessor()

InputProcessor Dragengine.BaseGameApp.getInputProcessor ( )

Input Processor.

◆ getInverseLookVertical()

bool Dragengine.BaseGameApp.getInverseLookVertical ( )

Invert looking up-down.

◆ getLoaders()

Loaders Dragengine.BaseGameApp.getLoaders ( )

Loaders.

◆ getMouseSensitivity()

float Dragengine.BaseGameApp.getMouseSensitivity ( )

Mouse sensitivity.

Version
1.18

◆ getNetworkStateTracker()

NetworkStateTracker Dragengine.BaseGameApp.getNetworkStateTracker ( )

Network state tracker.

◆ getPanelHud()

PanelHud Dragengine.BaseGameApp.getPanelHud ( )

Game world HUD panel or null.

◆ getPlayerControlledActor()

ECBehaviorPlayerControllable.Tracker Dragengine.BaseGameApp.getPlayerControlledActor ( )

Player controlled actor tracker.

◆ getScreenshotCreator()

ScreenshotCreator Dragengine.BaseGameApp.getScreenshotCreator ( )

Screenshot creator.

◆ getSettings()

ParameterTree Dragengine.BaseGameApp.getSettings ( )

Saved settings.

◆ getSkinAnnotations()

SkinAnnotations Dragengine.BaseGameApp.getSkinAnnotations ( )

Skin annotations.

◆ getTranslationManager()

TranslationManager Dragengine.BaseGameApp.getTranslationManager ( )

Translation manager.

◆ getTriggerTable()

TSTriggerTable Dragengine.BaseGameApp.getTriggerTable ( )

Trigger table.

◆ getWindowConsole()

WindowConsole Dragengine.BaseGameApp.getWindowConsole ( )

Console window toggled using CommandToggleConsole or null if absent.

◆ getWindowGameWorld()

WindowGameWorld Dragengine.BaseGameApp.getWindowGameWorld ( )

Game world window or null.

◆ getWindowPlayerChoice()

WindowPlayerChoice Dragengine.BaseGameApp.getWindowPlayerChoice ( )

PlayerChoice window or null if absent.

◆ getWindowSubTitle()

WindowSubTitle Dragengine.BaseGameApp.getWindowSubTitle ( )

SubTitle window or null if absent.

◆ initGame()

void Dragengine.BaseGameApp.initGame ( )

Called by game engine to init game.

Subclass has to super-call this method first before doing own initialization. Once this super-call returns all object instance provided by this class are created. Initializing the content of the object instances is up to the subclass. This is done either inside subclass initGame() implementation or one of the called hook methods.

After this super-call returns the following is true:

  • BaseGameApp.getApp() returns this object instance.
  • Console has a history of 50 entries.
  • Console has a LogConsoleMessages listener added.
  • InputSystem.setCaptureInputDevices() is set to true.
  • Desktop widget is present with designer "Desktop".
  • The default gui theme is loaded and assigned to the desktop widget.
  • Input processor is set to forward input to the desktop widget.
  • Console window potentially created and added to desktop (hidden)
  • Game world window potentially created and added to desktop
  • Bindings have been loaded from the saved bindings file or default bindings created

The super-call also invoked these hook methods to do initialization work:

Reimplemented from Dragengine.Game.

Reimplemented in Dragengine.TestSystem.TestGameApp.

◆ initLanguages()

void Dragengine.BaseGameApp.initLanguages ( )
protected

Load language packs and select active language pack.

Default implementation loads language packs from path specified by property pathLanguagePacks if property is not null and path is valid. Activates the language pack with the first matching identifier from the below list:

  • Configuration property named "defaultLanguagePackIdentifier"
  • Current user locale language
  • Class property defaultLanguagePackIdentifier The language pack identifier is matched case sensitive.
Since Version 1.16

Sets fallback language pack to active language pack. When changing language pack the fallback language pack stays untouched. This ensures default language translations are shown if the active translation is missing translations.

◆ initSettings()

void Dragengine.BaseGameApp.initSettings ( )

Init settings with default values.

Set the value of all settings supported by the application. Once saved the players can modify the settings file and knows all possible settings without searching.

◆ inputEvent()

void Dragengine.BaseGameApp.inputEvent ( InputEvent  event)

Process input event.

Checks the input event with the BindingManager and then sends the event to the active input processor. Make sure a valid InputProcessor is always set.

There is usually no need to overwrite this method in a subclass. If you do so super-call this method first.

Version 1.20

Upon receiving an event of type InputEventType.deviceAttachedDetached or InputEventType.deviceParamsChanged a global event is send. The event name is BaseGameApp.eventDeviceAttachedDetached respectively BaseGameApp.eventDeviceParamsChanged. Both events receive no additional arguments. The event is send before the active InputProcessor receives the event for processing.

Reimplemented from Dragengine.Game.

◆ loadBindings()

void Dragengine.BaseGameApp.loadBindings ( )
protected

Load bindings from saved configuration or create default bindings.

Loads the saved configuration from pathSavedBindings property. If the saved bindings file is absent or damaged default bindings are created.

If you change bindings call saveBindings() to save the bindings to the saved file. It is best to save changes to the bindings immediately.

Default bindings are not saved automatically. This has two main reasons. First the default bindings can be potentially created because of a damaged binding save file. Not saving them allows the user to quit the game and fix the file manually if desired. Second games not based on bindings should not save a useless binding file.

No implementation in this class calls saveBindings() itself. As long as you do not call saveBindings() on your own no bindings save file will be produced.

◆ loadConfiguration()

void Dragengine.BaseGameApp.loadConfiguration ( )
protected

Load configuration from parameter tree XML file if present.

Uses pathConfiguration to located the file.

◆ loadSettings()

void Dragengine.BaseGameApp.loadSettings ( )
protected

Load settings from saved settings or set default settings.

Loads the saved settings from pathSavedSettings property. If the saved settings file is absent or damaged set default settings and saves the file. Ensures a valid settings file with all known settings is saved to file. This way players can modify the settings file and know all possible settings without needing to search.

If you change settings call saveSettings() to save the settings to the saved file. It is best to save changes to the bindings immediately.

◆ new()

BaseGameApp Dragengine.BaseGameApp.new ( )

Create game application.

Empty implementation. All initialization tasks have to be done in the initGame() method call to support proper hook-method calls with custom subclass behavior.

Reimplemented from Dragengine.Game.

Reimplemented in Dragengine.TestSystem.TestGameApp.

◆ onFrameUpdate()

void Dragengine.BaseGameApp.onFrameUpdate ( )

Called by the game engine at the beginning of each frame update.

Performs the following actions:

  • Advances default TimerManager
  • Notifies all listeners in default FrameUpdateManager
  • Updates screenshot creator

Subclass has to super-call this method first before doing per-frame updates.

Reimplemented from Dragengine.Game.

Reimplemented in Dragengine.TestSystem.TestGameApp.

◆ onResizeRenderWindow()

void Dragengine.BaseGameApp.onResizeRenderWindow ( )

Render window size changed.

Resizes desktop widget to fix primary canvas size.

Reimplemented from Dragengine.Game.

◆ quitGame()

void Dragengine.BaseGameApp.quitGame ( )

Quit game.

Called by CommandQuitGame or by other scripts. Calls Engine.quit() to quit the game the next time possible. This will call cleanUp(). Make sure no reference loops are present after cleanUp() finishes to allow the Script Module to properly shut down.

Subclass can overwrite to ask user first if he wants to quit and optionally do some additional closing actions. To close the game call Engine.quit() .

◆ registerPersistencyFactories()

void Dragengine.BaseGameApp.registerPersistencyFactories ( )
protected

Register persistency factories.

Persistency factories allow saving and loading object instances implementing the Persistable interface for use with save states or network play. While creating the Loaders instance Loaders.addDefaultPersistencyFactories() adds all persistency factories provided by the DragonScript module. Subclass can implement registerPersistencyFactories() to add game specific persistency factories. Default implementation is empty. Super-calling is not required.

◆ saveBindings()

void Dragengine.BaseGameApp.saveBindings ( )

Save bindings to the bindings file.

Uses property pathSavedBindings as file name.

◆ saveSettings()

void Dragengine.BaseGameApp.saveSettings ( )

Save settings to the settings file.

Uses property pathSavedSettings as file name. If the file exists already creates first a backup copy with ".backup" appended to pathSavedBindings.

◆ setDesktop()

void Dragengine.BaseGameApp.setDesktop ( Desktop  desktop)

Set desktop widget.

Disposes of the old desktop if present and sets the new one. The new desktop is added to the primary canvas making it visible on screen. During resizing events the desktop is adjusted to fit the size to the primary canvas size.

This method does not modify the input processor. To change input processor to send events to the set desktop instance call setInputProcessorDesktop().

◆ setInputProcessor()

void Dragengine.BaseGameApp.setInputProcessor ( InputProcessor  inputProcessor)

Set input processor.

◆ setInputProcessorBindings()

void Dragengine.BaseGameApp.setInputProcessorBindings ( )

Set input processor to forward events to binding manager.

◆ setInputProcessorDesktop()

void Dragengine.BaseGameApp.setInputProcessorDesktop ( )

Set input processor to forward events to desktop widget.

◆ setInputProcessorNothing()

void Dragengine.BaseGameApp.setInputProcessorNothing ( )

Set input processor to nothing.

This is useful in situation where your game transitions from one input situation to another and you do not want to have any user interaction causing disturbances.

◆ setInverseLookVertical()

void Dragengine.BaseGameApp.setInverseLookVertical ( bool  inverseLookVertical)

Set if looking up-down is inverted.

Call saveSettings() after changing value. Not called automatically.

◆ setMouseSensitivity()

void Dragengine.BaseGameApp.setMouseSensitivity ( float  sensitivity)

Set mouse sensitivity.

Version
1.18

Call saveSettings() after changing value. Not called automatically.

◆ startLoadGameWorld()

void Dragengine.BaseGameApp.startLoadGameWorld ( GameWorldLoader  loader)

Start loading game world.

Calls startLoading() on loader. If this throws an exception cancelLoading() and dispose() is called on loader. Hence you do not have to worry about loader leaking if an exception is thrown.

Exceptions
EInvalidParamA game world loader is already active.

◆ userRequestedQuit()

void Dragengine.BaseGameApp.userRequestedQuit ( )

User requested window to be closed.

Default implementation calls quitGame().

Reimplemented from Dragengine.Game.

Member Data Documentation

◆ defaultConsoleBufferSize

int Dragengine.BaseGameApp.defaultConsoleBufferSize
protected

Default console buffer size.

Version
1.7

Default value is 50.

◆ defaultInputMouseAxisScale

float Dragengine.BaseGameApp.defaultInputMouseAxisScale
protected

Default binding input processor mouse axis scale factor.

Version
1.18

Default value is 0.2.

◆ defaultInputMouseWheelScale

float Dragengine.BaseGameApp.defaultInputMouseWheelScale
protected

Default binding input processor mouse wheel scale factor.

Version
1.18

Default value is 0.2.

◆ defaultLanguagePackIdentifier

String Dragengine.BaseGameApp.defaultLanguagePackIdentifier
protected

Name of default language pack to activate.

Version
1.16

Default value is the current user locale language at the start of the game. If no such language pack is found internationalization is disabled.

◆ defaultLanguagePackName

UnicodeString Dragengine.BaseGameApp.defaultLanguagePackName
protected

Name of default language pack to activate.

Deprecated:
Use defaultLanguagePackIdentifier.

Default value is "English". If no such language pack is found internationalization is disabled. The language pack name is matched case sensitive.

◆ defaultPathGuiTheme

final String Dragengine.BaseGameApp.defaultPathGuiTheme = "/shareddata/guithemes/modern/modern.guitheme.xml"
static

Path of default gui theme provided by the DragonScript module.

◆ eventDeviceAttachedDetached

String Dragengine.BaseGameApp.eventDeviceAttachedDetached = "deviceAttachedDetached"
static

Global event send if input devices have been attached or detached.

Version
1.20

The event receives no additional data.

◆ eventDeviceParamsChanged

String Dragengine.BaseGameApp.eventDeviceParamsChanged = "deviceParamsChanged"
static

Global event send if input device parameters have changed.

Version
1.20

The event receives no additional data.

◆ pathConfiguration

String Dragengine.BaseGameApp.pathConfiguration
protected

Configuration file path property.

Default value is "/configuration.ptree.xml". Change this property before initGame is called if the configuration parameter tree file is located in a different place.

Using a configuration parameter tree file is optional. If the file is not present it is not loaded. Can also be set to null in this case.

If the configuration file is present and values exist matching properties defined in this class the configuration file values take precendence. This allows to modify the properties without having to change source files.

◆ pathDesktopGuiTheme

String Dragengine.BaseGameApp.pathDesktopGuiTheme
protected

Desktop gui theme path property.

Set by default to defaultPathGuiTheme.

◆ pathLanguagePacks

String Dragengine.BaseGameApp.pathLanguagePacks
protected

Path to directory containing language packs.

Default value is null. To support internationalization in your game set the property to a valid path. Also set default language property if required.

◆ pathSavedBindings

String Dragengine.BaseGameApp.pathSavedBindings
protected

Binding save file path property.

Default value is "/config/bindings.xml". "/config" has to match the "Config Path" set in the game project.

◆ pathSavedSettings

String Dragengine.BaseGameApp.pathSavedSettings
protected

Application settings file path property.

Default value is "/config/settings.xml". "/config" has to match the "Config Path" set in the game project.

◆ settingInputInvertLookVertical

final String Dragengine.BaseGameApp.settingInputInvertLookVertical = "input.invertLookVertical"
static

Invert looking up-down setting key.

Note
The '.' separator is deprecated. Future values should use '/' separator.

◆ settingInputMouseSensitivity

final String Dragengine.BaseGameApp.settingInputMouseSensitivity = "input/mouseSensitivity"
static

Mouse sensitivity.

Version
1.18

The documentation for this class was generated from the following file: