Fr33dan / GPSaveConverter

Utility to transfer save files between the games installed from the Xbox app and other storefronts. https://ko-fi.com/fr33dan
342 stars 35 forks source link

Use modernized folder selection dialog for selecting non-xbox location #86

Closed FlaminSarge closed 4 months ago

FlaminSarge commented 5 months ago

Also handle missing data from PCGamingWiki properly. Also sets dialog's starting path to the existing path if any. Note if placeholders like %USERPROFILE% are in the existing path, only the filename value (folder name value) will get filled in, rather than auto-navigating to the existing path.

This pulls in https://github.com/ookii-dialogs/ookii-dialogs-winforms to create the dialog as we aim to support .NET 4.6 (which Windows ships with) and .NET 5 is when Microsoft made FolderBrowserDialog not-awful.

Note: According to https://github.com/ookii-dialogs/ookii-dialogs-winforms/releases, the library dropped support for .NET 4.6.1 (leaving only 4.6.2) with v4.0.0. Windows 10 comes with .NET 4.6 by default, with different updates having different versions. I do not think this will be a concern, but worst case we downgrade to ookii 3.0.0 if anyone raises an issue. Or we say "Requires Windows 10 1607 update".

FlaminSarge commented 5 months ago

@Fr33dan any idea if there's a good way to expand %USERPROFILE% to the correct path, but then convert it back once the path is selected? (Will probably attempt it in a separate PR)

FlaminSarge commented 5 months ago

I have a followup PR to this (after this gets merged) that changes the Dialog box that pops up every time you select a game without mappings into a warning icon that flashes next to the Select Non-Steam folder button

Fr33dan commented 4 months ago

Okay some clarification on what .NET/,NET Framework versions are acceptable. I think there is some confusion on the difference between the two. .NET is a package of extensions that is installed on top of the .NET Framework. Only the .NET Framework comes packaged with Windows so anything requiring .NET and not just .NET Framework is off the table.

I want it to be built into Windows for ease, but I am comfortable with requiring users to have Windows reasonably up to date. According to MS's documentation, .NET Framework 4.8.2 has been built in since the October 2020 update. 4 years is plenty of time to be comfortable using that.

Now with all that said on to the actual content of this PR. It looks good. Booted it up and tried it and it works as intended.

Fr33dan commented 4 months ago

Just realized I never answered your question on the path. You could get %USERPROFILE% into a string using Environment.GetEnvironmentVariable(). Then do a replace on the path from the dialog. If you do that, I would also do %APPDATA%, %LOCALAPPDATA%, and %PROGRAMDATA% just in case.

Actually you probably want to do those first and then %USERPROFILE% last. You would want to do the replacements deepest folders first to get the shortest final path. After you replace the shorter path the longer one won't be found to replace. Since the other ones are likely to be within the user profile it's going to be the shallowest folder. The others aren't likely to contain one other so beyond %USERPROFILE% being last the order shouldn't matter.

FlaminSarge commented 4 months ago

Okay some clarification on what .NET/,NET Framework versions are acceptable. I think there is some confusion on the difference between the two. .NET is a package of extensions that is installed on top of the .NET Framework. Only the .NET Framework comes packaged with Windows so anything requiring .NET and not just .NET Framework is off the table.

That explains my confusion looking at the docs. Hopefully I was correct on the versions and just misnaming them (looks like that library also misnamed them).

Fr33dan commented 4 months ago

I actually forgot they were different until I starting looking things up and it all came back to me. Been in Python land with my day job lately so the finer points of C# are faded in my mind.