1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-09-29 16:54:50 +00:00

Implement first project properties tab ("General")

Also, added some whitespace to the layout.

Also, removed some redundant fields from the app settings editor.
This commit is contained in:
Andy McFadden 2019-07-03 14:27:54 -07:00
parent 758d95e331
commit a23b048cb4
4 changed files with 270 additions and 147 deletions

View File

@ -24,7 +24,7 @@ namespace SourceGenWPF {
/// </summary>
public static class AutoLabel {
/// <summary>
/// Auto-label style enumeration. Values were chosen to map directly to a combo box.
/// Auto-label style enumeration.
/// </summary>
public enum Style {
Unknown = -1,

View File

@ -337,63 +337,51 @@ namespace SourceGenWPF.WpfGui {
}
}
private bool mUpperHexValues;
public bool UpperHexValues {
get { return mUpperHexValues; }
get { return mSettings.GetBool(AppSettings.FMT_UPPER_HEX_DIGITS, false); }
set {
mUpperHexValues = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.FMT_UPPER_HEX_DIGITS, value);
OnPropertyChanged();
IsDirty = true;
}
}
private bool mUpperOpcodes;
public bool UpperOpcodes {
get { return mUpperOpcodes; }
get { return mSettings.GetBool(AppSettings.FMT_UPPER_OP_MNEMONIC, false); }
set {
mUpperOpcodes = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.FMT_UPPER_OP_MNEMONIC, value);
OnPropertyChanged();
IsDirty = true;
}
}
private bool mUpperPseudoOps;
public bool UpperPseudoOps {
get { return mUpperPseudoOps; }
get { return mSettings.GetBool(AppSettings.FMT_UPPER_PSEUDO_OP_MNEMONIC, false); }
set {
mUpperPseudoOps = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.FMT_UPPER_PSEUDO_OP_MNEMONIC, value);
OnPropertyChanged();
IsDirty = true;
}
}
private bool mUpperOperandA;
public bool UpperOperandA {
get { return mUpperOperandA; }
get { return mSettings.GetBool(AppSettings.FMT_UPPER_OPERAND_A, false); }
set {
mUpperOperandA = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.FMT_UPPER_OPERAND_A, value);
OnPropertyChanged();
IsDirty = true;
}
}
private bool mUpperOperandS;
public bool UpperOperandS {
get { return mUpperOperandS; }
get { return mSettings.GetBool(AppSettings.FMT_UPPER_OPERAND_S, false); }
set {
mUpperOperandS = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.FMT_UPPER_OPERAND_S, value);
OnPropertyChanged();
IsDirty = true;
}
}
private bool mUpperOperandXY;
public bool UpperOperandXY {
get { return mUpperOperandXY; }
get { return mSettings.GetBool(AppSettings.FMT_UPPER_OPERAND_XY, false); }
set {
mUpperOperandXY = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.FMT_UPPER_OPERAND_XY, value);
OnPropertyChanged();
IsDirty = true;
}
}
@ -416,24 +404,20 @@ namespace SourceGenWPF.WpfGui {
IsDirty = true;
}
private bool mSpacesBetweenBytes;
public bool SpacesBetweenBytes {
get { return mSpacesBetweenBytes; }
get { return mSettings.GetBool(AppSettings.FMT_SPACES_BETWEEN_BYTES, false); }
set {
mSpacesBetweenBytes = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.FMT_SPACES_BETWEEN_BYTES, value);
OnPropertyChanged();
IsDirty = true;
}
}
private bool mEnableDebugMenu;
public bool EnableDebugMenu {
get { return mEnableDebugMenu; }
get { return mSettings.GetBool(AppSettings.DEBUG_MENU_ENABLED, false); }
set {
mEnableDebugMenu = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.DEBUG_MENU_ENABLED, value);
OnPropertyChanged();
IsDirty = true;
}
}
@ -503,53 +487,37 @@ namespace SourceGenWPF.WpfGui {
}
// checkboxes
private bool mShowCycleCounts;
public bool ShowCycleCounts {
get { return mShowCycleCounts; }
get { return mSettings.GetBool(AppSettings.SRCGEN_SHOW_CYCLE_COUNTS, false); }
set {
if (mShowCycleCounts != value) {
mShowCycleCounts = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.SRCGEN_SHOW_CYCLE_COUNTS, value);
OnPropertyChanged();
IsDirty = true;
}
}
}
private bool mLongLabelNewLine;
public bool LongLabelNewLine {
get { return mLongLabelNewLine; }
get { return mSettings.GetBool(AppSettings.SRCGEN_LONG_LABEL_NEW_LINE, false); }
set {
if (mLongLabelNewLine != value) {
mLongLabelNewLine = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.SRCGEN_LONG_LABEL_NEW_LINE, value);
OnPropertyChanged();
IsDirty = true;
}
}
}
private bool mAddIdentComment;
public bool AddIdentComment {
get { return mAddIdentComment; }
get { return mSettings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false); }
set {
if (mAddIdentComment != value) {
mAddIdentComment = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, value);
IsDirty = true;
}
}
}
private bool mDisableLabelLocalization;
public bool DisableLabelLocalization {
get { return mDisableLabelLocalization; }
set {
if (mDisableLabelLocalization != value) {
mDisableLabelLocalization = value;
OnPropertyChanged();
mSettings.SetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, value);
IsDirty = true;
}
}
public bool DisableLabelLocalization {
get { return mSettings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false); }
set {
mSettings.SetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, value);
OnPropertyChanged();
IsDirty = true;
}
}
private void Loaded_AsmConfig() {

View File

@ -22,10 +22,17 @@ limitations under the License.
xmlns:local="clr-namespace:SourceGenWPF.WpfGui"
mc:Ignorable="d"
Title="Edit Project Properties"
Width="700" Height="440" ResizeMode="NoResize"
Width="600" Height="400" ResizeMode="NoResize"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded">
<Window.Resources>
<!-- don't center the column headers -->
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
</Style>
</Window.Resources>
<DockPanel Margin="8">
<DockPanel DockPanel.Dock="Bottom">
<Button DockPanel.Dock="Right" Name="cancelButton" Content="Cancel" IsCancel="True"
@ -51,36 +58,48 @@ limitations under the License.
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<GroupBox Header="CPU" Grid.Column="0" Grid.Row="0">
<GroupBox Header="CPU" Grid.Column="0" Grid.Row="0" Padding="2,4">
<StackPanel>
<ComboBox Name="cpuComboBox"/>
<CheckBox Content="Enable undocumented instructions"/>
<ComboBox Name="cpuComboBox" ItemsSource="{Binding CpuItems}" DisplayMemberPath="Name"
SelectionChanged="CpuComboBox_SelectionChanged"/>
<CheckBox Margin="0,4,0,0" Content="Enable undocumented instructions"
IsChecked="{Binding IncludeUndocumentedInstr}"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Entry Flags" Grid.Column="0" Grid.Row="1">
<GroupBox Header="Entry Flags" Grid.Column="0" Grid.Row="1" Padding="2,4">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Flags:"/>
<TextBlock Text="N- V- M- X- D- I- Z- C- E-"
<TextBlock Name="currentFlagsText" Margin="4,2,0,0"
Text="N- V- M- X- D- I- Z- C- E-"
FontFamily="{StaticResource GeneralMonoFont}"/>
</StackPanel>
<Button Width="75" Content="Change"/>
<Button Width="75" Content="Change" Margin="0,4,0,0"
HorizontalAlignment="Left" Click="ChangeFlagButton_Click"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Analysis Parameters" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">
<GroupBox Header="Analysis Parameters" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2"
Margin="4,0,0,0" Padding="2,4">
<StackPanel>
<CheckBox Content="Analyze uncategorized data"/>
<CheckBox Content="Seek nearby targets"/>
<TextBlock Text="Minimum characters for string:"/>
<ComboBox Name="minStringCharsComboBox"/>
<CheckBox Name="analyzeUncategorizedCheckBox" Content="Analyze uncategorized data"
IsChecked="{Binding AnalyzeUncategorizedData}"/>
<CheckBox Name="seekAltTargetCheckBox" Margin="0,4,0,0" Content="Seek nearby targets"
IsChecked="{Binding SeekNearbyTargets}"/>
<TextBlock Margin="0,8,0,0" Text="Minimum characters for string:"/>
<ComboBox Name="minStringCharsComboBox" Margin="0,2,0,0"
ItemsSource="{Binding MinCharsItems}" DisplayMemberPath="Name"
SelectionChanged="MinStringCharsComboBox_SelectionChanged"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Miscellaneous" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2">
<GroupBox Header="Miscellaneous" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"
Padding="2,4">
<DockPanel>
<TextBlock DockPanel.Dock="Left" Text="Auto-label style:"/>
<ComboBox DockPanel.Dock="Left" Name="autoLabelStyleComboBox"/>
<TextBlock DockPanel.Dock="Left" Text="Auto-label style:" Margin="0,2,8,0"/>
<ComboBox DockPanel.Dock="Left" Name="autoLabelStyleComboBox"
ItemsSource="{Binding AutoLabelItems}" DisplayMemberPath="Name"
SelectionChanged="AutoLabelStyleComboBox_SelectionChanged"/>
</DockPanel>
</GroupBox>
</Grid>
@ -95,13 +114,13 @@ limitations under the License.
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
Text="Symbols defined in project:"/>
Margin="4,0,0,0" Text="Symbols defined in project:"/>
<ListView Grid.Column="0" Grid.Row="1"
<ListView Grid.Column="0" Grid.Row="1" Margin="4,4,4,0"
FontFamily="{StaticResource GeneralMonoFont}">
<ListView.Resources>
<Style TargetType="TextBlock">
@ -122,10 +141,10 @@ limitations under the License.
</ListView>
<StackPanel Grid.Column="1" Grid.Row="1">
<Button Width="120" Content="_New Symbol..."/>
<Button Width="120" Content="_Edit Symbol..."/>
<Button Width="120" Content="_Remove"/>
<Button Width="120" Content="_Import..."/>
<Button Name="newSymbolButton" Width="120" Margin="4" Content="_New Symbol..."/>
<Button Name="editSymbolButton" Width="120" Margin="4,4" Content="_Edit Symbol..."/>
<Button Name="removeSymbolButton" Width="120" Margin="4,4" Content="_Remove"/>
<Button Name="importSymbolsButton" Width="120" Margin="4,20,4,0" Content="_Import..."/>
</StackPanel>
</Grid>
</TabItem>
@ -143,19 +162,20 @@ limitations under the License.
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Currently configured symbol files:"/>
<TextBlock Grid.Column="0" Grid.Row="0" Margin="4,0,0,0"
Text="Currently configured symbol files:"/>
<ListBox Name="symbolFilesListBox" Grid.Column="0" Grid.Row="1">
<ListBox Name="symbolFilesListBox" Grid.Column="0" Grid.Row="1" Margin="4">
</ListBox>
<Button Grid.Column="0" Grid.Row="3" Width="120" HorizontalAlignment="Left"
Content="Add Symbol Files..."/>
<Button Grid.Column="0" Grid.Row="2" Width="120" HorizontalAlignment="Left"
Margin="4" Content="Add Symbol Files..."/>
<StackPanel Grid.Column="1" Grid.Row="1">
<Button Width="75" Content="Up"/>
<Button Width="75" Content="Down"/>
<Button Width="75" Content="Remove"/>
<StackPanel Grid.Column="2" Grid.Row="1">
<Button Name="symbolFileUpButton" Width="75" Margin="4" Content="_Up"/>
<Button Name="symbolFileDownButton" Width="75" Margin="4,4" Content="_Down"/>
<Button Name="symbolFileRemoveButton" Width="75" Margin="4,20,4,0" Content="_Remove"/>
</StackPanel>
</Grid>
</TabItem>
@ -173,17 +193,18 @@ limitations under the License.
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Currently configured symbol files:"/>
<TextBlock Grid.Column="0" Grid.Row="0" Margin="4,0,0,0"
Text="Currently configured symbol files:"/>
<ListBox Name="extensionScriptsListBox" Grid.Column="0" Grid.Row="1">
<ListBox Name="extensionScriptsListBox" Grid.Column="0" Grid.Row="1" Margin="4">
</ListBox>
<Button Grid.Column="0" Grid.Row="3" Width="120" HorizontalAlignment="Left"
Content="Add Scripts..."/>
Margin="4" Content="Add Scripts..."/>
<StackPanel Grid.Column="1" Grid.Row="1">
<Button Width="75" Content="Remove"/>
<Button Name="extensionScriptRemoveButton" Width="75" Margin="4" Content="_Remove"/>
</StackPanel>
</Grid>
</TabItem>

View File

@ -17,7 +17,9 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using Asm65;
@ -88,57 +90,12 @@ namespace SourceGenWPF.WpfGui {
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
Loaded_General();
#if false
// Configure CPU chooser. This must match the order of strings in the designer.
switch (mWorkProps.CpuType) {
case CpuDef.CpuType.Cpu6502:
cpuComboBox.SelectedIndex = 0;
break;
case CpuDef.CpuType.Cpu65C02:
cpuComboBox.SelectedIndex = 1;
break;
case CpuDef.CpuType.Cpu65816:
cpuComboBox.SelectedIndex = 2;
break;
default:
Debug.Assert(false);
cpuComboBox.SelectedIndex = 0;
break;
}
undocInstrCheckBox.Checked = mWorkProps.IncludeUndocumentedInstr;
analyzeUncategorizedCheckBox.Checked =
mWorkProps.AnalysisParams.AnalyzeUncategorizedData;
seekAltTargetCheckBox.Checked =
mWorkProps.AnalysisParams.SeekNearbyTargets;
int matchLen = mWorkProps.AnalysisParams.MinCharsForString;
int selIndex;
if (matchLen == DataAnalysis.MIN_CHARS_FOR_STRING_DISABLED) {
selIndex = 0; // disabled
} else {
selIndex = matchLen - 2;
}
if (selIndex < 0 || selIndex >= minStringCharsComboBox.Items.Count) {
Debug.Assert(false, "bad MinCharsForString " + matchLen);
selIndex = 0;
}
minStringCharsComboBox.SelectedIndex = selIndex;
selIndex = (int)mWorkProps.AutoLabelStyle;
if (selIndex < 0 || selIndex >= autoLabelStyleComboBox.Items.Count) {
Debug.Assert(false, "bad AutoLabelStyle " + mWorkProps.AutoLabelStyle);
selIndex = 0;
}
autoLabelStyleComboBox.SelectedIndex = selIndex;
LoadProjectSymbols();
LoadPlatformSymbolFiles();
LoadExtensionScriptNames();
// Various callbacks will have fired while configuring controls. Reset to "clean".
mDirty = false;
UpdateControls();
#endif
}
@ -155,5 +112,182 @@ namespace SourceGenWPF.WpfGui {
NewProps = new ProjectProperties(mWorkProps);
DialogResult = true;
}
#region General
// CPU combo box items
public class CpuItem {
public string Name { get; private set; }
public CpuDef.CpuType Type { get; private set; }
public CpuItem(string name, CpuDef.CpuType type) {
Name = name;
Type = type;
}
}
private static CpuItem[] sCpuItems = {
new CpuItem("MOS 6502", CpuDef.CpuType.Cpu6502),
new CpuItem("WDC W65C02S", CpuDef.CpuType.Cpu65C02),
new CpuItem("WDC W65C816S", CpuDef.CpuType.Cpu65816),
};
public CpuItem[] CpuItems { get { return sCpuItems; } }
// Min chars for string combo box items
public class MinCharsItem {
public string Name { get; private set; }
public int Value { get; private set; }
public MinCharsItem(string name, int value) {
Name = name;
Value = value;
}
}
private static MinCharsItem[] sMinCharsItems = {
new MinCharsItem("None (disabled)", DataAnalysis.MIN_CHARS_FOR_STRING_DISABLED),
new MinCharsItem("3", 3),
new MinCharsItem("4", 4),
new MinCharsItem("5", 5),
new MinCharsItem("6", 6),
new MinCharsItem("7", 7),
new MinCharsItem("8", 8),
new MinCharsItem("9", 9),
new MinCharsItem("10", 10),
};
public MinCharsItem[] MinCharsItems { get { return sMinCharsItems; } }
// Auto-label style combo box items
public class AutoLabelItem {
public string Name { get; private set; }
public AutoLabel.Style Style { get; private set; }
public AutoLabelItem(string name, AutoLabel.Style style) {
Name = name;
Style = style;
}
}
private static AutoLabelItem[] sAutoLabelItems = {
new AutoLabelItem("Simple (\"L1234\")", AutoLabel.Style.Simple),
new AutoLabelItem("Annotated (\"W_1234\")", AutoLabel.Style.Annotated),
new AutoLabelItem("Fully Annotated (\"DWR_1234\")", AutoLabel.Style.FullyAnnotated),
};
public AutoLabelItem[] AutoLabelItems { get { return sAutoLabelItems; } }
// properties for checkboxes
public bool IncludeUndocumentedInstr {
get { return mWorkProps.IncludeUndocumentedInstr; }
set {
mWorkProps.IncludeUndocumentedInstr = value;
OnPropertyChanged();
IsDirty = true;
}
}
public bool AnalyzeUncategorizedData {
get { return mWorkProps.AnalysisParams.AnalyzeUncategorizedData; }
set {
mWorkProps.AnalysisParams.AnalyzeUncategorizedData = value;
OnPropertyChanged();
IsDirty = true;
}
}
public bool SeekNearbyTargets {
get { return mWorkProps.AnalysisParams.SeekNearbyTargets; }
set {
mWorkProps.AnalysisParams.SeekNearbyTargets = value;
OnPropertyChanged();
IsDirty = true;
}
}
private void Loaded_General() {
for (int i = 0; i < CpuItems.Length; i++) {
if (CpuItems[i].Type == mWorkProps.CpuType) {
cpuComboBox.SelectedItem = CpuItems[i];
break;
}
}
if (cpuComboBox.SelectedItem == null) {
cpuComboBox.SelectedIndex = 0;
}
for (int i = 0; i < MinCharsItems.Length; i++) {
if (MinCharsItems[i].Value == mWorkProps.AnalysisParams.MinCharsForString) {
minStringCharsComboBox.SelectedItem = MinCharsItems[i];
break;
}
}
if (minStringCharsComboBox.SelectedItem == null) {
minStringCharsComboBox.SelectedIndex = 2;
}
for (int i = 0; i < AutoLabelItems.Length; i++) {
if (AutoLabelItems[i].Style == mWorkProps.AutoLabelStyle) {
autoLabelStyleComboBox.SelectedItem = AutoLabelItems[i];
break;
}
}
if (autoLabelStyleComboBox.SelectedItem == null) {
autoLabelStyleComboBox.SelectedIndex = 0;
}
UpdateEntryFlags();
}
private void UpdateEntryFlags() {
const string FLAGS = "CZIDXMVNE"; // flags, in order low to high, plus emu bit
const string VALUES = "-?01";
StringBuilder sb = new StringBuilder(27);
StatusFlags flags = mWorkProps.EntryFlags;
for (int i = 0; i < 9; i++) {
// Want to show P reg flags (first 8) in conventional high-to-low order.
int idx = (7 - i) + (i == 8 ? 9 : 0);
int val = flags.GetBit((StatusFlags.FlagBits)idx);
sb.Append(FLAGS[idx]);
sb.Append(VALUES[val + 2]);
sb.Append(' ');
}
currentFlagsText.Text = sb.ToString();
}
private void CpuComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
CpuItem item = (CpuItem)cpuComboBox.SelectedItem;
mWorkProps.CpuType = item.Type;
IsDirty = true;
}
private void MinStringCharsComboBox_SelectionChanged(object sender,
SelectionChangedEventArgs e) {
MinCharsItem item = (MinCharsItem)minStringCharsComboBox.SelectedItem;
mWorkProps.AnalysisParams.MinCharsForString = item.Value;
IsDirty = true;
}
private void AutoLabelStyleComboBox_SelectionChanged(object sender,
SelectionChangedEventArgs e) {
AutoLabelItem item = (AutoLabelItem)autoLabelStyleComboBox.SelectedItem;
mWorkProps.AutoLabelStyle = item.Style;
IsDirty = true;
}
private void ChangeFlagButton_Click(object sender, RoutedEventArgs e) {
CpuDef cpuDef = CpuDef.GetBestMatch(mWorkProps.CpuType,
mWorkProps.IncludeUndocumentedInstr);
EditStatusFlags dlg =
new EditStatusFlags(this, mWorkProps.EntryFlags, cpuDef.HasEmuFlag);
dlg.ShowDialog();
if (dlg.DialogResult == true) {
if (mWorkProps.EntryFlags != dlg.FlagValue) {
// Flags changed.
mWorkProps.EntryFlags = dlg.FlagValue;
UpdateEntryFlags();
IsDirty = true;
}
}
}
#endregion General
}
}