feat: 重构多人游戏界面和代码,使用文件存储游戏配置,重构底层代码

This commit is contained in:
ZZY
2024-11-06 22:13:03 +08:00
parent d323a0bee7
commit d6cbb5e11d
30 changed files with 715 additions and 262 deletions

View File

@ -8,50 +8,68 @@
script = ExtResource("1_3x8ac")
[node name="Chessboard" parent="." instance=ExtResource("1_yheur")]
position = Vector2(360, 660)
position = Vector2(360, 600)
scale = Vector2(2.5, 2.5)
[node name="Control" type="Control" parent="."]
custom_minimum_size = Vector2(720, 1280)
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
offset_right = 720.0
offset_bottom = 1280.0
theme = ExtResource("3_rcfhx")
[node name="Over" type="Button" parent="Control"]
layout_mode = 0
offset_left = 270.0
offset_top = 1105.0
offset_right = 449.0
offset_bottom = 1209.0
[node name="MarginContainer" type="MarginContainer" parent="Control"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 81.0
grow_horizontal = 2
[node name="HBoxContainer" type="HBoxContainer" parent="Control/MarginContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="Control/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Home" type="Button" parent="Control/MarginContainer/HBoxContainer/MarginContainer"]
layout_mode = 2
text = "返回主页"
[node name="MarginContainer2" type="MarginContainer" parent="Control/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Undo" type="Button" parent="Control/MarginContainer/HBoxContainer/MarginContainer2"]
layout_mode = 2
size_flags_vertical = 4
text = "撤回"
[node name="MarginContainer3" type="MarginContainer" parent="Control/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ReInit" type="Button" parent="Control/MarginContainer/HBoxContainer/MarginContainer3"]
layout_mode = 2
text = "重开"
[node name="MarginContainer2" type="MarginContainer" parent="Control"]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -114.0
grow_horizontal = 2
grow_vertical = 0
[node name="Over" type="Button" parent="Control/MarginContainer2"]
layout_mode = 2
text = "结束回合
(提示对方结束)"
[node name="Home" type="Button" parent="Control"]
layout_mode = 0
offset_left = 55.0
offset_top = 56.0
offset_right = 157.0
offset_bottom = 164.0
text = "返回主页"
[node name="Undo" type="Button" parent="Control"]
layout_mode = 0
offset_left = 319.0
offset_top = 58.0
offset_right = 419.0
offset_bottom = 158.0
text = "撤回"
[node name="ReInit" type="Button" parent="Control"]
layout_mode = 0
offset_left = 578.0
offset_top = 55.0
offset_right = 678.0
offset_bottom = 155.0
text = "重开"
[connection signal="pressed" from="Control/Over" to="." method="BtnOver"]
[connection signal="pressed" from="Control/Home" to="." method="GoHome"]
[connection signal="pressed" from="Control/Undo" to="." method="Undo"]
[connection signal="pressed" from="Control/ReInit" to="." method="ReInit"]
[connection signal="pressed" from="Control/MarginContainer/HBoxContainer/MarginContainer/Home" to="." method="GoHome"]
[connection signal="pressed" from="Control/MarginContainer/HBoxContainer/MarginContainer2/Undo" to="." method="Undo"]
[connection signal="pressed" from="Control/MarginContainer/HBoxContainer/MarginContainer3/ReInit" to="." method="ReInit"]
[connection signal="pressed" from="Control/MarginContainer2/Over" to="." method="BtnOver"]

View File

@ -0,0 +1,17 @@
[gd_scene format=3 uid="uid://pc83bstfltn"]
[node name="ServerStatus" type="HBoxContainer"]
anchors_preset = -1
anchor_right = 0.176389
anchor_bottom = 0.0179687
offset_right = -126.0
metadata/_edit_use_anchors_ = true
[node name="Label" type="Label" parent="."]
layout_mode = 2
size_flags_horizontal = 0
text = "Server Status"
[node name="ColorRect" type="ColorRect" parent="."]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2

78
Scenes/GameLobby.tscn Normal file
View File

@ -0,0 +1,78 @@
[gd_scene load_steps=3 format=3 uid="uid://00jxjgnmfbn7"]
[ext_resource type="Theme" uid="uid://intlbeu8h82r" path="res://Asserts/defaultTheme.tres" id="1_ge0tq"]
[ext_resource type="Script" path="res://Scripts/Controllers/GameLobby.cs" id="2_blx46"]
[node name="GameLobby" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_ge0tq")
script = ExtResource("2_blx46")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="Button" type="Button" parent="MarginContainer/VBoxContainer/MarginContainer"]
layout_mode = 2
text = "Back
"
[node name="MarginContainer2" type="HFlowContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/MarginContainer2/MarginContainer"]
layout_mode = 2
text = "Connect States"
[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ColorRect" type="ColorRect" parent="MarginContainer/VBoxContainer/MarginContainer2/MarginContainer2"]
layout_mode = 2
size_flags_horizontal = 3
[node name="MarginContainer3" type="MarginContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="ItemList" type="ItemList" parent="MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
[node name="Dialogs" type="Control" parent="."]
layout_mode = 3
anchors_preset = 0
[node name="AcceptDialog" type="AcceptDialog" parent="Dialogs"]
auto_translate_mode = 1
initial_position = 2
size = Vector2i(100, 118)
[node name="PopupMenu" type="PopupMenu" parent="Dialogs"]
auto_translate_mode = 1
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="Dialogs"]
auto_translate_mode = 1
initial_position = 2
size = Vector2i(200, 118)
[connection signal="pressed" from="MarginContainer/VBoxContainer/MarginContainer/Button" to="." method="OnBack"]
[connection signal="item_activated" from="MarginContainer/VBoxContainer/MarginContainer3/ItemList" to="." method="OnItemSelected"]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=3 format=3 uid="uid://cl8nkm6j8s8jh"]
[gd_scene load_steps=3 format=3 uid="uid://bc7w0h2x4bbdh"]
[ext_resource type="Script" path="res://Scripts/Controllers/Menu.cs" id="1_chiyi"]
[ext_resource type="Theme" uid="uid://intlbeu8h82r" path="res://Asserts/defaultTheme.tres" id="1_mkeko"]
@ -13,6 +13,7 @@ grow_vertical = 2
theme = ExtResource("1_mkeko")
script = ExtResource("1_chiyi")
metadata/_edit_horizontal_guides_ = [141.0]
metadata/_edit_use_anchors_ = true
[node name="Home" type="Button" parent="."]
layout_mode = 0
@ -113,6 +114,7 @@ initial_position = 2
size = Vector2i(200, 118)
[node name="URL" type="LineEdit" parent="."]
visible = false
layout_mode = 0
offset_left = 37.0
offset_top = 290.0

157
Scenes/Setting.tscn Normal file
View File

@ -0,0 +1,157 @@
[gd_scene load_steps=4 format=3 uid="uid://c6gxufppw1fu3"]
[ext_resource type="Theme" uid="uid://intlbeu8h82r" path="res://Asserts/defaultTheme.tres" id="1_6yfoi"]
[ext_resource type="Script" path="res://Scripts/Controllers/Setting.cs" id="1_xbvb3"]
[ext_resource type="PackedScene" uid="uid://pc83bstfltn" path="res://Scenes/Entities/ServerStatus.tscn" id="3_e50hu"]
[node name="Setting" type="MarginContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_6yfoi")
script = ExtResource("1_xbvb3")
[node name="BoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="BoxContainer"]
layout_mode = 2
[node name="Back" type="Button" parent="BoxContainer/MarginContainer"]
layout_mode = 2
text = "Back"
[node name="MarginContainer7" type="MarginContainer" parent="BoxContainer"]
layout_mode = 2
[node name="Button" type="Button" parent="BoxContainer/MarginContainer7"]
layout_mode = 2
text = "Save"
[node name="MarginContainer2" type="MarginContainer" parent="BoxContainer"]
layout_mode = 2
[node name="Server" type="HFlowContainer" parent="BoxContainer/MarginContainer2"]
layout_mode = 2
[node name="Label" type="Label" parent="BoxContainer/MarginContainer2/Server"]
layout_mode = 2
text = "Server IP"
[node name="LineEdit" type="LineEdit" parent="BoxContainer/MarginContainer2/Server"]
layout_mode = 2
size_flags_horizontal = 3
[node name="MarginContainer3" type="MarginContainer" parent="BoxContainer"]
layout_mode = 2
[node name="Name" type="HFlowContainer" parent="BoxContainer/MarginContainer3"]
layout_mode = 2
[node name="Label" type="Label" parent="BoxContainer/MarginContainer3/Name"]
layout_mode = 2
text = "Name"
[node name="LineEdit" type="LineEdit" parent="BoxContainer/MarginContainer3/Name"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Button" type="Button" parent="BoxContainer/MarginContainer3/Name"]
visible = false
layout_mode = 2
text = "OK"
[node name="MarginContainer4" type="MarginContainer" parent="BoxContainer"]
layout_mode = 2
[node name="HFlowContainer" type="HFlowContainer" parent="BoxContainer/MarginContainer4"]
layout_mode = 2
[node name="ServerStatus" parent="BoxContainer/MarginContainer4/HFlowContainer" instance=ExtResource("3_e50hu")]
layout_mode = 2
size_flags_horizontal = 3
[node name="CheckButton" type="CheckButton" parent="BoxContainer/MarginContainer4/HFlowContainer"]
visible = false
layout_mode = 2
text = "Server Start"
[node name="MarginContainer5" type="MarginContainer" parent="BoxContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HFlowContainer" parent="BoxContainer/MarginContainer5"]
layout_mode = 2
[node name="Label" type="Label" parent="BoxContainer/MarginContainer5/HBoxContainer"]
layout_mode = 2
text = "Font Size"
[node name="FontSize" type="LineEdit" parent="BoxContainer/MarginContainer5/HBoxContainer"]
layout_mode = 2
editable = false
[node name="MarginContainer6" type="MarginContainer" parent="BoxContainer"]
layout_mode = 2
[node name="FontSizeBar" type="HSlider" parent="BoxContainer/MarginContainer6"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
min_value = 10.0
max_value = 50.0
value = 10.0
[node name="HBoxContainer" type="HFlowContainer" parent="BoxContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="BoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Button" type="Button" parent="BoxContainer/HBoxContainer/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "Clear Config"
[node name="MarginContainer2" type="MarginContainer" parent="BoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Button2" type="Button" parent="BoxContainer/HBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Clear User Data"
[node name="HFlowContainer" type="HFlowContainer" parent="BoxContainer"]
layout_mode = 2
[node name="Button" type="Button" parent="BoxContainer/HFlowContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "GetCacheDir"
[node name="Button2" type="Button" parent="BoxContainer/HFlowContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "GetConfigDir"
[node name="Button3" type="Button" parent="BoxContainer/HFlowContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "GetDataDir"
[node name="Button4" type="Button" parent="BoxContainer/HFlowContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "GetUserDataDir"
[connection signal="pressed" from="BoxContainer/MarginContainer/Back" to="." method="OnBack"]
[connection signal="text_changed" from="BoxContainer/MarginContainer2/Server/LineEdit" to="." method="OnServerUrlChanged"]
[connection signal="text_changed" from="BoxContainer/MarginContainer3/Name/LineEdit" to="." method="OnNameChanged"]
[connection signal="value_changed" from="BoxContainer/MarginContainer6/FontSizeBar" to="." method="OnFontSizeChanged"]
[connection signal="pressed" from="BoxContainer/HBoxContainer/MarginContainer2/Button2" to="." method="OnClearUserData"]
[connection signal="pressed" from="BoxContainer/HFlowContainer/Button" to="." method="OnGetCacheDir"]
[connection signal="pressed" from="BoxContainer/HFlowContainer/Button2" to="." method="OnGetConfigDir"]
[connection signal="pressed" from="BoxContainer/HFlowContainer/Button3" to="." method="OnGetDataDir"]
[connection signal="pressed" from="BoxContainer/HFlowContainer/Button4" to="." method="OnGetUserDataDir"]

View File

@ -1,3 +0,0 @@
[gd_scene format=3 uid="uid://dp044iptyvvh"]
[node name="Web" type="Node"]