rendered paste body#ifndef ObjConfig
#define ObjConfig FukabunConfig
#endif
objectdef FukabunConfig inherits ObjBase
{
variable string etc = "${LavishScript.HomeDirectory}/Scripts/Fukabun/etc/"
variable string configFile = "fukabun.xml"
variable settingsetref setKernel
variable settingsetref setHuntGroups
variable settingsetref setCharacters
variable settingsetref setCharacter
method Load()
{
variable filepath fpEtc = ${etc}
variable string MySettings
LavishSettings:AddSet[Fukabun]
if ${fpEtc.FileExists[${configFile}]}
{
LavishSettings[Fukabun]:Import[${etc}${configFile}]
setKernel:Set[${LavishSettings[Fukabun].FindSet[Kernel]}]
setCharacters:Set[${LavishSettings[Fukabun].FindSet[Characters]}]
setHuntGroups:Set[${LavishSettings[Fukabun].FindSet["Hunt groups"]}]
}
else
{
LavishSettings[Fukabun]:AddSet[Kernel]
LavishSettings[Fukabun]:AddSet[Characters]
LavishSettings[Fukabun]:AddSet["Hunt groups"]
}
if !${setCharacters.FindSet[${Me}](exists)}
{
setCharacters:AddSet["${Me}"]
}
This.setCharacter:Set[${setCharacters.FindSet[${Me}]}]
}
member Kernel(string Key, string Default)
{
return ${setKernel.FindSetting["${Key}","${Default}"]}
}
member Character(string Key, string Default)
{
return ${setCharacter.FindSetting["${Key}","${Default}"]}
}
method Save()
{
LavishSettings[Fukabun]:Export[${etc}${configFile}]
}
method Initialize()
{
This:Load
This:Debug["Fukabun config: initializing."]
}
method Shutdown()
{
This:Save
}
}