diff --git a/Asset/Button/RoomControl/ExitButton.png b/Asset/Button/RoomControl/ExitButton.png index fe28eb6..3c983be 100644 Binary files a/Asset/Button/RoomControl/ExitButton.png and b/Asset/Button/RoomControl/ExitButton.png differ diff --git a/Asset/Button/RoomControl/QuitButton.png b/Asset/Button/RoomControl/QuitButton.png new file mode 100644 index 0000000..0649b6f Binary files /dev/null and b/Asset/Button/RoomControl/QuitButton.png differ diff --git a/Asset/Button/RoomControl/QuitButton.png.import b/Asset/Button/RoomControl/QuitButton.png.import new file mode 100644 index 0000000..736ad1a --- /dev/null +++ b/Asset/Button/RoomControl/QuitButton.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/QuitButton.png-31c18ce8db720f95af92c09426515d86.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Asset/Button/RoomControl/QuitButton.png" +dest_files=[ "res://.import/QuitButton.png-31c18ce8db720f95af92c09426515d86.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Asset/my_icon.png b/Asset/my_icon.png new file mode 100644 index 0000000..8c166c1 Binary files /dev/null and b/Asset/my_icon.png differ diff --git a/Asset/my_icon.png.import b/Asset/my_icon.png.import new file mode 100644 index 0000000..b3c5a75 --- /dev/null +++ b/Asset/my_icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/my_icon.png-85fedb93756f5e209c7e0c6750ff6123.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Asset/my_icon.png" +dest_files=[ "res://.import/my_icon.png-85fedb93756f5e209c7e0c6750ff6123.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Constants.gd b/Constants.gd index 3b7d4f8..213662d 100644 --- a/Constants.gd +++ b/Constants.gd @@ -91,7 +91,7 @@ class WebSockt: const URL = BASE_URL+":"+BASE_PORT const RELEASE_BASE_URL = "wss://mj.caimingyang.cn" - const RELEASE_BASE_PORT = "80" + const RELEASE_BASE_PORT = "443" const RELEASE_URL = RELEASE_BASE_URL+":"+RELEASE_BASE_PORT enum rule{JinzhouGameRule, ShenyangGameRule} diff --git a/Hall.gd b/Hall.gd index c838fea..7b6bd10 100644 --- a/Hall.gd +++ b/Hall.gd @@ -14,6 +14,7 @@ var my_user_id=0 func _ready(): $CreateRoomRequest.connect("request_completed", self, "on_create_request_completed") $JoinRoomRequest.connect("request_completed", self, "on_join_request_completed") + $BackButton.connect("pressed", self, "on_backbtn_clicked") ConnManager.connect("conn_success", self, "on_ws_established") rule_choice.add_item("锦州麻将", Constants.rule.JinzhouGameRule) @@ -50,6 +51,9 @@ func _on_JoinRoom_ConfirmButton_pressed(): func _on_JoinRoom_CancelButton_pressed(): $JoinRoomDialog.hide() +func on_backbtn_clicked(): + get_tree().change_scene("res://Login.tscn") + func on_create_request_completed(result, response_code, headers, body): if result!=HTTPRequest.RESULT_SUCCESS: print_debug("http response error when creating room") diff --git a/Hall.tscn b/Hall.tscn index 8d51c97..07f21df 100644 --- a/Hall.tscn +++ b/Hall.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=2] +[gd_scene load_steps=21 format=2] [ext_resource path="res://Asset/HallBackground.png" type="Texture" id=1] [ext_resource path="res://Asset/Button/RoomControl/CreateRoom.png" type="Texture" id=2] @@ -65,6 +65,10 @@ font_data = ExtResource( 8 ) size = 32 font_data = ExtResource( 8 ) +[sub_resource type="StreamTexture" id=11] +flags = 4 +load_path = "res://.import/QuitButton.png-31c18ce8db720f95af92c09426515d86.stex" + [node name="Node2D" type="Node2D"] script = ExtResource( 4 ) @@ -78,9 +82,9 @@ __meta__ = { } [node name="ButtonContainer" type="HBoxContainer" parent="."] -margin_left = 561.0 +margin_left = 557.0 margin_top = 856.611 -margin_right = 1367.0 +margin_right = 1363.0 margin_bottom = 1015.61 custom_constants/separation = 40 alignment = 1 @@ -323,6 +327,17 @@ margin_top = 8.0 margin_right = 229.0 margin_bottom = 83.0 texture_normal = ExtResource( 5 ) + +[node name="BackButton" type="TextureButton" parent="."] +margin_left = 48.0 +margin_top = 33.0 +margin_right = 108.0 +margin_bottom = 95.0 +rect_scale = Vector2( 2, 2 ) +texture_normal = SubResource( 11 ) +__meta__ = { +"_edit_use_anchors_": false +} [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="CreateRoomDialog/VoxContainer/ButtonContainer/ConfirmButton" to="." method="_on_CreateRoom_ConfirmButton_pressed"] diff --git a/Login.tscn b/Login.tscn index 7a42508..0e21da1 100644 --- a/Login.tscn +++ b/Login.tscn @@ -88,10 +88,15 @@ __meta__ = { } [node name="HBoxContainer" type="HBoxContainer" parent="."] -margin_left = 684.956 -margin_top = 879.628 -margin_right = 724.956 -margin_bottom = 919.628 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = 670.0 +margin_top = 827.761 +margin_right = 1115.0 +margin_bottom = 912.761 +rect_scale = Vector2( 1.3, 1.3 ) alignment = 1 __meta__ = { "_edit_use_anchors_": false @@ -326,9 +331,8 @@ custom_colors/font_color = Color( 0, 0, 0, 1 ) align = 1 [node name="LoginConfirmButton" type="TextureButton" parent="LoginPanel/VBoxContainer"] -margin_left = 200.0 margin_top = 114.0 -margin_right = 200.0 +margin_right = 400.0 margin_bottom = 189.0 grow_horizontal = 0 texture_normal = ExtResource( 11 ) diff --git a/Network/ConnManager.gd b/Network/ConnManager.gd index d0a89dd..2d6b231 100644 --- a/Network/ConnManager.gd +++ b/Network/ConnManager.gd @@ -11,6 +11,7 @@ signal recv_table_order_msg signal recv_game_result_msg signal recv_get_ready_msg signal recv_chat_msg +signal recv_join_msg signal conn_success signal conn_failed @@ -82,6 +83,8 @@ func _on_data(): emit_signal("recv_get_ready_msg", json) elif msg_type == Message.msg_type.CHAT_MSG: emit_signal("recv_chat_msg", json) + elif msg_type == Message.msg_type.JOIN_MSG: + emit_signal("recv_join_msg", json) print_debug("msg_type: ", json_recv.result["msg_type"]) diff --git a/Network/Message.gd b/Network/Message.gd index 18e7bbf..2c92eb9 100644 --- a/Network/Message.gd +++ b/Network/Message.gd @@ -10,7 +10,7 @@ extends Node func _ready(): pass # Replace with function body. -enum msg_type{GAME_MSG, TABLE_ORDER_MSG, GAME_RESULT_MSG, GET_READY_MSG, CHAT_MSG} +enum msg_type{GAME_MSG, TABLE_ORDER_MSG, GAME_RESULT_MSG, GET_READY_MSG, CHAT_MSG, JOIN_MSG} enum player_action{START,DEAL, CHOW,PONG, EXPOSED_KONG, CONCEALED_KONG, ADDED_KONG, WIN, CANCEL, DISCARD, DRAW, READY} diff --git a/Table/Table.gd b/Table/Table.gd index c091d19..87fbba4 100644 --- a/Table/Table.gd +++ b/Table/Table.gd @@ -19,6 +19,7 @@ func _ready(): ConnManager.connect("recv_game_result_msg", self, "handle_game_result_msg") ConnManager.connect("recv_get_ready_msg", self, "handle_get_ready_msg") ConnManager.connect("recv_chat_msg", self, "handle_chat_msg") + ConnManager.connect("recv_join_msg", self, "handle_join_msg") ConnManager.connect("conn_failed", self, "handle_conn_failed") @@ -35,7 +36,7 @@ func _ready(): $ChowPanel/MidChow.connect("pressed", self, "handle_mid_chow") $ChowPanel/RightChow.connect("pressed", self, "handle_right_chow") - $InfoArea/RoomIDLabel.text = " 房间: %s 玩法:%s" %[str(Global.my_room_id).pad_zeros(5),"测试"] + $InfoArea/RoomIDLabel.text = " 房间: %s" %[str(Global.my_room_id).pad_zeros(5)] $InfoArea/ExitButton.connect("pressed", self, "on_exit_pressed") $DisconnectDialog/VBoxContainer/ConfirmButton.connect("pressed", self, "on_disconnect_confirm") @@ -77,7 +78,7 @@ func handle_get_ready_msg(msg): $BottomAvatar.show_ready(msg["ready_list"][my_table_order]) $RightAvatar.show_ready(msg["ready_list"][(my_table_order+1)%4]) $OppoAvatar.show_ready(msg["ready_list"][(my_table_order+2)%4]) - $LeftAvatar.show_ready(msg["ready_list"][(my_table_order+2)%4]) + $LeftAvatar.show_ready(msg["ready_list"][(my_table_order+3)%4]) @@ -95,7 +96,24 @@ func handle_chat_msg(msg): elif from == (my_table_order+3)%4: $LeftAvatar.show_chat_pop(content) +func handle_join_msg(msg): + var users_info = msg["user_list"] + var bottom_nickname = users_info[0]["nickname"] + var bottom_gender = users_info[0]["gender"] + $BottomAvatar.show_avatar(bottom_nickname, bottom_gender) + if len(users_info)>=2: + var right_nickname = users_info[1]["nickname"] + var right_gender = users_info[1]["gender"] + $RightAvatar.show_avatar(right_nickname, right_gender) + if len(users_info)>=3: + var oppo_nickname = users_info[2]["nickname"] + var oppo_gender = users_info[2]["gender"] + $OppoAvatar.show_avatar(oppo_nickname, oppo_gender) + if len(users_info)>=4: + var left_nickname = users_info[3]["nickname"] + var left_gender = users_info[3]["gender"] + $LeftAvatar.show_avatar(left_nickname, left_gender) func handle_ready_pressed(): print_debug("ready pressed") diff --git a/Table/Table.tscn b/Table/Table.tscn index c795a40..a9031f4 100644 --- a/Table/Table.tscn +++ b/Table/Table.tscn @@ -54,7 +54,6 @@ [ext_resource path="res://Asset/PopupBackground.png" type="Texture" id=52] [ext_resource path="res://Table/PopupPanel.gd" type="Script" id=53] [ext_resource path="res://Asset/Button/General/Confirm.png" type="Texture" id=54] -[ext_resource path="res://Asset/Button/RoomControl/ExitButton.png" type="Texture" id=55] [ext_resource path="res://Asset/Tile/OppositeHand.png" type="Texture" id=56] [sub_resource type="DynamicFont" id=1] @@ -89,15 +88,19 @@ region_rect = Rect2( 0, 0, 640, 569 ) size = 32 font_data = ExtResource( 41 ) -[sub_resource type="StyleBoxTexture" id=10] +[sub_resource type="StyleBoxTexture" id=9] texture = ExtResource( 52 ) region_rect = Rect2( 0, 0, 640, 569 ) -[sub_resource type="DynamicFont" id=11] +[sub_resource type="DynamicFont" id=10] size = 48 font_data = ExtResource( 41 ) -[sub_resource type="DynamicFont" id=9] +[sub_resource type="StreamTexture" id=11] +flags = 4 +load_path = "res://.import/ExitButton.png-90bb905636ba19a1a2935f9c69eb1cf7.stex" + +[sub_resource type="DynamicFont" id=12] size = 64 font_data = ExtResource( 41 ) @@ -758,7 +761,7 @@ custom_colors/font_color = Color( 0, 0, 0, 1 ) visible = true margin_right = 600.0 margin_bottom = 400.0 -custom_styles/panel = SubResource( 10 ) +custom_styles/panel = SubResource( 9 ) __meta__ = { "_edit_use_anchors_": false } @@ -780,7 +783,7 @@ __meta__ = { [node name="Label" type="Label" parent="DisconnectDialog/VBoxContainer"] margin_right = 240.0 margin_bottom = 70.0 -custom_fonts/font = SubResource( 11 ) +custom_fonts/font = SubResource( 10 ) custom_colors/font_color = Color( 0, 0, 0, 1 ) text = "连接已断开" @@ -801,7 +804,7 @@ __meta__ = { margin_right = 90.0 margin_bottom = 122.0 rect_min_size = Vector2( 90, 122 ) -texture_normal = ExtResource( 55 ) +texture_normal = SubResource( 11 ) expand = true __meta__ = { "_edit_use_anchors_": false @@ -818,7 +821,7 @@ margin_left = 185.0 margin_top = 14.0 margin_right = 220.0 margin_bottom = 108.0 -custom_fonts/font = SubResource( 9 ) +custom_fonts/font = SubResource( 12 ) text = "0" __meta__ = { "_edit_use_anchors_": false @@ -829,7 +832,7 @@ margin_left = 228.0 margin_top = 14.0 margin_right = 403.0 margin_bottom = 108.0 -custom_fonts/font = SubResource( 9 ) +custom_fonts/font = SubResource( 12 ) text = "00000" __meta__ = { "_edit_use_anchors_": false diff --git a/project.godot b/project.godot index b46c89b..a368535 100644 --- a/project.godot +++ b/project.godot @@ -17,7 +17,7 @@ _global_script_class_icons={ config/name="MahjongGame" run/main_scene="res://Login.tscn" -config/icon="res://icon.png" +config/icon="res://Asset/my_icon.png" [autoload]