Skip to content

Commit

Permalink
Merge branch 'factorio-2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 committed Oct 19, 2024
2 parents 67cef23 + bee7ca1 commit a0264a6
Show file tree
Hide file tree
Showing 9 changed files with 407 additions and 385 deletions.
28 changes: 14 additions & 14 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ local function update_surface_count()
-- Hides 'All surfaces' button
local multiple_surfaces = #filtered_surfaces() > 1

if multiple_surfaces ~= global.multiple_surfaces then
for _, player_data in pairs(global.players) do
if multiple_surfaces ~= storage.multiple_surfaces then
for _, player_data in pairs(storage.players) do
local all_surfaces = player_data.refs.all_surfaces
all_surfaces.visible = multiple_surfaces
end
end

global.multiple_surfaces = multiple_surfaces
storage.multiple_surfaces = multiple_surfaces
end

script.on_event({defines.events.on_surface_created, defines.events.on_surface_deleted}, update_surface_count)
Expand All @@ -56,14 +56,14 @@ local function generate_item_to_entity_table()
-- Exception in mineable_properties is we don't want to include entity_name when type == "simple-entity" if item_name is a resource
-- This prevents things like rocks showing when searching for stone

local resource_prototypes = game.get_filtered_entity_prototypes({{filter = "type", type = "resource"}})
local resource_prototypes = prototypes.get_entity_filtered({{filter = "type", type = "resource"}})
local is_resource = {}
for _, resource in pairs(resource_prototypes) do
is_resource[resource.name] = true
end


local prototypes = game.get_filtered_entity_prototypes({})
local prototypes = prototypes.get_entity_filtered({})
-- Filter out rocks
local item_to_entities = {}
for _, prototype in pairs(prototypes) do
Expand Down Expand Up @@ -91,21 +91,21 @@ local function generate_item_to_entity_table()
end

-- Hardcode some Pyanodons associations
if game.active_mods["pypetroleumhandling"] then
if script.active_mods["pypetroleumhandling"] then
-- or {} in case something removed those items or playing an older version of Py
table.insert(item_to_entities["raw-gas"] or {}, "bitumen-seep")
table.insert(item_to_entities["tar"] or {}, "bitumen-seep")
table.insert(item_to_entities["crude-oil"] or {}, "bitumen-seep")
end

global.item_to_entities = item_to_entities
storage.item_to_entities = item_to_entities
end

