-
Notifications
You must be signed in to change notification settings - Fork 325
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
base: master
Are you sure you want to change the base?
Conversation
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.
|
||
foreach (var entry in archive.Entries) | ||
{ | ||
var extractPath = storagePath + "\\" + entry.FullName; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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")] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo!
There was a problem hiding this comment.
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 => |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
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.