private void savePresetXml()
{
if (!File.Exists(presetXmlFileName))
{
var xml = new XDocument(
new XDeclaration("1.0", "utf-8", "true"),
new XElement("presets"));
xml.Save(presetXmlFileName);
}
var xdoc = XDocument.Load(presetXmlFileName);
var preset = new XElement("preset",
new XAttribute("name", presetName),
new XElement("param",
new XAttribute("id", PKeyEnable),
new XAttribute("value", ssParam.bEnabled[PKeyEnable])
),
new XElement("param",
new XAttribute("id", PKeyAlwaysLookAtMaid),
new XAttribute("value", ssParam.bEnabled[PKeyAlwaysLookAtMaid])
),
new XElement("param",
new XAttribute("id", PKeyAlwaysLookAtFace),
new XAttribute("value", ssParam.bEnabled[PKeyAlwaysLookAtFace]),
new XElement("value",
new XAttribute("prop_Name", PPropLookAtFaceUp),
new XAttribute("value", ssParam.fValue[PKeyAlwaysLookAtFace][PPropLookAtFaceUp])
),
new XElement("value",
new XAttribute("prop_Name", PPropLookAtFaceLeft),
new XAttribute("value", ssParam.fValue[PKeyAlwaysLookAtFace][PPropLookAtFaceLeft])
),
new XElement("value",
new XAttribute("prop_Name", PPropLookAtFaceFront),
new XAttribute("value", ssParam.fValue[PKeyAlwaysLookAtFace][PPropLookAtFaceFront])
)
),
new XElement("param",
new XAttribute("id", PKeyAlwaysLookAtXxx),
new XAttribute("value", ssParam.bEnabled[PKeyAlwaysLookAtXxx]),
new XElement("value",
new XAttribute("prop_Name", PPropLookAtXxxUp),
new XAttribute("value", ssParam.fValue[PKeyAlwaysLookAtXxx][PPropLookAtXxxUp])
),
new XElement("value",
new XAttribute("prop_Name", PPropLookAtXxxLeft),
new XAttribute("value", ssParam.fValue[PKeyAlwaysLookAtXxx][PPropLookAtXxxLeft])
),
new XElement("value",
new XAttribute("prop_Name", PPropLookAtXxxFront),
new XAttribute("value", ssParam.fValue[PKeyAlwaysLookAtXxx][PPropLookAtXxxFront])
)
),
new XElement("param",
new XAttribute("id", PKeyAlwaysScreenOnMainCamera),
new XAttribute("value", ssParam.bEnabled[PKeyAlwaysScreenOnMainCamera]),
new XElement("value",
new XAttribute("prop_Name", PPropAlwaysScreenOnMainCameraUp),
new XAttribute("value", ssParam.fValue[PKeyAlwaysScreenOnMainCamera][PPropAlwaysScreenOnMainCameraUp])
),
new XElement("value",
new XAttribute("prop_Name", PPropAlwaysScreenOnMainCameraLeft),
new XAttribute("value", ssParam.fValue[PKeyAlwaysScreenOnMainCamera][PPropAlwaysScreenOnMainCameraLeft])
),
new XElement("value",
new XAttribute("prop_Name", PPropAlwaysScreenOnMainCameraFront),
new XAttribute("value", ssParam.fValue[PKeyAlwaysScreenOnMainCamera][PPropAlwaysScreenOnMainCameraFront])
)
),
new XElement("param",
new XAttribute("id", PKeySubCamera),
new XAttribute("value", ssParam.bEnabled[PKeySubCamera]),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraPosX),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraPosX])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraPosY),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraPosY])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraWidth),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraWidth])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraLocX),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraLocX])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraLocY),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraLocY])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraLocZ),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraLocZ])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraAngX),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraAngX])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraAngY),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraAngY])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraAngZ),
new XAttribute("value", ssParam.fValue[PKeySubCamera][PPropSubCameraAngZ])
)
),
new XElement("param",
new XAttribute("id", PKeyMainLight),
new XAttribute("value", ssParam.bEnabled[PKeyMainLight]),
new XElement("value",
new XAttribute("prop_Name", PPropMainLightLuminance),
new XAttribute("value", ssParam.fValue[PKeyMainLight][PPropMainLightLuminance])
),
new XElement("value",
new XAttribute("prop_Name", PPropMainLightColorRed),
new XAttribute("value", ssParam.fValue[PKeyMainLight][PPropMainLightColorRed])
),
new XElement("value",
new XAttribute("prop_Name", PPropMainLightColorGreen),
new XAttribute("value", ssParam.fValue[PKeyMainLight][PPropMainLightColorGreen])
),
new XElement("value",
new XAttribute("prop_Name", PPropMainLightColorBlue),
new XAttribute("value", ssParam.fValue[PKeyMainLight][PPropMainLightColorBlue])
)
),
new XElement("param",
new XAttribute("id", PKeySubLight),
new XAttribute("value", ssParam.bEnabled[PKeySubLight]),
new XElement("value",
new XAttribute("prop_Name", PPropSubLightRange),
new XAttribute("value", ssParam.fValue[PKeySubLight][PPropSubLightRange])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubLightLuminance),
new XAttribute("value", ssParam.fValue[PKeySubLight][PPropSubLightLuminance])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubLightColorRed),
new XAttribute("value", ssParam.fValue[PKeySubLight][PPropSubLightColorRed])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubLightColorGreen),
new XAttribute("value", ssParam.fValue[PKeySubLight][PPropSubLightColorGreen])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubLightColorBlue),
new XAttribute("value", ssParam.fValue[PKeySubLight][PPropSubLightColorBlue])
)
),
new XElement("param",
new XAttribute("id", PKeyCameraColor),
new XElement("value",
new XAttribute("prop_Name", PPropCameraColorRed),
new XAttribute("value", ssParam.fValue[PKeyCameraColor][PPropCameraColorRed])
),
new XElement("value",
new XAttribute("prop_Name", PPropCameraColorGreen),
new XAttribute("value", ssParam.fValue[PKeyCameraColor][PPropCameraColorGreen])
),
new XElement("value",
new XAttribute("prop_Name", PPropCameraColorBlue),
new XAttribute("value", ssParam.fValue[PKeyCameraColor][PPropCameraColorBlue])
),
new XElement("value",
new XAttribute("prop_Name", PPropCameraColorAlpha),
new XAttribute("value", ssParam.fValue[PKeyCameraColor][PPropCameraColorAlpha])
),
new XElement("value",
new XAttribute("prop_Name", PPropSubCameraFieldOfView),
new XAttribute("value", ssParam.fValue[PKeyCameraColor][PPropSubCameraFieldOfView])
)
),
new XElement("param",
new XAttribute("id", PKeyBSPos),
new XElement("value",
new XAttribute("prop_Name", PPropBSPosX),
new XAttribute("value", ssParam.fValue[PKeyBSPos][PPropBSPosX])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSPosY),
new XAttribute("value", ssParam.fValue[PKeyBSPos][PPropBSPosY])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSPosZ),
new XAttribute("value", ssParam.fValue[PKeyBSPos][PPropBSPosZ])
)
),
new XElement("param",
new XAttribute("id", PKeyBSSize),
new XElement("value",
new XAttribute("prop_Name", PPropBSSize),
new XAttribute("value", ssParam.fValue[PKeyBSSize][PPropBSSize])
)
),
new XElement("param",
new XAttribute("id", PKeyBSAngle),
new XElement("value",
new XAttribute("prop_Name", PPropBSAngleX),
new XAttribute("value", ssParam.fValue[PKeyBSAngle][PPropBSAngleX])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSAngleY),
new XAttribute("value", ssParam.fValue[PKeyBSAngle][PPropBSAngleY])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSAngleZ),
new XAttribute("value", ssParam.fValue[PKeyBSAngle][PPropBSAngleZ])
)
),
new XElement("param",
new XAttribute("id", PKeyBSColor),
new XElement("value",
new XAttribute("prop_Name", PPropScreenLightLuminance),
new XAttribute("value", ssParam.fValue[PKeyBSColor][PPropScreenLightLuminance])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSColorLuminance),
new XAttribute("value", ssParam.fValue[PKeyBSColor][PPropBSColorLuminance])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSColorRed),
new XAttribute("value", ssParam.fValue[PKeyBSColor][PPropBSColorRed])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSColorGreen),
new XAttribute("value", ssParam.fValue[PKeyBSColor][PPropBSColorGreen])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSColorBlue),
new XAttribute("value", ssParam.fValue[PKeyBSColor][PPropBSColorBlue])
),
new XElement("value",
new XAttribute("prop_Name", PPropBSColorAlpha),
new XAttribute("value", ssParam.fValue[PKeyBSColor][PPropBSColorAlpha])
)
),
new XElement("param",
new XAttribute("id", PKeyScreenFilter),
new XAttribute("value", ssParam.bEnabled[PKeyScreenFilter]),
new XElement("value",
new XAttribute("prop_Name", PPropScreenFilterLuminance),
new XAttribute("value", ssParam.fValue[PKeyScreenFilter][PPropScreenFilterLuminance])
),
new XElement("value",
new XAttribute("prop_Name", PPropScreenFilterRed),
new XAttribute("value", ssParam.fValue[PKeyScreenFilter][PPropScreenFilterRed])
),
new XElement("value",
new XAttribute("prop_Name", PPropScreenFilterGreen),
new XAttribute("value", ssParam.fValue[PKeyScreenFilter][PPropScreenFilterGreen])
),
new XElement("value",
new XAttribute("prop_Name", PPropScreenFilterBlue),
new XAttribute("value", ssParam.fValue[PKeyScreenFilter][PPropScreenFilterBlue])
),
new XElement("value",
new XAttribute("prop_Name", PPropScreenFilterAlpha),
new XAttribute("value", ssParam.fValue[PKeyScreenFilter][PPropScreenFilterAlpha])
)
)
);
var presetNodes = xdoc.Descendants("preset");
if (presetNodes.Count() == 0)
{
xdoc.Root.AddFirst(preset);
}
else
{
presetNodes.Last().AddAfterSelf(preset);
}
xdoc.Save(presetXmlFileName);
}