Add joinable legacy code

This commit is contained in:
Cooldude2606
2024-09-23 23:01:52 +01:00
parent 2a1206c498
commit d24555d805
24 changed files with 144 additions and 126 deletions

View File

@@ -31,9 +31,9 @@ end
local toggle_section =
Gui.element{
type = 'sprite-button',
sprite = 'utility/expand_dark',
hovered_sprite = 'utility/expand',
sprite = 'utility/expand',
tooltip = {'autofill.toggle-section-tooltip'},
style = "frame_action_button",
name = Gui.unique_static_name
}
:style(Gui.sprite_style(20))
@@ -42,12 +42,10 @@ Gui.element{
local flow_name = header_flow.caption
local flow = header_flow.parent.parent[flow_name]
if Gui.toggle_visible_state(flow) then
element.sprite = 'utility/collapse_dark'
element.hovered_sprite = 'utility/collapse'
element.sprite = 'utility/collapse'
element.tooltip = {'autofill.toggle-section-collapse-tooltip'}
else
element.sprite = 'utility/expand_dark'
element.hovered_sprite = 'utility/expand'
element.sprite = 'utility/expand'
element.tooltip = {'autofill.toggle-section-tooltip'}
end
end)

View File

@@ -7,6 +7,7 @@ local Gui = require("modules.exp_legacy.expcore.gui") --- @dep expcore.gui
local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
local config = require("modules.exp_legacy.config.bonus") --- @dep config.bonus
local vlayer = require("modules.exp_legacy.modules.control.vlayer")
local format_number = require("util").format_number --- @dep util
local bonus_container

View File

@@ -11,7 +11,7 @@ local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
local rolling_stocks = {}
local function landfill_init()
for name, _ in pairs(game.get_filtered_entity_prototypes({{filter = 'rolling-stock'}})) do
for name, _ in pairs(prototypes.get_entity_filtered{{filter = 'rolling-stock'}}) do
rolling_stocks[name] = true
end
end
@@ -103,9 +103,10 @@ local function landfill_gui_add_landfill(blueprint)
if not (rolling_stocks[ent.name] or ent.name == 'offshore-pump') then
-- curved rail, special
if ent.name ~= 'curved-rail' then
local box = game.entity_prototypes[ent.name].collision_box or game.entity_prototypes[ent.name].selection_box
local proto = prototypes.entity[ent.name]
local box = proto.collision_box or proto.selection_box
if game.entity_prototypes[ent.name].collision_mask['ground-tile'] == nil then
if proto.collision_mask['ground-tile'] == nil then
if ent.direction then
if ent.direction ~= defines.direction.north then
box = rotate_bounding_box(box)

View File

