mirror of
https://github.com/fadden/6502bench.git
synced 2025-07-02 01:23:53 +00:00
Add simple SGEC reader
SourceGen Edit Commands is a feature that allows you to generate commands into a file and have SourceGen apply them to the current project. I'm not expecting this to be used by anyone but me, so for now I'm just adding an entry to the debug menu that can read comments out of a file. Also, fixed a bug in the re-centering min/max code that prevented it from working on trivial shapes. Also, renamed the atari-avg visualizer to atari-avg-bz, with the expectation that one day somebody might want to create a variant for newer games.
This commit is contained in:
@ -4187,7 +4187,7 @@ namespace SourceGen {
|
||||
string basPathName = Path.GetFullPath(fileDlg.FileName);
|
||||
try {
|
||||
data = File.ReadAllBytes(basPathName);
|
||||
} catch (Exception ex) {
|
||||
} catch (IOException ex) {
|
||||
// not expecting this to happen
|
||||
MessageBox.Show(ex.Message);
|
||||
return;
|
||||
@ -4201,6 +4201,66 @@ namespace SourceGen {
|
||||
showTextDlg.ShowDialog();
|
||||
}
|
||||
|
||||
public void Debug_ApplyEditCommands() {
|
||||
OpenFileDialog fileDlg = new OpenFileDialog() {
|
||||
Filter = Res.Strings.FILE_FILTER_SGEC + "|" + Res.Strings.FILE_FILTER_ALL,
|
||||
FilterIndex = 1
|
||||
};
|
||||
if (fileDlg.ShowDialog() != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
string sgecPathName = Path.GetFullPath(fileDlg.FileName);
|
||||
string[] lines;
|
||||
try {
|
||||
lines = File.ReadAllLines(sgecPathName);
|
||||
} catch (IOException ex) {
|
||||
// not expecting this to happen
|
||||
MessageBox.Show(ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeSet cs = new ChangeSet(1);
|
||||
|
||||
List<int> changed = new List<int>(lines.Length);
|
||||
|
||||
string setComment = "set-comment +";
|
||||
foreach (string line in lines) {
|
||||
if (!line.StartsWith(setComment)) {
|
||||
Debug.WriteLine("Ignoring " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
int offset;
|
||||
try {
|
||||
offset = Convert.ToInt32(line.Substring(setComment.Length, 6), 16);
|
||||
} catch (Exception ex) {
|
||||
Debug.WriteLine("Failed on " + line);
|
||||
MessageBox.Show(ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (changed.Contains(offset)) {
|
||||
Debug.WriteLine("Skipping repeated entry +" + offset.ToString("X6"));
|
||||
continue;
|
||||
}
|
||||
|
||||
string oldComment = mProject.Comments[offset];
|
||||
string newComment = line.Substring(setComment.Length + 7);
|
||||
if (!string.IsNullOrEmpty(oldComment)) {
|
||||
Debug.WriteLine("Replacing comment +" + offset.ToString("x6") +
|
||||
" '" + oldComment + "'");
|
||||
}
|
||||
|
||||
UndoableChange uc = UndoableChange.CreateCommentChange(offset,
|
||||
oldComment, newComment);
|
||||
cs.Add(uc);
|
||||
changed.Add(offset);
|
||||
}
|
||||
|
||||
ApplyUndoableChanges(cs);
|
||||
}
|
||||
|
||||
public void Debug_ApplyPlatformSymbols() {
|
||||
ChangeSet cs = new ChangeSet(1);
|
||||
|
||||
|
Reference in New Issue
Block a user