From 04a9523cc39f976915effed2c92e69343c93ce24 Mon Sep 17 00:00:00 2001 From: Johannes Schneider Date: Fri, 20 Nov 2020 19:31:30 +0100 Subject: [PATCH] * fixed a bug, which caused the GoldDifference window to spawn without the team being initialized correctly * increase the Team stats sizing slightly --- GoldDiff/LeagueOfLegends/Game/LoLGame.cs | 25 ++++++++++++++----- GoldDiff/View/ControlElement/LoLGameView.xaml | 8 +++--- GoldDiff/View/GoldDifferenceWindow.xaml | 3 ++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/GoldDiff/LeagueOfLegends/Game/LoLGame.cs b/GoldDiff/LeagueOfLegends/Game/LoLGame.cs index e68486d..b6a7839 100644 --- a/GoldDiff/LeagueOfLegends/Game/LoLGame.cs +++ b/GoldDiff/LeagueOfLegends/Game/LoLGame.cs @@ -94,7 +94,7 @@ public void GameClientClosed() State = LoLGameStateType.Ended; } - + public void Consume(LoLClientGameData? gameData) { if (gameData == null) @@ -125,6 +125,7 @@ public void Consume(LoLClientGameData? gameData) { EventDispatcher!.Invoke(() => Initialized.Invoke(this, EventArgs.Empty)); } + EventDispatcher!.Invoke(() => GameDataReceived?.Invoke(this, gameData)); } @@ -134,18 +135,30 @@ private bool Initialize(LoLClientGameData gameData) { return true; } - + Mode = gameData.Stats.GameMode; - if (Mode != LoLGameModeType.Classic5X5 && Mode != LoLGameModeType.PracticeTool) + if (Mode != LoLGameModeType.Classic5X5 + #if DEBUG + && Mode != LoLGameModeType.PracticeTool + #endif + ) { // We do support only classic 5v5 games right now State = LoLGameStateType.Undefined; return false; } - + var teams = LoLTeamFactory.ExtractTeams(gameData, StaticResourceCache).ToList(); - TeamBlueSide = teams.FirstOrDefault(team => team.Side == LoLTeamType.BlueSide) ?? new LoLTeam(LoLTeamType.BlueSide, Enumerable.Empty()); - TeamRedSide = teams.FirstOrDefault(team => team.Side == LoLTeamType.RedSide) ?? new LoLTeam(LoLTeamType.RedSide, Enumerable.Empty()); + TeamBlueSide = teams.FirstOrDefault(team => team.Side == LoLTeamType.BlueSide); + TeamRedSide = teams.FirstOrDefault(team => team.Side == LoLTeamType.RedSide); + + if (TeamBlueSide == null && TeamRedSide == null) + { + return false; + } + + TeamBlueSide ??= new LoLTeam(LoLTeamType.BlueSide, Enumerable.Empty()); + TeamRedSide ??= new LoLTeam(LoLTeamType.RedSide, Enumerable.Empty()); RespawnTimerCollection = new LoLRespawnTimerCollection(); TeamPowerPlayCollection = new LoLTeamPowerPlayCollection(this); diff --git a/GoldDiff/View/ControlElement/LoLGameView.xaml b/GoldDiff/View/ControlElement/LoLGameView.xaml index 732ba57..731bcb6 100644 --- a/GoldDiff/View/ControlElement/LoLGameView.xaml +++ b/GoldDiff/View/ControlElement/LoLGameView.xaml @@ -34,13 +34,13 @@ - + - + - + - + diff --git a/GoldDiff/View/GoldDifferenceWindow.xaml b/GoldDiff/View/GoldDifferenceWindow.xaml index d5bfe4b..bda310f 100644 --- a/GoldDiff/View/GoldDifferenceWindow.xaml +++ b/GoldDiff/View/GoldDifferenceWindow.xaml @@ -33,6 +33,7 @@ + 64 48 @@ -47,7 +48,7 @@ - +