Skip to content

Commit b00a678

Browse files
authored
Merge branch 'master' into copilot/enable-metadata-editing
2 parents 22d06e0 + 3156dbb commit b00a678

4 files changed

Lines changed: 36 additions & 7 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
@@ -136,15 +136,17 @@ void ShowValidationMessageBox<T>(IEnumerable<T> validationErrors)
136136
"Validation failed",
137137
errorMsg,
138138
ButtonEnum.Ok,
139-
Icon.Error);
139+
Icon.Error,
140+
windowStartupLocation: WindowStartupLocation.CenterOwner);
140141
}
141142
else
142143
{
143144
box = MessageBoxManager.GetMessageBoxStandard(
144145
"Validation succeeded",
145146
"✔ No issues found. Object is valid.",
146147
ButtonEnum.Ok,
147-
Icon.Success);
148+
Icon.Success,
149+
windowStartupLocation: WindowStartupLocation.CenterOwner);
148150
}
149151
_ = box.ShowAsync();
150152
}

Gui/Views/ExtendedPropertyGrid.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ public override bool HandlePropertyChanged(PropertyCellContext context)
117117
? (uint8_t)costIndexProperty.GetValue(target)!
118118
: (uint8_t)0;
119119

120-
var designedYearProperty = TypeDescriptor.GetProperties(target)[currencyAttr.DesignedYearPropertyName];
121-
var designedYear = designedYearProperty != null
120+
var designedYearProperty = currencyAttr.DesignedYearPropertyName is null
121+
? null
122+
: TypeDescriptor.GetProperties(target)[currencyAttr.DesignedYearPropertyName];
123+
124+
var designedYear = designedYearProperty is not null
122125
? (uint16_t)designedYearProperty.GetValue(target)!
123126
: (uint16_t)1950;
124127

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)