From 1f9b1bd1fee80a851c3d7253cf151d6368669863 Mon Sep 17 00:00:00 2001 From: mtaheij Date: Sun, 18 Sep 2016 01:07:34 +0200 Subject: [PATCH 01/25] Use Incense and Lucky Eggs --- PokemonGo-UWP/Controls/RoundProgressBar.cs | 216 ++++++++++++++++++ PokemonGo-UWP/Entities/AppliedItemWrapper.cs | 110 +++++++++ PokemonGo-UWP/PokemonGo-UWP.csproj | 2 + .../Strings/en-US/CodeResources.resw | 3 + PokemonGo-UWP/Styles/Custom.xaml | 126 ++++++++++ PokemonGo-UWP/Utils/Game/Converters.cs | 83 ++++++- PokemonGo-UWP/Utils/GameClient.cs | 95 ++++++-- .../ViewModels/GameMapPageViewModel.cs | 32 +++ .../ViewModels/ItemsInventoryPageViewModel.cs | 82 +++++++ PokemonGo-UWP/Views/GameMapPage.xaml | 69 ++++++ PokemonGo-UWP/Views/GameMapPage.xaml.cs | 12 + PokemonGo-UWP/Views/ItemsInventoryPage.xaml | 11 +- 12 files changed, 820 insertions(+), 21 deletions(-) create mode 100644 PokemonGo-UWP/Controls/RoundProgressBar.cs create mode 100644 PokemonGo-UWP/Entities/AppliedItemWrapper.cs diff --git a/PokemonGo-UWP/Controls/RoundProgressBar.cs b/PokemonGo-UWP/Controls/RoundProgressBar.cs new file mode 100644 index 000000000..e94c5b970 --- /dev/null +++ b/PokemonGo-UWP/Controls/RoundProgressBar.cs @@ -0,0 +1,216 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.Foundation; +using Windows.UI; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Shapes; + +namespace PokemonGo_UWP.Controls +{ + public class RoundProgressBar : Canvas + { + public RoundProgressBar() + { + this.Loaded += OnLoaded; + } + + #region Properties + + public static readonly DependencyProperty RadiusProperty = + DependencyProperty.Register(nameof(Radius), typeof(int), typeof(RoundProgressBar), + new PropertyMetadata(100)); + + public static readonly DependencyProperty StrokeThicknessProperty = + DependencyProperty.Register(nameof(StrokeThickness), typeof(int), typeof(RoundProgressBar), + new PropertyMetadata(5)); + + public static readonly DependencyProperty ValueEndCapDiameterProperty = + DependencyProperty.Register(nameof(ValueEndCapDiameter), typeof(int), typeof(RoundProgressBar), + new PropertyMetadata(5)); + + public static readonly DependencyProperty ValueProperty = + DependencyProperty.Register(nameof(Value), typeof(int), typeof(RoundProgressBar), + new PropertyMetadata(0, OnValuePropertyChanged)); + + public static readonly DependencyProperty MinimumProperty = + DependencyProperty.Register(nameof(Minimum), typeof(int), typeof(RoundProgressBar), + new PropertyMetadata(0)); + + public static readonly DependencyProperty MaximumProperty = + DependencyProperty.Register(nameof(Maximum), typeof(int), typeof(RoundProgressBar), + new PropertyMetadata(100, OnMaximumPropertyChanged)); + + public static readonly DependencyProperty EmptyColorProperty = + DependencyProperty.Register(nameof(EmptyColor), typeof(Color), typeof(RoundProgressBar), + new PropertyMetadata(Color.FromArgb(0x00, 0x00, 0x00, 0x00))); + + public static readonly DependencyProperty FilledColorProperty = + DependencyProperty.Register(nameof(FilledColor), typeof(Color), typeof(RoundProgressBar), + new PropertyMetadata(Color.FromArgb(0x00, 0x00, 0x00, 0x00))); + + public int Radius + { + get { return (int)GetValue(RadiusProperty); } + set { SetValue(RadiusProperty, value); } + } + + public int StrokeThickness + { + get { return (int)GetValue(StrokeThicknessProperty); } + set { SetValue(StrokeThicknessProperty, value); } + } + + public int ValueEndCapDiameter + { + get { return (int)GetValue(ValueEndCapDiameterProperty); } + set { SetValue(ValueEndCapDiameterProperty, value); } + } + + public int Value + { + get { return (int)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + + public int Minimum + { + get { return (int)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + + public int Maximum + { + get { return (int)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + + public Color EmptyColor + { + get { return (Color)GetValue(EmptyColorProperty); } + set { SetValue(EmptyColorProperty, value); } + } + + public Color FilledColor + { + get { return (Color)GetValue(FilledColorProperty); } + set { SetValue(FilledColorProperty, value); } + } + + #endregion + + private void OnLoaded(object sender, RoutedEventArgs e) + { + SetControlSize(); + Draw(); + } + + private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = d as RoundProgressBar; + control.SetControlSize(); + control.Draw(); + } + + private static void OnMaximumPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + + var control = d as RoundProgressBar; + control.SetControlSize(); + control.Draw(); + } + + private void Draw() + { + Children.Clear(); + + Path radialBackgroundStrip = GetCircleSegment(GetCenterPoint(), Radius, 180); + radialBackgroundStrip.Stroke = new SolidColorBrush(EmptyColor); + radialBackgroundStrip.StrokeStartLineCap = PenLineCap.Round; + radialBackgroundStrip.StrokeEndLineCap = PenLineCap.Round; + radialBackgroundStrip.StrokeThickness = StrokeThickness; + + Children.Add(radialBackgroundStrip); + + Path radialValueStrip = GetCircleSegment(GetCenterPoint(), Radius, GetAngle()); + radialValueStrip.Stroke = new SolidColorBrush(FilledColor); + radialValueStrip.StrokeStartLineCap = PenLineCap.Round; + radialValueStrip.StrokeThickness = StrokeThickness; + + Children.Add(radialValueStrip); + + Ellipse valueEndpoint = new Ellipse(); + valueEndpoint.Fill = new SolidColorBrush(FilledColor); + valueEndpoint.Height = ValueEndCapDiameter; + valueEndpoint.Width = ValueEndCapDiameter; + Point valuePointCenter = ScaleUnitCirclePoint(GetCenterPoint(), Radius, GetAngle()); + SetLeft(valueEndpoint, valuePointCenter.X - (ValueEndCapDiameter / 2)); + SetTop(valueEndpoint, valuePointCenter.Y - (ValueEndCapDiameter / 2)); + + Children.Add(valueEndpoint); + } + + private void SetControlSize() + { + Width = Radius * 2 + Math.Max(StrokeThickness, ValueEndCapDiameter); + Height = Radius + Math.Max(StrokeThickness, ValueEndCapDiameter); + } + + private Point GetCenterPoint() + { + return new Point(Radius + (StrokeThickness / 2), Radius + (StrokeThickness / 2)); + } + + private double GetAngle() + { + double angle = (double)(Math.Min(Math.Max(Value, Minimum), Maximum) - Minimum) / (double)(Maximum - Minimum) * 180; + + if (angle >= 180) + { + angle = 179.999; + } + + return angle; + } + + private const double RADIANS = Math.PI / 180; + + private Path GetCircleSegment(Point centerPoint, double radius, double angle) + { + var path = new Path(); + var pathGeometry = new PathGeometry(); + + var circleStart = new Point(centerPoint.X - radius, centerPoint.Y); + + var arcSegment = new ArcSegment + { + IsLargeArc = false, + Point = ScaleUnitCirclePoint(centerPoint, radius, angle), + Size = new Size(radius, radius), + SweepDirection = SweepDirection.Clockwise, + RotationAngle = -90 + }; + + var pathFigure = new PathFigure + { + StartPoint = circleStart, + IsClosed = false + }; + + pathFigure.Segments.Add(arcSegment); + pathGeometry.Figures.Add(pathFigure); + + path.Data = pathGeometry; + return path; + } + + private Point ScaleUnitCirclePoint(Point origin, double radius, double angle) + { + return new Point(origin.X - Math.Cos(RADIANS * angle) * radius, origin.Y - Math.Sin(RADIANS * angle) * radius); + } + } +} diff --git a/PokemonGo-UWP/Entities/AppliedItemWrapper.cs b/PokemonGo-UWP/Entities/AppliedItemWrapper.cs new file mode 100644 index 000000000..6c6f1d85c --- /dev/null +++ b/PokemonGo-UWP/Entities/AppliedItemWrapper.cs @@ -0,0 +1,110 @@ +using Newtonsoft.Json; +using PokemonGo_UWP.Utils; +using PokemonGo_UWP.Utils.Helpers; +using PokemonGo_UWP.Views; +using POGOProtos.Inventory.Item; +using Template10.Common; +using Template10.Mvvm; +using System.ComponentModel; +using POGOProtos.Inventory; +using System; +using PokemonGo.RocketAPI.Extensions; + +namespace PokemonGo_UWP.Entities +{ + public class AppliedItemWrapper : INotifyPropertyChanged + { + private AppliedItem _wrappedData; + + public AppliedItemWrapper(AppliedItem appliedItem) + { + _wrappedData = appliedItem; + } + + [JsonProperty, JsonConverter(typeof(ProtobufJsonNetConverter))] + public AppliedItem WrappedData { get { return _wrappedData; } } + + public void Update(AppliedItem update) + { + _wrappedData = update; + + OnPropertyChanged(nameof(ItemId)); + OnPropertyChanged(nameof(ItemType)); + OnPropertyChanged(nameof(AppliedMs)); + OnPropertyChanged(nameof(ExpireMs)); + OnPropertyChanged(nameof(MaxSeconds)); + OnPropertyChanged(nameof(RemainingMs)); + OnPropertyChanged(nameof(RemainingSeconds)); + OnPropertyChanged(nameof(RemainingTime)); + } + + #region Wrapped Properties + + public ItemId ItemId => _wrappedData.ItemId; + + public ItemType ItemType => _wrappedData.ItemType; + + public long AppliedMs => _wrappedData.AppliedMs; + + public long ExpireMs => _wrappedData.ExpireMs; + + public long RemainingMs + { + get + { + long nowMs = DateTime.UtcNow.ToUnixTime(); + long remainingMs = ExpireMs - nowMs; + if (remainingMs < 0) remainingMs = 0; + return remainingMs; + } + } + + public int RemainingSeconds + { + get + { + return (int)(RemainingMs / 1000); + } + } + + public string RemainingTime + { + get + { + DateTime remainingTime = new DateTime().AddMilliseconds(RemainingMs); + return remainingTime.ToString("mm:ss"); + } + } + + public bool IsExpired + { + get + { + if (RemainingMs <= 0) return true; + return false; + } + } + #endregion + + public int MaxSeconds + { + get + { + long maxMs = ExpireMs - AppliedMs; + int maxSeconds = (int)maxMs / 1000; + return maxSeconds; + } + } + + #region INotifyPropertyChanged + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion + } +} \ No newline at end of file diff --git a/PokemonGo-UWP/PokemonGo-UWP.csproj b/PokemonGo-UWP/PokemonGo-UWP.csproj index 58fb42239..926ebd30f 100644 --- a/PokemonGo-UWP/PokemonGo-UWP.csproj +++ b/PokemonGo-UWP/PokemonGo-UWP.csproj @@ -733,6 +733,7 @@ App.xaml + PoGoMessageDialog.xaml @@ -751,6 +752,7 @@ + diff --git a/PokemonGo-UWP/Strings/en-US/CodeResources.resw b/PokemonGo-UWP/Strings/en-US/CodeResources.resw index 48ab2b01a..80e0bfa38 100644 --- a/PokemonGo-UWP/Strings/en-US/CodeResources.resw +++ b/PokemonGo-UWP/Strings/en-US/CodeResources.resw @@ -355,4 +355,7 @@ You also got {1} Stardust, {2} Candy and {3} XP. Lure Module + + Use {0} ? + \ No newline at end of file diff --git a/PokemonGo-UWP/Styles/Custom.xaml b/PokemonGo-UWP/Styles/Custom.xaml index ce56935cd..d5150dedd 100644 --- a/PokemonGo-UWP/Styles/Custom.xaml +++ b/PokemonGo-UWP/Styles/Custom.xaml @@ -1,6 +1,7 @@  @@ -831,6 +832,68 @@ + + + + + + + + + @@ -1018,6 +1117,17 @@ + + @@ -1210,6 +1320,22 @@ + + + diff --git a/PokemonGo-UWP/Utils/Game/Converters.cs b/PokemonGo-UWP/Utils/Game/Converters.cs index 4bce504b5..46bd4d5b9 100644 --- a/PokemonGo-UWP/Utils/Game/Converters.cs +++ b/PokemonGo-UWP/Utils/Game/Converters.cs @@ -343,7 +343,13 @@ public class ItemToItemIconConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, string language) { - var itemId = (value as ItemAward)?.ItemId ?? ((value as ItemData)?.ItemId ?? ((ItemDataWrapper)value).ItemId); + ItemId itemId = ItemId.ItemUnknown; + + if (value is ItemAward) itemId = (value as ItemAward).ItemId; + if (value is ItemData) itemId = (value as ItemData).ItemId; + if (value is ItemDataWrapper) itemId = (value as ItemDataWrapper).ItemId; + if (value is AppliedItemWrapper) itemId = (value as AppliedItemWrapper).ItemId; + return new Uri($"ms-appx:///Assets/Items/Item_{(int)itemId}.png"); } @@ -727,7 +733,13 @@ public class ItemToItemNameConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, string language) { - var itemId = (value as ItemAward)?.ItemId ?? ((value as ItemData)?.ItemId ?? ((ItemDataWrapper)value).ItemId); + ItemId itemId = ItemId.ItemUnknown; + + if (value is ItemAward) itemId = (value as ItemAward).ItemId; + if (value is ItemData) itemId = (value as ItemData).ItemId; + if (value is ItemDataWrapper) itemId = (value as ItemDataWrapper).ItemId; + if (value is AppliedItemWrapper) itemId = (value as AppliedItemWrapper).ItemId; + return Resources.Items.GetString(itemId.ToString()); } @@ -745,7 +757,13 @@ public class ItemToItemDescriptionConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, string language) { - var itemId = (value as ItemAward)?.ItemId ?? ((value as ItemData)?.ItemId ?? ((ItemDataWrapper)value).ItemId); + ItemId itemId = ItemId.ItemUnknown; + + if (value is ItemAward) itemId = (value as ItemAward).ItemId; + if (value is ItemData) itemId = (value as ItemData).ItemId; + if (value is ItemDataWrapper) itemId = (value as ItemDataWrapper).ItemId; + if (value is AppliedItemWrapper) itemId = (value as AppliedItemWrapper).ItemId; + return Resources.Items.GetString("D_" + itemId); } @@ -763,7 +781,13 @@ public class ItemToItemRecycleVisibilityConverter : IValueConverter public object Convert(object value, Type targetType, object parameter, string language) { - var itemId = (value as ItemAward)?.ItemId ?? ((value as ItemData)?.ItemId ?? ((ItemDataWrapper)value).ItemId); + ItemId itemId = ItemId.ItemUnknown; + + if (value is ItemAward) itemId = (value as ItemAward).ItemId; + if (value is ItemData) itemId = (value as ItemData).ItemId; + if (value is ItemDataWrapper) itemId = (value as ItemDataWrapper).ItemId; + if (value is AppliedItemWrapper) itemId = (value as AppliedItemWrapper).ItemId; + switch(itemId) { case ItemId.ItemUnknown: @@ -805,7 +829,15 @@ public object Convert(object value, Type targetType, object parameter, string la if (!(value is ItemDataWrapper)) return 1; var useableList = CurrentViewMode == ViewModels.ItemsInventoryPageViewModel.ItemsInventoryViewMode.Normal ? GameClient.NormalUseItemIds : GameClient.CatchItemIds; - return useableList.Contains(((ItemDataWrapper)value).ItemId) ? 1 : 0.5; + // If a similar item is already applied, it cannot be chosen again + foreach (AppliedItemWrapper appliedItem in GameClient.AppliedItems) + { + if (appliedItem.ItemId == ((ItemDataWrapper)value).ItemId) + { + return false; + } + } + return useableList.Contains(((ItemDataWrapper)value).ItemId) ? 1 : 0.5; } public object ConvertBack(object value, Type targetType, object parameter, string language) @@ -816,6 +848,47 @@ public object ConvertBack(object value, Type targetType, object parameter, strin #endregion } + public class ItemUseabilityToBooleanConverter : DependencyObject, IValueConverter + { + public ViewModels.ItemsInventoryPageViewModel.ItemsInventoryViewMode CurrentViewMode + { + get { return (ViewModels.ItemsInventoryPageViewModel.ItemsInventoryViewMode)GetValue(CurrentViewModeProperty); } + set { SetValue(CurrentViewModeProperty, value); } + } + + public static readonly DependencyProperty CurrentViewModeProperty = + DependencyProperty.Register("CurrentViewMode", + typeof(ViewModels.ItemsInventoryPageViewModel.ItemsInventoryViewMode), + typeof(ItemUseabilityToBooleanConverter), + new PropertyMetadata(null)); + + #region Implementation of IValueConverter + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (!(value is ItemDataWrapper)) return 1; + + var useableList = CurrentViewMode == ViewModels.ItemsInventoryPageViewModel.ItemsInventoryViewMode.Normal ? GameClient.NormalUseItemIds : GameClient.CatchItemIds; + + // If a similar item is already applied, it cannot be chosen again + foreach (AppliedItemWrapper appliedItem in GameClient.AppliedItems) + { + if (appliedItem.ItemId == ((ItemDataWrapper)value).ItemId) + { + return false; + } + } + return useableList.Contains(((ItemDataWrapper)value).ItemId) ? true : false; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } + + #endregion + } + public class CaptureXpToTotalCaptureXpConverter : IValueConverter { #region Implementation of IValueConverter diff --git a/PokemonGo-UWP/Utils/GameClient.cs b/PokemonGo-UWP/Utils/GameClient.cs index 52b4e73a8..7666710b1 100644 --- a/PokemonGo-UWP/Utils/GameClient.cs +++ b/PokemonGo-UWP/Utils/GameClient.cs @@ -68,10 +68,15 @@ private class Heartbeat /// private DispatcherTimer _mapUpdateTimer; - /// - /// True if another update operation is in progress. - /// - private bool _isHeartbeating; + /// + /// Timer used to update applied item + /// + private DispatcherTimer _appliedItemUpdateTimer; + + /// + /// True if another update operation is in progress. + /// + private bool _isHeartbeating; /// /// Checks if we need to update data @@ -149,16 +154,40 @@ private async void HeartbeatTick(object sender, object o) internal async Task StartDispatcher() { _keepHeartbeating = true; - if (_mapUpdateTimer != null) return; - - await DispatcherHelper.RunInDispatcherAndAwait(() => - { - _mapUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; - _mapUpdateTimer.Tick += HeartbeatTick; - _mapUpdateTimer.Start(); - }); + if (_mapUpdateTimer == null) + { + await DispatcherHelper.RunInDispatcherAndAwait(() => + { + _mapUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; + _mapUpdateTimer.Tick += HeartbeatTick; + _mapUpdateTimer.Start(); + }); + } + if (_appliedItemUpdateTimer == null) + { + await DispatcherHelper.RunInDispatcherAndAwait((Action)(() => + { + _appliedItemUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; + _appliedItemUpdateTimer.Tick += this._appliedItemUpdateTimer_Tick; + _appliedItemUpdateTimer.Start(); + })); + } } + private void _appliedItemUpdateTimer_Tick(object sender, object e) + { + foreach(AppliedItemWrapper appliedItem in AppliedItems) + { + if (appliedItem.IsExpired) + { + OnAppliedItemExpired?.Invoke(null, appliedItem); + AppliedItems.Remove(appliedItem); + break; + } + appliedItem.Update(appliedItem.WrappedData); + } + } + /// /// Stops heartbeat /// @@ -203,6 +232,11 @@ public static string CurrentVersion /// public static InventoryDelta InventoryDelta { get; private set; } + /// + /// Collection of applied items + /// + public static ObservableCollection AppliedItems { get; set; } = + new ObservableCollection(); #region Collections /// @@ -314,6 +348,7 @@ public static string CurrentVersion static GameClient() { PokedexInventory.CollectionChanged += PokedexInventory_CollectionChanged; + AppliedItems.CollectionChanged += AppliedItems_CollectionChanged; // TODO: Investigate whether or not this needs to be unsubscribed when the app closes. } @@ -336,7 +371,15 @@ private static void PokedexInventory_CollectionChanged(object sender, NotifyColl } } - #endregion + private static void AppliedItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) + { + OnAppliedItemStarted?.Invoke(null, (AppliedItemWrapper)e.NewItems[0]); + } + } + + #endregion #region Game Logic @@ -492,6 +535,8 @@ public static void DoLogout() private static Heartbeat _heartbeat; public static event EventHandler OnEggHatched; + public static event EventHandler OnAppliedItemExpired; + public static event EventHandler OnAppliedItemStarted; #region Compass Stuff /// @@ -1059,9 +1104,29 @@ public static async Task GetGymDetails(string gymid, doub /// StartGymBattle /// AttackGym - #endregion + #endregion + + #region Items Handling - #region Items Handling + /// + /// Uses the given incense item + /// + /// + /// + public static async Task UseIncense(ItemId item) + { + return await _client.Inventory.UseIncense(item); + } + + /// + /// Uses the given XpBoost item + /// + /// + /// + public static async Task UseXpBoost(ItemId item) + { + return await _client.Inventory.UseItemXpBoost(); + } /// /// Recycles the given amount of the selected item diff --git a/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs b/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs index e89cb93fd..45b6a6c71 100644 --- a/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs @@ -23,6 +23,7 @@ using POGOProtos.Map.Pokemon; using Google.Protobuf; using PokemonGo_UWP.Controls; +using POGOProtos.Inventory; namespace PokemonGo_UWP.ViewModels { @@ -56,6 +57,15 @@ public GameMapPageViewModel() } } + private void GameClient_OnAppliedItemExpired(object sender, AppliedItemWrapper e) + { + AppliedItemExpired?.Invoke(null, e); + } + + private void GameClient_OnAppliedItemStarted(object sender, AppliedItemWrapper e) + { + AppliedItemStarted?.Invoke(null, e); + } #region Lifecycle Handlers @@ -68,6 +78,9 @@ public GameMapPageViewModel() public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary suspensionState) { + GameClient.OnAppliedItemExpired += GameClient_OnAppliedItemExpired; + GameClient.OnAppliedItemStarted += GameClient_OnAppliedItemStarted; + // Prevent from going back to other pages NavigationService.ClearHistory(); if (parameter == null || mode == NavigationMode.Back) return; @@ -202,6 +215,11 @@ public LevelUpRewardsResponse LevelUpResponse private set { Set(ref _levelUpRewards, value); } } + /// + /// Collection of Applied items, like Incense + /// + public static ObservableCollection AppliedItems => GameClient.AppliedItems; + /// /// Collection of Pokemon in 1 step from current position /// @@ -242,6 +260,20 @@ public LevelUpRewardsResponse LevelUpResponse #endregion + #region AppliedItem Events + + /// + /// Event fired when an applied item has expired + /// + public event EventHandler AppliedItemExpired; + + /// + /// Event fired when an new item has been applied + /// + public event EventHandler AppliedItemStarted; + + #endregion + /// /// Waits for GPS auth and, if auth is given, starts updating data /// diff --git a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs index d6e2cf447..02a5aacd1 100644 --- a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs @@ -12,6 +12,7 @@ using PokemonGo_UWP.Controls; using POGOProtos.Networking.Responses; using System; +using POGOProtos.Inventory; namespace PokemonGo_UWP.ViewModels { @@ -136,6 +137,87 @@ public DelegateCommand ReturnToGameScreen #endregion + #region Use + + private DelegateCommand _useItemCommand; + + public DelegateCommand UseItemCommand => _useItemCommand ?? ( + _useItemCommand = new DelegateCommand((ItemDataWrapper item) => + { + if (item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncenseOrdinary || + item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncenseSpicy || + item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncenseFloral || + item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncenseCool) + { + var dialog = new PoGoMessageDialog("", string.Format(Resources.CodeResources.GetString("ItemUseQuestionText"), Resources.Items.GetString(item.ItemId.ToString()))); + dialog.AcceptText = Resources.CodeResources.GetString("YesText"); + dialog.CancelText = Resources.CodeResources.GetString("CancelText"); + dialog.CoverBackground = true; + dialog.AnimationType = PoGoMessageDialogAnimation.Bottom; + dialog.AcceptInvoked += async (sender, e) => + { + //// Send use request + var res = await GameClient.UseIncense(item.ItemId); + switch (res.Result) + { + case UseIncenseResponse.Types.Result.Success: + GameClient.AppliedItems.Add(new AppliedItemWrapper(res.AppliedIncense)); + await GameClient.UpdateInventory(); + break; + case UseIncenseResponse.Types.Result.IncenseAlreadyActive: + break; + case UseIncenseResponse.Types.Result.LocationUnset: + break; + case UseIncenseResponse.Types.Result.NoneInInventory: + break; + case UseIncenseResponse.Types.Result.Unknown: + break; + default: + throw new ArgumentOutOfRangeException(); + } + }; + + dialog.Show(); + } + + if (item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemLuckyEgg) + { + var dialog = new PoGoMessageDialog("", string.Format(Resources.CodeResources.GetString("ItemUseQuestionText"), Resources.Items.GetString(item.ItemId.ToString()))); + dialog.AcceptText = Resources.CodeResources.GetString("YesText"); + dialog.CancelText = Resources.CodeResources.GetString("CancelText"); + dialog.CoverBackground = true; + dialog.AnimationType = PoGoMessageDialogAnimation.Bottom; + dialog.AcceptInvoked += async (sender, e) => + { + // Send use request + var res = await GameClient.UseXpBoost(item.ItemId); + switch (res.Result) + { + case UseItemXpBoostResponse.Types.Result.Success: + AppliedItem appliedItem = res.AppliedItems.Item.FirstOrDefault(); + GameClient.AppliedItems.Add(new AppliedItemWrapper(appliedItem)); + await GameClient.UpdateInventory(); + break; + case UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive: + break; + case UseItemXpBoostResponse.Types.Result.ErrorInvalidItemType: + break; + case UseItemXpBoostResponse.Types.Result.ErrorLocationUnset: + break; + case UseItemXpBoostResponse.Types.Result.ErrorNoItemsRemaining: + break; + case UseItemXpBoostResponse.Types.Result.Unset: + break; + default: + throw new ArgumentOutOfRangeException(); + } + }; + + dialog.Show(); + } + }, (ItemDataWrapper item) => true)); + #endregion + #region Recycle private DelegateCommand _recycleItemCommand; diff --git a/PokemonGo-UWP/Views/GameMapPage.xaml b/PokemonGo-UWP/Views/GameMapPage.xaml index 8c9cb8f74..8c63d4e9c 100644 --- a/PokemonGo-UWP/Views/GameMapPage.xaml +++ b/PokemonGo-UWP/Views/GameMapPage.xaml @@ -12,6 +12,7 @@ xmlns:viewModels="using:PokemonGo_UWP.ViewModels" xmlns:entities="using:PokemonGo_UWP.Entities" xmlns:controls="using:Template10.Controls" + xmlns:POGOcontrols="using:PokemonGo_UWP.Controls" xmlns:utils="using:PokemonGo_UWP.Utils" x:Name="GamePage" RequestedTheme="{Binding CurrentTheme, Mode=OneWay}" @@ -239,6 +240,14 @@ Duration="0:0:0.2" /> + + + + + + + + @@ -704,6 +713,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + Margin="0,12,0,0" + Canvas.ZIndex="10" + SelectionMode="Single"> diff --git a/PokemonGo-UWP/Views/SearchPokestopPage.xaml b/PokemonGo-UWP/Views/SearchPokestopPage.xaml index 7eb57b1c9..caa830892 100644 --- a/PokemonGo-UWP/Views/SearchPokestopPage.xaml +++ b/PokemonGo-UWP/Views/SearchPokestopPage.xaml @@ -237,13 +237,17 @@ - - - - + + + + Date: Tue, 20 Sep 2016 19:25:46 +0200 Subject: [PATCH 05/25] Modifier button above circle --- PokemonGo-UWP/Styles/Custom.xaml | 2 +- PokemonGo-UWP/Views/SearchPokestopPage.xaml | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/PokemonGo-UWP/Styles/Custom.xaml b/PokemonGo-UWP/Styles/Custom.xaml index d5150dedd..5d96953ef 100644 --- a/PokemonGo-UWP/Styles/Custom.xaml +++ b/PokemonGo-UWP/Styles/Custom.xaml @@ -1184,7 +1184,7 @@ - + diff --git a/PokemonGo-UWP/Views/SearchPokestopPage.xaml b/PokemonGo-UWP/Views/SearchPokestopPage.xaml index 7eb57b1c9..caa830892 100644 --- a/PokemonGo-UWP/Views/SearchPokestopPage.xaml +++ b/PokemonGo-UWP/Views/SearchPokestopPage.xaml @@ -237,13 +237,17 @@ - - - - + + + + Date: Tue, 20 Sep 2016 19:32:20 +0200 Subject: [PATCH 06/25] Removed duplicate source include --- PokemonGo-UWP/PokemonGo-UWP.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/PokemonGo-UWP/PokemonGo-UWP.csproj b/PokemonGo-UWP/PokemonGo-UWP.csproj index 75bbd4124..03579c676 100644 --- a/PokemonGo-UWP/PokemonGo-UWP.csproj +++ b/PokemonGo-UWP/PokemonGo-UWP.csproj @@ -766,7 +766,6 @@ - From 105fd92f0180c3cae92e3d74c53809ebeb28c997 Mon Sep 17 00:00:00 2001 From: mtaheij Date: Tue, 20 Sep 2016 21:20:43 +0200 Subject: [PATCH 07/25] Save AppliedItems to SettingsService and retrieve after restart --- PokemonGo-UWP/App.xaml | 1 + PokemonGo-UWP/Utils/Game/Converters.cs | 19 ++++ PokemonGo-UWP/Utils/GameClient.cs | 105 ++++++++++++++---- .../Utils/Settings/SettingsService.cs | 43 +++++++ .../ViewModels/CapturePokemonPageViewModel.cs | 4 + .../ViewModels/GameMapPageViewModel.cs | 4 + .../ViewModels/ItemsInventoryPageViewModel.cs | 30 ++--- PokemonGo-UWP/Views/GameMapPage.xaml | 12 +- 8 files changed, 178 insertions(+), 40 deletions(-) diff --git a/PokemonGo-UWP/App.xaml b/PokemonGo-UWP/App.xaml index 75064912e..de0f0cfa9 100644 --- a/PokemonGo-UWP/App.xaml +++ b/PokemonGo-UWP/App.xaml @@ -76,6 +76,7 @@ + diff --git a/PokemonGo-UWP/Utils/Game/Converters.cs b/PokemonGo-UWP/Utils/Game/Converters.cs index 46bd4d5b9..d9103be16 100644 --- a/PokemonGo-UWP/Utils/Game/Converters.cs +++ b/PokemonGo-UWP/Utils/Game/Converters.cs @@ -1663,4 +1663,23 @@ public object ConvertBack(object value, Type targetType, object parameter, strin } #endregion } + + public class IsIncenseActiveToPlayerIconConverter : IValueConverter + { + #region Implementation of IValueConverter + + public object Convert(object value, Type targetType, object parameter, string language) + { + if ((bool)value) + return new Uri($"ms-appx:///Assets/Ui/ash_withincense.png"); + else + return new Uri($"ms-appx:///Assets/Ui/ash.png"); + } + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + + #endregion + } } diff --git a/PokemonGo-UWP/Utils/GameClient.cs b/PokemonGo-UWP/Utils/GameClient.cs index bc9b953bc..5de9144c7 100644 --- a/PokemonGo-UWP/Utils/GameClient.cs +++ b/PokemonGo-UWP/Utils/GameClient.cs @@ -180,7 +180,6 @@ private void _appliedItemUpdateTimer_Tick(object sender, object e) { if (appliedItem.IsExpired) { - OnAppliedItemExpired?.Invoke(null, appliedItem); AppliedItems.Remove(appliedItem); break; } @@ -232,17 +231,35 @@ public static string CurrentVersion /// public static InventoryDelta InventoryDelta { get; private set; } + public static bool IsIncenseActive + { + get + { + bool foundActiveIncense = false; + foreach (AppliedItemWrapper appliedItem in AppliedItems) + { + if (appliedItem.ItemType == ItemType.Incense && !appliedItem.IsExpired) + { + foundActiveIncense = true; + break; + } + } + return foundActiveIncense; + } + } + + #region Collections + /// /// Collection of applied items /// public static ObservableCollection AppliedItems { get; set; } = new ObservableCollection(); - #region Collections - /// - /// Collection of Pokemon in 1 step from current position - /// - public static ObservableCollection CatchablePokemons { get; set; } = + /// + /// Collection of Pokemon in 1 step from current position + /// + public static ObservableCollection CatchablePokemons { get; set; } = new ObservableCollection(); /// @@ -382,6 +399,25 @@ private static void AppliedItems_CollectionChanged(object sender, NotifyCollecti { OnAppliedItemStarted?.Invoke(null, (AppliedItemWrapper)e.NewItems[0]); } + else if (e.Action == NotifyCollectionChangedAction.Remove) + { + AppliedItemWrapper appliedItemWrapper = e.OldItems[0] as AppliedItemWrapper; + if (appliedItemWrapper.ItemType == ItemType.Incense) + { + SettingsService.Instance.IsIncenseActive = false; + SettingsService.Instance.IncenseAppliedMs = 0; + SettingsService.Instance.IncenseExpireMs = 0; + SettingsService.Instance.IncenseItemId = ItemId.ItemUnknown; + } + else if (appliedItemWrapper.ItemType == ItemType.XpBoost) + { + SettingsService.Instance.IsXpBoostActive = false; + SettingsService.Instance.XpBoostAppliedMs = 0; + SettingsService.Instance.XpBoostExpireMs = 0; + } + + OnAppliedItemExpired?.Invoke(null, (AppliedItemWrapper)e.OldItems[0]); + } } #endregion @@ -451,15 +487,39 @@ public static async Task InitializeClient() await new MessageDialog(e.Message).ShowAsyncQueue(); } } - } - /// - /// Starts a PTC session for the given user - /// - /// - /// - /// true if login worked - public static async Task DoPtcLogin(string username, string password) + if (SettingsService.Instance.IsIncenseActive) + { + AppliedItem incenseItem = new AppliedItem + { + AppliedMs = SettingsService.Instance.IncenseAppliedMs, + ExpireMs = SettingsService.Instance.IncenseExpireMs, + ItemId = SettingsService.Instance.IncenseItemId, + ItemType = ItemType.Incense + }; + AppliedItems.Add(new AppliedItemWrapper(incenseItem)); + } + + if (SettingsService.Instance.IsXpBoostActive) + { + AppliedItem xpboostItem = new AppliedItem + { + AppliedMs = SettingsService.Instance.XpBoostAppliedMs, + ExpireMs = SettingsService.Instance.XpBoostExpireMs, + ItemId = ItemId.ItemLuckyEgg, + ItemType = ItemType.XpBoost + }; + AppliedItems.Add(new AppliedItemWrapper(xpboostItem)); + } + } + + /// + /// Starts a PTC session for the given user + /// + /// + /// + /// true if login worked + public static async Task DoPtcLogin(string username, string password) { _clientSettings = new Settings { @@ -684,14 +744,17 @@ private static async Task UpdateMapObjects() LuredPokemons.UpdateByIndexWith(newLuredPokemon, x => x); // Update IncensePokemon - var incensePokemonResponse = await GetIncensePokemons(LocationServiceHelper.Instance.Geoposition); - if (incensePokemonResponse.Result == GetIncensePokemonResponse.Types.Result.IncenseEncounterAvailable) + if (IsIncenseActive) { - IncensePokemon[] newIncensePokemon; - newIncensePokemon = new IncensePokemon[1]; - newIncensePokemon[0] = new IncensePokemon(incensePokemonResponse, incensePokemonResponse.Latitude, incensePokemonResponse.Longitude); - Logger.Write($"Found incense Pokemon {incensePokemonResponse.PokemonId}"); - IncensePokemons.UpdateByIndexWith(newIncensePokemon, x => x); + var incensePokemonResponse = await GetIncensePokemons(LocationServiceHelper.Instance.Geoposition); + if (incensePokemonResponse.Result == GetIncensePokemonResponse.Types.Result.IncenseEncounterAvailable) + { + IncensePokemon[] newIncensePokemon; + newIncensePokemon = new IncensePokemon[1]; + newIncensePokemon[0] = new IncensePokemon(incensePokemonResponse, incensePokemonResponse.Latitude, incensePokemonResponse.Longitude); + Logger.Write($"Found incense Pokemon {incensePokemonResponse.PokemonId}"); + IncensePokemons.UpdateByIndexWith(newIncensePokemon, x => x); + } } Logger.Write("Finished updating map objects"); diff --git a/PokemonGo-UWP/Utils/Settings/SettingsService.cs b/PokemonGo-UWP/Utils/Settings/SettingsService.cs index 942ce9524..c8039b30f 100644 --- a/PokemonGo-UWP/Utils/Settings/SettingsService.cs +++ b/PokemonGo-UWP/Utils/Settings/SettingsService.cs @@ -6,6 +6,8 @@ using System; using Template10.Mvvm; using System.Runtime.CompilerServices; +using POGOProtos.Inventory.Item; +using PokemonGo.RocketAPI.Extensions; namespace PokemonGo_UWP.Utils { @@ -166,6 +168,47 @@ public double Zoomlevel set { Set(value); } } + public bool IsIncenseActive + { + get { return Get(false); } + set { Set(value); } + } + + public long IncenseAppliedMs + { + get { return Get(DateTime.UtcNow.ToUnixTime()); } + set { Set(value); } + } + + public long IncenseExpireMs + { + get { return Get(DateTime.UtcNow.ToUnixTime()); } + set { Set(value); } + } + + public ItemId IncenseItemId + { + get { return Get(ItemId.ItemIncenseOrdinary); } + set { Set(value); } + } + + public bool IsXpBoostActive + { + get { return Get(false); } + set { Set(value); } + } + + public long XpBoostAppliedMs + { + get { return Get(DateTime.UtcNow.ToUnixTime()); } + set { Set(value); } + } + + public long XpBoostExpireMs + { + get { return Get(DateTime.UtcNow.ToUnixTime()); } + set { Set(value); } + } #endregion #region Dev Stuff diff --git a/PokemonGo-UWP/ViewModels/CapturePokemonPageViewModel.cs b/PokemonGo-UWP/ViewModels/CapturePokemonPageViewModel.cs index 4e5ffb5ae..33d89bd71 100644 --- a/PokemonGo-UWP/ViewModels/CapturePokemonPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/CapturePokemonPageViewModel.cs @@ -157,15 +157,18 @@ public override async Task OnNavigatedToAsync(object parameter, NavigationMode m // Recovering the state CurrentEncounter = new EncounterResponse(); CurrentLureEncounter = new DiskEncounterResponse(); + CurrentIncenseEncounter = new IncenseEncounterResponse(); CurrentCaptureAward = new CaptureAward(); SelectedCaptureItem = new ItemData(); CurrentPokemon = JsonConvert.DeserializeObject((string) suspensionState[nameof(CurrentPokemon)]); CurrentEncounter.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(CurrentEncounter)]).CreateCodedInput()); CurrentLureEncounter.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(CurrentLureEncounter)]).CreateCodedInput()); + CurrentIncenseEncounter.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(CurrentIncenseEncounter)]).CreateCodedInput()); CurrentCaptureAward.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(CurrentCaptureAward)]).CreateCodedInput()); SelectedCaptureItem.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(SelectedCaptureItem)]).CreateCodedInput()); RaisePropertyChanged(() => CurrentEncounter); RaisePropertyChanged(() => CurrentLureEncounter); + RaisePropertyChanged(() => CurrentIncenseEncounter); RaisePropertyChanged(() => CurrentCaptureAward); RaisePropertyChanged(() => SelectedCaptureItem); } @@ -193,6 +196,7 @@ public override async Task OnNavigatedFromAsync(IDictionary susp suspensionState[nameof(CurrentPokemon)] = JsonConvert.SerializeObject(CurrentPokemon); suspensionState[nameof(CurrentEncounter)] = CurrentEncounter.ToByteString().ToBase64(); suspensionState[nameof(CurrentLureEncounter)] = CurrentLureEncounter.ToByteString().ToBase64(); + suspensionState[nameof(CurrentIncenseEncounter)] = CurrentIncenseEncounter.ToByteString().ToBase64(); suspensionState[nameof(CurrentCaptureAward)] = CurrentCaptureAward.ToByteString().ToBase64(); suspensionState[nameof(SelectedCaptureItem)] = SelectedCaptureItem.ToByteString().ToBase64(); } diff --git a/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs b/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs index 4729dd586..5ac4daa7f 100644 --- a/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs @@ -59,11 +59,13 @@ public GameMapPageViewModel() private void GameClient_OnAppliedItemExpired(object sender, AppliedItemWrapper e) { + RaisePropertyChanged("IsIncenseActive"); AppliedItemExpired?.Invoke(null, e); } private void GameClient_OnAppliedItemStarted(object sender, AppliedItemWrapper e) { + RaisePropertyChanged("IsIncenseActive"); AppliedItemStarted?.Invoke(null, e); } @@ -220,6 +222,8 @@ public LevelUpRewardsResponse LevelUpResponse /// public static ObservableCollection AppliedItems => GameClient.AppliedItems; + public static bool IsIncenseActive => GameClient.IsIncenseActive; + /// /// Collection of Pokemon in 1 step from current position /// diff --git a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs index c50da34bd..e1207da51 100644 --- a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs @@ -158,20 +158,23 @@ public DelegateCommand ReturnToGameScreen dialog.AcceptInvoked += async (sender, e) => { //// Send use request - //var res = await GameClient.UseIncense(item.ItemId); - var res = GetFakeIncenseResponse(item.ItemId); + var res = await GameClient.UseIncense(item.ItemId); switch (res.Result) { case UseIncenseResponse.Types.Result.Success: GameClient.AppliedItems.Add(new AppliedItemWrapper(res.AppliedIncense)); - await GameClient.UpdateInventory(); + SettingsService.Instance.IsIncenseActive = true; + SettingsService.Instance.IncenseAppliedMs = res.AppliedIncense.AppliedMs; + SettingsService.Instance.IncenseExpireMs = res.AppliedIncense.ExpireMs; + SettingsService.Instance.IncenseItemId = res.AppliedIncense.ItemId; + ReturnToGameScreen.Execute(); break; case UseIncenseResponse.Types.Result.IncenseAlreadyActive: + SettingsService.Instance.IsIncenseActive = true; + ReturnToGameScreen.Execute(); break; case UseIncenseResponse.Types.Result.LocationUnset: - break; case UseIncenseResponse.Types.Result.NoneInInventory: - break; case UseIncenseResponse.Types.Result.Unknown: break; default: @@ -192,23 +195,24 @@ public DelegateCommand ReturnToGameScreen dialog.AcceptInvoked += async (sender, e) => { // Send use request - //var res = await GameClient.UseXpBoost(item.ItemId); - var res = GetFakeXpBoostResponse(item.ItemId); + var res = await GameClient.UseXpBoost(item.ItemId); switch (res.Result) { case UseItemXpBoostResponse.Types.Result.Success: AppliedItem appliedItem = res.AppliedItems.Item.FirstOrDefault(); GameClient.AppliedItems.Add(new AppliedItemWrapper(appliedItem)); - await GameClient.UpdateInventory(); + SettingsService.Instance.IsXpBoostActive = true; + SettingsService.Instance.XpBoostAppliedMs = appliedItem.AppliedMs; + SettingsService.Instance.XpBoostExpireMs = appliedItem.ExpireMs; + ReturnToGameScreen.Execute(); break; case UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive: + SettingsService.Instance.IsXpBoostActive = true; + ReturnToGameScreen.Execute(); break; case UseItemXpBoostResponse.Types.Result.ErrorInvalidItemType: - break; case UseItemXpBoostResponse.Types.Result.ErrorLocationUnset: - break; case UseItemXpBoostResponse.Types.Result.ErrorNoItemsRemaining: - break; case UseItemXpBoostResponse.Types.Result.Unset: break; default: @@ -228,7 +232,7 @@ private UseIncenseResponse GetFakeIncenseResponse(POGOProtos.Inventory.Item.Item AppliedIncense = new AppliedItem { AppliedMs = DateTime.UtcNow.ToUnixTime(), - ExpireMs = DateTime.UtcNow.AddMinutes(10).ToUnixTime(), + ExpireMs = DateTime.UtcNow.AddMinutes(5).ToUnixTime(), ItemId = itemId, ItemType = POGOProtos.Inventory.Item.ItemType.Incense } @@ -240,7 +244,7 @@ private UseItemXpBoostResponse GetFakeXpBoostResponse(POGOProtos.Inventory.Item. AppliedItem appliedItem = new AppliedItem { AppliedMs = DateTime.UtcNow.ToUnixTime(), - ExpireMs = DateTime.UtcNow.AddMinutes(10).ToUnixTime(), + ExpireMs = DateTime.UtcNow.AddMinutes(5).ToUnixTime(), ItemId = itemId, ItemType = POGOProtos.Inventory.Item.ItemType.XpBoost }; diff --git a/PokemonGo-UWP/Views/GameMapPage.xaml b/PokemonGo-UWP/Views/GameMapPage.xaml index c039e3e1f..e6a625358 100644 --- a/PokemonGo-UWP/Views/GameMapPage.xaml +++ b/PokemonGo-UWP/Views/GameMapPage.xaml @@ -325,12 +325,12 @@ Canvas.ZIndex="1" x:Name="GameMapControl"> - + From 6011f3a5272344e78d6410949cbfe8acdc5a5af8 Mon Sep 17 00:00:00 2001 From: mtaheij Date: Tue, 20 Sep 2016 22:00:50 +0200 Subject: [PATCH 08/25] Inserted placeholders for using FakeIncense and FakeXpBoost --- PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs index e1207da51..67d8dc139 100644 --- a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs @@ -159,6 +159,7 @@ public DelegateCommand ReturnToGameScreen { //// Send use request var res = await GameClient.UseIncense(item.ItemId); + //var res = GetFakeIncenseResponse(item.ItemId); switch (res.Result) { case UseIncenseResponse.Types.Result.Success: @@ -196,6 +197,7 @@ public DelegateCommand ReturnToGameScreen { // Send use request var res = await GameClient.UseXpBoost(item.ItemId); + //var res = GetFakeXpBoostResponse(item.ItemId); switch (res.Result) { case UseItemXpBoostResponse.Types.Result.Success: From 4583d0f65dcec0166e3a3f025b57d51bee82f001 Mon Sep 17 00:00:00 2001 From: mtaheij Date: Tue, 20 Sep 2016 22:20:45 +0200 Subject: [PATCH 09/25] Removed code climate fail --- PokemonGo-UWP/Entities/IncensePokemon.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/PokemonGo-UWP/Entities/IncensePokemon.cs b/PokemonGo-UWP/Entities/IncensePokemon.cs index c00d21145..9c2e14010 100644 --- a/PokemonGo-UWP/Entities/IncensePokemon.cs +++ b/PokemonGo-UWP/Entities/IncensePokemon.cs @@ -28,9 +28,6 @@ public class IncensePokemon : IMapPokemon private GetIncensePokemonResponse _incensePokemonResponse; - /// - /// HACK - this should fix Pokestop floating on map - /// public Point Anchor => new Point(0.5, 1); public IncensePokemon(GetIncensePokemonResponse incensePokemonResponse, double lat, double lng) From 90c266e9c8ed58d221ca8f0fe6d365d9f9172362 Mon Sep 17 00:00:00 2001 From: Rover656 Date: Wed, 21 Sep 2016 17:18:23 +0100 Subject: [PATCH 10/25] Implement @swisszeni's fix for ItemClick hack --- PokemonGo-UWP/Views/ItemsInventoryPage.xaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PokemonGo-UWP/Views/ItemsInventoryPage.xaml b/PokemonGo-UWP/Views/ItemsInventoryPage.xaml index 3d5522901..dfc3fab87 100644 --- a/PokemonGo-UWP/Views/ItemsInventoryPage.xaml +++ b/PokemonGo-UWP/Views/ItemsInventoryPage.xaml @@ -112,7 +112,11 @@ Margin="8,0" Grid.Row="1" Padding="0,0,0,60"> - + + + + + - @@ -1123,7 +1123,7 @@ - + @@ -1335,6 +1335,7 @@ diff --git a/PokemonGo-UWP/Utils/Game/Converters.cs b/PokemonGo-UWP/Utils/Game/Converters.cs index d9103be16..1feecdf71 100644 --- a/PokemonGo-UWP/Utils/Game/Converters.cs +++ b/PokemonGo-UWP/Utils/Game/Converters.cs @@ -361,7 +361,31 @@ public object ConvertBack(object value, Type targetType, object parameter, strin #endregion } - public class PlayerTeamToTeamColorBrushConverter : IValueConverter + public class ItemToItemImageConverter : IValueConverter + { + #region Implementation of IValueConverter + + public object Convert(object value, Type targetType, object parameter, string language) + { + ItemId itemId = ItemId.ItemUnknown; + + if (value is ItemAward) itemId = (value as ItemAward).ItemId; + if (value is ItemData) itemId = (value as ItemData).ItemId; + if (value is ItemDataWrapper) itemId = (value as ItemDataWrapper).ItemId; + if (value is AppliedItemWrapper) itemId = (value as AppliedItemWrapper).ItemId; + + return new BitmapImage(new Uri($"ms-appx:///Assets/Items/Item_{(int)itemId}.png")); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } + + #endregion + } + + public class PlayerTeamToTeamColorBrushConverter : IValueConverter { #region Implementation of IValueConverter @@ -834,7 +858,7 @@ public object Convert(object value, Type targetType, object parameter, string la { if (appliedItem.ItemId == ((ItemDataWrapper)value).ItemId) { - return false; + return 0.5; } } return useableList.Contains(((ItemDataWrapper)value).ItemId) ? 1 : 0.5; diff --git a/PokemonGo-UWP/Utils/GameClient.cs b/PokemonGo-UWP/Utils/GameClient.cs index 5de9144c7..d211755c0 100644 --- a/PokemonGo-UWP/Utils/GameClient.cs +++ b/PokemonGo-UWP/Utils/GameClient.cs @@ -248,6 +248,23 @@ public static bool IsIncenseActive } } + public static bool IsXpBoostActive + { + get + { + bool foundActiveXpBoost = false; + foreach (AppliedItemWrapper appliedItem in AppliedItems) + { + if (appliedItem.ItemType == ItemType.XpBoost && !appliedItem.IsExpired) + { + foundActiveXpBoost = true; + break; + } + } + return foundActiveXpBoost; + } + } + #region Collections /// diff --git a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs index 67d8dc139..33ef65c24 100644 --- a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs @@ -150,79 +150,85 @@ public DelegateCommand ReturnToGameScreen item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncenseFloral || item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncenseCool) { - var dialog = new PoGoMessageDialog("", string.Format(Resources.CodeResources.GetString("ItemUseQuestionText"), Resources.Items.GetString(item.ItemId.ToString()))); - dialog.AcceptText = Resources.CodeResources.GetString("YesText"); - dialog.CancelText = Resources.CodeResources.GetString("CancelText"); - dialog.CoverBackground = true; - dialog.AnimationType = PoGoMessageDialogAnimation.Bottom; - dialog.AcceptInvoked += async (sender, e) => + if (!GameClient.IsIncenseActive) { - //// Send use request - var res = await GameClient.UseIncense(item.ItemId); - //var res = GetFakeIncenseResponse(item.ItemId); - switch (res.Result) + var dialog = new PoGoMessageDialog("", string.Format(Resources.CodeResources.GetString("ItemUseQuestionText"), Resources.Items.GetString(item.ItemId.ToString()))); + dialog.AcceptText = Resources.CodeResources.GetString("YesText"); + dialog.CancelText = Resources.CodeResources.GetString("CancelText"); + dialog.CoverBackground = true; + dialog.AnimationType = PoGoMessageDialogAnimation.Bottom; + dialog.AcceptInvoked += async (sender, e) => { - case UseIncenseResponse.Types.Result.Success: - GameClient.AppliedItems.Add(new AppliedItemWrapper(res.AppliedIncense)); - SettingsService.Instance.IsIncenseActive = true; - SettingsService.Instance.IncenseAppliedMs = res.AppliedIncense.AppliedMs; - SettingsService.Instance.IncenseExpireMs = res.AppliedIncense.ExpireMs; - SettingsService.Instance.IncenseItemId = res.AppliedIncense.ItemId; - ReturnToGameScreen.Execute(); - break; - case UseIncenseResponse.Types.Result.IncenseAlreadyActive: - SettingsService.Instance.IsIncenseActive = true; - ReturnToGameScreen.Execute(); - break; - case UseIncenseResponse.Types.Result.LocationUnset: - case UseIncenseResponse.Types.Result.NoneInInventory: - case UseIncenseResponse.Types.Result.Unknown: - break; - default: - throw new ArgumentOutOfRangeException(); - } - }; - - dialog.Show(); + //// Send use request + var res = await GameClient.UseIncense(item.ItemId); + //var res = GetFakeIncenseResponse(item.ItemId); + switch (res.Result) + { + case UseIncenseResponse.Types.Result.Success: + GameClient.AppliedItems.Add(new AppliedItemWrapper(res.AppliedIncense)); + SettingsService.Instance.IsIncenseActive = true; + SettingsService.Instance.IncenseAppliedMs = res.AppliedIncense.AppliedMs; + SettingsService.Instance.IncenseExpireMs = res.AppliedIncense.ExpireMs; + SettingsService.Instance.IncenseItemId = res.AppliedIncense.ItemId; + ReturnToGameScreen.Execute(); + break; + case UseIncenseResponse.Types.Result.IncenseAlreadyActive: + SettingsService.Instance.IsIncenseActive = true; + ReturnToGameScreen.Execute(); + break; + case UseIncenseResponse.Types.Result.LocationUnset: + case UseIncenseResponse.Types.Result.NoneInInventory: + case UseIncenseResponse.Types.Result.Unknown: + break; + default: + throw new ArgumentOutOfRangeException(); + } + }; + + dialog.Show(); + } } if (item.ItemId == POGOProtos.Inventory.Item.ItemId.ItemLuckyEgg) { - var dialog = new PoGoMessageDialog("", string.Format(Resources.CodeResources.GetString("ItemUseQuestionText"), Resources.Items.GetString(item.ItemId.ToString()))); - dialog.AcceptText = Resources.CodeResources.GetString("YesText"); - dialog.CancelText = Resources.CodeResources.GetString("CancelText"); - dialog.CoverBackground = true; - dialog.AnimationType = PoGoMessageDialogAnimation.Bottom; - dialog.AcceptInvoked += async (sender, e) => + if (!GameClient.IsXpBoostActive) { - // Send use request - var res = await GameClient.UseXpBoost(item.ItemId); - //var res = GetFakeXpBoostResponse(item.ItemId); - switch (res.Result) + var dialog = new PoGoMessageDialog("", string.Format(Resources.CodeResources.GetString("ItemUseQuestionText"), Resources.Items.GetString(item.ItemId.ToString()))); + dialog.AcceptText = Resources.CodeResources.GetString("YesText"); + dialog.CancelText = Resources.CodeResources.GetString("CancelText"); + dialog.CoverBackground = true; + dialog.AnimationType = PoGoMessageDialogAnimation.Bottom; + dialog.AcceptInvoked += async (sender, e) => { - case UseItemXpBoostResponse.Types.Result.Success: - AppliedItem appliedItem = res.AppliedItems.Item.FirstOrDefault(); - GameClient.AppliedItems.Add(new AppliedItemWrapper(appliedItem)); - SettingsService.Instance.IsXpBoostActive = true; - SettingsService.Instance.XpBoostAppliedMs = appliedItem.AppliedMs; - SettingsService.Instance.XpBoostExpireMs = appliedItem.ExpireMs; - ReturnToGameScreen.Execute(); - break; - case UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive: - SettingsService.Instance.IsXpBoostActive = true; - ReturnToGameScreen.Execute(); - break; - case UseItemXpBoostResponse.Types.Result.ErrorInvalidItemType: - case UseItemXpBoostResponse.Types.Result.ErrorLocationUnset: - case UseItemXpBoostResponse.Types.Result.ErrorNoItemsRemaining: - case UseItemXpBoostResponse.Types.Result.Unset: - break; - default: - throw new ArgumentOutOfRangeException(); - } - }; - - dialog.Show(); + // Send use request + var res = await GameClient.UseXpBoost(item.ItemId); + //var res = GetFakeXpBoostResponse(item.ItemId); + switch (res.Result) + { + case UseItemXpBoostResponse.Types.Result.Success: + AppliedItem appliedItem = res.AppliedItems.Item.FirstOrDefault(); + GameClient.AppliedItems.Add(new AppliedItemWrapper(appliedItem)); + SettingsService.Instance.IsXpBoostActive = true; + SettingsService.Instance.XpBoostAppliedMs = appliedItem.AppliedMs; + SettingsService.Instance.XpBoostExpireMs = appliedItem.ExpireMs; + ReturnToGameScreen.Execute(); + break; + case UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive: + SettingsService.Instance.IsXpBoostActive = true; + ReturnToGameScreen.Execute(); + break; + case UseItemXpBoostResponse.Types.Result.ErrorInvalidItemType: + case UseItemXpBoostResponse.Types.Result.ErrorLocationUnset: + case UseItemXpBoostResponse.Types.Result.ErrorNoItemsRemaining: + case UseItemXpBoostResponse.Types.Result.Unset: + break; + default: + throw new ArgumentOutOfRangeException(); + } + }; + + dialog.Show(); + } } }, (ItemDataWrapper item) => true)); diff --git a/PokemonGo-UWP/Views/GameMapPage.xaml b/PokemonGo-UWP/Views/GameMapPage.xaml index e6a625358..233597a72 100644 --- a/PokemonGo-UWP/Views/GameMapPage.xaml +++ b/PokemonGo-UWP/Views/GameMapPage.xaml @@ -767,7 +767,8 @@ RelativePanel.AlignTopWithPanel="True" Margin="0,12,0,0" Canvas.ZIndex="10" - SelectionMode="Single"> + IsItemClickEnabled="False" + SelectionMode="None"> + + diff --git a/PokemonGo-UWP/Utils/GameClient.cs b/PokemonGo-UWP/Utils/GameClient.cs index d211755c0..760b69289 100644 --- a/PokemonGo-UWP/Utils/GameClient.cs +++ b/PokemonGo-UWP/Utils/GameClient.cs @@ -418,21 +418,6 @@ private static void AppliedItems_CollectionChanged(object sender, NotifyCollecti } else if (e.Action == NotifyCollectionChangedAction.Remove) { - AppliedItemWrapper appliedItemWrapper = e.OldItems[0] as AppliedItemWrapper; - if (appliedItemWrapper.ItemType == ItemType.Incense) - { - SettingsService.Instance.IsIncenseActive = false; - SettingsService.Instance.IncenseAppliedMs = 0; - SettingsService.Instance.IncenseExpireMs = 0; - SettingsService.Instance.IncenseItemId = ItemId.ItemUnknown; - } - else if (appliedItemWrapper.ItemType == ItemType.XpBoost) - { - SettingsService.Instance.IsXpBoostActive = false; - SettingsService.Instance.XpBoostAppliedMs = 0; - SettingsService.Instance.XpBoostExpireMs = 0; - } - OnAppliedItemExpired?.Invoke(null, (AppliedItemWrapper)e.OldItems[0]); } } @@ -504,30 +489,6 @@ public static async Task InitializeClient() await new MessageDialog(e.Message).ShowAsyncQueue(); } } - - if (SettingsService.Instance.IsIncenseActive) - { - AppliedItem incenseItem = new AppliedItem - { - AppliedMs = SettingsService.Instance.IncenseAppliedMs, - ExpireMs = SettingsService.Instance.IncenseExpireMs, - ItemId = SettingsService.Instance.IncenseItemId, - ItemType = ItemType.Incense - }; - AppliedItems.Add(new AppliedItemWrapper(incenseItem)); - } - - if (SettingsService.Instance.IsXpBoostActive) - { - AppliedItem xpboostItem = new AppliedItem - { - AppliedMs = SettingsService.Instance.XpBoostAppliedMs, - ExpireMs = SettingsService.Instance.XpBoostExpireMs, - ItemId = ItemId.ItemLuckyEgg, - ItemType = ItemType.XpBoost - }; - AppliedItems.Add(new AppliedItemWrapper(xpboostItem)); - } } /// @@ -999,9 +960,14 @@ public static async Task UpdateInventory() item.InventoryItemData.Item != null && CatchItemIds.Contains(item.InventoryItemData.Item.ItemId)) .GroupBy(item => item.InventoryItemData.Item) .Select(item => item.First().InventoryItemData.Item), true); - - // Update incbuators - FreeIncubatorsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.EggIncubators != null) + AppliedItems.AddRange( + fullInventory + .Where(item => item.InventoryItemData.AppliedItems != null) + .SelectMany(item => item.InventoryItemData.AppliedItems.Item) + .Select(item => new AppliedItemWrapper(item)), true); + + // Update incbuators + FreeIncubatorsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.EggIncubators != null) .SelectMany(item => item.InventoryItemData.EggIncubators.EggIncubator) .Where(item => item != null && item.PokemonId == 0), true); UsedIncubatorsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.EggIncubators != null) diff --git a/PokemonGo-UWP/Utils/Settings/SettingsService.cs b/PokemonGo-UWP/Utils/Settings/SettingsService.cs index c8039b30f..a60de2f00 100644 --- a/PokemonGo-UWP/Utils/Settings/SettingsService.cs +++ b/PokemonGo-UWP/Utils/Settings/SettingsService.cs @@ -6,8 +6,6 @@ using System; using Template10.Mvvm; using System.Runtime.CompilerServices; -using POGOProtos.Inventory.Item; -using PokemonGo.RocketAPI.Extensions; namespace PokemonGo_UWP.Utils { @@ -167,48 +165,6 @@ public double Zoomlevel get { return Get(12D); } set { Set(value); } } - - public bool IsIncenseActive - { - get { return Get(false); } - set { Set(value); } - } - - public long IncenseAppliedMs - { - get { return Get(DateTime.UtcNow.ToUnixTime()); } - set { Set(value); } - } - - public long IncenseExpireMs - { - get { return Get(DateTime.UtcNow.ToUnixTime()); } - set { Set(value); } - } - - public ItemId IncenseItemId - { - get { return Get(ItemId.ItemIncenseOrdinary); } - set { Set(value); } - } - - public bool IsXpBoostActive - { - get { return Get(false); } - set { Set(value); } - } - - public long XpBoostAppliedMs - { - get { return Get(DateTime.UtcNow.ToUnixTime()); } - set { Set(value); } - } - - public long XpBoostExpireMs - { - get { return Get(DateTime.UtcNow.ToUnixTime()); } - set { Set(value); } - } #endregion #region Dev Stuff diff --git a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs index 33ef65c24..777d21a05 100644 --- a/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/ItemsInventoryPageViewModel.cs @@ -166,14 +166,9 @@ public DelegateCommand ReturnToGameScreen { case UseIncenseResponse.Types.Result.Success: GameClient.AppliedItems.Add(new AppliedItemWrapper(res.AppliedIncense)); - SettingsService.Instance.IsIncenseActive = true; - SettingsService.Instance.IncenseAppliedMs = res.AppliedIncense.AppliedMs; - SettingsService.Instance.IncenseExpireMs = res.AppliedIncense.ExpireMs; - SettingsService.Instance.IncenseItemId = res.AppliedIncense.ItemId; ReturnToGameScreen.Execute(); break; case UseIncenseResponse.Types.Result.IncenseAlreadyActive: - SettingsService.Instance.IsIncenseActive = true; ReturnToGameScreen.Execute(); break; case UseIncenseResponse.Types.Result.LocationUnset: @@ -208,13 +203,9 @@ public DelegateCommand ReturnToGameScreen case UseItemXpBoostResponse.Types.Result.Success: AppliedItem appliedItem = res.AppliedItems.Item.FirstOrDefault(); GameClient.AppliedItems.Add(new AppliedItemWrapper(appliedItem)); - SettingsService.Instance.IsXpBoostActive = true; - SettingsService.Instance.XpBoostAppliedMs = appliedItem.AppliedMs; - SettingsService.Instance.XpBoostExpireMs = appliedItem.ExpireMs; ReturnToGameScreen.Execute(); break; case UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive: - SettingsService.Instance.IsXpBoostActive = true; ReturnToGameScreen.Execute(); break; case UseItemXpBoostResponse.Types.Result.ErrorInvalidItemType: diff --git a/PokemonGo-UWP/Views/SearchPokestopPage.xaml b/PokemonGo-UWP/Views/SearchPokestopPage.xaml index caa830892..c6066cd23 100644 --- a/PokemonGo-UWP/Views/SearchPokestopPage.xaml +++ b/PokemonGo-UWP/Views/SearchPokestopPage.xaml @@ -237,15 +237,14 @@ From c174ef84c15285627f68f7791c99dfb48eeb3ffe Mon Sep 17 00:00:00 2001 From: mtaheij Date: Fri, 23 Sep 2016 10:00:59 +0200 Subject: [PATCH 15/25] Removed unused styles, converters and methods --- PokemonGo-UWP/Styles/Custom.xaml | 86 +------------------ PokemonGo-UWP/Utils/Game/Converters.cs | 41 --------- .../ViewModels/ItemsInventoryPageViewModel.cs | 35 -------- PokemonGo-UWP/Views/ItemsInventoryPage.xaml | 2 - 4 files changed, 1 insertion(+), 163 deletions(-) diff --git a/PokemonGo-UWP/Styles/Custom.xaml b/PokemonGo-UWP/Styles/Custom.xaml index e63395338..85078b396 100644 --- a/PokemonGo-UWP/Styles/Custom.xaml +++ b/PokemonGo-UWP/Styles/Custom.xaml @@ -832,68 +832,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + public sealed partial class GameMapPage : Page - { + { private Geopoint lastAutoPosition; private Button ReactivateMapAutoUpdateButton; @@ -48,11 +48,11 @@ public GameMapPage() // Add reactivate map update button if (ReactivateMapAutoUpdateButton != null) return; - #region Reactivate Map AutoUpdate Button - ReactivateMapAutoUpdateButton = new Button + #region Reactivate Map AutoUpdate Button + ReactivateMapAutoUpdateButton = new Button { Visibility = Visibility.Collapsed, - Style = (Style) BootStrapper.Current.Resources["ImageButtonStyle"], + Style = (Style)BootStrapper.Current.Resources["ImageButtonStyle"], Height = 44, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, @@ -60,11 +60,11 @@ public GameMapPage() Content = new Image { Source = - new BitmapImage - { - UriSource = - new Uri($"ms-appx:///Assets/Icons/RecenterMapIcon{ViewModel.CurrentTheme}.png") - }, + new BitmapImage + { + UriSource = + new Uri($"ms-appx:///Assets/Icons/RecenterMapIcon{ViewModel.CurrentTheme}.png") + }, Stretch = Stretch.Uniform, Height = 36, HorizontalAlignment = HorizontalAlignment.Center, @@ -79,36 +79,36 @@ public GameMapPage() VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(GameMapControl, 0), 1), 0), 0); tsp.Children.Add(ReactivateMapAutoUpdateButton); - #endregion - #region Map Style button ;) - if (GameMapControl.Is3DSupported) - { - var MapStyleButton = new Button - { - Style = (Style)BootStrapper.Current.Resources["ImageButtonStyle"], - Height = 44, - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(0, 0, 0, 34), - Content = new Image - { - Source = - new BitmapImage - { - UriSource = - new Uri($"ms-appx:///Assets/Teams/no-team.png") - }, - Stretch = Stretch.Uniform, - Height = 36, - HorizontalAlignment = HorizontalAlignment.Stretch - } - }; - MapStyleButton.Tapped += MapStyleButton_Tapped; - - tsp.Children.Add(MapStyleButton); - } - #endregion - DisplayInformation.GetForCurrentView().OrientationChanged += GameMapPage_OrientationChanged; + #endregion + #region Map Style button ;) + if (GameMapControl.Is3DSupported) + { + var MapStyleButton = new Button + { + Style = (Style)BootStrapper.Current.Resources["ImageButtonStyle"], + Height = 44, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(0, 0, 0, 34), + Content = new Image + { + Source = + new BitmapImage + { + UriSource = + new Uri($"ms-appx:///Assets/Teams/no-team.png") + }, + Stretch = Stretch.Uniform, + Height = 36, + HorizontalAlignment = HorizontalAlignment.Stretch + } + }; + MapStyleButton.Tapped += MapStyleButton_Tapped; + + tsp.Children.Add(MapStyleButton); + } + #endregion + DisplayInformation.GetForCurrentView().OrientationChanged += GameMapPage_OrientationChanged; }; } @@ -179,9 +179,9 @@ private async void ReactivateMapAutoUpdate_Tapped(object sender, TappedRoutedEve { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { - lastAutoPosition = null; - await UpdateMap(); - }); + lastAutoPosition = null; + await UpdateMap(); + }); } private void GameMapControl_TargetCameraChanged(MapControl sender, MapTargetCameraChangedEventArgs args) @@ -200,44 +200,44 @@ private void GameMapControl_OnZoomLevelChanged(MapControl sender, object args) protected override async void OnNavigatedTo(NavigationEventArgs e) { - try - { - base.OnNavigatedTo(e); - // Hide PokeMenu panel just in case - HidePokeMenuStoryboard.Begin(); - // See if we need to update the map - if ((e.Parameter != null) && (e.NavigationMode != NavigationMode.Back)) + try { - GameMapNavigationModes mode = - ((JObject) JsonConvert.DeserializeObject((string) e.Parameter)).Last - .ToObject(); - if ((mode == GameMapNavigationModes.AppStart) || (mode == GameMapNavigationModes.SettingsUpdate)) - SetupMap(); - } - // Set first position if we shomehow missed it + base.OnNavigatedTo(e); + // Hide PokeMenu panel just in case + HidePokeMenuStoryboard.Begin(); + // See if we need to update the map + if ((e.Parameter != null) && (e.NavigationMode != NavigationMode.Back)) + { + GameMapNavigationModes mode = + ((JObject)JsonConvert.DeserializeObject((string)e.Parameter)).Last + .ToObject(); + if ((mode == GameMapNavigationModes.AppStart) || (mode == GameMapNavigationModes.SettingsUpdate)) + SetupMap(); + } + // Set first position if we shomehow missed it await UpdateMap(); - //Changed order of calls, this allow to have events registration before trying to move map - //appears that for some reason TryRotate and/or TryTilt fails sometimes! - SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; - SubscribeToCaptureEvents(); - - } - catch (Exception ex) - { - //because we are in "async void" unhandled exception might not be raised - await ExceptionHandler.HandleException(ex); - } - try - { - await GameMapControl.TryRotateToAsync(SettingsService.Instance.MapHeading); - await GameMapControl.TryTiltToAsync(SettingsService.Instance.MapPitch); - } - catch - { - //we don't care :) - } - - } + //Changed order of calls, this allow to have events registration before trying to move map + //appears that for some reason TryRotate and/or TryTilt fails sometimes! + SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; + SubscribeToCaptureEvents(); + + } + catch (Exception ex) + { + //because we are in "async void" unhandled exception might not be raised + await ExceptionHandler.HandleException(ex); + } + try + { + await GameMapControl.TryRotateToAsync(SettingsService.Instance.MapHeading); + await GameMapControl.TryTiltToAsync(SettingsService.Instance.MapPitch); + } + catch + { + //we don't care :) + } + + } private void OnBackRequested(object sender, BackRequestedEventArgs backRequestedEventArgs) { @@ -253,11 +253,11 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) SystemNavigationManager.GetForCurrentView().BackRequested -= OnBackRequested; if (SettingsService.Instance.IsRememberMapZoomEnabled) SaveZoomLevel(); - SettingsService.Instance.MapPitch = GameMapControl.Pitch; - SettingsService.Instance.MapHeading = GameMapControl.Heading; - } + SettingsService.Instance.MapPitch = GameMapControl.Pitch; + SettingsService.Instance.MapHeading = GameMapControl.Heading; + } - private void SaveZoomLevel() + private void SaveZoomLevel() { // Bug fix for Issue 586 if ((SettingsService.Instance.Zoomlevel == 0) || (GameMapControl.ZoomLevel == 0)) @@ -278,24 +278,24 @@ private void SaveZoomLevel() private async Task UpdateMap() { - if (LocationServiceHelper.Instance.Geoposition != null) - { - await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => + if (LocationServiceHelper.Instance.Geoposition != null) + { + await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { - try - { - // Set player icon's position - MapControl.SetLocation(PlayerImage, LocationServiceHelper.Instance.Geoposition.Coordinate.Point); + try + { + // Set player icon's position + MapControl.SetLocation(PlayerImage, LocationServiceHelper.Instance.Geoposition.Coordinate.Point); // Update angle and center only if map is not being manipulated if (lastAutoPosition == null) { - //Reset of position or first run - //Save Center + //Reset of position or first run + //Save Center lastAutoPosition = GameMapControl.Center; - //Reset orientation to default + //Reset orientation to default if (double.IsNaN(GameMapControl.Heading))//DarkAngel: I love non nullable double that can be "!= null and not a number"... - await GameMapControl.TryRotateToAsync(0); + await GameMapControl.TryRotateToAsync(0); } //Small Trick: I'm not testing lastAutoPosition == GameMapControl.Center because MapControl is not taking exact location when setting center!! @@ -306,32 +306,32 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => if (currentCoord == previousCoord && ReactivateMapAutoUpdateButton != null) { //Previous position was set automatically, continue! - ReactivateMapAutoUpdateButton.Visibility = Visibility.Collapsed; - GameMapControl.Center = LocationServiceHelper.Instance.Geoposition.Coordinate.Point; + ReactivateMapAutoUpdateButton.Visibility = Visibility.Collapsed; + GameMapControl.Center = LocationServiceHelper.Instance.Geoposition.Coordinate.Point; lastAutoPosition = GameMapControl.Center; if ((SettingsService.Instance.MapAutomaticOrientationMode == MapAutomaticOrientationModes.GPS) && - ( - LocationServiceHelper.Instance.Geoposition.Coordinate.Heading.GetValueOrDefault(-1) >= 0 - && LocationServiceHelper.Instance.Geoposition.Coordinate.Heading.GetValueOrDefault(-1) <= 360 - )) - await GameMapControl.TryRotateToAsync(LocationServiceHelper.Instance.Geoposition.Coordinate.Heading.GetValueOrDefault(GameMapControl.Heading)); + ( + LocationServiceHelper.Instance.Geoposition.Coordinate.Heading.GetValueOrDefault(-1) >= 0 + && LocationServiceHelper.Instance.Geoposition.Coordinate.Heading.GetValueOrDefault(-1) <= 360 + )) + await GameMapControl.TryRotateToAsync(LocationServiceHelper.Instance.Geoposition.Coordinate.Heading.GetValueOrDefault(GameMapControl.Heading)); if (SettingsService.Instance.IsRememberMapZoomEnabled) GameMapControl.ZoomLevel = SettingsService.Instance.Zoomlevel; } - } - catch (Exception ex) - { - await ExceptionHandler.HandleException(ex); - } - }); - } - } + } + catch (Exception ex) + { + await ExceptionHandler.HandleException(ex); + } + }); + } + } private void SubscribeToCaptureEvents() { - LocationServiceHelper.Instance.PropertyChanged += LocationHelperPropertyChanged; + LocationServiceHelper.Instance.PropertyChanged += LocationHelperPropertyChanged; GameClient.HeadingUpdated += HeadingUpdated; ViewModel.LevelUpRewardsAwarded += ViewModelOnLevelUpRewardsAwarded; ViewModel.AppliedItemExpired += ViewModelOnAppliedItemExpired; @@ -354,18 +354,18 @@ private async void HeadingUpdated(object sender, CompassReading e) private void UnsubscribeToCaptureEvents() { - LocationServiceHelper.Instance.PropertyChanged -= LocationHelperPropertyChanged; + LocationServiceHelper.Instance.PropertyChanged -= LocationHelperPropertyChanged; GameClient.HeadingUpdated -= HeadingUpdated; ViewModel.LevelUpRewardsAwarded -= ViewModelOnLevelUpRewardsAwarded; } - private async void LocationHelperPropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName == nameof(LocationServiceHelper.Instance.Geoposition)) - { - await UpdateMap(); - } - } + private async void LocationHelperPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(LocationServiceHelper.Instance.Geoposition)) + { + await UpdateMap(); + } + } private void ViewModelOnLevelUpRewardsAwarded(object sender, EventArgs eventArgs) { @@ -374,45 +374,45 @@ private void ViewModelOnLevelUpRewardsAwarded(object sender, EventArgs eventArgs ShowLevelUpPanelStoryboard.Begin(); } - #endregion - private async void MapStyleButton_Tapped(object sender, TappedRoutedEventArgs e) - { - if (GameMapControl.Is3DSupported) - { - switch (GameMapControl.Style) - { - case MapStyle.None: - GameMapControl.Style = MapStyle.Road; - break; - case MapStyle.Road: - GameMapControl.Style = MapStyle.Aerial3DWithRoads; - break; - case MapStyle.Aerial: - case MapStyle.AerialWithRoads: - case MapStyle.Terrain: - case MapStyle.Aerial3D: - case MapStyle.Aerial3DWithRoads: - GameMapControl.Style = MapStyle.Road; - break; - default: - GameMapControl.Style = MapStyle.Road; - break; - } - } - else - { - await new Windows.UI.Popups.MessageDialog("Sorry 3DView is not supported!").ShowAsyncQueue(); - } - } - - private void ViewModelOnAppliedItemExpired(object sender, AppliedItemWrapper AppliedItem) - { - HideAppliedItemStoryboard.Begin(); - } - - private void ViewModelOnAppliedItemStarted(object sender, AppliedItemWrapper AppliedItem) - { - ShowAppliedItemStoryboard.Begin(); - } - } + #endregion + private async void MapStyleButton_Tapped(object sender, TappedRoutedEventArgs e) + { + if (GameMapControl.Is3DSupported) + { + switch (GameMapControl.Style) + { + case MapStyle.None: + GameMapControl.Style = MapStyle.Road; + break; + case MapStyle.Road: + GameMapControl.Style = MapStyle.Aerial3DWithRoads; + break; + case MapStyle.Aerial: + case MapStyle.AerialWithRoads: + case MapStyle.Terrain: + case MapStyle.Aerial3D: + case MapStyle.Aerial3DWithRoads: + GameMapControl.Style = MapStyle.Road; + break; + default: + GameMapControl.Style = MapStyle.Road; + break; + } + } + else + { + await new Windows.UI.Popups.MessageDialog("Sorry 3DView is not supported!").ShowAsyncQueue(); + } + } + + private void ViewModelOnAppliedItemExpired(object sender, AppliedItemWrapper AppliedItem) + { + HideAppliedItemStoryboard.Begin(); + } + + private void ViewModelOnAppliedItemStarted(object sender, AppliedItemWrapper AppliedItem) + { + ShowAppliedItemStoryboard.Begin(); + } + } } \ No newline at end of file diff --git a/PokemonGo-UWP/Views/PlayerProfilePage.xaml b/PokemonGo-UWP/Views/PlayerProfilePage.xaml index eb311d604..991073925 100644 --- a/PokemonGo-UWP/Views/PlayerProfilePage.xaml +++ b/PokemonGo-UWP/Views/PlayerProfilePage.xaml @@ -314,14 +314,18 @@ - + Date: Mon, 26 Sep 2016 15:37:58 +0200 Subject: [PATCH 21/25] Fixing UI and crashing bugs --- .../ViewModels/PokemonDetailPageViewModel.cs | 28 +++++++++++++------ .../Views/Pokemon/EggDetailControl.xaml.cs | 7 +---- .../Views/Pokemon/EggInventoryControl.xaml | 2 +- .../Pokemon/PokemonInventoryControl.xaml | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs b/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs index 4f5fcedf4..4a3a95a93 100644 --- a/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs @@ -330,14 +330,16 @@ public bool PlayerTeamIsSet { ServerRequestRunning = true; var isFavorite = Convert.ToBoolean(SelectedPokemon.Favorite); - var pokemonFavoriteResponse = await GameClient.SetFavoritePokemon(SelectedPokemon.Id, !isFavorite); + // Use local var to prevent bug when changing selected pokemon during running request + var favoritingPokemon = SelectedPokemon; + var pokemonFavoriteResponse = await GameClient.SetFavoritePokemon(favoritingPokemon.Id, !isFavorite); switch (pokemonFavoriteResponse.Result) { case SetFavoritePokemonResponse.Types.Result.Unset: break; case SetFavoritePokemonResponse.Types.Result.Success: // Inverse favorite state - SelectedPokemon.Favorite = Convert.ToInt32(!isFavorite); + favoritingPokemon.Favorite = Convert.ToInt32(!isFavorite); break; case SetFavoritePokemonResponse.Types.Result.ErrorPokemonNotFound: break; @@ -384,14 +386,17 @@ public bool PlayerTeamIsSet try { ServerRequestRunning = true; + // Use local var to prevent bug when changing selected pokemon during running request + var renamingPokemon = SelectedPokemon; + var nickname = textbox.Text; // Send rename request - var res = await GameClient.SetPokemonNickName((ulong)SelectedPokemon.Id, textbox.Text); + var res = await GameClient.SetPokemonNickName((ulong)renamingPokemon.Id, nickname); switch (res.Result) { case NicknamePokemonResponse.Types.Result.Unset: break; case NicknamePokemonResponse.Types.Result.Success: - SelectedPokemon.Nickname = textbox.Text; + renamingPokemon.Nickname = nickname; break; case NicknamePokemonResponse.Types.Result.ErrorPokemonNotFound: break; @@ -432,20 +437,27 @@ public bool PlayerTeamIsSet try { ServerRequestRunning = true; + // Use local var to prevent bug when changing selected pokemon during running request + var uppingPokemon = SelectedPokemon; // Send power up request - var res = await GameClient.PowerUpPokemon(SelectedPokemon.WrappedData); + var res = await GameClient.PowerUpPokemon(uppingPokemon.WrappedData); switch (res.Result) { case UpgradePokemonResponse.Types.Result.Unset: break; case UpgradePokemonResponse.Types.Result.Success: // Reload updated data - PokemonInventory.Remove(SelectedPokemon); + bool stillSowingUppingPokemon = uppingPokemon == SelectedPokemon; + PokemonInventory.Remove(uppingPokemon); var uppedPokemon = new PokemonDataWrapper(res.UpgradedPokemon); PokemonInventory.Add(uppedPokemon); PokemonInventory.SortBySortingmode(SortingMode); - SelectedPokemon = uppedPokemon; - RaisePropertyChanged(nameof(SelectedPokemon)); + // If the upping pokemon is still showing (not fliped to other), change selected to upped + if(stillSowingUppingPokemon) + { + SelectedPokemon = uppedPokemon; + RaisePropertyChanged(nameof(SelectedPokemon)); + } await GameClient.UpdateInventory(); await GameClient.UpdateProfile(); break; diff --git a/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs b/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs index 42a51ad37..1e815713a 100644 --- a/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs +++ b/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs @@ -26,15 +26,10 @@ public EggDetailControl() private void ShowIncubatorSelection_Click(object sender, RoutedEventArgs e) { IncubatorSelectionOverlayControl incubatorControl = new IncubatorSelectionOverlayControl(); - incubatorControl.IncubatorSelected += IncubatorControl_IncubatorSelected; + incubatorControl.IncubatorSelected += (incubator) => { IncubateEggCommand.Execute(incubator); }; incubatorControl.Show(); } - private void IncubatorControl_IncubatorSelected(POGOProtos.Inventory.EggIncubator incubator) - { - IncubateEggCommand.Execute(incubator); - } - #region Dependency Propertys public static readonly DependencyProperty IncubateEggCommandProperty = diff --git a/PokemonGo-UWP/Views/Pokemon/EggInventoryControl.xaml b/PokemonGo-UWP/Views/Pokemon/EggInventoryControl.xaml index 95c1289e7..fb172ba8e 100644 --- a/PokemonGo-UWP/Views/Pokemon/EggInventoryControl.xaml +++ b/PokemonGo-UWP/Views/Pokemon/EggInventoryControl.xaml @@ -54,7 +54,7 @@ - + diff --git a/PokemonGo-UWP/Views/Pokemon/PokemonInventoryControl.xaml b/PokemonGo-UWP/Views/Pokemon/PokemonInventoryControl.xaml index ed802dede..fa065f540 100644 --- a/PokemonGo-UWP/Views/Pokemon/PokemonInventoryControl.xaml +++ b/PokemonGo-UWP/Views/Pokemon/PokemonInventoryControl.xaml @@ -37,7 +37,7 @@ - + From b31b7452a28a75336d39b7ab02d97294384a5a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Zenh=C3=A4usern?= Date: Mon, 26 Sep 2016 17:41:44 +0200 Subject: [PATCH 22/25] Fixed naming --- PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs b/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs index 4a3a95a93..d36ad1bf1 100644 --- a/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs @@ -447,13 +447,13 @@ public bool PlayerTeamIsSet break; case UpgradePokemonResponse.Types.Result.Success: // Reload updated data - bool stillSowingUppingPokemon = uppingPokemon == SelectedPokemon; + bool selectedPokemonSameAsUpping = uppingPokemon == SelectedPokemon; PokemonInventory.Remove(uppingPokemon); var uppedPokemon = new PokemonDataWrapper(res.UpgradedPokemon); PokemonInventory.Add(uppedPokemon); PokemonInventory.SortBySortingmode(SortingMode); // If the upping pokemon is still showing (not fliped to other), change selected to upped - if(stillSowingUppingPokemon) + if(selectedPokemonSameAsUpping) { SelectedPokemon = uppedPokemon; RaisePropertyChanged(nameof(SelectedPokemon)); From 34884e9baff1aadd64cd589e5ab5ff63da1a0acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Zenh=C3=A4usern?= Date: Mon, 26 Sep 2016 23:37:36 +0200 Subject: [PATCH 23/25] Fixed wrong binding type --- .../PokemonInventoryPageViewModel.cs | 18 ------------------ .../Views/Pokemon/EggDetailControl.xaml.cs | 11 ++++++----- PokemonGo-UWP/Views/Pokemon/EggDetailPage.xaml | 3 ++- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/PokemonGo-UWP/ViewModels/PokemonInventoryPageViewModel.cs b/PokemonGo-UWP/ViewModels/PokemonInventoryPageViewModel.cs index cc289a1d1..ed623f584 100644 --- a/PokemonGo-UWP/ViewModels/PokemonInventoryPageViewModel.cs +++ b/PokemonGo-UWP/ViewModels/PokemonInventoryPageViewModel.cs @@ -185,15 +185,6 @@ public DelegateCommand ReturnToGameScreen #region Pokemon Inventory Handling - /// - /// Show sorting overlay for pokemon inventory - /// - private DelegateCommand _showPokemonSortingMenuCommand; - public DelegateCommand ShowPokemonSortingMenuCommand => _showPokemonSortingMenuCommand ?? (_showPokemonSortingMenuCommand = new DelegateCommand(() => - { - - })); - /// /// Sort the PokemonInventory with the CurrentPokemonSortingMode /// @@ -205,15 +196,6 @@ private void UpdateSorting() RaisePropertyChanged(() => PokemonInventory); } - /// - /// Show incubator overlay for egg inventory - /// - private DelegateCommand _showIncubatorOverlayCommand; - public DelegateCommand ShowIncubatorOverlayCommand => _showIncubatorOverlayCommand ?? (_showIncubatorOverlayCommand = new DelegateCommand(() => - { - - })); - #endregion #region Pokemon Detail diff --git a/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs b/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs index 1e815713a..aa07c6589 100644 --- a/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs +++ b/PokemonGo-UWP/Views/Pokemon/EggDetailControl.xaml.cs @@ -1,4 +1,5 @@ -using System; +using POGOProtos.Inventory; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -26,20 +27,20 @@ public EggDetailControl() private void ShowIncubatorSelection_Click(object sender, RoutedEventArgs e) { IncubatorSelectionOverlayControl incubatorControl = new IncubatorSelectionOverlayControl(); - incubatorControl.IncubatorSelected += (incubator) => { IncubateEggCommand.Execute(incubator); }; + incubatorControl.IncubatorSelected += (incubator) => { IncubateEggCommand?.Execute(incubator); }; incubatorControl.Show(); } #region Dependency Propertys public static readonly DependencyProperty IncubateEggCommandProperty = - DependencyProperty.Register(nameof(IncubateEggCommand), typeof(DelegateCommand), typeof(EggDetailControl), + DependencyProperty.Register(nameof(IncubateEggCommand), typeof(DelegateCommand), typeof(EggDetailControl), new PropertyMetadata(null)); - public DelegateCommand IncubateEggCommand + public DelegateCommand IncubateEggCommand { - get { return (DelegateCommand)GetValue(IncubateEggCommandProperty); } + get { return (DelegateCommand)GetValue(IncubateEggCommandProperty); } set { SetValue(IncubateEggCommandProperty, value); } } diff --git a/PokemonGo-UWP/Views/Pokemon/EggDetailPage.xaml b/PokemonGo-UWP/Views/Pokemon/EggDetailPage.xaml index 52a42d234..7ecd4c17d 100644 --- a/PokemonGo-UWP/Views/Pokemon/EggDetailPage.xaml +++ b/PokemonGo-UWP/Views/Pokemon/EggDetailPage.xaml @@ -1,4 +1,5 @@  - + From 904b71727a36fafbb5955dc7ea429db78f6d0ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Zenh=C3=A4usern?= Date: Wed, 9 Nov 2016 14:04:17 +0100 Subject: [PATCH 24/25] Added fix for wrong ID reported by @BadiBasso --- PokemonGo-UWP/Utils/GameClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PokemonGo-UWP/Utils/GameClient.cs b/PokemonGo-UWP/Utils/GameClient.cs index b1597f085..ceebe13a7 100644 --- a/PokemonGo-UWP/Utils/GameClient.cs +++ b/PokemonGo-UWP/Utils/GameClient.cs @@ -654,7 +654,7 @@ private static async Task UpdateMapObjects() BootStrapper.Current.NavigationService.Navigate(typeof(PokemonDetailPage), new SelectedPokemonNavModel() { - SelectedPokemonId = currentPokemon.PokemonId.ToString(), + SelectedPokemonId = currentPokemon.Id.ToString(), ViewMode = PokemonDetailPageViewMode.ReceivedPokemon }); } From ee446699898720be4f9b181a54d071222529f855 Mon Sep 17 00:00:00 2001 From: "Robert McLaws (Microsoft MVP)" Date: Fri, 11 Nov 2016 00:03:17 -0500 Subject: [PATCH 25/25] Login and banning text clarifications. Hopefully these changes make the warnings a bit easier to understand. --- PokemonGo-UWP/App.xaml.cs | 3 ++- PokemonGo-UWP/Strings/en-US/Resources.resw | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PokemonGo-UWP/App.xaml.cs b/PokemonGo-UWP/App.xaml.cs index 54fdf40f2..2328e092f 100644 --- a/PokemonGo-UWP/App.xaml.cs +++ b/PokemonGo-UWP/App.xaml.cs @@ -310,7 +310,8 @@ public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs } else if (latestUpdateInfo.Status == UpdateManager.UpdateStatus.NextVersionNotReady) { - var dialog = new MessageDialog("Please wait on next update", "This version is obsolete"); + var dialog = new MessageDialog("We've temporarily disabled the app to protect your account. An update will be ready soon. " + + "Please DO NOT open an issue on GitHub. Thank you for your patience."); dialog.Commands.Add(new UICommand("OK")); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; diff --git a/PokemonGo-UWP/Strings/en-US/Resources.resw b/PokemonGo-UWP/Strings/en-US/Resources.resw index 834c2aa1c..d4f646618 100644 --- a/PokemonGo-UWP/Strings/en-US/Resources.resw +++ b/PokemonGo-UWP/Strings/en-US/Resources.resw @@ -130,7 +130,7 @@ LOGIN with PTC Account - To login, enter your Username/Email and Password above. If you don't trust this app, please close it now. Niantic may ban you for using this app. Use at your own risk. + WARNING: Niantic may ban you for using this app. Use at your own risk. If you don't trust this app, please close it now. nearby