From c06348aeebe6ddedc993477ed54da915538fdbdb Mon Sep 17 00:00:00 2001 From: Valentin Lampriere Date: Fri, 14 Jan 2022 11:29:43 +0100 Subject: [PATCH] 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 758f37cf..094f9bc5 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -49,7 +49,6 @@ EID.ItemTypeAnm2Names = { "familiar", -- 4 "trinket" -- 5 } -EID.MODS = { } --------------------------------------------------------------------------- -------------------------Handle API Functions ----------------------------- @@ -1049,3 +1048,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 26e2b4d2..edf3ee16 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--------- @@ -362,7 +362,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 0c477cf2..dbc40904 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 @@ -376,9 +380,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 95a54a0b..0ce03b52 100644 --- a/mod_config_menu.lua +++ b/mod_config_menu.lua @@ -1206,24 +1206,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 } )