-
Notifications
You must be signed in to change notification settings - Fork 29
Configuration files
DGEngine use JSON files to create user interfaces and everything that happens in-game.
These JSON files are not 100% valid JSON files, since you can have repeated elements (not standard JSON).
They are processed in order.
First, let's analyse the provided main.json.
{
"title" : "Diablo",
"version": "1.09",
"refWindowSize": [640, 480],
"minWindowSize": [800, 600],
"windowSize": [800, 600],
"framerate": 60,
"keepAR": true,
"stretchToFit": true,
"smoothScreen": true,
"init": true,
"mountFile": [
{ "file": "DIABDAT.zip", "append": true }
],
"action": {
"name": "if.fileExists",
"param1": "ui_art/title.pcx",
"then": { "name": "load", "file": "ui/loadMain.json" },
"else": { "name": "load", "file": "ui/dataMissing.json" }
}
}title - String that is shown in the game window's title.
version - String that identifies the version. Can be used with if clauses when making mods that use previous game files.
refWindowSize - Array with reference width and height. Used to position game elements on screen. Diablo's reference size is [640, 480], so if you add an element at position [10, 10] that is anchored to nothing, it will be positioned in the appropriate screen position of the current window size.
Default value is [640, 480].
minWindowSize - Array with the minimum window width and height. You can't resize the window below this.
Default value is [640, 480].
windowSize - Array with the current window width and height. Change this to resize the game window.
Default value is [640, 480].
framerate - Game frame rate. Use value between 30 and 60.
Default value is 60.
keepAR - Boolean that defines if game windows keeps the aspect ratio when resizing and stretching is on.
Default value is true.
stretchToFit - Boolean that defines if the game windows stretches the content when resized. It uses the minWindowSize as the stretching size.
Default value is false.
init - initializes (opens) the game window. call only once at game initialization.
To see all of the supported options, see:
https://github.com/dgcor/DGEngine/blob/master/src/Parser/ParseFile.cpp
"action": {
"name": "if.fileExists",
...
}To see more about actions, check the Actions wiki page.
"mountFile": {
"file": "DIABDAT.zip",
"append": true
}file - Relative path in relation to the initial game file's path used. Required.
append - Append to game file's search path. Use to define the order in which to search for game files when mounting multiple archives. Default is false.
mount - Path to mount the archive in. Use to mount in a path different from root. Default is ``.
Resources must be loaded before using them. The same resource can be used with many drawables.
All resources have the following (one exception):
id - Resource id used when creating a drawable that uses the resource. Required.
file - Resource full file path on disk. Required.
Here is a list of resources currently supported:
audio
bitmapFont
celFile
celTexture
font
palette
sound
texture
"font": {
"id": "liberationSerif",
"file": "res/LiberationSerif-Regular.ttf"
}"texture": {
"id": "smlogo",
"file": "ui_art/smlogo.pcx",
"mask": "0x00FF00"
}mask - colour to use as transparent mask. Optional.
Drawables are shown on screen. They implement the UIObject interface.
All drawables have the following:
id - Drawable id. Required.
anchor - Anchor. Default is ["top", "left"].
position - Position on screen. Default is [0, 0].
visible - Visible flag. Default is true.
"animation": {
"id": "smlogo",
"texture": "smlogo",
"frames": 15,
"position": [125, 0],
"anchor": "none",
"refresh": 50
}texture - Animation texture. Required.
frames - Number of frames. Animation textures will be vertically split by this number to animate.
refresh - Refresh rate in milliseconds. Default is 50.
"image": {
"id": "mainmenu",
"texture": "mainmenu",
"anchor": "none"
}texture - Image texture. Required.