1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-28 03:57:22 +02:00

resize buttons so they're all the same

This commit is contained in:
Gerkiz 2020-12-05 18:09:37 +01:00
parent a4e5da99fd
commit 3e283b4483
7 changed files with 120 additions and 110 deletions

View File

@ -65,10 +65,10 @@ local function top_button(player)
if player.gui.top['comfy_panel_top_button'] then
return
end
local button =
player.gui.top.add({type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'})
local button = player.gui.top.add({type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'})
button.style.minimal_height = 38
button.style.minimal_width = 38
button.style.maximal_height = 38
button.style.minimal_width = 40
button.style.padding = -2
end

View File

@ -396,8 +396,7 @@ local function draw_main_frame(left, player)
right_flow.style.horizontal_align = 'right'
if (trusted[player.name] or player.admin) or global.comfy_panel_config.poll_trusted == false then
local create_poll_button =
right_flow.add {type = 'button', name = create_poll_button_name, caption = 'Create Poll'}
local create_poll_button = right_flow.add {type = 'button', name = create_poll_button_name, caption = 'Create Poll'}
apply_button_style(create_poll_button)
else
local create_poll_button =
@ -498,11 +497,9 @@ local function redraw_create_poll_content(data)
update_duration(duration_slider)
grid.add {type = 'flow'}
local question_label =
grid.add({type = 'flow'}).add {type = 'label', name = create_poll_label_name, caption = 'Question:'}
local question_label = grid.add({type = 'flow'}).add {type = 'label', name = create_poll_label_name, caption = 'Question:'}
local question_textfield =
grid.add({type = 'flow'}).add {type = 'textfield', name = create_poll_question_name, text = data.question}
local question_textfield = grid.add({type = 'flow'}).add {type = 'textfield', name = create_poll_question_name, text = data.question}
question_textfield.style.width = 170
Gui.set_data(question_label, question_textfield)
@ -587,8 +584,7 @@ local function draw_create_poll_frame(parent, player, previous_data)
confirm_name = create_poll_confirm_name
end
local frame =
parent.add {type = 'frame', name = create_poll_frame_name, caption = title_text, direction = 'vertical'}
local frame = parent.add {type = 'frame', name = create_poll_frame_name, caption = title_text, direction = 'vertical'}
frame.style.maximal_width = 320
local scroll_pane = frame.add {type = 'scroll-pane', vertical_scroll_policy = 'always'}
@ -649,8 +645,7 @@ local function draw_create_poll_frame(parent, player, previous_data)
end
local function show_new_poll(poll_data)
local message =
table.concat {poll_data.created_by.name, ' has created a new Poll #', poll_data.id, ': ', poll_data.question}
local message = table.concat {poll_data.created_by.name, ' has created a new Poll #', poll_data.id, ': ', poll_data.question}
for _, p in pairs(game.connected_players) do
local left = p.gui.left
@ -826,12 +821,14 @@ local function player_joined(event)
update_poll_viewer(data)
end
else
local b =
player.gui.top.add {
type = 'sprite-button',
name = main_button_name,
sprite = 'item/programmable-speaker',
tooltip = 'Let your question be heard!'
}
b.style.maximal_height = 38
end
end

View File

@ -42,17 +42,20 @@ local function create_floaty_text(surface, position, name, count)
)
end
local function chest_is_valid(chest, count)
local function chest_is_valid(chest, inventory)
if chest.type == 'cargo-wagon' then
local t = {}
local chest_inventory = chest.get_inventory(defines.inventory.cargo_wagon)
inventory = inventory.get_contents()
for index = 1, 40 do
if chest_inventory.get_filter(index) ~= nil then
local n = chest_inventory.get_filter(index)
if inventory[n] then
if (t[n] and t[n].valid) then
t[n].count = t[n].count + count
t[n].count = t[n].count + inventory[n]
else
t[n] = {count = count, valid = true}
t[n] = {count = inventory[n], valid = true}
end
end
end
end
@ -192,7 +195,6 @@ local function insert_item_into_chest(player_inventory, chests, filtered_chests,
['container'] = true,
['logistic-container'] = true
}
local to_insert = math.floor(count / #chests)
local variator = count % #chests
@ -343,10 +345,7 @@ local function auto_stash(player, event)
player.print('Inventory is empty.', print_color)
return
end
local inventory_tbl = {}
for name, count in pairs(inventory.get_contents()) do
inventory_tbl[name] = count
end
local chests
local r = this.small_radius
local area = {{player.position.x - r, player.position.y - r}, {player.position.x + r, player.position.y + r}}
@ -366,11 +365,10 @@ local function auto_stash(player, event)
player.print('No valid nearby containers found.', print_color)
return
end
for name, count in pairs(inventory_tbl) do
local filtered_chests = {}
local filtered_allowed
for _, e in pairs(chests) do
local is_valid, t = chest_is_valid(e, count)
local is_valid, t = chest_is_valid(e, inventory)
filtered_allowed = t
if is_valid then
filtered_chests[#filtered_chests + 1] = e
@ -387,6 +385,7 @@ local function auto_stash(player, event)
end
end
for name, count in pairs(inventory.get_contents()) do
local is_resource = this.whitelist[name]
if not inventory.find_item_stack(name).grid and not hotbar_items[name] then
@ -451,10 +450,10 @@ local function create_gui_button(player)
)
b.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
b.style.font = 'heading-1'
b.style.minimal_height = 38
b.style.minimal_height = 40
b.style.maximal_width = 40
b.style.minimal_width = 38
b.style.maximal_height = 38
b.style.maximal_width = 38
b.style.padding = 1
b.style.margin = 0
end

View File

@ -6,13 +6,15 @@ local Event = require 'utils.event'
local function draw_charging_gui()
for _, player in pairs(game.connected_players) do
if not player.gui.top.charging_station then
player.gui.top.add({type = "sprite-button", name = "charging_station", sprite = "item/battery-mk2-equipment", tooltip = {"modules.charging_station_tooltip"}})
local b = player.gui.top.add({type = 'sprite-button', name = 'charging_station', sprite = 'item/battery-mk2-equipment', tooltip = {'modules.charging_station_tooltip'}})
b.style.minimal_height = 38
b.style.maximal_height = 38
end
end
end
local function discharge_accumulators(surface, position, force, power_needs)
local accumulators = surface.find_entities_filtered{name = "accumulator", force = force, position = position, radius = 13}
local accumulators = surface.find_entities_filtered {name = 'accumulator', force = force, position = position, radius = 13}
local power_drained = 0
power_needs = power_needs * global.charging_station_multiplier
for _, accu in pairs(accumulators) do
@ -35,13 +37,21 @@ local function discharge_accumulators(surface, position, force, power_needs)
end
local function charge(player)
if not player.character then return end
if not player.character then
return
end
local armor_inventory = player.get_inventory(defines.inventory.character_armor)
if not armor_inventory.valid then return end
if not armor_inventory.valid then
return
end
local armor = armor_inventory[1]
if not armor.valid_for_read then return end
if not armor.valid_for_read then
return
end
local grid = armor.grid
if not grid or not grid.valid then return end
if not grid or not grid.valid then
return
end
local equip = grid.equipment
for _, piece in pairs(equip) do
if piece.valid and piece.generator_power == 0 then
@ -65,11 +75,17 @@ local function on_player_joined_game(event)
end
local function on_gui_click(event)
if not event then return end
if not event.element then return end
if not event.element.valid then return end
if not event then
return
end
if not event.element then
return
end
if not event.element.valid then
return
end
local player = game.players[event.element.player_index]
if event.element.name == "charging_station" then
if event.element.name == 'charging_station' then
charge(player)
return
end

View File

@ -81,7 +81,8 @@ function Public.difficulty_gui()
}
b.style.font = 'heading-2'
b.style.font_color = this.difficulties[this.difficulty_vote_index].print_color
b.style.minimal_height = 38
b.style.minimal_height = 37
b.style.maximal_height = 37
b.style.minimal_width = this.gui_width
end
end

View File

@ -31,7 +31,8 @@ function Public.draw_gui_char_button(player)
local b = player.gui.top.add({type = 'sprite-button', name = draw_main_frame_name, caption = '[RPG]', tooltip = 'RPG'})
b.style.font_color = {165, 165, 165}
b.style.font = 'heading-3'
b.style.minimal_height = 34
b.style.minimal_height = 38
b.style.maximal_height = 38
b.style.minimal_width = 50
b.style.padding = 0
b.style.margin = 0
@ -51,8 +52,7 @@ end
local function get_class(player)
local rpg_t = RPG.get('rpg_t')
local average =
(rpg_t[player.index].strength + rpg_t[player.index].magicka + rpg_t[player.index].dexterity + rpg_t[player.index].vitality) / 4
local average = (rpg_t[player.index].strength + rpg_t[player.index].magicka + rpg_t[player.index].dexterity + rpg_t[player.index].vitality) / 4
local high_attribute = 0
local high_attribute_name = ''
for _, attribute in pairs({'strength', 'magicka', 'dexterity', 'vitality'}) do
@ -338,8 +338,7 @@ local function draw_main_frame(player, location)
add_gui_description(right_bottom_table, ' ', w0)
add_gui_description(right_bottom_table, ({'rpg_gui.mining_name'}), w1)
local mining_speed_value =
math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100) .. '%'
local mining_speed_value = math.round((player.force.manual_mining_speed_modifier + player.character_mining_speed_modifier + 1) * 100) .. '%'
add_gui_stat(right_bottom_table, mining_speed_value, w2)
add_gui_description(right_bottom_table, ' ', w0)
@ -388,14 +387,12 @@ local function draw_main_frame(player, location)
add_gui_description(right_bottom_table, ' ', w0)
add_gui_description(right_bottom_table, ({'rpg_gui.crafting_speed'}), w1)
local crafting_speed_value =
math.round((player.force.manual_crafting_speed_modifier + player.character_crafting_speed_modifier + 1) * 100) .. '%'
local crafting_speed_value = math.round((player.force.manual_crafting_speed_modifier + player.character_crafting_speed_modifier + 1) * 100) .. '%'
add_gui_stat(right_bottom_table, crafting_speed_value, w2)
add_gui_description(right_bottom_table, ' ', w0)
add_gui_description(right_bottom_table, ({'rpg_gui.running_speed'}), w1)
local running_speed_value =
math.round((player.force.character_running_speed_modifier + player.character_running_speed_modifier + 1) * 100) .. '%'
local running_speed_value = math.round((player.force.character_running_speed_modifier + player.character_running_speed_modifier + 1) * 100) .. '%'
add_gui_stat(right_bottom_table, running_speed_value, w2)
add_gui_description(right_bottom_table, ' ', w0)

View File

@ -2,7 +2,7 @@ local WD = require 'modules.wave_defense.table'
local function create_gui(player)
local frame = player.gui.top.add({type = 'frame', name = 'wave_defense'})
frame.style.maximal_height = 38
frame.style.maximal_height = 37
local label = frame.add({type = 'label', caption = ' ', name = 'label'})
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}