1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-17 20:58:13 +02:00

gui label fixes

This commit is contained in:
Gerkiz 2022-04-07 16:12:34 +02:00
parent 095895ed81
commit c048002b7d
4 changed files with 75 additions and 57 deletions

View File

@ -30,8 +30,8 @@ local function build_group_gui(data)
local group_name_width = 150
local description_width = 240
local members_width = 90
local member_columns = 3
local actions_width = 80
local member_columns = 2
local actions_width = 130
local total_height = frame.style.minimal_height - 60
frame.clear()
@ -46,11 +46,12 @@ local function build_group_gui(data)
for _, h in pairs(headings) do
local l = t.add({type = 'label', caption = h[1]})
l.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
l.style.font = 'default-listbox'
l.style.font = 'heading-2'
l.style.top_padding = 6
l.style.minimal_height = 40
l.style.minimal_width = h[2]
l.style.maximal_width = h[2]
l.style.horizontal_align = 'center'
end
local scroll_pane =
@ -76,11 +77,12 @@ local function build_group_gui(data)
for _, group in pairs(this.tag_groups) do
if (group.name and group.founder and group.description) then
local l = t.add({type = 'label', caption = group.name})
l.style.font = 'default-bold'
l.style.top_padding = 16
l.style.bottom_padding = 16
l.style.minimal_width = group_name_width
l.style.maximal_width = group_name_width
l.style.font = 'heading-3'
l.style.horizontal_align = 'center'
local color
if game.players[group.founder] and game.players[group.founder].color then
color = game.players[group.founder].color
@ -97,11 +99,17 @@ local function build_group_gui(data)
l.style.maximal_width = description_width
l.style.font_color = {r = 0.90, g = 0.90, b = 0.90}
l.style.single_line = false
l.style.font = 'heading-3'
l.style.horizontal_align = 'center'
local tt = t.add({type = 'table', column_count = member_columns})
local tt = t.add({type = 'table', column_count = 2})
local flow = tt.add({type = 'flow'})
flow.style.left_padding = 65
local ttt = tt.add({type = 'table', column_count = member_columns})
ttt.style.minimal_width = members_width * 2 - 25
for _, p in pairs(game.connected_players) do
if group.name == this.player_group[p.name] then
l = tt.add({type = 'label', caption = p.name})
l = ttt.add({type = 'label', caption = p.name})
color = {
r = p.color.r * 0.6 + 0.4,
g = p.color.g * 0.6 + 0.4,
@ -109,8 +117,10 @@ local function build_group_gui(data)
a = 1
}
l.style.font_color = color
--l.style.minimal_width = members_width
l.style.maximal_width = members_width * 2
l.style.maximal_width = members_width * 2 - 60
l.style.single_line = false
l.style.font = 'heading-3'
l.style.horizontal_align = 'center'
end
end
@ -153,10 +163,12 @@ end
local build_group_gui_token = Token.register(build_group_gui)
local function refresh_gui()
for _, p in pairs(game.connected_players) do
local frame = Gui.get_player_active_frame(p)
local players = game.connected_players
for i = 1, #players do
local player = players[i]
local frame = Gui.get_player_active_frame(player)
if frame then
if frame.name == module_name then
if frame.frame2 and frame.frame2.valid then
local new_group_name = frame.frame2.group_table.new_group_name.text
local new_group_description = frame.frame2.group_table.new_group_description.text
@ -168,10 +180,10 @@ local function refresh_gui()
new_group_description = ''
end
local data = {player = p, frame = frame}
local data = {player = player, frame = frame}
build_group_gui(data)
frame = Gui.get_player_active_frame(p)
frame = Gui.get_player_active_frame(player)
frame.frame2.group_table.new_group_name.text = new_group_name
frame.frame2.group_table.new_group_description.text = new_group_description
end

View File

@ -576,7 +576,7 @@ local function player_list_show(data)
name = 'player_list_panel_header_' .. k,
caption = v
}
header_label.style.font = 'default-bold'
header_label.style.font = 'heading-2'
header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
end
@ -677,6 +677,7 @@ local function player_list_show(data)
}
name_label.style.minimal_width = column_widths['name_label']
name_label.style.maximal_width = column_widths['name_label']
name_label.style.font = 'heading-3'
-- RPG level
if this.rpg_enabled then
@ -689,6 +690,7 @@ local function player_list_show(data)
}
rpg_level_label.style.minimal_width = column_widths['rpg_level_label']
rpg_level_label.style.maximal_width = column_widths['rpg_level_label']
rpg_level_label.style.font = 'heading-3'
end
-- Total time
@ -700,6 +702,7 @@ local function player_list_show(data)
}
total_label.style.minimal_width = column_widths['total_label']
total_label.style.maximal_width = column_widths['total_label']
total_label.style.font = 'heading-3'
-- Current time
local current_label =
@ -710,6 +713,7 @@ local function player_list_show(data)
}
current_label.style.minimal_width = column_widths['current_label']
current_label.style.maximal_width = column_widths['current_label']
current_label.style.font = 'heading-3'
-- Poke
local flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'}

