Merge pull request #307 from valentinLampriere/master
Add an mod indicator which indicates from which mod an item came from
This commit is contained in:
4 files changed
+96
-5
No files matched your search
+20
-4
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user