Skip to content

Commit

Permalink
feat(bingo): add true transcend gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Aug 31, 2023
1 parent a2ea45b commit c7f8f4b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 4 deletions.
74 changes: 74 additions & 0 deletions MHFZ_Overlay/ViewModels/Windows/BingoWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,82 @@ namespace MHFZ_Overlay.ViewModels.Windows;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Windows.Media.Animation;
using LiveChartsCore.SkiaSharpView.Drawing;
using LiveChartsCore.SkiaSharpView.Extensions;
using LiveChartsCore.VisualElements;
using Xunit.Abstractions;
using System.Globalization;

public partial class BingoWindowViewModel : ObservableRecipient, IRecipient<QuestIDMessage>, IRecipient<RunIDMessage>
{
private readonly Random _random = new();

public IEnumerable<ISeries> GaugeSeries { get; set; }

public IEnumerable<VisualElement<SkiaSharpDrawingContext>> VisualElements { get; set; }

public NeedleVisual Needle { get; set; }

private static void SetStyle(
double sectionsOuter, double sectionsWidth, PieSeries<ObservableValue> series, int order)
{
series.OuterRadiusOffset = sectionsOuter;
series.MaxRadialColumnWidth = sectionsWidth;
switch (order)
{
default:
series.Fill = new SolidColorPaint(new SKColor(AddressModel.StaticHexColorToDecimal("#11111b")));
break;
case 1:
series.Fill = new SolidColorPaint(new SKColor(AddressModel.StaticHexColorToDecimal("#f9e2af")));
break;
case 2:
series.Fill = new SolidColorPaint(new SKColor(AddressModel.StaticHexColorToDecimal("#94e2d5")));
break;
case 3:
series.Fill = new SolidColorPaint(new SKColor(AddressModel.StaticHexColorToDecimal("#89b4fa")));
break;
}
}

[RelayCommand]
public void DoRandomChange()
{
// modifying the Value property updates and animates the chart automatically
Needle.Value = _random.Next(0, 100);
}

private void SetGauge()
{
var sectionsOuter = 130;
var sectionsWidth = 20;

Needle = new NeedleVisual
{
Value = 45,
Fill = new SolidColorPaint(SKColor.FromHsl(226, 64, 88, 127)),
};

GaugeSeries = GaugeGenerator.BuildAngularGaugeSections(
new GaugeItem(60, s => SetStyle(sectionsOuter, sectionsWidth, s, 1)),
new GaugeItem(30, s => SetStyle(sectionsOuter, sectionsWidth, s, 2)),
new GaugeItem(10, s => SetStyle(sectionsOuter, sectionsWidth, s, 3)));

VisualElements = new VisualElement<SkiaSharpDrawingContext>[]
{
new AngularTicksVisual
{
LabelsSize = 16,
LabelsOuterOffset = 15,
OuterOffset = 65,
TicksLength = 20,
LabelsPaint = new SolidColorPaint(new SKColor(AddressModel.StaticHexColorToDecimal("#cdd6f4"))),
Stroke = new SolidColorPaint(new SKColor(AddressModel.StaticHexColorToDecimal("#cdd6f4"))),
},
Needle
};
}

private ObservableCollection<ObservableValue>? _observableValues { get; set; }

private static readonly NLog.Logger LoggerInstance = NLog.LogManager.GetCurrentClassLogger();
Expand All @@ -54,6 +127,7 @@ public BingoWindowViewModel(SnackbarPresenter snackbarPresenter)
{
BingoWindowSnackbarPresenter = snackbarPresenter;
SetGraphs();
SetGauge();
}

public void Receive(QuestIDMessage message) => OnReceivedQuestID(message);
Expand Down
18 changes: 14 additions & 4 deletions MHFZ_Overlay/Views/Windows/BingoWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@
<RowDefinition Height="64"/>
<RowDefinition Height="64"/>
<RowDefinition Height="64"/>
<RowDefinition Height="64"/>
<RowDefinition Height="64"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="64"/>
Expand All @@ -390,7 +392,7 @@
<ui:SymbolIcon Foreground="{StaticResource Red}" Symbol="BookExclamationMark24" FontSize="48" Width="64" Height="64" Grid.Row="3"/>
<ui:SymbolIcon Foreground="{StaticResource Yellow}" Symbol="StarEmphasis32" FontSize="48" Width="64" Height="64" Grid.Row="4"/>
<ui:SymbolIcon Foreground="{StaticResource Green}" FontSize="48" Symbol="DeveloperBoardLightning20" Width="64" Height="64" Grid.Row="5"/>
<ui:Image Grid.Row="7" Height="64" Source="pack://application:,,,/MHFZ_Overlay;component/Assets/Icons/png/transcend.png"/>
<ui:Image Grid.Row="7" Grid.ColumnSpan="2" Grid.RowSpan="4" HorizontalAlignment="Center" Height="64" Source="pack://application:,,,/MHFZ_Overlay;component/Assets/Icons/png/transcend.png"/>
<Button Grid.Row="6" Width="64" Height="64" BorderBrush="Transparent" Background="Transparent" Content="{Binding Converter={StaticResource XamlIconToViewBoxConverter },ConverterParameter='Assets/Icons/Scrap_Icon_White.xaml'}"/>

<StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
Expand Down Expand Up @@ -419,9 +421,17 @@ Unlock an upgrade for increasing the chance of finding an ancient dragon part's
<ui:DynamicScrollViewer Grid.Row="5" Grid.Column="1" Margin="5" CanContentScroll="True" IsDeferredScrollingEnabled="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<TextBlock TextWrapping="Wrap" Text="Source Effects: None."/>
</ui:DynamicScrollViewer>
<TextBlock FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="6" Grid.Column="1" TextWrapping="Wrap" d:Text="Scraps Found: 0/100"/>
<ProgressBar Margin="4" Value="500" Grid.Column="1" Grid.Row="7" Maximum="1000"/>
<Button HorizontalAlignment="Center" Grid.Row="8" Grid.ColumnSpan="2" Content="True Transcend" Foreground="{StaticResource Crust}" Background="{StaticResource Blue}"/>
<TextBlock FontSize="18" VerticalAlignment="Center" Grid.Row="6" Grid.Column="1" TextWrapping="Wrap" Text="Scraps Found: 0/100"/>
<lvc:PieChart Width="Auto" Height="Auto" Grid.RowSpan="4" Grid.ColumnSpan="2"
Grid.Row="7"
Series="{Binding GaugeSeries}"
VisualElements="{Binding VisualElements}"
InitialRotation="-225"
MaxAngle="270"
MinValue="0"
MaxValue="100">
</lvc:PieChart>
<Button VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="10" Grid.ColumnSpan="2" Content="True Transcend" Foreground="{StaticResource Crust}" Background="{StaticResource Blue}" Command="{Binding DoRandomChangeCommand}"/>
</Grid>
</ui:DynamicScrollViewer>
</Grid>
Expand Down

0 comments on commit c7f8f4b

Please sign in to comment.