make CTRL+F5 do a full-re-export; otherwise just load (#50)

This commit is contained in:
Nostrademous
2024-12-25 12:56:04 -05:00
committed by Wires77
parent 37751c5f37
commit f4d3727d45
2 changed files with 49 additions and 42 deletions

View File

@@ -31,14 +31,14 @@ 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)
local GGPKClass = newClass("GGPKData", function(self, path, datPath, reExport)
if datPath then
self.oozPath = datPath:match("\\$") and datPath or (datPath .. "\\")
else
self.path = path
self.oozPath = io.popen("cd"):read('*l'):gsub('\r?', '') .. "\\ggpk\\"
self:CleanDir()
self:ExtractFiles()
self:CleanDir(reExport)
self:ExtractFiles(reExport)
end
self.dat = { }
@@ -51,10 +51,12 @@ local GGPKClass = newClass("GGPKData", function(self, path, datPath)
end
end)
function GGPKClass:CleanDir()
local cmd = 'del ' .. self.oozPath .. 'Data ' .. self.oozPath .. 'Metadata /Q /S'
ConPrintf(cmd)
os.execute(cmd)
function GGPKClass:CleanDir(reExport)
if reExport then
local cmd = 'del ' .. self.oozPath .. 'Data ' .. self.oozPath .. 'Metadata /Q /S'
ConPrintf(cmd)
os.execute(cmd)
end
end
function GGPKClass:ExtractFilesWithBun(fileListStr)
@@ -63,45 +65,47 @@ function GGPKClass:ExtractFilesWithBun(fileListStr)
os.execute(cmd)
end
function GGPKClass:ExtractFiles()
local datList, txtList, itList = self:GetNeededFiles()
local sweetSpotCharacter = 6000
local fileList = ''
for _, fname in ipairs(datList) do
if USE_DAT64 then
fileList = fileList .. '"' .. fname .. 'c64" '
else
function GGPKClass:ExtractFiles(reExport)
if reExport then
local datList, txtList, itList = self:GetNeededFiles()
local sweetSpotCharacter = 6000
local fileList = ''
for _, fname in ipairs(datList) do
if USE_DAT64 then
fileList = fileList .. '"' .. fname .. 'c64" '
else
fileList = fileList .. '"' .. fname .. '" '
end
if fileList:len() > sweetSpotCharacter then
self:ExtractFilesWithBun(fileList)
fileList = ''
end
end
for _, fname in ipairs(txtList) do
fileList = fileList .. '"' .. fname .. '" '
if fileList:len() > sweetSpotCharacter then
self:ExtractFilesWithBun(fileList)
fileList = ''
end
end
if fileList:len() > sweetSpotCharacter then
for _, fname in ipairs(itList) do
fileList = fileList .. '"' .. fname .. '" '
if fileList:len() > sweetSpotCharacter then
self:ExtractFilesWithBun(fileList)
fileList = ''
end
end
if (fileList:len() > 0) then
self:ExtractFilesWithBun(fileList)
fileList = ''
end
end
for _, fname in ipairs(txtList) do
fileList = fileList .. '"' .. fname .. '" '
if fileList:len() > sweetSpotCharacter then
self:ExtractFilesWithBun(fileList)
fileList = ''
end
end
for _, fname in ipairs(itList) do
fileList = fileList .. '"' .. fname .. '" '
if fileList:len() > sweetSpotCharacter then
self:ExtractFilesWithBun(fileList)
fileList = ''
end
end
if (fileList:len() > 0) then
self:ExtractFilesWithBun(fileList)
end
-- Overwrite Enums
local errMsg = PLoadModule("Scripts/enums.lua")
if errMsg then

View File

@@ -74,7 +74,10 @@ function main:Init()
self.datFileByName = { }
self:LoadSettings()
self.reExportGGPKData = false
if IsKeyDown("CTRL") then
self.reExportGGPKData = true
end
self:InitGGPK()
if self.datSource then
if USE_DAT64 then
@@ -446,10 +449,10 @@ function main:InitGGPK()
local now = GetTime()
local ggpkPath = self.datSource.ggpkPath
if ggpkPath and ggpkPath ~= "" then
self.ggpk = new("GGPKData", ggpkPath)
self.ggpk = new("GGPKData", ggpkPath, nil, self.reExportGGPKData)
ConPrintf("GGPK: %d ms", GetTime() - now)
elseif self.datSource.datFilePath then
self.ggpk = new("GGPKData", nil, self.datSource.datFilePath)
self.ggpk = new("GGPKData", nil, self.datSource.datFilePath, self.reExportGGPKData)
ConPrintf("GGPK: %d ms", GetTime() - now)
end
end