Skip to content
Merged
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
3 changes: 3 additions & 0 deletions src/Classes/BuildListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ local s_format = string.format
---@class BuildListControl: ListControl
local BuildListClass = newClass("BuildListControl", "ListControl")

---@param anchor Anchor?
---@param rect Rect?
---@param listMode any
function BuildListClass:BuildListControl(anchor, rect, listMode)
self:ListControl(anchor, rect, 20, "VERTICAL", false, listMode.list)
self.listMode = listMode
Expand Down
1 change: 1 addition & 0 deletions src/Classes/CalcBreakdownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local band = AND64 -- bit.band
---@class CalcBreakdownControl: Control, ControlHost
local CalcBreakdownClass = newClass("CalcBreakdownControl", "Control", "ControlHost")

---@param calcsTab CalcsTab
function CalcBreakdownClass:CalcBreakdownControl(calcsTab)
self:Control()
self:ControlHost()
Expand Down
9 changes: 8 additions & 1 deletion src/Classes/CalcSectionControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ local t_insert = table.insert
---@class CalcSectionControl: Control, ControlHost
local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost")

---@param calcsTab CalcsTab
---@param width any
---@param id any
---@param group any
---@param colour any
---@param subSection any
---@param updateFunc any
function CalcSectionClass:CalcSectionControl(calcsTab, width, id, group, colour, subSection, updateFunc)
self:Control(calcsTab, {0, 0, width, 0})
self:Control(nil, {0, 0, width, 0})
self:ControlHost()
self.calcsTab = calcsTab
self.id = id
Expand Down
10 changes: 3 additions & 7 deletions src/Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ function CalcsTabClass:BuildOutput()
end

-- Retrieve calculator functions
self.nodeCalculator = { self.calcs.getNodeCalculator(self.build) }
self.miscCalculator = { self.calcs.getMiscCalculator(self.build) }
local miscCalcFunc, miscCalcBase = self.calcs.getMiscCalculator(self.build)
self.miscCalculator = { miscCalcFunc, miscCalcBase }
end

-- Controls the coroutine that calculates node power
Expand Down Expand Up @@ -702,12 +702,8 @@ function CalcsTabClass:CalculateCombinedOffDefStat(original, modified)
return dpsIncr / modifiedDps, defence
end

function CalcsTabClass:GetNodeCalculator()
return unpack(self.nodeCalculator)
end

function CalcsTabClass:GetMiscCalculator()
return unpack(self.miscCalculator)
return self.miscCalculator[1], self.miscCalculator[2]
end

function CalcsTabClass:CreateUndoState()
Expand Down
9 changes: 9 additions & 0 deletions src/Classes/CompareCalcsHelpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ function M.FormatCalcModName(modName)
end

-- Resolve a modifier's source to a human-readable name
---@param mod Mod
---@param build Build
function M.ResolveSourceName(mod, build)
if not mod.source then return "" end
local sourceType = mod.source:match("[^:]+") or ""
Expand Down Expand Up @@ -138,6 +140,8 @@ function M.FormatModRow(row, sectionData, build)
end

-- Get breakdown text lines for a build's actor
---@param sectionData any
---@param build Build
function M.GetBreakdownLines(sectionData, build)
if not sectionData.breakdown then return nil end
local calcsActor = build.calcsTab and build.calcsTab.calcsEnv and build.calcsTab.calcsEnv.player
Expand All @@ -164,6 +168,8 @@ end

