XianShiChongBangOBJ = Up_BaseClassOBJ:new() XianShiChongBangOBJ.__cname = "XianShiChongBangOBJ" -- 配置文件 XianShiChongBangOBJ.cfg = {} XianShiChongBangOBJ.UIfile = "game/A/XianShiChongBangUI" -- 左侧按钮图片路径 XianShiChongBangOBJ.leftBtnImg = "res/custom/06/btn" -- 左侧按钮数量 XianShiChongBangOBJ.leftNum = 2 function XianShiChongBangOBJ:updata() ssrMessage:SubLink(self.__cname .. "_getrank", { page = self.id }) end function XianShiChongBangOBJ:sync(p1, p2, p3, data) local SeverTime = data.other.SeverTime or 0 if SeverTime == 0 then GUI:Text_setString(self.ui.Tiem_Text, "未开启") GUI:Text_setTextColor(self.ui.Tiem_Text, "#ff0000") elseif os.time() >= (SeverTime + 86400) then GUI:Text_setString(self.ui.Tiem_Text, "已结束") GUI:Text_setTextColor(self.ui.Tiem_Text, "#ff0000") else GUI:Text_COUNTDOWN(self.ui.Tiem_Text, (SeverTime + 86400) - os.time(), nil, 0) GUI:Text_setTextColor(self.ui.Tiem_Text, "#00ff00") end local self_name = SL:Get_USER_NAME() GUI:ListView_removeAllItems(self.ui.ListView) for i = 1, 10, 1 do GUI:QuickCell_Create(self.ui.ListView, "QuickCell_Create" .. i, 0, 0, 544, 30, function(quickParent) local cfg = self.cfg[i]["rank_" .. self.id] local list_Layout = GUI:Layout_Create(quickParent, "list_Layout", 0, 0, 544, 30, false) local rank_index = GUI:Text_Create(list_Layout, "rank_index", 34, 15, 16, "#00ff00", string.format("第%d名", i)) GUI:setAnchorPoint(rank_index, 0.50, 0.50) local player = data.other.Rank[i] and data.other.Rank[i][2] or "暂无玩家" local rank_name = GUI:Text_Create(list_Layout, "rank_name", 138, 15, 16, "#00ff00", player) GUI:setAnchorPoint(rank_name, 0.50, 0.50) local rank_Layout = GUI:Layout_Create(list_Layout, "rank_Layout", 340, 15, 20, 30, false) GUI:setAnchorPoint(rank_Layout, 0.50, 0.50) for id, v in ipairs(cfg) do local give_Lyout = GUI:Layout_Create(rank_Layout, "give_Lyout_" .. id, 0.00, 15.00, 70, 30, false) GUI:Win_SetParam(give_Lyout, #cfg - id) GUI:setAnchorPoint(give_Lyout, 0.50, 0.50) local item = GUI:ItemShow_Create(give_Lyout, "Item_" .. id, 0.00, 15.00, { index = SL:GetMetaValue("ITEM_INDEX_BY_NAME", v[1]), look = true, bgVisible = false, count = 1 }) GUI:setAnchorPoint(item, 0.50, 0.50) GUI:setScale(item, 0.5) local give_text = GUI:Text_Create(give_Lyout, "give_text_" .. id, 32.00, 14.00, 14, "#ffffff", string.format("x%d", v[2])) GUI:setAnchorPoint(give_text, 0.50, 0.50) end GUI:UserUILayout(rank_Layout, { dir = 2, addDir = 2, interval = 1, -- gap = { x = -15 }, sortfunc = function(lists) table.sort(lists, function(a, b) return GUI:Win_GetParam(a) > GUI:Win_GetParam(b) end) end }) local linkstr = (player ~= "暂无玩家" and player == self_name) and "<我要领取/@1111>" or "不可领取" local oper_Text = GUI:RichTextFCOLOR_Create(list_Layout, "oper_Text", 490, 15, linkstr, 100, 14, "#C0C0C0", 0, function(...) ssrMessage:SubLink(self.__cname .. "_givesrank", { rankid = self.id, id = i }) end, nil, { outlineSize = 1, outlineColor = SL:ConvertColorFromHexString("#000000") }) GUI:setAnchorPoint(oper_Text, 0.50, 0.50) return list_Layout end) end end function XianShiChongBangOBJ:reddot() end ------------------------网络消息------------------------ ------------------------注册事件------------------------ function XianShiChongBangOBJ:EventBind() local function XianShiChongBangOBJ_titleReload(data) if data.oper == 2 then if GUI:Win_IsNotNull(self._parent) then self:updata() end end end SL:RegisterLUAEvent(LUA_EVENT_TITLE_REFRESH, self.__cname, XianShiChongBangOBJ_titleReload) --关闭窗口 SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName) self:OnClose(widgetName) end) end --关闭窗口 function XianShiChongBangOBJ:OnClose(widgetName) if widgetName == self.__cname then self:UnRegisterEvent() end end function XianShiChongBangOBJ:UnRegisterEvent() SL:UnRegisterLUAEvent(LUA_EVENT_TITLE_REFRESH, self.__cname) SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname) end return XianShiChongBangOBJ