From f372dc06d31d494a424bb55a77d67c4862221244 Mon Sep 17 00:00:00 2001 From: TPlant Date: Tue, 5 Dec 2023 07:25:33 +0100 Subject: [PATCH] Code cleanup (#6820) * Remove unused variables * Refactor usage of global variables * Remove redundant code * Simplify return --- src/Classes/CheckBoxControl.lua | 2 +- src/Classes/DropDownControl.lua | 2 +- src/Classes/EditControl.lua | 2 +- src/Classes/SkillListControl.lua | 11 ++--------- src/Classes/TradeQuery.lua | 5 +---- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/Classes/CheckBoxControl.lua b/src/Classes/CheckBoxControl.lua index 97ae93c440..6829818886 100644 --- a/src/Classes/CheckBoxControl.lua +++ b/src/Classes/CheckBoxControl.lua @@ -39,7 +39,7 @@ function CheckBoxClass:Draw(viewPort, noTooltip) elseif mOver then SetDrawColor(1, 1, 1) elseif self.borderFunc then - r, g, b = self.borderFunc() + local r, g, b = self.borderFunc() SetDrawColor(r, g, b) else SetDrawColor(0.5, 0.5, 0.5) diff --git a/src/Classes/DropDownControl.lua b/src/Classes/DropDownControl.lua index 39aaf303fb..0e39a6f53f 100644 --- a/src/Classes/DropDownControl.lua +++ b/src/Classes/DropDownControl.lua @@ -236,7 +236,7 @@ function DropDownClass:Draw(viewPort, noTooltip) elseif mOver or self.dropped then SetDrawColor(1, 1, 1) elseif self.borderFunc then - r, g, b = self.borderFunc() + local r, g, b = self.borderFunc() SetDrawColor(r, g, b) else SetDrawColor(0.5, 0.5, 0.5) diff --git a/src/Classes/EditControl.lua b/src/Classes/EditControl.lua index 647e54ddab..e35c122212 100644 --- a/src/Classes/EditControl.lua +++ b/src/Classes/EditControl.lua @@ -247,7 +247,7 @@ function EditClass:Draw(viewPort, noTooltip) elseif mOver then SetDrawColor(1, 1, 1) elseif self.borderFunc then - r, g, b = self.borderFunc() + local r, g, b = self.borderFunc() SetDrawColor(r, g, b) else SetDrawColor(0.5, 0.5, 0.5) diff --git a/src/Classes/SkillListControl.lua b/src/Classes/SkillListControl.lua index 6fce9da81b..9143b072f3 100644 --- a/src/Classes/SkillListControl.lua +++ b/src/Classes/SkillListControl.lua @@ -207,10 +207,7 @@ end function SkillListClass:GetRowIcon(column, index, socketGroup) if column == 1 then - local slot = socketGroup.slot or nil - local color = "^7" - local currentMainSkill = self.skillsTab.build.mainSocketGroup == index - local disabled = not socketGroup.enabled or not socketGroup.slotEnabled + local slot = socketGroup.slot local itemsTab = self.skillsTab.build.itemsTab local weapon1Sel = itemsTab.activeItemSet["Weapon 1"].selItemId or 0 local weapon1Type = itemsTab.items[weapon1Sel] and itemsTab.items[weapon1Sel].base.type or "None" @@ -232,10 +229,6 @@ function SkillListClass:GetRowIcon(column, index, socketGroup) if slot == "Weapon 2 Swap" and (weapon2SwapType == "Quiver" or weapon2SwapType == "Shield") then slot = weapon2SwapType.." Swap" end - if slot_map[slot] then - return slot_map[slot].icon - else - return nil - end + return slot_map[slot] and slot_map[slot].icon end end diff --git a/src/Classes/TradeQuery.lua b/src/Classes/TradeQuery.lua index 121418ab99..aa8477ff50 100644 --- a/src/Classes/TradeQuery.lua +++ b/src/Classes/TradeQuery.lua @@ -102,12 +102,9 @@ function TradeQueryClass:PullLeagueList() self:SetNotice(self.controls.pbNotice, "Failed to Get PoE League List response") return end - table.sort(json_data, function(a, b) + table.sort(json_data, function(a, b) if a.endAt == nil then return false end if b.endAt == nil then return true end - if a.endAt == b.endAt then - return #a.id < #b.id - end return #a.id < #b.id end) self.itemsTab.leagueDropList = {}