-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to backup additional world files used by mods. Window no…
…w remembers dimensions.
- Loading branch information
1 parent
43f6ffc
commit bafde27
Showing
14 changed files
with
348 additions
and
49 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
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,28 @@ | ||
<Window x:Class="ValheimSaveShield.ExtraWorldFileEditWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:ValheimSaveShield" | ||
mc:Ignorable="d" | ||
xmlns:ui="http://schemas.modernwpf.com/2019" | ||
ui:WindowHelper.UseModernWindowStyle="True" | ||
Title="File Extension" SizeToContent="Height" Width="200" ResizeMode="NoResize" FocusManager.FocusedElement="{Binding ElementName=txtExtension}"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
<TextBox x:Name="txtExtension" Margin="5" Grid.Row="0" /> | ||
<Grid Grid.Row="1"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Button x:Name="btnOK" Content="OK" Margin="5" Grid.Column="1" Click="btnOK_Click"/> | ||
<Button x:Name="btnCancel" Content="Cancel" Margin="5" Grid.Column="2" Click="btnCancel_Click"/> | ||
</Grid> | ||
</Grid> | ||
</Window> |
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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
|
||
namespace ValheimSaveShield | ||
{ | ||
/// <summary> | ||
/// Interaction logic for ExtraWorldFileEditWindow.xaml | ||
/// </summary> | ||
public partial class ExtraWorldFileEditWindow : Window | ||
{ | ||
public ExtraWorldFileEditWindow(string ext) | ||
{ | ||
InitializeComponent(); | ||
if (ext != null) txtExtension.Text = ext; | ||
} | ||
public ExtraWorldFileEditWindow() : this(null) { } | ||
|
||
private void btnCancel_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DialogResult = false; | ||
Close(); | ||
} | ||
|
||
private void btnOK_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DialogResult = true; | ||
Tag = txtExtension.Text; | ||
Close(); | ||
} | ||
} | ||
} |
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,57 @@ | ||
<Window x:Class="ValheimSaveShield.ExtraWorldFilesWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:ValheimSaveShield" | ||
mc:Ignorable="d" | ||
xmlns:ui="http://schemas.modernwpf.com/2019" | ||
ui:WindowHelper.UseModernWindowStyle="True" | ||
Title="Extra World Files" Height="350" Width="400"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="*"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
<Expander x:Name="expTip" Header="Instructions" Margin="10" Grid.Row="0"> | ||
<TextBlock TextWrapping="Wrap" Margin="10"> | ||
If you're using a mod that generates additional files in your worlds folder that you want backed up, you can list the additional file extensions here. To be supported, the additional world files must adhere to the Worldname.ext naming format where Worldname is the name of your world and .ext is the extension of the file. | ||
<LineBreak/> | ||
<LineBreak/> | ||
For example: to back up an .ext file, you would add .ext to the list below. | ||
</TextBlock> | ||
</Expander> | ||
<ListBox x:Name="lstExtensions" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> | ||
<ListBox.ContextMenu> | ||
<ContextMenu x:Name="menuExtensions" Opened="menuExtensions_Opened"> | ||
<MenuItem x:Name="menuAdd" Header="Add" Click="menuAdd_Click"> | ||
<MenuItem.Icon> | ||
<Image Source="Resources/Add_32x.png"/> | ||
</MenuItem.Icon> | ||
</MenuItem> | ||
<MenuItem x:Name="menuEdit" Header="Edit" Click="menuEdit_Click"> | ||
<MenuItem.Icon> | ||
<Image Source="Resources/Edit_32x.png"/> | ||
</MenuItem.Icon> | ||
</MenuItem> | ||
<MenuItem x:Name="menuRemove" Header="Remove" Click="menuRemove_Click"> | ||
<MenuItem.Icon> | ||
<Image Source="Resources/Remove_32x.png"/> | ||
</MenuItem.Icon> | ||
</MenuItem> | ||
</ContextMenu> | ||
</ListBox.ContextMenu> | ||
</ListBox> | ||
<Grid Grid.Row="2"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Button x:Name="btnSave" Content="Save" Margin="10" Grid.Column="1" Click="btnSave_Click"/> | ||
<Button x:Name="btnCancel" Content="Cancel" Margin="10" Grid.Column="2" Click="btnCancel_Click"/> | ||
</Grid> | ||
</Grid> | ||
</Window> |
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,99 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
|
||
namespace ValheimSaveShield | ||
{ | ||
/// <summary> | ||
/// Interaction logic for ExtraWorldFilesWindow.xaml | ||
/// </summary> | ||
public partial class ExtraWorldFilesWindow : Window | ||
{ | ||
public ExtraWorldFilesWindow() | ||
{ | ||
InitializeComponent(); | ||
foreach (var ext in Properties.Settings.Default.WorldFileExtensions) | ||
{ | ||
lstExtensions.Items.Add(ext); | ||
} | ||
} | ||
|
||
private void menuExtensions_Opened(object sender, RoutedEventArgs e) | ||
{ | ||
if (lstExtensions.SelectedIndex > -1) | ||
{ | ||
menuEdit.Visibility = Visibility.Visible; | ||
menuRemove.Visibility = Visibility.Visible; | ||
} | ||
else | ||
{ | ||
menuEdit.Visibility = Visibility.Collapsed; | ||
menuRemove.Visibility = Visibility.Collapsed; | ||
} | ||
} | ||
|
||
private void btnSave_Click(object sender, RoutedEventArgs e) | ||
{ | ||
Properties.Settings.Default.WorldFileExtensions.Clear(); | ||
foreach (var ext in lstExtensions.Items) | ||
{ | ||
Properties.Settings.Default.WorldFileExtensions.Add(ext.ToString()); | ||
} | ||
Properties.Settings.Default.Save(); | ||
DialogResult = true; | ||
Close(); | ||
} | ||
|
||
private void btnCancel_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DialogResult = false; | ||
Close(); | ||
} | ||
|
||
private void menuRemove_Click(object sender, RoutedEventArgs e) | ||
{ | ||
lstExtensions.Items.Remove(lstExtensions.SelectedItem); | ||
} | ||
|
||
private void menuAdd_Click(object sender, RoutedEventArgs e) | ||
{ | ||
var editWin = new ExtraWorldFileEditWindow(); | ||
editWin.Owner = this; | ||
editWin.WindowStartupLocation = WindowStartupLocation.CenterOwner; | ||
if (editWin.ShowDialog().GetValueOrDefault()) | ||
{ | ||
var ext = editWin.Tag.ToString(); | ||
if (ext.IndexOf(".") != 0) { | ||
ext = "." + ext; | ||
} | ||
lstExtensions.Items.Add(ext); | ||
} | ||
} | ||
|
||
private void menuEdit_Click(object sender, RoutedEventArgs e) | ||
{ | ||
var editWin = new ExtraWorldFileEditWindow(lstExtensions.SelectedItem.ToString()); | ||
editWin.Owner = this; | ||
editWin.WindowStartupLocation = WindowStartupLocation.CenterOwner; | ||
if (editWin.ShowDialog().GetValueOrDefault()) | ||
{ | ||
var ext = editWin.Tag.ToString(); | ||
if (ext.IndexOf(".") != 0) | ||
{ | ||
ext = "." + ext; | ||
} | ||
lstExtensions.Items[lstExtensions.SelectedIndex] = ext; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.