From bf310d17bc9c2e2f791177aa64e6a011e5d592db Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 8 May 2019 18:00:17 -0700 Subject: [PATCH] Load a hard-coded project file Fixed some stuff that crashed. The project is loaded but nothing visually interesting happens yet. I'm still not entirely sure what the deal with declaring resources is, but it seems you can either declare a ResourceDictionary and put everything in it, or you can declare a bunch of items, which are then implicitly placed in a ResourceDictionary. This matters if you want to have your string definitions merged in with everything else. All of the examples I found did one thing or the other, not both at once, so it took some fiddling. Yay WPF. --- SourceGenWPF/App.xaml | 4 ++-- SourceGenWPF/ExternalFile.cs | 6 ++++++ SourceGenWPF/MainController.cs | 7 ++++--- SourceGenWPF/ProjWin/MainWindow.xaml.cs | 2 ++ SourceGenWPF/ProjectFile.cs | 4 ++-- SourceGenWPF/Res/Strings.xaml | 4 ++-- SourceGenWPF/Res/Strings.xaml.cs | 8 ++++---- SourceGenWPF/RuntimeDataAccess.cs | 4 ++++ 8 files changed, 26 insertions(+), 13 deletions(-) diff --git a/SourceGenWPF/App.xaml b/SourceGenWPF/App.xaml index 73ab575..53b96ad 100644 --- a/SourceGenWPF/App.xaml +++ b/SourceGenWPF/App.xaml @@ -19,9 +19,9 @@ limitations under the License. xmlns:local="clr-namespace:SourceGenWPF" StartupUri="ProjWin/MainWindow.xaml"> - Consolas + + Consolas - diff --git a/SourceGenWPF/ExternalFile.cs b/SourceGenWPF/ExternalFile.cs index 39de2fc..3d06f20 100644 --- a/SourceGenWPF/ExternalFile.cs +++ b/SourceGenWPF/ExternalFile.cs @@ -202,6 +202,12 @@ namespace SourceGenWPF { switch (mIdentLocation) { case Location.RuntimeDir: dir = RuntimeDataAccess.GetDirectory(); + if (string.IsNullOrEmpty(dir)) { + // Could happen if we can't find the runtime data directory, though + // we probably should've failed before now. + Debug.Assert(false); + return null; + } subdirAllowed = true; break; case Location.ProjectDir: diff --git a/SourceGenWPF/MainController.cs b/SourceGenWPF/MainController.cs index c126fa0..5e08f1f 100644 --- a/SourceGenWPF/MainController.cs +++ b/SourceGenWPF/MainController.cs @@ -184,9 +184,10 @@ namespace SourceGenWPF { public void OpenRecentProject(int projIndex) { - //if (DoClose()) { - // DoOpenFile(mRecentProjectPaths[projIndex]); - //} + if (DoClose()) { + //DoOpenFile(mRecentProjectPaths[projIndex]); + DoOpenFile(@"C:\Src\6502bench\EXTRA\ZIPPY#ff2000.dis65"); + } } /// diff --git a/SourceGenWPF/ProjWin/MainWindow.xaml.cs b/SourceGenWPF/ProjWin/MainWindow.xaml.cs index 8555727..b339d19 100644 --- a/SourceGenWPF/ProjWin/MainWindow.xaml.cs +++ b/SourceGenWPF/ProjWin/MainWindow.xaml.cs @@ -42,6 +42,8 @@ namespace SourceGenWPF.ProjWin { public MainWindow() { InitializeComponent(); + // TODO: verify that RuntimeData dir is accessible + mUI = new MainController(); } diff --git a/SourceGenWPF/ProjectFile.cs b/SourceGenWPF/ProjectFile.cs index 6163dfb..5574063 100644 --- a/SourceGenWPF/ProjectFile.cs +++ b/SourceGenWPF/ProjectFile.cs @@ -620,7 +620,7 @@ namespace SourceGenWPF { } if (intKey < 0 || intKey + dfd.Length > spf.FileDataLength) { report.Add(FileLoadItem.Type.Warning, - string.Format(Res.Strings.ERR_BAD_FD_FMT, intKey)); + string.Format(Res.Strings.ERR_BAD_FD, intKey)); continue; } @@ -675,7 +675,7 @@ namespace SourceGenWPF { subFormat = (FormatDescriptor.SubType)Enum.Parse( typeof(FormatDescriptor.SubType), sfd.SubFormat); } catch (ArgumentException) { - report.Add(FileLoadItem.Type.Warning, Res.Strings.ERR_BAD_FD_TYPE + + report.Add(FileLoadItem.Type.Warning, Res.Strings.ERR_BAD_FD_FORMAT + ": " + sfd.Format + "/" + sfd.SubFormat); return false; } diff --git a/SourceGenWPF/Res/Strings.xaml b/SourceGenWPF/Res/Strings.xaml index 896c058..d0a5760 100644 --- a/SourceGenWPF/Res/Strings.xaml +++ b/SourceGenWPF/Res/Strings.xaml @@ -3,8 +3,8 @@ xmlns:system="clr-namespace:System;assembly=mscorlib" xmlns:local="clr-namespace:SourceGenWPF.Res"> - Bad format descriptor at +{0:x6}. - Bad format descriptor type + Bad format descriptor at +{0:x6}. + Bad format descriptor type Bad file length Invalid file identifier Bad range diff --git a/SourceGenWPF/Res/Strings.xaml.cs b/SourceGenWPF/Res/Strings.xaml.cs index 0946bea..0050d3c 100644 --- a/SourceGenWPF/Res/Strings.xaml.cs +++ b/SourceGenWPF/Res/Strings.xaml.cs @@ -18,10 +18,10 @@ using System.Windows; namespace SourceGenWPF.Res { public static class Strings { - public static string ERR_BAD_FD_FMT = - (string)Application.Current.FindResource("str_ErrBadFdFmt"); - public static string ERR_BAD_FD_TYPE = - (string)Application.Current.FindResource("str_ErrBadFdType"); + public static string ERR_BAD_FD = + (string)Application.Current.FindResource("str_ErrBadFd"); + public static string ERR_BAD_FD_FORMAT = + (string)Application.Current.FindResource("str_ErrBadFdFormat"); public static string ERR_BAD_FILE_LENGTH = (string)Application.Current.FindResource("str_ErrBadFileLength"); public static string ERR_BAD_IDENT = diff --git a/SourceGenWPF/RuntimeDataAccess.cs b/SourceGenWPF/RuntimeDataAccess.cs index 6d6eab7..8b25e1a 100644 --- a/SourceGenWPF/RuntimeDataAccess.cs +++ b/SourceGenWPF/RuntimeDataAccess.cs @@ -55,7 +55,11 @@ namespace SourceGenWPF { return sBasePath; } + // Hack during development: remove bin/Debug, and convert SourceGenWPF to SourceGen. string upTwo = Path.GetDirectoryName(Path.GetDirectoryName(baseDir)); + if (upTwo.EndsWith("WPF")) { + upTwo = upTwo.Substring(0, upTwo.Length - 3); + } tryPath = Path.Combine(upTwo, RUNTIME_DATA_FILENAME); if (Directory.Exists(tryPath)) { sBasePath = Path.GetFullPath(tryPath);