-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic support for modifying rush loadouts
- Loading branch information
Showing
11 changed files
with
632 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
49
GiganticEmu.Launcher/ViewModels/RushLoadoutSettingsViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
251 changes: 251 additions & 0 deletions
251
GiganticEmu.Launcher/Views/Settings/RushLoadoutSettings.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.