Skip to content

Commit

Permalink
Merge pull request #918 from MasterBel2/spring-cleaning
Browse files Browse the repository at this point in the history
Spring cleaning
  • Loading branch information
AntlerForce authored Feb 21, 2025
2 parents 60c1697 + b2510c1 commit a85a27e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ function BattleListWindow:init(parent)
}
end

local function update()
self:Update()
end

self.infoPanel = Panel:New {
classname = "overlay_window",
x = "15%",
Expand Down Expand Up @@ -196,6 +192,7 @@ function BattleListWindow:init(parent)
checkVsAI:SetToggle(Configuration.battleFilterVsAI)
end
WG.Delay(UpdateCheckboxes, 0.2)
-- Delay required as Configuration:GetConfigData (where these values are set) runs after this is initialised.

self:SetMinItemWidth(100000)
self.columns = 3
Expand Down Expand Up @@ -259,7 +256,7 @@ function BattleListWindow:init(parent)

local function onConfigurationChange(listener, key, value)
if key == "displayBadEngines2" then
update()
self:Update()
elseif key == "battleFilterRedundant" then
self:SoftUpdate()
end
Expand All @@ -273,7 +270,7 @@ function BattleListWindow:init(parent)
end
WG.DownloadHandler.AddListener("DownloadFinished", downloadFinished)

update()
self:Update()
end

function BattleListWindow:RemoveListeners()
Expand Down
25 changes: 0 additions & 25 deletions LuaMenu/widgets/chobby/components/component.lua

This file was deleted.

4 changes: 1 addition & 3 deletions LuaMenu/widgets/chobby/components/downloader.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Downloader = Component:extends{}
Downloader = LCS.class{}

function Downloader:init(buttonsMode, tbl, timeout, updateListener, completeListener, queueFont, visibleListener)
self:super("init")

self.wrapperAsFallback = false

queueFont = queueFont or 1
Expand Down
3 changes: 1 addition & 2 deletions LuaMenu/widgets/chobby/components/list_window.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ListWindow = Component:extends{}
ListWindow = LCS.class{}

function ListWindow:init(parent, title, noWindow, windowClassname, noClose, customPadding, bottomSpacing)
self:DoInit() -- Lack of inheritance strikes again.

self.CancelFunc = function ()
self:HideWindow()
Expand Down
14 changes: 12 additions & 2 deletions LuaMenu/widgets/chobby/components/priority_popup.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PriorityPopup = Component:extends{}
PriorityPopup = LCS.class{}

PriorityPopup.registeredPopups = {}

function PriorityPopup:init(mainWindow, cancelFunction, acceptFunction, parentControlOverride, hideWindow, disableAcceptHotkey)
local sentTime
Expand Down Expand Up @@ -117,7 +119,7 @@ function PriorityPopup:init(mainWindow, cancelFunction, acceptFunction, parentCo
local sw, sh = Spring.GetWindowGeometry()
self:ViewResize(sw, sh)

self:super('init')
table.insert(PriorityPopup.registeredPopups, self)
end

function PriorityPopup:ViewResize(screenWidth, screenHeight)
Expand All @@ -141,3 +143,11 @@ function PriorityPopup:ClosePopup()
self.mainWindow:Dispose()
end
end

function PriorityPopup:unregister()
for i, comp in pairs(PriorityPopup.registeredPopups) do
if comp == self then
table.remove(PriorityPopup.registeredPopups, i)
end
end
end
5 changes: 2 additions & 3 deletions LuaMenu/widgets/chobby/components/sortable_list.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
SortableList = Component:extends{}
SortableList = LCS.class{}

function SortableList:init(holder, headings, itemHeight, defaultSort, sortDirection, scrollPanelOverride, ItemInFilter)
self:DoInit() -- Lack of inheritance strikes again.


self.sortBy = false
self.smallToLarge = sortDirection
if self.smallToLarge == nil then
Expand Down
11 changes: 4 additions & 7 deletions LuaMenu/widgets/chobby/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ local includes = {
"components/configuration.lua",

-- basic components
"components/component.lua",
"components/list_window.lua",
"components/console.lua",
"components/user_list_panel.lua",
Expand Down Expand Up @@ -92,19 +91,17 @@ function Chobby:_Initialize()
end)
end

function Chobby:GetRegisteredComponents()
return Component.registeredComponents
function Chobby:GetRegisteredPopups()
return PriorityPopup.registeredPopups
end

function Chobby:_DrawScreen()
self:WrapCall(function()
end)
end

function Chobby:_ViewResize(sw, sh)
self:WrapCall(function()
for i, comp in pairs(self:GetRegisteredComponents()) do
comp:ViewResize(sw, sh)
for i, popup in pairs(self:GetRegisteredPopups()) do
popup:ViewResize(sw, sh)
end
end)
end
Expand Down

0 comments on commit a85a27e

Please sign in to comment.