See spectators list in the info panel HUD (closes #94)
This commit is contained in:
parent
d197d95106
commit
f02ed85e42
@ -1,6 +1,6 @@
|
||||
local S = minetest.get_translator("block_league")
|
||||
|
||||
function block_league.info_panel_create(arena, p_name)
|
||||
function block_league.info_panel_create(p_name)
|
||||
Panel:new("bl_info_panel", {
|
||||
player = p_name,
|
||||
bg = "bl_hud_panel_bg.png",
|
||||
@ -59,6 +59,13 @@ function block_league.info_panel_create(arena, p_name)
|
||||
offset = {x = 415, y = -130},
|
||||
text = ""
|
||||
},
|
||||
spectators = {
|
||||
alignment = { x = 1, y = 0 },
|
||||
offset = { x = -530, y = -146},
|
||||
text = "",
|
||||
number = "0xB7ACA3",
|
||||
style = 4,
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
@ -131,29 +138,25 @@ function block_league.info_panel_update(arena, team_id)
|
||||
--local bar_height = stats.teamID == team_id and players_idx[pl_name] or nil
|
||||
|
||||
if team_id == 1 then
|
||||
|
||||
panel:update(nil,
|
||||
{y_players_clmn = {
|
||||
text = plyrs_clmn
|
||||
},
|
||||
y_pts_clmn = {
|
||||
text = pts_clmn
|
||||
},
|
||||
y_trd_clmn = {
|
||||
text = third_clmn
|
||||
}}--[[,
|
||||
|
||||
{y_players_clmn = {
|
||||
text = plyrs_clmn
|
||||
},
|
||||
y_pts_clmn = {
|
||||
text = pts_clmn
|
||||
},
|
||||
y_trd_clmn = {
|
||||
text = third_clmn
|
||||
}}--[[,
|
||||
|
||||
{player_indicator = {
|
||||
offset = { x = x_off, y = bar_height }
|
||||
}
|
||||
})]]
|
||||
{player_indicator = {
|
||||
offset = { x = x_off, y = bar_height }
|
||||
}
|
||||
})]]
|
||||
)
|
||||
|
||||
else
|
||||
|
||||
panel:update(nil,
|
||||
|
||||
{b_players_clmn = {
|
||||
text = plyrs_clmn
|
||||
},
|
||||
@ -172,3 +175,27 @@ function block_league.info_panel_update(arena, team_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function block_league.info_panel_update_spectators(arena)
|
||||
local spectators = ""
|
||||
|
||||
if arena.spectators_amount > 0 then
|
||||
for sp_name, _ in pairs(arena.spectators) do
|
||||
if spectators:len() > 90 then
|
||||
spectators = S("@1 etc.", spectators) .. " " -- space for next sub
|
||||
break
|
||||
end
|
||||
|
||||
spectators = spectators .. sp_name .. ", "
|
||||
end
|
||||
|
||||
spectators = S("Spectators: @1", spectators:sub(1, -3))
|
||||
end
|
||||
|
||||
for pl_name, _ in pairs(arena.players) do
|
||||
local panel = panel_lib.get_panel(pl_name, "bl_info_panel")
|
||||
panel:update(nil, {spectators = {text = spectators}})
|
||||
end
|
||||
end
|
||||
|
@ -46,9 +46,6 @@ end)
|
||||
arena_lib.on_join("block_league", function(p_name, arena, as_spectator, was_spectator)
|
||||
if as_spectator then
|
||||
create_and_show_HUD(arena, p_name, true)
|
||||
minetest.after(0.1, function()
|
||||
block_league.HUD_scoreboard_update_score(arena)
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
@ -139,6 +136,11 @@ function create_and_show_HUD(arena, p_name, is_spectator, was_spectator)
|
||||
panel_lib.get_panel(p_name, "bl_skill"):remove()
|
||||
block_league.HUD_spectate_remove(arena.players, p_name)
|
||||
|
||||
minetest.after(0.1, function()
|
||||
block_league.HUD_scoreboard_update_score(arena)
|
||||
block_league.info_panel_update_spectators(arena)
|
||||
end)
|
||||
|
||||
local team_marker = arena.players[p_name].teamID == 1 and "bl_hud_scoreboard_orangemark.png" or "bl_hud_scoreboard_bluemark.png"
|
||||
panel_lib.get_panel(p_name, "bl_scoreboard"):update(nil, nil, {team_marker = {text = team_marker}})
|
||||
block_league.HUD_stamina_update(arena, p_name)
|
||||
@ -157,7 +159,8 @@ function create_and_show_HUD(arena, p_name, is_spectator, was_spectator)
|
||||
|
||||
if is_spectator then
|
||||
block_league.HUD_spectate_create(arena, p_name)
|
||||
minetest.after(0.1, function() block_league.info_panel_update_spectators(arena) end)
|
||||
else
|
||||
block_league.info_panel_create(arena, p_name)
|
||||
block_league.info_panel_create(p_name)
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user