feat: 将游戏分辨率改为1920*1080,增加下载数据按钮
This commit is contained in:
@@ -20,6 +20,12 @@ config/icon="res://icon.svg"
|
|||||||
MultiGame="*res://scripts/autoload/MultiGame.gd"
|
MultiGame="*res://scripts/autoload/MultiGame.gd"
|
||||||
SceneManager="*res://scripts/autoload/SceneManager.gd"
|
SceneManager="*res://scripts/autoload/SceneManager.gd"
|
||||||
GameManager="*res://scripts/autoload/GameManager.gd"
|
GameManager="*res://scripts/autoload/GameManager.gd"
|
||||||
|
DownloadManager="*res://scripts/autoload/DownloadManager.gd"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1920
|
||||||
|
window/size/viewport_height=1080
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -9,8 +9,8 @@ script = ExtResource("1_yqjtg")
|
|||||||
[node name="Background" type="ColorRect" parent="."]
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
offset_left = -34.0
|
offset_left = -34.0
|
||||||
offset_top = -27.0
|
offset_top = -27.0
|
||||||
offset_right = 1186.0
|
offset_right = 1954.0
|
||||||
offset_bottom = 694.0
|
offset_bottom = 1167.0
|
||||||
color = Color(0.7058824, 0.6862745, 0, 1)
|
color = Color(0.7058824, 0.6862745, 0, 1)
|
||||||
|
|
||||||
[node name="IsServerLabel" type="Label" parent="."]
|
[node name="IsServerLabel" type="Label" parent="."]
|
||||||
@@ -23,10 +23,10 @@ theme_override_font_sizes/font_size = 20
|
|||||||
text = "啊啊啊啊啊:啊啊啊啊"
|
text = "啊啊啊啊啊:啊啊啊啊"
|
||||||
|
|
||||||
[node name="IPLabel" type="Label" parent="."]
|
[node name="IPLabel" type="Label" parent="."]
|
||||||
offset_left = 948.0
|
offset_left = 1742.0
|
||||||
offset_top = 11.0
|
offset_top = 14.0
|
||||||
offset_right = 1052.0
|
offset_right = 1844.0
|
||||||
offset_bottom = 46.0
|
offset_bottom = 59.0
|
||||||
theme_override_fonts/font = ExtResource("1_uwrxv")
|
theme_override_fonts/font = ExtResource("1_uwrxv")
|
||||||
theme_override_font_sizes/font_size = 24
|
theme_override_font_sizes/font_size = 24
|
||||||
text = "127.0.0.2"
|
text = "127.0.0.2"
|
||||||
|
|||||||
+16
-16
@@ -11,14 +11,14 @@ script = ExtResource("1_ekxnf")
|
|||||||
[node name="Background" type="ColorRect" parent="."]
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
offset_left = -24.0
|
offset_left = -24.0
|
||||||
offset_top = -22.0
|
offset_top = -22.0
|
||||||
offset_right = 1183.0
|
offset_right = 1925.0
|
||||||
offset_bottom = 647.0
|
offset_bottom = 1153.0
|
||||||
color = Color(0.7058824, 0.6862745, 0, 1)
|
color = Color(0.7058824, 0.6862745, 0, 1)
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="."]
|
[node name="Title" type="Label" parent="."]
|
||||||
offset_left = 304.0
|
offset_left = 540.0
|
||||||
offset_top = 58.0
|
offset_top = 58.0
|
||||||
offset_right = 883.0
|
offset_right = 1119.0
|
||||||
offset_bottom = 177.0
|
offset_bottom = 177.0
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
theme_override_fonts/font = ExtResource("1_l6cm7")
|
theme_override_fonts/font = ExtResource("1_l6cm7")
|
||||||
@@ -27,19 +27,19 @@ text = "纸片化学社区版"
|
|||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="StartGame" type="Button" parent="."]
|
[node name="StartGame" type="Button" parent="."]
|
||||||
offset_left = 397.0
|
offset_left = 672.0
|
||||||
offset_top = 227.0
|
offset_top = 355.0
|
||||||
offset_right = 713.03845
|
offset_right = 988.03845
|
||||||
offset_bottom = 326.0
|
offset_bottom = 454.0
|
||||||
theme_override_fonts/font = ExtResource("1_l6cm7")
|
theme_override_fonts/font = ExtResource("1_l6cm7")
|
||||||
theme_override_font_sizes/font_size = 36
|
theme_override_font_sizes/font_size = 36
|
||||||
text = "创建局域网游戏"
|
text = "创建局域网游戏"
|
||||||
|
|
||||||
[node name="JoinGame" type="Button" parent="."]
|
[node name="JoinGame" type="Button" parent="."]
|
||||||
offset_left = 396.0
|
offset_left = 666.0
|
||||||
offset_top = 373.0
|
offset_top = 509.0
|
||||||
offset_right = 712.03845
|
offset_right = 982.03845
|
||||||
offset_bottom = 472.0
|
offset_bottom = 608.0
|
||||||
theme_override_fonts/font = ExtResource("1_l6cm7")
|
theme_override_fonts/font = ExtResource("1_l6cm7")
|
||||||
theme_override_font_sizes/font_size = 36
|
theme_override_font_sizes/font_size = 36
|
||||||
text = "加入局域网游戏"
|
text = "加入局域网游戏"
|
||||||
@@ -139,10 +139,10 @@ theme_override_fonts/font = ExtResource("1_l6cm7")
|
|||||||
text = "请输入服务器IP(无需加端口)"
|
text = "请输入服务器IP(无需加端口)"
|
||||||
|
|
||||||
[node name="SettingButton" type="Button" parent="."]
|
[node name="SettingButton" type="Button" parent="."]
|
||||||
offset_left = 1029.0
|
offset_left = 1591.0
|
||||||
offset_top = 14.0
|
offset_top = 39.0
|
||||||
offset_right = 1137.0
|
offset_right = 1699.0
|
||||||
offset_bottom = 84.0
|
offset_bottom = 109.0
|
||||||
theme_override_fonts/font = ExtResource("1_l6cm7")
|
theme_override_fonts/font = ExtResource("1_l6cm7")
|
||||||
theme_override_font_sizes/font_size = 30
|
theme_override_font_sizes/font_size = 30
|
||||||
text = "设置"
|
text = "设置"
|
||||||
|
|||||||
+20
-10
@@ -9,8 +9,8 @@ script = ExtResource("1_r6d6q")
|
|||||||
[node name="Background" type="ColorRect" parent="."]
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
offset_left = -34.0
|
offset_left = -34.0
|
||||||
offset_top = -27.0
|
offset_top = -27.0
|
||||||
offset_right = 1186.0
|
offset_right = 1911.0
|
||||||
offset_bottom = 694.0
|
offset_bottom = 1050.0
|
||||||
color = Color(0.7058824, 0.6862745, 0, 1)
|
color = Color(0.7058824, 0.6862745, 0, 1)
|
||||||
|
|
||||||
[node name="DataSetting" type="Node2D" parent="."]
|
[node name="DataSetting" type="Node2D" parent="."]
|
||||||
@@ -76,22 +76,32 @@ theme_override_fonts/font = ExtResource("2_6wm04")
|
|||||||
theme_override_font_sizes/font_size = 24
|
theme_override_font_sizes/font_size = 24
|
||||||
|
|
||||||
[node name="SaveButton" type="Button" parent="."]
|
[node name="SaveButton" type="Button" parent="."]
|
||||||
offset_left = 56.0
|
offset_left = 89.0
|
||||||
offset_top = 520.0
|
offset_top = 902.0
|
||||||
offset_right = 220.0
|
offset_right = 253.0
|
||||||
offset_bottom = 597.0
|
offset_bottom = 979.0
|
||||||
theme_override_fonts/font = ExtResource("2_6wm04")
|
theme_override_fonts/font = ExtResource("2_6wm04")
|
||||||
theme_override_font_sizes/font_size = 30
|
theme_override_font_sizes/font_size = 30
|
||||||
text = "保存设置"
|
text = "保存设置"
|
||||||
|
|
||||||
|
[node name="DownloadButton" type="Button" parent="."]
|
||||||
|
offset_left = 495.0
|
||||||
|
offset_top = 912.0
|
||||||
|
offset_right = 671.0
|
||||||
|
offset_bottom = 1001.0
|
||||||
|
theme_override_fonts/font = ExtResource("2_6wm04")
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
text = "下载文件"
|
||||||
|
|
||||||
[node name="CancelButton" type="Button" parent="."]
|
[node name="CancelButton" type="Button" parent="."]
|
||||||
offset_left = 243.0
|
offset_left = 286.0
|
||||||
offset_top = 514.0
|
offset_top = 906.0
|
||||||
offset_right = 419.0
|
offset_right = 462.0
|
||||||
offset_bottom = 603.0
|
offset_bottom = 995.0
|
||||||
theme_override_fonts/font = ExtResource("2_6wm04")
|
theme_override_fonts/font = ExtResource("2_6wm04")
|
||||||
theme_override_font_sizes/font_size = 30
|
theme_override_font_sizes/font_size = 30
|
||||||
text = "取消"
|
text = "取消"
|
||||||
|
|
||||||
[connection signal="pressed" from="SaveButton" to="." method="_on_save_button_pressed"]
|
[connection signal="pressed" from="SaveButton" to="." method="_on_save_button_pressed"]
|
||||||
|
[connection signal="pressed" from="DownloadButton" to="." method="_on_download_button_pressed"]
|
||||||
[connection signal="pressed" from="CancelButton" to="." method="_on_cancel_button_pressed"]
|
[connection signal="pressed" from="CancelButton" to="." method="_on_cancel_button_pressed"]
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
@onready var http_request = $HTTPRequest
|
||||||
|
|
||||||
|
# 下载文件
|
||||||
|
func download_file(url: String, filename: String):
|
||||||
|
# 构建保存路径
|
||||||
|
var save_path = "user://" + filename
|
||||||
|
print("开始下载: ", url)
|
||||||
|
print("保存到: ", save_path)
|
||||||
|
|
||||||
|
# 发送请求
|
||||||
|
var error = http_request.request(url)
|
||||||
|
if error != OK:
|
||||||
|
push_error("请求发送失败: " + str(error))
|
||||||
|
return false
|
||||||
|
|
||||||
|
# 连接信号(一次性)
|
||||||
|
if http_request.is_connected("request_completed", _on_request_completed):
|
||||||
|
http_request.request_completed.disconnect(_on_request_completed)
|
||||||
|
|
||||||
|
http_request.request_completed.connect(_on_request_completed.bind(save_path), CONNECT_ONE_SHOT)
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
# 请求完成回调
|
||||||
|
func _on_request_completed(result, response_code, headers, body, save_path):
|
||||||
|
if result != HTTPRequest.RESULT_SUCCESS:
|
||||||
|
push_error("下载失败,错误代码: " + str(result))
|
||||||
|
return
|
||||||
|
|
||||||
|
if response_code != 200:
|
||||||
|
push_error("HTTP错误: " + str(response_code))
|
||||||
|
return
|
||||||
|
|
||||||
|
# 保存文件
|
||||||
|
var file = FileAccess.open(save_path, FileAccess.WRITE)
|
||||||
|
if file == null:
|
||||||
|
push_error("无法创建文件: " + save_path)
|
||||||
|
push_error("错误: " + str(FileAccess.get_open_error()))
|
||||||
|
return
|
||||||
|
|
||||||
|
file.store_buffer(body)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
print("文件保存成功: " + save_path)
|
||||||
|
print("文件大小: " + str(body.size()) + " 字节")
|
||||||
|
|
||||||
|
func download_from_origin() -> void:
|
||||||
|
if GameManager.data_origin.substr(0, 4) != "http":
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://ctiokhvk258u8
|
||||||
@@ -14,3 +14,7 @@ func _on_save_button_pressed() -> void:
|
|||||||
|
|
||||||
func _on_cancel_button_pressed() -> void:
|
func _on_cancel_button_pressed() -> void:
|
||||||
SceneManager.goto_scene("main_menu")
|
SceneManager.goto_scene("main_menu")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_download_button_pressed() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|||||||
Reference in New Issue
Block a user