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

[WIP] Add BattlePage UI with basic animations (no game play) #1743

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion PokemonGo-UWP/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<utils:PlayerTeamToTeamImageConverter x:Key="PlayerTeamToTeamImageConverter" />
<utils:PlayerTeamToTeamBaseImageConverter x:Key="PlayerTeamToTeamBaseImageConverter" />
<utils:PlayerTeamToTeamNameConverter x:Key="PlayerTeamToTeamNameConverter" />
<utils:AchievementValueToMedalImageConverter x:Key="AchievementValueToMedalImageConverter" />
<utils:AchievementValueToMedalIconConverter x:Key="AchievementValueToMedalIconConverter" />
<utils:PlayerTeamToTeamBackgroundImageConverter x:Key="PlayerTeamToTeamBackgroundImageConverter" />
<utils:AchievementNextValueConverter x:Key="AchievementNextValueConverter" />
<utils:AchievementValueConverter x:Key="AchievementValueConverter" />
Expand All @@ -95,6 +95,7 @@
<utils:IntToBooleanConverter x:Key="IntToBooleanConverter" />
<utils:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<utils:PokemonLastHoursVisibiltyConverter x:Key="PokemonLastHoursVisibiltyConverter" />
<utils:IsIncenseActiveToPlayerIconConverter x:Key="IsIncenseActiveToPlayerIconConverter" />

</ResourceDictionary>
</Application.Resources>
Expand Down
Binary file added PokemonGo-UWP/Assets/Icons/spawnpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PokemonGo-UWP/Assets/UI/ash_withincense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PokemonGo-UWP/Assets/UI/glare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions PokemonGo-UWP/Controls/ChargeAvailableBar.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<UserControl
x:Class="PokemonGo_UWP.Controls.ChargeAvailableBar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PokemonGo_UWP.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Height="16" d:DesignWidth="100">

<Grid>
<TextBlock Foreground="White">
<Run x:Name="TextChargeAvailable"></Run>
<Run Text="/"></Run>
<Run x:Name="TextMaxChargeAvailable"></Run>
</TextBlock>
</Grid>
</UserControl>
66 changes: 66 additions & 0 deletions PokemonGo-UWP/Controls/ChargeAvailableBar.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace PokemonGo_UWP.Controls
{
public sealed partial class ChargeAvailableBar : UserControl
{
#region "Dependency properties"
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(nameof(Value), typeof(double), typeof(ChargeAvailableBar),
new PropertyMetadata(0.0, OnPropertyChanged));
public static readonly DependencyProperty MaxValueProperty =
DependencyProperty.Register(nameof(MaxValue), typeof(double), typeof(ChargeAvailableBar),
new PropertyMetadata(0.0, OnPropertyChanged));

public double Value
{
get { return (double)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}

public double MaxValue
{
get { return (double)GetValue(MaxValueProperty); }
set { SetValue(MaxValueProperty, value); }
}

private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((ChargeAvailableBar)d).UpdateBar();
}

#endregion

private void UpdateBar()
{
TextChargeAvailable.Text = Value.ToString("n1");
TextMaxChargeAvailable.Text = MaxValue.ToString("n1");
}

public ChargeAvailableBar()
{
this.InitializeComponent();
this.Loaded += ChargeAvailableBar_Loaded;
}

private void ChargeAvailableBar_Loaded(object sender, RoutedEventArgs e)
{
UpdateBar();
}
}
}
16 changes: 6 additions & 10 deletions PokemonGo-UWP/Controls/CircularProgressBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ private static void OnPropertyChanged(DependencyObject sender, DependencyPropert

private static void OnImageSourcePathChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
if (sender == null) return;
CircularProgressBar circularProgressBar = sender as CircularProgressBar;
if (circularProgressBar?.ImageSourcePath != null)
{
circularProgressBar.InnerPathRoot.Fill = new ImageBrush
{
ImageSource = circularProgressBar.ImageSourcePath
};
}
BitmapImage fillImg = (circularProgressBar.ImageSourcePath != null) ?new BitmapImage(circularProgressBar.ImageSourcePath) : new BitmapImage();
circularProgressBar.InnerPathRoot.Fill = new ImageBrush { ImageSource = fillImg };
}

#endregion
Expand All @@ -68,7 +64,7 @@ private static void OnImageSourcePathChanged(DependencyObject sender, Dependency

public static readonly DependencyProperty InnerSegmentColorProperty = DependencyProperty.Register("InnerSegmentColor", typeof(Brush), typeof(CircularProgressBar), new PropertyMetadata(Colors.Gray));

public static readonly DependencyProperty ImageSourcePathProperty = DependencyProperty.Register("ImageSourcePath", typeof(BitmapImage), typeof(CircularProgressBar), new PropertyMetadata("", OnImageSourcePathChanged));
public static readonly DependencyProperty ImageSourcePathProperty = DependencyProperty.Register("ImageSourcePath", typeof(Uri), typeof(CircularProgressBar), new PropertyMetadata("", OnImageSourcePathChanged));

#endregion

Expand Down Expand Up @@ -122,9 +118,9 @@ public Brush InnerSegmentColor
set { SetValue(InnerSegmentColorProperty, value); }
}

