Skip to content

Commit

Permalink
fix merge issues and update new controls to use packed rect
Browse files Browse the repository at this point in the history
  • Loading branch information
Regisle committed Aug 31, 2024
1 parent 40a8a55 commit 360a19c
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 122 deletions.
2 changes: 1 addition & 1 deletion src/Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ 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
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
21 changes: 10 additions & 11 deletions src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont

self.toggleConfigs = false

self.controls.sectionAnchor = new("LabelControl", { "TOPLEFT", self, "TOPLEFT" }, 0, 20, 0, 0, "")
self.controls.sectionAnchor = new("LabelControl", { "TOPLEFT", self, "TOPLEFT" }, { 0, 20, 0, 0 }, "")

-- Set selector
self.controls.setSelect = new("DropDownControl", { "TOPLEFT", self.controls.sectionAnchor, "TOPLEFT" }, 76, -12, 210, 20, nil, function(index, value)
self.controls.setSelect = new("DropDownControl", { "TOPLEFT", self.controls.sectionAnchor, "TOPLEFT" }, { 76, -12, 210, 20 }, nil, function(index, value)
self:SetActiveConfigSet(self.configSetOrderList[index])
self:AddUndoState()
end)
self.controls.setSelect.enableDroppedWidth = true
self.controls.setSelect.enabled = function()
return #self.configSetOrderList > 1
end
self.controls.setLabel = new("LabelControl", { "RIGHT", self.controls.setSelect, "LEFT" }, -2, 0, 0, 16, "^7Config set:")
self.controls.setManage = new("ButtonControl", { "LEFT", self.controls.setSelect, "RIGHT" }, 4, 0, 90, 20, "Manage...", function()
self.controls.setLabel = new("LabelControl", { "RIGHT", self.controls.setSelect, "LEFT" }, { -2, 0, 0, 16 }, "^7Config set:")
self.controls.setManage = new("ButtonControl", { "LEFT", self.controls.setSelect, "RIGHT" }, { 4, 0, 90, 20 }, "Manage...", function()
self:OpenConfigSetManagePopup()
end)

self.controls.search = new("EditControl", { "TOPLEFT", self.controls.sectionAnchor, "TOPLEFT" }, 8, 15, 360, 20, "", "Search", "%c", 100, function()
self.controls.search = new("EditControl", { "TOPLEFT", self.controls.sectionAnchor, "TOPLEFT" }, { 8, 15, 360, 20 }, "", "Search", "%c", 100, function()
self:UpdateControls()
end, nil, nil, true)
self.controls.toggleConfigs = new("ButtonControl", { "LEFT", self.controls.search, "RIGHT" }, 10, 0, 200, 20, function()
self.controls.toggleConfigs = new("ButtonControl", { "LEFT", self.controls.search, "RIGHT" }, { 10, 0, 200, 20 }, function()
-- dynamic text
return self.toggleConfigs and "Hide Ineligible Configurations" or "Show All Configurations"
end, function()
Expand Down Expand Up @@ -144,8 +144,7 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
local lastSection
for _, varData in ipairs(varList) do
if varData.section then
lastSection = new("SectionControl", {"TOPLEFT",self.controls.search,"BOTTOMLEFT"}, 0, 0, 360, 0, varData.section)
lastSection = new("SectionControl", {"TOPLEFT",self,"TOPLEFT"}, {0, 0, 360, 0}, varData.section)
lastSection = new("SectionControl", {"TOPLEFT",self.controls.search,"BOTTOMLEFT"}, {0, 0, 360, 0}, varData.section)
lastSection.varControlList = { }
lastSection.col = varData.col
lastSection.height = function(self)
Expand Down Expand Up @@ -198,7 +197,7 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
self.build.buildFlag = true
end, 16)
elseif varData.type == "text" and varData.resizable then
control = new("ResizableEditControl", {"TOPLEFT",lastSection,"TOPLEFT"}, 8, 0, nil, 344, nil, nil, 118, 118 + 16 * 40, "", nil, "^%C\t\n", nil, function(buf, placeholder)
control = new("ResizableEditControl", {"TOPLEFT",lastSection,"TOPLEFT"}, {8, 0, 344, 118, nil, nil, nil, 118 + 16 * 40}, "", nil, "^%C\t\n", nil, function(buf, placeholder)
if placeholder then
self.configSets[self.activeConfigSetId].placeholder[varData.var] = tostring(buf)
else
Expand Down Expand Up @@ -936,8 +935,8 @@ end

function ConfigTabClass:OpenConfigSetManagePopup()
main:OpenPopup(370, 290, "Manage Config Sets", {
new("ConfigSetListControl", nil, 0, 50, 350, 200, self),
new("ButtonControl", nil, 0, 260, 90, 20, "Done", function()
new("ConfigSetListControl", nil, {0, 50, 350, 200}, self),
new("ButtonControl", nil, {0, 260, 90, 20}, "Done", function()
main:ClosePopup()
end),
})
Expand Down
5 changes: 4 additions & 1 deletion src/Classes/Control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ local rect = {
y,
width,
height,
}
could possibly have
minWidth,
minHeight,
}
for containers
--]]

local ControlClass = newClass("Control", function(self, anchor, rect)
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/DraggerControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
-- Class: Dragger Button Control
-- Dragger button control.
--
local DraggerClass = newClass("DraggerControl", "Control", "TooltipHost", function(self, anchor, x, y, width, height, label, onKeyDown, onKeyUp, onRightClick, onHover, forceTooltip)
self.Control(anchor, x, y, width, height)
local DraggerClass = newClass("DraggerControl", "Control", "TooltipHost", function(self, anchor, rect, label, onKeyDown, onKeyUp, onRightClick, onHover, forceTooltip)
self.Control(anchor, rect)
self.TooltipHost()
self.label = label
self.onKeyDown = onKeyDown
Expand Down
16 changes: 8 additions & 8 deletions src/Classes/ExtBuildListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ local m_min = math.min
local dkjson = require "dkjson"

local ExtBuildListControlClass = newClass("ExtBuildListControl", "ControlHost", "Control",
function(self, anchor, x, y, width, height, providers)
self.Control(anchor, x, y, width, height)
function(self, anchor, rect, providers)
self.Control(anchor, rect)
self.ControlHost()
self:SelectControl()

Expand All @@ -39,7 +39,7 @@ function ExtBuildListControlClass:Init(providerName)
wipeTable(self.controls)
wipeTable(self.tabs)

self.controls.sort = new("DropDownControl", { "TOP", self, "TOP" }, 0, -20, self.providerMaxLength, 20,
self.controls.sort = new("DropDownControl", { "TOP", self, "TOP" }, { 0, -20, self.providerMaxLength, 20 },
self.buildProvidersList, function(index, value)
self:Init(value)
end)
Expand Down Expand Up @@ -72,7 +72,7 @@ function ExtBuildListControlClass:Init(providerName)
if lastControl then
anchor = { "LEFT", lastControl, "RIGHT" }
end
local button = new("ButtonControl", anchor, 0, lastControl and 0 or -20, stringWidth + 10, 20, title, function()
local button = new("ButtonControl", anchor, { 0, lastControl and 0 or -20, stringWidth + 10, 20 }, title, function()
if self.activeListProvider:GetActiveList() == title then
return
end
Expand Down Expand Up @@ -105,7 +105,7 @@ function ExtBuildListControlClass:Init(providerName)
return (self.width() - self.controls.sort.width()) / 2
end

self.controls.scrollBarV = new("ScrollBarControl", { "RIGHT", self, "RIGHT" }, -1, 0, self.scroll and 16 or 0, 0,
self.controls.scrollBarV = new("ScrollBarControl", { "RIGHT", self, "RIGHT" }, { -1, 0, self.scroll and 16 or 0, 0 },
80, "VERTICAL") {
-- y = function()
-- return (self.scrollH and -8 or 0)
Expand All @@ -120,7 +120,7 @@ function ExtBuildListControlClass:Init(providerName)
end

if self.activeListProvider:GetPageUrl() then
self.controls.all = new("ButtonControl", { "BOTTOM", self, "BOTTOM" }, 0, 1, self.width, 20, "See All",
self.controls.all = new("ButtonControl", { "BOTTOM", self, "BOTTOM" }, { 0, 1, self.width, 20 }, "See All",
function()
local url = self.activeListProvider:GetPageUrl()
if url then
Expand Down Expand Up @@ -407,14 +407,14 @@ function ExtBuildListControlClass:Draw(viewPort, noTooltip)
local relativeHeight = currentHeight + 10 - self.controls.scrollBarV.offset
if relativeHeight > y and relativeHeight < self.height() + y - 10 then
if build.buildLink then
local importButton = new("ButtonControl", nil, x, currentHeight - self.controls.scrollBarV.offset, 45, 20, "Import", function()
local importButton = new("ButtonControl", nil, { x, currentHeight - self.controls.scrollBarV.offset, 45, 20 }, "Import", function()
self:importBuild(build)
end)
t_insert(self.controls, importButton)
end

if build.previewLink then
local previewButton = new("ButtonControl", nil, x + 50, currentHeight - self.controls.scrollBarV.offset, 60, 20, "Preview", function()
local previewButton = new("ButtonControl", nil, { x + 50, currentHeight - self.controls.scrollBarV.offset, 60, 20 }, "Preview", function()
OpenURL(build.previewLink)
end)
t_insert(self.controls, previewButton)
Expand Down
16 changes: 8 additions & 8 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,15 @@ holding Shift will put it in the second.]])
end

-- Section: Item Quality
self.controls.displayItemSectionQuality = new("Control", {"TOPLEFT",self.controls.displayItemSectionInfluence,"BOTTOMLEFT"}, 0, 0, 0, function()
self.controls.displayItemSectionQuality = new("Control", {"TOPLEFT",self.controls.displayItemSectionInfluence,"BOTTOMLEFT"}, {0, 0, 0, function()
return (self.controls.displayItemQuality:IsShown() and self.controls.displayItemQualityEdit:IsShown()) and 28 or 0
end)
self.controls.displayItemQuality = new("LabelControl", {"TOPLEFT",self.controls.displayItemSectionQuality,"TOPRIGHT"}, -4, 0, 0, 16, "^7Quality:")
end})
self.controls.displayItemQuality = new("LabelControl", {"TOPLEFT",self.controls.displayItemSectionQuality,"TOPRIGHT"}, {-4, 0, 0, 16}, "^7Quality:")
self.controls.displayItemQuality.shown = function()
return self.displayItem and self.displayItem.quality and (self.displayItem.base.type ~= "Amulet" or self.displayItem.base.type ~= "Belt" or self.displayItem.base.type ~= "Jewel" or self.displayItem.base.type ~= "Quiver" or self.displayItem.base.type ~= "Ring")
end

self.controls.displayItemQualityEdit = new("EditControl", {"LEFT",self.controls.displayItemQuality,"RIGHT"},2,0,60,20,nil,nil,"%D",2,function(buf)
self.controls.displayItemQualityEdit = new("EditControl", {"LEFT",self.controls.displayItemQuality,"RIGHT"}, {2, 0, 60, 20}, nil, nil, "%D", 2, function(buf)
self.displayItem.quality = tonumber(buf)
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
Expand All @@ -558,9 +558,9 @@ holding Shift will put it in the second.]])
end

-- Section: Catalysts
self.controls.displayItemSectionCatalyst = new("Control", {"TOPLEFT",self.controls.displayItemSectionQuality,"BOTTOMLEFT"}, 0, 0, 0, function()
self.controls.displayItemSectionCatalyst = new("Control", {"TOPLEFT",self.controls.displayItemSectionQuality,"BOTTOMLEFT"}, {0, 0, 0, function()
return (self.controls.displayItemCatalyst:IsShown() or self.controls.displayItemCatalystQualityEdit:IsShown()) and 28 or 0
end)
end})
self.controls.displayItemCatalyst = new("DropDownControl", {"TOPLEFT",self.controls.displayItemSectionCatalyst,"TOPRIGHT"}, {0, 0, 250, 20},
{"Catalyst","Abrasive (Attack)","Accelerating (Speed)","Fertile (Life & Mana)","Imbued (Caster)","Intrinsic (Attribute)","Noxious (Physical & Chaos Damage)",
"Prismatic (Resistance)","Tempering (Defense)","Turbulent (Elemental)","Unstable (Critical)"},
Expand All @@ -583,7 +583,7 @@ holding Shift will put it in the second.]])
self.controls.displayItemCatalyst.shown = function()
return self.displayItem and (self.displayItem.crafted or self.displayItem.hasModTags) and (self.displayItem.base.type == "Amulet" or self.displayItem.base.type == "Ring" or self.displayItem.base.type == "Belt")
end
self.controls.displayItemCatalystQualityEdit = new("EditControl", {"LEFT",self.controls.displayItemCatalyst,"RIGHT"},2,0,60,20,nil,nil,"%D",2,function(buf)
self.controls.displayItemCatalystQualityEdit = new("EditControl", {"LEFT",self.controls.displayItemCatalyst,"RIGHT"}, {2, 0, 60, 20}, nil, nil, "%D", 2, function(buf)
self.displayItem.catalystQuality = tonumber(buf)
if self.displayItem.crafted then
for i = 1, self.displayItem.affixLimit do
Expand Down Expand Up @@ -2530,7 +2530,7 @@ function ItemsTabClass:CorruptDisplayItem(modType)
end
controls.implicit4Label.shown = false
controls.implicit4.shown = false
controls.implicitCannotBeChangedLabel = new("LabelControl", {"TOPLEFT",nil,"TOPLEFT"}, 20, 45, 0, 20, "^7This Items Implicits Cannot Be Changed")
controls.implicitCannotBeChangedLabel = new("LabelControl", {"TOPLEFT",nil,"TOPLEFT"}, {20, 45, 0, 20}, "^7This Items Implicits Cannot Be Changed")
controls.implicitCannotBeChangedLabel.shown = self.displayItem.implicitsCannotBeChanged
buildList(controls.implicit, controls.implicit2, currentModType)
buildList(controls.implicit2, controls.implicit, currentModType)
Expand Down
8 changes: 4 additions & 4 deletions src/Classes/MinionSearchListControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ local t_insert = table.insert
local t_remove = table.remove
local s_format = string.format

local MinionSearchListClass = newClass("MinionSearchListControl", "MinionListControl", function(self, anchor, x, y, width, height, data, list, dest)
self.MinionListControl(anchor, x, y, width, height, data, list, dest)
local MinionSearchListClass = newClass("MinionSearchListControl", "MinionListControl", function(self, anchor, rect, data, list, dest)
self.MinionListControl(anchor, rect, data, list, dest)
self.unfilteredList = copyTable(list)
self.isMutable = false

self.controls.searchText = new("EditControl", {"BOTTOMLEFT",self,"TOPLEFT"}, 0, -2, 128, 18, "", "Search", "%c", 100, function(buf)
self.controls.searchText = new("EditControl", {"BOTTOMLEFT",self,"TOPLEFT"}, {0, -2, 128, 18}, "", "Search", "%c", 100, function(buf)
self:ListFilterChanged(buf, self.controls.searchModeDropDown.selIndex)
end, nil, nil, true)

self.controls.searchModeDropDown = new("DropDownControl", {"LEFT",self.controls.searchText,"RIGHT"}, 2, 0, 60, 18, { "Names", "Skills", "Both"}, function(index, value)
self.controls.searchModeDropDown = new("DropDownControl", {"LEFT",self.controls.searchText,"RIGHT"}, {2, 0, 60, 18}, { "Names", "Skills", "Both"}, function(index, value)
self:ListFilterChanged(self.controls.searchText.buf, index)
end)

Expand Down
10 changes: 5 additions & 5 deletions src/Classes/PartyTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,11 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
return not self.controls.ShowAdvanceTools.state
end

self.controls.editWarcriesLabel = new("LabelControl", {"TOPLEFT",self.controls.editAurasLabel,"BOTTOMLEFT"}, 0, 8, 0, theme.stringHeight, "^7Warcry Skills")
self.controls.editWarcriesLabel = new("LabelControl", {"TOPLEFT",self.controls.editAurasLabel,"BOTTOMLEFT"}, {0, 8, 0, theme.stringHeight}, "^7Warcry Skills")
self.controls.editWarcriesLabel.y = function()
return self.controls.ShowAdvanceTools.state and (self.controls.editAuras.height() + 8) or (theme.lineCounter(self.controls.simpleAuras.label) + 4)
end
self.controls.editWarcries = new("EditControl", {"TOPLEFT",self.controls.editWarcriesLabel,"TOPLEFT"}, 0, 18, 0, 0, "", nil, "^%C\t\n", nil, nil, 14, true)
self.controls.editWarcries = new("EditControl", {"TOPLEFT",self.controls.editWarcriesLabel,"TOPLEFT"}, {0, 18, 0, 0}, "", nil, "^%C\t\n", nil, nil, 14, true)
self.controls.editWarcries.width = function()
return self.width / 2 - 16
end
Expand All @@ -413,16 +413,16 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
self.controls.editWarcries.shown = function()
return self.controls.ShowAdvanceTools.state
end
self.controls.simpleWarcries = new("LabelControl", {"TOPLEFT",self.controls.editWarcriesLabel,"TOPLEFT"}, 0, 18, 0, theme.stringHeight, "")
self.controls.simpleWarcries = new("LabelControl", {"TOPLEFT",self.controls.editWarcriesLabel,"TOPLEFT"}, {0, 18, 0, theme.stringHeight}, "")
self.controls.simpleWarcries.shown = function()
return not self.controls.ShowAdvanceTools.state
end

self.controls.editLinksLabel = new("LabelControl", {"TOPLEFT",self.controls.editWarcriesLabel,"BOTTOMLEFT"}, 0, 8, 0, theme.stringHeight, "^7Link Skills")
self.controls.editLinksLabel = new("LabelControl", {"TOPLEFT",self.controls.editWarcriesLabel,"BOTTOMLEFT"}, {0, 8, 0, theme.stringHeight}, "^7Link Skills")
self.controls.editLinksLabel.y = function()
return self.controls.ShowAdvanceTools.state and (self.controls.editWarcries.height() + 8) or (theme.lineCounter(self.controls.simpleWarcries.label) + 4)
end
self.controls.editLinks = new("EditControl", {"TOPLEFT",self.controls.editLinksLabel,"TOPLEFT"}, 0, 18, 0, 0, "", nil, "^%C\t\n", nil, nil, 14, true)
self.controls.editLinks = new("EditControl", {"TOPLEFT",self.controls.editLinksLabel,"TOPLEFT"}, {0, 18, 0, 0}, "", nil, "^%C\t\n", nil, nil, 14, true)
self.controls.editLinks.width = function()
return self.width / 2 - 16
end
Expand Down
Loading

0 comments on commit 360a19c

Please sign in to comment.