View File

@ -127,22 +127,22 @@ local function add_global_stats(frame, player)
local t = frame.add {type = 'table', column_count = 5}
local l = t.add {type = 'label', caption = 'Rockets launched: '}
l.style.font = 'default-game'
l.style.font = 'heading-2'
l.style.font_color = {r = 175, g = 75, b = 255}
l.style.minimal_width = 140
local rocketsLaunched_label = t.add {type = 'label', caption = format_number(player.force.rockets_launched, true)}
rocketsLaunched_label.style.font = 'default-listbox'
rocketsLaunched_label.style.font = 'heading-3'
rocketsLaunched_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9}
rocketsLaunched_label.style.minimal_width = 123
local bugs_dead_label = t.add {type = 'label', caption = 'Dead bugs: '}
bugs_dead_label.style.font = 'default-game'
bugs_dead_label.style.font = 'heading-2'
bugs_dead_label.style.font_color = {r = 0.90, g = 0.3, b = 0.3}
bugs_dead_label.style.minimal_width = 100
local killcount_label = t.add {type = 'label', caption = format_number(tonumber(get_total_biter_killcount(player.force)), true)}
killcount_label.style.font = 'default-listbox'
killcount_label.style.font = 'heading-3'
killcount_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9}
killcount_label.style.minimal_width = 145
end
@ -191,10 +191,10 @@ local function show_score(data)
caption = cap,
name = header.name
}
label.style.font = 'default-listbox'
label.style.font = 'heading-2'
label.style.font_color = {r = 0.98, g = 0.66, b = 0.22} -- yellow
label.style.minimal_width = 150
label.style.horizontal_align = 'right'
label.style.horizontal_align = 'center'
end
-- Score list
@ -243,10 +243,10 @@ local function show_score(data)
caption = column.caption,
color = column.color or default_color
}
label.style.font = 'default'
label.style.font = 'heading-3'
label.style.minimal_width = 150
label.style.maximal_width = 150
label.style.horizontal_align = 'right'
label.style.horizontal_align = 'center'
end -- foreach column
end -- foreach entry
end

View File

@ -66,42 +66,44 @@ local function draw_main_frame(player)
}
else
for _, i in ipairs(instances) do
viewer_table.add {
type = 'label',
caption = i.name,
tooltip = i.connected .. '\nVersion: ' .. i.version,
style = 'caption_label'
}
local flow = viewer_table.add {type = 'flow'}
flow.style.horizontal_align = 'right'
flow.style.horizontally_stretchable = true
local empty_flow = viewer_table.add {type = 'flow'}
local button =
empty_flow.add {
type = 'button',
caption = 'Connect',
tooltip = 'Click to connect to this server.\n' .. i.connected .. '\nVersion: ' .. i.version,
name = instance_id_name
}
Gui.set_data(button, i.id)
apply_button_style(button)
if string.len(i.name) > 1 then
viewer_table.add {
type = 'label',
caption = i.name,
tooltip = i.connected .. '\nVersion: ' .. i.version,
style = 'caption_label'
}
local flow = viewer_table.add {type = 'flow'}
flow.style.horizontal_align = 'right'
flow.style.horizontally_stretchable = true
local empty_flow = viewer_table.add {type = 'flow'}
local button =
empty_flow.add {
type = 'button',
caption = 'Connect',
tooltip = 'Click to connect to this server.\n' .. i.connected .. '\nVersion: ' .. i.version,
name = instance_id_name
}
Gui.set_data(button, i.id)
apply_button_style(button)
if i.id == instance.id then
button.enabled = false
button.tooltip = 'You are here'
elseif i.status == 'unknown' then
button.enabled = i.game_port ~= nil
button.style.font_color = {r = 0.65}
button.style.hovered_font_color = {r = 0.65}
button.style.clicked_font_color = {r = 0.65}
button.style.disabled_font_color = {r = 0.75, g = 0.1, b = 0.1}
button.tooltip = 'Unknown status for this server'
elseif i.status ~= 'running' then
button.enabled = false
button.tooltip = 'This server is offline'
elseif i.version ~= instance.version then
button.enabled = false
button.tooltip = "We're on version: " .. instance.version .. '\nDestination server is on version: ' .. i.version
if i.id == instance.id then
button.enabled = false
button.tooltip = 'You are here'
elseif i.status == 'unknown' then
button.enabled = i.game_port ~= nil
button.style.font_color = {r = 0.65}
button.style.hovered_font_color = {r = 0.65}
button.style.clicked_font_color = {r = 0.65}
button.style.disabled_font_color = {r = 0.75, g = 0.1, b = 0.1}
button.tooltip = 'Unknown status for this server'
elseif i.status ~= 'running' then
button.enabled = false
button.tooltip = 'This server is offline'
elseif i.version ~= instance.version then
button.enabled = false
button.tooltip = "We're on version: " .. instance.version .. '\nDestination server is on version: ' .. i.version
end
end
end
end