1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Converted to rich text

- Reducing the footprint
This commit is contained in:
SimonFlapse 2019-03-01 10:18:39 +01:00
parent 30809c077a
commit e7759b0d37

View File

@ -10,6 +10,17 @@ local concat = table.concat
local main_frame_name = Gui.uid_name() local main_frame_name = Gui.uid_name()
local main_button_name = Gui.uid_name() local main_button_name = Gui.uid_name()
local descriptions = {
{disc = 'Satellites launched', icon = '[img=item.satellite]'},
{disc = 'Biters liberated', icon = '[img=entity.medium-biter]'},
{disc = 'Buildings by hand', icon = '[img=utility.hand]'},
{disc = 'Buildings by robots', icon = '[img=item.construction-robot]'},
{disc = 'Trees chopped', icon = '[img=entity.tree-02]'},
{disc = 'Rocks smashed', icon = '[img=entity.rock-huge]'},
{disc = 'Kills by train', icon = '[img=item.locomotive]'},
{disc = 'Coins spent', icon = '[img=item.coin]'},
}
local function create_score_gui(event) local function create_score_gui(event)
local player = Game.get_player_by_index(event.player_index) local player = Game.get_player_by_index(event.player_index)
if not player then if not player then
@ -27,14 +38,14 @@ local function refresh_score()
local players = game.connected_players local players = game.connected_players
local count = game.forces.player.get_item_launched('satellite') local count = game.forces.player.get_item_launched('satellite')
local satellites_launched = concat {'Satellites launched: ', count, ' '} local satellites_launched = concat {descriptions[1].icon .. ' ', count, ' '}
local biters_liberated = concat {'Biters liberated: ', PlayerStats.get_total_biter_kills(), ' '} local biters_liberated = concat {descriptions[2].icon .. ' ', PlayerStats.get_total_biter_kills(), ' '}
local buildings_by_hand = concat {'Buildings by hand: ', PlayerStats.get_total_player_built_entities(), ' '} local buildings_by_hand = concat {descriptions[3].icon .. ' ', PlayerStats.get_total_player_built_entities(), ' '}
local buildings_by_robot = concat {'Buildings by robots: ', PlayerStats.get_total_robot_built_entities(), ' '} local buildings_by_robot = concat {descriptions[4].icon .. ' ', PlayerStats.get_total_robot_built_entities(), ' '}
local trees_chopped = concat {'Trees chopped: ', PlayerStats.get_total_player_trees_mined(), ' '} local trees_chopped = concat {descriptions[5].icon .. ' ', PlayerStats.get_total_player_trees_mined(), ' '}
local rocks_smashed = concat {'Rocks smashed: ', PlayerStats.get_total_player_rocks_mined(), ' '} local rocks_smashed = concat {descriptions[6].icon .. ' ', PlayerStats.get_total_player_rocks_mined(), ' '}
local kills_by_train = concat {'Kills by train: ', PlayerStats.get_total_train_kills(), ' '} local kills_by_train = concat {descriptions[7].icon .. ' ', PlayerStats.get_total_train_kills(), ' '}
local coins_spent = concat {'Coins spent: ', PlayerStats.get_total_coins_spent(), ' '} local coins_spent = concat {descriptions[8].icon .. ' ', PlayerStats.get_total_coins_spent(), ' '}
for i = 1, #players do for i = 1, #players do
local player = players[i] local player = players[i]
@ -64,7 +75,7 @@ local function score_show(top)
local count = game.forces.player.get_item_launched('satellite') local count = game.forces.player.get_item_launched('satellite')
local frame = top.add {type = 'frame', name = main_frame_name} local frame = top.add {type = 'frame', name = main_frame_name}
local score_table = frame.add {type = 'table', name = 'score_table', column_count = 4} local score_table = frame.add {type = 'table', name = 'score_table', column_count = 8}
local style = score_table.style local style = score_table.style
style.vertical_spacing = 4 style.vertical_spacing = 4
style.horizontal_spacing = 16 style.horizontal_spacing = 16
@ -73,23 +84,26 @@ local function score_show(top)
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_satellites_launched', name = 'label_satellites_launched',
caption = concat {'Satellites launched: ', count, ' '} caption = concat {descriptions[1].icon .. ' ', count, ' '},
tooltip = descriptions[1].disc
} }
score_label_style(label, Color.orange) score_label_style(label, Color.white)
label = label =
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_biters_killed', name = 'label_biters_killed',
caption = concat {'Biters liberated: ', PlayerStats.get_total_biter_kills(), ' '} caption = concat {descriptions[2].icon .. ' ', PlayerStats.get_total_biter_kills(), ' '},
tooltip = descriptions[2].disc
} }
score_label_style(label, Color.red) score_label_style(label, Color.white)
label = label =
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_player_built_entities', name = 'label_player_built_entities',
caption = concat {'Buildings by hand: ', PlayerStats.get_total_player_built_entities(), ' '} caption = concat {descriptions[3].icon .. ' ', PlayerStats.get_total_player_built_entities(), ' '},
tooltip = descriptions[3].disc
} }
score_label_style(label, Color.white) score_label_style(label, Color.white)
@ -97,7 +111,8 @@ local function score_show(top)
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_robot_built_entities', name = 'label_robot_built_entities',
caption = concat {'Buildings by robots: ', PlayerStats.get_total_robot_built_entities(), ' '} caption = concat {descriptions[4].icon .. ' ', PlayerStats.get_total_robot_built_entities(), ' '},
tooltip = descriptions[4].disc
} }
score_label_style(label, Color.white) score_label_style(label, Color.white)
@ -105,33 +120,37 @@ local function score_show(top)
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_player_mined_trees', name = 'label_player_mined_trees',
caption = concat {'Trees chopped: ', PlayerStats.get_total_player_trees_mined(), ' '} caption = concat {descriptions[5].icon .. ' ', PlayerStats.get_total_player_trees_mined(), ' '},
tooltip = descriptions[5].disc
} }
score_label_style(label, Color.lime) score_label_style(label, Color.white)
label = label =
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_player_mined_stones', name = 'label_player_mined_stones',
caption = concat {'Rocks smashed: ', PlayerStats.get_total_player_rocks_mined(), ' '} caption = concat {descriptions[6].icon .. ' ', PlayerStats.get_total_player_rocks_mined(), ' '},
tooltip = descriptions[6].disc
} }
score_label_style(label, Color.lime) score_label_style(label, Color.white)
label = label =
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_kills_by_train', name = 'label_kills_by_train',
caption = concat {'Kills by train: ', PlayerStats.get_total_train_kills(), ' '} caption = concat {descriptions[7].icon .. ' ', PlayerStats.get_total_train_kills(), ' '},
tooltip = descriptions[7].disc
} }
score_label_style(label, Color.yellow) score_label_style(label, Color.white)
label = label =
score_table.add { score_table.add {
type = 'label', type = 'label',
name = 'label_coins_spent', name = 'label_coins_spent',
caption = concat {'Coins spent: ', PlayerStats.get_total_coins_spent(), ' '} caption = concat {descriptions[8].icon .. ' ', PlayerStats.get_total_coins_spent(), ' '},
tooltip = descriptions[8].disc
} }
score_label_style(label, Color.yellow) score_label_style(label, Color.white)
end end
local function rocket_launched(event) local function rocket_launched(event)