Added basic table.equals, dontSignal param to combobox calls & spell methods.

This commit is contained in:
BenDol
2014-07-09 04:07:02 +12:00
parent a9d4fd5e1e
commit 3dbcb1daee
3 changed files with 52 additions and 6 deletions

View File

@@ -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

View File

@@ -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