Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from ST-Apps/master
Browse files Browse the repository at this point in the history
Login on enter keydown
  • Loading branch information
QuentinSc authored Aug 1, 2016
2 parents b538942 + 83ee334 commit 0b30068
Show file tree
Hide file tree
Showing 49 changed files with 1,532 additions and 1,056 deletions.
Binary file modified .vs/Pokemon Go Universal/v14/.suo
Binary file not shown.
4 changes: 1 addition & 3 deletions PokemonGo-UWP/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
<ResourceDictionary Source="Styles\Custom.xaml" />
</ResourceDictionary.MergedDictionaries>

<viewModels:ViewModelLocator x:Key="Locator" />

<utils:PokemonIdToPokemonSpriteConverter x:Key="PokemonIdToPokemonSpriteConverter" />
<utils:EmptyConverter x:Key="EmptyConverter" />
<utils:PlayerTeamToTeamColorBrushConverter x:Key="PlayerTeamToTeamColorBrushConverter" />
Expand All @@ -22,7 +20,7 @@
<utils:CaptureXpToTotalCaptureXpConverter x:Key="CaptureXpToTotalCaptureXpConverter" />
<utils:ActivityTypeToActivityNameConverter x:Key="ActivityTypeToActivityNameConverter" />
<utils:MapObjectToGeopointConverter x:Key="MapObjectToGeopointConverter" />
<utils:ItemIdToPokemonSpriteConverter x:Key="ItemIdToPokemonSpriteConverter" />
<utils:ItemIdToItemIconConverter x:Key="ItemIdToItemIconConverter" />
<utils:PokemonDataToVisibilityConverter x:Key="PokemonDataToVisibilityConverter" />
<utils:ItemAwardToPokemonSpriteConverter x:Key="ItemAwardToPokemonSpriteConverter" />
<utils:NearbyPokemonDistanceToDistanceImageConverter x:Key="NearbyPokemonDistanceToDistanceImageConverter" />
Expand Down
36 changes: 25 additions & 11 deletions PokemonGo-UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
using Windows.System;
using Windows.System.Display;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using PokemonGo.RocketAPI;
using PokemonGo.RocketAPI.Logging;

