ZBShouBaoOBJ = Up_BaseClassOBJ:new() ZBShouBaoOBJ.__cname = "FuLiDaTingOBJ" ZBShouBaoOBJ.cfg = {} function ZBShouBaoOBJ:main(parent, data) self.cfg = data GUI:LoadExport(parent, "game/FuLiDaTing/ZBShouBaoUI") self._parent = parent self.ui = GUI:ui_delegate(parent) if not self.ui then return false end ---* 绑定事件 self:EventBind() self:updata() end function ZBShouBaoOBJ:updata() local cfg = self.cfg GUI:ListView_removeAllItems(self.ui.ListView) self.quick = {} for i, v in pairs(cfg or {}) do local cell = self:QuickCell_Create(i, v) self.quick[i] = cell end self:setsort() end function ZBShouBaoOBJ:setsort() local Vardata = hk.getkeytbl("GLOBAL(STR_全区首爆)") for k, v in pairs(Vardata or {}) do local num = Vardata[k] and (Vardata[k] or nil) or nil if num ~= nil then GUI:QuickCell_Exit(self.quick[k]) GUI:ListView_removeChild(self.ui.ListView, self.quick[k]) local cell = self:QuickCell_Create(k, self.cfg[k]) GUI:ListView_doLayout(self.ui.ListView) self.quick[k] = cell end end end function ZBShouBaoOBJ:QuickCell_Create(i, v) local cell = GUI:QuickCell_Create(self.ui.ListView, "QuickCell_Create" .. i, 0, 0, 522, 30, function(quickParent) local list_bg = GUI:Image_Create(quickParent, "list_bg_", 0, 0, "res/custom/01/6/0.png") local list_index = GUI:Text_Create(list_bg, "list_index_" .. i, 36, 15, 16, "#ff0000", i) GUI:setAnchorPoint(list_index, 0.50, 0.50) local item_name = GUI:Text_Create(list_bg, "item_name_" .. i, 154, 15, 16, "#ff0000", v.name) GUI:setAnchorPoint(item_name, 0.50, 0.50) local gives_Text = GUI:Text_Create(list_bg, "gives_Text_" .. i, 310, 15, 16, "#00ff00", string.format("绑定元宝x%d", v.money)) GUI:setAnchorPoint(gives_Text, 0.50, 0.50) local player = hk.getkeycount("GLOBAL(STR_全区首爆)", i) or "未爆出" local list_Player = GUI:Text_Create(list_bg, "list_Player_" .. i, 470, 15, 16, "#00ff00", player) GUI:setAnchorPoint(list_Player, 0.50, 0.50) GUI:Text_enableOutline(list_Player, "#000000", 2) GUI:Text_setTextColor(list_Player, player == "未爆出" and "#ff0000" or "#00ff00") return list_bg end) return cell end function ZBShouBaoOBJ:EventBind() local function ZBShouBaoOBJ_Var_Change(data) if GUI:Win_IsNotNull(self._parent) then if data.key == "GLOBAL(STR_全区首爆)" then self:setsort() return end end end SL:RegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname, ZBShouBaoOBJ_Var_Change) --关闭窗口 SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname .. "mrcz", function(widgetName) self:OnClose(widgetName) end) end --关闭窗口 function ZBShouBaoOBJ:OnClose(widgetName) if widgetName == self.__cname then self:UnRegisterEvent() end end function ZBShouBaoOBJ:UnRegisterEvent() SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname) SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname) end return ZBShouBaoOBJ