feat(chess): 初始化棋盘和玩家颜色,优化代码结构,重构多人游戏代码
- 在 ChessGame 中初始化棋盘,根据玩家颜色设置棋子 - 更新 UI 显示玩家颜色 - 调整棋盘位置和 UI 布局 - 重构部分代码以提高可读性和维护性
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
script = ExtResource("1_3x8ac")
|
||||
|
||||
[node name="Chessboard" parent="." instance=ExtResource("1_yheur")]
|
||||
position = Vector2(360, 600)
|
||||
position = Vector2(360, 650)
|
||||
scale = Vector2(2.5, 2.5)
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
@ -19,41 +19,69 @@ offset_right = 720.0
|
||||
offset_bottom = 1280.0
|
||||
theme = ExtResource("3_rcfhx")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control"]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 81.0
|
||||
offset_bottom = 133.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Control/MarginContainer"]
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control/MarginContainer/HBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Control/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Control/VBoxContainer/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Home" type="Button" parent="Control/MarginContainer/HBoxContainer/MarginContainer"]
|
||||
[node name="Home" type="Button" parent="Control/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
text = "返回主页"
|
||||
|
||||
[node name="MarginContainer2" type="MarginContainer" parent="Control/MarginContainer/HBoxContainer"]
|
||||
[node name="MarginContainer2" type="MarginContainer" parent="Control/VBoxContainer/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Undo" type="Button" parent="Control/MarginContainer/HBoxContainer/MarginContainer2"]
|
||||
[node name="Undo" type="Button" parent="Control/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
text = "撤回"
|
||||
|
||||
[node name="MarginContainer3" type="MarginContainer" parent="Control/MarginContainer/HBoxContainer"]
|
||||
[node name="MarginContainer3" type="MarginContainer" parent="Control/VBoxContainer/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="ReInit" type="Button" parent="Control/MarginContainer/HBoxContainer/MarginContainer3"]
|
||||
[node name="ReInit" type="Button" parent="Control/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer3"]
|
||||
layout_mode = 2
|
||||
text = "重开"
|
||||
|
||||
[node name="MarginContainer3" type="MarginContainer" parent="Control/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HFlowContainer" type="HFlowContainer" parent="Control/VBoxContainer/MarginContainer3"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Control/VBoxContainer/MarginContainer3/HFlowContainer"]
|
||||
layout_mode = 2
|
||||
text = "You Are
|
||||
"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Control/VBoxContainer/MarginContainer3/HFlowContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
editable = false
|
||||
|
||||
[node name="Label2" type="Label" parent="Control/VBoxContainer/MarginContainer3/HFlowContainer"]
|
||||
layout_mode = 2
|
||||
text = "Turns On"
|
||||
|
||||
[node name="LineEdit2" type="LineEdit" parent="Control/VBoxContainer/MarginContainer3/HFlowContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
editable = false
|
||||
|
||||
[node name="MarginContainer2" type="MarginContainer" parent="Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
@ -69,7 +97,7 @@ layout_mode = 2
|
||||
text = "结束回合
|
||||
(提示对方结束)"
|
||||
|
||||
[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/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer/Home" to="." method="GoHome"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer2/Undo" to="." method="Undo"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer/MarginContainer/HBoxContainer/MarginContainer3/ReInit" to="." method="ReInit"]
|
||||
[connection signal="pressed" from="Control/MarginContainer2/Over" to="." method="BtnOver"]
|
||||
|
128
Scenes/Menu.tscn
128
Scenes/Menu.tscn
@ -1,128 +0,0 @@
|
||||
[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"]
|
||||
|
||||
[node name="Menu" 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_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
|
||||
offset_left = 49.0
|
||||
offset_top = 100.0
|
||||
offset_right = 171.0
|
||||
offset_bottom = 170.0
|
||||
text = "返回主页"
|
||||
|
||||
[node name="Name" type="Control" parent="."]
|
||||
anchors_preset = 0
|
||||
offset_left = 215.0
|
||||
offset_top = 109.0
|
||||
offset_right = 697.0
|
||||
offset_bottom = 168.0
|
||||
|
||||
[node name="Label" type="Label" parent="Name"]
|
||||
layout_mode = 2
|
||||
offset_left = 2.0
|
||||
offset_top = 1.0
|
||||
offset_right = 80.0
|
||||
offset_bottom = 47.0
|
||||
text = "名字"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="Name"]
|
||||
layout_mode = 2
|
||||
offset_left = 93.0
|
||||
offset_right = 320.0
|
||||
offset_bottom = 50.0
|
||||
|
||||
[node name="Button" type="Button" parent="Name"]
|
||||
layout_mode = 0
|
||||
offset_left = 340.0
|
||||
offset_top = 3.0
|
||||
offset_right = 428.0
|
||||
offset_bottom = 55.0
|
||||
text = "确认修改
|
||||
"
|
||||
|
||||
[node name="Server" type="Control" parent="."]
|
||||
anchors_preset = 0
|
||||
offset_left = 19.0
|
||||
offset_top = 184.0
|
||||
offset_right = 705.0
|
||||
offset_bottom = 1198.0
|
||||
|
||||
[node name="ItemList" type="ItemList" parent="Server"]
|
||||
layout_mode = 0
|
||||
offset_left = 15.0
|
||||
offset_top = 214.0
|
||||
offset_right = 678.0
|
||||
offset_bottom = 1059.0
|
||||
|
||||
[node name="ConnectServer" type="Button" parent="Server"]
|
||||
layout_mode = 0
|
||||
offset_left = 297.0
|
||||
offset_top = 17.0
|
||||
offset_right = 517.0
|
||||
offset_bottom = 90.0
|
||||
text = "重连服务器"
|
||||
|
||||
[node name="Flush" type="Button" parent="Server"]
|
||||
layout_mode = 0
|
||||
offset_left = 535.0
|
||||
offset_top = 17.0
|
||||
offset_right = 652.0
|
||||
offset_bottom = 81.0
|
||||
text = "Flush"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Server"]
|
||||
layout_mode = 0
|
||||
offset_left = 236.0
|
||||
offset_top = 35.0
|
||||
offset_right = 276.0
|
||||
offset_bottom = 75.0
|
||||
|
||||
[node name="Label" type="Label" parent="Server"]
|
||||
layout_mode = 0
|
||||
offset_left = 19.0
|
||||
offset_top = 37.0
|
||||
offset_right = 229.0
|
||||
offset_bottom = 79.0
|
||||
text = "服务器连接状态"
|
||||
|
||||
[node name="Dialogs" type="Control" parent="."]
|
||||
anchors_preset = 0
|
||||
|
||||
[node name="AcceptDialog" type="AcceptDialog" parent="Dialogs"]
|
||||
initial_position = 2
|
||||
size = Vector2i(100, 118)
|
||||
|
||||
[node name="PopupMenu" type="PopupMenu" parent="Dialogs"]
|
||||
|
||||
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="Dialogs"]
|
||||
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
|
||||
offset_right = 677.0
|
||||
offset_bottom = 371.0
|
||||
|
||||
[connection signal="pressed" from="Home" to="." method="goToHome"]
|
||||
[connection signal="pressed" from="Name/Button" to="." method="EnterName"]
|
||||
[connection signal="item_activated" from="Server/ItemList" to="." method="OnItemSelected"]
|
||||
[connection signal="pressed" from="Server/ConnectServer" to="." method="Connect"]
|
||||
[connection signal="pressed" from="Server/Flush" to="." method="FlushData"]
|
@ -147,6 +147,7 @@ size_flags_horizontal = 3
|
||||
text = "GetUserDataDir"
|
||||
|
||||
[connection signal="pressed" from="BoxContainer/MarginContainer/Back" to="." method="OnBack"]
|
||||
[connection signal="pressed" from="BoxContainer/MarginContainer7/Button" to="." method="OnSave"]
|
||||
[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"]
|
||||
|
Reference in New Issue
Block a user