@@ -32,8 +32,8 @@ end
local prod_module_names = {}
local function get_module_name()
for name, item in pairs(game.item_prototypes) do
if item.module_effects and item.module_effects.productivity and item.module_effects.productivity.bonus > 0 then
for name, item in pairs(prototypes.item) do
if item.module_effects and item.module_effects.productivity and item.module_effects.productivity > 0 then
prod_module_names[#prod_module_names + 1] = name
end
end
@@ -124,7 +124,7 @@ Selection.on_selection(SelectionModuleArea, function(event)
['p'] = {}
}
for j=1, game.entity_prototypes[mma].module_inventory_size, 1 do
for j=1, prototypes.entity[mma].module_inventory_size, 1 do
local mmo = scroll_table['module_mm_' .. i .. '_' .. j].elem_value
if mmo then
@@ -161,7 +161,7 @@ local function row_set(player, element)
if scroll_table[element .. '0'].elem_value then
for i=1, config.module_slot_max do
if i <= game.entity_prototypes[scroll_table[element .. '0'].elem_value].module_inventory_size then
if i <= prototypes.entity[scroll_table[element .. '0'].elem_value].module_inventory_size then
if config.machine[scroll_table[element .. '0'].elem_value].prod then
scroll_table[element .. i].elem_filters = elem_filter.prod

View File

@@ -27,7 +27,7 @@ config.set_datastores(SelectedPlayer, SelectedAction)
local open_action_bar =
Gui.element{
type = 'sprite-button',
sprite = 'utility/expand_dots_white',
sprite = 'utility/expand_dots',
tooltip = {'player-list.open-action-bar'},
style = 'frame_button',
name = Gui.unique_static_name

View File

@@ -130,7 +130,7 @@ end)
Event.on_nth_tick(60, function()
for _, player in pairs(game.connected_players) do
local frame = Gui.get_left_element(player, production_container)
local stat = player.force.item_production_statistics
local stat = player.force.get_item_production_statistics(player.surface)
local precision_value = precision[frame.container['production_st'].disp.table['production_0_e'].selected_index]
local table = frame.container['production_st'].disp.table
@@ -139,8 +139,8 @@ Event.on_nth_tick(60, function()
local item = table[production_prefix .. '_e'].elem_value
if item then
local add = stat.get_flow_count{name=item, input=true, precision_index=precision_value, count=false} / 60
local minus = stat.get_flow_count{name=item, input=false, precision_index=precision_value, count=false} / 60
local add = math.floor(stat.get_flow_count{name=item, category="input", precision_index=precision_value, count=false} / 6) / 10
local minus = math.floor(stat.get_flow_count{name=item, category="output", precision_index=precision_value, count=false} / 6) / 10
local sum = add - minus
table[production_prefix .. '_1'].caption = format_n(add)

View File

@@ -81,14 +81,15 @@ Gui.element(function(_, parent, server_id, wrong_version)
local flow = parent.add{ name = server_id, type = 'flow' }
local button = flow.add{
type = 'sprite-button',
sprite = 'utility/circuit_network_panel_white', --- network panel white, warning white, download white
hovered_sprite = 'utility/circuit_network_panel_black', --- network panel black, warning black, download black
tooltip = {'readme.servers-connect-'..status, wrong_version}
sprite = 'utility/circuit_network_panel',
hovered_sprite = 'utility/circuit_network_panel',
tooltip = {'readme.servers-connect-'..status, wrong_version},
style = "frame_action_button"
}
if status == 'Offline' or status == 'Current' then
button.enabled = false
button.sprite = 'utility/circuit_network_panel_black'
button.sprite = 'utility/circuit_network_panel'
elseif status == 'Version' then
button.enabled = false
button.sprite = 'utility/shuffle'
@@ -119,9 +120,9 @@ Gui.element(function(_, parent)
-- Set up the top flow with logos
local top_flow = container.add{ type='flow' }
top_flow.add{ type='sprite', sprite='file/modules/gui/logo.png' }
top_flow.add{ type='sprite', sprite='file/modules/exp_legacy/modules/gui/logo.png' }
local top_vertical_flow = top_flow.add{ type='flow', direction='vertical' }
top_flow.add{ type='sprite', sprite='file/modules/gui/logo.png' }
top_flow.add{ type='sprite', sprite='file/modules/exp_legacy/modules/gui/logo.png' }
top_vertical_flow.style.horizontal_align = 'center'
-- Add the title and description to the top flow
@@ -415,7 +416,7 @@ Gui.element(function(definition, parent)
local left_side =
left_alignment.add{
type = 'frame',
style = 'frame_without_right_side'
style = 'character_gui_left_side'
}
left_side.style.vertically_stretchable = true
left_side.style.padding = 0

View File

@@ -153,7 +153,7 @@ local function research_gui_update()
local res_i = res_n + i - 3
if res['disp'][res_i] then
res_disp[i]['name'] = {'expcom-res.res-name', res['disp'][res_i]['raw_name'], game.technology_prototypes[res['disp'][res_i]['raw_name']].localised_name}
res_disp[i]['name'] = {'expcom-res.res-name', res['disp'][res_i]['raw_name'], prototypes.technology[res['disp'][res_i]['raw_name']].localised_name}
if research.time[res_i] == 0 then
res_disp[i]['target'] = res['disp'][res_i].target_disp

View File

@@ -423,9 +423,10 @@ end
local toggle_section =
Gui.element{
type = 'sprite-button',
sprite = 'utility/expand_dark',
sprite = 'utility/expand',
hovered_sprite = 'utility/expand',
tooltip = {'rocket-info.toggle-section-tooltip'},
style = "frame_action_button",
name = Gui.unique_static_name
}
:style(Gui.sprite_style(20))
@@ -434,12 +435,10 @@ Gui.element{
local flow_name = header_flow.caption
local flow = header_flow.parent.parent[flow_name]
if Gui.toggle_visible_state(flow) then
element.sprite = 'utility/collapse_dark'
element.hovered_sprite = 'utility/collapse'
element.sprite = 'utility/collapse'
element.tooltip = {'rocket-info.toggle-section-collapse-tooltip'}
else
element.sprite = 'utility/expand_dark'
element.hovered_sprite = 'utility/expand'
element.sprite = 'utility/expand'
element.tooltip = {'rocket-info.toggle-section-tooltip'}
end
end)
@@ -523,7 +522,7 @@ end)
--- Button on the top flow used to toggle the container
-- @element toggle_rocket_info
Gui.left_toolbar_button('item/satellite', {'rocket-info.main-tooltip'}, rocket_list_container, function(player)
Gui.left_toolbar_button('item/rocket-silo', {'rocket-info.main-tooltip'}, rocket_list_container, function(player)
return Roles.player_allowed(player, 'gui/rocket-info')
end)

View File

@@ -299,7 +299,7 @@ Gui.element(function(definition, parent)
type = 'label',
caption = null_time_short,
tooltip = null_time_long,
style = 'heading_1_label'
style = 'frame_title'
}
-- Update the eta

View File

@@ -114,8 +114,9 @@ local no_tasks_found =
local center =
header.add {
type = "flow",
style = "centering_horizontal_flow"
}
center.style.vertical_align = "center"
center.style.horizontal_align = "center"
center.style.horizontally_stretchable = true
center.add {
name = "header_label",
@@ -156,7 +157,7 @@ local subfooter_label =
return parent.add {
name = "footer_label",
type = "label",
style = "heading_1_label",
style = "frame_title",
caption = caption
}
end
@@ -240,7 +241,7 @@ local task_view_edit_button =
Gui.element {
type = "button",
name = Gui.unique_static_name,
caption = {"", "[img=utility/rename_icon_normal] ", {"task-list.edit"}},
caption = {"", "[img=utility/rename_icon] ", {"task-list.edit"}},
tooltip = {"task-list.edit-tooltip"},
style = "shortcut_bar_button"
}:style(Styles.footer_button):on_click(
@@ -257,8 +258,8 @@ local task_view_edit_button =
local task_view_close_button =
Gui.element{
type = "sprite-button",
sprite = "utility/collapse_dark",
hovered_sprite = "utility/collapse",
sprite = "utility/collapse",
style = "frame_action_button",
tooltip = {"task-list.close-tooltip"}
}
:style(Styles.sprite22):on_click(

View File

@@ -353,6 +353,7 @@ for index, element_define in ipairs(Gui.top_elements) do
if prev_handler then prev_handler(player, element, event) end -- Kind of hacky but works
local frame = Gui.get_left_element(player, toolbar_container)
if not frame then return end -- Gui might not be loaded yet
if not frame.container then log(frame.name) log(frame.parent.name) end
local button = frame.container.scroll.list[element_define.name][element_define.name]
local toolbar_button = Gui.get_top_element(player, element_define)
copy_style(toolbar_button, button)

View File

@@ -115,7 +115,7 @@ Gui.element{
radius = config.standard_proximity_radius + 2.5,
position = position,
collision_mask = {
'item-layer', 'object-layer', 'player-layer', 'water-tile'
'item', 'object', 'player', 'water_tile'
}
}
-- Remove 1 because that is the current player
@@ -256,8 +256,8 @@ end)
-- Required fields to make it squashable and strechable.
minimal_width = 10,
maximal_width = 300,
horizontally_squashable = "on",
horizontally_stretchable = "on",
horizontally_squashable = true,
horizontally_stretchable = true,
-- Other styling
height = 22,
padding = -2,
@@ -336,7 +336,7 @@ end)
local edit_warp_button =
Gui.element{
type = 'sprite-button',
sprite = 'utility/rename_icon_normal',
sprite = 'utility/rename_icon',
tooltip = {'warp-list.edit-tooltip-none'},
style = 'shortcut_bar_button',
name = Gui.unique_static_name