Skip to content

Commit

Permalink
add basic support for modifying rush loadouts
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBoot committed Nov 14, 2023
1 parent d3c5a57 commit 90bd7d8
Show file tree
Hide file tree
Showing 11 changed files with 632 additions and 5 deletions.
37 changes: 37 additions & 0 deletions GiganticEmu.Launcher/Converters/UpgradeConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
using GiganticEmu.Shared;

namespace GiganticEmu.Launcher;

public class UpgradeConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is SkillUpgrade su)
{
return $"[{su.Skill switch
{
Skill.Skill1 => "LMB",
Skill.Skill2 => "RMB",
Skill.Skill3 => "Q",
Skill.Skill4 => "E",
Skill.Focus => "Focus",
}}] {su.Path} {su.SubPath}";
}

if (value is TalentUpgrade tu)
{
return $"Talent {((int)tu.Upgrade) + 1}";
}

return value;
}

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
49 changes: 49 additions & 0 deletions GiganticEmu.Launcher/ViewModels/RushLoadoutSettingsViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

using System.Linq;
using System.Reactive;
using System.Threading.Tasks;
using DynamicData;
using GiganticEmu.Shared;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Splat;

namespace GiganticEmu.Launcher;

public class RushLoadoutSettingsViewModel : ReactiveObject, SettingsContainerViewModel.ISettingsPageViewModel
{
[Reactive]
public RushLoadout? RushLoadout { get; set; }

public ISourceList<RushLoadout> RushLoadouts { get; } = new SourceList<RushLoadout>();

public ReactiveCommand<Unit, Unit> Apply { get; }
public ReactiveCommand<Unit, Unit> Reset { get; }

public RushLoadoutSettingsViewModel()
{
Apply = ReactiveCommand.CreateFromTask(DoApply);
Reset = ReactiveCommand.CreateFromTask(DoReset);

_ = Task.Run(DoReset);
}

private async Task DoApply()
{
if (RushLoadout is RushLoadout loadout)
{
var configuration = Locator.Current.RequireService<LauncherConfiguration>();
await GameUtils.SaveRushLoadout(loadout, configuration.Game);
}
}

private async Task DoReset()
{
var configuration = Locator.Current.RequireService<LauncherConfiguration>();
var loadouts = (await GameUtils.GetRushLoadouts(configuration.Game)).ToList();

RushLoadouts.Clear();
RushLoadouts.AddRange(loadouts);
RushLoadout = RushLoadouts.Items.First();
}
}
2 changes: 1 addition & 1 deletion GiganticEmu.Launcher/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public MainWindow()
this.OneWayBind(ViewModel,
viewModel => viewModel.CurrentPage,
view => view.ButtonSettings.IsVisible,
value => value is AppViewModel.Page.Login or AppViewModel.Page.Main
value => value is AppViewModel.Page.Login or AppViewModel.Page.Main or AppViewModel.Page.Connect
)
.DisposeWith(disposables);

Expand Down
2 changes: 1 addition & 1 deletion GiganticEmu.Launcher/Views/Settings/LinuxSettings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<Grid
KeyboardNavigation.TabNavigation="Cycle"
VerticalAlignment="Top"
VerticalAlignment="Center"
ColumnDefinitions="* Auto *"
RowDefinitions="Auto Auto Auto">

Expand Down
2 changes: 1 addition & 1 deletion GiganticEmu.Launcher/Views/Settings/MainSettings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<Grid
KeyboardNavigation.TabNavigation="Cycle"
VerticalAlignment="Top"
VerticalAlignment="Center"
ColumnDefinitions="* Auto *"
RowDefinitions="Auto Auto Auto Auto Auto">

Expand Down
251 changes: 251 additions & 0 deletions GiganticEmu.Launcher/Views/Settings/RushLoadoutSettings.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
<rxui:ReactiveUserControl
xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GiganticEmu.Launcher"
xmlns:material="using:Material.Icons.Avalonia"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rxui="http://reactiveui.net"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="GiganticEmu.Launcher.RushLoadoutSettings"
x:TypeArguments="local:RushLoadoutSettingsViewModel"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="600">

<ScrollViewer>
<ScrollViewer.Resources>
<local:UpgradeConverter x:Key="UpgradeConverter" />
<DataTemplate x:Key="UpgradeItemTemplate">
<TextBlock>
<TextBlock.Text>
<Binding Converter="{StaticResource UpgradeConverter}"/>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ScrollViewer.Resources>

<Grid
KeyboardNavigation.TabNavigation="Cycle"
VerticalAlignment="Center"
ColumnDefinitions="* Auto *"
RowDefinitions="Auto Auto Auto Auto Auto Auto Auto Auto Auto Auto Auto Auto">

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="0">
Loadout
</TextBlock>
<ComboBox
Name="Loadout"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="0">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} [{1}]">
<Binding Path="Hero" />
<Binding Path="Index" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="1">
Upgrade 1
</TextBlock>
<ComboBox
Name="Upgrade1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="1"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="2">
Upgrade 2
</TextBlock>
<ComboBox
Name="Upgrade2"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="2"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="3">
Upgrade 3
</TextBlock>
<ComboBox
Name="Upgrade3"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="3"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="4">
Upgrade 4
</TextBlock>
<ComboBox
Name="Upgrade4"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="4"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="5">
Upgrade 5
</TextBlock>
<ComboBox
Name="Upgrade5"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="5"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="6">
Upgrade 6
</TextBlock>
<ComboBox
Name="Upgrade6"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="6"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="7">
Upgrade 7
</TextBlock>
<ComboBox
Name="Upgrade7"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="7"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="8">
Upgrade 8
</TextBlock>
<ComboBox
Name="Upgrade8"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="8"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="9">
Upgrade 9
</TextBlock>
<ComboBox
Name="Upgrade9"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="9"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="10">
Upgrade 10
</TextBlock>
<ComboBox
Name="Upgrade10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="10"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />

<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0 10 0 10"
Grid.Column="0"
Grid.Row="11"
>
Talent
</TextBlock>
<ComboBox
Name="Talent"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="200"
Grid.Column="2"
Grid.Row="11"
ItemTemplate="{StaticResource UpgradeItemTemplate}" />
</Grid>
</ScrollViewer>
</rxui:ReactiveUserControl>
Loading

0 comments on commit 90bd7d8

Please sign in to comment.