175 lines
4.9 KiB
Lua
175 lines
4.9 KiB
Lua
WuqiJinJieOBJ = Up_BaseClassOBJ:new()
|
|
|
|
WuqiJinJieOBJ.__cname = "WuqiJinJieOBJ"
|
|
|
|
-- 配置文件
|
|
WuqiJinJieOBJ.cfg = {}
|
|
|
|
function WuqiJinJieOBJ:main(arg1, arg2, arg3, data)
|
|
local parent = GUI:Win_Create(self.__cname, 0, 0, 0, 0, false, false, true, false)
|
|
|
|
if data and data.npcid then
|
|
GUI:Win_BindNPC(parent, data.npcid)
|
|
end
|
|
|
|
|
|
GUI:LoadExport(parent, "game/A/WuqiJinJieUI")
|
|
|
|
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
|
|
WuqiJinJieOBJ.cfg = data.cfg
|
|
end
|
|
|
|
self:updata()
|
|
end
|
|
|
|
|
|
function WuqiJinJieOBJ: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("res/custom/08/%d.png",num == i and 1 or 3))
|
|
GUI:Button_setTitleText(self.ui[z_btn], v.name)
|
|
GUI:Button_setTitleColor(self.ui[z_btn], num == i and "#fffffff" or "#C0C0C0")
|
|
GUI:Button_setTitleFontSize(self.ui[z_btn], 16)
|
|
GUI:Button_titleEnableOutline(self.ui[z_btn], "#000000", 2)
|
|
|
|
GUI:addOnClickEvent(self.ui[z_btn], function()
|
|
GUI:Button_loadTextureNormal(self.ui[string.format("z_btn_%s", self.z_select)], string.format("res/custom/08/%d.png",3))
|
|
GUI:Button_setTitleColor(self.ui[string.format("z_btn_%s", self.z_select)], "#C0C0C0")
|
|
GUI:Button_loadTextureNormal(self.ui[z_btn], string.format("res/custom/08/%d.png",1))
|
|
GUI:Button_setTitleColor(self.ui[z_btn], "#fffffff")
|
|
self.z_select = i
|
|
self:show(i)
|
|
end)
|
|
end
|
|
|
|
self:show(num)
|
|
|
|
end
|
|
|
|
|
|
function WuqiJinJieOBJ:show(num)
|
|
if not num then
|
|
return
|
|
end
|
|
local cfg = self.cfg[num]
|
|
|
|
hk.reloadItemShow(self.ui.hc_item, cfg.name, 1)
|
|
|
|
for i = 1, 2, 1 do
|
|
local xh_item = string.format("xh_%s", i)
|
|
hk.reloadItemShow(self.ui[xh_item], cfg.xh[1][1], 1)
|
|
end
|
|
|
|
local xh_item = string.format("xh_%s", 3)
|
|
hk.reloadItemShow(self.ui[xh_item], cfg.xh[2][1], cfg.xh[2][2])
|
|
|
|
|
|
GUI:Text_setString(self.ui.Text_1, cfg.gl.."%")
|
|
|
|
|
|
GUI:addOnClickEvent(self.ui.Button, function()
|
|
ssrMessage:SubLink("WuqiJinJieOBJ_up",num)
|
|
end)
|
|
|
|
---* 初始化红点
|
|
self:reddot()
|
|
end
|
|
|
|
|
|
|
|
|
|
function WuqiJinJieOBJ:reddot()
|
|
for i, v in ipairs(self.cfg) do
|
|
local z_btn = string.format("z_btn_%s", i)
|
|
local z_btn_red = string.format("z_btn_red_%d", i)
|
|
|
|
if hk.checkcontion(v.xh) 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
|
|
|
|
if self.z_select == i then
|
|
local up_red = string.format("up_red_%d", 1)
|
|
if hk.checkcontion(v.xh) then
|
|
if GUI:Win_IsNull(self.ui[up_red]) then
|
|
local button_size = GUI:getContentSize(self.ui.Button)
|
|
self.ui[up_red] = GUI:Image_Create(self.ui.Button, up_red, button_size.width - 20,button_size.height - 20, "res/public/btn_npcfh_04.png")
|
|
end
|
|
else
|
|
if GUI:Win_IsNotNull(self.ui[up_red]) then
|
|
GUI:removeFromParent(self.ui[up_red])
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
------------------------网络消息------------------------
|
|
function WuqiJinJieOBJ:upBool(arg1, arg2, arg3, data)
|
|
if GUI:Win_IsNotNull(self._parent) and data then
|
|
self:screffects(data[1])
|
|
end
|
|
end
|
|
|
|
|
|
|
|
---* 注册事件
|
|
function WuqiJinJieOBJ:EventBind()
|
|
local function WuqiJinJieOBJ_bag_del_Reload()
|
|
if GUI:Win_IsNotNull(self._parent) then
|
|
self:show(self.z_select)
|
|
end
|
|
end
|
|
SL:RegisterLUAEvent(LUA_EVENT_BAG_ITEM_CHANGE, self.__cname, WuqiJinJieOBJ_bag_del_Reload)
|
|
|
|
--关闭窗口
|
|
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName)
|
|
self:OnClose(widgetName)
|
|
end)
|
|
end
|
|
|
|
--关闭窗口
|
|
function WuqiJinJieOBJ:OnClose(widgetName)
|
|
if widgetName == self.__cname then
|
|
self:UnRegisterEvent()
|
|
end
|
|
end
|
|
|
|
function WuqiJinJieOBJ:UnRegisterEvent()
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_BAG_ITEM_CHANGE, self.__cname)
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname)
|
|
end
|
|
|
|
return WuqiJinJieOBJ
|