Skip to content

Commit

Permalink
GUI Version 0.3-Alpha
Browse files Browse the repository at this point in the history
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
Zalexanninev15 committed Apr 29, 2021
1 parent 3cf5d8f commit 5ecd957
Show file tree
Hide file tree
Showing 13 changed files with 2,831 additions and 302 deletions.
14 changes: 12 additions & 2 deletions languages/EN.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
[Interface]
PathLabel=Path to the game folder:
CButton=Choose
LButton=Languages
AppSettings=App Settings
[CheckBox]
Backup=Backup original files before downgrade
Shortcut=Make shortcut on Desktop
Reset=Remove GTA-SA.SET (Reset game settings and prevents crash)
GarbageCleaning=Remove unneeded files (ONLY for the version of the game from Rockstar Games Launcher)
GameReg=Register game path (Make game visible)
NoUpdates=Move game to another folder (Prevents auto-update and rehash)
Forced=Forced (ONLY for version 1.0)
DirectPlay=DirectPlay (ONLY for Windows 10)
InstallDirectX=Install DirectX
[Title]
Info=Information
Error=Error
FolderSelectDialog=Select the game folder
[InfoMsg]
Succes=Downgrade completed!
[ErrorMsg]
Expand Down
1 change: 0 additions & 1 deletion sources/Downgrader/Classes/FolderSelectDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public static ShowDialogResult Show(IntPtr ownerHandle, string 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 });
Expand Down
2 changes: 1 addition & 1 deletion sources/Downgrader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void Main(string[] args)
settings[2] = Convert.ToBoolean(cfg.GetValue("Downgrader", "CreateBackups"));
settings[6] = Convert.ToBoolean(cfg.GetValue("Downgrader", "CreateShortcut"));
settings[7] = Convert.ToBoolean(cfg.GetValue("Downgrader", "ResetGame"));
settings[14] = Convert.ToBoolean(cfg.GetValue("Downgrader", "RGLGarbage"));
settings[14] = Convert.ToBoolean(cfg.GetValue("Downgrader", "GarbageCleaning"));
settings[9] = Convert.ToBoolean(cfg.GetValue("Downgrader", "RegisterGamePath"));
settings[10] = Convert.ToBoolean(cfg.GetValue("Downgrader", "CreateNewGamePath"));
settings[12] = Convert.ToBoolean(cfg.GetValue("Downgrader", "Forced"));
Expand Down
4 changes: 2 additions & 2 deletions sources/Downgrader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
[assembly: AssemblyTrademark("Jetpack Downgrader (2020-2021)")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.11.0.5")]
[assembly: AssemblyFileVersion("1.11.0.5")]
[assembly: AssemblyVersion("1.11.5.1")]
[assembly: AssemblyFileVersion("1.11.5.1")]
85 changes: 85 additions & 0 deletions sources/GUI/Classes/FolderSelectDialog.cs
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; } }
}
}
}
6 changes: 3 additions & 3 deletions sources/GUI/Classes/INIEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public string GetValue(string aSection, string aKey)
// File.WriteAllText("text", buffer.ToString(), Encoding.Default);
// string rt = File.ReadAllText("text");
// File.Delete("text");
byte[] byteArray = Encoding.Default.GetBytes(buffer.ToString());
string rt = Encoding.UTF8.GetString(byteArray);
return rt;
byte[] local = Encoding.Default.GetBytes(buffer.ToString());
string localText = Encoding.UTF8.GetString(local);
return localText;
}

public void WritePrivateString(string aSection, string aKey, string aValue)
Expand Down
1 change: 1 addition & 0 deletions sources/GUI/Classes/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Forms;

namespace JetpackDowngraderGUI
{
static class Program
Expand Down
5 changes: 5 additions & 0 deletions sources/GUI/GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@
<StartupObject>JetpackDowngraderGUI.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="DarkUI, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DarkUI.2.0.2\lib\DarkUI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\FolderSelectDialog.cs" />
<Compile Include="Classes\IniEditor.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
Expand All @@ -75,6 +79,7 @@
<ItemGroup>
<None Include="app.config" />
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
Loading

1 comment on commit 5ecd957

@Zalexanninev15
Copy link
Owner Author

Choose a reason for hiding this comment

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

Appearance after redesign

2021-04-29_143052

Please sign in to comment.