Merge branch 'develop' into 'master'

UI优化,增加本地化功能

See merge request paper-chemis-community/game!4
This commit is contained in:
2026-04-01 09:34:32 +08:00
13 changed files with 151 additions and 41 deletions
+5 -4
View File
@@ -16,8 +16,9 @@ game/
- assets/ - assets/
- fonts/ - fonts/
- AlibabaPuHuiTi-3-65-Medium.ttf # 阿里巴巴普惠体 - AlibabaPuHuiTi-3-65-Medium.ttf # 阿里巴巴普惠体
- pics/ - translation/
- scenes - trans.csv
- scenes/
- main_menu.tscn - main_menu.tscn
- game.tscn - game.tscn
- settings.tscn - settings.tscn
@@ -43,7 +44,7 @@ game/
## 如何运行 ## 如何运行
请先运行数据后端,在游戏设置中输入后端 URL包含端口号和 `http://``https://` 前缀,或者选择本地已有的数据源,然后创建游戏或加入游戏开始游玩。 请先运行数据后端,在游戏设置中输入后端 URL包含端口号和 `http://``https://` 前缀,或者选择本地已有的数据源,然后创建游戏或加入游戏开始游玩。
## 最佳实践 ## 最佳实践
@@ -51,7 +52,7 @@ game/
你的开发应当遵循 Godot 引擎提供的[最佳实践](https://docs.godotengine.org/zh-cn/4.x/tutorials/best_practices/)及[GDScript 编写风格指南](https://docs.godotengine.org/zh-cn/4.x/tutorials/scripting/gdscript/gdscript_styleguide.html)。但下面提到的除外: 你的开发应当遵循 Godot 引擎提供的[最佳实践](https://docs.godotengine.org/zh-cn/4.x/tutorials/best_practices/)及[GDScript 编写风格指南](https://docs.godotengine.org/zh-cn/4.x/tutorials/scripting/gdscript/gdscript_styleguide.html)。但下面提到的除外:
`autoload` 目录下的单例脚本使用大驼峰式命名,其余脚本均应使用小蛇形式命。所有节点均应使用大驼峰式命名。 `autoload` 目录下的单例脚本使用大驼峰式命名,其余脚本均应使用小蛇形式命。所有节点均应使用大驼峰式命名。
除连接了信号或 HTTPRequest、MultiplayerAPI 的函数外,任何函数都不应该以下划线(`_`)开头。 除连接了信号或 HTTPRequest、MultiplayerAPI 的函数外,任何函数都不应该以下划线(`_`)开头。
+34
View File
@@ -0,0 +1,34 @@
keys,en,zh-cn
en,English,English
zh-cn,简体中文,简体中文
MAINMENU_TITLE,Paper Chemis Community,纸片化学社区版
UI_CONFIRM,Confirm,确定
MAINMENU_CREATEGAME,Create LAN Game,创建局域网游戏
MAINMENU_INPUTPLAYERNUM,Please Input max Player Number (2~4),请输入最大玩家数24
MAINMENU_PLAYERNUMERROR,Error! Please Input an integer between 2 and 4,输入数据错误请输入24之间的整数
MAINMENU_CREATEROOM,Create Room,创建房间
MAINMENU_JOINGAME,Join LAN Game,加入局域网游戏
MAINMENU_INPUTSERVERIP,Please Input IP Address (No Port),请输入服务器IP无需加端口
MAINMENU_JOINROOM,Join Room,加入房间
MAINMENU_QUITGAME,Quit Game,退出游戏
MAINMENU_SETTINGS,Settings,设置
SETTINGS_SETSOURCE,Set Data Source,数据源设置
SETTINGS_IPBEGIN,Auto IP Beginning,自动识别 IP 地址的起始部分
SETTINGS_NICKNAME,Nickname in Game,局内显示昵称
SETTINGS_LOADDATA,Load Local Data,加载本地数据
SETTINGS_SAVESETTINGS,Save Settings,保存设置
SETTINGS_BACK,Back,返回
SETTINGS_DOWNLOAD,Download,下载文件
SETTINGS_LOAD,Load Data,加载数据
SETTINGS_CHOOSELANG,Choose Language,选择语言
SETTINGS_TIP_NULL,Tip: None,提示:无
SETTINGS_TIP_SAVESETTINGS,Tip: Successfully saved settings,提示:保存设置成功
SETTINGS_TIP_STARTDOWNLOAD,Tip: Have started downloading. do not close the settings page,提示:已开始下载,请勿关闭设置页面
SETTINGS_TIP_SOURCEERROR,Tip: Download failed. Data source path error,提示:下载失败。数据源路径错误
SETTINGS_TIP_REQUESTERROR,Tip: Download failed. Failed to create a request,提示:下载失败。创建请求失败
SETTINGS_TIP_LOADING,Tip: Loading Resources. do not close the settings page,提示:正在加载资源,请勿关闭设置页面
SETTINGS_TIP_LOADED,Tip: Finish Loading,提示:完成加载
SETTINGS_TIP_NOLOCALSOURCE,Tip: No local data or no selection,提示:无本地数据或未选择,无法加载
GAMEUI_URNULL,Roome Running: You are XXX XXXX,啊啊啊啊啊:啊啊啊啊
GAMEUI_URHOST,Room Running: You are the Host,房间运行中:您是房主
GAMEUI_URGUEST,Room Running: You are a Guest,房间运行中:您是房客
1 keys en zh-cn
2 en English English
3 zh-cn 简体中文 简体中文
4 MAINMENU_TITLE Paper Chemis Community 纸片化学社区版
5 UI_CONFIRM Confirm 确定
6 MAINMENU_CREATEGAME Create LAN Game 创建局域网游戏
7 MAINMENU_INPUTPLAYERNUM Please Input max Player Number (2~4) 请输入最大玩家数(2~4)
8 MAINMENU_PLAYERNUMERROR Error! Please Input an integer between 2 and 4 输入数据错误!请输入2~4之间的整数!
9 MAINMENU_CREATEROOM Create Room 创建房间
10 MAINMENU_JOINGAME Join LAN Game 加入局域网游戏
11 MAINMENU_INPUTSERVERIP Please Input IP Address (No Port) 请输入服务器IP(无需加端口)
12 MAINMENU_JOINROOM Join Room 加入房间
13 MAINMENU_QUITGAME Quit Game 退出游戏
14 MAINMENU_SETTINGS Settings 设置
15 SETTINGS_SETSOURCE Set Data Source 数据源设置
16 SETTINGS_IPBEGIN Auto IP Beginning 自动识别 IP 地址的起始部分
17 SETTINGS_NICKNAME Nickname in Game 局内显示昵称
18 SETTINGS_LOADDATA Load Local Data 加载本地数据
19 SETTINGS_SAVESETTINGS Save Settings 保存设置
20 SETTINGS_BACK Back 返回
21 SETTINGS_DOWNLOAD Download 下载文件
22 SETTINGS_LOAD Load Data 加载数据
23 SETTINGS_CHOOSELANG Choose Language 选择语言
24 SETTINGS_TIP_NULL Tip: None 提示:无
25 SETTINGS_TIP_SAVESETTINGS Tip: Successfully saved settings 提示:保存设置成功
26 SETTINGS_TIP_STARTDOWNLOAD Tip: Have started downloading. do not close the settings page 提示:已开始下载,请勿关闭设置页面
27 SETTINGS_TIP_SOURCEERROR Tip: Download failed. Data source path error 提示:下载失败。数据源路径错误
28 SETTINGS_TIP_REQUESTERROR Tip: Download failed. Failed to create a request 提示:下载失败。创建请求失败
29 SETTINGS_TIP_LOADING Tip: Loading Resources. do not close the settings page 提示:正在加载资源,请勿关闭设置页面
30 SETTINGS_TIP_LOADED Tip: Finish Loading 提示:完成加载
31 SETTINGS_TIP_NOLOCALSOURCE Tip: No local data or no selection 提示:无本地数据或未选择,无法加载
32 GAMEUI_URNULL Roome Running: You are XXX XXXX 啊啊啊啊啊:啊啊啊啊
33 GAMEUI_URHOST Room Running: You are the Host 房间运行中:您是房主
34 GAMEUI_URGUEST Room Running: You are a Guest 房间运行中:您是房客
+19
View File
@@ -0,0 +1,19 @@
[remap]
importer="csv_translation"
type="Translation"
uid="uid://bkanjeodutw2s"
[deps]
files=["res://assets/translation/trans.en.translation", "res://assets/translation/trans.zh.translation"]
source_file="res://assets/translation/trans.csv"
dest_files=["res://assets/translation/trans.en.translation", "res://assets/translation/trans.zh.translation"]
[params]
compress=1
delimiter=0
unescape_keys=false
unescape_translations=true
Binary file not shown.
Binary file not shown.
+4
View File
@@ -31,6 +31,10 @@ DownloadManager="*res://scripts/autoload/DownloadManager.gd"
window/size/viewport_width=2560 window/size/viewport_width=2560
window/size/viewport_height=1440 window/size/viewport_height=1440
[internationalization]
locale/translations=PackedStringArray("res://assets/translation/trans.en.translation", "res://assets/translation/trans.zh.translation")
[rendering] [rendering]
renderer/rendering_method="gl_compatibility" renderer/rendering_method="gl_compatibility"
+1 -1
View File
@@ -20,7 +20,7 @@ offset_right = 255.0
offset_bottom = 63.0 offset_bottom = 63.0
theme_override_fonts/font = ExtResource("1_uwrxv") theme_override_fonts/font = ExtResource("1_uwrxv")
theme_override_font_sizes/font_size = 20 theme_override_font_sizes/font_size = 20
text = "啊啊啊啊啊:啊啊啊啊" text = "GAMEUI_URNULL"
[node name="IPLabel" type="Label" parent="." unique_id=2017838611] [node name="IPLabel" type="Label" parent="." unique_id=2017838611]
offset_left = 54.0 offset_left = 54.0
+20 -11
View File
@@ -23,7 +23,7 @@ offset_bottom = 207.0
size_flags_horizontal = 4 size_flags_horizontal = 4
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 84 theme_override_font_sizes/font_size = 84
text = "纸片化学社区版" text = "MAINMENU_TITLE"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="StartGame" type="Button" parent="." unique_id=1933485497] [node name="StartGame" type="Button" parent="." unique_id=1933485497]
@@ -33,7 +33,7 @@ offset_right = 1247.0385
offset_bottom = 632.0 offset_bottom = 632.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 = "MAINMENU_CREATEGAME"
[node name="JoinGame" type="Button" parent="." unique_id=1061477634] [node name="JoinGame" type="Button" parent="." unique_id=1061477634]
offset_left = 932.0 offset_left = 932.0
@@ -42,7 +42,16 @@ offset_right = 1248.0385
offset_bottom = 847.0 offset_bottom = 847.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 = "MAINMENU_JOINGAME"
[node name="QuitGame" type="Button" parent="." unique_id=70898198]
offset_left = 932.0
offset_top = 959.0
offset_right = 1248.0386
offset_bottom = 1058.0
theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 36
text = "MAINMENU_QUITGAME"
[node name="CreateGameUI" type="Node2D" parent="." unique_id=462604530] [node name="CreateGameUI" type="Node2D" parent="." unique_id=462604530]
visible = false visible = false
@@ -68,7 +77,7 @@ offset_right = 330.81818
offset_bottom = 224.0 offset_bottom = 224.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 = "MAINMENU_CREATEROOM"
[node name="Label" type="Label" parent="CreateGameUI" unique_id=1494594728] [node name="Label" type="Label" parent="CreateGameUI" unique_id=1494594728]
offset_left = 131.0 offset_left = 131.0
@@ -76,7 +85,7 @@ offset_top = 88.0
offset_right = 326.0 offset_right = 326.0
offset_bottom = 126.0 offset_bottom = 126.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
text = "请输入最大玩家数24" text = "MAINMENU_INPUTPLAYERNUM"
[node name="Warn" type="Node2D" parent="CreateGameUI" unique_id=961920457] [node name="Warn" type="Node2D" parent="CreateGameUI" unique_id=961920457]
visible = false visible = false
@@ -93,7 +102,7 @@ offset_left = 167.0
offset_top = 125.0 offset_top = 125.0
offset_right = 279.0 offset_right = 279.0
offset_bottom = 188.0 offset_bottom = 188.0
text = "确定" text = "UI_CONFIRM"
[node name="WarnLabel" type="Label" parent="CreateGameUI/Warn" unique_id=320937650] [node name="WarnLabel" type="Label" parent="CreateGameUI/Warn" unique_id=320937650]
offset_left = 126.0 offset_left = 126.0
@@ -101,8 +110,7 @@ offset_top = 64.0
offset_right = 316.0 offset_right = 316.0
offset_bottom = 107.0 offset_bottom = 107.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
text = "输入数据错误! text = "MAINMENU_PLAYERNUMERROR"
请输入24之间的整数"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="JoinGameUI" type="Node2D" parent="." unique_id=1134060090] [node name="JoinGameUI" type="Node2D" parent="." unique_id=1134060090]
@@ -129,7 +137,7 @@ offset_right = 330.81818
offset_bottom = 224.0 offset_bottom = 224.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 = "MAINMENU_JOINROOM"
[node name="Label" type="Label" parent="JoinGameUI" unique_id=1927653368] [node name="Label" type="Label" parent="JoinGameUI" unique_id=1927653368]
offset_left = 131.0 offset_left = 131.0
@@ -137,7 +145,7 @@ offset_top = 88.0
offset_right = 326.0 offset_right = 326.0
offset_bottom = 126.0 offset_bottom = 126.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
text = "请输入服务器IP无需加端口" text = "MAINMENU_INPUTSERVERIP"
[node name="SettingButton" type="Button" parent="." unique_id=1367541903] [node name="SettingButton" type="Button" parent="." unique_id=1367541903]
offset_left = 1998.0 offset_left = 1998.0
@@ -146,10 +154,11 @@ offset_right = 2106.0
offset_bottom = 200.0 offset_bottom = 200.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 = "MAINMENU_SETTINGS"
[connection signal="pressed" from="StartGame" to="." method="_on_start_game_pressed"] [connection signal="pressed" from="StartGame" to="." method="_on_start_game_pressed"]
[connection signal="pressed" from="JoinGame" to="." method="_on_join_game_pressed"] [connection signal="pressed" from="JoinGame" to="." method="_on_join_game_pressed"]
[connection signal="pressed" from="QuitGame" to="." method="_on_quit_game_pressed"]
[connection signal="pressed" from="CreateGameUI/CreateGameButton" to="CreateGameUI" method="_on_create_game_button_pressed"] [connection signal="pressed" from="CreateGameUI/CreateGameButton" to="CreateGameUI" method="_on_create_game_button_pressed"]
[connection signal="pressed" from="CreateGameUI/Warn/WarnButton" to="CreateGameUI" method="_on_warn_button_pressed"] [connection signal="pressed" from="CreateGameUI/Warn/WarnButton" to="CreateGameUI" method="_on_warn_button_pressed"]
[connection signal="pressed" from="JoinGameUI/JoinGameButton" to="JoinGameUI" method="_on_join_game_button_pressed"] [connection signal="pressed" from="JoinGameUI/JoinGameButton" to="JoinGameUI" method="_on_join_game_button_pressed"]
+39 -14
View File
@@ -23,7 +23,7 @@ offset_right = 193.0
offset_bottom = 90.0 offset_bottom = 90.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 = "SETTINGS_SETSOURCE"
[node name="LineEdit" type="LineEdit" parent="DataSetting" unique_id=34011310] [node name="LineEdit" type="LineEdit" parent="DataSetting" unique_id=34011310]
offset_left = 217.0 offset_left = 217.0
@@ -44,7 +44,7 @@ offset_right = 193.0
offset_bottom = 90.0 offset_bottom = 90.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 = "自动识别IP地址的起始部分" text = "SETTINGS_IPBEGIN"
[node name="LineEdit" type="LineEdit" parent="IPBeginSetting" unique_id=1179342188] [node name="LineEdit" type="LineEdit" parent="IPBeginSetting" unique_id=1179342188]
offset_left = 424.0 offset_left = 424.0
@@ -65,7 +65,7 @@ offset_right = 193.0
offset_bottom = 90.0 offset_bottom = 90.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 = "SETTINGS_NICKNAME"
[node name="LineEdit" type="LineEdit" parent="UsernameSetting" unique_id=694430941] [node name="LineEdit" type="LineEdit" parent="UsernameSetting" unique_id=694430941]
offset_left = 424.0 offset_left = 424.0
@@ -86,7 +86,7 @@ offset_right = 132.0
offset_bottom = 40.0 offset_bottom = 40.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 = "SETTINGS_LOADDATA"
[node name="ChooseSource" type="OptionButton" parent="LoadSource" unique_id=1045074926] [node name="ChooseSource" type="OptionButton" parent="LoadSource" unique_id=1045074926]
offset_left = 381.0 offset_left = 381.0
@@ -95,14 +95,39 @@ offset_right = 830.0
offset_bottom = 60.0 offset_bottom = 60.0
theme_override_font_sizes/font_size = 25 theme_override_font_sizes/font_size = 25
[node name="SaveButton" type="Button" parent="." unique_id=1377249836] [node name="ChooseLanguage" type="Node2D" parent="." unique_id=323270128]
offset_left = 150.0 position = Vector2(39, 405)
offset_top = 1321.0 metadata/_edit_group_ = true
offset_right = 314.0
offset_bottom = 1398.0 [node name="ChooseLanguageLabel" type="Label" parent="ChooseLanguage" unique_id=1719434618]
offset_left = 9.0
offset_top = 10.0
offset_right = 132.0
offset_bottom = 40.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 = "SETTINGS_CHOOSELANG"
[node name="ChooseLanguage" type="OptionButton" parent="ChooseLanguage" unique_id=476490830]
offset_left = 381.0
offset_top = 5.0
offset_right = 830.0
offset_bottom = 60.0
theme_override_font_sizes/font_size = 25
item_count = 2
popup/item_0/text = "en"
popup/item_0/id = 0
popup/item_1/text = "zh-cn"
popup/item_1/id = 1
[node name="SaveButton" type="Button" parent="." unique_id=1377249836]
offset_left = 132.0
offset_top = 1315.0
offset_right = 338.0
offset_bottom = 1392.0
theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30
text = "SETTINGS_SAVESETTINGS"
[node name="DownloadButton" type="Button" parent="." unique_id=315804661] [node name="DownloadButton" type="Button" parent="." unique_id=315804661]
offset_left = 598.0 offset_left = 598.0
@@ -111,7 +136,7 @@ offset_right = 774.0
offset_bottom = 1405.0 offset_bottom = 1405.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 = "SETTINGS_DOWNLOAD"
[node name="CancelButton" type="Button" parent="." unique_id=135993345] [node name="CancelButton" type="Button" parent="." unique_id=135993345]
offset_left = 371.0 offset_left = 371.0
@@ -120,7 +145,7 @@ offset_right = 550.0
offset_bottom = 1394.0 offset_bottom = 1394.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 = "SETTINGS_BACK"
[node name="LoadButton" type="Button" parent="." unique_id=2015694853] [node name="LoadButton" type="Button" parent="." unique_id=2015694853]
offset_left = 135.0 offset_left = 135.0
@@ -129,7 +154,7 @@ offset_right = 311.0
offset_bottom = 1287.0 offset_bottom = 1287.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 = "SETTINGS_LOAD"
[node name="Tips" type="Label" parent="." unique_id=1777076648] [node name="Tips" type="Label" parent="." unique_id=1777076648]
offset_left = 893.0 offset_left = 893.0
@@ -138,7 +163,7 @@ offset_right = 1920.0
offset_bottom = 1388.0 offset_bottom = 1388.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
text = "提示:无" text = "SETTINGS_TIP_NULL"
[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="DownloadButton" to="." method="_on_download_button_pressed"]
+6
View File
@@ -12,3 +12,9 @@ func set_texture(pic: String) -> void:
func set_card(cname: String) -> void: func set_card(cname: String) -> void:
card_name = cname card_name = cname
set_texture("user://download/sources/%s/assets/pics/%s" % [DownloadManager.uuid, GameManager.pic_list[card_name]]) set_texture("user://download/sources/%s/assets/pics/%s" % [DownloadManager.uuid, GameManager.pic_list[card_name]])
func set_pos(x: int, y: int) -> void:
$Sprite.position = Vector2(x, y)
func get_pos() -> Vector2:
return $Sprite.position
+5 -2
View File
@@ -8,18 +8,21 @@ func _ready() -> void:
init() init()
var card = create_card("Oxygen") var card = create_card("Oxygen")
card.show() card.show()
card.set_pos(300, 300)
print(card.get_pos())
func init() -> void: func init() -> void:
if multiplayer.is_server(): if multiplayer.is_server():
$IsServerLabel.text = "房间运行中:您是房主" $IsServerLabel.text = "GAMEUI_URHOST"
else: else:
$IsServerLabel.text = "房间运行中:您是房客" $IsServerLabel.text = "GAMEUI_URGUEST"
var addresses: PackedStringArray = IP.get_local_addresses() var addresses: PackedStringArray = IP.get_local_addresses()
var ipaddress: String = "" var ipaddress: String = ""
for address in addresses: for address in addresses:
if address.substr(0, GameManager.ip_begin.length()) == GameManager.ip_begin: if address.substr(0, GameManager.ip_begin.length()) == GameManager.ip_begin:
ipaddress = address ipaddress = address
break
$IPLabel.text = ipaddress $IPLabel.text = ipaddress
$Player1/Username.text = GameManager.username $Player1/Username.text = GameManager.username
+3 -1
View File
@@ -7,6 +7,8 @@ func _on_join_game_pressed() -> void:
func _on_start_game_pressed() -> void: func _on_start_game_pressed() -> void:
$CreateGameUI.show() $CreateGameUI.show()
func _on_setting_button_pressed() -> void: func _on_setting_button_pressed() -> void:
SceneManager.goto_scene("settings") SceneManager.goto_scene("settings")
func _on_quit_game_pressed() -> void:
get_tree().quit()
+15 -8
View File
@@ -9,6 +9,12 @@ func init_text() -> void:
$IPBeginSetting/LineEdit.text = GameManager.ip_begin $IPBeginSetting/LineEdit.text = GameManager.ip_begin
$UsernameSetting/LineEdit.text = GameManager.username $UsernameSetting/LineEdit.text = GameManager.username
$LoadSource/ChooseSource.select(GameManager.source) $LoadSource/ChooseSource.select(GameManager.source)
var language = "automatic"
if language == "automatic":
var preferred_language = OS.get_locale_language()
TranslationServer.set_locale(preferred_language)
else:
TranslationServer.set_locale(language)
func init_sources() -> void: func init_sources() -> void:
DownloadManager.get_sources() DownloadManager.get_sources()
@@ -20,7 +26,8 @@ func _on_save_button_pressed() -> void:
GameManager.ip_begin = $IPBeginSetting/LineEdit.text GameManager.ip_begin = $IPBeginSetting/LineEdit.text
GameManager.username = $UsernameSetting/LineEdit.text GameManager.username = $UsernameSetting/LineEdit.text
GameManager.source = $LoadSource/ChooseSource.get_selected() GameManager.source = $LoadSource/ChooseSource.get_selected()
SceneManager.goto_scene("main_menu") TranslationServer.set_locale($ChooseLanguage/ChooseLanguage.text)
$Tips.text = "SETTINGS_TIP_SAVESETTINGS"
func _on_cancel_button_pressed() -> void: func _on_cancel_button_pressed() -> void:
@@ -28,24 +35,24 @@ func _on_cancel_button_pressed() -> void:
func _on_download_button_pressed() -> void: func _on_download_button_pressed() -> void:
$Tips.text = "提示:已开始下载,请勿关闭设置页面" $Tips.text = "SETTINGS_TIP_STARTDOWNLOAD"
var result: int = await DownloadManager.download_from_origin() var result: int = await DownloadManager.download_from_origin()
if result == 1: if result == 1:
$Tips.text = "提示:下载失败。数据源路径错误" $Tips.text = "SETTINGS_TIP_SOURCEERROR"
return return
elif result == 2: elif result == 2:
$Tips.text = "提示:下载失败。创建请求失败" $Tips.text = "SETTINGS_TIP_REQUESTERROR"
return return
$Tips.text = "提示:正在加载资源,请勿关闭设置页面" $Tips.text = "SETTINGS_TIP_LOADING"
DownloadManager.load_resource() DownloadManager.load_resource()
$Tips.text = "提示:完成加载" $Tips.text = "SETTINGS_TIP_LOADED"
func _on_load_button_pressed() -> void: func _on_load_button_pressed() -> void:
if GameManager.sources.size() == 0 or GameManager.source == -1: if GameManager.sources.size() == 0 or GameManager.source == -1:
$Tips.text = "提示:无本地数据或未选择,无法加载" $Tips.text = "SETTINGS_TIP_NOLOCALSOURCE"
return; return;
DownloadManager.uuid = GameManager.sources[$LoadSource/ChooseSource.text] DownloadManager.uuid = GameManager.sources[$LoadSource/ChooseSource.text]
DownloadManager.load_resource() DownloadManager.load_resource()
$Tips.text = "提示:完成加载" $Tips.text = "SETTINGS_TIP_LOADED"