Skip to content

Commit

Permalink
Transfer multiple pokémon at once.
Browse files Browse the repository at this point in the history
You can select more than one pokemon by a long press. It will open the multiselect screen.
  • Loading branch information
mtaheij committed Feb 5, 2017
1 parent cbf6fdf commit 3ca98b1
Show file tree
Hide file tree
Showing 16 changed files with 681 additions and 122 deletions.
2 changes: 2 additions & 0 deletions PokemonGo-UWP/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<utils:PokemonIdToNearbyPokestopConverter x:Key="PokemonIdToNearbyPokestopConverter"/>
<utils:PokemonIdToNumericId x:Key="PokemonIdToNumericId" />
<utils:ItemClickEventArgsToClickedItemConverter x:Key="ItemClickEventArgsToClickedItemConverter" />
<utils:TappedRoutedEventArgsToClickedItemConverter x:Key="TappedRoutedEventArgsToClickedItemConverter" />
<utils:HoldingRoutedEventArgsToClickedItemConverter x:Key="HoldingRoutedEventArgsToClickedItemConverter" />
<utils:PokemonIdToPokemonSpriteConverter x:Key="PokemonIdToPokemonSpriteConverter" />
<utils:BuddyIsDeployedVisibilityConverter x:Key="BuddyIsDeployedVisibilityConverter" />
<utils:PokemonIsBuddyVisibilityConverter x:Key="PokemonIsBuddyVisibilityConverter" />
Expand Down
13 changes: 12 additions & 1 deletion PokemonGo-UWP/Controls/CircularProgressBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,18 @@ public Brush InnerSegmentColor

public Uri ImageSourcePath
{
get { return (Uri)GetValue(ImageSourcePathProperty); }
get
{
try
{
Uri u = (Uri)GetValue(ImageSourcePathProperty);
return u;
}
catch (Exception ex)
{
return null;
}
}
set { SetValue(ImageSourcePathProperty, value); }
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion PokemonGo-UWP/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:wincap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/windowscapabilities" IgnorableNamespaces="uap mp rescap wincap">
<Identity Name="c602d2cb-fdd8-4e41-b5a1-8f9a8a1f56c7" Publisher="CN=stept" Version="1.2.3.0" />
<Identity Name="c602d2cb-fdd8-4e41-b5a1-8f9a8a1f56c7" Publisher="CN=stept" Version="1.2.4.0" />
<mp:PhoneIdentity PhoneProductId="c602d2cb-fdd8-4e41-b5a1-8f9a8a1f56c7" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>PoGo</DisplayName>
Expand Down
9 changes: 9 additions & 0 deletions PokemonGo-UWP/Strings/en-US/CodeResources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,13 @@ You also got {1} Stardust, {2} Candy and {3} XP.</value>
<data name="ActivitySearchFortStreakBonus" xml:space="preserve">
<value>Streak Bonus</value>
</data>
<data name="CannotTransferBuddy" xml:space="preserve">
<value>Cannot transfer your buddy Pokémon!</value>
</data>
<data name="TransferMultiplePokemonWarningText" xml:space="preserve">
<value>After you transfer, you can't undo the transfer.</value>
</data>
<data name="TransferMultiplePokemonWarningTitle" xml:space="preserve">
<value>Do you want to transfer {0} Pokémon to the Professor?</value>
</data>
</root>
54 changes: 54 additions & 0 deletions PokemonGo-UWP/Utils/Game/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using Windows.Foundation;
using Windows.Services.Maps;
using System.Threading.Tasks;
using Windows.UI.Xaml.Input;

namespace PokemonGo_UWP.Utils
{
Expand Down Expand Up @@ -88,6 +89,59 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
#endregion
}

public class TappedRoutedEventArgsToClickedItemConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
TappedRoutedEventArgs args = (TappedRoutedEventArgs)value;
FrameworkElement clickedItem = args.OriginalSource as FrameworkElement;
return clickedItem.DataContext;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value;
}
}

public class DoubleTappedRoutedEventArgsToClickedItemConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
DoubleTappedRoutedEventArgs args = (DoubleTappedRoutedEventArgs)value;
FrameworkElement clickedItem = args.OriginalSource as FrameworkElement;
return clickedItem.DataContext;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value;
}
}

public class HoldingRoutedEventArgsToClickedItemConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
HoldingRoutedEventArgs args = (HoldingRoutedEventArgs)value;
if (args.HoldingState == Windows.UI.Input.HoldingState.Completed)
{
FrameworkElement clickedItem = args.OriginalSource as FrameworkElement;
return clickedItem.DataContext;
}
else
{
args.Handled = true;
return null;
}
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value;
}
}

public class PokemonIdToPokedexDescription : IValueConverter
{
#region Implementation of IValueConverter
Expand Down
18 changes: 18 additions & 0 deletions PokemonGo-UWP/Utils/Game/DataTemplateSelectors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,22 @@ protected override DataTemplate SelectTemplateCore(object item, DependencyObject
return template;
}
}

public class SelectedItemsTemplateSelector : DataTemplateSelector
{
public DataTemplate DefaultStateTemplate { get; set; }
public DataTemplate SelectedStateTemplate { get; set; }
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
{
GridViewItem gvi = container as GridViewItem;
if (gvi != null)
{
if (gvi.IsSelected)
return SelectedStateTemplate;
else
return DefaultStateTemplate;
}
return base.SelectTemplateCore(item, container);
}
}
}
10 changes: 10 additions & 0 deletions PokemonGo-UWP/Utils/GameClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,16 @@ public static async Task<ReleasePokemonResponse> TransferPokemon(ulong pokemonId
return await _client.Inventory.TransferPokemon(pokemonId);
}

/// <summary>
/// Transfers multiple Pokemons at once
/// </summary>
/// <param name="pokemonIds"></param>
/// <returns></returns>
public static async Task<ReleasePokemonResponse> TransferPokemons(ulong[] pokemonIds)
{
return await _client.Inventory.TransferPokemons(pokemonIds);
}

/// <summary>
/// Favourites/Unfavourites the Pokemon
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions PokemonGo-UWP/ViewModels/PokemonDetailPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ public bool PlayerTeamIsSet
cannotTransferDialog.Show();
return;
}
// This is also for the buddy pokemon
if (Convert.ToBoolean(SelectedPokemon.IsBuddy))
{
var cannotTransferDialog = new PoGoMessageDialog(Resources.CodeResources.GetString("CannotTransferBuddy"), "")
{
CoverBackground = true,
AnimationType = PoGoMessageDialogAnimation.Bottom
};
cannotTransferDialog.Show();
return;
}

// Ask for confirmation before moving the Pokemon
var name = Resources.Pokemon.GetString(SelectedPokemon.PokemonId.ToString());
var dialog =
Expand Down
Loading

0 comments on commit 3ca98b1

Please sign in to comment.