Skip to content

Commit

Permalink
Add a button above moveselectedmodup to move selected mod to be first…
Browse files Browse the repository at this point in the history
… in the list/highest priority so you dont have to spam click if you have many mods installed
  • Loading branch information
shananas committed Dec 17, 2023
1 parent 3fe37b4 commit 994418e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class MainViewModel : BaseNotifyPropertyChanged, IChangeModEnableState
public RelayCommand AddModCommand { get; set; }
public RelayCommand RemoveModCommand { get; set; }
public RelayCommand OpenModFolderCommand { get; set; }
public RelayCommand MoveTop { get; set; }
public RelayCommand MoveUp { get; set; }
public RelayCommand MoveDown { get; set; }
public RelayCommand BuildCommand { get; set; }
Expand Down Expand Up @@ -392,6 +393,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress =>
UseShellExecute = true
});
}, _ => IsModSelected);
MoveTop = new RelayCommand(_ => MoveSelectedModTop(), _ => CanSelectedModMoveUp());
MoveUp = new RelayCommand(_ => MoveSelectedModUp(), _ => CanSelectedModMoveUp());
MoveDown = new RelayCommand(_ => MoveSelectedModDown(), _ => CanSelectedModMoveDown());
BuildCommand = new RelayCommand(async _ =>
Expand Down Expand Up @@ -702,6 +704,18 @@ private void MoveSelectedModUp()
SelectedValue = ModsList[selectedIndex];
ModEnableStateChanged();
}
private void MoveSelectedModTop()
{
var selectedIndex = ModsList.IndexOf(SelectedValue);
if (selectedIndex < 0)
return;

var item = ModsList[selectedIndex];
ModsList.RemoveAt(selectedIndex);
ModsList.Insert(selectedIndex = 0, item);
SelectedValue = ModsList[selectedIndex];
ModEnableStateChanged();
}

private async Task PatchGame(bool fastMode)
{
Expand Down
12 changes: 12 additions & 0 deletions OpenKh.Tools.ModsManager/Views/ModManagerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@
</ListBox>
<Grid Grid.Column="1">
<StackPanel VerticalAlignment="Center">
<Button Grid.Row="0" Margin="0 3 0 3" Command="{Binding MoveTop}" ToolTip="Moves Selected mod to the top.">
<Image Source="{StaticResource ExpandChevronRightGroup_16x}" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
</Image>
</Button>
<Button Grid.Row="0" Margin="0 3 0 3" Command="{Binding MoveUp}" ToolTip="Moves selected mod up increasing its priority.">
<Image Source="{StaticResource AddRowToAbove_16x}"/>
</Button>
Expand Down

0 comments on commit 994418e

Please sign in to comment.