/// <summary> /// Gets positions of tool on HUD for all possible <see cref="EnumPokerSites"/> and <see cref="EnumGameType" /> /// </summary> /// <returns></returns> private List <HudPositionsInfo> GetHudPositions(EnumTableType tableType, Point position) { // existing elements positions will be in default xml files // we have predefined position of player labels // so we need to calculate offset between UI player label and UI position, then apply those offsets to hud player label var hudPositions = new List <HudPositionsInfo>(); var pokerSites = EntityUtils.GetSupportedPokerSites(); foreach (var pokerSite in pokerSites) { foreach (var gameType in Enum.GetValues(typeof(EnumGameType)).OfType <EnumGameType>()) { var hudPositionsInfo = new HudPositionsInfo { PokerSite = pokerSite, GameType = gameType, HudPositions = GetHudPositionInfo(pokerSite, tableType, position) }; hudPositions.Add(hudPositionsInfo); } } return(hudPositions); }
private HudLayoutInfo GetHudLayoutInfo(List <HudSavedLayout> layouts, HudViewType hudViewType) { var masterLayout = layouts.FirstOrDefault(); if (masterLayout == null) { return(null); } var tableDescription = GetTableDescription(masterLayout.LayoutId); var sameDefault = defaultLayouts.FirstOrDefault( l => l.TableType == tableDescription.TableType && l.HudViewType == hudViewType); if (settingsService.GetSettings().GeneralSettings.HudViewMode != (int)hudViewType && hudViewType != HudViewType.Plain) { return(null); } var filteredLayouts = hudViewType == HudViewType.Plain ? layouts.Where( l => GetTableDescription(l.LayoutId).PokerSite != EnumPokerSites.Ignition && GetTableDescription(l.LayoutId).PokerSite != EnumPokerSites.Bodog) .ToList() : layouts.Where( l => GetTableDescription(l.LayoutId).PokerSite == EnumPokerSites.Ignition || GetTableDescription(l.LayoutId).PokerSite == EnumPokerSites.Bodog) .ToList(); if (filteredLayouts.Count == 0) { return(null); } var newLayout = new HudLayoutInfo(); newLayout.TableType = tableDescription.TableType; newLayout.HudBumperStickerTypes = masterLayout.HudBumperStickerTypes.Select(s => s.Clone()).ToList(); newLayout.HudPlayerTypes = masterLayout.HudPlayerTypes.Select(p => p.Clone()).ToList(); newLayout.HudStats = masterLayout.HudStats.Select(s => { var statInfoBreak = s as StatInfoBreak; if (statInfoBreak != null) { return(statInfoBreak.Clone()); } return(s.Clone()); }).ToList(); newLayout.IsDefault = false; newLayout.HudViewType = hudViewType; newLayout.UiPositionsInfo = sameDefault?.UiPositionsInfo.Select(p => p.Clone()).ToList(); newLayout.Name = masterLayout.Name; foreach (var hudSavedLayout in filteredLayouts) { var newPositionInfo = new HudPositionsInfo(); newPositionInfo.GameType = GetTableDescription(hudSavedLayout.LayoutId).GameType; newPositionInfo.PokerSite = GetTableDescription(hudSavedLayout.LayoutId).PokerSite; newPositionInfo.HudPositions = hudSavedLayout.HudPositions.Where( p => p.HudType == (hudViewType == HudViewType.Plain ? HudType.Plain : HudType.Default)) .Select( p => new HudPositionInfo { Position = new Point(p.Position.X, p.Position.Y), Seat = p.Seat }) .ToList(); if (newPositionInfo.HudPositions.Any()) { newLayout.HudPositionsInfo.Add(newPositionInfo); } } if (sameDefault != null) { foreach (var defaultPosInfo in sameDefault.HudPositionsInfo) { if ( newLayout.HudPositionsInfo.Any( p => p.GameType == defaultPosInfo.GameType && p.PokerSite == defaultPosInfo.PokerSite)) { continue; } newLayout.HudPositionsInfo.Add(defaultPosInfo.Clone()); } } if (HudObjectsComparer.AreEquals(newLayout, sameDefault)) { return(null); } if (HudObjectsComparer.AreEqualsExceptPositions(newLayout, sameDefault)) { sameDefault.HudPositionsInfo = newLayout.HudPositionsInfo.Select(p => p.Clone()).ToList(); return(sameDefault); } return(newLayout.HudPositionsInfo.Any() ? newLayout : null); }