2020-02-03 10:33:27 +01:00
|
|
|
local Public = {}
|
|
|
|
|
2021-03-24 16:46:00 +01:00
|
|
|
local tooltip = 'Difficulty increases with higher score.'
|
2020-02-03 10:33:27 +01:00
|
|
|
|
|
|
|
local function create_score_gui(player)
|
2021-03-24 16:46:00 +01:00
|
|
|
local frame = player.gui.left.add({type = 'frame', name = 'pitch_black_score', direction = 'vertical'})
|
|
|
|
local t = frame.add({type = 'table', column_count = 2})
|
|
|
|
|
|
|
|
frame.tooltip = tooltip
|
|
|
|
t.tooltip = tooltip
|
|
|
|
|
|
|
|
local element = t.add({type = 'label', caption = 'Score: '})
|
|
|
|
element.style.font = 'heading-1'
|
|
|
|
element.style.font_color = {175, 175, 200}
|
|
|
|
element.style.horizontal_align = 'right'
|
|
|
|
element.style.maximal_width = 56
|
|
|
|
element.style.minimal_width = 56
|
|
|
|
element.tooltip = tooltip
|
|
|
|
|
2021-03-24 20:14:55 +01:00
|
|
|
element = t.add({type = 'label', caption = 0})
|
2021-03-24 16:46:00 +01:00
|
|
|
element.style.font = 'heading-1'
|
|
|
|
element.style.font_color = {100, 0, 255}
|
|
|
|
element.style.horizontal_align = 'left'
|
|
|
|
element.style.minimal_width = 32
|
|
|
|
element.tooltip = tooltip
|
|
|
|
|
|
|
|
return frame
|
2020-02-03 10:33:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local function update_score_gui(player)
|
2021-03-24 16:46:00 +01:00
|
|
|
local frame = player.gui.left.pitch_black_score
|
|
|
|
if not player.gui.left.pitch_black_score then
|
|
|
|
frame = create_score_gui(player)
|
|
|
|
end
|
|
|
|
|
|
|
|
local frame_table = frame.children[1]
|
|
|
|
|
|
|
|
local score_value = frame_table.children[2]
|
|
|
|
score_value.caption = global.map_score
|
2020-02-03 10:33:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function Public.update()
|
2021-03-24 16:46:00 +01:00
|
|
|
for _, player in pairs(game.connected_players) do
|
|
|
|
update_score_gui(player)
|
|
|
|
end
|
2020-02-03 10:33:27 +01:00
|
|
|
end
|
|
|
|
|
2021-03-24 16:46:00 +01:00
|
|
|
return Public
|