diff --git a/eid_api.lua b/eid_api.lua index 606b2c65..7f1145bd 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -49,6 +49,7 @@ EID.ItemTypeAnm2Names = { "familiar", -- 4 "trinket" -- 5 } + --------------------------------------------------------------------------- -------------------------Handle API Functions ----------------------------- local nullVector = Vector(0,0) @@ -61,28 +62,28 @@ local dynamicSpriteCache = {} -- used to store sprite objects of collectible ico function EID:addCollectible(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" - EID.descriptions[language].custom["5.100." .. id] = {id, itemName, description} + EID.descriptions[language].custom["5.100." .. id] = {id, itemName, description, EID._currentMod} end -- Adds a description for a trinket. Optional parameters: itemName, language function EID:addTrinket(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" - EID.descriptions[language].custom["5.350." .. id] = {id, itemName, description} + EID.descriptions[language].custom["5.350." .. id] = {id, itemName, description, EID._currentMod} end -- Adds a description for a card/rune. Optional parameters: itemName, language function EID:addCard(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" - EID.descriptions[language].custom["5.300." .. id] = {id, itemName, description} + EID.descriptions[language].custom["5.300." .. id] = {id, itemName, description, EID._currentMod} end -- Adds a description for a pilleffect id. Optional parameters: itemName, language function EID:addPill(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" - EID.descriptions[language].custom["5.70." .. id+1] = {id+1, itemName, description} + EID.descriptions[language].custom["5.70." .. id+1] = {id+1, itemName, description, EID._currentMod} end -- Adds a character specific description for the item "Birthright". Optional parameters: playerName, language @@ -320,6 +321,9 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity) description.Transformation = EID:getTransformation(Type, Variant, SubType) + description.ModName = tableEntry and tableEntry[4] + description.ModName = tableEntry and tableEntry[4] + for k,modifier in pairs(EID.DescModifiers) do if modifier.condition(description) then description = modifier.callback(description) @@ -1045,3 +1049,15 @@ end function EID:getErrorColor() return EID:getColor(EID.Config["ErrorColor"], EID.InlineColors["ColorEIDError"]) end + +-- Specify the name of the mod which will be displayed next to the item name +-- By default EID takes the mod name +function EID:setModIndicatorName(newName) + EID.ModIndicator[EID._currentMod].Name = newName +end +-- Set an icon for the mod which will be displayed next to the item name +function EID:setModIndicatorIcon(iconMarkup, override) + if override == nil then override = true end -- overide previous value if not specified + if EID.ModIndicator[EID._currentMod].Icon ~= nil and override == false then return end + EID.ModIndicator[EID._currentMod].Icon = iconMarkup +end diff --git a/eid_config.lua b/eid_config.lua index 5d6c3cd4..b896e56c 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -131,6 +131,12 @@ EID.UserConfig = { -- REPENTANCE ONLY!!! -- Default = true ["ShowQuality"] = true, + -- Set the mod indicator display + -- Default = "Both" + ["ModIndicatorDisplay"] = "None", + -- Set the mod indicator text color + -- Default = "ColorLightOrange" + ["ModIndicatorTextColor"] = "ColorLightOrange", -------TRANSFORMATIONS--------- @@ -359,6 +365,8 @@ EID.DefaultConfig = { ["DisplayTrinketInfo"] = true, ["ItemNameColor"] = "ColorEIDObjName", ["ShowQuality"] = true, + ["ModIndicatorDisplay"] = "None", + ["ModIndicatorTextColor"] = "ColorLightOrange", ["ShowObjectID"] = false, ["TransformationText"] = true, ["TransformationIcons"] = true, diff --git a/main.lua b/main.lua index 0a543715..f5555013 100644 --- a/main.lua +++ b/main.lua @@ -57,6 +57,18 @@ local hudBBSprite = Sprite() hudBBSprite:Load("gfx/eid_transform_icons.anm2", true) hudBBSprite:Play("boundingBox") + +EID.ModIndicator = { } +-- Overwriting "RegisterMod" to track which mods are loading +-- Useful to associate items to mods +EID._currentMod = "" +local OldRegisterMod = RegisterMod +RegisterMod = function (modName, apiVersion) + EID._currentMod = modName + EID.ModIndicator[modName] = { Name = modName, Icon = nil } + return OldRegisterMod(modName, apiVersion) +end + ------- Load all modules and other stuff ------ --transformation infos @@ -367,6 +379,16 @@ function EID:printDescription(desc) local quality = tonumber(EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Quality) curName = curName.." - {{Quality"..quality.."}}" end + + if desc.ModName then + if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then + curName = curName .. " {{"..EID.Config["ModIndicatorTextColor"].."}}" .. EID.ModIndicator[desc.ModName].Name + end + if (EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Icon only") and EID.ModIndicator[desc.ModName].Icon then + curName = curName .. "{{".. EID.ModIndicator[desc.ModName].Icon .."}}" + end + end + EID:renderString( curName, renderPos + (Vector(offsetX, -3) * EID.Scale), @@ -404,6 +426,7 @@ function EID:printDescription(desc) end end EID:printBulletPoints(desc.Description, renderPos) + end function EID:printBulletPoints(description, renderPos) @@ -1099,4 +1122,4 @@ end if enableDebug then require("eid_debugging") -end +end \ No newline at end of file diff --git a/mod_config_menu.lua b/mod_config_menu.lua index b58d436a..7d2b7641 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -1206,6 +1206,26 @@ if MCMLoaded then } ) end + -------Mod indicator for modded items--------- + local modIndicatorDisplays = {"Both","Name only","Icon only", "None"} + MCM.AddSetting( + "EID", + "Visuals", + { + Type = ModConfigMenu.OptionType.NUMBER, + CurrentSetting = function() + return AnIndexOf(modIndicatorDisplays, EID.Config["ModIndicatorDisplay"]) + end, + Minimum = 1, + Maximum = #modIndicatorDisplays, + Display = function() + return "Mod indicator displayed for: " .. EID.Config["ModIndicatorDisplay"] + end, + OnChange = function(currentNum) + EID.Config["ModIndicatorDisplay"] = modIndicatorDisplays[currentNum] + end + } + ) -------Object ID--------- MCM.AddSetting( "EID", @@ -1565,4 +1585,28 @@ if MCMLoaded then Info = {"Changes the color of error messages like Unknown pills"} } ) + -- Mod indicator Color + MCM.AddSetting( + "EID", + "Colors", + { + Type = ModConfigMenu.OptionType.NUMBER, + CurrentSetting = function() + return AnIndexOf(colorNameArray, EID.Config["ModIndicatorTextColor"]) + end, + Minimum = 0, + Maximum = 1000, + Display = function() + if EID.Config["ModIndicatorTextColor"] == nil then EID.Config["TextColor"] = EID.DefaultConfig["ModIndicatorTextColor"] end + EID.MCMCompat_isDisplayingEIDTab = "Visuals"; + return "Mod Indicator: " .. string.gsub(EID.Config["ModIndicatorTextColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["ModIndicatorTextColor"]).."/"..#colorNameArray..")" + end, + OnChange = function(currentNum) + if currentNum == 0 then currentNum = #colorNameArray end + if currentNum > #colorNameArray then currentNum = 1 end + EID.Config["ModIndicatorTextColor"] = colorNameArray[currentNum] + end, + Info = {"Changes the color of mod indicator texts (as long as they are enabled)."} + } + ) end