From 6e87284ab24506620d1cc80fbc2db95c72b6b00a Mon Sep 17 00:00:00 2001
From: Karl Clinckspoor <30571394+KarlClinckspoor@users.noreply.github.com>
Date: Sat, 18 Mar 2023 21:51:38 -0300
Subject: [PATCH 1/4] Small revamp of UI with WPF. Added log, described
actions.
---
.../Editor/CompareGameObjectProperties.cs | 2 +-
.../TestRemovingLockFromAllDoorsInArk.cs | 2 +-
.../Tools/TestWhatUltimateEditorFixes.cs | 2 +-
UWRandomizerWPF/MainWindow.xaml | 50 ++++++++------
UWRandomizerWPF/MainWindow.xaml.cs | 68 +++++++++++++++----
UWRandomizerWPF/Singletons.cs | 2 +-
UWRandomizerWPF/UWRandomizerWPF.csproj | 2 +-
7 files changed, 92 insertions(+), 36 deletions(-)
diff --git a/UWRandomizerUnitTests/Editor/CompareGameObjectProperties.cs b/UWRandomizerUnitTests/Editor/CompareGameObjectProperties.cs
index 868d3c6..da6775c 100644
--- a/UWRandomizerUnitTests/Editor/CompareGameObjectProperties.cs
+++ b/UWRandomizerUnitTests/Editor/CompareGameObjectProperties.cs
@@ -5,7 +5,7 @@
using System.Reflection;
using System.Text.Json;
using NUnit.Framework;
-using UWRandomizer;
+using UWRandomizerWPF;
using UWRandomizerEditor;
using UWRandomizerEditor.LEVdotARK;
using UWRandomizerEditor.LEVdotARK.Blocks;
diff --git a/UWRandomizerUnitTests/Tools/TestRemovingLockFromAllDoorsInArk.cs b/UWRandomizerUnitTests/Tools/TestRemovingLockFromAllDoorsInArk.cs
index 4916fb4..e7a3e64 100644
--- a/UWRandomizerUnitTests/Tools/TestRemovingLockFromAllDoorsInArk.cs
+++ b/UWRandomizerUnitTests/Tools/TestRemovingLockFromAllDoorsInArk.cs
@@ -2,7 +2,7 @@
using System.Configuration;
using System.IO;
using NUnit.Framework;
-using UWRandomizer;
+using UWRandomizerWPF;
using UWRandomizerEditor.LEVdotARK;
using UWRandomizerEditor.LEVdotARK.Blocks;
using UWRandomizerEditor.LEVdotARK.GameObjects.Specifics;
diff --git a/UWRandomizerUnitTests/Tools/TestWhatUltimateEditorFixes.cs b/UWRandomizerUnitTests/Tools/TestWhatUltimateEditorFixes.cs
index e2700f7..ddbb35a 100644
--- a/UWRandomizerUnitTests/Tools/TestWhatUltimateEditorFixes.cs
+++ b/UWRandomizerUnitTests/Tools/TestWhatUltimateEditorFixes.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
using NUnit.Framework;
-using UWRandomizer;
+using UWRandomizerWPF;
using UWRandomizerEditor.LEVdotARK;
using UWRandomizerEditor.LEVdotARK.Blocks;
using UWRandomizerTools;
diff --git a/UWRandomizerWPF/MainWindow.xaml b/UWRandomizerWPF/MainWindow.xaml
index 66facba..3a3e4a7 100644
--- a/UWRandomizerWPF/MainWindow.xaml
+++ b/UWRandomizerWPF/MainWindow.xaml
@@ -1,4 +1,4 @@
-
-
-
+
+
-
+
@@ -29,39 +29,51 @@
-
-
-
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/UWRandomizerWPF/MainWindow.xaml.cs b/UWRandomizerWPF/MainWindow.xaml.cs
index 5b9d3fb..9b1101e 100644
--- a/UWRandomizerWPF/MainWindow.xaml.cs
+++ b/UWRandomizerWPF/MainWindow.xaml.cs
@@ -15,8 +15,9 @@
using System.Windows.Shapes;
using UWRandomizerEditor.LEVdotARK;
using UWRandomizerTools;
+using Path = System.Windows.Shapes.Path;
-namespace UWRandomizer;
+namespace UWRandomizerWPF;
///
/// Interaction logic for MainWindow.xaml
@@ -36,46 +37,68 @@ public MainWindow()
private void Btn_LoadLevArk_Click(object sender, RoutedEventArgs e)
{
- ark = new ArkLoader(TxtBox_PathToArk.Text);
- Stack_Tools.IsEnabled = true;
- Btn_SaveChanges.IsEnabled = true;
+ AddMsgToLog($"Attempting to load lev.ark");
+ try
+ {
+ ark = new ArkLoader(TxtBoxPathToArk.Text);
+ StackTools.IsEnabled = true;
+ BtnSaveChanges.IsEnabled = true;
+ AddMsgToLog($"Loaded lev.ark");
+ }
+ catch (Exception exp)
+ {
+ AddMsgToLog($"Error when loading lev.ark. Exception: {exp}. Choose another file.");
+ }
}
private void Btn_SetSeed_Click(object sender, RoutedEventArgs e)
{
- int.TryParse(TxtBox_SeedValue.Text, out int newSeed);
- this.seed = newSeed;
- Singletons.SeedRandomAndReset(seed);
+ AddMsgToLog($"Attempting to interpret {TxtBoxSeedValue.Text} as an integer to use as seed");
+ if (int.TryParse(TxtBoxSeedValue.Text, out var newSeed))
+ {
+ this.seed = newSeed;
+ Singletons.SeedRandomAndReset(seed);
+ AddMsgToLog($"Done replacing seed");
+ return;
+ }
+ AddMsgToLog($"Couldn't interpret {TxtBoxSeedValue.Text} as an integer");
}
private void Btn_ExportSpoilerLog_Click(object sender, RoutedEventArgs e)
{
string log = CreateSpoilerLog();
- var openFileDlg = new Microsoft.Win32.OpenFileDialog();
- bool? result = openFileDlg.ShowDialog();
+ var saveFileDialog = new Microsoft.Win32.SaveFileDialog();
+ bool? result = saveFileDialog.ShowDialog();
if (result == true)
{
- File.WriteAllText(openFileDlg.FileName, log);
+ File.WriteAllText(saveFileDialog.FileName, log);
+ AddMsgToLog($"Saved spoiler log at {saveFileDialog.FileName}");
}
else
{
File.WriteAllText(log, "./UWspoilerlog.txt");
+ AddMsgToLog($"""Saved spoiler log to {System.IO.Path.Join(Directory.GetCurrentDirectory(), "./UWspoilerlog.txt")}""");
}
}
private void Btn_ShuffleItems_Click(object sender, RoutedEventArgs e)
{
+ AddMsgToLog("In-level shuffling of items in all levels");
ShuffleItems.ShuffleAllLevels(ark, Singletons.RandomInstance, _itemSettings);
+ AddMsgToLog("Done. Check either UltimateUnderworldEditor or export the spoiler log if you want.");
}
private void Btn_RemoveAllLocks_Click(object sender, RoutedEventArgs e)
{
+ AddMsgToLog("Removing all locks from doors");
RandoTools.RemoveAllDoorReferencesToLocks(ark);
+ AddMsgToLog("Done");
}
private void Btn_BackupLevArk_Click(object sender, RoutedEventArgs e)
{
+ AddMsgToLog($"Saving LEV.ARK as LEV.ARK.BCK.");
var tempArk = new ArkLoader(ark.Path);
UWRandomizerEditor.Utils.StdSaveBuffer(tempArk, System.IO.Path.GetDirectoryName(tempArk.Path), "LEV.ARK.BCK");
}
@@ -86,23 +109,28 @@ private void Btn_Browse_Click(object sender, RoutedEventArgs e)
bool? result = openFileDlg.ShowDialog();
if (result == true)
{
- TxtBox_PathToArk.Text = openFileDlg.FileName;
+ TxtBoxPathToArk.Text = openFileDlg.FileName;
+ AddMsgToLog($"Selected file {openFileDlg.FileName}");
}
}
private void Btn_SaveChanges_Click(object sender, RoutedEventArgs e)
{
+ AddMsgToLog("Attempting to save the current lev.ark over the old one.");
UWRandomizerEditor.Utils.StdSaveBuffer(ark, System.IO.Path.GetDirectoryName(ark.Path), "LEV.ARK");
+ AddMsgToLog("Save successful.");
}
private string CreateSpoilerLog()
{
var sb = new StringBuilder();
- sb.AppendLine($"Spoiler log: lev.ark, seed {seed}");
+ AddMsgToLog("Creating spoiler log, 1-indexed.");
+ sb.AppendLine($"Spoiler log: lev.ark, seed {seed}. Entries are XY pos (starts from bottom left) and the number is the object ID.");
int level = 0; // 1 indexed
foreach (var block in ark.TileMapObjectsBlocks)
{
level++;
+ AddMsgToLog($"Processing level {level}");
sb.AppendLine($"Level {level}");
foreach (var tile in block.TileInfos)
@@ -117,6 +145,7 @@ private string CreateSpoilerLog()
}
}
+ AddMsgToLog("Done creating spoiler log string");
return sb.ToString();
}
@@ -125,9 +154,24 @@ private void Btn_RestoreLevArk_Click(object sender, RoutedEventArgs e)
string backupPath = System.IO.Path.Join(System.IO.Path.GetDirectoryName(ark.Path), "LEV.ARK.BCK");
if (File.Exists(backupPath))
{
+ AddMsgToLog($"Found backup file LEV.ARK.BCK at '{backupPath}', deleting current lev.ark");
File.Delete(ark.Path);
+ AddMsgToLog($"Renaming backup to LEV.ARK");
File.Copy(backupPath, ark.Path);
+ AddMsgToLog($"Reloading LEV.ARK");
ark = new ArkLoader(ark.Path);
+ return;
}
+ AddMsgToLog("Couldn't find backup file LEV.ARK.BCK. Didn't do anything");
+ }
+
+ private void AddMsgToLog(string message)
+ {
+ ListViewLog.Items.Add(new ListViewItem() {Content = message});
+ }
+
+ private void BtnClearLog_OnClick(object sender, RoutedEventArgs e)
+ {
+ ListViewLog.Items.Clear();
}
}
\ No newline at end of file
diff --git a/UWRandomizerWPF/Singletons.cs b/UWRandomizerWPF/Singletons.cs
index 1c9c5e1..801e44e 100644
--- a/UWRandomizerWPF/Singletons.cs
+++ b/UWRandomizerWPF/Singletons.cs
@@ -1,6 +1,6 @@
using System;
-namespace UWRandomizer;
+namespace UWRandomizerWPF;
public static class Singletons
{
diff --git a/UWRandomizerWPF/UWRandomizerWPF.csproj b/UWRandomizerWPF/UWRandomizerWPF.csproj
index 0202691..ec601ee 100644
--- a/UWRandomizerWPF/UWRandomizerWPF.csproj
+++ b/UWRandomizerWPF/UWRandomizerWPF.csproj
@@ -6,7 +6,7 @@
enable
true
0.1.0
- UWRandomizer
+ 11
From 441dfe6fc92c4b1bccf9f2802cf9852e0de1ba6b Mon Sep 17 00:00:00 2001
From: Karl Clinckspoor <30571394+KarlClinckspoor@users.noreply.github.com>
Date: Sat, 18 Mar 2023 22:08:57 -0300
Subject: [PATCH 2/4] Changed settings to create publishable file.
---
UWRandomizerWPF/UWRandomizerWPF.csproj | 2 ++
1 file changed, 2 insertions(+)
diff --git a/UWRandomizerWPF/UWRandomizerWPF.csproj b/UWRandomizerWPF/UWRandomizerWPF.csproj
index ec601ee..8eeca9e 100644
--- a/UWRandomizerWPF/UWRandomizerWPF.csproj
+++ b/UWRandomizerWPF/UWRandomizerWPF.csproj
@@ -7,6 +7,8 @@
true
0.1.0
11
+ true
+ true
From 38b6233032e9564dce29d768bba1a80d798a9235 Mon Sep 17 00:00:00 2001
From: Karl Clinckspoor <30571394+KarlClinckspoor@users.noreply.github.com>
Date: Sat, 18 Mar 2023 22:16:45 -0300
Subject: [PATCH 3/4] Added runtime identifier: win-x64
---
UWRandomizerWPF/UWRandomizerWPF.csproj | 1 +
1 file changed, 1 insertion(+)
diff --git a/UWRandomizerWPF/UWRandomizerWPF.csproj b/UWRandomizerWPF/UWRandomizerWPF.csproj
index 8eeca9e..4f40051 100644
--- a/UWRandomizerWPF/UWRandomizerWPF.csproj
+++ b/UWRandomizerWPF/UWRandomizerWPF.csproj
@@ -9,6 +9,7 @@
11
true
true
+ win-x64
From 8421eb9c1a8ce6d41b70471f63f9643c20bd1140 Mon Sep 17 00:00:00 2001
From: Karl Clinckspoor <30571394+KarlClinckspoor@users.noreply.github.com>
Date: Sat, 18 Mar 2023 22:23:46 -0300
Subject: [PATCH 4/4] Removed c# 11 reference and fixed only instance of string
literal.
---
UWRandomizerWPF/MainWindow.xaml.cs | 5 +++--
UWRandomizerWPF/UWRandomizerWPF.csproj | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/UWRandomizerWPF/MainWindow.xaml.cs b/UWRandomizerWPF/MainWindow.xaml.cs
index 9b1101e..cd03ea7 100644
--- a/UWRandomizerWPF/MainWindow.xaml.cs
+++ b/UWRandomizerWPF/MainWindow.xaml.cs
@@ -77,8 +77,9 @@ private void Btn_ExportSpoilerLog_Click(object sender, RoutedEventArgs e)
}
else
{
- File.WriteAllText(log, "./UWspoilerlog.txt");
- AddMsgToLog($"""Saved spoiler log to {System.IO.Path.Join(Directory.GetCurrentDirectory(), "./UWspoilerlog.txt")}""");
+ var tempname = "UWspoilerlog.txt";
+ File.WriteAllText(log, tempname);
+ AddMsgToLog($"Saved spoiler log to {System.IO.Path.Join(Directory.GetCurrentDirectory(), tempname)}");
}
}
diff --git a/UWRandomizerWPF/UWRandomizerWPF.csproj b/UWRandomizerWPF/UWRandomizerWPF.csproj
index 4f40051..9370e8a 100644
--- a/UWRandomizerWPF/UWRandomizerWPF.csproj
+++ b/UWRandomizerWPF/UWRandomizerWPF.csproj
@@ -6,7 +6,7 @@
enable
true
0.1.0
- 11
+ 10
true
true
win-x64