-- Draw the calcs hover tooltip showing breakdown for both builds with common/unique grouping
-- tooltip, primaryBuild, primaryLabel passed as args instead of self
---@param tooltip Tooltip
---@param primaryBuild Build
function M.DrawCalcsTooltip(tooltip, primaryBuild, primaryLabel, colData, rowLabel, rowX, rowY, rowW, rowH, vp, compareEntry)
if tooltip:CheckForUpdate(colData, rowLabel) then
-- Get calcsEnv actors (these have breakdown data populated)
Expand Down Expand Up @@ -318,6 +324,8 @@ function M.DrawCalcsTooltip(tooltip, primaryBuild, primaryLabel, colData, rowLab
end

-- Resolve a modifier's source name for breakdown panel display
---@param mod Mod
---@param build Build
local function resolveModSource(mod, build)
local sourceType = mod.source and mod.source:match("[^:]+") or "?"
local sourceName = ""
Expand Down Expand Up @@ -352,6 +360,7 @@ local function resolveModSource(mod, build)
end

-- Draw a breakdown panel for a single build's SkillBuffs or SkillDebuffs,
---@param build Build
function M.DrawSkillBreakdownPanel(build, breakdownKey, label, cellX, cellY, cellW, cellH, vp)
local player = build.calcsTab and build.calcsTab.calcsEnv
and build.calcsTab.calcsEnv.player
Expand Down
10 changes: 5 additions & 5 deletions src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ local s_upper = string.upper
local varList = require("Modules.ConfigOptions")
local configModBrowser = require("Modules.ConfigModBrowser")

---@class CustomModBlockControl : Control, ControlHost
local CustomModBlockClass = newClass("CustomModBlockControl", "Control", "ControlHost")
---@class CustomModBlockControl: ControlHost, Control
local CustomModBlockClass = newClass("CustomModBlockControl", "ControlHost", "Control")

---@param anchor Anchor
---@param rect Rect
---@param anchor Anchor?
---@param rect Rect?
---@param configTab ConfigTab
---@param blockIndex any
---@param blockIndex integer
---@param blockData any
function CustomModBlockClass:CustomModBlockControl(anchor, rect, configTab, blockIndex, blockData)
self:Control(anchor, rect)
Expand Down
12 changes: 11 additions & 1 deletion src/Classes/Control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
local t_insert = table.insert
local m_floor = math.floor

---@enum (key) AnchorPoint
local anchorPos = {
["TOPLEFT"] = { 0 , 0 },
["TOP"] = { 0.5, 0 },
Expand Down Expand Up @@ -39,10 +40,19 @@ local rect = {
---@field shown Prop<boolean>
---@field x Prop<number>?
---@field y Prop<number>?
---@field width Prop<number>?
---@field height Prop<number>?
---@field collapseY number? An additional offset which is applied when this control uses a collapsed anchor.
---@field collapseX number? An additional offset which is applied when this control uses a collapsed anchor.
local ControlClass = newClass("Control")

---@generic T
---@alias Prop<T> (fun(self: self): T) | T
---@alias Anchor [AnchorPoint, Control|ControlHost|nil, AnchorPoint, boolean|nil]
---@alias Rect [Prop<number>?,Prop<number>?, Prop<number>?, Prop<number>?]

---@param anchor? Anchor
---@param rect? Rect
function ControlClass:Control(anchor, rect)
self.rectStart = rect or {0, 0, 0, 0}
self.x, self.y, self.width, self.height = unpack(self.rectStart)
Expand Down Expand Up @@ -160,4 +170,4 @@ function ControlClass:TabAdvance(step)
end
end
return self
end
end
6 changes: 6 additions & 0 deletions src/Classes/GemSelectControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ local toolTipText = "Prefix tag searches with a colon and exclude tags with a da
---@class GemSelectControl: EditControl
local GemSelectClass = newClass("GemSelectControl", "EditControl")

---@param anchor Anchor?
---@param rect Rect?
---@param skillsTab SkillsTab
---@param index integer
---@param changeFunc fun(...)
---@param forceTooltip boolean
function GemSelectClass:GemSelectControl(anchor, rect, skillsTab, index, changeFunc, forceTooltip)
self:EditControl(anchor, rect, nil, nil, "^ %a':-")
self.controls.scrollBar = new("ScrollBarControl"):ScrollBarControl({ "TOPRIGHT", self, "TOPRIGHT" }, { -1, 0, 18, 0 }, (self.height - 4) * 4)
Expand Down
9 changes: 9 additions & 0 deletions src/Classes/ItemDBControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ local m_floor = math.floor
---@class ItemDBControl: ListControl
local ItemDBClass = newClass("ItemDBControl", "ListControl")

---@class ItemDBData
---@field list table<string, Item>
---@field loading boolean?

---@param anchor Anchor?
---@param rect Rect?
---@param itemsTab ItemsTab
---@param db ItemDBData
---@param dbType "RARE"|"UNIQUE"
function ItemDBClass:ItemDBControl(anchor, rect, itemsTab, db, dbType)
self:ListControl(anchor, rect, 16, "VERTICAL", false)
self.itemsTab = itemsTab
Expand Down
4 changes: 4 additions & 0 deletions src/Classes/ItemListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ local t_insert = table.insert
---@class ItemListControl: ListControl
local ItemListClass = newClass("ItemListControl", "ListControl")

---@param anchor Anchor?
---@param rect Rect?
---@param itemsTab ItemsTab
---@param forceTooltip boolean?
function ItemListClass:ItemListControl(anchor, rect, itemsTab, forceTooltip)
self:ListControl(anchor, rect, 16, "VERTICAL", true, itemsTab.itemOrderList, forceTooltip)
self.itemsTab = itemsTab
Expand Down
7 changes: 7 additions & 0 deletions src/Classes/ItemSlotControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ local BuildExportPoE2 = LoadModule("Modules/BuildExportPoE2")
---@class ItemSlotControl: DropDownControl
local ItemSlotClass = newClass("ItemSlotControl", "DropDownControl")

---@param anchor Anchor?
---@param x Prop<number>
---@param y Prop<number>
---@param itemsTab ItemsTab
---@param slotName string
---@param slotLabel? string
---@param nodeId integer?
function ItemSlotClass:ItemSlotControl(anchor, x, y, itemsTab, slotName, slotLabel, nodeId)
self:DropDownControl(anchor, {x, y, 310, 20}, { }, function(index, value)
if self.items[index] ~= self.selItemId then
Expand Down
5 changes: 4 additions & 1 deletion src/Classes/LabelControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
---@class LabelControl: Control
local LabelClass = newClass("LabelControl", "Control")

---@param anchor? Anchor
---@param rect? Rect
---@param label? Prop<string>
function LabelClass:LabelControl(anchor, rect, label)
self:Control(anchor, rect)
self.label = label
Expand All @@ -18,4 +21,4 @@ end
function LabelClass:Draw()
local x, y = self:GetPos()
DrawString(x, y, "LEFT", self:GetProperty("height"), "VAR", self:GetProperty("label"))
end
end
10 changes: 9 additions & 1 deletion src/Classes/ListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ local m_min = math.min
local m_max = math.max
local m_floor = math.floor

---@class ListControl: Control, ControlHost
---@class ListControl<T>: Control, ControlHost
---@field list T[]
local ListClass = newClass("ListControl", "Control", "ControlHost")

---@param anchor Anchor?
---@param rect Rect?
---@param rowHeight number
---@param scroll "HORIZONTAL"|"VERTICAL"|boolean|nil
---@param isMutable boolean?
---@param list any[]?
---@param forceTooltip? any
function ListClass:ListControl(anchor, rect, rowHeight, scroll, isMutable, list, forceTooltip)
self:Control(anchor, rect)
self:ControlHost()
Expand Down
38 changes: 38 additions & 0 deletions src/Classes/ModStore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ local conditionName = setmetatable({ }, { __index = function(t, var)
return t[var]
end })

-- TODO: very incomplete
---@class ModCfg
---@field flags number? bit mask
---@field keywordFlags number?
---@field skillName string?
---@field source string?
---@class ModStore
local ModStoreClass = newClass("ModStore")

Expand Down Expand Up @@ -154,6 +160,10 @@ function ModStoreClass:Combine(modType, cfg, ...)
end
end

---@param modType string
---@param cfg? ModCfg
---@param ... string
---@return number
function ModStoreClass:Sum(modType, cfg, ...)
local flags, keywordFlags = 0, 0
local source
Expand Down Expand Up @@ -200,6 +210,9 @@ function ModStoreClass:SumNegativeValues(modType, cfg, modName, ...)
return total
end

---@param cfg? ModCfg
---@param ... string
---@return number
function ModStoreClass:More(cfg, ...)
local flags, keywordFlags = 0, 0
local source
Expand All @@ -222,6 +235,9 @@ function ModStoreClass:Flag(cfg, ...)
return self:FlagInternal(self, cfg, flags, keywordFlags, source, ...)
end

---@param cfg? ModCfg
---@param ... string
---@return any
function ModStoreClass:Override(cfg, ...)
local flags, keywordFlags = 0, 0
local source
Expand All @@ -233,6 +249,9 @@ function ModStoreClass:Override(cfg, ...)
return self:OverrideInternal(self, cfg, flags, keywordFlags, source, ...)
end

---@param cfg? ModCfg
---@param ... string
---@return any[]
function ModStoreClass:List(cfg, ...)
local flags, keywordFlags = 0, 0
local source
Expand All @@ -246,6 +265,10 @@ function ModStoreClass:List(cfg, ...)
return result
end

---@param modType string
---@param cfg? ModCfg
---@param ... string
---@return table[]
function ModStoreClass:Tabulate(modType, cfg, ...)
local flags, keywordFlags = 0, 0
local source
Expand Down Expand Up @@ -289,6 +312,10 @@ function ModStoreClass:HasMod(modType, cfg, ...)
return self:HasModInternal(modType, flags, keywordFlags, source, ...)
end

---@param var string
---@param cfg? ModCfg
---@param noMod? boolean
---@return boolean
function ModStoreClass:GetCondition(var, cfg, noMod)
if (cfg and cfg.overrideCond and cfg.overrideCond[var] ~= nil) then
return cfg.overrideCond[var]
Expand All @@ -297,10 +324,17 @@ function ModStoreClass:GetCondition(var, cfg, noMod)
end
end

---@param var string
---@param cfg? ModCfg
---@param noMod? boolean
---@return number
function ModStoreClass:GetMultiplier(var, cfg, noMod)
return (not noMod and self:Override(cfg, multiplierName[var])) or (self.multipliers[var] or 0) + (self.parent and self.parent:GetMultiplier(var, cfg, true) or 0) + (not noMod and self:Sum("BASE", cfg, multiplierName[var]) or 0)
end

---@param stat string
---@param cfg? ModCfg
---@return number
function ModStoreClass:GetStat(stat, cfg)
if stat == "ManaReservedPercent" then
local reservedPercentMana = 0
Expand Down Expand Up @@ -346,6 +380,10 @@ function ModStoreClass:GetStat(stat, cfg)
end
end

---@param mod Mod
---@param cfg? ModCfg
---@param globalLimits? table
---@return any
function ModStoreClass:EvalMod(mod, cfg, globalLimits)
local value = mod.value
local GetStat = self.GetStat
Expand Down
1 change: 1 addition & 0 deletions src/Classes/NotableDBControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ end
---@class NotableDBControl: ListControl
local NotableDBClass = newClass("NotableDBControl", "ListControl")

---@param itemsTab ItemsTab
function NotableDBClass:NotableDBControl(anchor, rect, itemsTab, db, dbType)
local headerHeight = 96
local innerRect = {rect[1], rect[2]+headerHeight, rect[3], rect[4]-headerHeight}
Expand Down
12 changes: 11 additions & 1 deletion src/Classes/PassiveMasteryControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ local m_floor = math.floor
---@class PassiveMasteryControl: ListControl
local PassiveMasteryControlClass = newClass("PassiveMasteryControl", "ListControl")

---@class MasterListElem
---@field label string
---@field id number

---@param anchor Anchor?
---@param rect Rect
---@param list MasterListElem[]
---@param treeTab TreeTab
---@param node Node
---@param saveButton ButtonControl
function PassiveMasteryControlClass:PassiveMasteryControl(anchor, rect, list, treeTab, node, saveButton)
self.list = list or { }
-- automagical width
for j=1,#list do
rect[3] = m_max(rect[3], DrawStringWidth(16, "VAR", list[j].label) + 5)
end
self:ListControl(anchor, rect, 16, false, false, self.list)
self:ListControl(anchor, rect, 16, nil, false, self.list)
self.treeTab = treeTab
self.treeView = treeTab.viewer
self.node = node
Expand Down
Loading
Loading