202 lines
5.9 KiB
Lua
202 lines
5.9 KiB
Lua
WuqiRongheOBJ = Up_BaseClassOBJ:new()
|
|
|
|
WuqiRongheOBJ.__cname = "WuqiRongheOBJ"
|
|
|
|
WuqiRongheOBJ.cfg = {}
|
|
|
|
|
|
|
|
function WuqiRongheOBJ:main(arg1, arg2, arg3, data)
|
|
local parent = GUI:Win_Create(self.__cname, 0, 0, 0, 0, false, false, true, false)
|
|
|
|
if data then
|
|
GUI:Win_BindNPC(parent, data)
|
|
end
|
|
|
|
GUI:LoadExport(parent, "game/A/WuqiRongheUI")
|
|
|
|
self._parent = parent
|
|
self.ui = GUI:ui_delegate(parent)
|
|
|
|
--- 窗口初始化居中与动作
|
|
ssrUIManager:OpenAlgin(self)
|
|
|
|
|
|
--背景图关闭
|
|
GUI:addOnClickEvent(self.ui.bg_close, function()
|
|
GUI:Win_Close(self._parent)
|
|
end)
|
|
|
|
|
|
--关闭按钮背景板关闭
|
|
GUI:addOnClickEvent(self.ui.btn_close, function()
|
|
GUI:Win_Close(self._parent)
|
|
end)
|
|
-- ---* 绑定事件
|
|
self:EventBind()
|
|
|
|
if data and data.cfg then
|
|
self.cfg = data.cfg
|
|
end
|
|
|
|
self:updata()
|
|
end
|
|
|
|
|
|
function WuqiRongheOBJ:updata(num)
|
|
num = num or 1
|
|
self.z_select = num
|
|
GUI:ListView_removeAllItems(self.ui.ListView_1)
|
|
for i, v in ipairs(self.cfg) do
|
|
local z_btn = string.format("z_btn_%s", i)
|
|
self.ui[z_btn] = GUI:Button_Create(self.ui.ListView_1, z_btn, 0, 0, string.format(num == i and "res/custom/09/f/%d.png" or "res/custom/09/f/%da.png",i))
|
|
GUI:addOnClickEvent(self.ui[z_btn], function()
|
|
-- self:updata(i)
|
|
GUI:Button_loadTextureNormal(self.ui[string.format("z_btn_%s", self.z_select)], string.format("res/custom/09/f/%da.png",self.z_select))
|
|
GUI:Button_loadTextureNormal(self.ui[z_btn], string.format("res/custom/09/f/%d.png",i))
|
|
self.z_select = i
|
|
self:z_update(i)
|
|
end)
|
|
end
|
|
self:z_update(num)
|
|
end
|
|
|
|
|
|
function WuqiRongheOBJ:z_update(num,id)
|
|
id = id or 1
|
|
self.zz_select = id
|
|
GUI:ListView_removeAllItems(self.ui.ListView_2)
|
|
for i, v in ipairs(self.cfg[num]) do
|
|
local zz_btn = string.format("zz_btn_%s", i)
|
|
self.ui[zz_btn] = GUI:Button_Create(self.ui.ListView_2, zz_btn, 0, 0, string.format("res/custom/09/%s.png",id == i and 1 or 2))
|
|
GUI:Button_setTitleText(self.ui[zz_btn], v.name)
|
|
GUI:Button_setTitleColor(self.ui[zz_btn], id == i and "#fffffff" or "#C0C0C0")
|
|
GUI:Button_setTitleFontSize(self.ui[zz_btn], 16)
|
|
GUI:Button_titleEnableOutline(self.ui[zz_btn], "#000000", 2)
|
|
GUI:addOnClickEvent(self.ui[zz_btn], function()
|
|
-- self:updata(i)
|
|
GUI:Button_loadTextureNormal(self.ui[string.format("zz_btn_%s", self.zz_select)], string.format("res/custom/09/%d.png",2))
|
|
GUI:Button_setTitleColor(self.ui[string.format("zz_btn_%s", self.zz_select)], "#C0C0C0")
|
|
GUI:Button_loadTextureNormal(self.ui[zz_btn], string.format("res/custom/09/%d.png",1))
|
|
GUI:Button_setTitleColor(self.ui[zz_btn], "#ffffff")
|
|
self.zz_select = i
|
|
self:show(num,i)
|
|
end)
|
|
end
|
|
self:show(num,id)
|
|
|
|
end
|
|
|
|
|
|
|
|
function WuqiRongheOBJ:show(num,id)
|
|
local cfg = self.cfg[num][id]
|
|
hk.reloadItemShow(self.ui.hc_item, cfg.name, 1)
|
|
|
|
for i, v in ipairs(cfg.xh) do
|
|
local xh_item = string.format("xh_%s", i)
|
|
hk.reloadItemShow(self.ui[xh_item], v[1], v[2],nil,nil,true)
|
|
end
|
|
|
|
GUI:Text_setString(self.ui.Text_1, cfg.gl.."%")
|
|
|
|
GUI:addOnClickEvent(self.ui.Button, function()
|
|
ssrMessage:SubLink("WuqiRongheOBJ_up",cfg.id)
|
|
end)
|
|
|
|
|
|
-- ---* 初始化红点
|
|
self:reddot()
|
|
end
|
|
|
|
|
|
|
|
|
|
function WuqiRongheOBJ:reddot()
|
|
for i, v in ipairs(self.cfg) do
|
|
|
|
local num = 0
|
|
for z_i, z_v in ipairs(v)do
|
|
|
|
local zz_btn = string.format("zz_btn_%s", z_i)
|
|
local zz_btn_red = string.format("zz_btn_red_%d", z_i)
|
|
|
|
if hk.checkcontion(z_v.xh) then
|
|
num = num + 1
|
|
|
|
if self.z_select == i then
|
|
if GUI:Win_IsNull(self.ui[zz_btn_red]) then
|
|
local button_size = GUI:getContentSize(self.ui[zz_btn])
|
|
self.ui[zz_btn_red] = GUI:Image_Create(self.ui[zz_btn], zz_btn_red, button_size.width - 20,button_size.height - 20, "res/public/btn_npcfh_04.png")
|
|
end
|
|
end
|
|
else
|
|
if self.z_select == i then
|
|
if GUI:Win_IsNotNull(self.ui[zz_btn_red]) then
|
|
GUI:removeFromParent(self.ui[zz_btn_red])
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
local z_btn = string.format("z_btn_%s", i)
|
|
local z_btn_red = string.format("z_btn_red_%d", i)
|
|
|
|
if num > 0 then
|
|
if GUI:Win_IsNull(self.ui[z_btn_red]) then
|
|
local button_size = GUI:getContentSize(self.ui[z_btn])
|
|
self.ui[z_btn_red] = GUI:Image_Create(self.ui[z_btn], z_btn_red, button_size.width - 20,button_size.height - 20, "res/public/btn_npcfh_04.png")
|
|
end
|
|
else
|
|
if GUI:Win_IsNotNull(self.ui[z_btn_red]) then
|
|
GUI:removeFromParent(self.ui[z_btn_red])
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
------------------------网络消息------------------------
|
|
function WuqiRongheOBJ:upBool(arg1, arg2, arg3, data)
|
|
if GUI:Win_IsNotNull(self._parent) and data then
|
|
self:screffects(data[1])
|
|
end
|
|
end
|
|
|
|
|
|
|
|
---* 注册事件
|
|
function WuqiRongheOBJ:EventBind()
|
|
local function WuqiRongheOBJ_bag_del_Reload(data)
|
|
if GUI:Win_IsNotNull(self._parent) then
|
|
self:show(self.z_select,self.zz_select)
|
|
end
|
|
end
|
|
SL:RegisterLUAEvent(LUA_EVENT_BAG_ITEM_CHANGE, self.__cname, WuqiRongheOBJ_bag_del_Reload)
|
|
|
|
|
|
|
|
|
|
|
|
--关闭窗口
|
|
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName)
|
|
self:OnClose(widgetName)
|
|
end)
|
|
end
|
|
|
|
--关闭窗口
|
|
function WuqiRongheOBJ:OnClose(widgetName)
|
|
if widgetName == self.__cname then
|
|
self:UnRegisterEvent()
|
|
end
|
|
end
|
|
|
|
function WuqiRongheOBJ:UnRegisterEvent()
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_BAG_ITEM_CHANGE, self.__cname)
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname)
|
|
end
|
|
|
|
return WuqiRongheOBJ
|