Skip to content

Commit

Permalink
Added Golden border when the achievement is rare (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jul 7, 2023
1 parent bdd39df commit bd83428
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Gavilya/Themes/Dark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@
<GradientStop Color="#FF008328" />
<GradientStop Color="#04B63A" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="GoldGradient" StartPoint="0,0" EndPoint="1,1">
<GradientStop Offset="0" Color="#FFD700"/>
<GradientStop Offset="1" Color="#FF8C00"/>
</LinearGradientBrush>
</ResourceDictionary>
2 changes: 1 addition & 1 deletion Gavilya/UserControls/AchievementItem.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<UserControl x:Class="Gavilya.UserControls.AchievementItem" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Gavilya.UserControls" FontFamily="../Fonts/#Hauora" Foreground="{DynamicResource Foreground}" mc:Ignorable="d" Height="350" Width="250" Margin="5" MaxWidth="250">
<Border CornerRadius="10" Background="{DynamicResource Background2}">
<Border x:Name="ItemBorder" CornerRadius="10" Background="{DynamicResource Background2}" BorderThickness="2">
<Grid MaxWidth="250">
<Grid.RowDefinitions>
<RowDefinition/>
Expand Down
10 changes: 10 additions & 0 deletions Gavilya/UserControls/AchievementItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
using Gavilya.Classes;
using Gavilya.SDK.RAWG;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Gavilya.UserControls;
Expand All @@ -48,6 +52,12 @@ private void InitUI(Achievement achievement)
AchievementDescriptionTxt.Text = achievement.description; // Set text
AchievementPourcentTxt.Text = $"{achievement.percent}% {Properties.Resources.AchievementPlayerUnlocked}"; // Set text

// Rare
if (double.Parse(achievement.percent, CultureInfo.InvariantCulture) < 1)
{
ItemBorder.BorderBrush = (LinearGradientBrush)Application.Current.Resources["GoldGradient"];
}

// Load the image
var image = new BitmapImage();
image.BeginInit();
Expand Down

0 comments on commit bd83428

Please sign in to comment.