Fixed font loading on Linux

This commit is contained in:
Wofsauge committed 2020-11-29 01:18:33 +01:00
1 parent 182ec1e56a
commit 8a8f7d75db
1 file changed
+26 -33
+26 -33
View File
@@ -55,42 +55,35 @@ local nullVector = Vector(0,0)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
------------------------------- Load Font --------------------------------- ------------------------------- Load Font ---------------------------------
local isWindows, _ = pcall(require,"LinuxDetectionFile")
local isluadebug, os = pcall(require,"os") local isluadebug, os = pcall(require,"os")
local modfolder ='external item descriptions_836319872' --release mod folder name if isluadebug then
if isWindows then local modfolder ='external item descriptions_836319872' --release mod folder name
-- WINDOWS local userPath = os.tmpname()
if isluadebug then userPath = string.gsub(userPath, "\\", "/")
local userPath = os.tmpname() local newPath = ""
userPath = string.gsub(userPath, "\\", "/") if not string.find(userPath, "AppData") then
local newPath = "" EID.modPath = os.getenv("HOME") .. "/.local/share/binding of isaac afterbirth+ mods/"..modfolder.."/"
for str in string.gmatch(userPath, "([^/]+)") do else
if str ~="AppData" then for str in string.gmatch(userPath, "([^/]+)") do
newPath = newPath..str.."/" if str ~="AppData" then
else newPath = newPath..str.."/"
break else
end break
end end
EID.modPath = newPath.."Documents/My Games/Binding of Isaac Afterbirth+ Mods/"..modfolder.."/" end
else EID.modPath = newPath.."Documents/My Games/Binding of Isaac Afterbirth+ Mods/"..modfolder.."/"
--use some very hacky trickery to get the path to this mod end
local _, err = pcall(require, "")
local _, basePathStart = string.find(err, "no file '", 1)
local _, modPathStart = string.find(err, "no file '", basePathStart)
local modPathEnd, _ = string.find(err, ".lua'", modPathStart)
EID.modPath = string.sub(err, modPathStart + 1, modPathEnd - 1)
end
EID.modPath = string.gsub(EID.modPath, "\\", "/")
EID.modPath = string.gsub(EID.modPath, ":/", ":\\")
else else
-- LINUX - Special thanks to jerb for providing these! --use some very hacky trickery to get the path to this mod
if isluadebug then local _, err = pcall(require, "")
EID.modPath = os.getenv("HOME") .. "/.local/share/binding of isaac afterbirth+ mods/"..modfolder.."/" local _, basePathStart = string.find(err, "no file '", 1)
else local _, modPathStart = string.find(err, "no file '", basePathStart)
-- only work if installed in the default location local modPathEnd, _ = string.find(err, ".lua'", modPathStart)
EID.modPath = "../../../../../.local/share/binding of isaac afterbirth+ mods/"..modfolder.."/" EID.modPath = string.sub(err, modPathStart + 1, modPathEnd - 1)
end
end end
EID.modPath = string.gsub(EID.modPath, "\\", "/")
EID.modPath = string.gsub(EID.modPath, "//", "/")
EID.modPath = string.gsub(EID.modPath, ":/", ":\\")
EID.font = Font() -- init font object EID.font = Font() -- init font object
local fontFile = EID.Config["FontType"] or "default" local fontFile = EID.Config["FontType"] or "default"