Fixed GetData() descriptions being unable to alter Modname, Quality and object icons
This commit is contained in:
1 parent
d00208df0b
commit
805d57540f
3 files changed
+29
-10
No files matched your search
+23
@@ -428,6 +428,29 @@ function EID:getLegacyModDescription(Type, Variant, SubType)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Returns the icon and mod name of a given EID description object as a preformatted description string
|
||||
function EID:getModNameString(descObj)
|
||||
local modString = ""
|
||||
if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then
|
||||
local modName = EID.ModIndicator[descObj.ModName] and EID.ModIndicator[descObj.ModName].Name or descObj.ModName
|
||||
modString = modString .. " {{"..EID.Config["ModIndicatorTextColor"].."}}" .. modName
|
||||
end
|
||||
local modIcon = EID.ModIndicator[descObj.ModName] and EID.ModIndicator[descObj.ModName].Icon
|
||||
if (EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Icon only") and modIcon then
|
||||
modString = modString .. "{{".. modIcon .."}}"
|
||||
end
|
||||
return modString
|
||||
end
|
||||
|
||||
-- Attempts to merge two given Description objects into one
|
||||
function EID:mergeDescriptionObjects(oldDescObj, newDescObj)
|
||||
for k,v in pairs(oldDescObj) do
|
||||
if not newDescObj[k] then
|
||||
newDescObj[k] = v
|
||||
end
|
||||
end
|
||||
return newDescObj
|
||||
end
|
||||
-- returns the specified object table in the current language.
|
||||
-- falls back to english if it doesnt exist, unless specified otherwise
|
||||
function EID:getDescriptionEntry(objTable, objID, noFallback)
|
||||
|
||||
+4
-1
@@ -199,7 +199,10 @@ local function onDebugRender(t)
|
||||
local descTable = {
|
||||
["Name"] = "Some Item with seed ".. v.InitSeed ,
|
||||
["Description"] = "Test specific description#Init seed: ".. v.InitSeed,
|
||||
["Transformation"] = "1,2"
|
||||
["Transformation"] = "1,2",
|
||||
["ModName"] = "My Mod name",
|
||||
["Quality"] = 4,
|
||||
["Icon"] = EID.ObjectIcon["5.100.1"],
|
||||
}
|
||||
v:GetData()["EID_Description"] = descTable
|
||||
end
|
||||
|
||||
@@ -625,12 +625,7 @@ function EID:printDescription(desc, cachedID)
|
||||
end
|
||||
-- Display the mod this item is from
|
||||
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
|
||||
curName = curName .. EID:getModNameString(desc)
|
||||
end
|
||||
|
||||
EID:renderString(
|
||||
@@ -1367,9 +1362,7 @@ local function onRender(t)
|
||||
local desc = EID:getEntityData(closest, "EID_Description")
|
||||
local origDesc = EID:getDescriptionObjByEntity(closest)
|
||||
if desc ~= nil and type(desc) == "table" then
|
||||
origDesc.Description = desc.Description or origDesc.Description
|
||||
origDesc.Name = desc.Name or origDesc.Name
|
||||
origDesc.Transformation = desc.Transformation or origDesc.Transformation
|
||||
origDesc = EID:mergeDescriptionObjects(origDesc, desc)
|
||||
else
|
||||
origDesc.Description = desc
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user