Skip to content

Commit 3156dbb

Browse files
committed
improve popups for deleting an object
1 parent 024a3f1 commit 3156dbb

3 files changed

Lines changed: 31 additions & 5 deletions

File tree

Gui/ViewModels/LocoTypes/BaseFileViewModel.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ async Task SaveWrapper()
111111
// note - this is the DAT file source, not the true source...
112112
if (CurrentFile.ObjectSource is ObjectSource.LocomotionSteam or ObjectSource.LocomotionGoG)
113113
{
114-
var box = MessageBoxManager.GetMessageBoxStandard("Confirm Save", $"{CurrentFile.FileName} is a vanilla Locomotion file - are you sure you want to overwrite it?", ButtonEnum.YesNo);
114+
var msbParams = GetDefaultParams();
115+
msbParams.ContentTitle = "Confirm Save";
116+
msbParams.ContentMessage = $"{CurrentFile.FileName} is a vanilla Locomotion file - are you sure you want to overwrite it?";
117+
msbParams.ButtonDefinitions = ButtonEnum.YesNo;
118+
msbParams.Icon = Icon.Database;
119+
120+
var box = MessageBoxManager.GetMessageBoxStandard(msbParams);
121+
115122
var result = await box.ShowAsync();
116123

117124
if (result == ButtonResult.Yes)
@@ -125,7 +132,14 @@ async Task SaveWrapper()
125132

126133
async Task DeleteWrapper()
127134
{
128-
var box = MessageBoxManager.GetMessageBoxStandard("Confirm Delete", $"Are you sure you would like to delete {CurrentFile.FileName}?", ButtonEnum.YesNo);
135+
var msbParams = GetDefaultParams();
136+
msbParams.ContentTitle = "Confirm Delete";
137+
msbParams.ContentMessage = $"Are you sure you would like to delete {CurrentFile.FileName}?";
138+
msbParams.ButtonDefinitions = ButtonEnum.YesNo;
139+
msbParams.Icon = Icon.Stop;
140+
141+
var box = MessageBoxManager.GetMessageBoxStandard(msbParams);
142+
129143
var result = await box.ShowAsync();
130144

131145
if (result == ButtonResult.Yes)
@@ -134,6 +148,16 @@ async Task DeleteWrapper()
134148
}
135149
}
136150

151+
MessageBoxStandardParams GetDefaultParams()
152+
=> new()
153+
{
154+
WindowStartupLocation = WindowStartupLocation.CenterOwner,
155+
Topmost = true,
156+
SizeToContent = SizeToContent.WidthAndHeight,
157+
ShowInCenter = true,
158+
MinHeight = 170,
159+
};
160+
137161
public string ReloadText => CurrentFile.FileLocation == FileLocation.Local ? "Reload" : "Redownload";
138162
public string SaveText => CurrentFile.FileLocation == FileLocation.Local ? "Save" : "Download";
139163
public string SaveAsText => $"{SaveText} As";

Gui/ViewModels/LocoTypes/ObjectEditorViewModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,17 @@ void ShowValidationMessageBox<T>(IEnumerable<T> validationErrors)
135135
"Validation failed",
136136
errorMsg,
137137
ButtonEnum.Ok,
138-
Icon.Error);
138+
Icon.Error,
139+
windowStartupLocation: WindowStartupLocation.CenterOwner);
139140
}
140141
else
141142
{
142143
box = MessageBoxManager.GetMessageBoxStandard(
143144
"Validation succeeded",
144145
"✔ No issues found. Object is valid.",
145146
ButtonEnum.Ok,
146-
Icon.Success);
147+
Icon.Success,
148+
windowStartupLocation: WindowStartupLocation.CenterOwner);
147149
}
148150
_ = box.ShowAsync();
149151
}

Gui/Views/MainWindow.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
<TextBlock Margin="4" HorizontalAlignment="Stretch" VerticalAlignment="Center" Text="{Binding SaveAsText}"/>
279279
</DockPanel>
280280
</Button>
281-
<Button Margin="4" Padding="2" HorizontalAlignment="Right" Classes="danger" Command="{Binding DeleteLocalFileCommand}" DockPanel.Dock="Right" HotKey="Ctrl+D" IsEnabled="{Binding IsLocalMode}" IsVisible="{Binding IsLocalMode}" ToolTip.Tip="(Ctrl+D) WARNING: this will delete your local file without asking! Only click this if you're sure you want to delete this file!">
281+
<Button Margin="4" Padding="2" HorizontalAlignment="Right" Classes="danger" Command="{Binding DeleteLocalFileCommand}" DockPanel.Dock="Right" HotKey="Ctrl+D" IsEnabled="{Binding IsLocalMode}" IsVisible="{Binding IsLocalMode}" ToolTip.Tip="(Ctrl+D) WARNING: this will delete your local file! Only click this if you're sure you want to delete this file!">
282282
<DockPanel>
283283
<materialIcons:MaterialIcon Width="24" Height="24" Margin="2" Kind="{Binding DeleteLocalFileIcon}"/>
284284
<TextBlock Margin="4" HorizontalAlignment="Stretch" VerticalAlignment="Center" Text="{Binding DeleteLocalFileText}"/>

0 commit comments

Comments
 (0)