Files
IveBeenAlones-HytaleLauncher/Form1.cs

208 lines
7.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HelloWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string path = ".ibalaunch";
string uuidsave = ".ibalaunch\\uuid";
string usersave = ".ibalaunch\\username";
string HytaleUserData = "UserData";
try
{
DirectoryInfo di = Directory.CreateDirectory(path);
Console.WriteLine($"Ensured directory exists: {di.FullName}");
}
catch (Exception)
{
Console.WriteLine($"An error occurred: idfk probably rw permission error?");
}
try
{
DirectoryInfo Hdi = Directory.CreateDirectory(HytaleUserData);
Console.WriteLine($"Ensured directory exists: {Hdi.FullName}");
}
catch (Exception)
{
Console.WriteLine($"An error occurred: idfk probably rw permission error?");
}
// Username File Checking
if (File.Exists(usersave))
{
FileInfo fileInfo = new FileInfo(usersave);
if (fileInfo.Length == 0)
{
Console.WriteLine("Username file is empty. Not setting anything.");
}
else
{
Console.WriteLine("Username file is not empty. Size: " + fileInfo.Length + " bytes.");
textBoxUsername.Text = File.ReadAllText(usersave);
checkUsername.Checked = true;
}
}
else
{
}
// UUID File Checking
if (File.Exists(uuidsave))
{
FileInfo fileInfo = new FileInfo(uuidsave);
if (fileInfo.Length == 0)
{
Console.WriteLine("UUID file is empty. Not setting anything.");
}
else
{
Console.WriteLine("UUID file is not empty. Size: " + fileInfo.Length + " bytes.");
textBoxUUID.Text = File.ReadAllText(uuidsave);
checkUUID.Checked = true;
}
}
else
{
}
}
private void button1_Click(object sender, EventArgs e){}
private void lblHelloWorld_Click(object sender, EventArgs e){}
private void label2_Click(object sender, EventArgs e){}
private void button2_Click(object sender, EventArgs e)
{
// All of this shit for username data
string TextBoxUsername = textBoxUsername.Text;
if (checkUsername.Checked == true)
{
Console.WriteLine("Username Checkbox true, saving.");
string usersave = ".ibalaunch\\username";
File.Create(usersave).Dispose();
Console.WriteLine("Username File exists, comparing textbox");
string UsernameFileText = File.ReadAllText(usersave);
if (UsernameFileText != TextBoxUsername)
{
Console.WriteLine("Username mismatch, writing!");
try
{
File.WriteAllText(usersave, TextBoxUsername);
Console.WriteLine("Username file saved.");
}
catch (Exception)
{
Console.WriteLine("An error occurred: idfk probably rw permission error?");
}
}
else
{
Console.WriteLine("Username already saved.");
}
}
else
{
Console.WriteLine("Username Checkbox false, not saving.");
}
Console.WriteLine("Username Shit done.");
// All of this shit is uuid data.
string TextBoxUUID = textBoxUUID.Text;
if (checkUUID.Checked == true)
{
Console.WriteLine("UUID Checkbox true, saving.");
string uuidsave = ".ibalaunch\\uuid";
File.Create(uuidsave).Dispose();
Console.WriteLine("UUID File exists, comparing textbox");
string UUIDFileText = File.ReadAllText(uuidsave);
if (UUIDFileText != TextBoxUUID)
{
Console.WriteLine("UUID mismatch, writing!");
try
{
File.WriteAllText(uuidsave, TextBoxUUID);
Console.WriteLine("UUID file saved.");
}
catch (Exception)
{
Console.WriteLine("An error occurred: idfk probably rw permission error?");
}
}
else
{
Console.WriteLine("UUID already saved.");
}
}
else
{
Console.WriteLine("UUID Checkbox false, not saving.");
}
Console.WriteLine("UUID Shit done.");
// Genuinely FUCK windows and C# and fucking whatever else to make this shit work
// I swear to fucking god I spent a solid 3 hours trying to make this thing
// OPEN A FUCKING EXE AND PASS ARGS CORRECTLY
string relativeExePath = Path.Combine("release\\package\\game\\latest\\Client\\", "HytaleClient.exe");
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
string workingDirectory = Path.Combine(baseDirectory, "install");
string Hytaleappdir = "\\release\\package\\game\\latest";
string HytaleJava = "\\release\\package\\jre\\latest\\bin\\java.exe";
string GamePath = "\"" + workingDirectory + "\\" + relativeExePath + "\""; //hytale.exe
string AppPath = "\"" + workingDirectory + Hytaleappdir + "\""; // game\latest
string UserdataPath = "\"" + baseDirectory + "UserData"+"\""; // game\latest
string JavaPath = "\"" + workingDirectory + HytaleJava + "\""; // java
string arguments = " --app-dir " +AppPath+ " --user-dir " + UserdataPath + " --java-exec " + JavaPath + " --auth-mode offline --uuid 13371337-1337-1337-1337-1337" + textBoxUUID.Text + " --name \"" + textBoxUsername.Text + "\""; // Command-line arguments for the VB app
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = GamePath,
Arguments = arguments,
UseShellExecute = true,
};
Console.WriteLine("Launching:");
Console.WriteLine(GamePath + arguments);
try
{
Process.Start(startInfo);
}
catch (Exception ex)
{
MessageBox.Show($"Error starting the VB.NET application: {ex.Message}");
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e){}
private void textBox2_TextChanged(object sender, EventArgs e){}
private void button1_Click_1(object sender, EventArgs e)
{
Random random = new Random();
int GeneratedUUIDVal = random.Next(10000000, 100000000);
textBoxUUID.Text = GeneratedUUIDVal.ToString();
}
private void checkUUID_CheckedChanged(object sender, EventArgs e){}
}
}