1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-10-31 19:04:44 +00:00

Auto-save, part 1

Added configuration option to app settings.  It's in the "code view"
tab, which isn't quite right, but none of the others fit better.

Also, force a Save As when a new project is first created.
This commit is contained in:
Andy McFadden 2024-08-02 13:47:39 -07:00
parent ef13101923
commit 3d4250cbc4
6 changed files with 58 additions and 1 deletions

View File

@ -75,7 +75,9 @@ namespace SourceGen {
public const string CLIP_LINE_FORMAT = "clip-line-format";
// Project open/save settings.
public const string PRVW_RECENT_PROJECT_LIST = "prvw-recent-project-list";
public const string PROJ_AUTO_SAVE_INTERVAL = "proj-auto-save-interval";
public const string SKIN_DARK_COLOR_SCHEME = "skin-dark-color-scheme";

View File

@ -325,6 +325,8 @@ namespace SourceGen {
// values here when that isn't the case. The point at which the setting is
// actually used is expected to do something reasonable by default.
settings.SetInt(AppSettings.PROJ_AUTO_SAVE_INTERVAL, 60); // enabled by default
settings.SetBool(AppSettings.SYMWIN_SHOW_USER, true);
settings.SetBool(AppSettings.SYMWIN_SHOW_NON_UNIQUE, false);
settings.SetBool(AppSettings.SYMWIN_SHOW_PROJECT, true);
@ -1073,6 +1075,7 @@ namespace SourceGen {
bool ok = PrepareNewProject(Path.GetFullPath(dlg.DataFileName), dlg.SystemDef);
if (ok) {
FinishPrep();
SaveProjectAs();
}
}

View File

@ -32,6 +32,9 @@ limitations under the License.
<system:String x:Key="str_AsmMismatchDataFmt">Assembled output does not match: offset +{0:x6} has value ${1:x2}, expected ${2:x2}.</system:String>
<system:String x:Key="str_AsmMismatchLengthFmt">Assembled output does not match: length is {0}, expected {1}.</system:String>
<system:String x:Key="str_AsmOutputNotFound">Expected output file wasn't created</system:String>
<system:String x:Key="str_AutoSave1Min">60 seconds</system:String>
<system:String x:Key="str_AutoSave5Min">5 minutes</system:String>
<system:String x:Key="str_AutoSaveOff">disabled</system:String>
<system:String x:Key="str_ClipformatAllColumns">All Columns</system:String>
<system:String x:Key="str_ClipformatAssemblerSource">Assembler Source</system:String>
<system:String x:Key="str_ClipformatDisassembly">Disassembly</system:String>

View File

@ -45,6 +45,12 @@ namespace SourceGen.Res {
(string)Application.Current.FindResource("str_AsmMismatchLengthFmt");
public static string ASM_OUTPUT_NOT_FOUND =
(string)Application.Current.FindResource("str_AsmOutputNotFound");
public static string AUTO_SAVE_OFF =
(string)Application.Current.FindResource("str_AutoSaveOff");
public static string AUTO_SAVE_1_MIN =
(string)Application.Current.FindResource("str_AutoSave1Min");
public static string AUTO_SAVE_5_MIN =
(string)Application.Current.FindResource("str_AutoSave5Min");
public static string CONFIRMATION_NEEDED =
(string)Application.Current.FindResource("str_ConfirmationNeeded");
public static string DATA_BANK_AUTO_FMT =

View File

@ -135,6 +135,12 @@ limitations under the License.
IsChecked="{Binding ShowCycleCountsScreen}"/>
<CheckBox Content="Use &quot;dark&quot; color scheme" Margin="0,4"
IsChecked="{Binding DarkColorScheme}"/>
<DockPanel LastChildFill="True">
<TextBlock Margin="0,3,0,0">Auto-save interval:</TextBlock>
<ComboBox Name="autoSaveComboBox" IsReadOnly="True" Margin="8,0,0,0"
ItemsSource="{Binding AutoSaveItems}" DisplayMemberPath="Title"
SelectionChanged="AutoSaveComboBox_SelectionChanged"/>
</DockPanel>
</StackPanel>
</GroupBox>

View File

@ -241,7 +241,7 @@ namespace SourceGen.WpfGui {
}
}
// NOTE: in the current implementation, the array index must match the enum value
private static ClipboardFormatItem[] sClipboardFormatItems = {
private static readonly ClipboardFormatItem[] sClipboardFormatItems = {
new ClipboardFormatItem(Res.Strings.CLIPFORMAT_ASSEMBLER_SOURCE,
MainController.ClipLineFormat.AssemblerSource),
new ClipboardFormatItem(Res.Strings.CLIPFORMAT_DISASSEMBLY,
@ -254,6 +254,26 @@ namespace SourceGen.WpfGui {
get { return sClipboardFormatItems; }
}
/// <summary>
/// Entries for the auto-save combo box.
/// </summary>
public class AutoSaveItem {
public string Title { get; private set; }
public int Interval { get; private set; }
public AutoSaveItem(string title, int interval) {
Title = title;
Interval = interval;
}
}
private static readonly AutoSaveItem[] sAutoSaveItems = {
new AutoSaveItem(Res.Strings.AUTO_SAVE_OFF, 0),
new AutoSaveItem(Res.Strings.AUTO_SAVE_1_MIN, 60),
new AutoSaveItem(Res.Strings.AUTO_SAVE_5_MIN, 300),
};
public AutoSaveItem[] AutoSaveItems { get { return sAutoSaveItems; } }
private void Loaded_CodeView() {
// Column widths. We called CaptureColumnWidths() during init, so this
// should always be a valid serialized string.
@ -289,6 +309,17 @@ namespace SourceGen.WpfGui {
clipboardFormatComboBox.SelectedIndex = clipIndex;
}
// Look for a matching auto-save interval.
int autoSaveInterval = mSettings.GetInt(AppSettings.PROJ_AUTO_SAVE_INTERVAL, 0);
int autoSaveIndex = 1; // show a non-disabled value if we don't find a match
for (int i = 0; i < sAutoSaveItems.Length; i++) {
if (sAutoSaveItems[i].Interval == autoSaveInterval) {
autoSaveIndex = i;
break;
}
}
autoSaveComboBox.SelectedIndex = autoSaveIndex;
EnableDebugMenu = mSettings.GetBool(AppSettings.DEBUG_MENU_ENABLED, false);
}
@ -419,6 +450,12 @@ namespace SourceGen.WpfGui {
IsDirty = true;
}
private void AutoSaveComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
AutoSaveItem item = (AutoSaveItem)autoSaveComboBox.SelectedItem;
mSettings.SetInt(AppSettings.PROJ_AUTO_SAVE_INTERVAL, item.Interval);
IsDirty = true;
}
public bool ShowCycleCountsScreen {
get { return mSettings.GetBool(AppSettings.FMT_SHOW_CYCLE_COUNTS, false); }
set {