Merge branch 'wofsauge:master' into master

This commit is contained in:
wakaba (aka. 미카) authored and GitHub committed 2022-02-09 02:12:04 +09:00
commit 21ad281d54
6 files changed
+111 -56

No files matched your search

+30 -15
View File
@@ -364,9 +364,9 @@ end
-- 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)
if not objID then if not objID then
return EID.descriptions[EID.Config["Language"]][objTable] or EID.descriptions["en_us"][objTable] return EID.descriptions[EID:getLanguage()][objTable] or EID.descriptions["en_us"][objTable]
else else
local translatedTable = EID.descriptions[EID.Config["Language"]][objTable] local translatedTable = EID.descriptions[EID:getLanguage()][objTable]
if noFallback then return translatedTable and translatedTable[objID] if noFallback then return translatedTable and translatedTable[objID]
else return (translatedTable and translatedTable[objID]) or (EID.descriptions["en_us"][objTable] and EID.descriptions["en_us"][objTable][objID]) end else return (translatedTable and translatedTable[objID]) or (EID.descriptions["en_us"][objTable] and EID.descriptions["en_us"][objTable][objID]) end
end end
@@ -404,8 +404,8 @@ function EID:getAdjustedSubtype(Type, Variant, SubType)
return 9999 return 9999
end end
local pool = game:GetItemPool() local pool = game:GetItemPool()
if REPENTANCE and EID.player.SubType == PlayerType.PLAYER_THESOUL_B then if REPENTANCE and EID.player:GetPlayerType() == PlayerType.PLAYER_THESOUL_B then
SubType = pool:GetPillEffect(SubType, EID.player:GetOtherTwin()) + 1 SubType = pool:GetPillEffect(SubType, EID.player:GetOtherTwin() or EID.player) + 1
else SubType = pool:GetPillEffect(SubType, EID.player) + 1 end else SubType = pool:GetPillEffect(SubType, EID.player) + 1 end
end end
return SubType return SubType
@@ -450,7 +450,7 @@ function EID:getTransformationName(id)
-- get translated custom name -- get translated custom name
local customTransform = EID.CustomTransformations[id] local customTransform = EID.CustomTransformations[id]
if customTransform ~= nil then if customTransform ~= nil then
return customTransform[EID.Config["Language"]] or customTransform["en_us"] or id return customTransform[EID:getLanguage()] or customTransform["en_us"] or id
end end
return id return id
end end
@@ -742,6 +742,19 @@ function EID:filterColorMarkup(text, baseKColor)
return textPartsTable return textPartsTable
end end
-- A simple function to replace all markup {{ }} with placeholder strings, to use in fitTextToWidth
function EID:replaceAllMarkupWithSpaces(text)
for word in string.gmatch(text, "{{.-}}") do
local lookup = EID:getIcon(word)
if lookup[1] ~= "ERROR" then
text = string.gsub(text, word, EID:generatePlaceholderString(lookup[3]), 1)
else
text = string.gsub(text, word, "", 1)
end
end
return text
end
-- Fits a given string to a specific width -- Fits a given string to a specific width
-- returns the string as a table of lines -- returns the string as a table of lines
function EID:fitTextToWidth(str, textboxWidth, breakUtf8Chars) function EID:fitTextToWidth(str, textboxWidth, breakUtf8Chars)
@@ -815,14 +828,8 @@ function EID:fitTextToWidth(str, textboxWidth, breakUtf8Chars)
-- we can break after str[cursor] -- we can break after str[cursor]
local word = sub(str, word_begin_index, cursor) local word = sub(str, word_begin_index, cursor)
local wordFiltered = EID:replaceAllMarkupWithSpaces(word)
local colorFiltered = EID:filterColorMarkup(word, EID:getTextColor()) local wordLength = EID:getStrWidth(wordFiltered)
local filteredWord = {}
for _, filtered in ipairs(colorFiltered) do
table.insert(filteredWord, filtered[1])
end
local strFiltered, spriteTable = EID:filterIconMarkup(table.concat(filteredWord), 0, 0)
local wordLength = EID:getStrWidth(strFiltered)
if curLength + wordLength <= textboxWidth or curLength < 17 then if curLength + wordLength <= textboxWidth or curLength < 17 then
table.insert(text, word) table.insert(text, word)
@@ -1210,7 +1217,7 @@ end
-- Function to fix font compatibility. Resets config font to a value compatible with your current language -- Function to fix font compatibility. Resets config font to a value compatible with your current language
function EID:fixDefinedFont() function EID:fixDefinedFont()
local curLang = EID.Config["Language"] local curLang = EID:getLanguage()
local curFont = EID.Config["FontType"] local curFont = EID.Config["FontType"]
for _, v in ipairs(EID.descriptions[curLang].fonts) do for _, v in ipairs(EID.descriptions[curLang].fonts) do
if curFont == v.name then if curFont == v.name then
@@ -1224,7 +1231,7 @@ function EID:fixDefinedFont()
end end
-- Check if a given font name is valid for the currently selected language -- Check if a given font name is valid for the currently selected language
function EID:canUseFontType(fontType) function EID:canUseFontType(fontType)
local curLang = EID.Config["Language"] local curLang = EID:getLanguage()
for _, v in ipairs(EID.descriptions[curLang].fonts) do for _, v in ipairs(EID.descriptions[curLang].fonts) do
if fontType == v.name then if fontType == v.name then
return true return true
@@ -1313,3 +1320,11 @@ function EID:checkPlayersForMissingItems()
end end
end end
end end
function EID:getLanguage()
local lang = EID.Config["Language"]
if lang == "auto" then
return Options and EID.LanguageMap[Options.Language] or "en_us"
end
return lang
end
+2 -2
View File
@@ -514,7 +514,7 @@ local moddedCrafting = false
-- Only works if the new items are at Weight 1.0 in their item pools, but better than nothing -- Only works if the new items are at Weight 1.0 in their item pools, but better than nothing
local function GameStartCrafting() local function GameStartCrafting()
if EID.Config["BagOfCraftingModdedRecipes"] and not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) and EID.itemConfig:GetCollectible(EID.XMLMaxItemID+1) ~= nil then if EID.Config["BagOfCraftingModdedRecipes"] and not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) and EID.itemConfig:GetCollectible(EID.XMLMaxItemID+1) ~= nil then
dofile("eid_xmldata") dofile(EID.modPath .. "eid_xmldata.lua")
-- Items past max ID detected -- Items past max ID detected
CraftingMaxItemID = EID.XMLMaxItemID -- XMLMaxItemID is never modified CraftingMaxItemID = EID.XMLMaxItemID -- XMLMaxItemID is never modified
-- Add new item qualities -- Add new item qualities
@@ -542,7 +542,7 @@ local function GameStartCrafting()
sortNeeded = true sortNeeded = true
elseif moddedCrafting then elseif moddedCrafting then
-- we had modded items; they have since been disabled -- we had modded items; they have since been disabled
dofile("eid_xmldata") dofile(EID.modPath .. "eid_xmldata.lua")
moddedCrafting = false moddedCrafting = false
sortNeeded = true sortNeeded = true
end end
+4 -3
View File
@@ -1,7 +1,8 @@
EID.UserConfig = { EID.UserConfig = {
-------GENERAL--------- -------GENERAL---------
-- Change the language of the mod -- Change the language of the mod
-- Currently Supported: English = "en_us" (Default), "en_us_detailed" (More detailed descriptions) -- Currently Supported: auto = "auto" (Default) Same as Options->Language(Rep), or English(ab+)
-- English = "en_us", "en_us_detailed" (More detailed descriptions)
-- French = "fr" SPECIAL THANKS TO Nicolas Delvaux -- French = "fr" SPECIAL THANKS TO Nicolas Delvaux
-- Polish = "pl" SPECIAL THANKS TO Rickyy -- Polish = "pl" SPECIAL THANKS TO Rickyy
-- Spanish = "spa" SPECIAL THANKS TO Lidia Arroyo Purroy -- Spanish = "spa" SPECIAL THANKS TO Lidia Arroyo Purroy
@@ -16,7 +17,7 @@ EID.UserConfig = {
-- --
-- If you want to make a translation, please contact me :) (wofsauge) -- If you want to make a translation, please contact me :) (wofsauge)
-- --
["Language"] = "en_us", ["Language"] = "auto",
-- Change if item names should be displayed in English, your translated language or both -- Change if item names should be displayed in English, your translated language or both
-- States: 1 = English , 2 = translated, 3 = both -- States: 1 = English , 2 = translated, 3 = both
-- Default = 2 -- Default = 2
@@ -374,7 +375,7 @@ EID.UserConfig = {
-------------------------------------------------- --------------------------------------------------
EID.DefaultConfig = { EID.DefaultConfig = {
["Language"] = "en_us", ["Language"] = "auto",
["TranslateItemName"] = 2, ["TranslateItemName"] = 2,
["FontType"] = "default", ["FontType"] = "default",
["TextboxWidth"] = 130, ["TextboxWidth"] = 130,
+7
View File
@@ -516,3 +516,10 @@ EID.GoldenTrinketData = {
EID.BreakUtf8CharsLanguage = { EID.BreakUtf8CharsLanguage = {
['zh_cn'] = true ['zh_cn'] = true
} }
EID.LanguageMap = {
["ru"] = "ru",
["de"] = "de",
["kr"] = "ko_kr",
["zh"] = "zh_cn",
}
+53 -32
View File
@@ -366,6 +366,7 @@ if REPENTANCE then
-- Watch for a Void absorbing active items -- Watch for a Void absorbing active items
-- (Note: Doesn't differentiate between different players if both players have Void...) -- (Note: Doesn't differentiate between different players if both players have Void...)
-- (Note: Doesn't care about shop / choice items yet either)
function EID:CheckVoidAbsorbs(collectibleType) function EID:CheckVoidAbsorbs(collectibleType)
local pedestals = Isaac.FindByType(5, 100, -1, true, false) local pedestals = Isaac.FindByType(5, 100, -1, true, false)
for _, pedestal in ipairs(pedestals) do for _, pedestal in ipairs(pedestals) do
@@ -509,8 +510,8 @@ function EID:printDescription(desc)
end end
--Display ItemType / Charge --Display ItemType / Charge
local itemType = -1 local itemType = -1
if tonumber(desc.ObjSubType) ~= nil and desc.ObjType == 5 and desc.ObjVariant == 100 then if desc.ObjSubType ~= nil and desc.ObjType == 5 and desc.ObjVariant == 100 then
itemType = EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Type or -1 itemType = EID.itemConfig:GetCollectible(desc.ObjSubType).Type or -1
end end
if EID.Config["ShowItemType"] and (itemType == 3 or itemType == 4) then if EID.Config["ShowItemType"] and (itemType == 3 or itemType == 4) then
local offsetY = 2 local offsetY = 2
@@ -538,7 +539,7 @@ function EID:printDescription(desc)
local curName = desc.Name local curName = desc.Name
if EID.Config["TranslateItemName"] ~= 2 then if EID.Config["TranslateItemName"] ~= 2 then
local curLanguage = EID.Config["Language"] local curLanguage = EID.Config["Language"]
if curLanguage ~= "en_us" then if EID:getLanguage() ~= "en_us" then
EID.Config["Language"] = "en_us" EID.Config["Language"] = "en_us"
local englishName = desc.PermanentTextEnglish or EID:getObjectName(desc.ObjType, desc.ObjVariant, desc.ObjSubType) local englishName = desc.PermanentTextEnglish or EID:getObjectName(desc.ObjType, desc.ObjVariant, desc.ObjSubType)
EID.Config["Language"] = curLanguage EID.Config["Language"] = curLanguage
@@ -612,7 +613,7 @@ function EID:printBulletPoints(description, renderPos)
local textScale = Vector(EID.Scale, EID.Scale) local textScale = Vector(EID.Scale, EID.Scale)
description = EID:replaceShortMarkupStrings(description) description = EID:replaceShortMarkupStrings(description)
for line in string.gmatch(description, "([^#]+)") do for line in string.gmatch(description, "([^#]+)") do
local formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID.Config["Language"]]) local formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID:getLanguage()])
local textColor = EID:getTextColor() local textColor = EID:getTextColor()
for i, lineToPrint in ipairs(formatedLines) do for i, lineToPrint in ipairs(formatedLines) do
-- render bulletpoint -- render bulletpoint
@@ -806,8 +807,8 @@ end
function EID:setPlayer() function EID:setPlayer()
local p = Isaac.GetPlayer(0) local p = Isaac.GetPlayer(0)
if REPENTANCE and p.SubType == PlayerType.PLAYER_THEFORGOTTEN_B then if REPENTANCE and p:GetPlayerType() == PlayerType.PLAYER_THEFORGOTTEN_B then
EID.player = p:GetOtherTwin() EID.player = p:GetOtherTwin() or p
else else
EID.player = p EID.player = p
end end
@@ -928,6 +929,51 @@ local function checkStartOfRunWarnings()
end end
end end
-- Check our position modifiers based on HUD offset and character choice
local function checkPosModifiers()
-- HUD offset adjustment, done every frame so it looks nice while changing the option
if Options then
EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10))
else
EID:addTextPosModifier("HudOffset", Vector((EID.Config["HUDOffset"] * 2) - 20, EID.Config["HUDOffset"] - 10))
end
-- the other modifiers don't need to be ran as frequently
if EID.GameRenderCount % 30 ~= 0 then return end
-- Greed Mode small right adjustment
if game:IsGreedMode() then
EID:addTextPosModifier("Greed Mode Horizontal", Vector(8,0))
else
EID:removeTextPosModifier("Greed Mode Horizontal")
end
if not REPENTANCE then
-- AB+ Schoolbag adjustment
if EID.player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG) then
EID:addTextPosModifier("Schoolbag", Vector(0,30))
else
EID:removeTextPosModifier("Schoolbag")
end
else
-- Tainted Isaac and Tainted ??? unique HUD adjustment
if EID.player:GetPlayerType() == 21 or EID.player:GetPlayerType() == 25 then
EID:addTextPosModifier("Tainted HUD", Vector(0,30))
else
EID:removeTextPosModifier("Tainted HUD")
end
-- Jacob and Esau card/pill adjustment
if EID.player:GetPlayerType() == 19 then
EID:addTextPosModifier("J&E HUD", Vector(0,15))
else
EID:removeTextPosModifier("J&E HUD")
end
-- Magdalene Birthright third row of hearts adjustment
if EID.player:GetPlayerType() == 1 and EID.player:HasCollectible(619) then
EID:addTextPosModifier("18 Heart HUD", Vector(0,5))
else
EID:removeTextPosModifier("18 Heart HUD")
end
end
end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
---------------------------On Render Function------------------------------ ---------------------------On Render Function------------------------------
@@ -963,29 +1009,9 @@ local function onRender(t)
end end
checkStartOfRunWarnings() checkStartOfRunWarnings()
checkPosModifiers()
EID:renderMCMDummyDescription() EID:renderMCMDummyDescription()
if EID.GameVersion == "ab+" then
if EID.player:HasCollectible(CollectibleType.COLLECTIBLE_SCHOOLBAG) then
EID:addTextPosModifier("Schoolbag", Vector(0,30))
else
EID:removeTextPosModifier("Schoolbag")
end
else
-- Tainted Isaac and Tainted ???
if EID.player.SubType == 21 or EID.player.SubType == 25 then
EID:addTextPosModifier("Tained HUD", Vector(0,30))
else
EID:removeTextPosModifier("Tained HUD")
end
-- Magdalene Birthright
if EID.player.SubType == 1 and EID.player:HasCollectible(619) then
EID:addTextPosModifier("18 Heart HUD", Vector(0,5))
else
EID:removeTextPosModifier("18 Heart HUD")
end
end
if EID.isHidden then if EID.isHidden then
return return
elseif EID.Config["HideInBattle"] then elseif EID.Config["HideInBattle"] then
@@ -1299,11 +1325,6 @@ if EID.MCMLoaded or REPENTANCE then
EID:fixDefinedFont() 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
EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10))
else
EID:addTextPosModifier("HudOffset", Vector((EID.Config["HUDOffset"] * 2) - 20, EID.Config["HUDOffset"] - 10))
end
end end
end end
end end
+15 -4
View File
@@ -76,15 +76,14 @@ end
function EID:renderMCMDummyDescription() function EID:renderMCMDummyDescription()
if MCMLoaded then if MCMLoaded then
if not Options then
local hudOffset = ModConfigMenu.Config["General"].HudOffset local hudOffset = ModConfigMenu.Config["General"].HudOffset
if hudOffset == nil and ScreenHelper then if hudOffset == nil and ScreenHelper then
hudOffset = ScreenHelper.GetOffset() hudOffset = ScreenHelper.GetOffset()
end end
if REPENTANCE and Options then
hudOffset = (Options.HUDOffset * 10)
end
EID.Config["HUDOffset"] = hudOffset EID.Config["HUDOffset"] = hudOffset
EID:addTextPosModifier("HudOffset", Vector((hudOffset * 2) - 20, hudOffset - 10)) EID:addTextPosModifier("HudOffset", Vector((hudOffset * 2) - 20, hudOffset - 10))
end
if MCM.IsVisible and EID.MCMCompat_isDisplayingEIDTab ~= "" then if MCM.IsVisible and EID.MCMCompat_isDisplayingEIDTab ~= "" then
if EID.MCMCompat_isDisplayingEIDTab == "Mouse" and EID.Config["EnableMouseControls"] then if EID.MCMCompat_isDisplayingEIDTab == "Mouse" and EID.Config["EnableMouseControls"] then
clearRenderDummyDesc() clearRenderDummyDesc()
@@ -280,18 +279,30 @@ if MCMLoaded then
{ {
Type = ModConfigMenu.OptionType.NUMBER, Type = ModConfigMenu.OptionType.NUMBER,
CurrentSetting = function() CurrentSetting = function()
if EID.Config["Language"] == "auto" then
return #(EID.Languages) + 1
else
return AnIndexOf(EID.Languages, EID.Config["Language"]) return AnIndexOf(EID.Languages, EID.Config["Language"])
end
end, end,
Minimum = 1, Minimum = 1,
Maximum = #(EID.Languages), Maximum = #(EID.Languages) + 1, -- add "auto" language
Display = function() Display = function()
EID.MCMCompat_isDisplayingEIDTab = "Visuals" EID.MCMCompat_isDisplayingEIDTab = "Visuals"
if EID.Config["Language"] == "auto" then
return "Language: auto(" .. displayLanguage[AnIndexOf(EID.Languages, EID:getLanguage())] .. ")"
else
return "Language: " .. displayLanguage[AnIndexOf(EID.Languages, EID.Config["Language"])] return "Language: " .. displayLanguage[AnIndexOf(EID.Languages, EID.Config["Language"])]
end
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true EID.MCM_OptionChanged = true
EID.RefreshBagTextbox = true -- Crafting isn't open so it won't notice MCM_OptionChanged, but definitely needs to refresh EID.RefreshBagTextbox = true -- Crafting isn't open so it won't notice MCM_OptionChanged, but definitely needs to refresh
if currentNum == #(EID.Languages) + 1 then
EID.Config["Language"] = "auto"
else
EID.Config["Language"] = EID.Languages[currentNum] EID.Config["Language"] = EID.Languages[currentNum]
end
local isFixed = EID:fixDefinedFont() local isFixed = EID:fixDefinedFont()
if isFixed then if isFixed then
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt") EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")