Skip to content

Commit ba68b3d

Browse files
committed
v1.1.0
- Fixed a folder not found issue with the launchers installer if you selected a custom install path. - Fixed several message box and logging errors in the launcher. - Added a button that lets you change your install path in the launchers settings, this moves the folder and modifies the registry for you.
1 parent 371a044 commit ba68b3d

File tree

14 files changed

+229
-208
lines changed

14 files changed

+229
-208
lines changed

Architecture/Path.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ public bool Exists()
5151
return (IsFile() ? File.Exists(GetPath()) : Directory.Exists(GetPath()));
5252
}
5353

54+
public Path CreateDirectory()
55+
{
56+
if (!IsFile())
57+
{
58+
Directory.CreateDirectory(GetPath());
59+
}
60+
61+
return this;
62+
}
63+
5464
// Modifies the current path with the given string. If you wish to return/add on to the path by creating a new one instead of modifying it, see down below for the divide operator overload.
5565
public Path Append(string str)
5666
{

Controls/CRNumberbox.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ public bool Hexadecimal
3636
set { InputBx.Hexadecimal = value; }
3737
}
3838

39+
public Font DisplayFont
40+
{
41+
get { return InputBx.Font; }
42+
set { InputBx.Font = value; }
43+
}
44+
45+
public bool ReadOnly
46+
{
47+
get { return InputBx.ReadOnly; }
48+
set { InputBx.ReadOnly = value; }
49+
}
50+
3951
public CRNumberbox()
4052
{
4153
InitializeComponent();

Controls/CRPopup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ protected void CRPopup_DoubleSecondClick(EventArgs e)
134134

135135
if (InternalForm != null)
136136
{
137+
InternalForm.Show();
137138
InternalForm.TopMost = true;
138139
}
139140
}

Controls/CRTextbox.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Controls/CRTextbox.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Drawing;
23
using System.Windows.Forms;
34

45
namespace CodeRedLauncher.Controls
@@ -22,12 +23,24 @@ public FilterTypes TextFilter
2223
set { Filter = value; }
2324
}
2425

26+
public Font DisplayFont
27+
{
28+
get { return InputBx.Font; }
29+
set { InputBx.Font = value; }
30+
}
31+
2532
public string DisplayText
2633
{
2734
get { return InputBx.Text; }
2835
set { InputBx.Text = value; }
2936
}
3037

38+
public bool ReadOnly
39+
{
40+
get { return InputBx.ReadOnly; }
41+
set { InputBx.ReadOnly = value; }
42+
}
43+
3144
public CRTextbox()
3245
{
3346
InitializeComponent();

Forms/MainFrm.Designer.cs

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Forms/MainFrm.cs

Lines changed: 90 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System;
22
using System.IO;
33
using Microsoft.Win32;
4-
using System.Text.Json;
54
using System.Diagnostics;
65
using System.Windows.Forms;
76
using System.IO.Compression;
87
using System.Threading.Tasks;
98
using System.Collections.Generic;
109
using CodeRedLauncher.Controls;
10+
using System.Configuration;
1111

1212
namespace CodeRedLauncher
1313
{
@@ -23,15 +23,27 @@ private void MainFrm_Load(object sender, EventArgs e)
2323
StartupRoutine();
2424
}
2525

26-
private void TitleBar_OnMinimized(object sender, EventArgs e)
26+
private void MainFrm_Resize(object sender, EventArgs e)
2727
{
28-
if (Configuration.ShouldHideWhenMinimized())
28+
if (this.WindowState == FormWindowState.Minimized)
2929
{
30-
this.Hide();
30+
TitleBar_OnMinimized(null, null);
3131
}
32-
else
32+
}
33+
34+
private void TitleBar_OnMinimized(object sender, EventArgs e)
35+
{
36+
if (true)
3337
{
34-
this.WindowState = FormWindowState.Minimized;
38+
if (Configuration.ShouldHideWhenMinimized())
39+
{
40+
this.Hide();
41+
}
42+
else if (this.WindowState != FormWindowState.Minimized)
43+
{
44+
this.Show();
45+
this.WindowState = FormWindowState.Minimized;
46+
}
3547
}
3648
}
3749

@@ -278,6 +290,72 @@ private void InjectionTimeoutBx_OnValueChanged(object sender, EventArgs e)
278290
}
279291
}
280292

