From fc477adc4f92b20fc374914dc94d3563c896d342 Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 01:33:36 +0100 Subject: [PATCH 1/7] Display mod name for modded items (+MCM support) --- eid_api.lua | 12 ++++++++---- eid_config.lua | 4 ++++ main.lua | 16 +++++++++++++++- mod_config_menu.lua | 21 +++++++++++++++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index b9c99f23..91294f1e 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -49,6 +49,8 @@ EID.ItemTypeAnm2Names = { "familiar", -- 4 "trinket" -- 5 } +EID.MODS = { } + --------------------------------------------------------------------------- -------------------------Handle API Functions ----------------------------- local nullVector = Vector(0,0) @@ -61,28 +63,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 @@ -318,6 +320,8 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity) local tableEntry = EID:getDescriptionData(Type, Variant, description.ObjSubType) description.Description = tableEntry and tableEntry[3] or EID:getXMLDescription(Type, Variant, description.ObjSubType) + description.ModName = tableEntry and tableEntry[4] + description.Transformation = EID:getTransformation(Type, Variant, description.ObjSubType) for k,modifier in pairs(EID.DescModifiers) do diff --git a/eid_config.lua b/eid_config.lua index 78ed9ded..706d00ee 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -131,6 +131,9 @@ EID.UserConfig = { -- REPENTANCE ONLY!!! -- Default = true ["ShowQuality"] = true, + -- Display mod name for modded items + -- Default = true + ["ShowModName"] = true, -------TRANSFORMATIONS--------- @@ -351,6 +354,7 @@ EID.DefaultConfig = { ["DisplayTrinketInfo"] = true, ["ItemNameColor"] = "ColorEIDObjName", ["ShowQuality"] = true, + ["ShowModName"] = true, ["ShowObjectID"] = false, ["TransformationText"] = true, ["TransformationIcons"] = true, diff --git a/main.lua b/main.lua index 447a3e74..86ab41af 100644 --- a/main.lua +++ b/main.lua @@ -57,6 +57,14 @@ local hudBBSprite = Sprite() hudBBSprite:Load("gfx/eid_transform_icons.anm2", true) hudBBSprite:Play("boundingBox") +EID._currentMod = "" + +local OldRegisterMod = RegisterMod +RegisterMod = function (modName, apiVersion) + EID._currentMod = modName + return OldRegisterMod(modName, apiVersion) +end + ------- Load all modules and other stuff ------ --transformation infos @@ -361,6 +369,11 @@ function EID:printDescription(desc) local quality = tonumber(EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Quality) curName = curName.." - {{Quality"..quality.."}}" end + + if EID.Config["ShowModName"] and desc.ModName then + curName = curName .. " {{ColorWhite}}" .. desc.ModName + end + EID:renderString( curName, renderPos + (Vector(offsetX, -3) * EID.Scale), @@ -398,6 +411,7 @@ function EID:printDescription(desc) end end EID:printBulletPoints(desc.Description, renderPos) + end function EID:printBulletPoints(description, renderPos) @@ -1076,4 +1090,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 141bf09f..b81755fb 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -1184,6 +1184,27 @@ if MCMLoaded then } ) end + -------Mod name for modded items--------- + MCM.AddSetting( + "EID", + "Visuals", + { + Type = ModConfigMenu.OptionType.BOOLEAN, + CurrentSetting = function() + return EID.Config["ShowModName"] + end, + Display = function() + local onOff = "False" + if EID.Config["ShowModName"] then + onOff = "True" + end + return "Display mod name: " .. onOff + end, + OnChange = function(currentBool) + EID.Config["ShowModName"] = currentBool + end + } + ) -------Object ID--------- MCM.AddSetting( "EID", From 66b8c307ba7a60f98d9c7a900ee360c683f9ce36 Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 11:29:43 +0100 Subject: [PATCH 2/7] Add custom mod icon + custom mod name --- eid_api.lua | 9 ++++++++- eid_config.lua | 8 ++++---- main.lua | 16 +++++++++++++--- mod_config_menu.lua | 19 +++++++++---------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index 91294f1e..d8251705 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -49,7 +49,6 @@ EID.ItemTypeAnm2Names = { "familiar", -- 4 "trinket" -- 5 } -EID.MODS = { } --------------------------------------------------------------------------- -------------------------Handle API Functions ----------------------------- @@ -1010,3 +1009,11 @@ end function EID:getErrorColor() return EID:getColor(EID.Config["ErrorColor"], EID.InlineColors["ColorEIDError"]) end + + +function EID:addModIndicatorName(newName) + EID.ModIndicator[EID._currentMod].Name = newName +end +function EID:addModIndicatorIcon(iconMarkup) + EID.ModIndicator[EID._currentMod].Icon = iconMarkup +end diff --git a/eid_config.lua b/eid_config.lua index 706d00ee..31bcdd9c 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -131,9 +131,9 @@ EID.UserConfig = { -- REPENTANCE ONLY!!! -- Default = true ["ShowQuality"] = true, - -- Display mod name for modded items - -- Default = true - ["ShowModName"] = true, + -- Set the mod indicator display + -- Default = "Both" + ["ModIndicatorDisplay"] = "Both", -------TRANSFORMATIONS--------- @@ -354,7 +354,7 @@ EID.DefaultConfig = { ["DisplayTrinketInfo"] = true, ["ItemNameColor"] = "ColorEIDObjName", ["ShowQuality"] = true, - ["ShowModName"] = true, + ["ModIndicatorDisplay"] = "Both", ["ShowObjectID"] = false, ["TransformationText"] = true, ["TransformationIcons"] = true, diff --git a/main.lua b/main.lua index 86ab41af..382c4ea6 100644 --- a/main.lua +++ b/main.lua @@ -57,11 +57,15 @@ local hudBBSprite = Sprite() hudBBSprite:Load("gfx/eid_transform_icons.anm2", true) hudBBSprite:Play("boundingBox") -EID._currentMod = "" +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 @@ -370,9 +374,15 @@ function EID:printDescription(desc) curName = curName.." - {{Quality"..quality.."}}" end - if EID.Config["ShowModName"] and desc.ModName then - curName = curName .. " {{ColorWhite}}" .. desc.ModName + if desc.ModName then + if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then + curName = curName .. " {{ColorWhite}}" .. 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 + print(EID.Config["ModIndicatorDisplay"]) EID:renderString( curName, diff --git a/mod_config_menu.lua b/mod_config_menu.lua index b81755fb..65424291 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -1184,24 +1184,23 @@ if MCMLoaded then } ) end - -------Mod name for modded items--------- + -------Mod indicator for modded items--------- + local modIndicatorDisplays = {"Both","Name only","Icon only", "None"} MCM.AddSetting( "EID", "Visuals", { - Type = ModConfigMenu.OptionType.BOOLEAN, + Type = ModConfigMenu.OptionType.NUMBER, CurrentSetting = function() - return EID.Config["ShowModName"] + return AnIndexOf(modIndicatorDisplays, EID.Config["ModIndicatorDisplay"]) end, + Minimum = 1, + Maximum = #modIndicatorDisplays, Display = function() - local onOff = "False" - if EID.Config["ShowModName"] then - onOff = "True" - end - return "Display mod name: " .. onOff + return "Mod indicator displayed for: " .. EID.Config["ModIndicatorDisplay"] end, - OnChange = function(currentBool) - EID.Config["ShowModName"] = currentBool + OnChange = function(currentNum) + EID.Config["ModIndicatorDisplay"] = modIndicatorDisplays[currentNum] end } ) From d5bb47f840c1af596089f834bf1cef73dfbc43e9 Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 11:35:39 +0100 Subject: [PATCH 3/7] Get rid of prints --- main.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/main.lua b/main.lua index 382c4ea6..5eace6c0 100644 --- a/main.lua +++ b/main.lua @@ -382,7 +382,6 @@ function EID:printDescription(desc) curName = curName .. "{{".. EID.ModIndicator[desc.ModName].Icon .."}}" end end - print(EID.Config["ModIndicatorDisplay"]) EID:renderString( curName, From 939f2a7ab2ecf8d633f1dd6e41c915e5d7e07fc4 Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 12:26:14 +0100 Subject: [PATCH 4/7] Allow user to change mod indicator color --- eid_config.lua | 4 ++++ main.lua | 4 ++-- mod_config_menu.lua | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/eid_config.lua b/eid_config.lua index 31bcdd9c..c9d151cc 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -134,6 +134,9 @@ EID.UserConfig = { -- Set the mod indicator display -- Default = "Both" ["ModIndicatorDisplay"] = "Both", + -- Set the mod indicator text color + -- Default = "ColorLightOrange" + ["ModIndicatorTextColor"] = "ColorLightOrange", -------TRANSFORMATIONS--------- @@ -355,6 +358,7 @@ EID.DefaultConfig = { ["ItemNameColor"] = "ColorEIDObjName", ["ShowQuality"] = true, ["ModIndicatorDisplay"] = "Both", + ["ModIndicatorTextColor"] = "ColorLightOrange", ["ShowObjectID"] = false, ["TransformationText"] = true, ["TransformationIcons"] = true, diff --git a/main.lua b/main.lua index 5eace6c0..63abc049 100644 --- a/main.lua +++ b/main.lua @@ -376,9 +376,9 @@ function EID:printDescription(desc) if desc.ModName then if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then - curName = curName .. " {{ColorWhite}}" .. EID.ModIndicator[desc.ModName].Name + 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 + 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 diff --git a/mod_config_menu.lua b/mod_config_menu.lua index 65424291..6a1f1be8 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -1563,4 +1563,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 From 94d99a5b3f6ca2b3df5190dbc9f69337cffe57d9 Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 14:06:23 +0100 Subject: [PATCH 5/7] Add mod indicator override parameter --- eid_api.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eid_api.lua b/eid_api.lua index d8251705..61ea72c0 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -1011,9 +1011,11 @@ function EID:getErrorColor() end -function EID:addModIndicatorName(newName) +function EID:setModIndicatorName(newName) EID.ModIndicator[EID._currentMod].Name = newName end -function EID:addModIndicatorIcon(iconMarkup) +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 From c33922ee564320b73a63363ec71a0d1e089087f2 Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 14:06:50 +0100 Subject: [PATCH 6/7] Switch default mod indicator from "Both" to "None" --- eid_config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eid_config.lua b/eid_config.lua index c9d151cc..5e87c206 100644 --- a/eid_config.lua +++ b/eid_config.lua @@ -133,7 +133,7 @@ EID.UserConfig = { ["ShowQuality"] = true, -- Set the mod indicator display -- Default = "Both" - ["ModIndicatorDisplay"] = "Both", + ["ModIndicatorDisplay"] = "None", -- Set the mod indicator text color -- Default = "ColorLightOrange" ["ModIndicatorTextColor"] = "ColorLightOrange", @@ -357,7 +357,7 @@ EID.DefaultConfig = { ["DisplayTrinketInfo"] = true, ["ItemNameColor"] = "ColorEIDObjName", ["ShowQuality"] = true, - ["ModIndicatorDisplay"] = "Both", + ["ModIndicatorDisplay"] = "None", ["ModIndicatorTextColor"] = "ColorLightOrange", ["ShowObjectID"] = false, ["TransformationText"] = true, From 1ff3bc07e16255e0f8176eac03136046ae393746 Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 14:35:02 +0100 Subject: [PATCH 7/7] Add comments to new API functions --- eid_api.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eid_api.lua b/eid_api.lua index 61ea72c0..81cea774 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -1010,10 +1010,12 @@ 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