General Exporter improvements (#8013)

* Fix Windows line ending issues

* Removed some footguns

* Final improvements
This commit is contained in:
Wires77
2024-07-29 22:50:25 -05:00
committed by GitHub
parent 0904a87704
commit 2aa03fe2dc
3 changed files with 45 additions and 20 deletions

View File

@@ -11,6 +11,7 @@ local function scanDir(directory, extension)
local t = { }
local pFile = io.popen('dir "'..directory..'" /b')
for filename in pFile:lines() do
filename = filename:gsub('\r?$', '')
--ConPrintf("%s\n", filename)
if extension then
if filename:match(extension) then
@@ -35,8 +36,8 @@ local GGPKClass = newClass("GGPKData", function(self, path, datPath)
self.oozPath = datPath:match("\\$") and datPath or (datPath .. "\\")
else
self.path = path
self.temp = io.popen("cd"):read('*l')
self.oozPath = self.temp .. "\\ggpk\\"
self.oozPath = io.popen("cd"):read('*l'):gsub('\r?', '') .. "\\ggpk\\"
self:CleanDir()
self:ExtractFiles()
end
@@ -50,6 +51,11 @@ 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)
end
function GGPKClass:ExtractFilesWithBun(fileListStr)
local cmd = 'cd ' .. self.oozPath .. ' && bun_extract_file.exe extract-files "' .. self.path .. '" . ' .. fileListStr
@@ -267,7 +273,8 @@ function GGPKClass:GetNeededFiles()
"Data/Commands.dat",
"Data/ModEquivalencies.dat",
"Data/InfluenceTags.dat",
"Data/InfluenceTypes.dat"
"Data/InfluenceTypes.dat",
"Data/leaguenames.dat"
}
local txtFiles = {
"Metadata/StatDescriptions/passive_skill_aura_stat_descriptions.txt",

View File

@@ -28,19 +28,22 @@ function GGPKSourceListClass:EditDATSource(datSource, newSource)
controls.label = new("EditControl", nil, 85, 20, 180, 20, datSource.label, nil, nil, nil, function(buf)
controls.save.enabled = (controls.dat.buf:match("%S") or controls.ggpk.buf:match("%S")) and buf:match("%S")
end)
controls.ggpkLabel = new("LabelControl", nil, 0, 40, 0, 16, "^7GGPK/Steam PoE path:")
controls.ggpkLabel = new("LabelControl", nil, 0, 40, 0, 16, "^7Source from GGPK/Steam PoE path:")
controls.ggpk = new("EditControl", {"TOP",controls.ggpkLabel,"TOP"}, 0, 20, 350, 20, datSource.ggpkPath, nil, nil, nil, function(buf)
controls.save.enabled = (buf:match("%S") or controls.dat.buf:match("%S")) and controls.label.buf:match("%S") and controls.spec.buf:match("%S")
end)
controls.datLabel = new("LabelControl", {"TOP",controls.ggpk,"TOP"}, 0, 22, 0, 16, "^7DAT File location:")
controls.ggpk.enabled = function() return not controls.dat.buf:match("%S") end
controls.datLabel = new("LabelControl", {"TOP",controls.ggpk,"TOP"}, 0, 22, 0, 16, "^7Source from DAT files:")
controls.dat = new("EditControl", {"TOP",controls.datLabel,"TOP"}, 0, 20, 350, 20, datSource.datFilePath, nil, nil, nil, function(buf)
controls.save.enabled = (buf:match("%S") or controls.ggpk.buf:match("%S")) and controls.label.buf:match("%S") and controls.spec.buf:match("%S")
end)
controls.dat.enabled = function() return not controls.ggpk.buf:match("%S") end
controls.specLabel = new("LabelControl", {"TOP",controls.dat,"TOP"}, 0, 22, 0, 16, "^7Spec File location:")
controls.spec = new("EditControl", {"TOP",controls.specLabel,"TOP"}, 0, 20, 350, 20, datSource.spec or "spec.lua", nil, nil, nil, function(buf)
controls.save.enabled = (controls.dat.buf:match("%S") or controls.ggpk.buf:match("%S")) and controls.label.buf:match("%S") and buf:match("%S")
end)
controls.save = new("ButtonControl", {"TOP",controls.spec,"TOP"}, -45, 22, 80, 20, "Save", function()
local reload = datSource.label == main.datSource.label
datSource.label = controls.label.buf
datSource.ggpkPath = controls.ggpk.buf or ""
datSource.datFilePath = controls.dat.buf or ""
@@ -50,6 +53,9 @@ function GGPKSourceListClass:EditDATSource(datSource, newSource)
self.selIndex = #self.list
self.selValue = datSource
end
if reload then
main:LoadDatSource(datSource)
end
main:ClosePopup()
end)
controls.save.enabled = false

View File

@@ -82,6 +82,9 @@ function main:Init()
else
self:LoadDatFiles()
end
if self.datFileByName["leaguenames"] then
self.leagueLabel = self.datFileByName["leaguenames"]:ReadValueText({ type = "String" }, self.datFileByName["leaguenames"].rows[2] + 8)
end
end
self.scriptList = { }
@@ -152,25 +155,15 @@ function main:Init()
self.colList = { }
self.controls.datSourceLabel = new("LabelControl", nil, 10, 10, 100, 16, "^7GGPK/Steam PoE path:")
self.controls.shownLeagueLabel = new("LabelControl", nil, 10, 10, 100, 16, "^7Data from:")
self.controls.leagueLabel = new("LabelControl", { "LEFT", self.controls.shownLeagueLabel, "RIGHT"}, 10, 0, 100, 16, function() return "^7" .. (self.leagueLabel or "Unknown") end)
self.controls.addSource = new("ButtonControl", nil, 10, 30, 100, 18, "Edit Sources...", function()
self.OpenPathPopup()
end)
self.datSources = self.datSources or { }
self.controls.datSource = new("DropDownControl", nil, 10, 50, 250, 18, self.datSources, function(_, 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.datSource = value
self.datSpecs = LoadModule(self.datSource.spec)
self:InitGGPK()
if USE_DAT64 then
self:LoadDat64Files()
else
self:LoadDatFiles()
end
self:LoadDatSource(value)
end, nil)
if self.datSource and self.datSource.label then
@@ -339,6 +332,25 @@ function main:CanExit()
return true
end
function main:LoadDatSource(value)
self.leagueLabel = nil
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.datSource = value
self.datSpecs = LoadModule(self.datSource.spec)
self:InitGGPK()
if USE_DAT64 then
self:LoadDat64Files()
else
self:LoadDatFiles()
end
if self.datFileByName["leaguenames"] then
self.leagueLabel = self.datFileByName["leaguenames"]:ReadValueText({ type = "String" }, self.datFileByName["leaguenames"].rows[2] + 8)
end
end
function main:OpenPathPopup()
main:OpenPopup(370, 290, "Manage GGPK versions", {
new("GGPKSourceListControl", nil, 0, 50, 350, 200, self),
@@ -416,8 +428,8 @@ function main:InitGGPK()
return
else
local now = GetTime()
local ggpkPath = self.datSource.ggpkPath or self.datSource.datFilePath
if ggpkPath then
local ggpkPath = self.datSource.ggpkPath
if ggpkPath and ggpkPath ~= "" then
self.ggpk = new("GGPKData", ggpkPath)
ConPrintf("GGPK: %d ms", GetTime() - now)
elseif self.datSource.datFilePath then