namespace PokemonGo_UWP
{
Expand All @@ -20,10 +23,7 @@ namespace PokemonGo_UWP
[Bindable]
sealed partial class App : BootStrapper
{
/// <summary>
/// Locator instance
/// </summary>
public static ViewModelLocator ViewModelLocator;


/// <summary>
/// Used to prevent lockscreen while playing
Expand All @@ -34,6 +34,11 @@ public App()
{
InitializeComponent();

#if DEBUG
// Init logger
Logger.SetLogger(new ConsoleLogger(LogLevel.Info));
#endif

// Init HockeySDK
if (!string.IsNullOrEmpty(ApplicationKeys.HockeyAppToken))
HockeyClient.Current.Configure(ApplicationKeys.HockeyAppToken);
Expand All @@ -51,19 +56,28 @@ public override async Task OnInitializeAsync(IActivatedEventArgs args)
var statusBar = StatusBar.GetForCurrentView();
await statusBar.HideAsync();
}
// Get a static reference to viewmodel locator to use it within viewmodels
ViewModelLocator = (ViewModelLocator) Current.Resources["Locator"];
await Task.CompletedTask;
}

public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
await NavigationService.NavigateAsync(typeof(MainPage));
{
if (!string.IsNullOrEmpty(SettingsService.Instance.PtcAuthToken))
{
// We have a stored token, let's go to game page
NavigationService.Navigate(typeof(GameMapPage), true);
//await ViewModelLocator.GameManagerViewModel.InitGame(true);
try
{
await GameClient.InitializeClient();
// We have a stored token, let's go to game page
NavigationService.Navigate(typeof(GameMapPage), true);
//await ViewModelLocator.GameManagerViewModel.InitGame(true);
}
catch (Exception)
{
await ExceptionHandler.HandleException();
}
}
else
{
await NavigationService.NavigateAsync(typeof(MainPage));
}

// Check for updates
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
84 changes: 84 additions & 0 deletions PokemonGo-UWP/Entities/FortDataWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Geolocation;
using AllEnum;
using Google.Protobuf;
using PokemonGo.RocketAPI.GeneratedCode;
using PokemonGo_UWP.Utils;
using PokemonGo_UWP.Views;
using Template10.Common;
using Template10.Mvvm;

namespace PokemonGo_UWP.Entities
{
public class FortDataWrapper
{

private readonly FortData _fortData;

public FortDataWrapper(FortData fortData)
{
_fortData = fortData;
Geoposition =
new Geopoint(new BasicGeoposition { Latitude = _fortData.Latitude, Longitude = _fortData.Longitude });
}

private DelegateCommand _trySearchPokestop;

/// <summary>
/// We're just navigating to the capture page, reporting that the player wants to capture the selected Pokemon.
/// The only logic here is to check if the encounter was successful before navigating, everything else is handled by
/// the actual capture method.
/// </summary>
public DelegateCommand TrySearchPokestop => _trySearchPokestop ?? (
_trySearchPokestop = new DelegateCommand(() =>
{
NavigationHelper.NavigationState["CurrentPokestop"] = this;
BootStrapper.Current.NavigationService.Navigate(typeof(SearchPokestopPage), true);
}, () => true)
);


#region Wrapped Properties

public FortType Type => _fortData.Type;

public ByteString ActiveFortModifier => _fortData.ActiveFortModifier;

public long CooldownCompleteTimestampMs => _fortData.CooldownCompleteTimestampMs;

public bool Enabled => _fortData.Enabled;

public PokemonId GuardPokemonId => _fortData.GuardPokemonId;

public long GymPoints => _fortData.GymPoints;

public string Id => _fortData.Id;

public bool IsInBattle => _fortData.IsInBattle;

public long LastModifiedTimestampMs => _fortData.LastModifiedTimestampMs;

public FortLureInfo LureInfo => _fortData.LureInfo;

public TeamColor OwnedByTeam => _fortData.OwnedByTeam;

public FortRenderingType RenderingType => _fortData.RenderingType;

public FortSponsor Sponsor => _fortData.Sponsor;

public Geopoint Geoposition { get; set; }

public int GuardPokemonCp => _fortData.GuardPokemonCp;

public double Latitude => _fortData.Latitude;

public double Longitude => _fortData.Longitude;

#endregion

}
}
25 changes: 22 additions & 3 deletions PokemonGo-UWP/Entities/MapPokemonWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using Windows.Devices.Geolocation;
using AllEnum;
using Newtonsoft.Json;
using PokemonGo.RocketAPI.GeneratedCode;
using PokemonGo_UWP.Utils;
using PokemonGo_UWP.Views;
using Template10.Common;
using Template10.Mvvm;

namespace PokemonGo_UWP.Entities
{
Expand All @@ -15,6 +20,20 @@ public MapPokemonWrapper(MapPokemon mapPokemon)
new Geopoint(new BasicGeoposition {Latitude = _mapPokemon.Latitude, Longitude = _mapPokemon.Longitude});
}

private DelegateCommand _tryCatchPokemon;

/// <summary>
/// We're just navigating to the capture page, reporting that the player wants to capture the selected Pokemon.
/// </summary>
public DelegateCommand TryCatchPokemon => _tryCatchPokemon ?? (
_tryCatchPokemon = new DelegateCommand(() =>
{
NavigationHelper.NavigationState["CurrentPokemon"] = this;
BootStrapper.Current.NavigationService.Navigate(typeof(CapturePokemonPage), true);
}, () => true)
);


#region Wrapped Properties

public PokemonId PokemonId => _mapPokemon.PokemonId;
Expand All @@ -25,11 +44,11 @@ public MapPokemonWrapper(MapPokemon mapPokemon)

public string SpawnpointId => _mapPokemon.SpawnpointId;

public Geopoint Geoposition { get; }
public Geopoint Geoposition { get; set; }

public double Latitude => Geoposition.Position.Latitude;
public double Latitude => _mapPokemon.Latitude;

public double Longitude => Geoposition.Position.Longitude;
public double Longitude => _mapPokemon.Longitude;

#endregion
}
Expand Down
6 changes: 3 additions & 3 deletions PokemonGo-UWP/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?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" IgnorableNamespaces="uap mp">
<Identity Name="c602d2cb-fdd8-4e41-b5a1-8f9a8a1f56c7" Publisher="CN=stept" Version="1.0.7.0" />
<Identity Name="c602d2cb-fdd8-4e41-b5a1-8f9a8a1f56c7" Publisher="CN=stept" Version="1.0.8.0" />
<mp:PhoneIdentity PhoneProductId="c602d2cb-fdd8-4e41-b5a1-8f9a8a1f56c7" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>PoGo-UWP</DisplayName>
<DisplayName>PoGo</DisplayName>
<PublisherDisplayName>ST-Apps</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
Expand All @@ -15,7 +15,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="PokemonGo-UWP.App">
<uap:VisualElements DisplayName="PoGo-UWP" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Sample" BackgroundColor="transparent">
<uap:VisualElements DisplayName="PoGo" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Sample" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
Expand Down
12 changes: 9 additions & 3 deletions PokemonGo-UWP/PokemonGo-UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<DefineConstants>TRACE;DEBUG;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS;</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
Expand Down Expand Up @@ -324,17 +324,23 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Entities\FortDataWrapper.cs" />
<Compile Include="Entities\MapPokemonWrapper.cs" />
<Compile Include="Entities\NearbyPokemonWrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\ApplicationKeys.cs" />
<Compile Include="Utils\Converters.cs" />
<Compile Include="Utils\ExceptionHandler.cs" />
<Compile Include="Utils\GameClient.cs" />
<Compile Include="Utils\MessageDialogExtensions.cs" />
<Compile Include="Utils\NavigationHelper.cs" />
<Compile Include="Utils\Settings.cs" />
<Compile Include="Utils\SettingsService.cs" />
<Compile Include="Utils\UpdateManager.cs" />
<Compile Include="ViewModels\GameManagerViewModel.cs" />
<Compile Include="ViewModels\ViewModelLocator.cs" />
<Compile Include="ViewModels\CapturePokemonPageViewModel.cs" />
<Compile Include="ViewModels\GameMapPageViewModel.cs" />
<Compile Include="ViewModels\LoginPageViewModel.cs" />
<Compile Include="ViewModels\SearchPokeStopPageViewModel.cs" />
<Compile Include="Views\CapturePokemonPage.xaml.cs">
<DependentUpon>CapturePokemonPage.xaml</DependentUpon>
</Compile>
Expand Down
2 changes: 1 addition & 1 deletion PokemonGo-UWP/Utils/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
#endregion
}

public class ItemIdToPokemonSpriteConverter : IValueConverter
public class ItemIdToItemIconConverter : IValueConverter
{
#region Implementation of IValueConverter

Expand Down
32 changes: 32 additions & 0 deletions PokemonGo-UWP/Utils/ExceptionHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Popups;
using PokemonGo_UWP.Views;
using Template10.Common;
using Template10.Services.NavigationService;

namespace PokemonGo_UWP.Utils
{
public static class ExceptionHandler
{

public static async Task HandleException()
{
var dialog = new MessageDialog("Something went wrong and app may be unstable now. Do you want to logout and try again?");
dialog.Commands.Add(new UICommand("Yes") { Id = 0 });
dialog.Commands.Add(new UICommand("No") { Id = 1 });
dialog.DefaultCommandIndex = 0;
dialog.CancelCommandIndex = 1;
var result = await dialog.ShowAsyncQueue();
if ((int)result.Id == 0)
{
GameClient.DoLogout();
BootStrapper.Current.NavigationService.Navigate(typeof(MainPage));
}
}

}
}
Loading

0 comments on commit 0b30068

Please sign in to comment.