public BitmapImage ImageSourcePath
public Uri ImageSourcePath
{
get { return (BitmapImage)GetValue(ImageSourcePathProperty); }
get { return (Uri)GetValue(ImageSourcePathProperty); }
set { SetValue(ImageSourcePathProperty, value); }
}
#endregion
Expand Down
58 changes: 58 additions & 0 deletions PokemonGo-UWP/Controls/HealthIndicatorBar.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<UserControl
x:Class="PokemonGo_UWP.Controls.HealthIndicatorBar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PokemonGo_UWP.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Height="8"
d:DesignWidth="100">
<UserControl.Resources>
<Storyboard x:Name="DampStoryboard">
<DoubleAnimation Storyboard.TargetName="DampedBar" Storyboard.TargetProperty="(Border.RenderTransform).(ScaleTransform.ScaleX)"
BeginTime="0:0:0.3" Duration="0:0:0.4">
</DoubleAnimation>
</Storyboard>
<Storyboard x:Name="FlashStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="FlashBar" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:0.05">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:0.1">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:0.15">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Grid>
<Border Background="Gray" CornerRadius="5" BorderThickness="0" Opacity="0.5">
</Border>
<Border x:Name="DampedBar" Background="Orange" CornerRadius="5,0,0,5" BorderThickness="0">
<Border.RenderTransform>
<ScaleTransform></ScaleTransform>
</Border.RenderTransform>
</Border>
<Border x:Name="HealthBar" Background="Lime" CornerRadius="5,0,0,5" BorderThickness="0">
<Border.RenderTransform>
<ScaleTransform></ScaleTransform>
</Border.RenderTransform>
</Border>
<Border x:Name="FlashBar" Background="Red" CornerRadius="5" BorderThickness="0" Opacity="0.5" Visibility="Collapsed">
</Border>
</Grid>
</UserControl>
90 changes: 90 additions & 0 deletions PokemonGo-UWP/Controls/HealthIndicatorBar.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace PokemonGo_UWP.Controls
{
public sealed partial class HealthIndicatorBar : UserControl
{
#region "Dependency properties"
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register(nameof(Value), typeof(int), typeof(HealthIndicatorBar),
new PropertyMetadata(0, OnPropertyChanged));
public static readonly DependencyProperty MaxValueProperty =
DependencyProperty.Register(nameof(MaxValue), typeof(int), typeof(HealthIndicatorBar),
new PropertyMetadata(100, OnPropertyChanged));

public int Value
{
get { return (int)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}

public int MaxValue
{
get { return (int)GetValue(MaxValueProperty); }
set { SetValue(MaxValueProperty, value); }
}

private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((HealthIndicatorBar)d).UpdateBar();
}
#endregion

private static SolidColorBrush LimeBrush = new SolidColorBrush(Colors.Lime);
private static SolidColorBrush YellowBrush = new SolidColorBrush(Colors.Yellow);
private static SolidColorBrush RedBrush = new SolidColorBrush(Colors.Red);

private void UpdateBar()
{
double valueScale = (MaxValue == 0) ? 0 : (double)this.Value / MaxValue;
if (valueScale < 0) valueScale = 0;
else if (valueScale > 1) valueScale = 1;
((ScaleTransform)HealthBar.RenderTransform).ScaleX = valueScale;

if (valueScale==1)
{
HealthBar.CornerRadius = new CornerRadius(5);
DampedBar.CornerRadius = new CornerRadius(5);
}
else
{
HealthBar.CornerRadius = new CornerRadius(5, 0, 0, 5);
DampedBar.CornerRadius = new CornerRadius(5, 0, 0, 5);
FlashStoryboard.Begin();
}
if (valueScale > 0.6) HealthBar.Background = LimeBrush;
else if (valueScale > 0.3) HealthBar.Background = YellowBrush;
else HealthBar.Background = RedBrush;
((DoubleAnimation)DampStoryboard.Children[0]).To = valueScale;
DampStoryboard.Begin();
}

public HealthIndicatorBar()
{
this.InitializeComponent();
this.Loaded += HealthIndicatorBar_Loaded;
}

private void HealthIndicatorBar_Loaded(object sender, RoutedEventArgs e)
{
UpdateBar();
}
}
}
32 changes: 10 additions & 22 deletions PokemonGo-UWP/Controls/OutdoorBackground.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using PokemonGo_UWP.Utils.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -23,31 +24,18 @@ public OutdoorBackground()
{
this.InitializeComponent();

var currentTime = int.Parse(DateTime.Now.ToString("HH"));
var dayTime = currentTime > 7 && currentTime < 19;
if (!dayTime)
if (!UIHelper.IsDaySky(DateTime.Now, TimeZoneInfo.Local, Utils.Helpers.LocationServiceHelper.Instance?.Geoposition))
{
BackgroundBrush.GradientStops[0].Color = ColorFromString("#FF01080E");
BackgroundBrush.GradientStops[1].Color = ColorFromString("#FF01080E");
BackgroundBrush.GradientStops[2].Color = ColorFromString("#FF02154D");
BackgroundBrush.GradientStops[3].Color = ColorFromString("#FF182247");
BackgroundBrush.GradientStops[4].Color = ColorFromString("#FF1684B9");
BackgroundBrush.GradientStops[5].Color = ColorFromString("#FF6A86B5");
BackgroundBrush.GradientStops[0].Color = UIHelper.ColorFromString("#FF01080E");
BackgroundBrush.GradientStops[1].Color = UIHelper.ColorFromString("#FF01080E");
BackgroundBrush.GradientStops[2].Color = UIHelper.ColorFromString("#FF02154D");
BackgroundBrush.GradientStops[3].Color = UIHelper.ColorFromString("#FF182247");
BackgroundBrush.GradientStops[4].Color = UIHelper.ColorFromString("#FF1684B9");
BackgroundBrush.GradientStops[5].Color = UIHelper.ColorFromString("#FF6A86B5");
DayPic.Visibility = Visibility.Collapsed;
NightPic.Visibility = Visibility.Visible;
}

}
private Windows.UI.Color ColorFromString(string hex)
{
hex = hex.Replace("#", string.Empty);
byte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
byte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
byte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
byte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
Windows.UI.Color color = Windows.UI.Color.FromArgb(a, r, g, b);
return color;

}

}
}
Loading