Skip to content

Commit

Permalink
QoL Enums Data file was added, Trade Data relative was added (#7275)
Browse files Browse the repository at this point in the history
* QoL Enums Data file was added, Trade Data relative was added

* COmmentas was added, Unused variable was removed

* Method was renamed

* Tooltips was added

* Enum indentation was fixed

* Enum indentation was fixed v2

---------

Co-authored-by: justjuangui <[email protected]>
  • Loading branch information
justjuangui and justjuangui authored Jul 21, 2024
1 parent 4d9e848 commit b2f5081
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/Export/Classes/Dat64File.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,13 @@ function Dat64FileClass:ReadValueText(spec, offset)
end
local other = main.datFileByName[spec.refTo:lower()]
if other then
local otherRow = other.rows[val + ((spec.type == "Enum" and spec.refTo:lower() ~= self.name) and 0 or 1)]
local newVal = val + ((spec.type == "Enum" and spec.refTo:lower() ~= self.name) and 0 or 1)
if (spec.enumBase and spec.enumBase > 0) then
newVal = newVal + spec.enumBase
end
local otherRow = other.rows[newVal]
if not otherRow then
return "<bad ref #"..val..">"
return "<bad ref #"..newVal..">"
end
if other.spec[1] then
return other:ReadValueText(other.spec[1], otherRow)
Expand Down
16 changes: 16 additions & 0 deletions src/Export/Classes/GGPKData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ function GGPKClass:ExtractFiles()
local cmd = 'cd ' .. self.oozPath .. ' && bun_extract_file.exe extract-files "' .. self.path .. '" . ' .. fileList
ConPrintf(cmd)
os.execute(cmd)

-- Overwrite Enums
local errMsg = PLoadModule("Scripts/enums.lua")
if errMsg then
print(errMsg)
end
end

function GGPKClass:AddDatFiles()
Expand Down Expand Up @@ -228,6 +234,16 @@ function GGPKClass:GetNeededFiles()
"Data/weaponclasses.dat",
"Data/monsterconditions.dat",
"Data/rarity.dat",
"Data/trademarketcategory.dat",
"Data/trademarketcategorygroups.dat",
"Data/PlayerTradeWhisperFormats.dat",
"Data/TradeMarketCategoryListAllClass.dat",
"Data/TradeMarketIndexItemAs.dat",
"Data/TradeMarketImplicitModDisplay.dat",
"Data/Commands.dat",
"Data/ModEquivalencies.dat",
"Data/InfluenceTags.dat",
"Data/InfluenceTypes.dat"
}
local txtFiles = {
"Metadata/StatDescriptions/passive_skill_aura_stat_descriptions.txt",
Expand Down
33 changes: 30 additions & 3 deletions src/Export/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,18 @@ function main:Init()
end) {
shown = function()
return self.curSpecCol
end,
tooltipFunc = function(tooltip)
tooltip:Clear()
tooltip:AddLine(16, "^7Field name in the dat file")
end
}

self.controls.colType = new("DropDownControl", {"TOPLEFT",self.controls.colName,"BOTTOMLEFT"}, 0, 4, 90, 18, self.typeDrop, function(_, value)
self.curSpecCol.type = value
self.curDatFile:OnSpecChanged()
self:UpdateCol()
end)
end, "^7Field type in the dat file")

self.controls.colIsList = new("CheckBoxControl", {"TOPLEFT",self.controls.colType,"BOTTOMLEFT"}, 30, 4, 18, "List:", function(state)
self.curSpecCol.list = state
Expand All @@ -253,12 +257,34 @@ function main:Init()
self.controls.colRefTo = new("EditControl", {"TOPLEFT",self.controls.colType,"BOTTOMLEFT"}, 0, 26, 150, 18, nil, nil, nil, nil, function(buf)
self.curSpecCol.refTo = buf
self.curDatFile:OnSpecChanged()
end)
end) {
tooltipFunc = function(tooltip)
tooltip:Clear()
tooltip:AddLine(16, "^7Reference to another dat file")
end
}

self.controls.colWidth = new("EditControl", {"TOPLEFT",self.controls.colRefTo,"BOTTOMLEFT"}, 0, 4, 100, 18, nil, nil, "%D", nil, function(buf)
self.curSpecCol.width = m_max(tonumber(buf) or 150, 20)
self.controls.rowList:BuildColumns()
end) { numberInc = 10 }
end) {
numberInc = 10,
tooltipFunc = function(tooltip)
tooltip:Clear()
tooltip:AddLine(16, "^7Column width in the grid")
end
}

self.controls.enumBase = new("EditControl", {"TOPLEFT",self.controls.colWidth,"BOTTOMLEFT"}, 0, 4, 100, 18, nil, nil, "%D", nil, function(buf)
self.curSpecCol.enumBase = tonumber(buf) or 0
self.curDatFile:OnSpecChanged()
end) {
numberInc = 1,
tooltipFunc = function(tooltip)
tooltip:Clear()
tooltip:AddLine(16, "^7Base value for enum types")
end
}

self.controls.colDelete = new("ButtonControl", {"BOTTOMRIGHT",self.controls.colName,"TOPRIGHT"}, 0, -4, 18, 18, "x", function()
t_remove(self.curDatFile.spec, self.curSpecColIndex)
Expand Down Expand Up @@ -468,6 +494,7 @@ function main:UpdateCol()
self.controls.colRefTo.enabled = self.curDatFile.cols[self.curSpecColIndex].isRef
self.controls.colRefTo:SetText(self.curSpecCol.refTo)
self.controls.colWidth:SetText(self.curSpecCol.width)
self.controls.enumBase:SetText(self.curSpecCol.enumBase or 0)
self.controls.rowList:BuildColumns()
end

Expand Down
69 changes: 69 additions & 0 deletions src/Export/Scripts/enums.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
local band = bit.band
local rshift = bit.rshift
local push = table.insert
local schar = string.char

local function writeNum(n, c)
local bytes = {}
for i = 1, c do
push(bytes, schar(band(n, 0xFF)))
n = rshift(n, 8)
end
return table.concat(bytes)
end

function len(t)
local count = 0
for _ in pairs(t) do count = count + 1 end
return count
end

local function writeEnum(filename, enumTable)
local filenameAbs = "./ggpk/data/" .. filename
local out = io.open(filenameAbs, "wb")
local size = len(enumTable)

out:write(writeNum(size,4))

-- Write fields
local stringIndex = 8
for v, s in ipairs(enumTable) do
out:write(writeNum(stringIndex,8))
local utf16 = convertUTF8to16(s)
stringIndex = stringIndex + utf16:len() + 2
end

-- data offset mark
for i = 1, 8 do
out:write(schar(0xBB))
end

-- strings in utf16
for _, s in ipairs(enumTable) do
out:write(convertUTF8to16(s) .. "\0\0")
end

out:close()
print("Wrote " .. size .. " enum types to " .. filename)
end


-- influenced types
local influenceTypes = {
"Shaper",
"Elder",
"Crusader",
"Eyrie",
"Basilisk",
"Adjudicator",
"None"
}

writeEnum("influenceTypes.dat64", influenceTypes)

-- passive Skills types
local passiveSkillTypes = {
"Passive Tree",
"Atlas Tree"
}
writeEnum("passiveSkillTypes.dat64", passiveSkillTypes)
Loading

0 comments on commit b2f5081

Please sign in to comment.