Versatile Java game engine with pluggable backends (this was used in Rogue, I think)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gamecore/src/mightypork/gamecore/core/init/InitTaskConfig.java

82 lines
1.3 KiB

package mightypork.gamecore.core.init;
import mightypork.gamecore.core.config.Config;
import mightypork.utils.annotations.Stub;
/**
* Initialize config. To apply this initializer, you must extend it. That
* ensures that the workdir initializer has already finished when the code is
* executed (such as resolving a file path for the config file).
*
* @author Ondřej Hruška (MightyPork)
*/
public abstract class InitTaskConfig extends InitTask {
/**
* Add a config with given alias
*
* @param alias config alias
* @param config config to add
*/
protected void addConfig(String alias, Config config)
{
Config.register(alias, config);
}
/**
* Initialize the main config.
*
* @return the main config.
*/
protected abstract Config buildConfig();
/**
* Initialize extra configs.<br>
* the addConfig() method can be used to register configs.
*/
@Stub
protected void buildExtraConfigs()
{
}
// locked to encourage the use of the build* methods.
@Override
public final void init()
{
}
@Override
public final void run()
{
addConfig("main", buildConfig());
buildExtraConfigs();
}
@Override
public String getName()
{
return "config";
}
@Override
public String[] getDependencies()
{
return new String[] { "workdir" };
}
@Override
public int getPriority()
{
return PRIO_FIRST;
}
}