mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-16 02:47:48 +02:00
resize buttons so they're all the same
This commit is contained in:
parent
a4e5da99fd
commit
3e283b4483
@ -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
|
||||
|
||||
@ -144,7 +144,7 @@ local function on_gui_click(event)
|
||||
if event.element.name == 'comfy_panel_top_button' then
|
||||
if player.gui.left.comfy_panel then
|
||||
player.gui.left.comfy_panel.destroy()
|
||||
Public.comfy_panel_restore_left_gui(player)
|
||||
Public.comfy_panel_restore_left_gui(player)
|
||||
return
|
||||
else
|
||||
Public.comfy_panel_clear_screen_gui(player)
|
||||
@ -155,7 +155,7 @@ local function on_gui_click(event)
|
||||
|
||||
if event.element.caption == 'X' and event.element.name == 'comfy_panel_close' then
|
||||
player.gui.left.comfy_panel.destroy()
|
||||
Public.comfy_panel_restore_left_gui(player)
|
||||
Public.comfy_panel_restore_left_gui(player)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
player.gui.top.add {
|
||||
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
|
||||
|
||||
|
@ -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 (t[n] and t[n].valid) then
|
||||
t[n].count = t[n].count + count
|
||||
else
|
||||
t[n] = {count = count, valid = true}
|
||||
if inventory[n] then
|
||||
if (t[n] and t[n].valid) then
|
||||
t[n].count = t[n].count + inventory[n]
|
||||
else
|
||||
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,27 +365,27 @@ 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)
|
||||
filtered_allowed = t
|
||||
if is_valid then
|
||||
filtered_chests[#filtered_chests + 1] = e
|
||||
end
|
||||
local filtered_chests = {}
|
||||
local filtered_allowed
|
||||
for _, e in pairs(chests) do
|
||||
local is_valid, t = chest_is_valid(e, inventory)
|
||||
filtered_allowed = t
|
||||
if is_valid then
|
||||
filtered_chests[#filtered_chests + 1] = e
|
||||
end
|
||||
end
|
||||
|
||||
this.floating_text_y_offsets = {}
|
||||
this.floating_text_y_offsets = {}
|
||||
|
||||
local hotbar_items = {}
|
||||
for i = 1, 100, 1 do
|
||||
local prototype = player.get_quick_bar_slot(i)
|
||||
if prototype then
|
||||
hotbar_items[prototype.name] = true
|
||||
end
|
||||
local hotbar_items = {}
|
||||
for i = 1, 100, 1 do
|
||||
local prototype = player.get_quick_bar_slot(i)
|
||||
if prototype then
|
||||
hotbar_items[prototype.name] = true
|
||||
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
|
||||
|
@ -4,79 +4,95 @@
|
||||
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"}})
|
||||
end
|
||||
end
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if not player.gui.top.charging_station then
|
||||
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 power_drained = 0
|
||||
power_needs = power_needs * global.charging_station_multiplier
|
||||
for _,accu in pairs(accumulators) do
|
||||
if accu.valid then
|
||||
if accu.energy > 3000000 and power_needs > 0 then
|
||||
if power_needs >= 2000000 then
|
||||
power_drained = power_drained + 2000000
|
||||
accu.energy = accu.energy - 2000000
|
||||
power_needs = power_needs - 2000000
|
||||
else
|
||||
power_drained = power_drained + power_needs
|
||||
accu.energy = accu.energy - power_needs
|
||||
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
|
||||
if accu.valid then
|
||||
if accu.energy > 3000000 and power_needs > 0 then
|
||||
if power_needs >= 2000000 then
|
||||
power_drained = power_drained + 2000000
|
||||
accu.energy = accu.energy - 2000000
|
||||
power_needs = power_needs - 2000000
|
||||
else
|
||||
power_drained = power_drained + power_needs
|
||||
accu.energy = accu.energy - power_needs
|
||||
end
|
||||
elseif power_needs <= 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif power_needs <= 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return power_drained / global.charging_station_multiplier
|
||||
return power_drained / global.charging_station_multiplier
|
||||
end
|
||||
|
||||
local function charge(player)
|
||||
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
|
||||
local armor = armor_inventory[1]
|
||||
if not armor.valid_for_read then return end
|
||||
local grid = armor.grid
|
||||
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
|
||||
local energy_needs = piece.max_energy - piece.energy
|
||||
if energy_needs > 0 then
|
||||
local energy = discharge_accumulators(player.surface, player.position, player.force, energy_needs)
|
||||
if energy > 0 then
|
||||
if piece.energy + energy >= piece.max_energy then
|
||||
piece.energy = piece.max_energy
|
||||
else
|
||||
piece.energy = piece.energy + energy
|
||||
end
|
||||
end
|
||||
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
|
||||
local armor = armor_inventory[1]
|
||||
if not armor.valid_for_read then
|
||||
return
|
||||
end
|
||||
local grid = armor.grid
|
||||
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
|
||||
local energy_needs = piece.max_energy - piece.energy
|
||||
if energy_needs > 0 then
|
||||
local energy = discharge_accumulators(player.surface, player.position, player.force, energy_needs)
|
||||
if energy > 0 then
|
||||
if piece.energy + energy >= piece.max_energy then
|
||||
piece.energy = piece.max_energy
|
||||
else
|
||||
piece.energy = piece.energy + energy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
draw_charging_gui()
|
||||
draw_charging_gui()
|
||||
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
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "charging_station" then
|
||||
charge(player)
|
||||
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
|
||||
charge(player)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
global.charging_station_multiplier = 1
|
||||
global.charging_station_multiplier = 1
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user