Skip to content

Commit de39f99

Browse files
committed
- Double click on the entry in the savegame list to load it. Yay!
- SE window now shows the name of the savegame that is being edited.
1 parent 4ef8ff3 commit de39f99

File tree

3 files changed

+109
-102
lines changed

3 files changed

+109
-102
lines changed

D-OS Save Editor/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
<ColumnDefinition Width="250"/>
155155
<ColumnDefinition/>
156156
</Grid.ColumnDefinitions>
157-
<ListBox Grid.Row="0" x:Name="SavegameListBox" Margin="0,10,10,0" SelectionChanged="SavegameListBox_OnSelectionChanged" Height="400" MaxWidth="240" Width="240"/>
157+
<ListBox Grid.Row="0" x:Name="SavegameListBox" Margin="0,10,10,0" SelectionChanged="SavegameListBox_OnSelectionChanged" Height="400" MaxWidth="240" Width="240" MouseDoubleClick="LoadButton_OnClick"/>
158158
<Button x:Name="RefreshButton" Style="{StaticResource RefreshImageButtonStyle}" Grid.Row="1" Width="20" Height="20" HorizontalAlignment="Right" Margin="0, 5,10,0" Padding="0" VerticalAlignment="Top" Click="RefreshButton_OnClick"/>
159159
<Button Content="About" Grid.Row="1" HorizontalAlignment="Left" Margin="35,30,0,0" Click="AboutButton_OnClick"/>
160160
<Button Style="{StaticResource BugReportButtonStyle}" Grid.Row="1" Width="20" Height="18" HorizontalAlignment="Left" Margin="0,30,20,0" Padding="0" VerticalAlignment="Top" Click="BugReportButton_OnClick" ToolTip="Bug report"/>

D-OS Save Editor/MainWindow.xaml.cs

Lines changed: 106 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,111 @@ private void LoadSavegamesPath(string dir)
214214
return null;
215215
}
216216

