Drag[en]gine Script Module DragonScript
1.21
|
Base class for game applications. More...
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... | |
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:
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.
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.
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.
|
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:
If WindowConsole is present this command is also added:
|
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:
|
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:
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.
|
protected |
Create and set desktop.
|
protected |
Create connection tracker.
Creates instance of ConnectionTracker.
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.
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.
InputProcessor Dragengine.BaseGameApp.createInputProcessorBindings | ( | ) |
Create input processor to forward events to binding manager.
InputProcessor Dragengine.BaseGameApp.createInputProcessorDesktop | ( | ) |
Create input processor to forward events to desktop widget.
|
protected |
Create network state tracker.
Creates instance of NetworkStateTracker.
|
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.
|
protected |
Create screen shot creater.
Creates instance of ScreenshotCreator and assigns console.
|
protected |
Create skin annotations.
Creates instance of SkinAnnotations. Subclass can overwrite to load skin annotations into the newly created object like this:
See LoadSkinAnnotations.loadFromFiles for details about the *.deskinann files.
|
protected |
Create translation manager.
Creates instance of TranslationManager.
|
protected |
Create trigger table.
Creates instance of TSTriggerTable.
|
protected |
Create console window.
Default implementation creates an instance of WinowConsole and assigns getConsole(). Subclass can return null to not use a console window.
|
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
|
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.
|
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.
DefaultBindingHelper Dragengine.BaseGameApp.defaultBindings | ( | ) |
Create default bindings.
Default implementation creates instance of DefaultBindingHelper with these bindings:
If WindowConsole is present these additional bindings are added:
If any of these commands are not present no binding is added form them.
Typical subclass implementation can look like this:
void Dragengine.BaseGameApp.desktopLoadGuiTheme | ( | String | filename | ) |
Load gui theme and assign it to desktop widget.
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.
|
static |
The one and only application object.
BindingManager Dragengine.BaseGameApp.getBindingManager | ( | ) |
Binding manager.
CommandManager Dragengine.BaseGameApp.getCommandManager | ( | ) |
Command Manager.
ParameterTree Dragengine.BaseGameApp.getConfiguration | ( | ) |
Game configuration.
ConnectionTracker Dragengine.BaseGameApp.getConnectionTracker | ( | ) |
Connection tracker.
Console Dragengine.BaseGameApp.getConsole | ( | ) |
Console object.
ConsoleCommandList Dragengine.BaseGameApp.getConsoleCommands | ( | ) |
Console command list.
Desktop Dragengine.BaseGameApp.getDesktop | ( | ) |
Desktop widget.
ElementClassList Dragengine.BaseGameApp.getElementClassList | ( | ) |
Element classes list.
GameWorldLoader Dragengine.BaseGameApp.getGameWorldLoader | ( | ) |
Game world loader or null.
GlobalEvents Dragengine.BaseGameApp.getGlobalEvents | ( | ) |
Global event manager.
MutableID Dragengine.BaseGameApp.getIDGenerator | ( | ) |
ID Generator.
InputProcessor Dragengine.BaseGameApp.getInputProcessor | ( | ) |
Input Processor.
bool Dragengine.BaseGameApp.getInverseLookVertical | ( | ) |
Invert looking up-down.
Loaders Dragengine.BaseGameApp.getLoaders | ( | ) |
Loaders.
float Dragengine.BaseGameApp.getMouseSensitivity | ( | ) |
Mouse sensitivity.
NetworkStateTracker Dragengine.BaseGameApp.getNetworkStateTracker | ( | ) |
Network state tracker.
ECBehaviorPlayerControllable.Tracker Dragengine.BaseGameApp.getPlayerControlledActor | ( | ) |
Player controlled actor tracker.
ScreenshotCreator Dragengine.BaseGameApp.getScreenshotCreator | ( | ) |
Screenshot creator.
ParameterTree Dragengine.BaseGameApp.getSettings | ( | ) |
Saved settings.
SkinAnnotations Dragengine.BaseGameApp.getSkinAnnotations | ( | ) |
Skin annotations.
TranslationManager Dragengine.BaseGameApp.getTranslationManager | ( | ) |
Translation manager.
TSTriggerTable Dragengine.BaseGameApp.getTriggerTable | ( | ) |
Trigger table.
WindowConsole Dragengine.BaseGameApp.getWindowConsole | ( | ) |
Console window toggled using CommandToggleConsole or null if absent.
WindowGameWorld Dragengine.BaseGameApp.getWindowGameWorld | ( | ) |
Game world window or null.
WindowPlayerChoice Dragengine.BaseGameApp.getWindowPlayerChoice | ( | ) |
PlayerChoice window or null if absent.
WindowSubTitle Dragengine.BaseGameApp.getWindowSubTitle | ( | ) |
SubTitle window or null if absent.
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:
The super-call also invoked these hook methods to do initialization work:
Reimplemented from Dragengine.Game.
Reimplemented in Dragengine.TestSystem.TestGameApp.
|
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:
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.
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.
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.
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.
|
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.
|
protected |
Load configuration from parameter tree XML file if present.
Uses pathConfiguration to located the file.
|
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.
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.
void Dragengine.BaseGameApp.onFrameUpdate | ( | ) |
Called by the game engine at the beginning of each frame update.
Performs the following actions:
Subclass has to super-call this method first before doing per-frame updates.
Reimplemented from Dragengine.Game.
Reimplemented in Dragengine.TestSystem.TestGameApp.
void Dragengine.BaseGameApp.onResizeRenderWindow | ( | ) |
Render window size changed.
Resizes desktop widget to fix primary canvas size.
Reimplemented from Dragengine.Game.
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() .
|
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.
void Dragengine.BaseGameApp.saveBindings | ( | ) |
Save bindings to the bindings file.
Uses property pathSavedBindings as file name.
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.
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().
void Dragengine.BaseGameApp.setInputProcessor | ( | InputProcessor | inputProcessor | ) |
Set input processor.
void Dragengine.BaseGameApp.setInputProcessorBindings | ( | ) |
Set input processor to forward events to binding manager.
void Dragengine.BaseGameApp.setInputProcessorDesktop | ( | ) |
Set input processor to forward events to desktop widget.
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.
void Dragengine.BaseGameApp.setInverseLookVertical | ( | bool | inverseLookVertical | ) |
Set if looking up-down is inverted.
Call saveSettings() after changing value. Not called automatically.
void Dragengine.BaseGameApp.setMouseSensitivity | ( | float | sensitivity | ) |
Set mouse sensitivity.
Call saveSettings() after changing value. Not called automatically.
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.
EInvalidParam | A game world loader is already active. |
void Dragengine.BaseGameApp.userRequestedQuit | ( | ) |
User requested window to be closed.
Default implementation calls quitGame().
Reimplemented from Dragengine.Game.
|
protected |
Default console buffer size.
Default value is 50.
|
protected |
Default binding input processor mouse axis scale factor.
Default value is 0.2.
|
protected |
Default binding input processor mouse wheel scale factor.
Default value is 0.2.
|
protected |
Name of default language pack to activate.
Default value is the current user locale language at the start of the game. If no such language pack is found internationalization is disabled.
|
protected |
Name of default language pack to activate.
Default value is "English". If no such language pack is found internationalization is disabled. The language pack name is matched case sensitive.
|
static |
Path of default gui theme provided by the DragonScript module.
|
static |
Global event send if input devices have been attached or detached.
The event receives no additional data.
|
static |
Global event send if input device parameters have changed.
The event receives no additional data.
|
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.
|
protected |
Desktop gui theme path property.
Set by default to defaultPathGuiTheme.
|
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.
|
protected |
Binding save file path property.
Default value is "/config/bindings.xml". "/config" has to match the "Config Path" set in the game project.
|
protected |
Application settings file path property.
Default value is "/config/settings.xml". "/config" has to match the "Config Path" set in the game project.
|
static |
Invert looking up-down setting key.
|
static |
Mouse sensitivity.