mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-09 00:08:04 -06:00
Add query limit per-player setting to limit results in Stations/Trains GUI tabs
This commit is contained in:
@@ -14,6 +14,7 @@ cybersyn-allow-cargo-in-depot=Allow cargo in depots
|
||||
cybersyn-invert-sign=Invert combinator output (deprecated)
|
||||
cybersyn-manager-enabled=Enable the Cybersyn GUI.
|
||||
cybersyn-manager-update-rate=Manager refresh tick interval
|
||||
cybersyn-manager-result-limit=Max entities displayed on GUI pages.
|
||||
|
||||
[mod-setting-description]
|
||||
cybersyn-enable-planner=Enable or disable the central planning algorithm. If disabled no new trains will be dispatched.
|
||||
@@ -29,7 +30,7 @@ cybersyn-warmup-time=How many seconds a cybernetic combinator will wait before c
|
||||
cybersyn-stuck-train-time=After this many seconds from a train's dispatch, an alert will be sent to let you know a train is probably stuck and has not completed its delivery. The player will likely have to debug their network to get the train unstuck.
|
||||
cybersyn-allow-cargo-in-depot=If checked, trains will be allowed to have cargo in depots; no alerts will be generated and the train will not be held. In addition, trains with orders to visit requester stations with "Inactivity condition" checked will wait for inactivity instead of waiting for empty cargo. Useful for creating train systems where depots handle excess cargo. For advanced users only.
|
||||
cybersyn-invert-sign=Flip the sign of the output of cybernetic combinators to be the same as it is in LTN or in earlier versions of Project Cybersyn.
|
||||
|
||||
cybersyn-manager-result-limit=Caps the number of matching enitities (e.g. stations, trains) to limit the amount of update time consumed when the list is refreshed.\n-1 means return all results.
|
||||
|
||||
[item-name]
|
||||
cybersyn-combinator=Cybernetic combinator
|
||||
|
||||
@@ -157,7 +157,8 @@ function manager_gui.tick(global)
|
||||
if manager_data then
|
||||
for i, v in pairs(manager_data.players) do
|
||||
if v.is_manager_open then
|
||||
manager.update(global, v)
|
||||
local query_limit = settings.get_player_settings(i)["cybersyn-manager-result-limit"].value
|
||||
manager.update(global, v, query_limit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -159,12 +159,12 @@ end
|
||||
|
||||
--- @param map_data MapData
|
||||
--- @param player_data PlayerData
|
||||
function manager.update(map_data, player_data)
|
||||
function manager.update(map_data, player_data, query_limit)
|
||||
if player_data.selected_tab ~= nil then
|
||||
manager.build(player_data)
|
||||
end
|
||||
if player_data.selected_tab == "stations_tab" then
|
||||
stations_tab.build(map_data, player_data)
|
||||
stations_tab.build(map_data, player_data, query_limit)
|
||||
elseif player_data.selected_tab == "inventory_tab" then
|
||||
inventory_tab.build(map_data, player_data)
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ end
|
||||
--- @param map_data MapData
|
||||
--- @param player_data PlayerData
|
||||
--- @return GuiElemDef
|
||||
function stations_tab.build(map_data, player_data)
|
||||
function stations_tab.build(map_data, player_data, query_limit)
|
||||
|
||||
local widths = constants.gui["en"]
|
||||
local refs = player_data.refs
|
||||
@@ -72,6 +72,8 @@ function stations_tab.build(map_data, player_data)
|
||||
|
||||
local stations_sorted = {}
|
||||
local to_sorted_manifest = {}
|
||||
|
||||
local i = 0
|
||||
for id, station in pairs(stations) do
|
||||
local entity = station.entity_stop
|
||||
if not entity.valid then
|
||||
@@ -139,6 +141,10 @@ function stations_tab.build(map_data, player_data)
|
||||
end
|
||||
|
||||
stations_sorted[#stations_sorted + 1] = id
|
||||
i = i + 1
|
||||
if query_limit ~= -1 and i >= query_limit then
|
||||
break
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ local trains_tab = {}
|
||||
--- @param map_data MapData
|
||||
--- @param player_data PlayerData
|
||||
--- @return GuiElemDef
|
||||
function trains_tab.build(map_data, player_data)
|
||||
function trains_tab.build(map_data, player_data, query_limit)
|
||||
local widths = constants.gui["en"]
|
||||
|
||||
local search_item = player_data.search_item
|
||||
@@ -22,6 +22,8 @@ function trains_tab.build(map_data, player_data)
|
||||
|
||||
|
||||
local trains_sorted = {}
|
||||
|
||||
local i = 0
|
||||
for id, train in pairs(map_data.trains) do
|
||||
if search_network_name then
|
||||
if search_network_name ~= train.network_name then
|
||||
@@ -70,6 +72,10 @@ function trains_tab.build(map_data, player_data)
|
||||
end
|
||||
|
||||
trains_sorted[#trains_sorted + 1] = id
|
||||
i = i + 1
|
||||
if query_limit ~= -1 and i >= query_limit then
|
||||
break
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
||||
|
||||
@@ -118,6 +118,15 @@ data:extend({
|
||||
setting_type = "startup",
|
||||
default_value = true,
|
||||
},
|
||||
{
|
||||
type = "int-setting",
|
||||
name = "cybersyn-manager-result-limit",
|
||||
order = "aa",
|
||||
setting_type = "runtime-per-user",
|
||||
default_value = -1,
|
||||
minimum_value = -1,
|
||||
maximum_value = 2147483647,
|
||||
}
|
||||
--{
|
||||
-- type = "bool-setting",
|
||||
-- name = "cybersyn-disable-top-left-button",
|
||||
|
||||
Reference in New Issue
Block a user