UI: show roomID in table scene

This commit is contained in:
2020-05-29 20:58:45 +08:00
parent 46bbfef5cc
commit 7fa445c0bf
8 changed files with 132 additions and 27 deletions
+1
View File
@@ -1,6 +1,7 @@
extends Node extends Node
var my_user_id = 0 var my_user_id = 0
var my_room_id = 0
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
+4
View File
@@ -52,6 +52,8 @@ func on_create_request_completed(result, response_code, headers, body):
var res = json.result var res = json.result
if res["success"]==true: if res["success"]==true:
print_debug("room created") print_debug("room created")
var room_id = res["reason"]
Global.my_room_id = room_id
# connect to websocket # connect to websocket
ConnManager.connect_ws(Global.my_user_id) ConnManager.connect_ws(Global.my_user_id)
else: else:
@@ -65,6 +67,8 @@ func on_join_request_completed(result, response_code, headers, body):
var res = json.result var res = json.result
if res["success"]==true: if res["success"]==true:
print_debug("room joined") print_debug("room joined")
var room_id = res["reason"]
Global.my_room_id = room_id
# connect to websocket # connect to websocket
ConnManager.connect_ws(Global.my_user_id) ConnManager.connect_ws(Global.my_user_id)
else: else:
+25 -4
View File
@@ -52,10 +52,10 @@ __meta__ = {
} }
[node name="ButtonContainer" type="HBoxContainer" parent="."] [node name="ButtonContainer" type="HBoxContainer" parent="."]
margin_left = 621.264 margin_left = 561.0
margin_top = 859.261 margin_top = 856.611
margin_right = 1417.26 margin_right = 1367.0
margin_bottom = 1018.26 margin_bottom = 1015.61
custom_constants/separation = 40 custom_constants/separation = 40
alignment = 1 alignment = 1
__meta__ = { __meta__ = {
@@ -247,6 +247,27 @@ texture_normal = ExtResource( 6 )
[node name="CreateRoomRequest" type="HTTPRequest" parent="."] [node name="CreateRoomRequest" type="HTTPRequest" parent="."]
[node name="JoinRoomRequest" type="HTTPRequest" parent="."] [node name="JoinRoomRequest" type="HTTPRequest" parent="."]
[node name="PopupPanel" type="PopupPanel" parent="."]
margin_right = 16.0
margin_bottom = 16.0
[node name="VBoxContainer" type="VBoxContainer" parent="PopupPanel"]
margin_left = 8.0
margin_top = 8.0
margin_right = 229.0
margin_bottom = 116.0
[node name="Label" type="Label" parent="PopupPanel/VBoxContainer"]
margin_right = 40.0
margin_bottom = 25.0
[node name="ConfirmeButton" type="TextureButton" parent="PopupPanel/VBoxContainer"]
margin_left = 8.0
margin_top = 8.0
margin_right = 229.0
margin_bottom = 83.0
texture_normal = ExtResource( 5 )
[connection signal="pressed" from="ButtonContainer/CreateRoomButton" to="." method="_on_CreateRoomButton_pressed"] [connection signal="pressed" from="ButtonContainer/CreateRoomButton" to="." method="_on_CreateRoomButton_pressed"]
[connection signal="pressed" from="ButtonContainer/EnterRoomButton" to="." method="_on_EnterRoomButton_pressed"] [connection signal="pressed" from="ButtonContainer/EnterRoomButton" to="." method="_on_EnterRoomButton_pressed"]
[connection signal="pressed" from="CreateRoomDialog/VoxContainer/ButtonContainer/ConfirmButton" to="." method="_on_CreateRoom_ConfirmButton_pressed"] [connection signal="pressed" from="CreateRoomDialog/VoxContainer/ButtonContainer/ConfirmButton" to="." method="_on_CreateRoom_ConfirmButton_pressed"]
+68 -12
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=26 format=2] [gd_scene load_steps=29 format=2]
[ext_resource path="res://Asset/LoginBackgounnd.png" type="Texture" id=1] [ext_resource path="res://Asset/LoginBackgounnd.png" type="Texture" id=1]
[ext_resource path="res://Asset/Font/SourceHanSansSC-Normal.otf" type="DynamicFontData" id=2] [ext_resource path="res://Asset/Font/SourceHanSansSC-Normal.otf" type="DynamicFontData" id=2]
@@ -43,26 +43,38 @@ font_data = ExtResource( 2 )
[sub_resource type="ButtonGroup" id=9] [sub_resource type="ButtonGroup" id=9]
[sub_resource type="StreamTexture" id=13] [sub_resource type="StreamTexture" id=10]
flags = 4 flags = 4
load_path = "res://.import/RadioSelect.png-9fa6b8f56f1a88ae34b11e74ec2554de.stex" load_path = "res://.import/RadioSelect.png-9fa6b8f56f1a88ae34b11e74ec2554de.stex"
[sub_resource type="StreamTexture" id=14] [sub_resource type="StreamTexture" id=11]
flags = 4 flags = 4
load_path = "res://.import/RadioNormal.png-11ab88ef6fe2e65a4d5b3a4e5e51d8b4.stex" load_path = "res://.import/RadioNormal.png-11ab88ef6fe2e65a4d5b3a4e5e51d8b4.stex"
[sub_resource type="DynamicFont" id=10] [sub_resource type="DynamicFont" id=12]
size = 24 size = 24
font_data = ExtResource( 2 ) font_data = ExtResource( 2 )
[sub_resource type="StyleBoxTexture" id=11] [sub_resource type="StyleBoxTexture" id=13]
texture = ExtResource( 6 ) texture = ExtResource( 6 )
region_rect = Rect2( 0, 0, 640, 569 ) region_rect = Rect2( 0, 0, 640, 569 )
[sub_resource type="DynamicFont" id=12] [sub_resource type="DynamicFont" id=14]
size = 24 size = 24
font_data = ExtResource( 2 ) font_data = ExtResource( 2 )
[sub_resource type="StyleBoxTexture" id=15]
texture = ExtResource( 6 )
region_rect = Rect2( 0, 0, 640, 569 )
[sub_resource type="DynamicFont" id=16]
size = 48
font_data = ExtResource( 2 )
[sub_resource type="DynamicFont" id=17]
size = 48
font_data = ExtResource( 2 )
[node name="Node2D" type="Node2D"] [node name="Node2D" type="Node2D"]
script = ExtResource( 5 ) script = ExtResource( 5 )
@@ -219,9 +231,9 @@ text = "男"
margin_left = 99.0 margin_left = 99.0
margin_right = 190.0 margin_right = 190.0
margin_bottom = 59.0 margin_bottom = 59.0
custom_icons/radio_checked = SubResource( 13 ) custom_icons/radio_checked = SubResource( 10 )
custom_icons/radio_unchecked = SubResource( 14 ) custom_icons/radio_unchecked = SubResource( 11 )
custom_fonts/font = SubResource( 10 ) custom_fonts/font = SubResource( 12 )
custom_colors/font_color_disabled = Color( 0, 0, 0, 1 ) custom_colors/font_color_disabled = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover_pressed = Color( 0, 0, 0, 1 ) custom_colors/font_color_hover_pressed = Color( 0, 0, 0, 1 )
custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 )
@@ -242,7 +254,7 @@ __meta__ = {
[node name="LoginPanel" type="PopupPanel" parent="."] [node name="LoginPanel" type="PopupPanel" parent="."]
margin_right = 800.0 margin_right = 800.0
margin_bottom = 400.0 margin_bottom = 400.0
custom_styles/panel = SubResource( 11 ) custom_styles/panel = SubResource( 13 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": true "_edit_use_anchors_": true
} }
@@ -285,7 +297,7 @@ margin_right = 194.0
margin_bottom = 48.0 margin_bottom = 48.0
custom_styles/focus = ExtResource( 8 ) custom_styles/focus = ExtResource( 8 )
custom_styles/normal = ExtResource( 8 ) custom_styles/normal = ExtResource( 8 )
custom_fonts/font = SubResource( 12 ) custom_fonts/font = SubResource( 14 )
custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 )
align = 1 align = 1
@@ -305,7 +317,7 @@ margin_right = 194.0
margin_bottom = 106.0 margin_bottom = 106.0
custom_styles/focus = ExtResource( 8 ) custom_styles/focus = ExtResource( 8 )
custom_styles/normal = ExtResource( 8 ) custom_styles/normal = ExtResource( 8 )
custom_fonts/font = SubResource( 12 ) custom_fonts/font = SubResource( 14 )
custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 )
align = 1 align = 1
@@ -318,6 +330,50 @@ texture_normal = ExtResource( 11 )
[node name="LoginHTTPRequest" type="HTTPRequest" parent="."] [node name="LoginHTTPRequest" type="HTTPRequest" parent="."]
[node name="RegisterHTTPRequest" type="HTTPRequest" parent="."] [node name="RegisterHTTPRequest" type="HTTPRequest" parent="."]
[node name="LoginFailedPanel" type="PopupPanel" parent="."]
margin_right = 16.0
margin_bottom = 16.0
custom_styles/panel = SubResource( 15 )
[node name="HBoxContainer" type="VBoxContainer" parent="LoginFailedPanel"]
margin_right = 221.0
margin_bottom = 153.0
[node name="Label" type="Label" parent="LoginFailedPanel/HBoxContainer"]
margin_right = 221.0
margin_bottom = 70.0
custom_fonts/font = SubResource( 16 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "登陆失败"
[node name="ConfirmButton" type="TextureButton" parent="LoginFailedPanel/HBoxContainer"]
margin_top = 78.0
margin_right = 221.0
margin_bottom = 153.0
texture_normal = ExtResource( 11 )
[node name="RegisterFailedPanel" type="PopupPanel" parent="."]
margin_right = 16.0
margin_bottom = 16.0
custom_styles/panel = SubResource( 15 )
[node name="VBoxContainer" type="VBoxContainer" parent="RegisterFailedPanel"]
margin_right = 221.0
margin_bottom = 153.0
[node name="Label" type="Label" parent="RegisterFailedPanel/VBoxContainer"]
margin_right = 221.0
margin_bottom = 70.0
custom_fonts/font = SubResource( 17 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "注册失败"
[node name="ConfirmButton" type="TextureButton" parent="RegisterFailedPanel/VBoxContainer"]
margin_top = 78.0
margin_right = 221.0
margin_bottom = 153.0
texture_normal = ExtResource( 11 )
[connection signal="pressed" from="HBoxContainer/LoginButton" to="." method="_on_LoginButton_pressed"] [connection signal="pressed" from="HBoxContainer/LoginButton" to="." method="_on_LoginButton_pressed"]
[connection signal="pressed" from="HBoxContainer/SignupButton" to="." method="_on_SignupButton_pressed"] [connection signal="pressed" from="HBoxContainer/SignupButton" to="." method="_on_SignupButton_pressed"]
[connection signal="pressed" from="RegisterDialog/VBoxContainer/RegisterConfirmButton" to="." method="_on_RegisterConfirmButton_pressed"] [connection signal="pressed" from="RegisterDialog/VBoxContainer/RegisterConfirmButton" to="." method="_on_RegisterConfirmButton_pressed"]
+7 -4
View File
@@ -8,6 +8,7 @@ onready var first_nickname = $Container/First/Label
onready var second_nickname = $Container/Second/Label onready var second_nickname = $Container/Second/Label
onready var third_nickname = $Container/Third/Label onready var third_nickname = $Container/Third/Label
onready var fourth_nickname = $Container/Fourth/Label onready var fourth_nickname = $Container/Fourth/Label
onready var max_label_width = 200
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
@@ -28,7 +29,9 @@ func set_first(msg):
first_nickname.text = msg["user_list"][0]["nickname"] first_nickname.text = msg["user_list"][0]["nickname"]
var hand = msg["player_tile"][0]["hand_tiles"] var hand = msg["player_tile"][0]["hand_tiles"]
var shown = msg["player_tile"][0]["shown_tiles"] var shown = msg["player_tile"][0]["shown_tiles"]
var tile_pos = first_nickname.rect_size.x var tile_pos = max_label_width
print_debug("pos: ", tile_pos)
print_debug("text: ", first_nickname.text)
for h in hand: for h in hand:
var tile = get_hand_instance(h["suit"], h["number"]) var tile = get_hand_instance(h["suit"], h["number"])
tile.position = Vector2(tile_pos, 0) tile.position = Vector2(tile_pos, 0)
@@ -54,7 +57,7 @@ func set_second(msg):
second_nickname.text = msg["user_list"][1]["nickname"] second_nickname.text = msg["user_list"][1]["nickname"]
var hand = msg["player_tile"][1]["hand_tiles"] var hand = msg["player_tile"][1]["hand_tiles"]
var shown = msg["player_tile"][1]["shown_tiles"] var shown = msg["player_tile"][1]["shown_tiles"]
var tile_pos = 0 var tile_pos = max_label_width
for h in hand: for h in hand:
var tile = get_hand_instance(h["suit"], h["number"]) var tile = get_hand_instance(h["suit"], h["number"])
tile.position = Vector2(tile_pos, y) tile.position = Vector2(tile_pos, y)
@@ -79,7 +82,7 @@ func set_third(msg):
third_nickname.text = msg["user_list"][2]["nickname"] third_nickname.text = msg["user_list"][2]["nickname"]
var hand = msg["player_tile"][2]["hand_tiles"] var hand = msg["player_tile"][2]["hand_tiles"]
var shown = msg["player_tile"][2]["shown_tiles"] var shown = msg["player_tile"][2]["shown_tiles"]
var tile_pos = 0 var tile_pos = max_label_width
for h in hand: for h in hand:
var tile = get_hand_instance(h["suit"], h["number"]) var tile = get_hand_instance(h["suit"], h["number"])
tile.position = Vector2(tile_pos, y) tile.position = Vector2(tile_pos, y)
@@ -104,7 +107,7 @@ func set_fourth(msg):
fourth_nickname.text = msg["user_list"][3]["nickname"] fourth_nickname.text = msg["user_list"][3]["nickname"]
var hand = msg["player_tile"][3]["hand_tiles"] var hand = msg["player_tile"][3]["hand_tiles"]
var shown = msg["player_tile"][3]["shown_tiles"] var shown = msg["player_tile"][3]["shown_tiles"]
var tile_pos = 0 var tile_pos = max_label_width
for h in hand: for h in hand:
var tile = get_hand_instance(h["suit"], h["number"]) var tile = get_hand_instance(h["suit"], h["number"])
tile.position = Vector2(tile_pos, y) tile.position = Vector2(tile_pos, y)
+2
View File
@@ -33,6 +33,8 @@ func _ready():
$ChowPanel/LeftChow.connect("pressed", self, "handle_left_chow") $ChowPanel/LeftChow.connect("pressed", self, "handle_left_chow")
$ChowPanel/MidChow.connect("pressed", self, "handle_mid_chow") $ChowPanel/MidChow.connect("pressed", self, "handle_mid_chow")
$ChowPanel/RightChow.connect("pressed", self, "handle_right_chow") $ChowPanel/RightChow.connect("pressed", self, "handle_right_chow")
$RoomIDLabel.text = "房间号: " + str(Global.my_room_id).pad_zeros(5)
+24 -6
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=62 format=2] [gd_scene load_steps=63 format=2]
[ext_resource path="res://Table/OppositeDropArea.gd" type="Script" id=1] [ext_resource path="res://Table/OppositeDropArea.gd" type="Script" id=1]
[ext_resource path="res://Table/PlayerAction.gd" type="Script" id=2] [ext_resource path="res://Table/PlayerAction.gd" type="Script" id=2]
@@ -86,6 +86,10 @@ region_rect = Rect2( 0, 0, 640, 569 )
size = 32 size = 32
font_data = ExtResource( 41 ) font_data = ExtResource( 41 )
[sub_resource type="DynamicFont" id=9]
size = 64
font_data = ExtResource( 41 )
[node name="Table" type="Node2D"] [node name="Table" type="Node2D"]
script = ExtResource( 6 ) script = ExtResource( 6 )
@@ -265,6 +269,7 @@ __meta__ = {
} }
[node name="TestButtons" type="HBoxContainer" parent="VBoxContainer"] [node name="TestButtons" type="HBoxContainer" parent="VBoxContainer"]
visible = false
margin_right = 76.0 margin_right = 76.0
margin_bottom = 37.0 margin_bottom = 37.0
custom_constants/separation = 10 custom_constants/separation = 10
@@ -681,9 +686,9 @@ one_shot = true
[node name="ChatField" type="HBoxContainer" parent="."] [node name="ChatField" type="HBoxContainer" parent="."]
margin_left = 1364.08 margin_left = 1364.08
margin_top = 856.17 margin_top = 821.17
margin_right = 1897.08 margin_right = 1897.08
margin_bottom = 907.17 margin_bottom = 872.17
script = ExtResource( 43 ) script = ExtResource( 43 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
@@ -696,7 +701,7 @@ size_flags_horizontal = 3
custom_styles/normal = SubResource( 5 ) custom_styles/normal = SubResource( 5 )
custom_fonts/font = SubResource( 6 ) custom_fonts/font = SubResource( 6 )
custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_colors/font_color = Color( 0, 0, 0, 1 )
placeholder_text = "按回车发送消息" placeholder_text = "输入聊天消息"
[node name="SendButton" type="TextureButton" parent="ChatField"] [node name="SendButton" type="TextureButton" parent="ChatField"]
margin_left = 431.0 margin_left = 431.0
@@ -716,9 +721,8 @@ __meta__ = {
} }
[node name="Container" type="VBoxContainer" parent="PopupPanel"] [node name="Container" type="VBoxContainer" parent="PopupPanel"]
margin_top = 15.0
margin_right = 933.0 margin_right = 933.0
margin_bottom = 454.0 margin_bottom = 439.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@@ -781,6 +785,20 @@ custom_colors/font_color = Color( 0, 0, 0, 1 )
margin_left = 8.0 margin_left = 8.0
margin_right = 8.0 margin_right = 8.0
margin_bottom = 48.0 margin_bottom = 48.0
[node name="RoomIDLabel" type="Label" parent="."]
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = 171.0
margin_right = 346.0
margin_bottom = 94.0
custom_fonts/font = SubResource( 9 )
text = "00000"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="VBoxContainer/TestButtons/StartButton" to="." method="_on_Button9_pressed"] [connection signal="pressed" from="VBoxContainer/TestButtons/StartButton" to="." method="_on_Button9_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Button" to="." method="_on_Button_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/Button" to="." method="_on_Button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Button3" to="." method="_on_Button3_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/Button3" to="." method="_on_Button3_pressed"]
+1 -1
View File
@@ -16,7 +16,7 @@ _global_script_class_icons={
[application] [application]
config/name="MahjongGame" config/name="MahjongGame"
run/main_scene="res://Hall.tscn" run/main_scene="res://Login.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload] [autoload]