Skip to content

Commit 356c29c

Browse files
RegisleWires77
andauthored
Change controls to take a packed "rect" instead of x, y, width, height (#6873)
* change controls to take a packed "rect" instead of x, y, width, height * Fix bad merge * Add missing box notation * fix merge issues and update new controls to use packed rect * update export * fix white space * fix spelling mistake * fix more merge issues --------- Co-authored-by: Wires77 <Wires77@users.noreply.github.com>
1 parent 5667a34 commit 356c29c

59 files changed

Lines changed: 867 additions & 852 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Classes/BuildListControl.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
local ipairs = ipairs
77
local s_format = string.format
88

9-
local BuildListClass = newClass("BuildListControl", "ListControl", function(self, anchor, x, y, width, height, listMode)
10-
self.ListControl(anchor, x, y, width, height, 20, "VERTICAL", false, listMode.list)
9+
local BuildListClass = newClass("BuildListControl", "ListControl", function(self, anchor, rect, listMode)
10+
self.ListControl(anchor, rect, 20, "VERTICAL", false, listMode.list)
1111
self.listMode = listMode
1212
self.colList = {
1313
{ width = function() return self:GetProperty("width") - 172 end },
1414
{ },
1515
}
1616
self.showRowSeparators = true
17-
self.controls.path = new("PathControl", {"BOTTOM",self,"TOP"}, 0, -2, width, 24, main.buildPath, listMode.subPath, function(subPath)
17+
self.controls.path = new("PathControl", {"BOTTOM",self,"TOP"}, {0, -2, self.width, 24}, main.buildPath, listMode.subPath, function(subPath)
1818
listMode.subPath = subPath
1919
listMode:BuildList()
2020
self.selIndex = nil
@@ -74,8 +74,8 @@ end
7474

7575
function BuildListClass:RenameBuild(build, copyOnName)
7676
local controls = { }
77-
controls.label = new("LabelControl", nil, 0, 20, 0, 16, "^7Enter the new name for this "..(build.folderName and "folder:" or "build:"))
78-
controls.edit = new("EditControl", nil, 0, 40, 350, 20, build.folderName or build.buildName, nil, "\\/:%*%?\"<>|%c", 100, function(buf)
77+
controls.label = new("LabelControl", nil, {0, 20, 0, 16}, "^7Enter the new name for this "..(build.folderName and "folder:" or "build:"))
78+
controls.edit = new("EditControl", nil, {0, 40, 350, 20}, build.folderName or build.buildName, nil, "\\/:%*%?\"<>|%c", 100, function(buf)
7979
controls.save.enabled = false
8080
if build.folderName then
8181
if buf:match("%S") then
@@ -97,7 +97,7 @@ function BuildListClass:RenameBuild(build, copyOnName)
9797
end
9898
end
9999
end)
100-
controls.save = new("ButtonControl", nil, -45, 70, 80, 20, "Save", function()
100+
controls.save = new("ButtonControl", nil, {-45, 70, 80, 20}, "Save", function()
101101
local newBuildName = controls.edit.buf
102102
if build.folderName then
103103
if copyOnName then
@@ -132,7 +132,7 @@ function BuildListClass:RenameBuild(build, copyOnName)
132132
self.listMode:SelectControl(self)
133133
end)
134134
controls.save.enabled = false
135-
controls.cancel = new("ButtonControl", nil, 45, 70, 80, 20, "Cancel", function()
135+
controls.cancel = new("ButtonControl", nil, {45, 70, 80, 20}, "Cancel", function()
136136
main:ClosePopup()
137137
self.listMode:SelectControl(self)
138138
end)

src/Classes/ButtonControl.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
-- Class: Button Control
44
-- Basic button control.
55
--
6-
local ButtonClass = newClass("ButtonControl", "Control", "TooltipHost", function(self, anchor, x, y, width, height, label, onClick, onHover, forceTooltip)
7-
self.Control(anchor, x, y, width, height)
6+
local ButtonClass = newClass("ButtonControl", "Control", "TooltipHost", function(self, anchor, rect, label, onClick, onHover, forceTooltip)
7+
self.Control(anchor, rect)
88
self.TooltipHost()
99
self.label = label
1010
self.onClick = onClick

src/Classes/CalcBreakdownControl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ local CalcBreakdownClass = newClass("CalcBreakdownControl", "Control", "ControlH
2424
self.rangeGuide:Load("Assets/range_guide.png")
2525
self.uiOverlay = NewImageHandle()
2626
self.uiOverlay:Load("Assets/game_ui_small.png")
27-
self.controls.scrollBar = new("ScrollBarControl", {"RIGHT",self,"RIGHT"}, -2, 0, 18, 0, 80, "VERTICAL", true)
27+
self.controls.scrollBar = new("ScrollBarControl", {"RIGHT",self,"RIGHT"}, {-2, 0, 18, 0}, 80, "VERTICAL", true)
2828
end)
2929

3030
function CalcBreakdownClass:IsMouseOver()

src/Classes/CalcSectionControl.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
local t_insert = table.insert
77

88
local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost", function(self, calcsTab, width, id, group, colour, subSection, updateFunc)
9-
self.Control(calcsTab, 0, 0, width, 0)
9+
self.Control(calcsTab, {0, 0, width, 0})
1010
self.ControlHost()
1111
self.calcsTab = calcsTab
1212
self.id = id
@@ -33,7 +33,7 @@ local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost"
3333
end
3434
end
3535
subSec.collapsed = subSec.defaultCollapsed
36-
self.controls["toggle"..i] = new("ButtonControl", {"TOPRIGHT",self,"TOPRIGHT"}, -3, -13 + (16 * i), 16, 16, function()
36+
self.controls["toggle"..i] = new("ButtonControl", {"TOPRIGHT",self,"TOPRIGHT"}, {-3, -13 + (16 * i), 16, 16}, function()
3737
return subSec.collapsed and "+" or "-"
3838
end, function()
3939
subSec.collapsed = not subSec.collapsed

src/Classes/CalcsTab.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
3232
self.colWidth = 230
3333
self.sectionList = { }
3434

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

3838
-- Special section for skill/mode selection
3939
self:NewSection(3, "SkillSelect", 1, colorCodes.NORMAL, {{ defaultCollapsed = false, label = "View Skill Details", data = {
4040
{ label = "Socket Group", { controlName = "mainSocketGroup",
41-
control = new("DropDownControl", nil, 0, 0, 300, 16, nil, function(index, value)
41+
control = new("DropDownControl", nil, {0, 0, 300, 16}, nil, function(index, value)
4242
self.input.skill_number = index
4343
self:AddUndoState()
4444
self.build.buildFlag = true
@@ -52,22 +52,22 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
5252
}
5353
}, },
5454
{ label = "Active Skill", { controlName = "mainSkill",
55-
control = new("DropDownControl", nil, 0, 0, 300, 16, nil, function(index, value)
55+
control = new("DropDownControl", nil, {0, 0, 300, 16}, nil, function(index, value)
5656
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
5757
mainSocketGroup.mainActiveSkillCalcs = index
5858
self.build.buildFlag = true
5959
end)
6060
}, },
6161
{ label = "Skill Part", playerFlag = "multiPart", { controlName = "mainSkillPart",
62-
control = new("DropDownControl", nil, 0, 0, 250, 16, nil, function(index, value)
62+
control = new("DropDownControl", nil, {0, 0, 250, 16}, nil, function(index, value)
6363
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
6464
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
6565
srcInstance.skillPartCalcs = index
6666
self:AddUndoState()
6767
self.build.buildFlag = true
6868
end)
6969
}, },{ label = "Skill Stages", playerFlag = "multiStage", { controlName = "mainSkillStageCount",
70-
control = new("EditControl", nil, 0, 0, 52, 16, nil, nil, "%D", nil, function(buf)
70+
control = new("EditControl", nil, {0, 0, 52, 16}, nil, nil, "%D", nil, function(buf)
7171
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
7272
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
7373
srcInstance.skillStageCountCalcs = tonumber(buf)
@@ -76,7 +76,7 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
7676
end)
7777
}, },
7878
{ label = "Active Mines", playerFlag = "mine", { controlName = "mainSkillMineCount",
79-
control = new("EditControl", nil, 0, 0, 52, 16, nil, nil, "%D", nil, function(buf)
79+
control = new("EditControl", nil, {0, 0, 52, 16}, nil, nil, "%D", nil, function(buf)
8080
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
8181
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
8282
srcInstance.skillMineCountCalcs = tonumber(buf)
@@ -85,13 +85,13 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
8585
end)
8686
}, },
8787
{ label = "Show Minion Stats", flag = "haveMinion", { controlName = "showMinion",
88-
control = new("CheckBoxControl", nil, 0, 0, 18, nil, function(state)
88+
control = new("CheckBoxControl", nil, {0, 0, 18}, nil, function(state)
8989
self.input.showMinion = state
9090
self:AddUndoState()
9191
end, "Show stats for the minion instead of the player.")
9292
}, },
9393
{ label = "Minion", flag = "minion", { controlName = "mainSkillMinion",
94-
control = new("DropDownControl", nil, 0, 0, 160, 16, nil, function(index, value)
94+
control = new("DropDownControl", nil, {0, 0, 160, 16}, nil, function(index, value)
9595
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
9696
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
9797
if value.itemSetId then
@@ -104,12 +104,12 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
104104
end)
105105
} },
106106
{ label = "Spectre Library", flag = "spectre", { controlName = "mainSkillMinionLibrary",
107-
control = new("ButtonControl", nil, 0, 0, 100, 16, "Manage Spectres...", function()
107+
control = new("ButtonControl", nil, {0, 0, 100, 16}, "Manage Spectres...", function()
108108
self.build:OpenSpectreLibrary()
109109
end)
110110
} },
111111
{ label = "Minion Skill", flag = "haveMinion", { controlName = "mainSkillMinionSkill",
112-
control = new("DropDownControl", nil, 0, 0, 200, 16, nil, function(index, value)
112+
control = new("DropDownControl", nil, {0, 0, 200, 16}, nil, function(index, value)
113113
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
114114
local srcInstance = mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeEffect.srcInstance
115115
srcInstance.skillMinionSkillCalcs = index
@@ -119,7 +119,7 @@ local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Contro
119119
} },
120120
{ label = "Calculation Mode", {
121121
controlName = "mode",
122-
control = new("DropDownControl", nil, 0, 0, 100, 16, buffModeDropList, function(index, value)
122+
control = new("DropDownControl", nil, {0, 0, 100, 16}, buffModeDropList, function(index, value)
123123
self.input.misc_buffMode = value.buffMode
124124
self:AddUndoState()
125125
self.build.buildFlag = true
@@ -149,7 +149,7 @@ Effective DPS: Curses and enemy properties (such as resistances and status condi
149149

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

152-
self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT",self,"TOPRIGHT"}, 0, 0, 18, 0, 50, "VERTICAL", true)
152+
self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT",self,"TOPRIGHT"}, {0, 0, 18, 0}, 50, "VERTICAL", true)
153153
self.powerBuilderInitialized = nil
154154
end)
155155

src/Classes/CheckBoxControl.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
-- Class: Check Box Control
44
-- Basic check box control.
55
--
6-
local CheckBoxClass = newClass("CheckBoxControl", "Control", "TooltipHost", function(self, anchor, x, y, size, label, changeFunc, tooltipText, initialState)
7-
self.Control(anchor, x, y, size, size)
6+
local CheckBoxClass = newClass("CheckBoxControl", "Control", "TooltipHost", function(self, anchor, rect, label, changeFunc, tooltipText, initialState)
7+
rect[4] = rect[3] or 0
8+
self.Control(anchor, rect)
89
self.TooltipHost(tooltipText)
910
self.label = label
10-
self.labelWidth = DrawStringWidth(size - 4, "VAR", label or "") + 5
11+
self.labelWidth = DrawStringWidth(self.width - 4, "VAR", label or "") + 5
1112
self.changeFunc = changeFunc
1213
self.state = initialState
1314
end)

src/Classes/ConfigSetListControl.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ local t_insert = table.insert
77
local t_remove = table.remove
88
local m_max = math.max
99

10-
local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", function(self, anchor, x, y, width, height, configTab)
11-
self.ListControl(anchor, x, y, width, height, 16, "VERTICAL", true, configTab.configSetOrderList)
10+
local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", function(self, anchor, rect, configTab)
11+
self.ListControl(anchor, rect, 16, "VERTICAL", true, configTab.configSetOrderList)
1212
self.configTab = configTab
13-
self.controls.copy = new("ButtonControl", {"BOTTOMLEFT",self,"TOP"}, 2, -4, 60, 18, "Copy", function()
13+
self.controls.copy = new("ButtonControl", {"BOTTOMLEFT",self,"TOP"}, {2, -4, 60, 18}, "Copy", function()
1414
local configSet = configTab.configSets[self.selValue]
1515
local newConfigSet = copyTable(configSet)
1616
newConfigSet.id = 1
@@ -23,30 +23,30 @@ local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", funct
2323
self.controls.copy.enabled = function()
2424
return self.selValue ~= nil
2525
end
26-
self.controls.delete = new("ButtonControl", {"LEFT",self.controls.copy,"RIGHT"}, 4, 0, 60, 18, "Delete", function()
26+
self.controls.delete = new("ButtonControl", {"LEFT",self.controls.copy,"RIGHT"}, {4, 0, 60, 18}, "Delete", function()
2727
self:OnSelDelete(self.selIndex, self.selValue)
2828
end)
2929
self.controls.delete.enabled = function()
3030
return self.selValue ~= nil and #self.list > 1
3131
end
32-
self.controls.rename = new("ButtonControl", {"BOTTOMRIGHT",self,"TOP"}, -2, -4, 60, 18, "Rename", function()
32+
self.controls.rename = new("ButtonControl", {"BOTTOMRIGHT",self,"TOP"}, {-2, -4, 60, 18}, "Rename", function()
3333
self:RenameSet(configTab.configSets[self.selValue])
3434
end)
3535
self.controls.rename.enabled = function()
3636
return self.selValue ~= nil
3737
end
38-
self.controls.new = new("ButtonControl", {"RIGHT",self.controls.rename,"LEFT"}, -4, 0, 60, 18, "New", function()
38+
self.controls.new = new("ButtonControl", {"RIGHT",self.controls.rename,"LEFT"}, {-4, 0, 60, 18}, "New", function()
3939
self:RenameSet(configTab:NewConfigSet(), true)
4040
end)
4141
end)
4242

4343
function ConfigSetListClass:RenameSet(configSet, addOnName)
4444
local controls = { }
45-
controls.label = new("LabelControl", nil, 0, 20, 0, 16, "^7Enter name for this config set:")
46-
controls.edit = new("EditControl", nil, 0, 40, 350, 20, configSet.title, nil, nil, 100, function(buf)
45+
controls.label = new("LabelControl", nil, {0, 20, 0, 16}, "^7Enter name for this config set:")
46+
controls.edit = new("EditControl", nil, {0, 40, 350, 20}, configSet.title, nil, nil, 100, function(buf)
4747
controls.save.enabled = buf:match("%S")
4848
end)
49-
controls.save = new("ButtonControl", nil, -45, 70, 80, 20, "Save", function()
49+
controls.save = new("ButtonControl", nil, {-45, 70, 80, 20}, "Save", function()
5050
configSet.title = controls.edit.buf
5151
self.configTab.modFlag = true
5252
if addOnName then
@@ -59,7 +59,7 @@ function ConfigSetListClass:RenameSet(configSet, addOnName)
5959
main:ClosePopup()
6060
end)
6161
controls.save.enabled = false
62-
controls.cancel = new("ButtonControl", nil, 45, 70, 80, 20, "Cancel", function()
62+
controls.cancel = new("ButtonControl", nil, {45, 70, 80, 20}, "Cancel", function()
6363
if addOnName then
6464
self.configTab.configSets[configSet.id] = nil
6565
end

0 commit comments

Comments
 (0)