diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs
index d2ddcba..7943c08 100644
--- a/SourceGen/DisasmProject.cs
+++ b/SourceGen/DisasmProject.cs
@@ -120,6 +120,11 @@ namespace SourceGen {
///
public CpuDef CpuDef { get; private set; }
+ ///
+ /// If set, changes are ignored.
+ ///
+ public bool IsReadOnly { get; set; }
+
///
/// If true, plugins will execute in the main application's AppDomain instead of
/// the sandbox. Must be set before calling Initialize().
@@ -1785,6 +1790,9 @@ namespace SourceGen {
///
/// Set to push.
public void PushChangeSet(ChangeSet changeSet) {
+ if (IsReadOnly) {
+ return;
+ }
Debug.WriteLine("PushChangeSet: adding " + changeSet);
// Remove all of the "redo" entries from the current position to the end.
@@ -1850,6 +1858,9 @@ namespace SourceGen {
public UndoableChange.ReanalysisScope ApplyChanges(ChangeSet cs, bool backward,
out RangeSet affectedOffsets) {
affectedOffsets = new RangeSet();
+ if (IsReadOnly) {
+ return UndoableChange.ReanalysisScope.None;
+ }
UndoableChange.ReanalysisScope needReanalysis = UndoableChange.ReanalysisScope.None;
diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs
index 55729c8..b81f4e5 100644
--- a/SourceGen/MainController.cs
+++ b/SourceGen/MainController.cs
@@ -626,9 +626,7 @@ namespace SourceGen {
private void UpdateTitle() {
// Update main window title.
StringBuilder sb = new StringBuilder();
- sb.Append(Res.Strings.TITLE_BASE);
if (mProject != null) {
- sb.Append(" - ");
if (string.IsNullOrEmpty(mProjectPathName)) {
sb.Append(Res.Strings.TITLE_NEW_PROJECT);
} else {
@@ -639,7 +637,14 @@ namespace SourceGen {
sb.Append(" ");
sb.Append(Res.Strings.TITLE_MODIFIED);
}
+
+ if (mProject.IsReadOnly) {
+ sb.Append(" ");
+ sb.Append(Res.Strings.TITLE_READ_ONLY);
+ }
+ sb.Append(" - ");
}
+ sb.Append(Res.Strings.TITLE_BASE);
mMainWin.Title = sb.ToString();
}
@@ -1082,6 +1087,8 @@ namespace SourceGen {
if (ok != true) {
return;
}
+
+ newProject.IsReadOnly = dlg.WantReadOnly;
}
mProject = newProject;
@@ -1175,6 +1182,7 @@ namespace SourceGen {
///
/// True on success, false if the save attempt failed or was canceled.
public bool SaveProjectAs() {
+ Debug.Assert(!mProject.IsReadOnly);
SaveFileDialog fileDlg = new SaveFileDialog() {
Filter = ProjectFile.FILENAME_FILTER + "|" + Res.Strings.FILE_FILTER_ALL,
FilterIndex = 1,
@@ -1205,6 +1213,7 @@ namespace SourceGen {
///
/// True on success, false if the save attempt failed.
public bool SaveProject() {
+ Debug.Assert(!mProject.IsReadOnly);
if (string.IsNullOrEmpty(mProjectPathName)) {
return SaveProjectAs();
}
@@ -1317,8 +1326,11 @@ namespace SourceGen {
return true;
}
- public bool IsProjectOpen() {
- return mProject != null;
+ public bool IsProjectOpen {
+ get { return mProject != null; }
+ }
+ public bool IsProjectReadOnly {
+ get { return mProject != null && mProject.IsReadOnly; }
}
public void AssembleProject() {
diff --git a/SourceGen/Res/Strings.xaml b/SourceGen/Res/Strings.xaml
index e405957..759a5b3 100644
--- a/SourceGen/Res/Strings.xaml
+++ b/SourceGen/Res/Strings.xaml
@@ -53,7 +53,7 @@ limitations under the License.
Unknown Source or Type in symbolBad symbol reference partType hint not recognized
- Removing duplicate label '{0}' (offset +{1:x6})
+ Removed duplicate label '{0}' (offset +{1:x6})Failed copying {0} to {1}: {2}.The file {0} exists, but is not a directory.File Error
@@ -164,5 +164,6 @@ limitations under the License.
6502bench SourceGen(save needed)[new project]
+ *READ-ONLY*[unset]
\ No newline at end of file
diff --git a/SourceGen/Res/Strings.xaml.cs b/SourceGen/Res/Strings.xaml.cs
index b23891b..168173a 100644
--- a/SourceGen/Res/Strings.xaml.cs
+++ b/SourceGen/Res/Strings.xaml.cs
@@ -309,6 +309,8 @@ namespace SourceGen.Res {
(string)Application.Current.FindResource("str_TitleModified");
public static string TITLE_NEW_PROJECT =
(string)Application.Current.FindResource("str_TitleNewProject");
+ public static string TITLE_READ_ONLY =
+ (string)Application.Current.FindResource("str_TitleReadOnly");
public static string UNSET =
(string)Application.Current.FindResource("str_Unset");
}
diff --git a/SourceGen/RuntimeData/Help/mainwin.html b/SourceGen/RuntimeData/Help/mainwin.html
index adb8276..07c4a57 100644
--- a/SourceGen/RuntimeData/Help/mainwin.html
+++ b/SourceGen/RuntimeData/Help/mainwin.html
@@ -54,8 +54,9 @@ shown. If it's something simple, like a missing .sym65 or extension
script file, you'll be notified. If it's something more complicated,
e.g. the project has a comment on an offset that doesn't exist, you
will be warned that the problematic data has been deleted, and will be
-lost if the project is saved. You will also be given the opportunity
-to cancel the loading of the project.
+lost if the project is saved. By default, such a project will be opened
+in read-only mode, though you can override this in the dialog. You will
+also be given the opportunity to simply cancel loading the project.
The locations of the last few projects you've worked with are saved
in the application settings. You can access them from
diff --git a/SourceGen/WpfGui/MainWindow.xaml b/SourceGen/WpfGui/MainWindow.xaml
index 66ef0f3..9fdc345 100644
--- a/SourceGen/WpfGui/MainWindow.xaml
+++ b/SourceGen/WpfGui/MainWindow.xaml
@@ -264,9 +264,9 @@ limitations under the License.
+ CanExecute="CanSaveProject" Executed="SaveCmd_Executed"/>
+ CanExecute="CanSaveProject" Executed="SaveAsCmd_Executed"/>
diff --git a/SourceGen/WpfGui/MainWindow.xaml.cs b/SourceGen/WpfGui/MainWindow.xaml.cs
index 100d3c9..801ef36 100644
--- a/SourceGen/WpfGui/MainWindow.xaml.cs
+++ b/SourceGen/WpfGui/MainWindow.xaml.cs
@@ -934,7 +934,7 @@ namespace SourceGen.WpfGui {
///
///
private bool IsProjectOpen() {
- return mMainCtrl != null && mMainCtrl.IsProjectOpen();
+ return mMainCtrl != null && mMainCtrl.IsProjectOpen;
}
///
@@ -1033,6 +1033,11 @@ namespace SourceGen.WpfGui {
(counts.mCodeHints != 0 || counts.mDataHints != 0 || counts.mInlineDataHints != 0);
}
+ private void CanSaveProject(object sender, CanExecuteRoutedEventArgs e) {
+ e.CanExecute = mMainCtrl != null && mMainCtrl.IsProjectOpen &&
+ !mMainCtrl.IsProjectReadOnly;
+ }
+
private void CanToggleSingleByteFormat(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = IsProjectOpen() && mMainCtrl.CanToggleSingleByteFormat();
}
diff --git a/SourceGen/WpfGui/ProjectLoadIssues.xaml b/SourceGen/WpfGui/ProjectLoadIssues.xaml
index c9299b4..27b8664 100644
--- a/SourceGen/WpfGui/ProjectLoadIssues.xaml
+++ b/SourceGen/WpfGui/ProjectLoadIssues.xaml
@@ -25,14 +25,23 @@ limitations under the License.
SizeToContent="WidthAndHeight" ResizeMode="NoResize"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
Loaded="ProjectLoadIssues_Loaded">
+
+
+
+
+
Problems were detected while loading the project file:
-
+
Invalid data items will be discarded when you save the project.
+
diff --git a/SourceGen/WpfGui/ProjectLoadIssues.xaml.cs b/SourceGen/WpfGui/ProjectLoadIssues.xaml.cs
index d604854..31ead87 100644
--- a/SourceGen/WpfGui/ProjectLoadIssues.xaml.cs
+++ b/SourceGen/WpfGui/ProjectLoadIssues.xaml.cs
@@ -14,13 +14,28 @@
* limitations under the License.
*/
using System;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
using System.Windows;
namespace SourceGen.WpfGui {
///
/// Display errors and warnings generated while attempting to open a project.
///
- public partial class ProjectLoadIssues : Window {
+ public partial class ProjectLoadIssues : Window, INotifyPropertyChanged {
+ public bool WantReadOnly {
+ get { return mWantReadOnly; }
+ set { mWantReadOnly = value; OnPropertyChanged(); }
+ }
+ private bool mWantReadOnly;
+
+ public bool ShowSaveWarning {
+ get { return mShowItemWarning; }
+ set { mShowItemWarning = value; OnPropertyChanged(); }
+ }
+ private bool mShowItemWarning;
+
///
/// Multi-line message for text box.
///
@@ -35,10 +50,17 @@ namespace SourceGen.WpfGui {
Unknown = 0, Continue, Cancel, ContinueOrCancel
}
+ // INotifyPropertyChanged implementation
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
public ProjectLoadIssues(Window owner, string msgs, Buttons allowedButtons) {
InitializeComponent();
Owner = owner;
+ DataContext = this;
mMessages = msgs;
mAllowedButtons = allowedButtons;
@@ -52,14 +74,18 @@ namespace SourceGen.WpfGui {
okButton.IsEnabled = false;
// No point warning them about invalid data if they can't continue.
- invalidDiscardLabel.Visibility = Visibility.Hidden;
- }
- if (mAllowedButtons == Buttons.Continue) {
+ ShowSaveWarning = false;
+ } else if (mAllowedButtons == Buttons.Continue) {
// Cancel not allowed.
cancelButton.IsEnabled = false;
- // They're stuck with the problem.
- invalidDiscardLabel.Visibility = Visibility.Hidden;
+ // Problem is outside the scope of the project (e.g. bad platform symbol file),
+ // so saving the project won't change anything.
+ ShowSaveWarning = false;
+ } else {
+ Debug.Assert(mAllowedButtons == Buttons.ContinueOrCancel);
+ ShowSaveWarning = true;
+ WantReadOnly = true;
}
}