REPENTOGON phase 0 (e2c5aec, GPL-2): ISAAC_REPENTOGON option (on), src/repentogon/ with the hidden REPENTOGON global switch, callback ids 1000-1499 with REPENTOGON's enable state and dispatch (priorities, optional and two-parameter filters, isolated errors), its scripts loaded from assets/repentogon/scripts, its options store and a vanilla-parity switch (on) in the overlay, scripts/repentogon_coverage.py and analysis/repentogon_coverage.tsv (2,834 rows)
This commit is contained in:
1 parent
78cb0775b0
commit
2cc082f6ee
31 files changed
+12955
-149
No files matched your search
@@ -0,0 +1,98 @@
|
||||
---@alias REPENTOGON.ModId string
|
||||
---@class REPENTOGON.ModData
|
||||
|
||||
--#region Data
|
||||
|
||||
---@type table<ModReference, REPENTOGON.ModId>
|
||||
local s_modIds = {}
|
||||
|
||||
---@type table<REPENTOGON.ModId, ModReference[]>
|
||||
local s_modReferences = {}
|
||||
|
||||
local s_modsLoaded = false
|
||||
|
||||
--#endregion
|
||||
|
||||
local table_insert = table.insert
|
||||
local table_remove = table.remove
|
||||
local GetModId = _CBindings.GetModId
|
||||
|
||||
---@param modReference ModReference
|
||||
local function _RegisterMod(modReference)
|
||||
local id = GetModId(modReference)
|
||||
if not id then
|
||||
return
|
||||
end
|
||||
|
||||
assert(s_modIds[modReference] == nil, "The same mod has been registered multiple times")
|
||||
s_modIds[modReference] = id
|
||||
local modReferences = s_modReferences[id]
|
||||
if not modReferences then
|
||||
modReferences = {}
|
||||
s_modReferences[id] = modReferences
|
||||
end
|
||||
|
||||
table_insert(modReferences, modReference)
|
||||
end
|
||||
|
||||
---@param modReference ModReference
|
||||
local function _UnloadMod(modReference)
|
||||
local id = s_modIds[modReference]
|
||||
if not id then
|
||||
return
|
||||
end
|
||||
|
||||
s_modIds[modReference] = nil
|
||||
|
||||
local modReferences = s_modReferences[id]
|
||||
for i = 1, #modReferences, 1 do
|
||||
if modReferences[i] == modReference then
|
||||
table_remove(modReferences, i)
|
||||
break -- there should never be multiple of the same mod references in the list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function _OnModsLoaded()
|
||||
s_modsLoaded = true
|
||||
end
|
||||
|
||||
---@param modReference ModReference
|
||||
---@return REPENTOGON.ModId?
|
||||
local function GetModIdByReference(modReference)
|
||||
return s_modIds[modReference]
|
||||
end
|
||||
|
||||
---@param modId REPENTOGON.ModId
|
||||
---@return ModReference?
|
||||
local function GetModReferenceById(modId)
|
||||
local modReferences = s_modReferences[modId]
|
||||
if modReferences then
|
||||
return modReferences[1]
|
||||
end
|
||||
end
|
||||
|
||||
---@return fun(table: table<REPENTOGON.ModId, ModReference[]>, index?: REPENTOGON.ModId): REPENTOGON.ModId, ModReference[]
|
||||
---@return table
|
||||
local function GetModIterator()
|
||||
return pairs(s_modReferences)
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
local function ModsLoaded()
|
||||
return s_modsLoaded
|
||||
end
|
||||
|
||||
---@class REPENTOGON.Scripts.ModManager
|
||||
local Module = {}
|
||||
Module.detail = {}
|
||||
|
||||
Module.detail.RegisterMod = _RegisterMod
|
||||
Module.detail.UnloadMod = _UnloadMod
|
||||
Module.detail.OnModsLoaded = _OnModsLoaded
|
||||
Module.GetModIdByReference = GetModIdByReference
|
||||
Module.GetModReferenceById = GetModReferenceById
|
||||
Module.ModsLoaded = ModsLoaded
|
||||
Module.GetModIterator = GetModIterator
|
||||
|
||||
return Module
|
||||
Reference in new issue
Block a user