Class MainModuleConfig
java.lang.Object
io.codetoil.curved_spacetime.MainModuleConfig
The engine's own settings, read from
config/main-module.config.
Holds the frame rate the callback loop runs at and the level every module's logger is set to.
Neither key is required to be present: loading substitutes a documented default for anything
missing or unparseable and reports that through isDirty(), so that a user who deletes
the file gets a complete one back on the next run.
-
Constructor Summary
ConstructorsConstructorDescriptionMainModuleConfig(Logger logger) Creates a configuration that reports load problems to the given logger. -
Method Summary
Modifier and TypeMethodDescriptionintgetFPS()Returns the frame rate the engine's callback loop runs at.Returns the level every module sets its logger to.booleanisDirty()Returns whether this configuration differs from what is on disk.load()Reads the configuration from disk, substituting defaults for anything missing or invalid.voidsave()Writes the configuration to disk, creatingconfig/if it does not exist.
-
Constructor Details
-
MainModuleConfig
-
-
Method Details
-
getFPS
public int getFPS()Returns the frame rate the engine's callback loop runs at.- Returns:
- the configured frames per second, within the inclusive bounds 1 and 1000
-
getLoggerLevel
Returns the level every module sets its logger to.- Returns:
- the configured logging level
-
load
Reads the configuration from disk, substituting defaults for anything missing or invalid.A missing file is not an error. Each key that is absent or fails to parse is reported through the logger, replaced with its default, and marks the configuration dirty.
- Returns:
- this configuration, so that construction and loading compose
- Throws:
IOException- if the file exists but cannot be read
-
save
Writes the configuration to disk, creatingconfig/if it does not exist.Every key is written, not only those that changed, and the dirty flag is cleared on success.
- Throws:
IOException- if the config directory cannot be created or the file cannot be written
-
isDirty
public boolean isDirty()Returns whether this configuration differs from what is on disk.Loading having substituted a default for
fpsorlogger_levelis the usual cause;save()clears it.- Returns:
trueif the file does not match this configuration and should be rewritten
-