Made it get the latest version from the servers
This commit is contained in:
1 parent
1a8f4de7f9
commit
3a4b905869
3 files changed
+27
No files matched your search
@@ -176,6 +176,8 @@ theme_override_font_sizes/font_size = 81
|
|||||||
text = "Latest Version: {Version Number}"
|
text = "Latest Version: {Version Number}"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="HTTPRequest" type="HTTPRequest" parent="VersionText/LatestVersion"]
|
||||||
|
|
||||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||||
stream = ExtResource("2_853f1")
|
stream = ExtResource("2_853f1")
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ using System;
|
|||||||
|
|
||||||
public partial class Globals : Node {
|
public partial class Globals : Node {
|
||||||
public static string LatestVersion = "";
|
public static string LatestVersion = "";
|
||||||
|
public static string AccessLevel = "";
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public partial class VersionChecker : Control {
|
public partial class VersionChecker : Control {
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
@@ -7,5 +9,27 @@ public partial class VersionChecker : Control {
|
|||||||
string GameVersion = ProjectSettings.GetSetting("application/config/version").AsString();
|
string GameVersion = ProjectSettings.GetSetting("application/config/version").AsString();
|
||||||
|
|
||||||
VersionLabel.Text = "Version: " + GameVersion;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user