Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MeTonaTOR committed Jan 31, 2019
1 parent a9bc036 commit b45bb76
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 60 deletions.
109 changes: 58 additions & 51 deletions GameLauncher/App/Classes/Events/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void checkAvailability() {
try {
WebClientWithTimeout update_data = new WebClientWithTimeout();
update_data.CancelAsync();
update_data.DownloadStringAsync(new Uri(Self.mainserver + "/launcher/update?version=" + Application.ProductVersion));
update_data.DownloadStringAsync(new Uri(Self.mainserver + "/update.php?version=" + Application.ProductVersion));
update_data.DownloadStringCompleted += (sender, e) => {
description.Visible = true;
Expand All @@ -53,68 +53,75 @@ public void checkAvailability() {
} else {
UpdateCheckResponse updater = JsonConvert.DeserializeObject<UpdateCheckResponse>(e.Result);
if(updater.Code == 0) {
if (updater.Payload.UpdateExists == false) {
text.Text = "Launcher Status - Updated";
status.Image = Properties.Resources.ac_success;
text.ForeColor = Color.FromArgb(0x9fc120);
description.Text = "Version : v" + Application.ProductVersion + "build-" + WebClientWithTimeout.createHash(AppDomain.CurrentDomain.FriendlyName).Substring(0, 7);
} else {
text.Text = "Launcher Status - Available";
status.Image = Properties.Resources.ac_warning;
text.ForeColor = Color.Yellow;
description.Text = "New Version : " + updater.Payload.LatestVersion;
try {
if(updater.Code == 0) {
if (updater.Payload.UpdateExists == false) {
text.Text = "Launcher Status - Updated";
status.Image = Properties.Resources.ac_success;
text.ForeColor = Color.FromArgb(0x9fc120);
description.Text = "Version : v" + Application.ProductVersion + "build-" + WebClientWithTimeout.createHash(AppDomain.CurrentDomain.FriendlyName).Substring(0, 7);
} else {
text.Text = "Launcher Status - Available";
status.Image = Properties.Resources.ac_warning;
text.ForeColor = Color.Yellow;
description.Text = "New Version : " + updater.Payload.LatestVersion;
var settingFile = new IniFile("Settings.ini");
if (settingFile.Read("IgnoreUpdateVersion") != updater.Payload.LatestVersion) {
var dia = new TaskDialog {
Caption = "Update",
InstructionText = "An update is available!",
DetailsExpanded = true,
Icon = TaskDialogStandardIcon.Information,
DetailsCollapsedLabel = "Show Changelog",
Text = "An update is available. Do you want to download it?\nYour version: " +
Application.ProductVersion + "\nUpdated version: " + updater.Payload.LatestVersion,
DetailsExpandedText =
new WebClientWithTimeout().DownloadString(Self.mainserver + "/launcher/changelog"),
ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter
};
var settingFile = new IniFile("Settings.ini");
if (settingFile.Read("IgnoreUpdateVersion") != updater.Payload.LatestVersion) {
var dia = new TaskDialog {
Caption = "Update",
InstructionText = "An update is available!",
DetailsExpanded = true,
Icon = TaskDialogStandardIcon.Information,
DetailsCollapsedLabel = "Show Changelog",
Text = "An update is available. Do you want to download it?\nYour version: " +
Application.ProductVersion + "\nUpdated version: " + updater.Payload.LatestVersion,
DetailsExpandedText =
new WebClientWithTimeout().DownloadString(Self.mainserver + "/launcher/changelog"),
ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter
};
var update = new TaskDialogCommandLink("update", "Yes", "Launcher will be updated to " + updater.Payload.LatestVersion + ".");
var cancel = new TaskDialogCommandLink("cancel", "No", "Launcher will ask you to update on the next launch.");
var skipupdate = new TaskDialogCommandLink("skipupdate", "Ignore", "This update will be skipped. A new prompt will apear as soon as a newer update is available.");
var update = new TaskDialogCommandLink("update", "Yes", "Launcher will be updated to " + updater.Payload.LatestVersion + ".");
var cancel = new TaskDialogCommandLink("cancel", "No", "Launcher will ask you to update on the next launch.");
var skipupdate = new TaskDialogCommandLink("skipupdate", "Ignore", "This update will be skipped. A new prompt will apear as soon as a newer update is available.");
update.UseElevationIcon = true;
update.UseElevationIcon = true;
skipupdate.Click += (sender3, e3) => {
settingFile.Write("IgnoreUpdateVersion", updater.Payload.LatestVersion);
dia.Close();
skipupdate.Click += (sender3, e3) => {
settingFile.Write("IgnoreUpdateVersion", updater.Payload.LatestVersion);
dia.Close();
};
};
cancel.Click += (sender3, e3) => {
dia.Close();
};
cancel.Click += (sender3, e3) => {
dia.Close();
};
update.Click += (sender3, e3) => {
if (File.Exists("GameLauncherUpdater.exe")) {
Process.Start(@"GameLauncherUpdater.exe", Process.GetCurrentProcess().Id.ToString());
} else {
Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
}
update.Click += (sender3, e3) => {
if (File.Exists("GameLauncherUpdater.exe")) {
Process.Start(@"GameLauncherUpdater.exe", Process.GetCurrentProcess().Id.ToString());
} else {
Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
}
dia.Close();
};
dia.Close();
};
dia.Controls.Add(update);
dia.Controls.Add(cancel);
dia.Controls.Add(skipupdate);
dia.Controls.Add(update);
dia.Controls.Add(cancel);
dia.Controls.Add(skipupdate);
dia.Show();
dia.Show();
}
}
} else {
text.Text = "Launcher Status - GitHub Error";
status.Image = Properties.Resources.ac_error;
text.ForeColor = Color.FromArgb(254, 0, 0);
description.Text = "Version : v" + Application.ProductVersion + "build-" + WebClientWithTimeout.createHash(AppDomain.CurrentDomain.FriendlyName).Substring(0, 7);
}
} else {
text.Text = "Launcher Status - GitHub Error";
} catch {
text.Text = "Launcher Status - Backend Error";
status.Image = Properties.Resources.ac_error;
text.ForeColor = Color.FromArgb(254, 0, 0);
description.Text = "Version : v" + Application.ProductVersion + "build-" + WebClientWithTimeout.createHash(AppDomain.CurrentDomain.FriendlyName).Substring(0, 7);
Expand Down
9 changes: 6 additions & 3 deletions GameLauncher/App/Classes/Self.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

namespace GameLauncherReborn {
class Self {
public static string mainserver = "https://launcher.worldunited.gg";
//public static string mainserver = "http://launcher.worldunited.gg";
public static string mainserver = "http://37.233.101.12";

public static string[] serverlisturl = new string[] {
mainserver + "/serverlist.json",
"https://launchpad.soapboxrace.world/servers",
"https://launchpad.soapboxrace.world/servers",
"http://api.nightriderz.world/servers.json"
};

Expand All @@ -23,10 +24,12 @@ class Self {
public static string internetcheckurl = mainserver + "/generate_204.php";
public static string statsurl = mainserver + "/stats";

public static string CDNUrlList = mainserver + "/list.json"; //hosted on WOPL, coz why not.
public static string CDNUrlList = mainserver + "/cdn_list.json"; //hosted on WOPL, coz why not.

private static IniFile SettingFile = new IniFile("Settings.ini");

public static string DiscordRPCID = "540651192179752970";

public static int ProxyPort = new Random().Next(6260, 6269);
public static Boolean sendRequest = true;

Expand Down
14 changes: 9 additions & 5 deletions GameLauncher/App/MainScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ public MainScreen(Form splashscreen) {
//handlers.readyCallback = Discord_Ready; //Discord, please, fix that... (already reported on DiscordRPC Issues Page)
handlers.errorCallback = Discord_Error;
handlers.disconnectedCallback = Discord_Disconnect;
DiscordRpc.Initialize("427355155537723393", ref handlers, true, String.Empty);
DiscordRpc.Register("427355155537723393", "\"" + Directory.GetCurrentDirectory() + "\\GameLauncher.exe\" --discord");
DiscordRpc.Initialize(Self.DiscordRPCID, ref handlers, true, String.Empty);
DiscordRpc.Register(Self.DiscordRPCID, "\"" + Directory.GetCurrentDirectory() + "\\GameLauncher.exe\" --discord");

Log.Debug("Setting SSL Protocol");
ServicePointManager.Expect100Continue = true;
Expand Down Expand Up @@ -770,7 +770,7 @@ private void mainScreen_Load(object sender, EventArgs e) {
Directory.CreateDirectory(_settingFile.Read("InstallationDirectory"));
if (!File.Exists(_settingFile.Read("InstallationDirectory") + "/lightfx.dll")) {
try {
File.WriteAllBytes(_settingFile.Read("InstallationDirectory") + "/lightfx.dll", new WebClientWithTimeout().DownloadData("http://launcher.soapboxrace.world/lightfx.dll"));
File.WriteAllBytes(_settingFile.Read("InstallationDirectory") + "/lightfx.dll", new WebClientWithTimeout().DownloadData( Self.mainserver + "/files/lightfx.dll"));
/*string tempNameZip = Path.GetTempFileName();
File.WriteAllBytes(tempNameZip, ExtractResource.AsByte("GameLauncher.SoapBoxModules.lightfx.zip"));
Expand Down Expand Up @@ -1244,8 +1244,12 @@ private void serverPick_SelectedIndexChanged(object sender, EventArgs e) {
ServerStatusBar(_colorOnline, _startPoint, _endPoint);
}
ServerStatusText.Text = "Server Status - Online ( ON )";
ServerStatusText.ForeColor = Color.FromArgb(159, 193, 32);
try {
ServerStatusText.Text = "Server Status - Online ( ON )";
ServerStatusText.ForeColor = Color.FromArgb(159, 193, 32);
} catch {
//¯\_(ツ)_/¯
}
ServerStatusDesc.Text = string.Format("players in game - {0}", numPlayers);
_serverEnabled = true;
Expand Down
2 changes: 1 addition & 1 deletion GameLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal static void Main() {

if(!File.Exists("GameLauncherUpdater.exe")) {
try {
File.WriteAllBytes("GameLauncherUpdater.exe", new WebClientWithTimeout().DownloadData("http://launcher.soapboxrace.world/GameLauncherUpdater.exe"));
File.WriteAllBytes("GameLauncherUpdater.exe", new WebClientWithTimeout().DownloadData(Self.mainserver + "/files/GameLauncherUpdater.exe"));
} catch { /* ignored */ }
}

Expand Down

0 comments on commit b45bb76

Please sign in to comment.