Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Selected Mod Top Button #954

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions OpenKh.Tools.ModsManager/ViewModels/ModViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace OpenKh.Tools.ModsManager.ViewModels
{
public class ModViewModel : BaseNotifyPropertyChanged
{
public ColorThemeService ColorTheme => ColorThemeService.Instance;
private static readonly string FallbackImage = null;
private readonly ModModel _model;
private readonly IChangeModEnableState _changeModEnableState;
Expand Down
2 changes: 1 addition & 1 deletion OpenKh.Tools.ModsManager/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<MenuItem Header="Auto Update Mods" IsCheckable="True" ToolTip="When enabled Mod Manager will automatically update all mods on startup." IsChecked="{Binding AutoUpdateMods}" StaysOpenOnClick="True"/>
<MenuItem Header="Check for update" Command="{Binding CheckOpenkhUpdateCommand}"/>
<MenuItem Header="Check Mods for Updates" Command="{Binding CheckForModUpdatesCommand}"/>
<MenuItem Header="DarkMode" IsCheckable="True" IsChecked="{Binding ColorTheme.DarkMode}" StaysOpenOnClick="True"/>
<MenuItem Header="Dark Mode" IsCheckable="True" IsChecked="{Binding ColorTheme.DarkMode}" StaysOpenOnClick="True"/>
<MenuItem Header="Panacea Settings" Visibility="{Binding PanaceaSettings}">
<MenuItem Header="Enable Console" IsCheckable="True" IsChecked="{Binding PanaceaConsoleEnabled}" StaysOpenOnClick="True"/>
<MenuItem Header="Enable Debug Log" IsCheckable="True" IsChecked="{Binding PanaceaDebugLogEnabled}" IsEnabled="{Binding PanaceaConsoleEnabled}" StaysOpenOnClick="True"/>
Expand Down
4 changes: 2 additions & 2 deletions OpenKh.Tools.ModsManager/Views/ModDetailsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<UserControl.Resources>
<SolidColorBrush x:Key="textHyperlink" Color="#569CD6" />
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{Binding ColorThemeService.TextColor}"/>
<Setter Property="Foreground" Value="{Binding ColorTheme.TextColor}"/>
</Style>
<Style TargetType="Expander">
<Setter Property="Foreground" Value="{Binding ColorThemeService.TextColor}"/>
<Setter Property="Foreground" Value="{Binding ColorTheme.TextColor}"/>
</Style>
</UserControl.Resources>
<StackPanel Background="{Binding BackgroundColor}">
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
Loading