i heard you guys liked comments

This commit is contained in:
Thomas G 2022-07-23 01:57:53 +10:00
parent e76d66e8b8
commit 69da3662dc
3 changed files with 19 additions and 1 deletions

Binary file not shown.

View File

@ -14,6 +14,7 @@ namespace ARCHBLOXLauncherGUI
{ {
private void CreateShortcut() private void CreateShortcut()
{ {
// create shortcut on user's desktop
object shDesktop = (object)"Desktop"; object shDesktop = (object)"Desktop";
WshShell shell = new WshShell(); WshShell shell = new WshShell();
string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\ARCHBLOX Launcher.lnk"; string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\ARCHBLOX Launcher.lnk";
@ -22,6 +23,7 @@ namespace ARCHBLOXLauncherGUI
shortcut.TargetPath = ARCHBLOXLauncherGUI.Extensions.GetExecutablePath(); shortcut.TargetPath = ARCHBLOXLauncherGUI.Extensions.GetExecutablePath();
shortcut.Save(); shortcut.Save();
} }
// variables
bool exitafterarg = false; bool exitafterarg = false;
bool lockanims = true; bool lockanims = true;
bool rbxl = false; bool rbxl = false;
@ -35,6 +37,7 @@ namespace ARCHBLOXLauncherGUI
static string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Archblx\", @"Versions\"); static string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Archblx\", @"Versions\");
static string clientPath = Path.Combine(folderPath, version_string + @"\"); static string clientPath = Path.Combine(folderPath, version_string + @"\");
static string filePath = Path.Combine(clientPath, "ArchbloxPlayerBeta.exe"); static string filePath = Path.Combine(clientPath, "ArchbloxPlayerBeta.exe");
// animations
void slideOutJoinBox(object sender, EventArgs e) void slideOutJoinBox(object sender, EventArgs e)
{ {
lockanims = true; lockanims = true;
@ -154,6 +157,7 @@ namespace ARCHBLOXLauncherGUI
var info1 = ""; var info1 = "";
var info2 = ""; var info2 = "";
string[] args = ARCHBLOXProtocol.SharedVariables.Arguments.Split('/'); string[] args = ARCHBLOXProtocol.SharedVariables.Arguments.Split('/');
// check to see if uri/arguments were used
foreach (var word in args) foreach (var word in args)
{ {
if (lastword == "host") { if (lastword == "host") {
@ -228,9 +232,11 @@ namespace ARCHBLOXLauncherGUI
if (exitafterarg == true) if (exitafterarg == true)
{ {
// close program
Environment.Exit(0); Environment.Exit(0);
} }
// setup animations
AnimationHandler_SlideOutHostBox.Tick += new EventHandler(slideOutHostBox); AnimationHandler_SlideOutHostBox.Tick += new EventHandler(slideOutHostBox);
AnimationHandler_SlideInHostBox.Tick += new EventHandler(slideInHostBox); AnimationHandler_SlideInHostBox.Tick += new EventHandler(slideInHostBox);
@ -266,6 +272,7 @@ namespace ARCHBLOXLauncherGUI
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
// hosting
string phrase = textBox2.Text; string phrase = textBox2.Text;
string[] words = phrase.Split('.'); string[] words = phrase.Split('.');
@ -353,6 +360,7 @@ namespace ARCHBLOXLauncherGUI
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
{ {
// joining
if (!System.IO.File.Exists(filePath)) if (!System.IO.File.Exists(filePath))
{ {
DialogResult res = MessageBox.Show("You need to install the latest version of ARCHBLOX to join " + serverip.Text + ":" + serverport.Text + ". Would you like to install it?", "ARCHBLOX", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); DialogResult res = MessageBox.Show("You need to install the latest version of ARCHBLOX to join " + serverip.Text + ":" + serverport.Text + ". Would you like to install it?", "ARCHBLOX", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
@ -428,6 +436,7 @@ namespace ARCHBLOXLauncherGUI
private void button3_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)
{ {
// ask user to open dialog
OpenFileDialog dialog = new OpenFileDialog(); OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = "Choose a RBXL..."; dialog.Title = "Choose a RBXL...";
dialog.AddExtension = true; dialog.AddExtension = true;
@ -451,6 +460,7 @@ namespace ARCHBLOXLauncherGUI
} }
private void Form1_HelpButtonClicked(Object sender, CancelEventArgs e) private void Form1_HelpButtonClicked(Object sender, CancelEventArgs e)
{ {
// this no longer exists
ARCHBLOXLauncherGUI.Form2 form2 = new ARCHBLOXLauncherGUI.Form2(); ARCHBLOXLauncherGUI.Form2 form2 = new ARCHBLOXLauncherGUI.Form2();
form2.Show(); form2.Show();
} }

View File

@ -11,6 +11,7 @@ namespace ARCHBLOXLauncherGUI
{ {
public partial class Form2 : Form public partial class Form2 : Form
{ {
// setup variables
public bool Uri_Installed = false; public bool Uri_Installed = false;
public bool IsCompleted = false; public bool IsCompleted = false;
public bool DontEvenBother = false; public bool DontEvenBother = false;
@ -19,6 +20,7 @@ namespace ARCHBLOXLauncherGUI
private static long GetDirectorySize(string folderPath) private static long GetDirectorySize(string folderPath)
{ {
// get size of a directory
DirectoryInfo di = new DirectoryInfo(folderPath); DirectoryInfo di = new DirectoryInfo(folderPath);
return di.EnumerateFiles("*", SearchOption.AllDirectories).Sum(fi => fi.Length) / 1000000; return di.EnumerateFiles("*", SearchOption.AllDirectories).Sum(fi => fi.Length) / 1000000;
} }
@ -26,6 +28,7 @@ namespace ARCHBLOXLauncherGUI
public Form2() public Form2()
{ {
InitializeComponent(); InitializeComponent();
// setup file paths etc
byte[] raw = wc.DownloadData("https://archblox.com/client/version.txt"); byte[] raw = wc.DownloadData("https://archblox.com/client/version.txt");
string webData = Encoding.UTF8.GetString(raw); string webData = Encoding.UTF8.GetString(raw);
string version_string = webData; string version_string = webData;
@ -35,6 +38,7 @@ namespace ARCHBLOXLauncherGUI
{ {
if (Directory.Exists(folderPath)) if (Directory.Exists(folderPath))
{ {
// since the folder already exists, show size of folder and ask user if they want to delete older versions
DialogResult res = MessageBox.Show("Do you want to delete previous installs of ARCHBLOX? Current size of ARCHBLOX folder: " + GetDirectorySize(folderPath) + "MB.", "ARCHBLOX", MessageBoxButtons.YesNo, MessageBoxIcon.Information); DialogResult res = MessageBox.Show("Do you want to delete previous installs of ARCHBLOX? Current size of ARCHBLOX folder: " + GetDirectorySize(folderPath) + "MB.", "ARCHBLOX", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (res == DialogResult.Yes) if (res == DialogResult.Yes)
{ {
@ -45,6 +49,7 @@ namespace ARCHBLOXLauncherGUI
} }
} }
} }
// setup variables
wc.DownloadProgressChanged += Client_DownloadProgressChanged; wc.DownloadProgressChanged += Client_DownloadProgressChanged;
wc.DownloadFileCompleted += Client_DownloadFileCompleted; wc.DownloadFileCompleted += Client_DownloadFileCompleted;
progressBar1.Style = ProgressBarStyle.Marquee; progressBar1.Style = ProgressBarStyle.Marquee;
@ -53,6 +58,7 @@ namespace ARCHBLOXLauncherGUI
wc.DownloadFileCompleted += Client_DownloadFileCompleted; wc.DownloadFileCompleted += Client_DownloadFileCompleted;
if (Directory.Exists(clientPath)) if (Directory.Exists(clientPath))
{ {
// ask user if they want to re-install
DialogResult res = MessageBox.Show("The latest version of ARCHBLOX is already installed. Do you want to re-install it?", "ARCHBLOX", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); DialogResult res = MessageBox.Show("The latest version of ARCHBLOX is already installed. Do you want to re-install it?", "ARCHBLOX", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (res == DialogResult.Yes) if (res == DialogResult.Yes)
{ {
@ -68,6 +74,7 @@ namespace ARCHBLOXLauncherGUI
} }
if (DontEvenBother == false) if (DontEvenBother == false)
{ {
// continue with install
Directory.CreateDirectory(clientPath); Directory.CreateDirectory(clientPath);
wc.DownloadFileAsync(new Uri(@"https://archblox.com/client/" + version_string + ".zip"), filePath); wc.DownloadFileAsync(new Uri(@"https://archblox.com/client/" + version_string + ".zip"), filePath);
progressBar1.Style = ProgressBarStyle.Blocks; progressBar1.Style = ProgressBarStyle.Blocks;
@ -83,7 +90,7 @@ namespace ARCHBLOXLauncherGUI
{ {
if (IsCompleted == false) if (IsCompleted == false)
{ {
// the download has completed, extract zip, setup URI.
IsCompleted = true; IsCompleted = true;
byte[] raw = wc.DownloadData("https://archblox.com/client/version.txt"); byte[] raw = wc.DownloadData("https://archblox.com/client/version.txt");
string webData = Encoding.UTF8.GetString(raw); string webData = Encoding.UTF8.GetString(raw);
@ -114,6 +121,7 @@ namespace ARCHBLOXLauncherGUI
private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{ {
// update the progress bar
progressBar1.Minimum = 0; progressBar1.Minimum = 0;
double receive = double.Parse(e.BytesReceived.ToString()); double receive = double.Parse(e.BytesReceived.ToString());
double total = double.Parse(e.TotalBytesToReceive.ToString()); double total = double.Parse(e.TotalBytesToReceive.ToString());