Made it get the latest version from the servers

This commit is contained in:
Puppet committed 2025-08-27 16:39:00 -07:00
1 parent 1a8f4de7f9
commit 3a4b905869
3 files changed
+27

No files matched your search

+2
View File
@@ -176,6 +176,8 @@ theme_override_font_sizes/font_size = 81
text = "Latest Version: {Version Number}"
horizontal_alignment = 2
[node name="HTTPRequest" type="HTTPRequest" parent="VersionText/LatestVersion"]
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource("2_853f1")
autoplay = true
+1
View File
@@ -3,4 +3,5 @@ using System;
public partial class Globals : Node {
public static string LatestVersion = "";
public static string AccessLevel = "";
}
+24
View File
@@ -1,5 +1,7 @@
using Godot;
using System;
using System.Text;
using System.Collections.Generic;
public partial class VersionChecker : Control {
public override void _Ready() {
@@ -7,5 +9,27 @@ public partial class VersionChecker : Control {
string GameVersion = ProjectSettings.GetSetting("application/config/version").AsString();
VersionLabel.Text = "Version: " + GameVersion;
HttpRequest GetLatestVersionNode = GetNode<HttpRequest>("LatestVersion/HTTPRequest");
GetLatestVersionNode.RequestCompleted += OnRequestCompleted;
string url = "https://berrydash-godot.lncvrt.xyz/database/getLatestVersion.php?version=" + GameVersion;
GetLatestVersionNode.Request(url);
}
private void OnRequestCompleted(long result, long responseCode, string[] headers, byte[] body) {
string ResponseBody = Encoding.UTF8.GetString(body);
GD.Print(ResponseBody);
List<string> ResponseValues = [.. ResponseBody.Split(";")];
Globals.AccessLevel = ResponseValues[0];
Globals.LatestVersion = ResponseValues[1];
Label LatestVersionLabel = GetNode<Label>("LatestVersion");
LatestVersionLabel.Text = "Latest Version: " + Globals.LatestVersion;
}
}