private static ChatOverlaySettingsModel[] CreateDefaultChatOverlaySettings() { var overlay = new ChatOverlaySettingsModel() { Name = DefaultChatOverlayName, X = 20, Y = 20, W = 640, H = 480, IsLock = false, Scale = 1.0d, BackgroundColor = Colors.Black, Opacity = 0.6d, PCNameStyle = PCNameStyles.FullName, }; var chatPages = new SuspendableObservableCollection <ChatPageSettingsModel>() { new ChatPageSettingsModel() { Name = "ALL", ParentOverlaySettings = overlay, HandledChannels = HandledChatChannelModel.CreateDefaultHandledChannels(true), IgnoreFilters = FilterModel.CreateDefualtIgnoreFilters(), } }; overlay.ChatPages = chatPages; return(new[] { overlay }); }
/// <summary> /// バージョンアップ等による設定ファイルの追加、変更を反映する /// </summary> private static void MigrateConfig( string fileName) { fileName = SwitchFileName(fileName); if (!File.Exists(fileName)) { return; } var config = Config.Load <Config>( fileName); var i = 0; // チャットページのチャンネルを整備する i = 0; var channels = ChatCodes.All .Select(x => new { ChatCode = x, Order = i++, }) .ToArray(); foreach (var overlay in config.ChatOverlaySettings) { foreach (var page in overlay.ChatPages) { var handledChannels = new List <HandledChatChannelModel>(page.HandledChannels); handledChannels .Where(x => !ChatCodes.All.Contains(x.ChatCode)) .ToArray() .Walk(x => handledChannels.Remove(x)); handledChannels.AddRange(ChatCodes.All .Where(x => !handledChannels.Any(y => y.ChatCode == x)) .Select(x => new HandledChatChannelModel() { ChatCode = x, IsEnabled = true, })); handledChannels.Sort((x, y) => { var orderX = channels.FirstOrDefault(z => z.ChatCode == x.ChatCode)?.Order ?? int.MaxValue; var orderY = channels.FirstOrDefault(z => z.ChatCode == y.ChatCode)?.Order ?? int.MaxValue; return(orderX - orderY); }); page.HandledChannels = handledChannels.ToArray(); // 除外フィルタを設定する if (page.IgnoreFilters == null) { page.IgnoreFilters = FilterModel.CreateDefualtIgnoreFilters(); } else { for (int j = 0; j < page.IgnoreFilters.Length; j++) { if (page.IgnoreFilters[j] == null) { page.IgnoreFilters[j] = new FilterModel(); } } } } } // ログカラー設定を整備する var colors = new List <ChatChannelSettingsModel>(config.ChatChannelsSettings); colors .Where(x => !ChatCodes.All.Contains(x.ChatCode)) .ToArray() .Walk(x => colors.Remove(x)); colors.AddRange(ChatCodes.All .Where(x => !colors.Any(y => y.ChatCode == x)) .Select(x => new ChatChannelSettingsModel() { ChatCode = x, })); colors.Sort((x, y) => { var orderX = channels.FirstOrDefault(z => z.ChatCode == x.ChatCode)?.Order ?? int.MaxValue; var orderY = channels.FirstOrDefault(z => z.ChatCode == y.ChatCode)?.Order ?? int.MaxValue; return(orderX - orderY); }); config.ChatChannelsSettings = colors.ToArray(); // キャラクタープロファイルを整備する i = 0; var linkers = ChatCodes.LinkableChannels .Select(x => new { ChatCode = x, Order = i++, }) .ToArray(); foreach (var prof in config.CharacterProfileList) { prof.ChannelLinkerList .Where(x => !ChatCodes.LinkableChannels.Contains(x.ChatCode)) .ToArray() .Walk(x => prof.ChannelLinkerList.Remove(x)); prof.ChannelLinkerList.AddRange(ChatCodes.LinkableChannels .Where(x => !prof.ChannelLinkerList.Any(y => y.ChatCode == x)) .Select(x => new ChannelLinkerModel() { ChatCode = x, })); prof.ChannelLinkerList.Sort((x, y) => { var orderX = linkers.FirstOrDefault(z => z.ChatCode == x.ChatCode)?.Order ?? int.MaxValue; var orderY = linkers.FirstOrDefault(z => z.ChatCode == y.ChatCode)?.Order ?? int.MaxValue; return(orderX - orderY); }); } // 保存する config.Save(); }