Esempio n. 1
0
        public void Load()
        {
            try
            {
                if (!File.Exists(this.DefaultFile))
                {
                    return;
                }

                // 旧形式を置換する
                var text = File.ReadAllText(
                    this.DefaultFile,
                    new UTF8Encoding(false));
                text = text.Replace("DocumentElement", "ArrayOfPanelSettings");
                File.WriteAllText(
                    this.DefaultFile,
                    text,
                    new UTF8Encoding(false));

                using (var sr = new StreamReader(this.DefaultFile, new UTF8Encoding(false)))
                {
                    if (sr.BaseStream.Length > 0)
                    {
                        var xs   = new XmlSerializer(this.table.GetType());
                        var data = xs.Deserialize(sr) as IList <SpellPanel>;

                        this.table.Clear();

                        foreach (var x in data)
                        {
                            // 旧Generalパネルの名前を置換える
                            if (x.PanelName == "General")
                            {
                                x.PanelName = SpellPanel.GeneralPanel.PanelName;
                            }

                            // NaNを潰す
                            x.Top    = double.IsNaN(x.Top) ? 0 : x.Top;
                            x.Left   = double.IsNaN(x.Left) ? 0 : x.Left;
                            x.Margin = double.IsNaN(x.Margin) ? 0 : x.Margin;

                            // ソートオーダーを初期化する
                            if (x.SortOrder == SpellOrders.None)
                            {
                                if (x.FixedPositionSpell)
                                {
                                    x.SortOrder = SpellOrders.Fixed;
                                }
                                else
                                {
                                    if (!Settings.Default.AutoSortEnabled)
                                    {
                                        x.SortOrder = SpellOrders.SortMatchTime;
                                    }
                                    else
                                    {
                                        if (!Settings.Default.AutoSortReverse)
                                        {
                                            x.SortOrder = SpellOrders.SortRecastTimeASC;
                                        }
                                        else
                                        {
                                            x.SortOrder = SpellOrders.SortRecastTimeDESC;
                                        }
                                    }
                                }
                            }

                            this.table.Add(x);
                        }
                    }
                }
            }
            finally
            {
                var generalPanel = this.table.FirstOrDefault(x => x.PanelName == SpellPanel.GeneralPanel.PanelName);
                if (generalPanel != null)
                {
                    SpellPanel.SetGeneralPanel(generalPanel);
                }
                else
                {
                    this.table.Add(SpellPanel.GeneralPanel);
                }
            }
        }
Esempio n. 2
0
 public static void SetGeneralPanel(
     SpellPanel panel)
 {
     panel.SortPriority = generalPanel.SortPriority;
     generalPanel       = panel;
 }
Esempio n. 3
0
        public void Load()
        {
            try
            {
                if (!File.Exists(this.DefaultFile))
                {
                    return;
                }

                // 旧形式を置換する
                var text = File.ReadAllText(
                    this.DefaultFile,
                    new UTF8Encoding(false));
                text = text.Replace("DocumentElement", "ArrayOfPanelSettings");
                File.WriteAllText(
                    this.DefaultFile,
                    text,
                    new UTF8Encoding(false));

                using (var sr = new StreamReader(this.DefaultFile, new UTF8Encoding(false)))
                {
                    try
                    {
                        if (sr.BaseStream.Length > 0)
                        {
                            var xs   = new XmlSerializer(this.table.GetType());
                            var data = xs.Deserialize(sr) as IList <SpellPanel>;

                            this.table.Clear();
                            foreach (var item in data)
                            {
                                // 旧Generalパネルの名前を置換える
                                if (item.PanelName == "General")
                                {
                                    item.PanelName = SpellPanel.GeneralPanel.PanelName;
                                }

                                this.table.Add(item);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Write(Translate.Get("LoadXMLError"), ex);
                    }
                }
            }
            finally
            {
                // NaNを潰す
                foreach (var x in this.table)
                {
                    x.Top    = double.IsNaN(x.Top) ? 0 : x.Top;
                    x.Left   = double.IsNaN(x.Left) ? 0 : x.Left;
                    x.Margin = double.IsNaN(x.Margin) ? 0 : x.Margin;
                }

                // プリセットパネルを作る
                var generalPanel = this.Table.FirstOrDefault(x => x.PanelName == SpellPanel.GeneralPanel.PanelName);
                if (generalPanel == null)
                {
                    this.Table.Add(SpellPanel.GeneralPanel);
                }
                else
                {
                    SpellPanel.SetGeneralPanel(generalPanel);
                }
            }
        }