1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-05-31 22:41:37 +00:00

Add separate button for adding symbols+scripts from project

The "add platform symbol file" and "add extension script" buttons
create a file dialog with the initial directory set to the
RuntimeData directory inside the SourceGen installation directory.
This is great if you're trying to add a file from the platform
definitions, but annoying if you're trying to add it from the
project directory.

It's really convenient to not have to hunt around though, so now
there are two buttons: one for platform, one for project.  The
latter is disabled if the project is new and hasn't been saved yet.
This commit is contained in:
Andy McFadden 2019-10-09 13:24:09 -07:00
parent e1a9100a8f
commit b8e11215fa
3 changed files with 50 additions and 13 deletions

View File

@ -294,6 +294,13 @@ with SourceGen, or in the directory where the project file lives. This
is mostly to keep things manageable when projects are distributed to
other people, but also acts as a minor security check, to prevent a
wayward project from trying to open files it shouldn't.</p>
<p>Click one of the "Add Symbol Files" buttons to include one or more
symbol files in the project.
The "Add Symbol Files from Platform" button sets the directory
to the SourceGen RuntimeData directory, while "Add Symbol Files from Project"
starts in the project directory. If you haven't yet saved the project,
the latter button will be disabled. The only difference between the
buttons is the initial directory.</p>
<p>In the list, files loaded from the RuntimeData directory will be
prefixed with <code>RT:</code>. Files loaded from the project directory
will be prefixed with <code>PROJ:</code>.</p>
@ -303,15 +310,20 @@ you will receive a warning.</p>
<h3><a name="projprop-extscripts">Extension Scripts</a></h3>
<p>From here, you can add and remove extension script files.
See the <a href="advanced.html#scripts">extension scripts</a> section for
details on how extension scripts work.</p>
See the <a href="advanced.html#extension-scripts">extension scripts</a>
section for details on how extension scripts work.</p>
<p>Extension script files must live in the RuntimeData directory that comes
with SourceGen, or in the directory where the project file lives. This
is mostly to keep things manageable when projects are distributed to
other people, but also acts as a minor security check, to prevent a
wayward project from trying to open files it shouldn't.</p>
<p>Click one of the "Add Scripts" buttons to include one more scripts in
the project. The "Add Scripts from Platform" button sets the directory
to the SourceGen RuntimeData directory, while "Add Scripts from Project"
starts in the project directory. If you haven't yet saved the project,
the latter button will be disabled. The only difference between the
buttons is the initial directory.</p>
<p>In the list, files loaded from the RuntimeData directory will be
prefixed with <code>RT:</code>. Files loaded from the project directory
will be prefixed with <code>PROJ:</code>.</p>

View File

@ -211,9 +211,15 @@ limitations under the License.
ItemsSource="{Binding PlatformSymbolIdentifiers}"
SelectionChanged="List_SelectionChanged"/>
<Button Grid.Column="0" Grid.Row="2" Width="120" HorizontalAlignment="Left"
Margin="4" Content="Add Symbol Files..."
Click="AddSymbolFilesButton_Click"/>
<StackPanel Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal">
<Button Width="200" Margin="4"
Content="Add Symbol Files from Platform..."
Click="AddSymbolFilesPlatformButton_Click"/>
<Button Width="200" Margin="4"
Content="Add Symbol Files from Project..."
IsEnabled="{Binding HasProjectDir}"
Click="AddSymbolFilesProjectButton_Click"/>
</StackPanel>
<StackPanel Grid.Column="2" Grid.Row="1">
<Button Name="symbolFileUpButton" Width="75" Margin="4" Content="_Up"
@ -247,9 +253,15 @@ limitations under the License.
ItemsSource="{Binding ExtensionScriptIdentifiers}"
SelectionChanged="List_SelectionChanged"/>
<Button Grid.Column="0" Grid.Row="3" Width="120" HorizontalAlignment="Left"
Margin="4" Content="Add Scripts..."
Click="AddExtensionScriptsButton_Click"/>
<StackPanel Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Orientation="Horizontal">
<Button Width="200" Margin="4"
Content="Add Scripts from Platform..."
Click="AddExtensionScriptsPlatformButton_Click"/>
<Button Width="200" Margin="4"
Content="Add Scripts from Project..."
IsEnabled="{Binding HasProjectDir}"
Click="AddExtensionScriptsProjectButton_Click"/>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="1">
<Button Name="extensionScriptRemoveButton" Width="75" Margin="4" Content="_Remove"

View File

@ -76,6 +76,7 @@ namespace SourceGen.WpfGui {
/// Project directory, if one has been established; otherwise empty.
/// </summary>
private string mProjectDir;
public bool HasProjectDir { get { return !string.IsNullOrEmpty(mProjectDir); } }
/// <summary>
@ -714,11 +715,17 @@ namespace SourceGen.WpfGui {
}
}
private void AddSymbolFilesButton_Click(object sender, RoutedEventArgs e) {
private void AddSymbolFilesPlatformButton_Click(object sender, RoutedEventArgs e) {
AddSymbolFiles(true);
}
private void AddSymbolFilesProjectButton_Click(object sender, RoutedEventArgs e) {
AddSymbolFiles(false);
}
private void AddSymbolFiles(bool fromPlatform) {
OpenFileDialog fileDlg = new OpenFileDialog() {
Filter = PlatformSymbols.FILENAME_FILTER,
Multiselect = true,
InitialDirectory = RuntimeDataAccess.GetDirectory(),
InitialDirectory = fromPlatform ? RuntimeDataAccess.GetDirectory() : mProjectDir,
RestoreDirectory = true // doesn't seem to work?
};
if (fileDlg.ShowDialog() != true) {
@ -822,11 +829,17 @@ namespace SourceGen.WpfGui {
}
}
private void AddExtensionScriptsButton_Click(object sender, EventArgs e) {
private void AddExtensionScriptsPlatformButton_Click(object sender, RoutedEventArgs e) {
AddExtensionScripts(true);
}
private void AddExtensionScriptsProjectButton_Click(object sender, RoutedEventArgs e) {
AddExtensionScripts(false);
}
private void AddExtensionScripts(bool fromPlatform) {
OpenFileDialog fileDlg = new OpenFileDialog() {
Filter = Sandbox.ScriptManager.FILENAME_FILTER,
Multiselect = true,
InitialDirectory = RuntimeDataAccess.GetDirectory(),
InitialDirectory = fromPlatform ? RuntimeDataAccess.GetDirectory() : mProjectDir,
RestoreDirectory = true // doesn't seem to work?
};
if (fileDlg.ShowDialog() != true) {