Rearranged variable initializations

This commit is contained in:
Wofsauge committed 2020-11-27 22:56:39 +01:00
1 parent 4cb51d0672
commit d3decba7be
4 files changed
+40 -34

No files matched your search

-3
View File
@@ -18,9 +18,6 @@ if not __eidEntityDescriptions then
__eidEntityDescriptions = {} __eidEntityDescriptions = {}
end end
EID.PositionModifiers = {}
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-------------------------Handle Custom Enum ----------------------------- -------------------------Handle Custom Enum -----------------------------
+1 -1
View File
@@ -1,4 +1,4 @@
EIDConfig = { EID.DefaultConfig = {
-------GENERAL--------- -------GENERAL---------
-- Change language of the mod. -- Change language of the mod.
+34 -25
View File
@@ -1,15 +1,26 @@
EID = RegisterMod("External Item Descriptions", 1) EID = RegisterMod("External Item Descriptions", 1)
EID.itemConfig = Isaac.GetItemConfig() -- important variables
EID.GameVersion = "ab+"
EID.Languages = {"en_us", "en_us_detailed", "fr", "pt", "ru", "spa", "bul", "pl", "turkish"}
EID.descriptions = {} -- Table that holds all translation strings EID.descriptions = {} -- Table that holds all translation strings
require("eid_config")
EID.Config = EID.DefaultConfig
EID.Config.Version = "3.0"
EID.isHidden = EID.Config["Hidden"]
-- general variables
EID.PositionModifiers = {}
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
EID.isDisplayingText = false EID.isDisplayingText = false
EID.isDisplayingPermanent = false EID.isDisplayingPermanent = false
EID.permanentDisplayTextObj = nil EID.permanentDisplayTextObj = nil
EID.lastDescriptionEntity = nil EID.lastDescriptionEntity = nil
local lineHeight = 11 EID.lineHeight = 11
local hideDescToggle = false
EID.sacrificeCounter = 1 EID.sacrificeCounter = 1
EID.itemConfig = Isaac.GetItemConfig()
-- Sprite inits
EID.IconSprite = Sprite() EID.IconSprite = Sprite()
EID.IconSprite:Load("gfx/icons.anm2", true) EID.IconSprite:Load("gfx/icons.anm2", true)
@@ -26,26 +37,20 @@ local ArrowSprite = Sprite()
ArrowSprite:Load("gfx/icons.anm2", true) ArrowSprite:Load("gfx/icons.anm2", true)
ArrowSprite:Play("Arrow", false) ArrowSprite:Play("Arrow", false)
require("eid_config") ------- Load all modules and other stuff ------
EID.Config = EID.DefaultConfig
EID.Config.Version = "3.0"
require("mod_config_menu") require("mod_config_menu")
require("descriptions.ab+.transformations") --transformation infos
require("descriptions."..EID.GameVersion..".transformations")
--languages --languages
require("descriptions.ab+.en_us") for _,lang in ipairs(EID.Languages) do
require("descriptions.ab+.turkish") -- WIP require("descriptions."..EID.GameVersion.."."..lang)
require("descriptions.ab+.en_us_detailed") end
require("descriptions.ab+.bul") -- WIP
require("descriptions.ab+.fr")
require("descriptions.ab+.pl") -- WIP
require("descriptions.ab+.pt")
require("descriptions.ab+.ru")
require("descriptions.ab+.spa")
require("eid_data") require("eid_data")
require("eid_api") require("eid_api")
-------------- Load Font -------------
EID.LastRenderCallColor = EID:getTextColor() EID.LastRenderCallColor = EID:getTextColor()
local nullVector = Vector(0,0) local nullVector = Vector(0,0)
@@ -130,7 +135,7 @@ function EID:printDescription(desc)
offsetX = offsetX + 8 offsetX = offsetX + 8
end end
if not EID.Config["ShowItemName"] then if not EID.Config["ShowItemName"] then
renderPos.Y = renderPos.Y + lineHeight * EID.Config["Scale"] renderPos.Y = renderPos.Y + EID.lineHeight * EID.Config["Scale"]
end end
end end
--Display Itemname --Display Itemname
@@ -142,7 +147,7 @@ function EID:printDescription(desc)
EID:getNameColor() EID:getNameColor()
) )
renderPos.Y = renderPos.Y + lineHeight * EID.Config["Scale"] renderPos.Y = renderPos.Y + EID.lineHeight * EID.Config["Scale"]
end end
--Display Transformation --Display Transformation
@@ -154,9 +159,9 @@ function EID:printDescription(desc)
local iconHeight = transformSprite[4] or -1 local iconHeight = transformSprite[4] or -1
local iconOffsetX = transformSprite[5] or -1 local iconOffsetX = transformSprite[5] or -1
local iconOffsetY = transformSprite[6] or -1 local iconOffsetY = transformSprite[6] or -1
local transformLineHeight = lineHeight local transformLineHeight = EID.lineHeight
if EID.Config["TransformationIcons"] then if EID.Config["TransformationIcons"] then
transformLineHeight = math.max(lineHeight, transformSprite[4]) transformLineHeight = math.max(EID.lineHeight, transformSprite[4])
local iconSprite = transformSprite[7] or EID.InlineIconSprite local iconSprite = transformSprite[7] or EID.InlineIconSprite
iconSprite:Play(transformSprite[1]) iconSprite:Play(transformSprite[1])
EID:renderIcon( EID:renderIcon(
@@ -201,7 +206,7 @@ function EID:printBulletPoints(description, renderPos)
textColor = EID:renderString(bpIcon, renderPos, textScale , textColor) textColor = EID:renderString(bpIcon, renderPos, textScale , textColor)
end end
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Config["Scale"], 0), textScale, textColor) textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Config["Scale"], 0), textScale, textColor)
renderPos.Y = renderPos.Y + lineHeight * EID.Config["Scale"] renderPos.Y = renderPos.Y + EID.lineHeight * EID.Config["Scale"]
end end
end end
end end
@@ -254,14 +259,14 @@ end
local function onRender(t) local function onRender(t)
EID.isDisplayingText = false EID.isDisplayingText = false
if Input.IsButtonTriggered(EID.Config["HideKey"], 0) then if Input.IsButtonTriggered(EID.Config["HideKey"], 0) then
hideDescToggle = not hideDescToggle EID.isHidden = not EID.isHidden
end end
if hideDescToggle then if EID.isHidden then
return return
end end
local player = Isaac.GetPlayer(0) local player = Isaac.GetPlayer(0)
EID:renderMCMDummyDescription() EID:renderMCMDummyDescription()
if player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG) then if player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG) then
@@ -370,6 +375,8 @@ end
EID:AddCallback(ModCallbacks.MC_POST_RENDER, onRender) EID:AddCallback(ModCallbacks.MC_POST_RENDER, onRender)
-- only save and load configs when using MCM. Otherwise Config file changes arent calid
if EID.MCMLoaded then
local json = require("json") local json = require("json")
-------------------------------- --------------------------------
--------Handle Savadata--------- --------Handle Savadata---------
@@ -385,6 +392,7 @@ EID:AddCallback(ModCallbacks.MC_POST_RENDER, onRender)
EID.Config[key] = savedEIDConfig[key] EID.Config[key] = savedEIDConfig[key]
end end
end end
EID.isHidden = EID.Config["Hidden"]
end end
end end
end end
@@ -395,5 +403,6 @@ EID:AddCallback(ModCallbacks.MC_POST_RENDER, onRender)
EID.SaveData(EID, json.encode(EID.Config)) EID.SaveData(EID, json.encode(EID.Config))
end end
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame) EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame)
end
require("eid_debugging") require("eid_debugging")
+5 -5
View File
@@ -4,6 +4,7 @@ local MCMLoaded, MCM = pcall(require, "scripts.modconfig")
EID.MCMCompat_isDisplayingEIDTab = false EID.MCMCompat_isDisplayingEIDTab = false
local MCMCompat_isDisplayingDummyMCMObj = false local MCMCompat_isDisplayingDummyMCMObj = false
local MCMCompat_oldPermanentObj = false local MCMCompat_oldPermanentObj = false
EID.MCMLoaded = MCMLoaded
function EID:renderMCMDummyDescription() function EID:renderMCMDummyDescription()
if MCMLoaded then if MCMLoaded then
@@ -41,22 +42,21 @@ if MCMLoaded then
-- Language -- Language
local displayLanguage = {"English", "English (detailed)", "French", "Portuguese", "Russian", "Spanish", "Bulgarian (WIP)", "Polish (WIP)", "Turkish (WIP)"} local displayLanguage = {"English", "English (detailed)", "French", "Portuguese", "Russian", "Spanish", "Bulgarian (WIP)", "Polish (WIP)", "Turkish (WIP)"}
local langLookup = {"en_us", "en_us_detailed", "fr", "pt", "ru", "spa", "bul", "pl", "turkish"}
ModConfigMenu.AddSetting( ModConfigMenu.AddSetting(
"EID", "EID",
"General", "General",
{ {
Type = ModConfigMenuOptionType.NUMBER, Type = ModConfigMenuOptionType.NUMBER,
CurrentSetting = function() CurrentSetting = function()
return AnIndexOf(langLookup, EID.Config["Language"]) return AnIndexOf(EID.Languages, EID.Config["Language"])
end, end,
Minimum = 1, Minimum = 1,
Maximum = #langLookup, Maximum = #(EID.Languages),
Display = function() Display = function()
return "Language: " .. displayLanguage[AnIndexOf(langLookup, EID.Config["Language"])] return "Language: " .. displayLanguage[AnIndexOf(EID.Languages, EID.Config["Language"])]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.Config["Language"] = langLookup[currentNum] EID.Config["Language"] = EID.Languages[currentNum]
end end
} }
) )