Skip to content

Commit 151f5c0

Browse files
committed
Change class constructor to be added as a separate method, instead of being an argument to newClass
1 parent 913a772 commit 151f5c0

70 files changed

Lines changed: 335 additions & 195 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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ local ipairs = ipairs
77
local s_format = string.format
88

99
---@class BuildListControl: ListControl
10-
local BuildListClass = newClass("BuildListControl", "ListControl", function(self, anchor, rect, listMode)
10+
local BuildListClass = newClass("BuildListControl", "ListControl")
11+
12+
function BuildListClass:BuildListControl(anchor, rect, listMode)
1113
self.ListControl(anchor, rect, 20, "VERTICAL", false, listMode.list)
1214
self.listMode = listMode
13-
self.colList = {
14-
{ width = function() return self:GetProperty("width") - 172 end },
15+
self.colList = {
16+
{ width = function() return self:GetProperty("width") - 172 end },
1517
{ },
1618
}
1719
self.showRowSeparators = true
@@ -45,7 +47,7 @@ local BuildListClass = newClass("BuildListControl", "ListControl", function(self
4547
self.controls.path.width = function ()
4648
return self.width()
4749
end
48-
end)
50+
end
4951

5052
function BuildListClass:SelByFileName(selFileName)
5153
for index, build in ipairs(self.list) do

src/Classes/ButtonControl.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
-- Basic button control.
55
--
66
---@class ButtonControl: Control, TooltipHost
7-
local ButtonClass = newClass("ButtonControl", "Control", "TooltipHost", function(self, anchor, rect, label, onClick, onHover, forceTooltip)
7+
local ButtonClass = newClass("ButtonControl", "Control", "TooltipHost")
8+
9+
function ButtonClass:ButtonControl(anchor, rect, label, onClick, onHover, forceTooltip)
810
self.Control(anchor, rect)
911
self.TooltipHost()
1012
self.label = label
1113
self.onClick = onClick
1214
self.onHover = onHover
1315
self.forceTooltip = forceTooltip
14-
end)
16+
end
1517

1618
function ButtonClass:Click()
1719
if self:IsShown() and self:IsEnabled() then

src/Classes/CalcBreakdownControl.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ local m_pi = math.pi
1414
local band = bit.band
1515

1616
---@class CalcBreakdownControl: Control, ControlHost
17-
local CalcBreakdownClass = newClass("CalcBreakdownControl", "Control", "ControlHost", function(self, calcsTab)
17+
local CalcBreakdownClass = newClass("CalcBreakdownControl", "Control", "ControlHost")
18+
19+
function CalcBreakdownClass:CalcBreakdownControl(calcsTab)
1820
self.Control()
1921
self.ControlHost()
2022
self.calcsTab = calcsTab
@@ -26,7 +28,7 @@ local CalcBreakdownClass = newClass("CalcBreakdownControl", "Control", "ControlH
2628
self.uiOverlay = NewImageHandle()
2729
self.uiOverlay:Load("Assets/game_ui_small.png")
2830
self.controls.scrollBar = new("ScrollBarControl", {"RIGHT",self,"RIGHT"}, {-2, 0, 18, 0}, 80, "VERTICAL", true)
29-
end)
31+
end
3032

3133
function CalcBreakdownClass:IsMouseOver()
3234
if not self:IsShown() then

src/Classes/CalcSectionControl.lua

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

88
---@class CalcSectionControl: Control, ControlHost
9-
local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost", function(self, calcsTab, width, id, group, colour, subSection, updateFunc)
9+
local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost")
10+
11+
function CalcSectionClass:CalcSectionControl(calcsTab, width, id, group, colour, subSection, updateFunc)
1012
self.Control(calcsTab, {0, 0, width, 0})
1113
self.ControlHost()
1214
self.calcsTab = calcsTab
@@ -53,7 +55,7 @@ local CalcSectionClass = newClass("CalcSectionControl", "Control", "ControlHost"
5355
self.shown = function()
5456
return self.enabled
5557
end
56-
end)
58+
end
5759

5860
function CalcSectionClass:IsMouseOver()
5961
if not self:IsShown() then

src/Classes/CalcsTab.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ local buffModeDropList = {
1717
}
1818

1919
---@class CalcsTab: UndoHandler, ControlHost, Control
20-
local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Control", function(self, build)
20+
local CalcsTabClass = newClass("CalcsTab", "UndoHandler", "ControlHost", "Control")
21+
22+
function CalcsTabClass:CalcsTab(build)
2123
self.UndoHandler()
2224
self.ControlHost()
2325
self.Control()
@@ -152,7 +154,7 @@ Effective DPS: Curses and enemy properties (such as resistances and status condi
152154

153155
self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT",self,"TOPRIGHT"}, {0, 0, 18, 0}, 50, "VERTICAL", true)
154156
self.powerBuilderInitialized = nil
155-
end)
157+
end
156158

157159
function CalcsTabClass:Load(xml, dbFileName)
158160
for _, node in ipairs(xml) do

src/Classes/CheckBoxControl.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
-- Basic check box control.
55
--
66
---@class CheckBoxControl: Control, TooltipHost
7-
local CheckBoxClass = newClass("CheckBoxControl", "Control", "TooltipHost", function(self, anchor, rect, label, changeFunc, tooltipText, initialState)
7+
local CheckBoxClass = newClass("CheckBoxControl", "Control", "TooltipHost")
8+
9+
function CheckBoxClass:CheckBoxControl(anchor, rect, label, changeFunc, tooltipText, initialState)
810
rect[4] = rect[3] or 0
911
self.Control(anchor, rect)
1012
self.TooltipHost(tooltipText)
1113
self.label = label
1214
self.labelWidth = DrawStringWidth(self.width - 4, "VAR", label or "") + 5
1315
self.changeFunc = changeFunc
1416
self.state = initialState
15-
end)
17+
end
1618

1719
function CheckBoxClass:IsMouseOver()
1820
if not self:IsShown() then

src/Classes/CompareEntry.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ local m_min = math.min
1010
local m_max = math.max
1111

1212
---@class CompareEntry: ControlHost
13-
local CompareEntryClass = newClass("CompareEntry", "ControlHost", function(self, xmlText, label)
13+
local CompareEntryClass = newClass("CompareEntry", "ControlHost")
14+
15+
function CompareEntryClass:CompareEntry(xmlText, label)
1416
self.ControlHost()
1517

1618
self.label = label or "Comparison Build"
@@ -52,7 +54,7 @@ local CompareEntryClass = newClass("CompareEntry", "ControlHost", function(self,
5254
if xmlText then
5355
self:LoadFromXML(xmlText)
5456
end
55-
end)
57+
end
5658

5759
function CompareEntryClass:LoadFromXML(xmlText)
5860
-- Parse the XML

src/Classes/ComparePowerReportListControl.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ local t_insert = table.insert
88
local t_sort = table.sort
99

1010
---@class ComparePowerReportListControl: ListControl
11-
local ComparePowerReportListClass = newClass("ComparePowerReportListControl", "ListControl", function(self, anchor, rect)
11+
local ComparePowerReportListClass = newClass("ComparePowerReportListControl", "ListControl")
12+
13+
function ComparePowerReportListClass:ComparePowerReportListControl(anchor, rect)
1214
self.ListControl(anchor, rect, 18, "VERTICAL", false)
1315

1416
local width = rect[3]
@@ -23,7 +25,7 @@ local ComparePowerReportListClass = newClass("ComparePowerReportListControl", "L
2325
self.colLabels = true
2426
self.showRowSeparators = true
2527
self.statusText = "Select a metric above to generate the power report."
26-
end)
28+
end
2729

2830
function ComparePowerReportListClass:SetReport(stat, report)
2931
self.impactColumn.label = stat and stat.label or ""

src/Classes/CompareTab.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ local function matchFlags(reqFlags, notFlags, flags)
123123
end
124124

125125
---@class CompareTab: ControlHost, Control
126-
local CompareTabClass = newClass("CompareTab", "ControlHost", "Control", function(self, primaryBuild)
126+
local CompareTabClass = newClass("CompareTab", "ControlHost", "Control")
127+
128+
function CompareTabClass:CompareTab(primaryBuild)
127129
self.ControlHost()
128130
self.Control()
129131

@@ -191,7 +193,7 @@ local CompareTabClass = newClass("CompareTab", "ControlHost", "Control", functio
191193

192194
-- Controls for the comparison screen
193195
self:InitControls()
194-
end)
196+
end
195197

196198
function CompareTabClass:InitControls()
197199
-- Sub-tab buttons

src/Classes/ConfigSetListControl.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ local t_remove = table.remove
88
local m_max = math.max
99

1010
---@class ConfigSetListControl: ListControl
11-
local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", function(self, anchor, rect, configTab)
11+
local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl")
12+
13+
function ConfigSetListClass:ConfigSetListControl(anchor, rect, configTab)
1214
self.ListControl(anchor, rect, 16, "VERTICAL", true, configTab.configSetOrderList)
1315
self.configTab = configTab
1416
self.controls.copy = new("ButtonControl", {"BOTTOMLEFT",self,"TOP"}, {2, -4, 60, 18}, "Copy", function()
@@ -39,7 +41,7 @@ local ConfigSetListClass = newClass("ConfigSetListControl", "ListControl", funct
3941
self.controls.new = new("ButtonControl", {"RIGHT",self.controls.rename,"LEFT"}, {-4, 0, 60, 18}, "New", function()
4042
self:RenameSet(configTab:NewConfigSet(), true)
4143
end)
42-
end)
44+
end
4345

4446
function ConfigSetListClass:RenameSet(configSet, addOnName)
4547
local controls = { }

0 commit comments

Comments
 (0)