mirror of
https://github.com/edubart/otclient.git
synced 2025-04-30 09:39:21 +02:00

* rework client modules * hide main window when loading * remake top menu functions * rework modules autoload * improve path resolving for otml and lua * move core_widgets to core_lib * fix tooltip issues * split some styles * add bit32 lua library * fix assert issues * fix compilation on linux 32 systems * rework gcc compile options * renable and fix some warnings * remove unused constants * speedup sprite cache * move UIGame to lua (not funcional yet) * fix a lot of issues in x11 window * fix crash handler * add some warnings do uiwidget and much more...
44 lines
1.0 KiB
Lua
44 lines
1.0 KiB
Lua
RadioGroup = newclass()
|
|
|
|
function RadioGroup.create()
|
|
local radiogroup = RadioGroup.internalCreate()
|
|
radiogroup.widgets = {}
|
|
return radiogroup
|
|
end
|
|
|
|
function RadioGroup:destroy()
|
|
while #self.widgets ~= 0 do
|
|
self:removeWidget(self.widgets[1])
|
|
end
|
|
end
|
|
|
|
function RadioGroup:addWidget(widget)
|
|
table.insert(self.widgets, widget)
|
|
widget.onMousePress = function(widget) self:selectWidget(widget) end
|
|
end
|
|
|
|
function RadioGroup:removeWidget(widget)
|
|
if self.selectedWidget == widget then
|
|
self:selectWidget(nil)
|
|
end
|
|
widget.onMousePress = nil
|
|
table.removevalue(self.widgets, widget)
|
|
end
|
|
|
|
function RadioGroup:selectWidget(selectedWidget)
|
|
if selectedWidget == self.selectedWidget then return end
|
|
|
|
local previousSelectedWidget = self.selectedWidget
|
|
self.selectedWidget = selectedWidget
|
|
|
|
if previousSelectedWidget then
|
|
previousSelectedWidget:setChecked(false)
|
|
end
|
|
|
|
if selectedWidget then
|
|
selectedWidget:setChecked(true)
|
|
end
|
|
|
|
signalcall(self.onSelectionChange, self, selectedWidget, previousSelectedWidget)
|
|
end
|