-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: - First alpha version! - Significantly redesigned appearance, many elements have been improved. New design could not exist if it were not for the library DarkUI (https://github.com/RobinPerris/DarkUI) by RobinPerris (https://github.com/RobinPerris) - Added opening a dialog for selecting a folder - Added more translatable places, in particular, added translation of the text of checkboxes - Added a little more features that would not have been there if not for the redesign - Changed the option to remove unnecessary files from the RGL version of the game (this change also affects downgrader) - Minor improvements
- Loading branch information
1 parent
3cf5d8f
commit 5ecd957
Showing
13 changed files
with
2,831 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Windows.Forms; | ||
|
||
namespace JetpackDowngraderGUI | ||
{ | ||
public class FolderSelectDialog | ||
{ | ||
private string _initialDirectory; | ||
private string _title; | ||
private string _fileName = ""; | ||
public string InitialDirectory | ||
{ | ||
get { return string.IsNullOrEmpty(_initialDirectory) ? Environment.CurrentDirectory : _initialDirectory; } | ||
set { _initialDirectory = value; } | ||
} | ||
public string Title { get { return _title ?? "Select a folder"; } set { _title = value; } } | ||
public string FileName { get { return _fileName; } } | ||
public bool Show() { return Show(IntPtr.Zero); } | ||
public bool Show(IntPtr hWndOwner) | ||
{ | ||
var result = Environment.OSVersion.Version.Major >= 6 ? VistaDialog.Show(hWndOwner, InitialDirectory, Title) : ShowXpDialog(hWndOwner, InitialDirectory, Title); _fileName = result.FileName; | ||
return result.Result; | ||
} | ||
private struct ShowDialogResult | ||
{ | ||
public bool Result { get; set; } | ||
public string FileName { get; set; } | ||
} | ||
private static ShowDialogResult ShowXpDialog(IntPtr ownerHandle, string initialDirectory, string title) | ||
{ | ||
var folderBrowserDialog = new FolderBrowserDialog { Description = title, SelectedPath = initialDirectory, ShowNewFolderButton = false }; | ||
var dialogResult = new ShowDialogResult(); | ||
if (folderBrowserDialog.ShowDialog(new WindowWrapper(ownerHandle)) == DialogResult.OK) { dialogResult.Result = true; dialogResult.FileName = folderBrowserDialog.SelectedPath; } | ||
return dialogResult; | ||
} | ||
private static class VistaDialog | ||
{ | ||
private const string c_foldersFilter = "Folders|\n"; | ||
private const BindingFlags c_flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; | ||
private readonly static Assembly s_windowsFormsAssembly = typeof(FileDialog).Assembly; | ||
private readonly static Type s_iFileDialogType = s_windowsFormsAssembly.GetType("System.Windows.Forms.FileDialogNative+IFileDialog"); | ||
private readonly static MethodInfo s_createVistaDialogMethodInfo = typeof(OpenFileDialog).GetMethod("CreateVistaDialog", c_flags); | ||
private readonly static MethodInfo s_onBeforeVistaDialogMethodInfo = typeof(OpenFileDialog).GetMethod("OnBeforeVistaDialog", c_flags); | ||
private readonly static MethodInfo s_getOptionsMethodInfo = typeof(FileDialog).GetMethod("GetOptions", c_flags); | ||
private readonly static MethodInfo s_setOptionsMethodInfo = s_iFileDialogType.GetMethod("SetOptions", c_flags); | ||
private readonly static uint s_fosPickFoldersBitFlag = (uint)s_windowsFormsAssembly.GetType("System.Windows.Forms.FileDialogNative+FOS").GetField("FOS_PICKFOLDERS").GetValue(null); | ||
private readonly static ConstructorInfo s_vistaDialogEventsConstructorInfo = s_windowsFormsAssembly.GetType("System.Windows.Forms.FileDialog+VistaDialogEvents").GetConstructor(c_flags, null, new[] { typeof(FileDialog) }, null); | ||
private readonly static MethodInfo s_adviseMethodInfo = s_iFileDialogType.GetMethod("Advise"); | ||
private readonly static MethodInfo s_unAdviseMethodInfo = s_iFileDialogType.GetMethod("Unadvise"); | ||
private readonly static MethodInfo s_showMethodInfo = s_iFileDialogType.GetMethod("Show"); | ||
public static ShowDialogResult Show(IntPtr ownerHandle, string initialDirectory, string title) | ||
{ | ||
var openFileDialog = new OpenFileDialog | ||
{ | ||
AddExtension = false, | ||
CheckFileExists = false, | ||
DereferenceLinks = true, | ||
Filter = c_foldersFilter, | ||
InitialDirectory = initialDirectory, | ||
Multiselect = false, | ||
Title = title | ||
}; | ||
var iFileDialog = s_createVistaDialogMethodInfo.Invoke(openFileDialog, new object[] { }); | ||
s_onBeforeVistaDialogMethodInfo.Invoke(openFileDialog, new[] { iFileDialog }); | ||
s_setOptionsMethodInfo.Invoke(iFileDialog, new object[] { (uint)s_getOptionsMethodInfo.Invoke(openFileDialog, new object[] { }) | s_fosPickFoldersBitFlag }); | ||
var adviseParametersWithOutputConnectionToken = new[] { s_vistaDialogEventsConstructorInfo.Invoke(new object[] { openFileDialog }), 0U }; | ||
s_adviseMethodInfo.Invoke(iFileDialog, adviseParametersWithOutputConnectionToken); | ||
|
||
try | ||
{ | ||
int retVal = (int)s_showMethodInfo.Invoke(iFileDialog, new object[] { ownerHandle }); | ||
return new ShowDialogResult { Result = retVal == 0, FileName = openFileDialog.FileName }; | ||
} | ||
finally { s_unAdviseMethodInfo.Invoke(iFileDialog, new[] { adviseParametersWithOutputConnectionToken[1] }); } | ||
} | ||
} | ||
private class WindowWrapper : IWin32Window | ||
{ | ||
private readonly IntPtr _handle; | ||
public WindowWrapper(IntPtr handle) { _handle = handle; } | ||
public IntPtr Handle { get { return _handle; } } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System.Windows.Forms; | ||
|
||
namespace JetpackDowngraderGUI | ||
{ | ||
static class Program | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
5ecd957
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.