Usable Fonts can now be defined per languagepack

This commit is contained in:
Wofsauge committed 2022-01-09 01:47:10 +01:00
1 parent 2e47c85dbe
commit f91fcf23be
4 files changed
+53 -10

No files matched your search

+13
View File
@@ -945,6 +945,19 @@ function EID:getEntityData(entity, str)
return nil return nil
end end
-- Function to fix font compatibility. Resets config font to a value compatible with your current language
function EID:fixDefinedFont()
local curLang = EID.Config["Language"]
local curFont = EID.Config["FontType"]
for _, v in ipairs(EID.descriptions[curLang].fonts) do
if curFont == v then
return false
end
end
EID.Config["FontType"] = EID.descriptions[curLang].fonts[1]
return true
end
-- Creates a copy of a KColor object. This prevents overwriting existing -- Creates a copy of a KColor object. This prevents overwriting existing
function EID:copyKColor(colorObj) function EID:copyKColor(colorObj)
return KColor(colorObj.Red, colorObj.Green, colorObj.Blue, colorObj.Alpha) return KColor(colorObj.Red, colorObj.Green, colorObj.Blue, colorObj.Alpha)
+4 -4
View File
@@ -45,7 +45,7 @@ local game = Game()
local bingeBuff = EID:getDescriptionEntry("bingeEaterBuffs", descObj.ObjSubType) local bingeBuff = EID:getDescriptionEntry("bingeEaterBuffs", descObj.ObjSubType)
if bingeBuff ~= nil then if bingeBuff ~= nil then
local iconStr = "#{{Collectible664}} " local iconStr = "#{{Collectible664}} "
EID:appendToDescription(descObj, iconStr..bingeBuff[3]:gsub("#",iconStr)) EID:appendToDescription(descObj, iconStr..bingeBuff:gsub("#",iconStr))
end end
return descObj return descObj
end end
@@ -73,7 +73,7 @@ local game = Game()
local belialBuff = EID:getDescriptionEntry("bookOfBelialBuffs", descObj.ObjSubType) local belialBuff = EID:getDescriptionEntry("bookOfBelialBuffs", descObj.ObjSubType)
if belialBuff ~= nil then if belialBuff ~= nil then
local iconStr = "#{{Collectible34}} " local iconStr = "#{{Collectible34}} "
EID:appendToDescription(descObj, iconStr..belialBuff[3]:gsub("#",iconStr)) EID:appendToDescription(descObj, iconStr..belialBuff:gsub("#",iconStr))
end end
return descObj return descObj
end end
@@ -99,7 +99,7 @@ local game = Game()
local wispType = EID:getDescriptionEntry("bookOfVirtuesWisps", descObj.ObjSubType) local wispType = EID:getDescriptionEntry("bookOfVirtuesWisps", descObj.ObjSubType)
if wispType ~= nil then if wispType ~= nil then
local iconStr = "#{{Collectible584}} " local iconStr = "#{{Collectible584}} "
EID:appendToDescription(descObj, iconStr..wispType[1]:gsub("#",iconStr)) EID:appendToDescription(descObj, iconStr..wispType:gsub("#",iconStr))
end end
return descObj return descObj
end end
@@ -171,7 +171,7 @@ local game = Game()
local clothBuff = EID:getDescriptionEntry("tarotClothBuffs", descObj.ObjSubType) local clothBuff = EID:getDescriptionEntry("tarotClothBuffs", descObj.ObjSubType)
if clothBuff ~= nil then if clothBuff ~= nil then
local iconStr = "#{{Collectible451}} " local iconStr = "#{{Collectible451}} "
EID:appendToDescription(descObj, iconStr..clothBuff[3]:gsub("#",iconStr)) EID:appendToDescription(descObj, iconStr..clothBuff:gsub("#",iconStr))
end end
return descObj return descObj
end end
+4 -1
View File
@@ -58,7 +58,6 @@ hudBBSprite:Load("gfx/eid_transform_icons.anm2", true)
hudBBSprite:Play("boundingBox") hudBBSprite:Play("boundingBox")
------- Load all modules and other stuff ------ ------- Load all modules and other stuff ------
require("mod_config_menu")
--transformation infos --transformation infos
require("descriptions."..EID.GameVersion..".transformations") require("descriptions."..EID.GameVersion..".transformations")
@@ -66,7 +65,9 @@ require("descriptions."..EID.GameVersion..".transformations")
for _,lang in ipairs(EID.Languages) do for _,lang in ipairs(EID.Languages) do
require("descriptions."..EID.GameVersion.."."..lang) require("descriptions."..EID.GameVersion.."."..lang)
end end
table.sort(EID.Languages)
require("mod_config_menu")
require("eid_data") require("eid_data")
require("eid_xmldata") require("eid_xmldata")
require("eid_api") require("eid_api")
@@ -111,6 +112,7 @@ end
EID.modPath = GetCurrentModPath() EID.modPath = GetCurrentModPath()
EID.font = Font() -- init font object EID.font = Font() -- init font object
EID:fixDefinedFont()
local fontFile = EID.Config["FontType"] or "default" local fontFile = EID.Config["FontType"] or "default"
local success = EID:loadFont(EID.modPath .. "resources/font/eid_"..fontFile..".fnt") local success = EID:loadFont(EID.modPath .. "resources/font/eid_"..fontFile..".fnt")
if not success then if not success then
@@ -959,6 +961,7 @@ if EID.MCMLoaded or REPENTANCE then
EID.isHidden = EID.Config["InitiallyHidden"] EID.isHidden = EID.Config["InitiallyHidden"]
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"]) EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
EID.Scale = EID.Config["Scale"] EID.Scale = EID.Config["Scale"]
EID:fixDefinedFont()
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt") EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
if REPENTANCE then if REPENTANCE then
EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10)) EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10))
+32 -5
View File
@@ -33,6 +33,30 @@ local function renderDummyDesc()
EID:displayPermanentText(demoDescObj) EID:displayPermanentText(demoDescObj)
end end
-- get list of all defined fonts per language file
local fonts = {}
for k, pack in pairs(EID.descriptions) do
if pack.fonts then
for _,fontToAdd in ipairs(pack.fonts) do
local exists = false
for _,font in ipairs(fonts) do
if font == fontToAdd then
exists = true
break
end
end
if not exists then
table.insert(fonts, fontToAdd)
end
end
end
end
-- get list of all defined Language names
local displayLanguage = {}
for k, lang in ipairs(EID.Languages) do
table.insert(displayLanguage, EID.descriptions[lang].languageName)
end
local function clearRenderDummyDesc() local function clearRenderDummyDesc()
if MCMCompat_oldPermanentObj == nil then if MCMCompat_oldPermanentObj == nil then
EID:hidePermanentText() EID:hidePermanentText()
@@ -182,7 +206,6 @@ if MCMLoaded then
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
---------------------------------General----------------------------------- ---------------------------------General-----------------------------------
-- Language -- Language
local displayLanguage = {"English", "English (detailed)", "French", "Portuguese (AB+)", "Portugues (Brasil)", "Russian", "Spanish", "Italian", "Bulgarian (WIP) (AB+)", "Polish", "German (WIP) (AB+)", "Turkish"}
MCM.AddSetting( MCM.AddSetting(
"EID", "EID",
"General", "General",
@@ -199,6 +222,10 @@ if MCMLoaded then
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.Config["Language"] = EID.Languages[currentNum] EID.Config["Language"] = EID.Languages[currentNum]
local isFixed = EID:fixDefinedFont()
if isFixed then
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
end
end, end,
Info = {"Changes the language.","Languages marked with (WIP) are incomplete"} Info = {"Changes the language.","Languages marked with (WIP) are incomplete"}
} }
@@ -902,23 +929,23 @@ if MCMLoaded then
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
---------------------------------Visuals----------------------------------- ---------------------------------Visuals-----------------------------------
-- Font Type -- Font Type
local fontTypes = {"default","borderless","inverted"}
MCM.AddSetting( MCM.AddSetting(
"EID", "EID",
"Visuals", "Visuals",
{ {
Type = ModConfigMenu.OptionType.NUMBER, Type = ModConfigMenu.OptionType.NUMBER,
CurrentSetting = function() CurrentSetting = function()
return AnIndexOf(fontTypes, EID.Config["FontType"]) return AnIndexOf(fonts, EID.Config["FontType"])
end, end,
Minimum = 1, Minimum = 1,
Maximum = #fontTypes, Maximum = #fonts,
Display = function() Display = function()
EID.MCMCompat_isDisplayingEIDTab = "Visuals"; EID.MCMCompat_isDisplayingEIDTab = "Visuals";
return "Font Type: " .. EID.Config["FontType"] return "Font Type: " .. EID.Config["FontType"]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.Config["FontType"] = fontTypes[currentNum] EID.Config["FontType"] = fonts[currentNum]
EID:fixDefinedFont()
local fontFile = EID.Config["FontType"] or "default" local fontFile = EID.Config["FontType"] or "default"
EID:loadFont(EID.modPath .. "resources/font/eid_"..fontFile..".fnt") EID:loadFont(EID.modPath .. "resources/font/eid_"..fontFile..".fnt")
end end