Skip to content

Commit

Permalink
Add confirmation when deleting a custom container
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercamp committed Nov 18, 2024
1 parent 2642a97 commit 17a7250
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
11 changes: 8 additions & 3 deletions PalCalc.UI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PalCalc.UI"
StartupUri="AppWindow.xaml">
<!--
<Application.Resources>
<!--
fix for XAML binding errors involving combobox
https://gist.github.com/TobiasSekan/73a93c2dfea4a051ff72abb5218d6f8f
-->
<Application.Resources>
-->
<Style TargetType="ComboBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<!-- (same for TreeViewItem) -->
<Style TargetType="TreeViewItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</Application.Resources>
</Application>
4 changes: 4 additions & 0 deletions PalCalc.UI/Localization/LocalizationCodes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PalCalc.UI/Localization/LocalizationCodes.resx
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@
<data name="LC_CUSTOM_CONTAINER_RENAME_TITLE" xml:space="preserve">
<value />
</data>
<data name="LC_REMOVE_CUSTOM_CONTAINER_DESCRIPTION" xml:space="preserve">
<value>Label</value>
</data>
<data name="LC_REMOVE_SAVE_DESCRIPTION" xml:space="preserve">
<value>SaveLabel</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions PalCalc.UI/Localization/Localizations/en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ If disabled, the time to breed a pal is always based on the sum of the time requ
<data name="LC_RANDOM_TRAIT" xml:space="preserve">
<value>(Random)</value>
</data>
<data name="LC_REMOVE_CUSTOM_CONTAINER_DESCRIPTION" xml:space="preserve">
<value>The custom container '{Label}' will be removed.</value>
</data>
<data name="LC_REMOVE_SAVE_DESCRIPTION" xml:space="preserve">
<value>Are you sure you want to remove this save from from Pal Calc?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public CustomContainerGridViewModel(CustomContainerViewModel container)

DeleteSlotCommand = new RelayCommand<IContainerGridSlotViewModel>(
execute: item => container.Contents.Remove((item as ContainerGridCustomPalSlotViewModel)?.PalInstance),
canExecute: item => item is ContainerGridCustomPalSlotViewModel
canExecute: item => item is ContainerGridCustomPalSlotViewModel && Slots.Contains(item)
);
}

Expand Down
3 changes: 3 additions & 0 deletions PalCalc.UI/ViewModel/Inspector/SearchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public SearchViewModel(SaveGameViewModel sgvm)
var customContainer = container as CustomSearchableContainerViewModel;
if (customContainer == null) return;

if (MessageBox.Show(LocalizationCodes.LC_REMOVE_CUSTOM_CONTAINER_DESCRIPTION.Bind(customContainer.Label).Value, "", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
return;

sgvm.Customizations.CustomContainers.Remove(customContainer.Value);
}
);
Expand Down
2 changes: 0 additions & 2 deletions PalCalc.UI/ViewModel/SaveCustomizationsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ public void Dispose()
// (Auto-saves any changes with debounce. There should only ever be one instance for each save file)
public partial class SaveCustomizationsViewModel : IDisposable
{
private SaveGameViewModel save;
private Debouncer saveAction;

public SaveCustomizationsViewModel(SaveGameViewModel save)
{
this.save = save;
var data = Storage.LoadSaveCustomizations(save.Value, PalDB.LoadEmbedded());

CustomContainers = new ObservableCollection<CustomContainerViewModel>(data.CustomContainers.Select(c => new CustomContainerViewModel(c)));
Expand Down

0 comments on commit 17a7250

Please sign in to comment.