/// <summary> /// 設定読み込み /// </summary> /// <param name="iPlayerName"></param> /// <returns></returns> public bool Load(string iPlayerName) { //Bokka.xmlの読み込み string xmlFilename = XML_FILENAME_SETTINGS; SettingsProperty xmlSettings = new SettingsProperty(); if (File.Exists(xmlFilename)) { FileStream fs = new FileStream(xmlFilename, System.IO.FileMode.Open); //シリアライズ XmlSerializer serializer = new XmlSerializer(typeof(SettingsProperty)); //読み込み xmlSettings = (SettingsProperty)serializer.Deserialize(fs); fs.Close(); } //メンバに設定 BaseWait = xmlSettings.BaseWait; ChatWait = xmlSettings.ChatWait; bool foundFlg = false; foreach (SettingsPlayerProperty v in xmlSettings.Player) { if (v.Name == iPlayerName) { foundFlg = true; FormPosX = v.FormPosX; FormPosY = v.FormPosY; TicketUseEach = v.TicketUseEach; Kamihr3 = v.Kamihr3; LimitTicket = v.LimitTicket; LimitCp = v.LimitCp; MenuIndexWorksCall = v.MenuIndexWorksCall; MenuIndexArea = v.MenuIndexArea; MenuIndexBivouac = v.MenuIndexBivouac; } } if (!foundFlg) { SettingsPlayerProperty player = new SettingsPlayerProperty(); FormPosX = player.FormPosX; FormPosY = player.FormPosY; TicketUseEach = player.TicketUseEach; Kamihr3 = player.Kamihr3; LimitTicket = player.LimitTicket; LimitCp = player.LimitCp; MenuIndexWorksCall = player.MenuIndexWorksCall; MenuIndexArea = player.MenuIndexArea; MenuIndexBivouac = player.MenuIndexBivouac; } return(true); }
/// <summary> /// 設定保存 /// </summary> /// <param name="iPlayerName"></param> /// <returns></returns> public bool Save(string iPlayerName) { //設定の読み込み string xmlFilename = XML_FILENAME_SETTINGS; XmlSerializer serializer; SettingsProperty xmlSettings = new SettingsProperty(); if (File.Exists(xmlFilename)) { FileStream fs = new FileStream(xmlFilename, System.IO.FileMode.Open); //シリアライズ serializer = new XmlSerializer(typeof(SettingsProperty)); //読み込み xmlSettings = (SettingsProperty)serializer.Deserialize(fs); fs.Close(); } //保存データ設定 bool foundFlg = false; foreach (SettingsPlayerProperty v in xmlSettings.Player) { if (v.Name == iPlayerName) { foundFlg = true; v.FormPosX = FormPosX; v.FormPosY = FormPosY; v.TicketUseEach = TicketUseEach; v.Kamihr3 = Kamihr3; v.LimitTicket = LimitTicket; v.LimitCp = LimitCp; v.MenuIndexWorksCall = MenuIndexWorksCall; v.MenuIndexArea = MenuIndexArea; v.MenuIndexBivouac = MenuIndexBivouac; } } if (!foundFlg) { SettingsPlayerProperty player = new SettingsPlayerProperty(); player.Name = iPlayerName; player.FormPosX = FormPosX; player.FormPosY = FormPosY; player.TicketUseEach = TicketUseEach; player.Kamihr3 = Kamihr3; player.LimitTicket = LimitTicket; player.LimitCp = LimitCp; player.MenuIndexWorksCall = MenuIndexWorksCall; player.MenuIndexArea = MenuIndexArea; player.MenuIndexBivouac = MenuIndexBivouac; xmlSettings.Player.Add(player); } //設定の保存 StreamWriter sw = new StreamWriter(xmlFilename, false, new UTF8Encoding(false)); //名前空間出力抑制 XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add(String.Empty, String.Empty); //シリアライズ serializer = new XmlSerializer(typeof(SettingsProperty)); serializer.Serialize(sw, xmlSettings, ns); //書き込み sw.Flush(); sw.Close(); sw = null; return(true); }