Skip to content

Conversation

@Jakz
Copy link
Collaborator

@Jakz Jakz commented Jun 18, 2018

As proposed and discussed before this PR separates choosing a system from choosing a disk type in the UI so that it is managed by two different combo boxes.

Fixes #51

@Jakz Jakz changed the title Separated of System and Type Separated of System and Disc Type Jun 18, 2018
@mnadareski mnadareski self-requested a review June 18, 2018 03:35
Copy link
Collaborator

@mnadareski mnadareski left a comment

Choose a reason for hiding this comment

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

See inline comments below.

if (currentSystem != null && currentSystem.Item2 != KnownSystem.NONE)
{

List<Tuple<string, DiscType?>> allowedDiscTypesForSystem = Utilities.Validation.GetValidDiscTypes(currentSystem.Item2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just modify what comes out of GetValidDiscTypes? It seems that would make the code cleaner.

private List<Tuple<char, string, bool>> _drives { get; set; }
private List<int> _driveSpeeds { get { return new List<int> { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 }; } }
private List<Tuple<string, KnownSystem?, DiscType?>> _systems { get; set; }
private List<Tuple<string, KnownSystem?>> _systems { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the time being, can you also have a persistent _discTypes list here as well? That helps keep track of what is being used globally.

Copy link
Collaborator Author

@Jakz Jakz Jun 18, 2018

Choose a reason for hiding this comment

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

Sure, I'll build a List<DiscType?> of all currently used types for the systems, which sounds like what we're looking for since it's just to track it.

{
Utilities.Validation.DetermineFlags(customParameters, out type, out system, out string letter, out string path);
string letter, path;
Utilities.Validation.DetermineFlags(customParameters, out type, out system, out letter, out path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you had problems with the older version of VS and this, but can you put this back to inline variable declaration? It's much cleaner that way.

FileName = dicPath,
Arguments = parameters,
},
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a pedantic nit: I leave the dangling commas so that future changes touch less code. It's something I've had to do for work so it's built in. If you don't mind returning that, I'd appreciate it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure I will but I don't guarantee to remember to put them where needed since it's not in my code taste.

case DiscType.GameCubeGameDisc:
case DiscType.GDROM:
lbl_Status.Content = string.Format("{0} discs are partially supported by DIC", Converters.DiscTypeToString(selectedDiscType));
btn_StartStop.IsEnabled = (_drives.Count > 0 ? true : false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't the DiscTypeToString calls return the same as discTypeTuple.Item1? That would reduce the number of method calls here.

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 a side effect of the refactor of the top part for the new management, just haven't modified it, but this discTypeTuple.Item1 is so unreadable, damn unnamed tuples.

string readspeed = Regex.Match(output.Substring(index), @"ReadSpeedMaximum: [0-9]+KB/sec \(([0-9]*)x\)").Groups[1].Value;
if (!Int32.TryParse(readspeed, out int speed))
int speed;
if (!Int32.TryParse(readspeed, out speed))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto here with the inlining

{
var driveTuple = cmb_DriveLetter.SelectedItem as Tuple<char, string, bool>;
var discTuple = cmb_DiscType.SelectedItem as Tuple<string, KnownSystem?, DiscType?>;
var discTuple = cmb_SystemType.SelectedItem as Tuple<string, KnownSystem?, DiscType?>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one needs to be Tuple<string, KnownSystem?>

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 we don't need to fetch anything again here since we already have selectedSystem and selectedDiscType from above, I'll enhance accordingly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This would still be incorrect as cmb_SystemType.SelectedItem is a Tuple<string, KnownSystem?> and this would return null always.

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, I was actually talking about something similar in EnsureDiscInformation() method, here we need to fetch them.

mappings[Template.SaturnHeaderField] = GetSaturnHeader(GetFirstTrack(outputDirectory, outputFilename)).ToString();
if (GetSaturnBuildInfo(mappings[Template.SaturnHeaderField], out string serial, out string version, out string buildDate))
string serial, version, buildDate;
if (GetSaturnBuildInfo(mappings[Template.SaturnHeaderField], out serial, out version, out buildDate))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto here with the inlining

case KnownSystem.MicrosoftXBOX360XDG3:
if (GetXBOXAuxInfo(combinedBase + "_disc.txt", out string dmihash, out string pfihash, out string sshash, out string ss))
string dmihash, pfihash, sshash, ss;
if (GetXBOXAuxInfo(combinedBase + "_disc.txt", out dmihash, out pfihash, out sshash, out ss))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto here with the inlining

{
if (!Int32.TryParse(parameter, out int temp))
int temp;
if (!Int32.TryParse(parameter, out temp))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto here with the inlining

@Jakz
Copy link
Collaborator Author

Jakz commented Jun 18, 2018

Ok, I should have pushed all relevant issues and tweaks.

.OrderBy(t => t.Item1)
.ToList();

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Remove any extra space in the method. Not functional, just a style thing.

Copy link
Collaborator

@mnadareski mnadareski left a comment

Choose a reason for hiding this comment

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

Looks good, can't wait to test this out!

@mnadareski mnadareski merged commit 308fad3 into SabreTools:master Jun 18, 2018
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