viplist order
This commit is contained in:
parent
a628c700fc
commit
983bc745bd
|
@ -29,10 +29,10 @@ function VipList.addVip()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- hooked events
|
-- hooked events
|
||||||
function Game.onAddVip(id, name, online)
|
function VipList.onAddVip(id, name, online)
|
||||||
local vipList = vipWindow:getChildById('vipList')
|
local vipList = vipWindow:getChildById('vipList')
|
||||||
|
|
||||||
local label = createWidget('VipListLabel', vipList)
|
local label = createWidget('VipListLabel', nil)
|
||||||
label:setId('vip' .. id)
|
label:setId('vip' .. id)
|
||||||
label:setText(name)
|
label:setText(name)
|
||||||
|
|
||||||
|
@ -43,19 +43,40 @@ function Game.onAddVip(id, name, online)
|
||||||
end
|
end
|
||||||
|
|
||||||
label.vipOnline = online
|
label.vipOnline = online
|
||||||
end
|
|
||||||
|
|
||||||
function Game.onVipStateChange(id, online)
|
local nameLower = name:lower()
|
||||||
local vipList = vipWindow:getChildById('vipList')
|
local childrenCount = vipList:getChildCount()
|
||||||
local label = vipList:getChildById('vip' .. id)
|
for i=1,childrenCount do
|
||||||
|
|
||||||
if online then
|
local child = vipList:getChildByIndex(i)
|
||||||
label:setColor('#00ff00')
|
if online and not child.vipOnline then
|
||||||
else
|
vipList:insertChild(i, label)
|
||||||
label:setColor('#ff0000')
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local childText = child:getText():lower()
|
||||||
|
local length = math.min(childText:len(), nameLower:len())
|
||||||
|
|
||||||
|
for j=1,length do
|
||||||
|
if nameLower:byte(j) < childText:byte(j) then
|
||||||
|
vipList:insertChild(i, label)
|
||||||
|
return
|
||||||
|
elseif nameLower:byte(j) > childText:byte(j) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
label.vipOnline = online
|
vipList:insertChild(childrenCount+1, label)
|
||||||
|
end
|
||||||
|
|
||||||
|
function VipList.onVipStateChange(id, online)
|
||||||
|
local vipList = vipWindow:getChildById('vipList')
|
||||||
|
local label = vipList:getChildById('vip' .. id)
|
||||||
|
local text = label:getText()
|
||||||
|
vipList:removeChild(label)
|
||||||
|
|
||||||
|
VipList.onAddVip(id, text, online)
|
||||||
end
|
end
|
||||||
|
|
||||||
function VipList.onVipListMousePress(widget, mousePos, mouseButton)
|
function VipList.onVipListMousePress(widget, mousePos, mouseButton)
|
||||||
|
@ -87,4 +108,6 @@ end
|
||||||
|
|
||||||
|
|
||||||
connect(Game, { onLogin = VipList.create,
|
connect(Game, { onLogin = VipList.create,
|
||||||
onLogout = VipList.destroy })
|
onLogout = VipList.destroy,
|
||||||
|
onAddVip = VipList.onAddVip,
|
||||||
|
onVipStateChange = VipList.onVipStateChange })
|
||||||
|
|
Loading…
Reference in New Issue