Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/Export/Classes/GGPKData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ local function scanDir(directory, extension)
return t
end

local function getDatFilePathCandidates(fname)
if fname:match("^Data/Balance/") then
return {
fname,
fname:gsub("^Data/Balance/", "Data/"),
}
end
return { fname }
end

-- Path can be in any format recognized by the extractor at oozPath, ie,
-- a .ggpk file or a Steam Path of Exile directory
local GGPKClass = newClass("GGPKData", function(self, path, datPath, reExport)
Expand Down Expand Up @@ -132,7 +142,13 @@ function GGPKClass:AddDat64Files()
for _, fname in ipairs(datFiles) do
local record = { }
record.name = fname:match("([^/\\]+)$") .. "c64"
local rawFile = io.open(self.oozPath .. fname:gsub("/", "\\") .. "c64", 'rb')
local rawFile
for _, fileName in ipairs(getDatFilePathCandidates(fname)) do
rawFile = io.open(self.oozPath .. fileName:gsub("/", "\\") .. "c64", 'rb')
if rawFile then
break
end
end
if rawFile then
record.data = rawFile:read("*all")
rawFile:close()
Expand Down
33 changes: 23 additions & 10 deletions src/Export/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ function main:Init()
self.datFileByName = { }

self:LoadSettings()
if self.datSource and self.datSource.spec then
self.datSpecs = LoadModule(self.datSource.spec)
end
self.reExportGGPKData = false
if IsKeyDown("CTRL") then
self.reExportGGPKData = true
Expand Down Expand Up @@ -373,15 +376,30 @@ function main:CanExit()
return true
end

local function getDatSpecPath(datSource)
if not datSource or not datSource.spec then
return
end
return datSource.spec..(datSource.spec:match("%.lua$") and "" or ".lua")
end

function main:SaveDatSpec(datSource)
local specPath = getDatSpecPath(datSource)
if not specPath or not self.datSpecs then
return
end
local out = io.open(specPath, "w")
out:write('return ')
writeLuaTable(out, self.datSpecs, 1)
out:close()
end

function main:LoadDatSource(value)
self.leagueLabel = nil
local reExportState = self.reExportGGPKData
self.reExportGGPKData = true
self:SaveDatSpec(self.datSource)
self.datSource = value
local out = io.open(self.datSource.spec..(self.datSource.spec:match("%.lua$") and "" or ".lua"), "w")
out:write('return ')
writeLuaTable(out, self.datSpecs, 1)
out:close()
self.datSpecs = LoadModule(self.datSource.spec)
self:InitGGPK()
if USE_DAT64 then
Expand All @@ -405,12 +423,7 @@ function main:OpenPathPopup()
end

function main:Shutdown()
if self.datSource and self.datSource.spec then
local out = io.open(self.datSource.spec, "w")
out:write('return ')
writeLuaTable(out, self.datSpecs, 1)
out:close()
end
self:SaveDatSpec(self.datSource)

self:SaveSettings()
end
Expand Down