diff --git a/descriptions/ab+/en_us.lua b/descriptions/ab+/en_us.lua index f88cb65d..8d06988f 100644 --- a/descriptions/ab+/en_us.lua +++ b/descriptions/ab+/en_us.lua @@ -66,7 +66,7 @@ EID.descriptions["en_us"].collectibles={ {"51", "Pentagram", "↑ +1 Damage up#↑ +10% Devil/Angel Room chance"}, {"52", "Dr. Fetus", "Bomb tears#Each bomb deals 5x your damage + 30#↓ Tear Delay x 2.5"}, {"53", "Magneto", "Magnetic attraction for pickups"}, - {"54", "Treasure Map", "Reveals the floor-layout"}, + {"54", "Treasure Map", "Reveals the floor layout#Does not show room icons"}, {"55", "Mom's Eye", "Chance to shoot a tear backwards#Chance is 100% at 2 Luck"}, {"56", "Lemon Mishap", "Drop a pool of lemonade#Deals 66 contact damage per second"}, {"57", "Distant Admiration", "Mid-range fly orbital#Deals 75 contact damage per second"}, @@ -385,7 +385,7 @@ EID.descriptions["en_us"].collectibles={ {"370", "Mr. Dolly", "↑ +0.7 Tears up#↑ +5.25 Range up#↑ +0.5 Tear Height#Spawns 3 random hearts when picked up"}, {"371", "Curse of the Tower", "Spawn 6 troll bombs every time you get hit#These are affected by bomb items"}, {"372", "Charged Baby", "Random chance to drop a battery or freeze all enemies in the room#Chance to add one charge to your active item"}, - {"373", "Dead Eye", "↑ +12.5% damage up for every tear that successfully hits an enemy(max. +100%)"}, + {"373", "Dead Eye", "↑ +25% Damage up for every tear that successfully hits an enemy (max +100%)#Chance to lose the multiplier when you miss"}, {"374", "Holy Light", "Random chance to fire a Holy tear, which will spawn a beam of light on hit#The beam deals 4x your damage"}, {"375", "Host Hat", "Grants explosion immunity and immunity from Mom's and Satan's foot stomps#20% chance to block tears"}, {"376", "Restock", "Spawns 3 random Pickups#Shops instantly restock their items when you buy them"}, @@ -518,9 +518,9 @@ EID.descriptions["en_us"].collectibles={ {"503", "Little Horn", "Chance to fire tears that instantly kill enemies#Running into enemies will deal 3.5 damage to them"}, {"504", "Brown Nugget", "Spawns a fly turret that shoots at enemies#Each shot deals 2 damage"}, {"505", "Poke Go", "Chance to spawn a charmed enemy when entering a hostile room"}, - {"506", "Backstabber", "Tears can cause bleeding, which deals 10% damage of the enemies total health every 5 seconds"}, - {"507", "Sharp Straw", "Deals your damage + 10% damage equal to the maximum health of the enemy#Affects all enemies in the room#Chance to drop half hearts when it deals damage"}, - {"508", "Mom's Razor", "Orbital that causes bleeding, which deals 10% damage of the enemy's total health every 5 seconds#Deals 300% your damage on contact per second"}, + {"506", "Backstabber", "If tears hit an enemy in the back, they do double damage and cause bleeding, which deals 10% damage of the enemy's max health every 5 seconds"}, + {"507", "Sharp Straw", "Deals your damage + 10% of the enemy's max health#Affects all enemies in the room#Chance to drop half hearts when it deals damage"}, + {"508", "Mom's Razor", "Orbital that causes bleeding, which deals 10% damage of the enemy's max health every 5 seconds#Deals 300% your damage on contact per second#Does not block shots"}, {"509", "Bloodshot Eye", "Orbital that shoots a tear every 2 seconds in a random direction#Deals 3.5 damage per tear#Deals 30 contact damage per second"}, {"510", "Delirious", "Spawns a friendly white delirium version of a boss for the current room"}, {"511", "Angry Fly", "Orbits around a random enemy until that enemy dies#Deals 30 contact damage per second to other enemies"}, @@ -537,7 +537,7 @@ EID.descriptions["en_us"].collectibles={ {"522", "Telekinesis", "Enemy projectiles close to you are held in place for 3 seconds#They get thrown away from you afterwards#Recharges after 3 seconds"}, {"523", "Moving Box", "When used, stores all pickups from the current room#Using it again will put them back on the floor again#This allows you to move things between rooms"}, {"524", "Technology Zero", "Tears will be connected with beams of electricity#Electricity damage equals your damage"}, - {"525", "Leprosy", "Taking damage will spawn a projectile blocking orbital#Max. 3 Orbitals at the same time#Orbitals are destroyed, if they take too much damage"}, + {"525", "Leprosy", "Taking damage will spawn a projectile blocking orbital#Max 3 orbitals at the same time#Orbitals are destroyed if they take too much damage"}, {"526", "7 Seals", "Spawns small horsemen familiars that spawn their respective locusts#Horsemen changes every 10 seconds"}, {"527", "Mr. ME!", "!!! Familiar that can do tasks for you:#Opening doors & chests, Bring items, Steal from the shop / Devil, fight enemies, explode, and activate pressure plates"}, {"528", "Angelic Prism", "Orbital prism#Tears hitting it will split into 4"}, @@ -628,7 +628,7 @@ EID.descriptions["en_us"].trinkets={ {"57", "???'s Soul", "Familiar that bounces around the room#Shoots in the same direction as the player#Deals 3.5 damage per tear"}, {"58", "Samson's Lock", "↑ 1/15 Chance for +0.5 Damage up when killing an enemy#Effect lasts for current room"}, {"59", "Cain's Eye", "25% chance to reveal map icons at start of new floor"}, - {"60", "Eve's Bird Foot", "Chance to spawn a dead bird when killing an enemy"}, + {"60", "Eve's Bird Foot", "Chance to spawn a {{Collectible117}}Dead Bird when killing an enemy"}, {"61", "The Left Hand", "Turns all chests into red chests"}, {"62", "Shiny Rock", "Crawlspace rocks and tinted rocks blink every 10 seconds"}, {"63", "Safety Scissors", "Turns troll bombs into bomb pickups"}, diff --git a/descriptions/rep/en_us.lua b/descriptions/rep/en_us.lua index 3731406d..e9402c41 100644 --- a/descriptions/rep/en_us.lua +++ b/descriptions/rep/en_us.lua @@ -186,6 +186,7 @@ local repCollectibles={ [503] = {"503", "Little Horn", "Chance to fire tears that summon a Big Horn hand#The hand kills enemies instantly and deals damage to bosses#Running into enemies will deal 3.5 damage to them"}, -- Little Horn [504] = {"504", "Brown Nugget", "Spawns a fly turret that shoots at enemies#Each shot deals 3.5 damage"}, -- Brown Nugget [509] = {"509", "Bloodshot Eye", "Orbital that shoots a tear every 1/3rd second when enemy is nearby#Deals 3.5 damage per tear#Deals 30 contact damage per second"}, -- Bloodshot Eye + [517] = {"517", "Fast Bombs", "+7 Bombs#Allows you to rapidly place bombs on the ground#Bombs don't knockback each other"}, -- Fast Bombs [523] = {"523", "Moving Box", "When used, stores up to 10 pickups from the current room#Using it again will put them back on the floor again#This allows you to move things between rooms"}, -- Moving Box [524] = {"524", "Technology Zero", "Tears will be connected with beams of electricity#Electricity damage equals 1/3 of your damage"}, -- Technology Zero [531] = {"531", "Haemolacria", "Tears fly in an arc#Tears burst into smaller tears on impact#↓ Tears down#↑ +50% Damage up#↑ +1 additional Damage up"}, -- Haemolacria @@ -578,7 +579,7 @@ EID.descriptions["en_us"].tarotClothBuffs = { [7] = {"7", "", "Spawns 3 Red Hearts"}, -- VI - The Lovers [8] = {"8", "", "Doubled duration"}, -- VII - The Chariot [9] = {"9", "", "Doubled pickup spawns"}, -- VIII - Justice - [10] = {"10", "", "Prevents Greed from spawning in the shop#Turns shop into a normal shop if greed was already fought in it"}, -- IX - The Hermit + [10] = {"10", "", "Prevents Greed from spawning in the shop#Turns shop into a normal shop if Greed was already fought in it"}, -- IX - The Hermit [11] = {"11", "", "Spawns 2 Slot Machines"}, -- X - Wheel of Fortune [12] = {"12", "", "Doubled stat increase, excluding dmg multiplier"}, -- XI - Strength [14] = {"14", "", "Deals 80 damage"}, -- XIII - Death @@ -904,6 +905,7 @@ EID.descriptions["en_us"].CraftingBestQuality = "Best Quality:" EID.descriptions["en_us"].CraftingHideKey = "Hide:" EID.descriptions["en_us"].CraftingPreviewKey = "Preview:" +EID.descriptions["en_us"].CraftingPreviewBackup = "!!! If this item's locked, it will turn into" EID.descriptions["en_us"].CraftingResults = "(Scroll: hold {{CONFIG_BoC_Toggle}} + {{ButtonY}} {{ButtonA}},#Lock: {{ButtonX}}, Refresh: {{ButtonB}})" diff --git a/eid_api.lua b/eid_api.lua index 555ec9a6..d52e7ba3 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -777,14 +777,27 @@ function EID:GetMaxCollectibleID() step = step // 2 end end - + return id end local maxCollectibleID = nil +function EID:DetectModdedItems() + if maxCollectibleID == nil then + maxCollectibleID = EID:GetMaxCollectibleID() + end + if maxCollectibleID > EID.XMLMaxItemID then + return true + end + if EID.itemConfig:GetCollectible(EID.XMLMaxItemID) == nil then + return true + end + return false +end + function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem) local itemPool = Game():GetItemPool() - if (not maxCollectibleID) then maxCollectibleID = EID:GetMaxCollectibleID() end + if maxCollectibleID == nil then maxCollectibleID = EID:GetMaxCollectibleID() end for i= 1, maxCollectibleID do if ItemConfig.Config.IsValidCollectible(i) and i ~= collectibleID then itemPool:AddRoomBlacklist(i) @@ -861,14 +874,14 @@ function EID:tableToCraftingIconsMerged(craftTable, indicateCompleteContent) local iconString = "" for nr,count in ipairs(filteredList) do if (count > 0) then - local completedColoring = indicateCompleteContent and EID:bagContaingsItem(nr, count) and "{{ColorBagComplete}}" or "" + local completedColoring = indicateCompleteContent and EID:bagContainsItem(nr, count) and "{{ColorBagComplete}}" or "" iconString = iconString..completedColoring..count.."{{Crafting"..nr.."}}{{CR}}" end end return iconString end -function EID:bagContaingsItem(itemID, itemCount) +function EID:bagContainsItem(itemID, itemCount) local foundCount = 0 for _, bagItem in ipairs(EID.BagItems) do if bagItem == itemID then diff --git a/eid_bagofcrafting.lua b/eid_bagofcrafting.lua index bef639b9..fbc70d87 100644 --- a/eid_bagofcrafting.lua +++ b/eid_bagofcrafting.lua @@ -528,10 +528,10 @@ local function trackBagHolding() if isCardHold and string.match(animationName, "PickupWalk") and #EID.BagItems>=8 then holdCounter = holdCounter + 1 if holdCounter < 30 then - EID.icount = EID.player:GetCollectibleCount() + icount = EID.player:GetCollectibleCount() end else - if isCardHold and holdCounter >= 30 and (string.match(animationName, "Walk") and not string.match(animationName, "Pickup") or (EID.player:GetCollectibleCount() ~= EID.icount)) then + if isCardHold and holdCounter >= 30 and (string.match(animationName, "Walk") and not string.match(animationName, "Pickup") or (EID.player:GetCollectibleCount() ~= icount)) then EID.BagItems = {} else holdCounter = 0 @@ -574,37 +574,23 @@ local randResultCache = {} local calcResultCache = {} local numResults = 0 -EID.bagOfCraftingOffset = 0 +--these aren't local so that they can be saved and reloaded, or cleared in the Mod Config Menu EID.bagOfCraftingCurPickupCount = -1 EID.bagOfCraftingRoomQueries = {} EID.bagOfCraftingFloorQuery = {} EID.BagItems = {} -EID.icount = 0 -EID.lockedResults = nil -EID.refreshNextTick = false -EID.refreshPosition = 0 -EID.bagOfCraftingRefreshes = 0 -EID.downHeld = 0 -EID.upHeld = 0 +local icount = 0 +local bagOfCraftingOffset = 0 +local lockedResults = nil +local refreshNextTick = false +local refreshPosition = 0 +local bagOfCraftingRefreshes = 0 +local downHeld = 0 +local upHeld = 0 -EID.craftingIsHidden = false -EID.showCraftingResult = false - -local maxItemID = nil - -function EID:DetectModdedItems() - if maxItemID == nil then - maxItemID = EID:GetMaxCollectibleID() - end - if maxItemID > EID.XMLMaxItemID then - return true - end - if EID.itemConfig:GetCollectible(EID.XMLMaxItemID) == nil then - return true - end - return false -end +local craftingIsHidden = false +local showCraftingResult = false local function calcFloorItems() EID.bagOfCraftingFloorQuery = {} @@ -642,8 +628,7 @@ local function combinations(arr, length, startPos, tempResult, randResults, newR tempResult[8-length+1] = arr[i] combinations(arr,length-1, i+1, tempResult, randResults, newResults) end -end - +end --code from InputHelper in MCM local HotkeyToString = {} for key,num in pairs(Keyboard) do @@ -654,6 +639,56 @@ for key,num in pairs(Keyboard) do HotkeyToString[num] = keyString end +local function getHotkeyString() + local hotkeyString = "" + local hideDesc = EID:getDescriptionEntry("CraftingHideKey") + local previewDesc = EID:getDescriptionEntry("CraftingPreviewKey") + --we have a binding for a keyboard hide key + if HotkeyToString[EID.Config["CraftingHideKey"]] then + hotkeyString = hideDesc .. " " .. HotkeyToString[EID.Config["CraftingHideKey"]] + end + --we have a binding for a keyboard preview toggle key, and a full bag, and aren't on Preview Only mode + if #EID.BagItems >= 8 and EID.Config["BagOfCraftingDisplayMode"] ~= "Preview Only" and HotkeyToString[EID.Config["CraftingResultKey"]] then + if hotkeyString ~= "" then hotkeyString = hotkeyString .. ", " end + hotkeyString = hotkeyString .. previewDesc .. " " .. HotkeyToString[EID.Config["CraftingResultKey"]] + end + if hotkeyString ~= "" then + hotkeyString = "!!! " .. hotkeyString .. "#" + end + return hotkeyString +end + +local function getFloorItemsString(showPreviews, roomItems) + local floorString = "" + if #EID.BagItems >0 then + if showPreviews and #EID.BagItems >= 8 then + local recipe = EID:calculateBagOfCrafting(EID.BagItems) + floorString = floorString .. "{{Collectible"..recipe.."}} " + end + local bagDesc = EID:getDescriptionEntry("CraftingBagContent") + floorString = floorString .. bagDesc.. EID:tableToCraftingIconsMerged(EID.BagItems).."#" + --debug the bag order + --EID:appendToDescription(customDescObj, EID:tableToCraftingIconsFull(EID.BagItems, false).."#") + end + if #roomItems >0 then + if showPreviews and #roomItems == 8 then + local recipe = EID:calculateBagOfCrafting(roomItems) + floorString = floorString .. "{{Collectible"..recipe.."}} " + end + local roomDesc = EID:getDescriptionEntry("CraftingRoomContent") + floorString = floorString .. roomDesc..EID:tableToCraftingIconsMerged(roomItems).."#" + end + if #EID.bagOfCraftingFloorQuery >0 and #roomItems ~= #EID.bagOfCraftingFloorQuery then + if showPreviews and #EID.bagOfCraftingFloorQuery == 8 then + local recipe = EID:calculateBagOfCrafting(EID.bagOfCraftingFloorQuery) + floorString = floorString .. "{{Collectible"..recipe.."}} " + end + local floorDesc = EID:getDescriptionEntry("CraftingFloorContent") + floorString = floorString .. floorDesc..EID:tableToCraftingIconsMerged(EID.bagOfCraftingFloorQuery).."#" + end + return floorString +end + function EID:handleBagOfCraftingRendering() trackBagHolding() trackBagActivated() @@ -662,18 +697,22 @@ function EID:handleBagOfCraftingRendering() local tableToCraftingIconsFunc = EID.tableToCraftingIconsMerged if EID.Config["BagOfCraftingDisplayIcons"] then tableToCraftingIconsFunc = EID.tableToCraftingIconsFull end + local customDescObj = EID:getDescriptionObj(5, 100, 710) + customDescObj.Description = "" + --prevent our hotkeys from triggering as they're set if not ModConfigMenu or not ModConfigMenu.IsVisible then if Input.IsButtonTriggered(EID.Config["CraftingHideKey"], 0) or Input.IsButtonTriggered(EID.Config["CraftingHideButton"], EID.player.ControllerIndex) then - EID.craftingIsHidden = not EID.craftingIsHidden + craftingIsHidden = not craftingIsHidden end if Input.IsButtonTriggered(EID.Config["CraftingResultKey"], 0) or Input.IsButtonTriggered(EID.Config["CraftingResultButton"], EID.player.ControllerIndex) then - EID.showCraftingResult = not EID.showCraftingResult + showCraftingResult = not showCraftingResult end end - if EID.isHidden or EID.craftingIsHidden then + --determine if we should display anything at all, display item preview if applicable, and figure out our room/floor's pickup contents + if EID.isHidden or craftingIsHidden then return elseif EID.Config["BagOfCraftingHideInBattle"] then if Isaac.CountBosses() > 0 or Isaac.CountEnemies() > 0 then @@ -687,22 +726,10 @@ function EID:handleBagOfCraftingRendering() if EID.Config["DisplayBagOfCrafting"] == "hold" and not string.find(EID.player:GetSprite():GetAnimation(), "PickupWalk") then return false end - if Game():GetRoom():GetFrameCount ()<2 then + if Game():GetRoom():GetFrameCount() < 2 then return false end - if EID.showCraftingResult and #EID.BagItems >= 8 then - local craftingResult, backupResult = EID:calculateBagOfCrafting(EID.BagItems) - local descriptionObj = EID:getDescriptionObj(5, 100, craftingResult) - local backupObj = EID:getDescriptionObj(5, 100, backupResult) - if (backupResult ~= craftingResult) then - EID:appendToDescription(descriptionObj,"#!!! If this item's locked, it will turn into#{{Collectible" .. backupResult .. "}} " .. - EID:getObjectName(5, 100, backupResult) .. "#" .. backupObj.Description) - end - EID:printDescription(descriptionObj) - return true - end - local curSeed = Game():GetSeeds():GetStartSeed() --reset our calculated recipes when the game seed changes if (curSeed ~= lastSeedUsed) then @@ -713,6 +740,24 @@ function EID:handleBagOfCraftingRendering() end lastSeedUsed = curSeed + --Display the result of the 8 items in our bag + if (showCraftingResult or EID.Config["BagOfCraftingDisplayMode"] == "Preview Only") and #EID.BagItems >= 8 then + local craftingResult, backupResult = EID:calculateBagOfCrafting(EID.BagItems) + local descriptionObj = EID:getDescriptionObj(5, 100, craftingResult) + --prepend the Hide/Preview hotkeys to the description + descriptionObj.Description = getHotkeyString() .. descriptionObj.Description + local backupObj = EID:getDescriptionObj(5, 100, backupResult) + if (backupResult ~= craftingResult) then + local backupDesc = EID:getDescriptionEntry("CraftingPreviewBackup") + EID:appendToDescription(descriptionObj,"#" .. backupDesc .. "#{{Collectible" .. backupResult .. "}} " .. + EID:getObjectName(5, 100, backupResult) .. "#" .. backupObj.Description) + end + EID:printDescription(descriptionObj) + return true + end + --if we're in Preview Only mode, then we have nothing more to do + if (EID.Config["BagOfCraftingDisplayMode"] == "Preview Only") then return false end + local curRoomIndex = Game():GetLevel():GetCurrentRoomDesc().SafeGridIndex local results = {} @@ -760,65 +805,35 @@ function EID:handleBagOfCraftingRendering() return false end - --sort by ingredient quality table.sort(itemQuery, qualitySort) - --Simplified Mode display - if (EID.Config["BagOfCraftingSimplifiedMode"] or EID:DetectModdedItems()) then - local customDescObj = EID:getDescriptionObj(5, 100, 710) - customDescObj.Description = "" + --No Recipes Mode display + if (EID.Config["BagOfCraftingDisplayMode"] == "No Recipes") then + EID:appendToDescription(customDescObj, getHotkeyString()) + EID:appendToDescription(customDescObj, getFloorItemsString(false, roomItems)) - local hotkeyString = "" - if HotkeyToString[EID.Config["CraftingHideKey"]] then - hotkeyString = "Hide: " .. HotkeyToString[EID.Config["CraftingHideKey"]] - end - if #EID.BagItems >= 8 and HotkeyToString[EID.Config["CraftingResultKey"]] then - if hotkeyString ~= "" then hotkeyString = hotkeyString .. ", " end - hotkeyString = hotkeyString .. "Preview: " .. HotkeyToString[EID.Config["CraftingResultKey"]] - end - if hotkeyString ~= "" then - EID:appendToDescription(customDescObj, "!!! " .. hotkeyString .. "#") - end - - if #EID.BagItems >0 then - if #EID.BagItems >= 8 then - local recipe = EID:calculateBagOfCrafting(EID.BagItems) - EID:appendToDescription(customDescObj, "{{Collectible"..recipe.."}} ") - end - local bagDesc = EID:getDescriptionEntry("CraftingBagContent").."(Beta)" - EID:appendToDescription(customDescObj, bagDesc..EID:tableToCraftingIconsMerged(EID.BagItems).."#") - end - if #roomItems >0 then - local roomDesc = EID:getDescriptionEntry("CraftingRoomContent") - EID:appendToDescription(customDescObj, roomDesc..EID:tableToCraftingIconsMerged(roomItems).."#") - end - if #EID.bagOfCraftingFloorQuery >0 and #roomItems ~= #EID.bagOfCraftingFloorQuery then - local floorDesc = EID:getDescriptionEntry("CraftingFloorContent") - EID:appendToDescription(customDescObj, floorDesc..EID:tableToCraftingIconsMerged(EID.bagOfCraftingFloorQuery).."#") - end - - local mostValuableSimp = {} + local mostValuableBag = {} for i=1,8 do - mostValuableSimp[i] = itemQuery[i] + mostValuableBag[i] = itemQuery[i] end local bagQuality, bagResult = EID:simulateBagOfCrafting(EID.BagItems) - local bestQuality, bestResult = EID:simulateBagOfCrafting(mostValuableSimp) + local bestQuality, bestResult = EID:simulateBagOfCrafting(mostValuableBag) local bagQualityDesc = EID:getDescriptionEntry("CraftingBagQuality") local bestQualityDesc = EID:getDescriptionEntry("CraftingBestQuality") if (#EID.BagItems > 0) then EID:appendToDescription(customDescObj, bagQualityDesc .. " " .. bagQuality .. "#" .. bagResult .. "#") end - if (bestQuality > bagQuality) then EID:appendToDescription(customDescObj, bestQualityDesc .. " " .. bestQuality .. "#{{Blank}} " .. tableToCraftingIconsFunc(self, mostValuableSimp, true) .. "#" .. bestResult .. "#") end + if (bestQuality > bagQuality) then EID:appendToDescription(customDescObj, bestQualityDesc .. " " .. bestQuality .. "#{{Blank}} " .. tableToCraftingIconsFunc(self,mostValuableBag, true) .. "#" .. bestResult .. "#") end EID:printDescription(customDescObj) return true end local queryString = table.concat(itemQuery,",") - if EID.lockedResults ~= nil then - results = calcResultCache[EID.lockedResults] - elseif calcResultCache[queryString] == nil or EID.refreshNextTick then + if lockedResults ~= nil then + results = calcResultCache[lockedResults] + elseif calcResultCache[queryString] == nil or refreshNextTick then --build on top of our previous recipe lists, if possible local randResults = randResultCache[queryString] or {} local newResults = {} @@ -829,11 +844,11 @@ function EID:handleBagOfCraftingRendering() local mostValuable = {} --shift our thorough check forward one ingredient each refresh (it will find duplicates, but spamming refresh will get a lot of variety) - if (EID.refreshNextTick) then - EID.bagOfCraftingRefreshes = EID.bagOfCraftingRefreshes + 1 - if (#itemQuery >= EID.Config["BagOfCraftingCombinationMax"] + EID.bagOfCraftingRefreshes) then + if (refreshNextTick) then + bagOfCraftingRefreshes = bagOfCraftingRefreshes + 1 + if (#itemQuery >= EID.Config["BagOfCraftingCombinationMax"] + bagOfCraftingRefreshes) then for i=1,EID.Config["BagOfCraftingCombinationMax"] do - mostValuable[i] = itemQuery[i+EID.bagOfCraftingRefreshes] + mostValuable[i] = itemQuery[i+bagOfCraftingRefreshes] end end --we have less items than our threshold; every single recipe will be listed @@ -891,127 +906,85 @@ function EID:handleBagOfCraftingRendering() numResults = 0 for k,v in ipairs(sortedIDs) do - if (EID.refreshNextTick and EID.bagOfCraftingOffset > 0 and v == EID.refreshPosition) then + if (refreshNextTick and bagOfCraftingOffset > 0 and v == refreshPosition) then --jump to the item we were looking at before, so you can more easily refresh for variants of recipes - EID.bagOfCraftingOffset = numResults + bagOfCraftingOffset = numResults end numResults = numResults + #results[v] end - if not EID.refreshNextTick then - EID.bagOfCraftingOffset = 0 - EID.bagOfCraftingRefreshes = 0 + if not refreshNextTick then + bagOfCraftingOffset = 0 + bagOfCraftingRefreshes = 0 end - EID.refreshNextTick = false + refreshNextTick = false else results = calcResultCache[queryString] end if numResults == 0 then - EID.bagOfCraftingOffset = 0 + bagOfCraftingOffset = 0 return false end - local customDescObj = EID:getDescriptionObj(5, 100, 710) - customDescObj.Description = "" - - local hotkeyString = "" - if HotkeyToString[EID.Config["CraftingHideKey"]] then - hotkeyString = "Hide: " .. HotkeyToString[EID.Config["CraftingHideKey"]] - end - if #EID.BagItems >= 8 and HotkeyToString[EID.Config["CraftingResultKey"]] then - if hotkeyString ~= "" then hotkeyString = hotkeyString .. ", " end - hotkeyString = hotkeyString .. "Preview: " .. HotkeyToString[EID.Config["CraftingResultKey"]] - end - if hotkeyString ~= "" then - EID:appendToDescription(customDescObj, "!!! " .. hotkeyString .. "#") - end - - -- Bag content display - if #EID.BagItems >0 then - if #EID.BagItems >= 8 then - local recipe = EID:calculateBagOfCrafting(EID.BagItems) - EID:appendToDescription(customDescObj, "{{Collectible"..recipe.."}} ") - end - local bagDesc = EID:getDescriptionEntry("CraftingBagContent") - EID:appendToDescription(customDescObj, bagDesc..EID:tableToCraftingIconsMerged(EID.BagItems).."#") - --debug the bag order - --EID:appendToDescription(customDescObj, EID:tableToCraftingIconsFull(EID.BagItems, false).."#") - end - -- Room content display - if #roomItems >0 then - if #roomItems == 8 then - local recipe = EID:calculateBagOfCrafting(roomItems) - EID:appendToDescription(customDescObj, "{{Collectible"..recipe.."}} ") - end - local roomDesc = EID:getDescriptionEntry("CraftingRoomContent") - EID:appendToDescription(customDescObj, roomDesc..EID:tableToCraftingIconsMerged(roomItems).."#") - end - -- Floot content display - if #EID.bagOfCraftingFloorQuery >0 and #roomItems ~= #EID.bagOfCraftingFloorQuery then - if #EID.bagOfCraftingFloorQuery == 8 then - local recipe = EID:calculateBagOfCrafting(EID.bagOfCraftingFloorQuery) - EID:appendToDescription(customDescObj, "{{Collectible"..recipe.."}} ") - end - local floorDesc = EID:getDescriptionEntry("CraftingFloorContent") - EID:appendToDescription(customDescObj, floorDesc..EID:tableToCraftingIconsMerged(EID.bagOfCraftingFloorQuery).."#") - end + EID:appendToDescription(customDescObj, getHotkeyString()) + EID:appendToDescription(customDescObj, getFloorItemsString(true, roomItems)) local resultDesc = EID:getDescriptionEntry("CraftingResults") EID:appendToDescription(customDescObj, resultDesc) if Input.IsActionPressed(EID.Config["BagOfCraftingToggleKey"], EID.player.ControllerIndex) then EID.player:SetShootingCooldown(2) if Input.IsActionTriggered(ButtonAction.ACTION_SHOOTDOWN, EID.player.ControllerIndex) then - EID.bagOfCraftingOffset = math.min(numResults-(numResults%EID.Config["BagOfCraftingResults"]), EID.bagOfCraftingOffset + EID.Config["BagOfCraftingResults"]) - EID.downHeld = Isaac.GetTime() + bagOfCraftingOffset = math.min(numResults-(numResults%EID.Config["BagOfCraftingResults"]), bagOfCraftingOffset + EID.Config["BagOfCraftingResults"]) + downHeld = Isaac.GetTime() elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTUP, EID.player.ControllerIndex) then - EID.bagOfCraftingOffset = math.max(0, EID.bagOfCraftingOffset - EID.Config["BagOfCraftingResults"]) - EID.upHeld = Isaac.GetTime() + bagOfCraftingOffset = math.max(0, bagOfCraftingOffset - EID.Config["BagOfCraftingResults"]) + upHeld = Isaac.GetTime() --lock the current results so you can actually do a recipe that you've scrolled down to without losing it elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTLEFT, EID.player.ControllerIndex) then - if (EID.lockedResults == nil) then EID.lockedResults = queryString - else EID.lockedResults = nil end + if (lockedResults == nil) then lockedResults = queryString + else lockedResults = nil end --refresh the recipes elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTRIGHT, EID.player.ControllerIndex) then - if (EID.lockedResults == nil) then - EID.refreshNextTick = true + if (lockedResults == nil) then + refreshNextTick = true end end --scroll pages quickly if the button is held - if Input.IsActionPressed(ButtonAction.ACTION_SHOOTDOWN, EID.player.ControllerIndex) and Isaac.GetTime() - EID.downHeld > 750 then - EID.bagOfCraftingOffset = math.min(numResults-(numResults%EID.Config["BagOfCraftingResults"]), EID.bagOfCraftingOffset + EID.Config["BagOfCraftingResults"]) - EID.downHeld = Isaac.GetTime() - 700 - elseif Input.IsActionPressed(ButtonAction.ACTION_SHOOTUP, EID.player.ControllerIndex) and Isaac.GetTime() - EID.upHeld > 750 then - EID.bagOfCraftingOffset = math.max(0, EID.bagOfCraftingOffset - EID.Config["BagOfCraftingResults"]) - EID.upHeld = Isaac.GetTime() - 700 + if Input.IsActionPressed(ButtonAction.ACTION_SHOOTDOWN, EID.player.ControllerIndex) and Isaac.GetTime() - downHeld > 750 then + bagOfCraftingOffset = math.min(numResults-(numResults%EID.Config["BagOfCraftingResults"]), bagOfCraftingOffset + EID.Config["BagOfCraftingResults"]) + downHeld = Isaac.GetTime() - 700 + elseif Input.IsActionPressed(ButtonAction.ACTION_SHOOTUP, EID.player.ControllerIndex) and Isaac.GetTime() - upHeld > 750 then + bagOfCraftingOffset = math.max(0, bagOfCraftingOffset - EID.Config["BagOfCraftingResults"]) + upHeld = Isaac.GetTime() - 700 end end --fix bug with being allowed to go to an empty page if recipe count = multiple of page size (or if we refresh on last page) - if (EID.bagOfCraftingOffset >= numResults) then EID.bagOfCraftingOffset = EID.bagOfCraftingOffset - EID.Config["BagOfCraftingResults"] end + if (bagOfCraftingOffset >= numResults) then bagOfCraftingOffset = bagOfCraftingOffset - EID.Config["BagOfCraftingResults"] end local prevItem = 0 local qualities = { [0] = "{{ColorSilver}}", "{{ColorLime}}", "{{ColorPastelBlue}}", "{{ColorLavender}}", "{{ColorLightOrange}}" } local prefix = "#{{Blank}} " - if (EID.lockedResults) then + if (lockedResults) then prefix = "#{{Trinket159}} " end --results is now a table of tables for each item, so we have to iterate over the table using sortedIDs - if (EID.bagOfCraftingOffset > 0) then - customDescObj.Description = customDescObj.Description.. prefix .. "...+"..EID.bagOfCraftingOffset.." more" + if (bagOfCraftingOffset > 0) then + customDescObj.Description = customDescObj.Description.. prefix .. "...+"..bagOfCraftingOffset.." more" end local curOffset = 0 - EID.refreshPosition = -1 + refreshPosition = -1 for k,id in ipairs(sortedIDs) do - if (curOffset + #results[id] <= EID.bagOfCraftingOffset) then curOffset = curOffset + #results[id] + if (curOffset + #results[id] <= bagOfCraftingOffset) then curOffset = curOffset + #results[id] else - if (EID.refreshPosition == -1) then EID.refreshPosition = id end + if (refreshPosition == -1) then refreshPosition = id end for k2, v in ipairs(results[id]) do curOffset = curOffset + 1 - if (curOffset > EID.bagOfCraftingOffset+EID.Config["BagOfCraftingResults"]) then break end + if (curOffset > bagOfCraftingOffset+EID.Config["BagOfCraftingResults"]) then break end if not v then break end - if (curOffset > EID.bagOfCraftingOffset) then + if (curOffset > bagOfCraftingOffset) then if not EID.Config["BagOfCraftingDisplayNames"] then customDescObj.Description = customDescObj.Description.."# {{Collectible"..v[2].."}} " --tack on the secondary recipe image to achievement-locked recipes @@ -1037,8 +1010,8 @@ function EID:handleBagOfCraftingRendering() end end end - if (EID.bagOfCraftingOffset + EID.Config["BagOfCraftingResults"] < numResults) then - customDescObj.Description = customDescObj.Description.. prefix .. "...+"..(numResults-EID.Config["BagOfCraftingResults"]-EID.bagOfCraftingOffset).." more" + if (bagOfCraftingOffset + EID.Config["BagOfCraftingResults"] < numResults) then + customDescObj.Description = customDescObj.Description.. prefix .. "...+"..(numResults-EID.Config["BagOfCraftingResults"]-bagOfCraftingOffset).." more" end EID:printDescription(customDescObj) diff --git a/eid_config.lua b/eid_config.lua index d8bac318..d67428c0 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -1,21 +1,3 @@ -local Controller = Controller or {} -Controller.DPAD_LEFT = 0 -Controller.DPAD_RIGHT = 1 -Controller.DPAD_UP = 2 -Controller.DPAD_DOWN = 3 -Controller.BUTTON_A = 4 -Controller.BUTTON_B = 5 -Controller.BUTTON_X = 6 -Controller.BUTTON_Y = 7 -Controller.BUMPER_LEFT = 8 -Controller.TRIGGER_LEFT = 9 -Controller.STICK_LEFT = 10 -Controller.BUMPER_RIGHT = 11 -Controller.TRIGGER_RIGHT = 12 -Controller.STICK_RIGHT = 13 -Controller.BUTTON_BACK = 14 -Controller.BUTTON_START = 15 - EID.UserConfig = { -------GENERAL--------- -- Change language of the mod. @@ -203,17 +185,22 @@ EID.UserConfig = { ---------Bag of Crafting----------- - -- Display-modes for Bag of Crafting descriptions + -- When to show the Bag of Crafting display -- Options: "always", "hold", "never" -- "always" = Always show Results, "hold" = Show when holding up bag, "never" = Never show results -- Default = "always" ["DisplayBagOfCrafting"] = "always", + -- Display modes for the Bag of Crafting display + -- Options: "Recipe List", "Preview Only", "No Recipes" + -- The recipe list is a detailed calculated list of recipes based on what you have available on the floor + -- Preview Only shows the description of the item you can currently craft in your bag + -- No Recipes shows percentages of what item you might get from your bag / best option on the floor, for a more intended experience + -- (No Recipes is recommended if you have modded items) + -- Default = "Recipe List" + ["BagOfCraftingDisplayMode"] = "Recipe List", -- Hide the recipe list when in battle -- Default = true ["BagOfCraftingHideInBattle"] = true, - -- Simplified / No Recipes Mode shows quality and item pool percentages instead of exact recipes, for a more intended experience - -- Default = false - ["BagOfCraftingSimplifiedMode"] = false, -- Changes the number of Results shown in the Bag of crafting description -- Higher numbers can cause more lag! -- Default = 7 @@ -241,8 +228,8 @@ EID.UserConfig = { -- Default = Keyboard.KEY_F3 ["CraftingHideKey"] = Keyboard.KEY_F3, -- Set the controller binding to toggle the crafting display, so you can see descriptions of items/pickups on the floor - -- Use the Controller enum at the top of this file, or a number - -- Of note are Controller.STICK_LEFT and Controller.STICK_RIGHT, which aren't used in-game with default controls + -- Use the Controller names here: https://github.com/wofsauge/External-Item-Descriptions/blob/master/mod_config_menu.lua#L1 or a number + -- Of note are Controller.STICK_LEFT and Controller.STICK_RIGHT (pushing the sticks in), which aren't used in-game with default controls -- Default = none (-1) ["CraftingHideButton"] = -1, -- Set the keybinding to toggle viewing the description of the item ready to be crafted in the bag @@ -365,7 +352,7 @@ EID.DefaultConfig = { ["BagOfCraftingDisplayNames"] = false, ["BagOfCraftingDisplayIcons"] = false, ["BagOfCraftingHideInBattle"] = true, - ["BagOfCraftingSimplifiedMode"] = false, + ["BagOfCraftingDisplayMode"] = "Recipe List", ["CraftingHideKey"] = Keyboard.KEY_F3, ["CraftingHideButton"] = -1, ["CraftingResultKey"] = Keyboard.KEY_F4, diff --git a/main.lua b/main.lua index 5e01f8ef..0a4ce156 100644 --- a/main.lua +++ b/main.lua @@ -595,7 +595,7 @@ local function renderAchievementInfo() demoDescObj.Description = EID:getDescriptionEntry("OldGameVersionWarningText") or "" EID:displayPermanentText(demoDescObj) hasShownAchievementWarning = true - elseif EID.player:HasCollectible(710) and EID:DetectModdedItems() and EID.Config.DisplayBagOfCrafting ~= "never" and not EID.Config.BagOfCraftingSimplifiedMode then + elseif EID.player:HasCollectible(710) and EID:DetectModdedItems() and EID.Config.DisplayBagOfCrafting ~= "never" and EID.Config.BagOfCraftingDisplayMode ~= "No Recipes" then local demoDescObj = EID:getDescriptionObj(-999, -1, 1) demoDescObj.Name = EID:getDescriptionEntry("AchievementWarningTitle") or "" demoDescObj.Description = EID:getDescriptionEntry("ModdedRecipesWarningText") or "" @@ -639,13 +639,12 @@ local function onRender(t) EID.isHidden = not EID.isHidden end - if ModConfigMenu and ModConfigMenu.IsVisible and ModConfigMenu.Config["Mod Config Menu"].HideHudInMenu and EID.MCMCompat_isDisplayingEIDTab ~= "Visuals" then --if if the mod config menu exists, is opened and Hide Hud is enabled, and ModConfigMenu is currently in the "Visuals" tab of EID + if ModConfigMenu and ModConfigMenu.IsVisible and ModConfigMenu.Config["Mod Config Menu"].HideHudInMenu and EID.MCMCompat_isDisplayingEIDTab ~= "Visuals" and EID.MCMCompat_isDisplayingEIDTab ~= "Crafting" then --if the mod config menu exists, is opened and Hide Hud is enabled, and ModConfigMenu isn't currently in the "Visuals" or "Crafting" tab of EID return end - EID:renderMCMDummyDescription() - renderAchievementInfo() + EID:renderMCMDummyDescription() if EID.GameVersion == "ab+" then if EID.player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG) then @@ -659,12 +658,6 @@ local function onRender(t) else EID:removeTextPosModifier("Tained HUD") end - if EID.player:HasCollectible(710) then - local success = EID:handleBagOfCraftingRendering() - if success then - return - end - end end if EID.isHidden then @@ -681,6 +674,13 @@ local function onRender(t) return end + if REPENTANCE and EID.player:HasCollectible(710) then + local success = EID:handleBagOfCraftingRendering() + if success then + return + end + end + EID.lastDescriptionEntity = nil EID.lastDist = 10000 local searchGroups = {} diff --git a/mod_config_menu.lua b/mod_config_menu.lua index 81cda46f..c141f2cf 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -1,3 +1,20 @@ +Controller = Controller or {} +Controller.DPAD_LEFT = 0 +Controller.DPAD_RIGHT = 1 +Controller.DPAD_UP = 2 +Controller.DPAD_DOWN = 3 +Controller.BUTTON_A = 4 +Controller.BUTTON_B = 5 +Controller.BUTTON_X = 6 +Controller.BUTTON_Y = 7 +Controller.BUMPER_LEFT = 8 +Controller.TRIGGER_LEFT = 9 +Controller.STICK_LEFT = 10 +Controller.BUMPER_RIGHT = 11 +Controller.TRIGGER_RIGHT = 12 +Controller.STICK_RIGHT = 13 +Controller.BUTTON_BACK = 14 +Controller.BUTTON_START = 15 -- MOD CONFIG MENU Compatibility local MCMLoaded, MCM = pcall(require, "scripts.modconfig") @@ -43,6 +60,8 @@ function EID:renderMCMDummyDescription() EID:renderHUDLocationIndicators() elseif EID.MCMCompat_isDisplayingEIDTab == "Visuals" and EID.permanentDisplayTextObj == nil then renderDummyDesc() + elseif EID.MCMCompat_isDisplayingEIDTab == "Crafting" then + clearRenderDummyDesc() end MCMCompat_isDisplayingDummyMCMObj = true EID:buildColorArray() @@ -1136,7 +1155,8 @@ if MCMLoaded then Minimum = 1, Maximum = 3, Display = function() - return "Display Mode: " .. EID.Config["DisplayBagOfCrafting"] + EID.MCMCompat_isDisplayingEIDTab = "Crafting" + return "Show Display: " .. EID.Config["DisplayBagOfCrafting"] end, OnChange = function(currentNum) EID.Config["DisplayBagOfCrafting"] = bagDisplays[currentNum] @@ -1144,16 +1164,32 @@ if MCMLoaded then Info = {"Always = Always show Results, Hold = Show when holding up bag, Never = Never show results"} } ) + -- Bag of Crafting Display Mode + local bagDisplayModes = {"Recipe List","Preview Only","No Recipes"} + MCM.AddSetting( + "EID", + "Crafting", + { + Type = ModConfigMenu.OptionType.NUMBER, + CurrentSetting = function() + return AnIndexOf(bagDisplayModes, EID.Config["BagOfCraftingDisplayMode"]) + end, + Minimum = 1, + Maximum = 3, + Display = function() + return "Display Mode: " .. EID.Config["BagOfCraftingDisplayMode"] + end, + OnChange = function(currentNum) + EID.Config["BagOfCraftingDisplayMode"] = bagDisplayModes[currentNum] + end, + Info = {"Toggle showing a list of calculated recipes, showing just an item preview when the bag is full, or showing percentages of what item you might get (No Recipes is recommended if using modded items)"} + } + ) -- Bag of Crafting Hide in Battle EID:AddBooleanSetting("Crafting", "BagOfCraftingHideInBattle", "Hide in Battle", "Yes", "No", "Hides the recipe list when in a fight") - -- Bag of Crafting No Recipes Mode - EID:AddBooleanSetting("Crafting", - "BagOfCraftingSimplifiedMode", - "No Recipes Mode", "On", "Off", - "No Recipes Mode shows quality and item pool percentages instead of exact recipes, for a more intended experience") -- Bag of Crafting 8 icons toggle EID:AddBooleanSetting("Crafting", "BagOfCraftingDisplayIcons", @@ -1161,6 +1197,7 @@ if MCMLoaded then "Choose if you want recipes (and the Best Quality bag in No Recipes Mode) shown as 8 icons, or as grouped ingredients") MCM.AddSpace("EID", "Crafting") + MCM.AddText("EID", "Crafting", function() return "Recipe List Options" end) -- Bag of Crafting results per page MCM.AddSetting( @@ -1255,7 +1292,7 @@ if MCMLoaded then EID:AddHotkeySetting("Crafting", "CraftingResultKey", "Result Toggle (Keyboard)", - "Press this key to toggle the description of the item ready to be crafted", false) + "Press this key to toggle the description of the item ready to be crafted in Recipe List/No Recipe Mode", false) EID:AddHotkeySetting("Crafting", "CraftingResultButton", "Result Toggle (Controller)", "Press this button to toggle the description of the item ready to be crafted (Left Stick or Right Stick recommended; most other buttons will not work)", true)