script.on_init(
function()
global.players = {}
global.current_searches = {}
global.multiple_surfaces = false
storage.players = {}
storage.current_searches = {}
storage.multiple_surfaces = false
update_surface_count()
generate_item_to_entity_table()
end
Expand All @@ -114,19 +114,19 @@ script.on_init(
script.on_configuration_changed(
function()
-- Destroy all GUIs
for player_index, player_data in pairs(global.players) do
for player_index, player_data in pairs(storage.players) do
local player = game.get_player(player_index)
if player then
Gui.destroy(player, player_data)
else
global.players[player_index] = nil
storage.players[player_index] = nil
end
end

-- Stop in-progress non-blocking searches
global.current_searches = {}
storage.current_searches = {}

global.multiple_surfaces = false
storage.multiple_surfaces = false
update_surface_count()
generate_item_to_entity_table()
end
Expand Down
Binary file removed graphics/search-white.png
Binary file not shown.
25 changes: 4 additions & 21 deletions prototypes/shortcuts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,10 @@ local search_shortcut = {
associated_control_input = "search-factory",
toggleable = true,
order = "d",
icon = {
filename = "__FactorySearch__/graphics/search-black.png",
size = 26,
flags = {"gui-icon"}
},
--[[small_icon = {
filename = "__SpidertronEnhancements__/graphics/follow-shortcut-24.png",
size = 24,
flags = {"gui-icon"}
},]]
disabled_icon = {
filename = "__FactorySearch__/graphics/search-white.png",
size = 26,
flags = {"gui-icon"}
},
--[[disabled_small_icon =
{
filename = "__SpidertronEnhancements__/graphics/follow-shortcut-white-24.png",
size = 24,
flags = {"gui-icon"}
}]]
icon = "__FactorySearch__/graphics/search-black.png",
icon_size = 26,
small_icon = "__FactorySearch__/graphics/search-black.png",
small_icon_size = 26,
}
local search_input = {
type = "custom-input",
Expand Down
20 changes: 0 additions & 20 deletions prototypes/style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,3 @@ styles.fs_flib_titlebar_drag_handle = {
height = 24,
horizontally_stretchable = "on",
}

styles.fs_flib_selected_frame_action_button = {
type = "button_style",
parent = "frame_action_button",
default_font_color = button_hovered_font_color,
default_graphical_set = {
base = { position = { 225, 17 }, corner_size = 8 },
shadow = { position = { 440, 24 }, corner_size = 8, draw_type = "outer" },
},
hovered_font_color = button_hovered_font_color,
hovered_graphical_set = {
base = { position = { 369, 17 }, corner_size = 8 },
shadow = { position = { 440, 24 }, corner_size = 8, draw_type = "outer" },
},
clicked_font_color = button_hovered_font_color,
clicked_graphical_set = {
base = { position = { 352, 17 }, corner_size = 8 },
shadow = { position = { 440, 24 }, corner_size = 8, draw_type = "outer" },
},
}
26 changes: 13 additions & 13 deletions scripts/custom-input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local function on_shortcut_pressed(event)
if event.prototype_name and event.prototype_name ~= "search-factory" then return end
local player = game.get_player(event.player_index)

local player_data = global.players[event.player_index]
local player_data = storage.players[event.player_index]
Gui.toggle(player, player_data)
end
event.on_lua_shortcut(on_shortcut_pressed)
Expand All @@ -13,7 +13,7 @@ script.on_event("search-factory", on_shortcut_pressed)
script.on_event("open-search-prototype",
function(event)
local player = game.get_player(event.player_index)
local player_data = global.players[event.player_index]
local player_data = storage.players[event.player_index]
if event.selected_prototype then
local name = event.selected_prototype.name
local type
Expand All @@ -27,19 +27,19 @@ script.on_event("open-search-prototype",
end
if event.selected_prototype.derived_type == "resource" then
-- If we know it is a resource, then ensure we treat it as one first
local products = game.entity_prototypes[name].mineable_properties.products
local products = prototypes.entity[name].mineable_properties.products
if products then
name = products[1].name
type = products[1].type
end
elseif game.item_prototypes[name] then
elseif prototypes.item[name] then
type = "item"
elseif game.fluid_prototypes[name] then
elseif prototypes.fluid[name] then
type = "fluid"
elseif game.virtual_signal_prototypes[name] then
elseif prototypes.virtual_signal[name] then
type = "virtual"
elseif game.recipe_prototypes[name] then
local recipe = game.recipe_prototypes[name]
elseif prototypes.recipe[name] then
local recipe = prototypes.recipe[name]
local main_product = recipe.main_product
if main_product then
name = main_product.name
Expand All @@ -49,8 +49,8 @@ script.on_event("open-search-prototype",
name = product.name
type = product.type
end
elseif game.entity_prototypes[name] then
local entity = game.entity_prototypes[name]
elseif prototypes.entity[name] then
local entity = prototypes.entity[name]
local items_to_place_this = entity.items_to_place_this
if items_to_place_this and items_to_place_this[1] then
name = items_to_place_this[1].name
Expand All @@ -64,8 +64,8 @@ script.on_event("open-search-prototype",
type = products[1].type
end
end
elseif game.tile_prototypes[name] then
local tile = game.tile_prototypes[name]
elseif prototypes.tile[name] then
local tile = prototypes.tile[name]
local items_to_place_this = tile.items_to_place_this
if items_to_place_this and items_to_place_this[1] then
name = items_to_place_this[1].name
Expand All @@ -78,7 +78,7 @@ script.on_event("open-search-prototype",
return
end
Gui.open(player, player_data)
player_data = global.players[event.player_index]
player_data = storage.players[event.player_index]
local refs = player_data.refs
refs.item_select.elem_value = {type = type, name = name}
Gui.start_search(player, player_data)
Expand Down
Loading

0 comments on commit a0264a6

Please sign in to comment.