From 2e2cd19fbf529963d9fea6bac9c95fc0106105b8 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Mon, 7 Feb 2022 03:41:48 -0500 Subject: [PATCH 1/9] Fix dofile without MCM --- eid_bagofcrafting.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eid_bagofcrafting.lua b/eid_bagofcrafting.lua index 8cd60cda..c443533d 100644 --- a/eid_bagofcrafting.lua +++ b/eid_bagofcrafting.lua @@ -514,7 +514,7 @@ local moddedCrafting = false -- Only works if the new items are at Weight 1.0 in their item pools, but better than nothing local function GameStartCrafting() if EID.Config["BagOfCraftingModdedRecipes"] and not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) and EID.itemConfig:GetCollectible(EID.XMLMaxItemID+1) ~= nil then - dofile("eid_xmldata") + dofile(EID.modPath .. "eid_xmldata.lua") -- Items past max ID detected CraftingMaxItemID = EID.XMLMaxItemID -- XMLMaxItemID is never modified -- Add new item qualities @@ -542,7 +542,7 @@ local function GameStartCrafting() sortNeeded = true elseif moddedCrafting then -- we had modded items; they have since been disabled - dofile("eid_xmldata") + dofile(EID.modPath .. "eid_xmldata.lua") moddedCrafting = false sortNeeded = true end From 49d4f3785670566023a50ecb6018ba92c289e4f6 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Mon, 7 Feb 2022 03:42:23 -0500 Subject: [PATCH 2/9] HUD offset only needed if Options doesn't exist --- mod_config_menu.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mod_config_menu.lua b/mod_config_menu.lua index 93d98713..86a57359 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -76,15 +76,13 @@ end function EID:renderMCMDummyDescription() if MCMLoaded then - local hudOffset = ModConfigMenu.Config["General"].HudOffset - if hudOffset == nil and ScreenHelper then - hudOffset = ScreenHelper.GetOffset() + if not Options then + local hudOffset = ModConfigMenu.Config["General"].HudOffset + if hudOffset == nil and ScreenHelper then + hudOffset = ScreenHelper.GetOffset() + end + EID.Config["HUDOffset"] = hudOffset end - if REPENTANCE and Options then - hudOffset = (Options.HUDOffset * 10) - end - EID.Config["HUDOffset"] = hudOffset - EID:addTextPosModifier("HudOffset", Vector((hudOffset * 2) - 20, hudOffset - 10)) if MCM.IsVisible and EID.MCMCompat_isDisplayingEIDTab ~= "" then if EID.MCMCompat_isDisplayingEIDTab == "Mouse" and EID.Config["EnableMouseControls"] then clearRenderDummyDesc() From c6aba7efe4093d9d35d2cc86bc0d824d708464f5 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Mon, 7 Feb 2022 03:43:43 -0500 Subject: [PATCH 3/9] HUD offset only needed when Options doesn't exist --- mod_config_menu.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mod_config_menu.lua b/mod_config_menu.lua index 86a57359..aac631c1 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -82,6 +82,7 @@ function EID:renderMCMDummyDescription() hudOffset = ScreenHelper.GetOffset() end EID.Config["HUDOffset"] = hudOffset + EID:addTextPosModifier("HudOffset", Vector((hudOffset * 2) - 20, hudOffset - 10)) end if MCM.IsVisible and EID.MCMCompat_isDisplayingEIDTab ~= "" then if EID.MCMCompat_isDisplayingEIDTab == "Mouse" and EID.Config["EnableMouseControls"] then From 356195599be5898bebd000ba9187306b6dc7c9a1 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Mon, 7 Feb 2022 03:44:12 -0500 Subject: [PATCH 4/9] Fix text pos modifier issues --- main.lua | 76 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/main.lua b/main.lua index d5b43f5f..3641d259 100644 --- a/main.lua +++ b/main.lua @@ -366,6 +366,7 @@ if REPENTANCE then -- Watch for a Void absorbing active items -- (Note: Doesn't differentiate between different players if both players have Void...) + -- (Note: Doesn't care about shop / choice items yet either) function EID:CheckVoidAbsorbs(collectibleType) local pedestals = Isaac.FindByType(5, 100, -1, true, false) for _, pedestal in ipairs(pedestals) do @@ -509,8 +510,8 @@ function EID:printDescription(desc) end --Display ItemType / Charge local itemType = -1 - if tonumber(desc.ObjSubType) ~= nil and desc.ObjType == 5 and desc.ObjVariant == 100 then - itemType = EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Type or -1 + if desc.ObjSubType ~= nil and desc.ObjType == 5 and desc.ObjVariant == 100 then + itemType = EID.itemConfig:GetCollectible(desc.ObjSubType).Type or -1 end if EID.Config["ShowItemType"] and (itemType == 3 or itemType == 4) then local offsetY = 2 @@ -806,7 +807,7 @@ end function EID:setPlayer() local p = Isaac.GetPlayer(0) - if REPENTANCE and p.SubType == PlayerType.PLAYER_THEFORGOTTEN_B then + if REPENTANCE and p:GetPlayerType() == PlayerType.PLAYER_THEFORGOTTEN_B then EID.player = p:GetOtherTwin() else EID.player = p @@ -928,6 +929,48 @@ local function checkStartOfRunWarnings() end end +local function checkPosModifiers() + -- HUD offset adjustment + if Options then + EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10)) + else + EID:addTextPosModifier("HudOffset", Vector((EID.Config["HUDOffset"] * 2) - 20, EID.Config["HUDOffset"] - 10)) + end + -- Greed Mode small right adjustment + if game:IsGreedMode() then + EID:addTextPosModifier("Greed Mode Horizontal", Vector(8,0)) + else + EID:removeTextPosModifier("Greed Mode Horizontal") + end + if not REPENTANCE then + -- AB+ Schoolbag adjustment + if EID.player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG) then + EID:addTextPosModifier("Schoolbag", Vector(0,30)) + else + EID:removeTextPosModifier("Schoolbag") + end + else + -- Tainted Isaac and Tainted ??? unique HUD adjustment + if EID.player:GetPlayerType() == 21 or EID.player:GetPlayerType() == 25 then + EID:addTextPosModifier("Tainted HUD", Vector(0,30)) + else + EID:removeTextPosModifier("Tainted HUD") + end + -- Jacob and Esau card/pill adjustment + if EID.player:GetPlayerType() == 19 then + EID:addTextPosModifier("J&E HUD", Vector(0,15)) + else + EID:removeTextPosModifier("J&E HUD") + end + -- Magdalene Birthright third row of hearts adjustment + if EID.player:GetPlayerType() == 1 and EID.player:HasCollectible(619) then + EID:addTextPosModifier("18 Heart HUD", Vector(0,5)) + else + EID:removeTextPosModifier("18 Heart HUD") + end + end +end + --------------------------------------------------------------------------- ---------------------------On Render Function------------------------------ @@ -963,28 +1006,8 @@ local function onRender(t) end checkStartOfRunWarnings() + checkPosModifiers() EID:renderMCMDummyDescription() - - if EID.GameVersion == "ab+" then - if EID.player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG) then - EID:addTextPosModifier("Schoolbag", Vector(0,30)) - else - EID:removeTextPosModifier("Schoolbag") - end - else - -- Tainted Isaac and Tainted ??? - if EID.player.SubType == 21 or EID.player.SubType == 25 then - EID:addTextPosModifier("Tained HUD", Vector(0,30)) - else - EID:removeTextPosModifier("Tained HUD") - end - -- Magdalene Birthright - if EID.player.SubType == 1 and EID.player:HasCollectible(619) then - EID:addTextPosModifier("18 Heart HUD", Vector(0,5)) - else - EID:removeTextPosModifier("18 Heart HUD") - end - end if EID.isHidden then return @@ -1299,11 +1322,6 @@ if EID.MCMLoaded or REPENTANCE then EID:fixDefinedFont() EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt") - if REPENTANCE then - EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10)) - else - EID:addTextPosModifier("HudOffset", Vector((EID.Config["HUDOffset"] * 2) - 20, EID.Config["HUDOffset"] - 10)) - end end end end From 5a1304360e1e33630bc1bac045fc58bd13d49d63 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Mon, 7 Feb 2022 03:44:28 -0500 Subject: [PATCH 5/9] Fix Tainted Forgotten clicker issue --- eid_api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eid_api.lua b/eid_api.lua index 724ea6e9..4e239681 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -404,7 +404,7 @@ function EID:getAdjustedSubtype(Type, Variant, SubType) return 9999 end local pool = game:GetItemPool() - if REPENTANCE and EID.player.SubType == PlayerType.PLAYER_THESOUL_B then + if REPENTANCE and EID.player:GetPlayerType() == PlayerType.PLAYER_THESOUL_B then SubType = pool:GetPillEffect(SubType, EID.player:GetOtherTwin()) + 1 else SubType = pool:GetPillEffect(SubType, EID.player) + 1 end end From 3ad0dd9dbbd11cb46a0083cf7c67ad11f3b813b5 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Mon, 7 Feb 2022 04:34:43 -0500 Subject: [PATCH 6/9] Fix Tainted Forgotten co-op issue --- eid_api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eid_api.lua b/eid_api.lua index 4e239681..eedb5857 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -405,7 +405,7 @@ function EID:getAdjustedSubtype(Type, Variant, SubType) end local pool = game:GetItemPool() if REPENTANCE and EID.player:GetPlayerType() == PlayerType.PLAYER_THESOUL_B then - SubType = pool:GetPillEffect(SubType, EID.player:GetOtherTwin()) + 1 + SubType = pool:GetPillEffect(SubType, EID.player:GetOtherTwin() or EID.player) + 1 else SubType = pool:GetPillEffect(SubType, EID.player) + 1 end end return SubType From 66185e91082ecd7d9a755f24c333d7eb04e84ee3 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Mon, 7 Feb 2022 04:34:58 -0500 Subject: [PATCH 7/9] Fix Tainted Forgotten co-op issue --- main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.lua b/main.lua index 3641d259..6eaca9b0 100644 --- a/main.lua +++ b/main.lua @@ -808,7 +808,7 @@ end function EID:setPlayer() local p = Isaac.GetPlayer(0) if REPENTANCE and p:GetPlayerType() == PlayerType.PLAYER_THEFORGOTTEN_B then - EID.player = p:GetOtherTwin() + EID.player = p:GetOtherTwin() or p else EID.player = p end From 081f10f9c33b0062119085da5fc1aa74c7f9f9e1 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Tue, 8 Feb 2022 03:55:32 -0500 Subject: [PATCH 8/9] improve checkposmodifiers performance --- main.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.lua b/main.lua index 6eaca9b0..6b2d18df 100644 --- a/main.lua +++ b/main.lua @@ -929,13 +929,16 @@ local function checkStartOfRunWarnings() end end +-- Check our position modifiers based on HUD offset and character choice local function checkPosModifiers() - -- HUD offset adjustment + -- HUD offset adjustment, done every frame so it looks nice while changing the option if Options then EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10)) else EID:addTextPosModifier("HudOffset", Vector((EID.Config["HUDOffset"] * 2) - 20, EID.Config["HUDOffset"] - 10)) end + -- the other modifiers don't need to be ran as frequently + if EID.GameRenderCount % 30 ~= 0 then return end -- Greed Mode small right adjustment if game:IsGreedMode() then EID:addTextPosModifier("Greed Mode Horizontal", Vector(8,0)) From 6cdd64b8e786f012fe90f3364bd46d419adfbdd1 Mon Sep 17 00:00:00 2001 From: Buurazu Date: Tue, 8 Feb 2022 03:55:47 -0500 Subject: [PATCH 9/9] huge improvement to fitTextToWidth --- eid_api.lua | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index eedb5857..be17dfaf 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -742,6 +742,19 @@ function EID:filterColorMarkup(text, baseKColor) return textPartsTable end +-- A simple function to replace all markup {{ }} with placeholder strings, to use in fitTextToWidth +function EID:replaceAllMarkupWithSpaces(text) + for word in string.gmatch(text, "{{.-}}") do + local lookup = EID:getIcon(word) + if lookup[1] ~= "ERROR" then + text = string.gsub(text, word, EID:generatePlaceholderString(lookup[3]), 1) + else + text = string.gsub(text, word, "", 1) + end + end + return text +end + -- Fits a given string to a specific width -- returns the string as a table of lines function EID:fitTextToWidth(str, textboxWidth, breakUtf8Chars) @@ -815,14 +828,8 @@ function EID:fitTextToWidth(str, textboxWidth, breakUtf8Chars) -- we can break after str[cursor] local word = sub(str, word_begin_index, cursor) - - local colorFiltered = EID:filterColorMarkup(word, EID:getTextColor()) - local filteredWord = {} - for _, filtered in ipairs(colorFiltered) do - table.insert(filteredWord, filtered[1]) - end - local strFiltered, spriteTable = EID:filterIconMarkup(table.concat(filteredWord), 0, 0) - local wordLength = EID:getStrWidth(strFiltered) + local wordFiltered = EID:replaceAllMarkupWithSpaces(word) + local wordLength = EID:getStrWidth(wordFiltered) if curLength + wordLength <= textboxWidth or curLength < 17 then table.insert(text, word)