mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Ragnarok Settings
- added Ragnarok settings
This commit is contained in:
parent
711cf955c3
commit
87f86036d7
28 changed files with 708 additions and 58 deletions
|
|
@ -218,6 +218,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
if (attr.ClearSection)
|
||||
{
|
||||
WriteValue(iniFiles, attr.File, attr.Section, null, null);
|
||||
ClearSectionIfEmpty(iniFiles, attr);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -240,6 +241,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
{
|
||||
// The condition value was not set to true, so clear this attribute instead of writing it
|
||||
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
|
||||
ClearSectionIfEmpty(iniFiles, attr);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -252,6 +254,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
{
|
||||
// The attributed value was set to false, so clear this attribute instead of writing it
|
||||
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
|
||||
ClearSectionIfEmpty(iniFiles, attr);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -325,6 +328,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
{
|
||||
// The attributed value does not have a value, so clear this attribute instead of writing it.
|
||||
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
|
||||
ClearSectionIfEmpty(iniFiles, attr);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -338,6 +342,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
{
|
||||
// The attributed value is the same as the specified value, so clear this attribute instead of writing it.
|
||||
WriteValue(iniFiles, attr.File, attr.Section, keyName, null);
|
||||
ClearSectionIfEmpty(iniFiles, attr);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -369,6 +374,8 @@ namespace ServerManagerTool.Common.Serialization
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClearSectionIfEmpty(iniFiles, attr);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
@ -380,6 +387,19 @@ namespace ServerManagerTool.Common.Serialization
|
|||
SaveFiles(iniFiles);
|
||||
}
|
||||
|
||||
private void ClearSectionIfEmpty(Dictionary<string, IniFile> iniFiles, BaseIniFileEntryAttribute attr)
|
||||
{
|
||||
if (attr.ClearSectionIfEmpty)
|
||||
{
|
||||
var section = ReadSection(iniFiles, attr.File, attr.Section);
|
||||
var hasKeys = section?.Any() ?? false;
|
||||
if (!hasKeys)
|
||||
{
|
||||
WriteValue(iniFiles, attr.File, attr.Section, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> ReadSection(Enum iniFile, Enum section)
|
||||
{
|
||||
return ReadSection(iniFile, SectionNames[section]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue