protected override void OnActivate() { base.OnActivate(); if (CurrentLayout == null && Layouts.Any()) { CurrentLayout = Layouts.First(); } }
internal void InitBaseData() { if (!Maps.Any()) { var lines = File.ReadAllLines("SquadMaps.csv").Skip(1); foreach (var line in lines) { var items = line.Split(';'); Maps.Add(new GameMap() { Name = items[0], Region = Enum.Parse <GameMapRegion>(items[1]), }); } SaveChanges(); } if (!Layouts.Any()) { var lines = File.ReadAllLines("SquadLayouts.csv").Skip(1); foreach (var line in lines) { var items = line.Split(';'); var name = items[0]; Layouts.Add(new GameLayout() { Name = name, Left = !string.IsNullOrEmpty(items[1]) ? (Faction?)Enum.Parse <Faction>(items[1]) : null, Right = !string.IsNullOrEmpty(items[2]) ? (Faction?)Enum.Parse <Faction>(items[2]) : null, Thumbnail = items[3], MapFull = items[4], GameMap = Maps.FirstOrDefault(m => name.Contains(m.Name)) ?? Maps.FirstOrDefault(m => m.Region == GameMapRegion.Training) }); } SaveChanges(); } if (!Users.Any()) { for (int i = 1; i <= 80; ++i) { Users.Add(new User() { Name = $"User {i}", SteamId = "XXXXXXXXX" }); SaveChanges(); } } }
public bool IsShortcutUsed(Shortcut sc, ILayout layout) { return(!sc.IsEmpty() && Layouts.Any(l => l != layout && l.Shortcut.Match(sc))); }