Make config option "TranslateItemName" work in all usecases, fixing wrong behavior in Item reminder and other features

This commit is contained in:
Wofsauge committed 2026-07-22 21:05:49 +02:00
1 parent 9efa77309e
commit 78bc8fcb43
2 files changed
+28 -17

No files matched your search

+28 -3
View File
@@ -100,7 +100,6 @@ local dynamicSpriteCache = {} -- used to store sprite objects of collectible ico
---@field Icon EID_Icon
---@field Entity Entity?
---@field ShowWhenUnidentified boolean?
---@field PermanentTextEnglish string?
---@field IgnoreBulletPointIconConfig boolean?
---@field ItemType integer?
---@field ChargeType integer?
@@ -526,7 +525,7 @@ end
---@param permName1 string
---@param permName2 string?
function EID:displayPermanentText(descriptionObject, permName1, permName2)
descriptionObject.PermanentTextEnglish = EID:getDescriptionEntryEnglish(permName1, permName2)
descriptionObject.Name = EID:getDescriptionEntryEnglish(permName1, permName2)
EID.permanentDisplayTextObj = descriptionObject
EID.isDisplayingPermanent = true
end
@@ -938,11 +937,12 @@ function EID:getTransformationName(id)
end
---Tries to get the ingame name of an item based on its ID
--- Used internally by EID:getObjectName, which also handles the TranslateItemName config option
---@param Type EntityType
---@param Variant integer
---@param SubType integer
---@return string
function EID:getObjectName(Type, Variant, SubType)
local function getObjectName_internal(Type, Variant, SubType)
local fallbackName = Type.."."..Variant.."."..SubType
local tableName = EID:getTableName(Type, Variant, SubType)
@@ -990,6 +990,31 @@ function EID:getObjectName(Type, Variant, SubType)
return fallbackName
end
---Tries to get the ingame name of an item based on its ID
---@param Type EntityType
---@param Variant integer
---@param SubType integer
---@return string
function EID:getObjectName(Type, Variant, SubType)
local combinedName = getObjectName_internal(Type, Variant, SubType)
if EID.Config["TranslateItemName"] ~= 2 then
local curLanguage = EID.Config["Language"]
if EID:getLanguage() ~= EID.DefaultLanguageCode then
EID.Config["Language"] = EID.DefaultLanguageCode
local englishName = getObjectName_internal(Type, Variant, SubType)
EID.Config["Language"] = curLanguage
if englishName ~= combinedName then
if EID.Config["TranslateItemName"] == 1 then
combinedName = englishName
elseif EID.Config["TranslateItemName"] == 3 and combinedName ~= englishName then
combinedName = combinedName.." ("..englishName..")"
end
end
end
end
return combinedName
end
---Returns the name of a player based on their ID
---@param id PlayerType
---@param altFallback? string
-14
View File
@@ -641,19 +641,6 @@ function EID:printDescription(desc, cachedID)
local curName = ""
if EID.Config["ShowItemName"] and desc.Name then
curName = desc.Name
if EID.Config["TranslateItemName"] ~= 2 and desc.ObjType ~= -999 then
local curLanguage = EID.Config["Language"]
if EID:getLanguage() ~= EID.DefaultLanguageCode then
EID.Config["Language"] = EID.DefaultLanguageCode
local englishName = desc.PermanentTextEnglish or EID:getObjectName(desc.ObjType, desc.ObjVariant, desc.ObjSubType)
EID.Config["Language"] = curLanguage
if EID.Config["TranslateItemName"] == 1 then
curName = englishName
elseif EID.Config["TranslateItemName"] == 3 and curName ~= englishName then
curName = curName.." ("..englishName..")"
end
end
end
end
-- Display Entity ID
if EID.Config["ShowObjectID"] and desc.ObjType and desc.ObjType > 0 then
@@ -1679,7 +1666,6 @@ function EID:OnRender()
if EID.Config["ItemReminderEnabled"] and EID.holdTabCounter >= 30 and EID.TabDescThisFrame == false and EID.holdTabPlayer ~= nil then
EID:ItemReminderHandleInputs()
local demoDescObj = EID:getDescriptionObj(-999, -1, 1)
demoDescObj.PermanentTextEnglish = EID:getDescriptionEntryEnglish("ItemReminder", "Title")
-- check for scrolling being enabled here and append scroll controls to the title?
demoDescObj.Description = EID:ItemReminderGetDescription()
demoDescObj.Name = EID:ItemReminderGetTitle()