mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Merge branch 'main' into aperx
This commit is contained in:
@@ -110,8 +110,9 @@ end
|
||||
--- @param value unknown
|
||||
function GuiData._metatable.__newindex(self, key, value)
|
||||
assert(type(key) == "userdata", "Index type '" .. ExpUtil.get_class_name(key) .. "' given to GuiData. Must be of type userdata.")
|
||||
local object_name = key.object_name --- @diagnostic disable-line assign-type-mismatch
|
||||
local object_name = key.object_name
|
||||
if object_name == "LuaGuiElement" then
|
||||
--- @cast key LuaGuiElement
|
||||
local data = self.element_data
|
||||
local player_elements = data[key.player_index]
|
||||
if not player_elements then
|
||||
@@ -121,8 +122,10 @@ function GuiData._metatable.__newindex(self, key, value)
|
||||
player_elements[key.index] = value
|
||||
registration_numbers[reg_obj(key)] = key.player_index
|
||||
elseif object_name == "LuaPlayer" then
|
||||
--- @cast key LuaPlayer
|
||||
self.player_data[key.index] = value
|
||||
elseif object_name == "LuaForce" then
|
||||
--- @cast key LuaForce
|
||||
self.force_data[key.index] = value
|
||||
else
|
||||
error("Unsupported object class '" .. object_name .. "' given as index to GuiData.")
|
||||
|
||||
@@ -28,7 +28,7 @@ local GuiIter = {
|
||||
_scopes = registered_scopes,
|
||||
}
|
||||
|
||||
local function nop() return nil, nil end
|
||||
local function no_loop() return nil, nil end
|
||||
|
||||
--- Get the next valid element
|
||||
--- @param elements table<uint, LuaGuiElement>
|
||||
@@ -51,9 +51,9 @@ end
|
||||
--- @param online boolean?
|
||||
--- @return uint?, LuaPlayer?, table<uint, LuaGuiElement>?
|
||||
local function next_valid_player(scope_elements, players, prev_index, online)
|
||||
local index, player = nil, nil
|
||||
local index, player = prev_index, nil
|
||||
while true do
|
||||
index, player = next(players, prev_index)
|
||||
index, player = next(players, index)
|
||||
while player and not player.valid do
|
||||
scope_elements[player.index] = nil
|
||||
index, player = next(players, index)
|
||||
@@ -66,7 +66,7 @@ local function next_valid_player(scope_elements, players, prev_index, online)
|
||||
|
||||
if online == nil or player.connected == online then
|
||||
local player_elements = scope_elements[player.index]
|
||||
if player_elements and #player_elements > 0 then
|
||||
if player_elements and next(player_elements) then
|
||||
return index, player, player_elements
|
||||
end
|
||||
end
|
||||
@@ -78,13 +78,13 @@ end
|
||||
--- @param player LuaPlayer
|
||||
--- @return ExpGui_GuiIter.ReturnType
|
||||
function GuiIter.player_elements(scope, player)
|
||||
if not player.valid then return nop end
|
||||
if not player.valid then return no_loop end
|
||||
|
||||
local scope_elements = registered_scopes[scope]
|
||||
if not scope_elements then return nop end
|
||||
if not scope_elements then return no_loop end
|
||||
|
||||
local player_elements = scope_elements[player.index]
|
||||
if not player_elements then return nop end
|
||||
if not player_elements then return no_loop end
|
||||
|
||||
local element_index, element = nil, nil
|
||||
return function()
|
||||
@@ -101,7 +101,7 @@ end
|
||||
--- @return ExpGui_GuiIter.ReturnType
|
||||
function GuiIter.filtered_elements(scope, players, online)
|
||||
local scope_elements = registered_scopes[scope]
|
||||
if not scope_elements then return nop end
|
||||
if not scope_elements then return no_loop end
|
||||
|
||||
local index, player, player_elements = nil, nil, nil
|
||||
local element_index, element = nil, nil
|
||||
@@ -128,7 +128,7 @@ end
|
||||
--- @return ExpGui_GuiIter.ReturnType
|
||||
function GuiIter.all_elements(scope)
|
||||
local scope_elements = registered_scopes[scope]
|
||||
if not scope_elements then return nop end
|
||||
if not scope_elements then return no_loop end
|
||||
|
||||
local player_index, player_elements, player = nil, nil, nil
|
||||
local element_index, element = nil, nil
|
||||
@@ -193,7 +193,7 @@ function GuiIter.get_online_elements(scope, filter)
|
||||
return GuiIter.filtered_elements(scope, game.connected_players)
|
||||
elseif class_name == "LuaPlayer" then
|
||||
--- @cast filter LuaPlayer
|
||||
if not filter.connected then return nop end
|
||||
if not filter.connected then return no_loop end
|
||||
return GuiIter.player_elements(scope, filter)
|
||||
elseif class_name == "LuaForce" then
|
||||
--- @cast filter LuaForce
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@clusterio/lib": "^2.0.0-alpha.19"
|
||||
"@clusterio/lib": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@clusterio/lib": "^2.0.0-alpha.19",
|
||||
"@types/node": "^20.14.9",
|
||||
"typescript": "^5.5.3"
|
||||
"@clusterio/lib": "catalog:",
|
||||
"@types/node": "catalog:",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expcluster/lib_util": "workspace:*",
|
||||
"@sinclair/typebox": "^0.30.4"
|
||||
"@expcluster/lib_util": "workspace:^",
|
||||
"@sinclair/typebox": "catalog:"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
Reference in New Issue
Block a user