217+
private async Task LoadSavegame()
218+
{
219+
LoadButton.IsEnabled = false;
220+
221+
if (SavegameListBox.SelectedItem == null) return;
222+
223+
var unpackDir = GetTempPath() + "DOSSE" + DirectorySeparatorChar + "unpackaged";
224+
var saveGameName = ((TextBlock)SavegameListBox.SelectedItem).Uid;
225+
226+
// check backup
227+
switch (IsBackedUp(saveGameName))
228+
{
229+
case BackupStatus.None:
230+
var dlgResult = MessageBox.Show(this, "The savegame is not backed up. Do you want to make a backup first?",
231+
"No backup found.", MessageBoxButton.YesNo, MessageBoxImage.Warning);
232+
if (dlgResult == MessageBoxResult.Yes)
233+
BackupSavegame(saveGameName);
234+
break;
235+
case BackupStatus.Current:
236+
break;
237+
case BackupStatus.Old:
238+
dlgResult = MessageBox.Show(this,
239+
"The backup seems to be old because it failed checksum validation. Do you want to make a new backup?",
240+
"Old backup found", MessageBoxButton.YesNo, MessageBoxImage.Warning);
241+
if (dlgResult == MessageBoxResult.Yes)
242+
BackupSavegame(saveGameName);
243+
break;
244+
case BackupStatus.NoChecksum:
245+
dlgResult = MessageBox.Show(this,
246+
"The backup may be old because it does not have a checksum file. Do you want to make a new backup?",
247+
"No checksum file", MessageBoxButton.YesNo, MessageBoxImage.Warning);
248+
if (dlgResult == MessageBoxResult.No) return;
249+
else break;
250+
case BackupStatus.NoImage:
251+
dlgResult = MessageBox.Show(this,
252+
"The backup may be old because it does not have a checksum file. Do you want to make a new backup?",
253+
"No image file", MessageBoxButton.YesNo, MessageBoxImage.Warning);
254+
if (dlgResult == MessageBoxResult.No) return;
255+
else break;
256+
}
257+
258+
var savegame = new Savegame(
259+
DirectoryTextBox.Text + DirectorySeparatorChar + saveGameName + DirectorySeparatorChar + saveGameName + ".lsv",
260+
unpackDir,
261+
(Game)GameEditionTextBlock.Tag);
262+
263+
// unpack
264+
var progressIndicator = new ProgressIndicator($"Loading {saveGameName}", false) { Owner = Application.Current.MainWindow };
265+
var progress = new Progress<string>();
266+
progress.ProgressChanged += (o, s) =>
267+
{
268+
progressIndicator.ProgressText = s;
269+
};
270+
271+
if (_getMetaBackgroundWorker.IsBusy)
272+
progressIndicator.ProgressText = "Waiting for meta info...";
273+
274+
progressIndicator.Show();
275+
276+
while (_getMetaBackgroundWorker.IsBusy)
277+
await Task.Delay(5);
278+
279+
// TODO DNSA (Do Not Show Again) message box
280+
// version check
281+
if (MainWindowData.Meta.IsOutdatedVersion)
282+
{
283+
var dlgResult = MessageBox.Show(this,
284+
$"It appears that the version of your game is different from what this SE is purposely created for (ver. {DataTable.SupportedGameVersion}). As a result, changes made to your savegame may corrupt the savegame.\n\nMake sure you make a backup before continuing.",
285+
"Game version incompatible", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
286+
if (dlgResult == MessageBoxResult.Cancel)
287+
{
288+
progressIndicator.Close();
289+
return;
290+
}
291+
292+
}
293+
// mod check
294+
if (MainWindowData.Meta.IsModWarning)
295+
{
296+
var dlgResult = MessageBox.Show(this,
297+
"It appears that you have used mods. As a result, changes made to your savegame may corrupt the savegame.\n\nMake sure you make a backup before continuing.",
298+
"Mods found", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
299+
if (dlgResult == MessageBoxResult.Cancel)
300+
{
301+
progressIndicator.Close();
302+
return;
303+
}
304+
}
305+
306+
var unpackTask = await UnpackSaveAsync(savegame, progress);
307+
progressIndicator.Close();
308+
if (!unpackTask) return;
309+
310+
SaveEditor se;
311+
try
312+
{
313+
se = new SaveEditor(savegame) { Owner = Application.Current.MainWindow };
314+
}
315+
catch
316+
{
317+
return;
318+
}
319+
se.ShowDialog();
320+
}
321+
217322
/// <summary>
218323
/// Unpacks lsv files
219324
/// </summary>
@@ -414,107 +519,7 @@ private async void SavegameListBox_OnSelectionChanged(object sender, SelectionCh
414519

415520
private async void LoadButton_OnClick(object sender, RoutedEventArgs e)
416521
{
417-
LoadButton.IsEnabled = false;
418-
419-
if (SavegameListBox.SelectedItem == null) return;
420-
421-
var unpackDir = GetTempPath() + "DOSSE" + DirectorySeparatorChar + "unpackaged";
422-
var saveGameName = ((TextBlock)SavegameListBox.SelectedItem).Uid;
423-
424-
// check backup
425-
switch (IsBackedUp(saveGameName))
426-
{
427-
case BackupStatus.None:
428-
var dlgResult = MessageBox.Show(this, "The savegame is not backed up. Do you want to make a backup first?",
429-
"No backup found.", MessageBoxButton.YesNo, MessageBoxImage.Warning);
430-
if (dlgResult == MessageBoxResult.Yes)
431-
BackupSavegame(saveGameName);
432-
break;
433-
case BackupStatus.Current:
434-
break;
435-
case BackupStatus.Old:
436-
dlgResult = MessageBox.Show(this,
437-
"The backup seems to be old because it failed checksum validation. Do you want to make a new backup?",
438-
"Old backup found", MessageBoxButton.YesNo, MessageBoxImage.Warning);
439-
if (dlgResult == MessageBoxResult.Yes)
440-
BackupSavegame(saveGameName);
441-
break;
442-
case BackupStatus.NoChecksum:
443-
dlgResult = MessageBox.Show(this,
444-
"The backup may be old because it does not have a checksum file. Do you want to make a new backup?",
445-
"No checksum file", MessageBoxButton.YesNo, MessageBoxImage.Warning);
446-
if (dlgResult == MessageBoxResult.No) return;
447-
else break;
448-
case BackupStatus.NoImage:
449-
dlgResult = MessageBox.Show(this,
450-
"The backup may be old because it does not have a checksum file. Do you want to make a new backup?",
451-
"No image file", MessageBoxButton.YesNo, MessageBoxImage.Warning);
452-
if (dlgResult == MessageBoxResult.No) return;
453-
else break;
454-
}
455-
456-
var savegame = new Savegame(
457-
DirectoryTextBox.Text + DirectorySeparatorChar + saveGameName + DirectorySeparatorChar + saveGameName + ".lsv",
458-
unpackDir,
459-
(Game)GameEditionTextBlock.Tag);
460-
461-
// unpack
462-
var progressIndicator = new ProgressIndicator($"Loading {saveGameName}", false) {Owner = Application.Current.MainWindow};
463-
var progress = new Progress<string>();
464-
progress.ProgressChanged += (o, s) =>
465-
{
466-
progressIndicator.ProgressText = s;
467-
};
468-
469-
if (_getMetaBackgroundWorker.IsBusy)
470-
progressIndicator.ProgressText = "Waiting for meta info...";
471-
472-
progressIndicator.Show();
473-
474-
while (_getMetaBackgroundWorker.IsBusy)
475-
await Task.Delay(5);
476-
477-
// TODO DNSA (Do Not Show Again) message box
478-
// version check
479-
if (MainWindowData.Meta.IsOutdatedVersion)
480-
{
481-
var dlgResult = MessageBox.Show(this,
482-
$"It appears that the version of your game is different from what this SE is purposely created for (ver. {DataTable.SupportedGameVersion}). As a result, changes made to your savegame may corrupt the savegame.\n\nMake sure you make a backup before continuing.",
483-
"Game version incompatible", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
484-
if (dlgResult == MessageBoxResult.Cancel)
485-
{
486-
progressIndicator.Close();
487-
return;
488-
}
489-
490-
}
491-
// mod check
492-
if (MainWindowData.Meta.IsModWarning)
493-
{
494-
var dlgResult = MessageBox.Show(this,
495-
"It appears that you have used mods. As a result, changes made to your savegame may corrupt the savegame.\n\nMake sure you make a backup before continuing.",
496-
"Mods found", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
497-
if (dlgResult == MessageBoxResult.Cancel)
498-
{
499-
progressIndicator.Close();
500-
return;
501-
}
502-
}
503-
504-
var unpackTask = await UnpackSaveAsync(savegame, progress);
505-
progressIndicator.Close();
506-
if (!unpackTask) return;
507-
508-
SaveEditor se;
509-
try
510-
{
511-
se = new SaveEditor(savegame) { Owner = Application.Current.MainWindow };
512-
}
513-
catch
514-
{
515-
return;
516-
}
517-
se.ShowDialog();
522+
await LoadSavegame();
518523
}
519524

520525
private void BackupButton_OnClick(object sender, RoutedEventArgs e)

D-OS Save Editor/SE/SaveEditor.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public SaveEditor(Savegame savegame)
4747
InitializeComponent();
4848
Savegame = savegame;
4949

50+
Title = $"D-OS Save Editor: {savegame.SavegameName.Substring(0,savegame.SavegameName.Length-4)}";
51+
5052
// make a copy of players
5153
try
5254
{

0 commit comments

Comments
 (0)