Compare commits
5 Commits
2.0-Codeba
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d7f0f4fdf | |||
|
|
3ae40534df | ||
| d5b43b85b4 | |||
|
|
636ad3d6ae | ||
|
|
25fbe2f22b |
3
FodyWeavers.xml
Normal file
3
FodyWeavers.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<Costura />
|
||||
</Weavers>
|
||||
121
Form1.Designer.cs
generated
121
Form1.Designer.cs
generated
@@ -39,6 +39,15 @@
|
||||
this.checkUUID = new System.Windows.Forms.CheckBox();
|
||||
this.btnPlay = new System.Windows.Forms.Button();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||
this.btnInstallVersion = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.installProgressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.comboBox2Play = new System.Windows.Forms.ComboBox();
|
||||
this.btnUninstallVersion = new System.Windows.Forms.Button();
|
||||
this.btnLauncherUpdate = new System.Windows.Forms.Button();
|
||||
this.labelLauncherVersion = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxUsername
|
||||
@@ -111,9 +120,9 @@
|
||||
//
|
||||
// btnPlay
|
||||
//
|
||||
this.btnPlay.Location = new System.Drawing.Point(285, 26);
|
||||
this.btnPlay.Location = new System.Drawing.Point(550, 150);
|
||||
this.btnPlay.Name = "btnPlay";
|
||||
this.btnPlay.Size = new System.Drawing.Size(104, 104);
|
||||
this.btnPlay.Size = new System.Drawing.Size(104, 50);
|
||||
this.btnPlay.TabIndex = 9;
|
||||
this.btnPlay.Text = "Play!";
|
||||
this.btnPlay.UseVisualStyleBackColor = true;
|
||||
@@ -127,11 +136,105 @@
|
||||
this.toolTip1.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
|
||||
this.toolTip1.ToolTipTitle = "UUID";
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
this.comboBox1.FormattingEnabled = true;
|
||||
this.comboBox1.Location = new System.Drawing.Point(270, 25);
|
||||
this.comboBox1.Name = "comboBox1";
|
||||
this.comboBox1.Size = new System.Drawing.Size(200, 21);
|
||||
this.comboBox1.TabIndex = 10;
|
||||
this.comboBox1.Text = "Select A Version";
|
||||
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
|
||||
//
|
||||
// btnInstallVersion
|
||||
//
|
||||
this.btnInstallVersion.Location = new System.Drawing.Point(408, 52);
|
||||
this.btnInstallVersion.Name = "btnInstallVersion";
|
||||
this.btnInstallVersion.Size = new System.Drawing.Size(62, 20);
|
||||
this.btnInstallVersion.TabIndex = 11;
|
||||
this.btnInstallVersion.Text = "Install";
|
||||
this.btnInstallVersion.UseVisualStyleBackColor = true;
|
||||
this.btnInstallVersion.Click += new System.EventHandler(this.btnInstallVersion_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(270, 10);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(271, 13);
|
||||
this.label1.TabIndex = 12;
|
||||
this.label1.Text = "Game Updater (May freeze launcher while downloading)";
|
||||
//
|
||||
// installProgressBar1
|
||||
//
|
||||
this.installProgressBar1.Location = new System.Drawing.Point(270, 52);
|
||||
this.installProgressBar1.Name = "installProgressBar1";
|
||||
this.installProgressBar1.Size = new System.Drawing.Size(132, 20);
|
||||
this.installProgressBar1.TabIndex = 13;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(273, 94);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(73, 13);
|
||||
this.label2.TabIndex = 16;
|
||||
this.label2.Text = "Game Version";
|
||||
//
|
||||
// comboBox2Play
|
||||
//
|
||||
this.comboBox2Play.FormattingEnabled = true;
|
||||
this.comboBox2Play.Location = new System.Drawing.Point(273, 109);
|
||||
this.comboBox2Play.Name = "comboBox2Play";
|
||||
this.comboBox2Play.Size = new System.Drawing.Size(200, 21);
|
||||
this.comboBox2Play.TabIndex = 14;
|
||||
this.comboBox2Play.Text = "Select A Version";
|
||||
this.comboBox2Play.SelectedIndexChanged += new System.EventHandler(this.comboBox2Play_SelectedIndexChanged);
|
||||
//
|
||||
// btnUninstallVersion
|
||||
//
|
||||
this.btnUninstallVersion.Location = new System.Drawing.Point(408, 136);
|
||||
this.btnUninstallVersion.Name = "btnUninstallVersion";
|
||||
this.btnUninstallVersion.Size = new System.Drawing.Size(62, 20);
|
||||
this.btnUninstallVersion.TabIndex = 17;
|
||||
this.btnUninstallVersion.Text = "Uninstall";
|
||||
this.btnUninstallVersion.UseVisualStyleBackColor = true;
|
||||
this.btnUninstallVersion.Click += new System.EventHandler(this.btnUninstallVersion_Click);
|
||||
//
|
||||
// btnLauncherUpdate
|
||||
//
|
||||
this.btnLauncherUpdate.Location = new System.Drawing.Point(550, 26);
|
||||
this.btnLauncherUpdate.Name = "btnLauncherUpdate";
|
||||
this.btnLauncherUpdate.Size = new System.Drawing.Size(104, 104);
|
||||
this.btnLauncherUpdate.TabIndex = 18;
|
||||
this.btnLauncherUpdate.Text = "LAUNCHER UPDATE AVAILIBLE";
|
||||
this.btnLauncherUpdate.UseVisualStyleBackColor = true;
|
||||
this.btnLauncherUpdate.Click += new System.EventHandler(this.btnLauncherUpdate_Click);
|
||||
//
|
||||
// labelLauncherVersion
|
||||
//
|
||||
this.labelLauncherVersion.AutoSize = true;
|
||||
this.labelLauncherVersion.Location = new System.Drawing.Point(9, 189);
|
||||
this.labelLauncherVersion.Name = "labelLauncherVersion";
|
||||
this.labelLauncherVersion.Size = new System.Drawing.Size(94, 13);
|
||||
this.labelLauncherVersion.TabIndex = 19;
|
||||
this.labelLauncherVersion.Text = "Unknown Version.";
|
||||
this.labelLauncherVersion.Click += new System.EventHandler(this.labelLauncherVersion_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(404, 161);
|
||||
this.ClientSize = new System.Drawing.Size(684, 211);
|
||||
this.Controls.Add(this.labelLauncherVersion);
|
||||
this.Controls.Add(this.btnLauncherUpdate);
|
||||
this.Controls.Add(this.btnUninstallVersion);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.comboBox2Play);
|
||||
this.Controls.Add(this.installProgressBar1);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.btnInstallVersion);
|
||||
this.Controls.Add(this.comboBox1);
|
||||
this.Controls.Add(this.btnPlay);
|
||||
this.Controls.Add(this.checkUUID);
|
||||
this.Controls.Add(this.checkUsername);
|
||||
@@ -140,9 +243,12 @@
|
||||
this.Controls.Add(this.textBoxUUID);
|
||||
this.Controls.Add(this.labelUsername);
|
||||
this.Controls.Add(this.textBoxUsername);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Form1";
|
||||
this.Text = "IveBeenAlone\'s Hytale Launcher";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -158,6 +264,15 @@
|
||||
private System.Windows.Forms.CheckBox checkUUID;
|
||||
private System.Windows.Forms.Button btnPlay;
|
||||
private System.Windows.Forms.ToolTip toolTip1;
|
||||
private System.Windows.Forms.ComboBox comboBox1;
|
||||
private System.Windows.Forms.Button btnInstallVersion;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ProgressBar installProgressBar1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ComboBox comboBox2Play;
|
||||
private System.Windows.Forms.Button btnUninstallVersion;
|
||||
private System.Windows.Forms.Button btnLauncherUpdate;
|
||||
private System.Windows.Forms.Label labelLauncherVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
470
Form1.cs
470
Form1.cs
@@ -5,25 +5,54 @@ using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace HelloWorld
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
|
||||
private const string UpdateURL = "https://ibatv.xyz/data/lnch/hy.txt";
|
||||
|
||||
private string SanSessionID;
|
||||
private string SanTokenID;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
btnLauncherUpdate.Visible = false;
|
||||
LoadComboBoxItems();
|
||||
LoadDownloadedFiles();
|
||||
|
||||
|
||||
string path = ".ibalaunch";
|
||||
string uuidsave = ".ibalaunch\\uuid";
|
||||
string usersave = ".ibalaunch\\username";
|
||||
string verssave = ".ibalaunch\\lastplayedversion";
|
||||
string HytaleUserData = "UserData";
|
||||
|
||||
|
||||
|
||||
Version localVersion = GetLocalVersion();
|
||||
|
||||
|
||||
string localversionstring = localVersion.ToString();
|
||||
//Console.WriteLine("Version" + localversionstring);
|
||||
labelLauncherVersion.Text = localversionstring;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
DirectoryInfo di = Directory.CreateDirectory(path);
|
||||
@@ -84,12 +113,66 @@ namespace HelloWorld
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
// UUID File Checking
|
||||
if (File.Exists(verssave))
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(verssave);
|
||||
if (fileInfo.Length == 0)
|
||||
{
|
||||
Console.WriteLine("Last Played file is empty. Not setting anything.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Last Played file is not empty. Size: " + fileInfo.Length + " bytes.");
|
||||
|
||||
comboBox2Play.Text = File.ReadAllText(verssave);
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
||||
private async Task CheckForUpdateAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Version localVersion = GetLocalVersion();
|
||||
Version onlineVersion = await GetOnlineVersionAsync();
|
||||
|
||||
if (onlineVersion > localVersion)
|
||||
{
|
||||
btnLauncherUpdate.Visible = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Optional: log or ignore
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private Version GetLocalVersion()
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetName().Version;
|
||||
}
|
||||
|
||||
private async Task<Version> GetOnlineVersionAsync()
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
string versionText = await client.GetStringAsync(UpdateURL);
|
||||
return new Version(versionText.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 async void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
// All of this shit for username data
|
||||
@@ -159,21 +242,101 @@ namespace HelloWorld
|
||||
Console.WriteLine("UUID Shit done.");
|
||||
|
||||
|
||||
// All of this shit is Last Played version data.
|
||||
string DropDownGameVers = comboBox2Play.Text;
|
||||
string verssave = ".ibalaunch\\lastplayedversion";
|
||||
File.Create(verssave).Dispose();
|
||||
Console.WriteLine("LastPlayedVersion File exists, comparing textbox");
|
||||
string VersFileText = File.ReadAllText(verssave);
|
||||
if (VersFileText != DropDownGameVers)
|
||||
{
|
||||
Console.WriteLine("LastPlayedVersion mismatch, writing!");
|
||||
try
|
||||
{
|
||||
File.WriteAllText(verssave, DropDownGameVers);
|
||||
Console.WriteLine("LastPlayedVersion file saved.");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("An error occurred: idfk probably rw permission error?");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("LastPlayedVersion already saved.");
|
||||
}
|
||||
|
||||
Console.WriteLine("LastPlayedVersion Shit done.");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var payload = new
|
||||
{
|
||||
uuid = "13371337-1337-1337-1337-1337" + textBoxUUID.Text,
|
||||
name = textBoxUsername.Text,
|
||||
scopes = new[] { "hytale:server", "hytale:client" }
|
||||
};
|
||||
|
||||
|
||||
//textBoxUUID.Text + " --name \"" + textBoxUsername.Text
|
||||
|
||||
string json = JsonSerializer.Serialize(payload);
|
||||
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
using (HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"))
|
||||
{
|
||||
HttpResponseMessage response = await client.PostAsync(
|
||||
"https://sessions.sanasol.ws/game-session/child",
|
||||
content
|
||||
);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string responseJson = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Deserialize response
|
||||
SessionResponse session =
|
||||
JsonSerializer.Deserialize<SessionResponse>(responseJson);
|
||||
|
||||
SanSessionID = session.sessionToken;
|
||||
SanTokenID = session.identityToken;
|
||||
|
||||
//MessageBox.Show("Session created!");
|
||||
Console.WriteLine("Session: " + SanSessionID + "\n\nToken: " + SanTokenID);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 relativeExePath = Path.Combine("install\\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 workingDirectory = Path.Combine(baseDirectory, "Versions");
|
||||
string Hytaleappdir = "\\install\\release\\package\\game\\latest";
|
||||
string HytaleJava = "\\install\\release\\package\\jre\\latest\\bin\\java.exe";
|
||||
|
||||
|
||||
string LaunchVersion = comboBox2Play.Text;
|
||||
|
||||
|
||||
string GamePath = "\"" + workingDirectory + "\\" + LaunchVersion + "\\" + relativeExePath + "\""; //hytale.exe
|
||||
string AppPath = "\"" + workingDirectory + "\\" + LaunchVersion + Hytaleappdir + "\""; // game\latest
|
||||
string UserdataPath = "\"" + baseDirectory + "UserData" + "\"";
|
||||
string JavaPath = "\"" + workingDirectory + "\\" + LaunchVersion + HytaleJava + "\""; // java
|
||||
|
||||
string arguments = " --app-dir " + AppPath + " --user-dir " + UserdataPath + " --java-exec " + JavaPath + " --auth-mode authenticated --uuid 13371337-1337-1337-1337-1337" + textBoxUUID.Text + " --name \"" + textBoxUsername.Text + "\"" + " --identity-token " + SanTokenID + " --session-token " + SanSessionID; // Command-line arguments for the VB app
|
||||
|
||||
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
|
||||
{
|
||||
@@ -191,18 +354,291 @@ namespace HelloWorld
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Error starting the VB.NET application: {ex.Message}");
|
||||
MessageBox.Show($"Error starting the application: {ex.Message}\n" + GamePath + arguments);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBox1_CheckedChanged(object sender, EventArgs e){}
|
||||
private void textBox2_TextChanged(object sender, EventArgs e){}
|
||||
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){}
|
||||
private void checkUUID_CheckedChanged(object sender, EventArgs e) { }
|
||||
|
||||
|
||||
private async void LoadComboBoxItems()
|
||||
{
|
||||
string url = "https://ibatv.xyz/data/list.txt";
|
||||
|
||||
try
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
string fileContents = await client.GetStringAsync(url);
|
||||
|
||||
string[] lines = fileContents
|
||||
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
comboBox1.Items.Clear();
|
||||
comboBox1.Items.AddRange(lines);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Failed to load items: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { }
|
||||
|
||||
private async void btnInstallVersion_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (comboBox1.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Please select a version first.");
|
||||
return;
|
||||
}
|
||||
|
||||
string baseUrl = "https://ibatv.xyz/data/files/";
|
||||
string rawName = comboBox1.SelectedItem.ToString();
|
||||
string fileName = rawName.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)
|
||||
? rawName
|
||||
: rawName + ".zip";
|
||||
string fileUrl = baseUrl + fileName;
|
||||
|
||||
string InstallBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string savePath = Path.Combine(InstallBaseDirectory, fileName);
|
||||
string installDir = Path.Combine(InstallBaseDirectory, "Versions");
|
||||
|
||||
string localListPath = Path.Combine(installDir, "versions.txt");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
using (HttpResponseMessage response = await client.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead))
|
||||
{
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
long? totalBytes = response.Content.Headers.ContentLength;
|
||||
|
||||
using (var contentStream = await response.Content.ReadAsStreamAsync())
|
||||
using (var fileStream = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.None, 41943040, true))
|
||||
{
|
||||
var buffer = new byte[41943040]; //40MiB apparently. :shrug:
|
||||
long totalRead = 0;
|
||||
int bytesRead;
|
||||
installProgressBar1.Value = 0;
|
||||
|
||||
while ((bytesRead = await contentStream.ReadAsync(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
await fileStream.WriteAsync(buffer, 0, bytesRead);
|
||||
totalRead += bytesRead;
|
||||
|
||||
if (totalBytes.HasValue)
|
||||
{
|
||||
int progress = (int)((totalRead * 100L) / totalBytes.Value);
|
||||
installProgressBar1.Value = Math.Min(progress, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string folderName = Path.GetFileNameWithoutExtension(fileName);
|
||||
string extractPath = Path.Combine(installDir, folderName);
|
||||
|
||||
Directory.CreateDirectory(extractPath);
|
||||
ZipFile.ExtractToDirectory(savePath, extractPath);
|
||||
|
||||
File.Delete(savePath);
|
||||
|
||||
string baseName = Path.GetFileNameWithoutExtension(fileName);
|
||||
|
||||
List<string> downloadedFiles = new List<string>();
|
||||
if (File.Exists(localListPath))
|
||||
downloadedFiles = File.ReadAllLines(localListPath).ToList();
|
||||
|
||||
// Append only if not already in the list
|
||||
if (!downloadedFiles.Contains(baseName, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
File.AppendAllText(localListPath, baseName + Environment.NewLine);
|
||||
LoadDownloadedFiles();
|
||||
}
|
||||
|
||||
MessageBox.Show("Download complete:\n" + savePath + "\n" + "Extracted to:\n" + installDir);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Download failed:\n" + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void comboBox2Play_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void LoadDownloadedFiles()
|
||||
{
|
||||
|
||||
string InstallBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string installDir = Path.Combine(InstallBaseDirectory, "Versions");
|
||||
string localListPath = Path.Combine(installDir, "versions.txt");
|
||||
|
||||
comboBox2Play.Items.Clear(); // Clear old items
|
||||
|
||||
if (File.Exists(localListPath))
|
||||
{
|
||||
var downloadedFiles = File.ReadAllLines(localListPath);
|
||||
|
||||
foreach (var file in downloadedFiles)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(file))
|
||||
comboBox2Play.Items.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnUninstallVersion_Click(object sender, EventArgs e)
|
||||
{
|
||||
//string baseUrl = "https://ibatv.xyz/data/files/";
|
||||
string rawName = comboBox1.SelectedItem.ToString();
|
||||
string fileName = rawName.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)
|
||||
? rawName
|
||||
: rawName + ".zip";
|
||||
//string fileUrl = baseUrl + fileName;
|
||||
|
||||
string InstallBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string savePath = Path.Combine(InstallBaseDirectory, fileName);
|
||||
string installDir = Path.Combine(InstallBaseDirectory, "Versions");
|
||||
|
||||
string localListPath = Path.Combine(installDir, "versions.txt");
|
||||
|
||||
|
||||
|
||||
if (comboBox2Play.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Please select a version to delete.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string selectedVersion = comboBox2Play.SelectedItem.ToString();
|
||||
|
||||
// Confirm deletion
|
||||
var result = MessageBox.Show(
|
||||
$"Are you sure you want to delete the version '{selectedVersion}'?",
|
||||
"Confirm Deletion",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
|
||||
if (result != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// Delete installed folder
|
||||
//string installDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string versionPath = Path.Combine(installDir, selectedVersion);
|
||||
|
||||
if (Directory.Exists(versionPath))
|
||||
Directory.Delete(versionPath, true); // true = recursive delete
|
||||
|
||||
// Update local list
|
||||
// string localListPath = Path.Combine(installDir, "downloaded_files.txt");
|
||||
if (File.Exists(localListPath))
|
||||
{
|
||||
var downloadedFiles = File.ReadAllLines(localListPath).ToList();
|
||||
downloadedFiles.RemoveAll(f => string.Equals(f, selectedVersion, StringComparison.OrdinalIgnoreCase));
|
||||
File.WriteAllLines(localListPath, downloadedFiles);
|
||||
}
|
||||
|
||||
// Remove from ComboBox
|
||||
comboBox2Play.Items.Remove(selectedVersion);
|
||||
|
||||
LoadDownloadedFiles();
|
||||
|
||||
MessageBox.Show($"Version '{selectedVersion}' has been deleted.", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error deleting version:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async void btnLauncherUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
string tempExe = Path.Combine(Path.GetTempPath(), "latest.exe");
|
||||
|
||||
await DownloadUpdateAsync(tempExe);
|
||||
|
||||
StartUpdaterAndExit(tempExe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task DownloadUpdateAsync(string destinationPath)
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
using (var response = await client.GetAsync("https://ibatv.xyz/data/lnch/hy/latest.exe", HttpCompletionOption.ResponseHeadersRead))
|
||||
{
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
using (var fs = new FileStream(
|
||||
destinationPath,
|
||||
FileMode.Create,
|
||||
FileAccess.Write,
|
||||
FileShare.None))
|
||||
{
|
||||
await response.Content.CopyToAsync(fs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void StartUpdaterAndExit(string newExePath)
|
||||
{
|
||||
string currentExe = Application.ExecutablePath;
|
||||
|
||||
string cmd =
|
||||
$"/C timeout 2 >nul && " +
|
||||
$"copy /Y \"{newExePath}\" \"{currentExe}\" && " +
|
||||
$"start \"\" \"{currentExe}\"";
|
||||
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "cmd.exe",
|
||||
Arguments = cmd,
|
||||
WindowStyle = ProcessWindowStyle.Normal,
|
||||
CreateNoWindow = true
|
||||
});
|
||||
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
await CheckForUpdateAsync();
|
||||
}
|
||||
|
||||
private void labelLauncherVersion_Click(object sender, EventArgs e) { }
|
||||
|
||||
|
||||
|
||||
public class SessionResponse
|
||||
{
|
||||
public string sessionToken { get; set; }
|
||||
public string identityToken { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="packages\Costura.Fody.6.0.0\build\Costura.Fody.props" Condition="Exists('packages\Costura.Fody.6.0.0\build\Costura.Fody.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -12,7 +13,11 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishUrl>Publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
@@ -22,10 +27,11 @@
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<AutorunEnabled>true</AutorunEnabled>
|
||||
<ApplicationRevision>1</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
@@ -48,14 +54,56 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>false</SignManifests>
|
||||
<SignManifests>true</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>hytale.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestCertificateThumbprint>F2C20D945681822F49095156F092FCAC954EAA94</ManifestCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestKeyFile>IBAHytaleLauncher_TemporaryKey.pfx</ManifestKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Costura, Version=6.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Costura.Fody.6.0.0\lib\netstandard2.0\Costura.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.10.0.2\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.IO.Pipelines, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.Pipelines.10.0.2\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encodings.Web, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Text.Encodings.Web.10.0.2\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Text.Json.10.0.2\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -83,6 +131,8 @@
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="IBAHytaleLauncher_TemporaryKey.pfx" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -120,4 +170,16 @@
|
||||
<Content Include="hytale.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
|
||||
<Error Condition="!Exists('packages\Fody.6.8.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.6.8.2\build\Fody.targets'))" />
|
||||
<Error Condition="!Exists('packages\Costura.Fody.6.0.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.6.0.0\build\Costura.Fody.props'))" />
|
||||
<Error Condition="!Exists('packages\Costura.Fody.6.0.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.6.0.0\build\Costura.Fody.targets'))" />
|
||||
</Target>
|
||||
<Import Project="packages\Fody.6.8.2\build\Fody.targets" Condition="Exists('packages\Fody.6.8.2\build\Fody.targets')" />
|
||||
<Import Project="packages\Costura.Fody.6.0.0\build\Costura.Fody.targets" Condition="Exists('packages\Costura.Fody.6.0.0\build\Costura.Fody.targets')" />
|
||||
</Project>
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.9.7.0")]
|
||||
[assembly: AssemblyFileVersion("2.9.7.0")]
|
||||
[assembly: AssemblyVersion("3.9.0.0")]
|
||||
[assembly: AssemblyFileVersion("3.9.0.0")]
|
||||
|
||||
15
packages.config
Normal file
15
packages.config
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Costura.Fody" version="6.0.0" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="Fody" version="6.8.2" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.2" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.6.1" targetFramework="net472" />
|
||||
<package id="System.IO.Pipelines" version="10.0.2" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.6.3" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net472" />
|
||||
<package id="System.Text.Encodings.Web" version="10.0.2" targetFramework="net472" />
|
||||
<package id="System.Text.Json" version="10.0.2" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.6.1" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user