/// <summary> /// Creates gauge indicator view model /// </summary> /// <param name="creationInfo"><see cref="HudToolCreationInfo"/></param> /// <returns>Gauge indicator view model</returns> private HudBaseToolViewModel CreateGaugeIndicatorTool(HudToolCreationInfo creationInfo) { Check.Require(creationInfo.Layout != null, "Layout isn't defined. Gauge indicator has not been created."); var statInfo = creationInfo.Source as StatInfo; if (statInfo == null) { return(null); } statInfo.IsSelected = false; var layoutTool = new HudLayoutGaugeIndicator { BaseStat = statInfo.Clone(), Text = statInfo.ToolTip }; var toolViewModel = layoutTool.CreateViewModel(creationInfo.HudElement); toolViewModel.Position = creationInfo.Position; creationInfo.Layout.LayoutTools.Add(layoutTool); return(toolViewModel); }
/// <summary> /// Initialize an instance of <see cref="HudGaugeIndicatorViewModel"/> /// </summary> /// <param name="tool"><see cref="HudLayoutGaugeIndicator"/> to initialize an instance</param> private HudGaugeIndicatorViewModel(HudLayoutGaugeIndicator tool) : this() { Check.ArgumentNotNull(() => tool); this.tool = tool; if (Stats != null) { Stats.CollectionChanged += OnStatsCollectionChanged; Stats.ChangeTrackingEnabled = true; Stats.ItemChanged .Where(x => x.PropertyName == nameof(StatInfo.IsPopupBarNotSupported)) .Subscribe(x => RefreshGroupedStats()); } InitializeCommands(); }
public static ReactiveList <HudGaugeIndicatorStatsGroupViewModel> GroupStats(HudLayoutGaugeIndicator tool, HudElementViewModel hudElementViewModel) { var groupedStats = new ReactiveList <HudGaugeIndicatorStatsGroupViewModel>(); if (tool.Stats == null) { return(groupedStats); } HudGaugeIndicatorStatsGroupViewModel group = null; foreach (var stat in tool.Stats) { var groupType = GetStatGroupType(stat); if (group == null || group.GroupType != groupType) { group = new HudGaugeIndicatorStatsGroupViewModel { GroupType = groupType }; groupedStats.Add(group); } var gaugeIndicatorStatInfo = new HudGaugeIndicatorStatInfo(stat); if (hudElementViewModel != null) { gaugeIndicatorStatInfo.HeatMapViewModel = (HudHeatMapViewModel)tool.Tools? .OfType <HudLayoutHeatMapTool>() .FirstOrDefault(x => x.BaseStat != null && x.BaseStat.Stat == stat.Stat)? .CreateViewModel(hudElementViewModel); } group.Stats.Add(gaugeIndicatorStatInfo); } return(groupedStats); }
public void HudLayoutGaugeIndicatorCanBeSerializedDeserializedWithProtobuf() { var hudLayoutToolExpected = new HudLayoutGaugeIndicator { BaseStat = new StatInfo { Stat = Stat.CBet }, Stats = new ReactiveList <StatInfo> { new StatInfo { Stat = Stat.VPIP } }, Text = "Test", HeaderText = "HeaderText", IsVertical = true, Tools = new ReactiveList <HudLayoutTool> { new HudLayoutHeatMapTool { BaseStat = new StatInfo { Stat = Stat.VPIP } } } }; var hudLayoutToolActual = SerializerHelper.GetSerializedDeserializedObject(hudLayoutToolExpected); Assert.That(hudLayoutToolActual.Id, Is.EqualTo(hudLayoutToolExpected.Id)); Assert.That(hudLayoutToolActual.Text, Is.EqualTo(hudLayoutToolExpected.Text)); Assert.That(hudLayoutToolActual.HeaderText, Is.EqualTo(hudLayoutToolExpected.HeaderText)); Assert.That(hudLayoutToolActual.IsVertical, Is.EqualTo(hudLayoutToolExpected.IsVertical)); Assert.That(hudLayoutToolActual.BaseStat.Stat, Is.EqualTo(hudLayoutToolExpected.BaseStat.Stat)); Assert.That(hudLayoutToolActual.Stats.Count, Is.EqualTo(hudLayoutToolExpected.Stats.Count)); Assert.That(hudLayoutToolActual.Stats.FirstOrDefault().Stat, Is.EqualTo(hudLayoutToolExpected.Stats.FirstOrDefault().Stat)); Assert.That(hudLayoutToolActual.Tools.Count, Is.EqualTo(hudLayoutToolExpected.Tools.Count)); Assert.That(hudLayoutToolActual.Tools.FirstOrDefault().ToolType, Is.EqualTo(hudLayoutToolExpected.Tools.FirstOrDefault().ToolType)); }
/// <summary> /// Creates <see cref="HudLayoutInfoV2"/> for tests, all tools must be included /// </summary> /// <returns><see cref="HudLayoutInfoV2"/></returns> private static HudLayoutInfoV2 CreateHudLayoutInfo() { var hudLayoutInfo = new HudLayoutInfoV2 { TableType = EnumTableType.HU, Name = "TestLayout", Filter = new HudLayoutFilter { DataFreshness = 30, TableTypes = new[] { (int)EnumTableType.HU, (int)EnumTableType.Six } }, TrackMeterPositions = new List <HudPositionsInfo> { new HudPositionsInfo { GameType = EnumGameType.MTTHoldem, PokerSite = EnumPokerSites.Bodog, HudPositions = new List <HudPositionInfo> { new HudPositionInfo { Position = new System.Windows.Point(1, 15) } } } } }; var plainBoxTool = new HudLayoutPlainBoxTool { Positions = new List <HudPositionsInfo> { new HudPositionsInfo { GameType = EnumGameType.CashHoldem, HudPositions = new List <HudPositionInfo> { new HudPositionInfo { Position = new System.Windows.Point(1, 1), Seat = 1, Width = 2 } }, PokerSite = EnumPokerSites.Bodog } }, Stats = new ReactiveList <StatInfo> { new StatInfo { Stat = Stat.VPIP } } }; var textboxTool = new HudLayoutTextBoxTool { Text = "Test" }; var fourStatBoxTool = new HudLayoutFourStatsBoxTool { Positions = new List <HudPositionsInfo> { new HudPositionsInfo { GameType = EnumGameType.CashHoldem, HudPositions = new List <HudPositionInfo> { new HudPositionInfo { Position = new System.Windows.Point(1, 1), Seat = 1, Width = 2 } }, PokerSite = EnumPokerSites.Bodog } }, Stats = new ReactiveList <StatInfo> { new StatInfo { Stat = Stat.VPIP } } }; var tiltMeterTool = new HudLayoutTiltMeterTool(); var playerIconTool = new HudLayoutPlayerIconTool(); var graphTool = new HudLayoutGraphTool(); var gaugeIndicatorTool = new HudLayoutGaugeIndicator(); var bumperStickers = new HudLayoutBumperStickersTool(); var heatMap = new HudLayoutHeatMapTool(); hudLayoutInfo.LayoutTools = new List <HudLayoutTool> { plainBoxTool, textboxTool, fourStatBoxTool, tiltMeterTool, playerIconTool, graphTool, gaugeIndicatorTool, bumperStickers, heatMap }; return(hudLayoutInfo); }
public void HudGaugeIndicatorViewModelToolCanBeSerializedDeserializedWithProtobuf() { var hudLayoutToolExpected = new HudLayoutGaugeIndicator { BaseStat = new StatInfo { Stat = Stat.CBet }, Stats = new ReactiveList <StatInfo> { new StatInfo { Stat = Stat.VPIP }, new StatInfo { Stat = Stat.PFR }, new StatInfo { Stat = Stat.S3Bet }, new StatInfo { Stat = Stat.ColdCall } }, Text = "test", IsVertical = true, HeaderText = "HeaderText", Tools = new ReactiveList <HudLayoutTool> { new HudLayoutHeatMapTool { BaseStat = new StatInfo { Stat = Stat.PFR } } } }; var hudElement = new HudElementViewModel { Seat = 1, }; var hudToolViewModelExpected = hudLayoutToolExpected.CreateViewModel(hudElement) as HudGaugeIndicatorViewModel; hudToolViewModelExpected.IsGraphIndicatorsDisabled = true; Assert.IsNotNull(hudToolViewModelExpected.GroupedStats); var hudToolViewModelActual = SerializerHelper.GetSerializedDeserializedObject(hudToolViewModelExpected); Assert.That(hudToolViewModelActual.Id, Is.EqualTo(hudToolViewModelExpected.Id)); Assert.That(hudToolViewModelActual.ToolType, Is.EqualTo(hudToolViewModelExpected.ToolType)); Assert.That(hudToolViewModelActual.Stats.Count, Is.EqualTo(hudToolViewModelExpected.Stats.Count)); Assert.That(hudToolViewModelActual.BaseStat.Stat, Is.EqualTo(hudToolViewModelExpected.BaseStat.Stat)); Assert.That(hudToolViewModelActual.Width, Is.EqualTo(hudToolViewModelExpected.Width)); Assert.That(hudToolViewModelActual.Text, Is.EqualTo(hudToolViewModelExpected.Text)); Assert.That(hudToolViewModelActual.HeaderText, Is.EqualTo(hudToolViewModelExpected.HeaderText)); Assert.That(hudToolViewModelActual.Height, Is.EqualTo(hudToolViewModelExpected.Height)); Assert.That(hudToolViewModelActual.Position, Is.EqualTo(hudToolViewModelExpected.Position)); Assert.That(hudToolViewModelActual.IsGraphIndicatorsDisabled, Is.EqualTo(hudToolViewModelExpected.IsGraphIndicatorsDisabled)); Assert.That(hudToolViewModelActual.GroupedStats.Count, Is.EqualTo(hudToolViewModelExpected.GroupedStats.Count)); var hudGaugeIndicatorStats = hudToolViewModelActual.GroupedStats.SelectMany(x => x.Stats).ToArray(); foreach (var groupedStat in hudToolViewModelExpected.GroupedStats) { foreach (var expectedHudGaugeIndicatorStat in groupedStat.Stats) { var actualHudGaugeIndicatorStat = hudGaugeIndicatorStats.FirstOrDefault(x => x.Stat.Stat == expectedHudGaugeIndicatorStat.Stat.Stat); Assert.IsNotNull(actualHudGaugeIndicatorStat); if (expectedHudGaugeIndicatorStat.IsHeatMapVisible) { Assert.That(actualHudGaugeIndicatorStat.IsHeatMapVisible, Is.EqualTo(expectedHudGaugeIndicatorStat.IsHeatMapVisible)); Assert.That(actualHudGaugeIndicatorStat.HeatMapViewModel.BaseStat.Stat, Is.EqualTo(expectedHudGaugeIndicatorStat.HeatMapViewModel.BaseStat.Stat)); } } } }
private void MigratePopups(HudLayoutInfo layout, HudLayoutInfoV2 layoutInfoV2) { if (layout.HudStats.Any(x => x.Stat == Stat.VPIP)) { var hudLayoutVPIPGaugeIndicatorTool = new HudLayoutGaugeIndicator { BaseStat = CreateStatInfo(Stat.VPIP), Text = "TOTAL", HeaderText = "VPIP", Stats = new ReactiveList <StatInfo> { CreateStatInfo(Stat.VPIP_EP), CreateStatInfo(Stat.VPIP_MP), CreateStatInfo(Stat.VPIP_CO), CreateStatInfo(Stat.VPIP_BN), CreateStatInfo(Stat.VPIP_SB), CreateStatInfo(Stat.VPIP_BB), } }; var hudLayoutColdCallGaugeIndicatorTool = new HudLayoutGaugeIndicator { BaseStat = CreateStatInfo(Stat.VPIP), Text = "COLD CALL", HeaderText = "Cold Call", Stats = new ReactiveList <StatInfo> { CreateStatInfo(Stat.ColdCall_EP), CreateStatInfo(Stat.ColdCall_MP), CreateStatInfo(Stat.ColdCall_CO), CreateStatInfo(Stat.ColdCall_BN), CreateStatInfo(Stat.ColdCall_SB), CreateStatInfo(Stat.ColdCall_BB), } }; layoutInfoV2.LayoutTools.Add(hudLayoutVPIPGaugeIndicatorTool); layoutInfoV2.LayoutTools.Add(hudLayoutColdCallGaugeIndicatorTool); } if (layout.HudStats.Any(x => x.Stat == Stat.PFR)) { var hudLayoutPFRGaugeIndicatorTool = new HudLayoutGaugeIndicator { BaseStat = CreateStatInfo(Stat.PFR), Text = "UNOPENED", HeaderText = "PFR", Stats = new ReactiveList <StatInfo> { CreateStatInfo(Stat.UO_PFR_EP), CreateStatInfo(Stat.UO_PFR_MP), CreateStatInfo(Stat.UO_PFR_CO), CreateStatInfo(Stat.UO_PFR_BN), CreateStatInfo(Stat.UO_PFR_SB) } }; layoutInfoV2.LayoutTools.Add(hudLayoutPFRGaugeIndicatorTool); } if (layout.HudStats.Any(x => x.Stat == Stat.S3Bet)) { var hudLayout3BetGaugeIndicatorTool = new HudLayoutGaugeIndicator { BaseStat = CreateStatInfo(Stat.S3Bet), Text = "TOTAL", HeaderText = "3-bet%", Stats = new ReactiveList <StatInfo> { CreateStatInfo(Stat.ThreeBet_EP), CreateStatInfo(Stat.ThreeBet_MP), CreateStatInfo(Stat.ThreeBet_CO), CreateStatInfo(Stat.ThreeBet_BN), CreateStatInfo(Stat.ThreeBet_SB), CreateStatInfo(Stat.ThreeBet_BB), } }; layoutInfoV2.LayoutTools.Add(hudLayout3BetGaugeIndicatorTool); } if (layout.HudStats.Any(x => x.Stat == Stat.AGG)) { var hudLayoutAggGaugeIndicatorTool = new HudLayoutGaugeIndicator { BaseStat = CreateStatInfo(Stat.AGG), Text = "TOTAL", HeaderText = "AGG%", Stats = new ReactiveList <StatInfo> { CreateStatInfo(Stat.FlopAGG), CreateStatInfo(Stat.TurnAGG), CreateStatInfo(Stat.RiverAGG), CreateStatInfo(Stat.RecentAgg) } }; layoutInfoV2.LayoutTools.Add(hudLayoutAggGaugeIndicatorTool); } if (layout.HudStats.Any(x => x.Stat == Stat.PlayerInfoIcon)) { var hudLayoutGraphTool = new HudLayoutGraphTool { BaseStat = CreateStatInfo(Stat.PlayerInfoIcon), Stats = new ReactiveList <StatInfo> { CreateStatInfo(Stat.NetWon) } }; layoutInfoV2.LayoutTools.Add(hudLayoutGraphTool); } }
/// <summary> /// Initialize an instance of <see cref="HudGaugeIndicatorViewModel"/> /// </summary> /// <param name="tool"><see cref="HudLayoutGaugeIndicator"/> to initialize an instance</param> /// <param name="parent">Parent <see cref="HudElementViewModel"/> to initialize an instance</param> public HudGaugeIndicatorViewModel(HudLayoutGaugeIndicator tool, HudElementViewModel parent) : this(tool) { Check.ArgumentNotNull(() => parent); Parent = parent; }