Skip to content

Conversation

@Jakz
Copy link
Collaborator

@Jakz Jakz commented Jun 20, 2018

This pull request refactors the management of current path properties:

  • properties are moved in a dedicated Options file which also manage persistence
  • the handmade UI for options is removed and a dedicated OptionsWindow.xaml file is created
  • all the current interactions are bridged through new options management

This refactor is not meant to be final since Options currently relies on reflection for a fast replacement solution of actual management, but we'll fix this successively.

MainWindow.xaml Outdated
<ToolBarTray Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Height="30" HorizontalAlignment="Stretch" IsLocked="True">
<ToolBar>
<Button x:Name="tbr_Properties" Content="Properties" Command="Properties" Click="tbr_Properties_Click" CommandManager.CanExecute="tbr_Properties_CanExecute"/>
<Button x:Name="tbr_Options" Content="Options" Click="tbr_Options_Click" CommandManager.CanExecute="tbr_Options_CanExecute"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the Command="Properties" was required in some way, but I cannot confirm why.

e.CanExecute = true;
}
//_optionsWindow.Owner = this;
//_optionsWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these two lines commented out? They seem like pretty valid options to enable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented them because they didn't work as expected but probably the problem was somewhere else.

string dicPath = _options.dicPath;
string sgRawPath = _options.sgRawPath;
string psxtPath = _options.psxtPath;
string subdumpPath = _options.subdumpPath;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to set these here if you just call the _options.blahPath variables below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I did this to avoid renaming them all and keep the following code more readable. I'd avoid making string copies if it's possible in C# (eg. ref string dicPath = ref _options.dicPath) but it's a micro optimization.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the rest of the code you still reference the _options. ones, though. So if you want to make the least changes, I'd keep those variables more global and just have the setter there. Then you shouldn't have to worry. Or go the other way and remove the usage of those variables completely.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's because we're dealing with StartDumping() function which is the big boy and each path is potentially (and actually) required multiple times, this is not true in the single cases around for which aliasing the name was just redundant.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that makes sense in this case. Looks good, just need to test it.


// Validate that the required program exits
if (!File.Exists(dicPath))
// Validate that the required program exits and it's not DICUI itself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I can't spell apparently... If you can change program exits to program exists, I'd appreciate it

@mnadareski
Copy link
Collaborator

I'll have to test to see how the new window plays out with saving and loading, but the couple small comments are all I could see.

@mnadareski
Copy link
Collaborator

I was able to test locally. The new options box looks much cleaner than it did before. I also confirmed that the saving and loading of options was consistent. This is going to be a nit, but later on, it might be cool to have the output directory automatically update if you change the default. This isn't necessary for this change, just something fun for the future.

@mnadareski mnadareski merged commit de22ead into SabreTools:master Jun 20, 2018
@Jakz Jakz deleted the properties_ui_to_xaml branch June 27, 2018 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants