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 config import/export buttons for in game addon #1426

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

reiichi001
Copy link
Contributor

Adds buttons to import/export a zip file containing Dalamud and Plugin config. No launcher config is being handled here as this can be platform and computer specific.

Adds WPF commandline arguments to handle import/export as well for testing purposes that do not rely on gui features.

Import and Export are implemented under XIVLauncher.Common so that this can be implemented on other compatible launchers that use xlcommon.

Adds buttons to import/export a zip file containing Dalamud and Plugin config. No launcher config is being handled here as this can be platform and computer specific.

Adds WPF commandline arguments to handle import/export as well for testing purposes that do not rely on gui features.

Import and Export are implemented under XIVLauncher.Common so that this can be implemented on other compatible launchers that use xlcommon.
@reiichi001
Copy link
Contributor Author

Sample screenshots of what the GUI implementation looks like.
image
image
image
image


foreach (var entry in archive.Entries)
{
var extractPath = storagePath + "\\" + entry.FullName;
Copy link
Member

Choose a reason for hiding this comment

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

Path.Combine()?

using var archive = ZipFile.Open(inFile.FullName, ZipArchiveMode.Read);

// If we weren't on .Net Framework, we could use this...
// ZipFileExtensions.ExtractToDirectory(archive, storagePath, true);
Copy link
Member

Choose a reason for hiding this comment

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

It's probably better to go through the entries directly. Then you can also choose to delete the file if it exists - which is probably what people expect when importing a backup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My initial vision was to just overwrite from the backup, but ideally yes, a "do you want to replace this file, yes, yes to all, no, cancel" style prompt would be better. My worry here is some plugins generate TONS of files in their config directories and most users are not going to want to click yes to that every time. (ex: CharacterSync making backups of all game config for multiple characters for multiple days/launches)

This was more of a companion to the official launcher's FEA file solution, but for our config. (Although nothing prevents this from later handling game config too if we wanted to do that)

@@ -59,6 +60,12 @@ public class CmdLineOptions
[CommandLine.Option("clientlang", Required = false, HelpText = "Client language to use.")]
public ClientLanguage? ClientLanguage { get; set; }

[CommandLine.Option("exportconfig", Required = false, HelpText = "Export a zip of all config")]
Copy link
Member

Choose a reason for hiding this comment

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

Are these necessary? What's your use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not strictly needed. I just like having command args for any of the file-based features. Makes it easy for testing when I want to specify custom appdata paths to certify that it unpacks correctly.

//TODO: Localize this text like a good programmer

var importConfirmPromptResult = CustomMessageBox.Show(Loc.Localize("ConfigImportPrompt1", "XIVLauncher is going to import config from the file you selected.\n\n") + zipFile + Loc.Localize("ConfigImportPrompt2", "\n\nThis will overwrite any files that already exist.\n\nDo you want to proceed?"),
Loc.Localize("ConfigImportPromptTitle", "Import confg file?"), MessageBoxButton.YesNo);
Copy link
Member

Choose a reason for hiding this comment

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

Typo!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

confg spelling corrected. Was that the only one? Or did I miss another? (Will be included on next commit on this branch)

var window = new ConfigImportExportProgressWindow();
window.SetTitle(Loc.Localize("ConfigExportRunning", "Running config export..."));

Task.Run(async () => await DalamudAndPluginConfigImportExport.ExportConfig(Paths.RoamingPath)).ContinueWith(async task =>
Copy link
Member

Choose a reason for hiding this comment

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

This task needs a continuation. You need to observe the exception if it didn't complete successfully and hide the progress window if it's still open.

}
catch (Exception ex)
{
CustomMessageBox.Show(ex.ToString(), "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
Copy link
Member

Choose a reason for hiding this comment

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

Hide the progress window here too?

}
}

private static void AddIfExist(string entryPath, ZipArchive zip)
Copy link
Member

Choose a reason for hiding this comment

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

We already have this function in the tspack code. Maybe move to common util class?

private static void AddIfExist(FileInfo file, ZipArchive zip)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one's a little different from tspack code. I had to get a little hacky for directory handling. But that could probably still be used for tspacks too. I've moved it to a util method in xivlauncher.common.util, but the WPF app didn't really like me doing that and VS stopped giving me intellisense when I tried. I might need some handholding to get that moved properly. (It could just be my machine being annoying)

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