From f8880b7e92026f8da38f56b38de69e0db7b20f06 Mon Sep 17 00:00:00 2001 From: Tiger Date: Wed, 21 Jan 2026 14:53:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=96=87=E4=BB=B6=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/game.tscn | 38 +++++++++++++++++++------ scenes/settings.tscn | 3 ++ scripts/autoload/DownloadManager.gd | 44 ++++++++++++++++++++--------- scripts/game/game.gd | 2 ++ 4 files changed, 65 insertions(+), 22 deletions(-) diff --git a/scenes/game.tscn b/scenes/game.tscn index 3fe28db..cfa4174 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -14,19 +14,41 @@ offset_bottom = 1167.0 color = Color(0.7058824, 0.6862745, 0, 1) [node name="IsServerLabel" type="Label" parent="."] -offset_left = 30.0 -offset_top = 11.0 -offset_right = 227.0 -offset_bottom = 59.0 +offset_left = 58.0 +offset_top = 15.0 +offset_right = 255.0 +offset_bottom = 63.0 theme_override_fonts/font = ExtResource("1_uwrxv") theme_override_font_sizes/font_size = 20 text = "啊啊啊啊啊:啊啊啊啊" [node name="IPLabel" type="Label" parent="."] -offset_left = 1742.0 -offset_top = 14.0 -offset_right = 1844.0 -offset_bottom = 59.0 +offset_left = 54.0 +offset_top = 53.0 +offset_right = 156.0 +offset_bottom = 98.0 theme_override_fonts/font = ExtResource("1_uwrxv") theme_override_font_sizes/font_size = 24 text = "127.0.0.2" + +[node name="Player1" type="Node2D" parent="."] + +[node name="Username" type="Label" parent="Player1"] +offset_left = 57.0 +offset_top = 1003.0 +offset_right = 539.0 +offset_bottom = 1061.0 +theme_override_fonts/font = ExtResource("1_uwrxv") +theme_override_font_sizes/font_size = 35 +text = "Player1" + +[node name="Player2" type="Node2D" parent="."] + +[node name="Username" type="Label" parent="Player2"] +offset_left = 1446.0 +offset_top = 15.0 +offset_right = 1928.0 +offset_bottom = 73.0 +theme_override_fonts/font = ExtResource("1_uwrxv") +theme_override_font_sizes/font_size = 35 +text = "Player2" diff --git a/scenes/settings.tscn b/scenes/settings.tscn index 33c5fb3..65a379b 100644 --- a/scenes/settings.tscn +++ b/scenes/settings.tscn @@ -107,6 +107,9 @@ offset_left = 711.0 offset_top = 913.0 offset_right = 1738.0 offset_bottom = 966.0 +theme_override_fonts/font = ExtResource("2_6wm04") +theme_override_font_sizes/font_size = 50 +text = "提示:无" [connection signal="pressed" from="SaveButton" to="." method="_on_save_button_pressed"] [connection signal="pressed" from="DownloadButton" to="." method="_on_download_button_pressed"] diff --git a/scripts/autoload/DownloadManager.gd b/scripts/autoload/DownloadManager.gd index 49d7b1b..c1e47fe 100644 --- a/scripts/autoload/DownloadManager.gd +++ b/scripts/autoload/DownloadManager.gd @@ -1,24 +1,40 @@ extends Node +func _ready() -> void: + print(OS.get_user_data_dir()) + +func create_file(file_path: String) -> void: + var base_dir = file_path.get_base_dir() + if !DirAccess.dir_exists_absolute(base_dir): + DirAccess.make_dir_recursive_absolute(base_dir) + FileAccess.open(file_path, FileAccess.WRITE) + func download_file(server_path: String, local_path: String) -> void: - var http = HTTPRequest.new() - http.download_file = local_path - http.request(server_path) + var http = HTTPRequest.new() + add_child(http) + var file_path = "user://downloads_test/" + local_path + if !FileAccess.file_exists(file_path): + create_file(file_path) + http.set_download_file(file_path) + http.request(server_path) func download_from_origin() -> int: - var origin = GameManager.data_origin - var http = HTTPRequest.new() + var origin = GameManager.data_origin + var http = HTTPRequest.new() + add_child(http) - if origin.substr(0, 4) != "http": - return 1 - - if http.request(origin) != OK: - return 2 + if origin.substr(0, 4) != "http": + return 1 + + if http.request(origin) != OK: + return 2 - if origin[-1] != "/": - origin = origin + "/" + if origin[-1] != "/": + origin = origin + "/" - return 0 + download_file(origin + "card/id/Oxygen", "test_Oxygen.json") + + return 0 func load_resource(): - pass + pass diff --git a/scripts/game/game.gd b/scripts/game/game.gd index 50dd47b..3b1cd3e 100644 --- a/scripts/game/game.gd +++ b/scripts/game/game.gd @@ -15,3 +15,5 @@ func init() -> void: if address.substr(0, GameManager.ip_begin.length()) == GameManager.ip_begin: ipaddress = address $IPLabel.text = ipaddress + $Player1/Username.text = GameManager.username + \ No newline at end of file