mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 20:14:54 +02:00
Added basic table.equals, dontSignal param to combobox calls & spell methods.
This commit is contained in:
@@ -182,3 +182,14 @@ function table.collect(t, func)
|
||||
return res
|
||||
end
|
||||
|
||||
function table.equals(t, comp)
|
||||
local equals = false
|
||||
if type(t) == "table" and type(comp) == "table" then
|
||||
for k,v in pairs(t) do
|
||||
if v == comp[k] then
|
||||
equals = true
|
||||
end
|
||||
end
|
||||
end
|
||||
return equals
|
||||
end
|
@@ -28,25 +28,29 @@ function UIComboBox:getOption(text)
|
||||
end
|
||||
end
|
||||
|
||||
function UIComboBox:setCurrentOption(text)
|
||||
function UIComboBox:setCurrentOption(text, dontSignal)
|
||||
if not self.options then return end
|
||||
for i,v in ipairs(self.options) do
|
||||
if v.text == text and self.currentIndex ~= i then
|
||||
self.currentIndex = i
|
||||
self:setText(text)
|
||||
signalcall(self.onOptionChange, self, text, v.data)
|
||||
if not dontSignal then
|
||||
signalcall(self.onOptionChange, self, text, v.data)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIComboBox:setCurrentOptionByData(data)
|
||||
function UIComboBox:setCurrentOptionByData(data, dontSignal)
|
||||
if not self.options then return end
|
||||
for i,v in ipairs(self.options) do
|
||||
if v.data == data and self.currentIndex ~= i then
|
||||
self.currentIndex = i
|
||||
self:setText(v.text)
|
||||
signalcall(self.onOptionChange, self, v.text, v.data)
|
||||
if not dontSignal then
|
||||
signalcall(self.onOptionChange, self, v.text, v.data)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user