Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change controls to take a packed "rect" instead of x, y, width, height #6873

Merged
merged 10 commits into from
Sep 8, 2024
14 changes: 7 additions & 7 deletions src/Classes/BuildListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
local ipairs = ipairs
local s_format = string.format

local BuildListClass = newClass("BuildListControl", "ListControl", function(self, anchor, x, y, width, height, listMode)
self.ListControl(anchor, x, y, width, height, 20, "VERTICAL", false, listMode.list)
local BuildListClass = newClass("BuildListControl", "ListControl", function(self, anchor, rect, listMode)
self.ListControl(anchor, rect, 20, "VERTICAL", false, listMode.list)
self.listMode = listMode
self.colList = {
{ width = function() return self:GetProperty("width") - 172 end },
{ },
}
self.showRowSeparators = true
self.controls.path = new("PathControl", {"BOTTOM",self,"TOP"}, 0, -2, width, 24, main.buildPath, listMode.subPath, function(subPath)
self.controls.path = new("PathControl", {"BOTTOM",self,"TOP"}, {0, -2, self.width, 24}, main.buildPath, listMode.subPath, function(subPath)
listMode.subPath = subPath
listMode:BuildList()
self.selIndex = nil
Expand Down Expand Up @@ -74,8 +74,8 @@ end

function BuildListClass:RenameBuild(build, copyOnName)
local controls = { }
controls.label = new("LabelControl", nil, 0, 20, 0, 16, "^7Enter the new name for this "..(build.folderName and "folder:" or "build:"))
controls.edit = new("EditControl", nil, 0, 40, 350, 20, build.folderName or build.buildName, nil, "\\/:%*%?\"<>|%c", 100, function(buf)
controls.label = new("LabelControl", nil, {0, 20, 0, 16}, "^7Enter the new name for this "..(build.folderName and "folder:" or "build:"))
controls.edit = new("EditControl", nil, {0, 40, 350, 20}, build.folderName or build.buildName, nil, "\\/:%*%?\"<>|%c", 100, function(buf)
controls.save.enabled = false
if build.folderName then
if buf:match("%S") then
Expand All @@ -97,7 +97,7 @@ function BuildListClass:RenameBuild(build, copyOnName)
end
end
end)
controls.save = new("ButtonControl", nil, -45, 70, 80, 20, "Save", function()
controls.save = new("ButtonControl", nil, {-45, 70, 80, 20}, "Save", function()
local newBuildName = controls.edit.buf
if build.folderName then
if copyOnName then
Expand Down Expand Up @@ -132,7 +132,7 @@ function BuildListClass:RenameBuild(build, copyOnName)
self.listMode:SelectControl(self)
end)
controls.save.enabled = false
controls.cancel = new("ButtonControl", nil, 45, 70, 80, 20, "Cancel", function()
controls.cancel = new("ButtonControl", nil, {45, 70, 80, 20}, "Cancel", function()
main:ClosePopup()
self.listMode:SelectControl(self)
end)
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/ButtonControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
-- Class: Button Control
-- Basic button control.
--
local ButtonClass = newClass("ButtonControl", "Control", "TooltipHost", function(self, anchor, x, y, width, height, label, onClick, onHover, forceTooltip)
self.Control(anchor, x, y, width, height)
local ButtonClass = newClass("ButtonControl", "Control", "TooltipHost", function(self, anchor, rect, label, onClick, onHover, forceTooltip)
self.Control(anchor, rect)
self.TooltipHost()
self.label = label
self.onClick = onClick
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/CalcBreakdownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ local CalcBreakdownClass = newClass("CalcBreakdownControl", "Control", "ControlH
self.rangeGuide:Load("Assets/range_guide.png")
self.uiOverlay = NewImageHandle()
self.uiOverlay:Load("Assets/game_ui_small.png")
self.controls.scrollBar = new("ScrollBarControl", {"RIGHT",self,"RIGHT"}, -2, 0, 18, 0, 80, "VERTICAL", true)
self.controls.scrollBar = new("ScrollBarControl", {"RIGHT",self,"RIGHT"}, {-2, 0, 18, 0}, 80, "VERTICAL", true)
end)

function CalcBreakdownClass:IsMouseOver()
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/CalcSectionControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
local t_insert = table.insert

local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost", function(self, calcsTab, width, id, group, colour, subSection, updateFunc)
self.Control(calcsTab, 0, 0, width, 0)
self.Control(calcsTab, {0, 0, width, 0})
self.ControlHost()
self.calcsTab = calcsTab
self.id = id
Expand All @@ -33,7 +33,7 @@ local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost"
end
end
subSec.collapsed = subSec.defaultCollapsed
self.controls["toggle"..i] = new("ButtonControl", {"TOPRIGHT",self,"TOPRIGHT"}, -3, -13 + (16 * i), 16, 16, function()
self.controls["toggle"..i] = new("ButtonControl", {"TOPRIGHT",self,"TOPRIGHT"}, {-3, -13 + (16 * i), 16, 16}, function()
return subSec.collapsed and "+" or "-"
end, function()
subSec.collapsed = not subSec.collapsed
Expand Down
24 changes: 12 additions & 12 deletions src/Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
self.colWidth = 230
self.sectionList = { }

self.controls.search = new("EditControl", {"TOPLEFT",self,"TOPLEFT"}, 4, 5, 260, 20, "", "Search", "%c", 100, nil, nil, nil, true)
self.controls.search = new("EditControl", {"TOPLEFT",self,"TOPLEFT"}, {4, 5, 260, 20}, "", "Search", "%c", 100, nil, nil, nil, true)
t_insert(self.controls, self.controls.search)

-- Special section for skill/mode selection
self:NewSection(3, "SkillSelect", 1, colorCodes.NORMAL, {{ defaultCollapsed = false, label = "View Skill Details", data = {
{ label = "Socket Group", { controlName = "mainSocketGroup",
control = new("DropDownControl", nil, 0, 0, 300, 16, nil, function(index, value)
control = new("DropDownControl", nil, {0, 0, 300, 16}, nil, function(index, value)
self.input.skill_number = index
self:AddUndoState()
self.build.buildFlag = true
Expand All @@ -52,22 +52,22 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
}
}, },
{ label = "Active Skill", { controlName = "mainSkill",
control = new("DropDownControl", nil, 0, 0, 300, 16, nil, function(index, value)
control = new("DropDownControl", nil, {0, 0, 300, 16}, nil, function(index, value)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
mainSocketGroup.mainActiveSkillCalcs = index
self.build.buildFlag = true
end)
}, },
{ label = "Skill Part", playerFlag = "multiPart", { controlName = "mainSkillPart",
control = new("DropDownControl", nil, 0, 0, 250, 16, nil, function(index, value)
control = new("DropDownControl", nil, {0, 0, 250, 16}, nil, function(index, value)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
srcInstance.skillPartCalcs = index
self:AddUndoState()
self.build.buildFlag = true
end)
}, },{ label = "Skill Stages", playerFlag = "multiStage", { controlName = "mainSkillStageCount",
control = new("EditControl", nil, 0, 0, 52, 16, nil, nil, "%D", nil, function(buf)
control = new("EditControl", nil, {0, 0, 52, 16}, nil, nil, "%D", nil, function(buf)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
srcInstance.skillStageCountCalcs = tonumber(buf)
Expand All @@ -76,7 +76,7 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
end)
}, },
{ label = "Active Mines", playerFlag = "mine", { controlName = "mainSkillMineCount",
control = new("EditControl", nil, 0, 0, 52, 16, nil, nil, "%D", nil, function(buf)
control = new("EditControl", nil, {0, 0, 52, 16}, nil, nil, "%D", nil, function(buf)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
srcInstance.skillMineCountCalcs = tonumber(buf)
Expand All @@ -85,13 +85,13 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
end)
}, },
{ label = "Show Minion Stats", flag = "haveMinion", { controlName = "showMinion",
control = new("CheckBoxControl", nil, 0, 0, 18, nil, function(state)
control = new("CheckBoxControl", nil, {0, 0, 18}, nil, function(state)
self.input.showMinion = state
self:AddUndoState()
end, "Show stats for the minion instead of the player.")
}, },
{ label = "Minion", flag = "minion", { controlName = "mainSkillMinion",
control = new("DropDownControl", nil, 0, 0, 160, 16, nil, function(index, value)
control = new("DropDownControl", nil, {0, 0, 160, 16}, nil, function(index, value)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
if value.itemSetId then
Expand All @@ -104,12 +104,12 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
end)
} },
{ label = "Spectre Library", flag = "spectre", { controlName = "mainSkillMinionLibrary",
control = new("ButtonControl", nil, 0, 0, 100, 16, "Manage Spectres...", function()
control = new("ButtonControl", nil, {0, 0, 100, 16}, "Manage Spectres...", function()
self.build:OpenSpectreLibrary()
end)
} },
{ label = "Minion Skill", flag = "haveMinion", { controlName = "mainSkillMinionSkill",
control = new("DropDownControl", nil, 0, 0, 200, 16, nil, function(index, value)
control = new("DropDownControl", nil, {0, 0, 200, 16}, nil, function(index, value)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
srcInstance.skillMinionSkillCalcs = index
Expand All @@ -119,7 +119,7 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
} },
{ label = "Calculation Mode", {
controlName = "mode",
control = new("DropDownControl", nil, 0, 0, 100, 16, buffModeDropList, function(index, value)
control = new("DropDownControl", nil, {0, 0, 100, 16}, buffModeDropList, function(index, value)
self.input.misc_buffMode = value.buffMode
self:AddUndoState()
self.build.buildFlag = true
Expand Down Expand Up @@ -149,7 +149,7 @@ Effective DPS: Curses and enemy properties (such as resistances and status condi

self.controls.breakdown = new("CalcBreakdownControl", self)

self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT",self,"TOPRIGHT"}, 0, 0, 18, 0, 50, "VERTICAL", true)
self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT",self,"TOPRIGHT"}, {0, 0, 18, 0}, 50, "VERTICAL", true)
self.powerBuilderInitialized = nil
end)

Expand Down
7 changes: 4 additions & 3 deletions src/Classes/CheckBoxControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
-- Class: Check Box Control
-- Basic check box control.
--
local CheckBoxClass = newClass("CheckBoxControl", "Control", "TooltipHost", function(self, anchor, x, y, size, label, changeFunc, tooltipText, initialState)
self.Control(anchor, x, y, size, size)
local CheckBoxClass = newClass("CheckBoxControl", "Control", "TooltipHost", function(self, anchor, rect, label, changeFunc, tooltipText, initialState)
rect[4] = rect[3] or 0
self.Control(anchor, rect)
self.TooltipHost(tooltipText)
self.label = label
self.labelWidth = DrawStringWidth(size - 4, "VAR", label or "") + 5
self.labelWidth = DrawStringWidth(self.width - 4, "VAR", label or "") + 5
self.changeFunc = changeFunc
self.state = initialState
end)
Expand Down
20 changes: 10 additions & 10 deletions src/Classes/ConfigSetListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ local t_insert = table.insert
local t_remove = table.remove
local m_max = math.max

local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", function(self, anchor, x, y, width, height, configTab)
self.ListControl(anchor, x, y, width, height, 16, "VERTICAL", true, configTab.configSetOrderList)
local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", function(self, anchor, rect, configTab)
self.ListControl(anchor, rect, 16, "VERTICAL", true, configTab.configSetOrderList)
self.configTab = configTab
self.controls.copy = new("ButtonControl", {"BOTTOMLEFT",self,"TOP"}, 2, -4, 60, 18, "Copy", function()
self.controls.copy = new("ButtonControl", {"BOTTOMLEFT",self,"TOP"}, {2, -4, 60, 18}, "Copy", function()
local configSet = configTab.configSets[self.selValue]
local newConfigSet = copyTable(configSet)
newConfigSet.id = 1
Expand All @@ -23,30 +23,30 @@ local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", funct
self.controls.copy.enabled = function()
return self.selValue ~= nil
end
self.controls.delete = new("ButtonControl", {"LEFT",self.controls.copy,"RIGHT"}, 4, 0, 60, 18, "Delete", function()
self.controls.delete = new("ButtonControl", {"LEFT",self.controls.copy,"RIGHT"}, {4, 0, 60, 18}, "Delete", function()
self:OnSelDelete(self.selIndex, self.selValue)
end)
self.controls.delete.enabled = function()
return self.selValue ~= nil and #self.list > 1
end
self.controls.rename = new("ButtonControl", {"BOTTOMRIGHT",self,"TOP"}, -2, -4, 60, 18, "Rename", function()
self.controls.rename = new("ButtonControl", {"BOTTOMRIGHT",self,"TOP"}, {-2, -4, 60, 18}, "Rename", function()
self:RenameSet(configTab.configSets[self.selValue])
end)
self.controls.rename.enabled = function()
return self.selValue ~= nil
end
self.controls.new = new("ButtonControl", {"RIGHT",self.controls.rename,"LEFT"}, -4, 0, 60, 18, "New", function()
self.controls.new = new("ButtonControl", {"RIGHT",self.controls.rename,"LEFT"}, {-4, 0, 60, 18}, "New", function()
self:RenameSet(configTab:NewConfigSet(), true)
end)
end)

function ConfigSetListClass:RenameSet(configSet, addOnName)
local controls = { }
controls.label = new("LabelControl", nil, 0, 20, 0, 16, "^7Enter name for this config set:")
controls.edit = new("EditControl", nil, 0, 40, 350, 20, configSet.title, nil, nil, 100, function(buf)
controls.label = new("LabelControl", nil, {0, 20, 0, 16}, "^7Enter name for this config set:")
controls.edit = new("EditControl", nil, {0, 40, 350, 20}, configSet.title, nil, nil, 100, function(buf)
controls.save.enabled = buf:match("%S")
end)
controls.save = new("ButtonControl", nil, -45, 70, 80, 20, "Save", function()
controls.save = new("ButtonControl", nil, {-45, 70, 80, 20}, "Save", function()
configSet.title = controls.edit.buf
self.configTab.modFlag = true
if addOnName then
Expand All @@ -59,7 +59,7 @@ function ConfigSetListClass:RenameSet(configSet, addOnName)
main:ClosePopup()
end)
controls.save.enabled = false
controls.cancel = new("ButtonControl", nil, 45, 70, 80, 20, "Cancel", function()
controls.cancel = new("ButtonControl", nil, {45, 70, 80, 20}, "Cancel", function()
if addOnName then
self.configTab.configSets[configSet.id] = nil
end
Expand Down
Loading
Loading