293+
// https://learn.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
294+
static void CopyDirectory(string sourceDir, string destinationDir, bool bRecursive)
295+
{
296+
DirectoryInfo sourceInfo = new DirectoryInfo(sourceDir);
297+
DirectoryInfo[] dirs = sourceInfo.GetDirectories();
298+
Directory.CreateDirectory(destinationDir);
299+
300+
foreach (FileInfo file in sourceInfo.GetFiles())
301+
{
302+
string targetFilePath = Path.Combine(destinationDir, file.Name);
303+
file.CopyTo(targetFilePath);
304+
}
305+
306+
if (bRecursive)
307+
{
308+
foreach (DirectoryInfo subDir in dirs)
309+
{
310+
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
311+
CopyDirectory(subDir.FullName, newDestinationDir, true);
312+
}
313+
}
314+
}
315+
316+
private void InstallPathBtn_OnButtonClick(object sender, EventArgs e)
317+
{
318+
Architecture.Path modulePath = Storage.GetModulePath();
319+
320+
if (modulePath.Exists())
321+
{
322+
Architecture.Path newPath = new Architecture.Path();
323+
FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
324+
325+
if (folderBrowser.ShowDialog() == DialogResult.OK)
326+
{
327+
newPath = new Architecture.Path(folderBrowser.SelectedPath);
328+
329+
if (newPath.Exists())
330+
{
331+
if (!newPath.GetPath().Contains("CodeRed"))
332+
{
333+
newPath.Append("CodeRed").CreateDirectory();
334+
}
335+
}
336+
337+
Logger.Write("User selected \"" + folderBrowser.SelectedPath + "\" for new install path.");
338+
}
339+
340+
if (newPath.Exists())
341+
{
342+
CopyDirectory(modulePath.GetPath(), newPath.GetPath(), true);
343+
Directory.Delete(modulePath.GetPath(), true);
344+
345+
Installer.ModifyRegistry(false, newPath);
346+
Configuration.Invalidate(true);
347+
Storage.Invalidate(true);
348+
ConfigToInterface();
349+
StorageToInterface();
350+
}
351+
else
352+
{
353+
Logger.Write("Selected path is invalid, cannot move install path!", LogLevel.LEVEL_ERROR);
354+
MessageBox.Show("Selected path is invalid, cannot move install path!", Assembly.GetTitle());
355+
}
356+
}
357+
}
358+
281359
private void OpenFolderBtn_OnButtonClick(object sender, EventArgs e)
282360
{
283361
Architecture.Path folderPath = Storage.GetModulePath();
@@ -632,9 +710,7 @@ private async void StartupRoutine(bool bInvalidate = false)
632710

633711
if (await Retrievers.CheckInitialized())
634712
{
635-
string pingUrl = await Retrievers.GetModuleUrl();
636-
637-
if (await Downloaders.WebsiteOnline(pingUrl) == false)
713+
if (await Downloaders.WebsiteOnline(Retrievers.GetRemoteURL()) == false)
638714
{
639715
OfflinePopupCtrl.Show();
640716
}
@@ -762,6 +838,7 @@ private void StorageToInterface()
762838

763839
LaunchBtn.Visible = true;
764840
ManualInjectBtn.Visible = false;
841+
InstallPathBx.DisplayText = Storage.GetModulePath().GetPath();
765842
}
766843
}
767844

@@ -915,13 +992,13 @@ private async void InstallPopupCtrl_DoubleFirstButtonClick(object sender, EventA
915992
else if (moduleReport.FailReason != null)
916993
{
917994
Logger.Write(moduleReport.FailReason, LogLevel.LEVEL_ERROR);
918-
MessageBox.Show(moduleReport.FailReason);
995+
MessageBox.Show(moduleReport.FailReason, Assembly.GetTitle());
919996
}
920997
}
921998
else if (pathReport.FailReason != null)
922999
{
9231000
Logger.Write(pathReport.FailReason, LogLevel.LEVEL_ERROR);
924-
MessageBox.Show(pathReport.FailReason);
1001+
MessageBox.Show(pathReport.FailReason, Assembly.GetTitle());
9251002
}
9261003
}
9271004

@@ -943,13 +1020,13 @@ private async void InstallPopupCtrl_DoubleSecondButtonClick(object sender, Event
9431020
else if (moduleReport.FailReason != null)
9441021
{
9451022
Logger.Write(moduleReport.FailReason, LogLevel.LEVEL_ERROR);
946-
MessageBox.Show(moduleReport.FailReason);
1023+
MessageBox.Show(moduleReport.FailReason, Assembly.GetTitle());
9471024
}
9481025
}
9491026
else if (pathReport.FailReason != null)
9501027
{
9511028
Logger.Write(pathReport.FailReason, LogLevel.LEVEL_ERROR);
952-
MessageBox.Show(pathReport.FailReason);
1029+
MessageBox.Show(pathReport.FailReason, Assembly.GetTitle());
9531030
}
9541031
}
9551032

@@ -975,7 +1052,6 @@ private async void UpdatePopupCtrl_DoubleSecondButtonClick(object sender, EventA
9751052
{
9761053
UpdatePopupCtrl.Hide();
9771054
ProcessTmr.Start();
978-
this.TopMost = false;
9791055
CheckForUpdates(true, false);
9801056
}
9811057
else if (report.FailReason != null)

0 commit comments

Comments
 (0)