Fix: game result panel problem
This commit is contained in:
1 parent
b47967974f
commit
82322fcd25
4 files changed
+54
-165
No files matched your search
+2
-1
@@ -41,6 +41,7 @@ class Tile:
|
||||
const RESULT_HAND_WIDTH = 76*RESULT_SCALE
|
||||
const RESULT_SHOWN_HEIGHT = BOTTOM_DROP_HEIGHT*RESULT_SCALE
|
||||
const RESULT_SHOWN_WIDTH = BOTTOM_DROP_WIDTH*RESULT_SCALE
|
||||
const RESULT_VERTICALL_GAP = 30
|
||||
|
||||
|
||||
class Screen:
|
||||
@@ -58,7 +59,7 @@ class Table:
|
||||
|
||||
const SIDE_HAND_MARGIN = 80
|
||||
const SIDE_SHOWN_MARGIN_X = SIDE_HAND_MARGIN + 50 + 30
|
||||
const SIDE_SHOWN_MARGIN_Y = 50
|
||||
const SIDE_SHOWN_MARGIN_Y = 150
|
||||
const SIDE_DROP_MARGIN_X = SIDE_SHOWN_MARGIN_X + 50
|
||||
|
||||
class Timer_Table:
|
||||
|
||||
+34
-104
@@ -4,131 +4,55 @@ extends PopupPanel
|
||||
var hand_texture
|
||||
var shown_texture
|
||||
|
||||
onready var first_nickname = $Container/First/Label
|
||||
onready var second_nickname = $Container/Second/Label
|
||||
onready var third_nickname = $Container/Third/Label
|
||||
onready var fourth_nickname = $Container/Fourth/Label
|
||||
onready var max_label_width = 200
|
||||
onready var nickname_labels = [$Nickname0, $Nickname1, $Nickname2, $Nickname3]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
hand_texture = ImageTexture.new()
|
||||
hand_texture = load("res://Asset/Tile/HandinTilesSheet.png")
|
||||
shown_texture = Image.new()
|
||||
shown_texture = ImageTexture.new()
|
||||
shown_texture = load("res://Asset/Tile/DropTileBottom.png")
|
||||
|
||||
|
||||
func show_result(msg):
|
||||
set_first(msg)
|
||||
set_second(msg)
|
||||
set_third(msg)
|
||||
set_fourth(msg)
|
||||
popup_centered()
|
||||
|
||||
func set_first(msg):
|
||||
first_nickname.text = msg["user_list"][0]["nickname"]
|
||||
var hand = msg["player_tile"][0]["hand_tiles"]
|
||||
var shown = msg["player_tile"][0]["shown_tiles"]
|
||||
var tile_pos = max_label_width
|
||||
print_debug("pos: ", tile_pos)
|
||||
print_debug("text: ", first_nickname.text)
|
||||
for h in hand:
|
||||
var tile = get_hand_instance(h["suit"], h["number"])
|
||||
tile.position = Vector2(tile_pos, 0)
|
||||
$Container/First.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
if shown == null:
|
||||
return
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
for s in shown:
|
||||
for t in s["tiles"]:
|
||||
var tile = get_shown_instance(t["suit"], t["number"])
|
||||
tile.position = Vector2(tile_pos, 0)
|
||||
$Container/First.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
var winner = msg["winner"]
|
||||
if winner == 0:
|
||||
pass
|
||||
|
||||
for i in range(4):
|
||||
show_line(i, msg)
|
||||
popup_centered(Vector2(950, 550))
|
||||
|
||||
|
||||
func set_second(msg):
|
||||
var y = 1 * Constants.Tile.RESULT_HEIGHT
|
||||
second_nickname.text = msg["user_list"][1]["nickname"]
|
||||
var hand = msg["player_tile"][1]["hand_tiles"]
|
||||
var shown = msg["player_tile"][1]["shown_tiles"]
|
||||
var tile_pos = max_label_width
|
||||
func show_line(row, msg):
|
||||
var x = 0
|
||||
var y = row*(Constants.Tile.RESULT_HAND_HEIGHT+Constants.Tile.RESULT_VERTICALL_GAP)
|
||||
y += Constants.Tile.RESULT_VERTICALL_GAP*2
|
||||
var nickname = msg["user_list"][row]["nickname"]
|
||||
var hand = msg["player_tile"][row]["hand_tiles"]
|
||||
var shown = msg["player_tile"][row]["shown_tiles"]
|
||||
|
||||
var nickname_label = nickname_labels[row]
|
||||
nickname_label.text = nickname
|
||||
nickname_label.rect_position = Vector2(x, y)
|
||||
x = max_label_width
|
||||
for h in hand:
|
||||
var tile = get_hand_instance(h["suit"], h["number"])
|
||||
tile.position = Vector2(tile_pos, y)
|
||||
$Container/Second.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
add_child(tile)
|
||||
tile.position = Vector2(x, y)
|
||||
x += Constants.Tile.RESULT_HAND_WIDTH
|
||||
if shown == null:
|
||||
return
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
x += Constants.Tile.RESULT_HAND_WIDTH
|
||||
for s in shown:
|
||||
for t in s["tiles"]:
|
||||
var tile = get_shown_instance(t["suit"], t["number"])
|
||||
tile.position = Vector2(tile_pos, y)
|
||||
$Container/Second.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
var winner = msg["winner"]
|
||||
if winner == 1:
|
||||
pass
|
||||
|
||||
func set_third(msg):
|
||||
var y = 2 * Constants.Tile.RESULT_HEIGHT
|
||||
third_nickname.text = msg["user_list"][2]["nickname"]
|
||||
var hand = msg["player_tile"][2]["hand_tiles"]
|
||||
var shown = msg["player_tile"][2]["shown_tiles"]
|
||||
var tile_pos = max_label_width
|
||||
for h in hand:
|
||||
var tile = get_hand_instance(h["suit"], h["number"])
|
||||
tile.position = Vector2(tile_pos, y)
|
||||
$Container/Third.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
if shown == null:
|
||||
return
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
for s in shown:
|
||||
for t in s["tiles"]:
|
||||
var tile = get_shown_instance(t["suit"], t["number"])
|
||||
tile.position = Vector2(tile_pos, y)
|
||||
$Container/Third.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
var winner = msg["winner"]
|
||||
if winner == 2:
|
||||
pass
|
||||
|
||||
func set_fourth(msg):
|
||||
var y = 3 * Constants.Tile.RESULT_HEIGHT
|
||||
fourth_nickname.text = msg["user_list"][3]["nickname"]
|
||||
var hand = msg["player_tile"][3]["hand_tiles"]
|
||||
var shown = msg["player_tile"][3]["shown_tiles"]
|
||||
var tile_pos = max_label_width
|
||||
for h in hand:
|
||||
var tile = get_hand_instance(h["suit"], h["number"])
|
||||
tile.position = Vector2(tile_pos, y)
|
||||
$Container/Fourth.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
if shown == null:
|
||||
return
|
||||
tile_pos += Constants.Tile.RESULT_HAND_WIDTH
|
||||
for s in shown:
|
||||
for t in s["tiles"]:
|
||||
var tile = get_shown_instance(t["suit"], t["number"])
|
||||
tile.position = Vector2(tile_pos, y)
|
||||
$Container/Fourth.add_child(tile)
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
tile_pos += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
var winner = msg["winner"]
|
||||
if winner == 3:
|
||||
pass
|
||||
add_child(tile)
|
||||
tile.position = Vector2(x, y)
|
||||
x += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
x += Constants.Tile.RESULT_SHOWN_WIDTH
|
||||
|
||||
|
||||
func get_hand_instance(suit, number):
|
||||
var tile = Sprite.new()
|
||||
tile.centered = false
|
||||
tile.texture = hand_texture
|
||||
tile.vframes = 5
|
||||
tile.hframes = 9
|
||||
@@ -138,6 +62,7 @@ func get_hand_instance(suit, number):
|
||||
|
||||
func get_shown_instance(suit, number):
|
||||
var tile = Sprite.new()
|
||||
tile.centered = false
|
||||
tile.texture = shown_texture
|
||||
tile.vframes = 5
|
||||
tile.hframes = 9
|
||||
@@ -145,6 +70,7 @@ func get_shown_instance(suit, number):
|
||||
tile.scale = Vector2(Constants.Tile.RESULT_SCALE, Constants.Tile.RESULT_SCALE)
|
||||
return tile
|
||||
|
||||
|
||||
func get_avatar_path(gender):
|
||||
var path = ""
|
||||
if gender == Message.gender.FEMALE:
|
||||
@@ -152,5 +78,9 @@ func get_avatar_path(gender):
|
||||
elif gender == Message.gender.MALE:
|
||||
path = "res://Asset/Avatar/Male.png"
|
||||
|
||||
func clear_tiles():
|
||||
for tile in get_children():
|
||||
remove_child(tile)
|
||||
tile.queue_free()
|
||||
|
||||
|
||||
+2
-1
@@ -58,7 +58,8 @@ func handle_table_order_msg(msg):
|
||||
|
||||
func handle_game_result_msg(msg):
|
||||
var winner = int(msg["winner"])
|
||||
$PopupPanel.show_result(msg)
|
||||
$GameResultPanel.show_result(msg)
|
||||
$ReadyButton.show()
|
||||
print_debug("winner: ", winner)
|
||||
|
||||
func handle_get_ready_msg(msg):
|
||||
|
||||
+16
-59
@@ -709,83 +709,40 @@ margin_right = 533.0
|
||||
margin_bottom = 51.0
|
||||
texture_normal = ExtResource( 45 )
|
||||
|
||||
[node name="PopupPanel" type="PopupPanel" parent="."]
|
||||
[node name="GameResultPanel" type="PopupPanel" parent="."]
|
||||
visible = true
|
||||
margin_left = 493.0
|
||||
margin_top = 251.0
|
||||
margin_right = 1426.0
|
||||
margin_bottom = 690.0
|
||||
margin_bottom = 751.0
|
||||
rect_min_size = Vector2( 950, 550 )
|
||||
custom_styles/panel = SubResource( 7 )
|
||||
script = ExtResource( 53 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Container" type="VBoxContainer" parent="PopupPanel"]
|
||||
margin_right = 933.0
|
||||
margin_bottom = 439.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="First" type="HBoxContainer" parent="PopupPanel/Container"]
|
||||
margin_right = 933.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="Label" type="Label" parent="PopupPanel/Container/First"]
|
||||
margin_bottom = 48.0
|
||||
[node name="Nickname0" type="Label" parent="GameResultPanel"]
|
||||
margin_right = 950.0
|
||||
margin_bottom = 550.0
|
||||
custom_fonts/font = SubResource( 8 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="New" type="HBoxContainer" parent="PopupPanel/Container/First"]
|
||||
margin_left = 8.0
|
||||
margin_right = 8.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="Second" type="HBoxContainer" parent="PopupPanel/Container"]
|
||||
margin_top = 56.0
|
||||
margin_right = 933.0
|
||||
margin_bottom = 104.0
|
||||
|
||||
[node name="Label" type="Label" parent="PopupPanel/Container/Second"]
|
||||
margin_bottom = 48.0
|
||||
[node name="Nickname1" type="Label" parent="GameResultPanel"]
|
||||
margin_right = 950.0
|
||||
margin_bottom = 550.0
|
||||
custom_fonts/font = SubResource( 8 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="New" type="HBoxContainer" parent="PopupPanel/Container/Second"]
|
||||
margin_left = 8.0
|
||||
margin_right = 8.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="Third" type="HBoxContainer" parent="PopupPanel/Container"]
|
||||
margin_top = 112.0
|
||||
margin_right = 933.0
|
||||
margin_bottom = 160.0
|
||||
|
||||
[node name="Label" type="Label" parent="PopupPanel/Container/Third"]
|
||||
margin_bottom = 48.0
|
||||
[node name="Nickname2" type="Label" parent="GameResultPanel"]
|
||||
margin_right = 950.0
|
||||
margin_bottom = 550.0
|
||||
custom_fonts/font = SubResource( 8 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="New" type="HBoxContainer" parent="PopupPanel/Container/Third"]
|
||||
margin_left = 8.0
|
||||
margin_right = 8.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="Fourth" type="HBoxContainer" parent="PopupPanel/Container"]
|
||||
margin_top = 168.0
|
||||
margin_right = 933.0
|
||||
margin_bottom = 216.0
|
||||
|
||||
[node name="Label" type="Label" parent="PopupPanel/Container/Fourth"]
|
||||
margin_bottom = 48.0
|
||||
[node name="Nickname3" type="Label" parent="GameResultPanel"]
|
||||
margin_right = 950.0
|
||||
margin_bottom = 550.0
|
||||
custom_fonts/font = SubResource( 8 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="New" type="HBoxContainer" parent="PopupPanel/Container/Fourth"]
|
||||
margin_left = 8.0
|
||||
margin_right = 8.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="RoomIDLabel" type="Label" parent="."]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
|
||||
Reference in new issue
Block a user