Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement importing appx. #3

Merged
merged 4 commits into from
Feb 19, 2021
Merged

Implement importing appx. #3

merged 4 commits into from
Feb 19, 2021

Conversation

MisteFr
Copy link
Contributor

@MisteFr MisteFr commented Mar 24, 2019

Implement importing appx versions directly from the application.

Nullable<bool> result = openFileDlg.ShowDialog();
if (result == true)
{
string directory = openFileDlg.SafeFileName + " (imported)";
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a reason to add (imported) to the actual directory name?
I think that this shouldn't be appended in the dirname, but instead just appended in the display layer.

string directory = openFileDlg.SafeFileName + " (imported)";
if (Directory.Exists(directory))
{
Directory.Delete(directory, true);
Copy link
Owner

Choose a reason for hiding this comment

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

Please add a question dialog before removal.

@@ -52,6 +53,22 @@ public partial class MainWindow : Window, ICommonVersionCommands {
});
}

private async void Button_Click(object sender, RoutedEventArgs e)
Copy link
Owner

Choose a reason for hiding this comment

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

Please rename this to something that makes more sense, eg. ImportButtonClick

Copy link
Owner

Choose a reason for hiding this comment

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

Also, code style note:
This project uses inline { and } brackets. Please reconfigure your IDE to follow this codestyle and update the changes.

@@ -228,8 +245,21 @@ public partial class MainWindow : Window, ICommonVersionCommands {
});
}

private void InvokeRemove(Version v) {
Directory.Delete(v.GameDirectory, true);
private async void InvokeRemove(Version v) {
Copy link
Owner

Choose a reason for hiding this comment

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

By making this async you are introducing a significant issue - the button can now be clicked twice and the function will be invoked twice. TL;Dr you probably don't want that unless you can either add special handling for that case and/or can display the progress to user somehow.

As I believe that displaying progress for removal is out of scope for this PR this should be rewritten to remove the async prefix.

@@ -263,20 +293,28 @@ public class Versions : List<Object> {
public class Version : NotifyPropertyChangedBase {

public Version() { }
public Version(string uuid, string name, bool isBeta, ICommonVersionCommands commands) {
public Version(string uuid, string name, bool isBeta, ICommonVersionCommands commands, string directory = "") {
Copy link
Owner

Choose a reason for hiding this comment

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

Why "" instead of null?
I'd argue that in this case a separate constructor might be better as well.

string[] subdirectoryEntries = Directory.GetDirectories(".");
foreach (string subdirectory in subdirectoryEntries)
{
if (subdirectory.Contains("(imported)"))
Copy link
Owner

Choose a reason for hiding this comment

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

This should probably be replaced with a scan for directories matching the following criteria: has AppxManifest.xml and Minecraft.Windows.exe (or the older one, how was it called?) inside.

@dktapps dktapps dismissed MCMrARM’s stale review February 19, 2021 22:59

Addressed changes

@dktapps
Copy link
Collaborator

dktapps commented Feb 19, 2021

I've amended this with some UI fixes and adjustments.

@dktapps dktapps merged commit 818cfcb into MCMrARM:master Feb 19, 2021
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.

3 participants