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
|
return nil
|
||||||
end
|
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.
|
-- returns the specified object table in the current language.
|
||||||
-- falls back to english if it doesnt exist, unless specified otherwise
|
-- falls back to english if it doesnt exist, unless specified otherwise
|
||||||
function EID:getDescriptionEntry(objTable, objID, noFallback)
|
function EID:getDescriptionEntry(objTable, objID, noFallback)
|
||||||
|
|||||||
+4
-1
@@ -199,7 +199,10 @@ local function onDebugRender(t)
|
|||||||
local descTable = {
|
local descTable = {
|
||||||
["Name"] = "Some Item with seed ".. v.InitSeed ,
|
["Name"] = "Some Item with seed ".. v.InitSeed ,
|
||||||
["Description"] = "Test specific description#Init 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
|
v:GetData()["EID_Description"] = descTable
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -625,12 +625,7 @@ function EID:printDescription(desc, cachedID)
|
|||||||
end
|
end
|
||||||
-- Display the mod this item is from
|
-- Display the mod this item is from
|
||||||
if desc.ModName then
|
if desc.ModName then
|
||||||
if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then
|
curName = curName .. EID:getModNameString(desc)
|
||||||
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
|
end
|
||||||
|
|
||||||
EID:renderString(
|
EID:renderString(
|
||||||
@@ -1367,9 +1362,7 @@ local function onRender(t)
|
|||||||
local desc = EID:getEntityData(closest, "EID_Description")
|
local desc = EID:getEntityData(closest, "EID_Description")
|
||||||
local origDesc = EID:getDescriptionObjByEntity(closest)
|
local origDesc = EID:getDescriptionObjByEntity(closest)
|
||||||
if desc ~= nil and type(desc) == "table" then
|
if desc ~= nil and type(desc) == "table" then
|
||||||
origDesc.Description = desc.Description or origDesc.Description
|
origDesc = EID:mergeDescriptionObjects(origDesc, desc)
|
||||||
origDesc.Name = desc.Name or origDesc.Name
|
|
||||||
origDesc.Transformation = desc.Transformation or origDesc.Transformation
|
|
||||||
else
|
else
|
||||||
origDesc.Description = desc
|
origDesc.Description = desc
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user