200 lines
6.9 KiB
Lua
200 lines
6.9 KiB
Lua
JueXueXiuLianOBJ = Up_BaseClassOBJ:new()
|
|
|
|
-- JueXueXiuLianOBJ = {}
|
|
|
|
JueXueXiuLianOBJ.__cname = "JueXueXiuLianOBJ"
|
|
|
|
-- UI文件
|
|
JueXueXiuLianOBJ.UIfile = "game/A/JueXueXiuLianUI"
|
|
|
|
|
|
-- 配置文件
|
|
JueXueXiuLianOBJ.cfg = {}
|
|
|
|
|
|
--* 初始化绝学界面
|
|
function JueXueXiuLianOBJ:updata()
|
|
GUI:removeAllChildren(self.ui.Icon_Layout)
|
|
|
|
if GUI:Win_IsNotNull(self.ui.select_bg) then
|
|
GUI:removeFromParent(self.ui.select_bg)
|
|
end
|
|
|
|
for i, v in ipairs(self.cfg.juexue) do
|
|
local list_icon = string.format("list_icon_%d", i)
|
|
self.ui[list_icon] = GUI:Button_Create(self.ui.Icon_Layout, list_icon, 0, 0, string.format("res/custom/11/magicIcon/%d.png", v.icon))
|
|
GUI:setContentSize(self.ui[list_icon], 52, 52)
|
|
GUI:setGrey(self.ui[list_icon], self:get(i))
|
|
GUI:Win_SetParam(self.ui[list_icon], #self.cfg.juexue - i)
|
|
GUI:addOnClickEvent(self.ui[list_icon], function()
|
|
if GUI:Win_IsNotNull(self.ui.select_bg) then
|
|
GUI:removeFromParent(self.ui.select_bg)
|
|
end
|
|
|
|
self.ui.select_bg = GUI:Image_Create(self.ui[list_icon], "select_bg", 26, 26, "res/custom/11/4.png")
|
|
GUI:setAnchorPoint(self.ui.select_bg, 0.50, 0.50)
|
|
self:show(i)
|
|
end)
|
|
end
|
|
|
|
GUI:UserUILayout(self.ui.Icon_Layout, {
|
|
dir = 3,
|
|
addDir = 1,
|
|
interval = 0,
|
|
gap = { x = 28, y = 8 },
|
|
rownums = { 3, 3, 3, 3, 3, 3, 3 },
|
|
sortfunc = function(lists)
|
|
table.sort(lists, function(a, b)
|
|
return GUI:Win_GetParam(a) > GUI:Win_GetParam(b)
|
|
end)
|
|
end
|
|
})
|
|
|
|
self:jiesuo()
|
|
-- self:show(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
---* 效果展示
|
|
function JueXueXiuLianOBJ:show(id)
|
|
GUI:setVisible(self.ui.up_btn, false)
|
|
GUI:Text_setString(self.ui.PS_Text, string.format("%s:%s",self.cfg.juexue[id].name,self.cfg.juexue[id].effec))
|
|
end
|
|
|
|
|
|
|
|
function JueXueXiuLianOBJ:get(id)
|
|
local jiesuoCfg = hk.getkeytbl("HUMAN(STR_绝学修炼)")
|
|
for i, v in pairs(jiesuoCfg or {}) do
|
|
if v == id then
|
|
return false
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
|
|
----* 人物解锁格子初始化
|
|
function JueXueXiuLianOBJ:jiesuo()
|
|
self.id = self.id or 1
|
|
local jiesuoCfg = hk.getkeytbl("HUMAN(STR_绝学修炼)")
|
|
GUI:ListView_removeAllItems(self.ui.xl_ListView)
|
|
for i = 1, 4, 1 do
|
|
local open = jiesuoCfg[i] and true or false
|
|
|
|
local jiesuolist = string.format("jiesuolist_%d", i)
|
|
self.ui[jiesuolist] = GUI:Image_Create(self.ui.xl_ListView, jiesuolist, 0, 0, string.format("res/custom/11/box/%d.png", not open and i or 6))
|
|
GUI:setTouchEnabled(self.ui[jiesuolist], true)
|
|
|
|
if open and jiesuoCfg[i] > 0 then
|
|
local jiesuo_icon = string.format("jiesuo_icon_%d", i)
|
|
self.ui[jiesuo_icon] = GUI:Image_Create(self.ui[jiesuolist], jiesuo_icon, 34, 54, string.format("res/custom/11/magicIcon/%d.png", self.cfg.juexue[jiesuoCfg[i]].icon))
|
|
GUI:setContentSize(self.ui[jiesuo_icon], 60, 60)
|
|
GUI:setAnchorPoint(self.ui[jiesuo_icon], 0.50, 0.50)
|
|
|
|
local juexue_name = string.format("juexue_name_%d", i)
|
|
self.ui[juexue_name] = GUI:Text_Create(self.ui[jiesuolist], juexue_name, 34, 12, 13, "#ffffff", self.cfg.juexue[jiesuoCfg[i]].name)
|
|
|
|
|
|
if self.id == i then
|
|
if GUI:Win_IsNotNull(self.ui.select_bg) then
|
|
GUI:removeFromParent(self.ui.select_bg)
|
|
end
|
|
self.ui.select_bg = GUI:Image_Create(self.ui[jiesuo_icon], "select_bg", 30, 30, "res/custom/11/4.png")
|
|
GUI:setAnchorPoint(self.ui.select_bg, 0.50, 0.50)
|
|
self:show(jiesuoCfg[i])
|
|
self.xh = self.cfg.xilian
|
|
self:setxh()
|
|
GUI:setVisible(self.ui.up_btn, true)
|
|
end
|
|
|
|
|
|
GUI:setAnchorPoint(self.ui[juexue_name], 0.50, 0.50)
|
|
GUI:addOnClickEvent(self.ui[jiesuolist], function()
|
|
self.id = i
|
|
if GUI:Win_IsNotNull(self.ui.select_bg) then
|
|
GUI:removeFromParent(self.ui.select_bg)
|
|
end
|
|
self.ui.select_bg = GUI:Image_Create(self.ui[jiesuo_icon], "select_bg", 30, 30, "res/custom/11/4.png")
|
|
GUI:setAnchorPoint(self.ui.select_bg, 0.50, 0.50)
|
|
self:show(jiesuoCfg[i])
|
|
GUI:setVisible(self.ui.up_btn, true)
|
|
|
|
GUI:Button_loadTextureNormal(self.ui.up_btn, "res/custom/11/5.png")
|
|
GUI:Button_loadTexturePressed(self.ui.up_btn, "res/custom/11/6.png")
|
|
self.xh = self.cfg.xilian
|
|
self:setxh()
|
|
GUI:addOnClickEvent(self.ui.up_btn, function()
|
|
ssrMessage:SubLink(self.__cname .. "_up", { id = i })
|
|
end)
|
|
end)
|
|
else
|
|
GUI:addOnClickEvent(self.ui[jiesuolist], function()
|
|
GUI:Button_loadTextureNormal(self.ui.up_btn, "res/custom/11/10.png")
|
|
GUI:Button_loadTexturePressed(self.ui.up_btn, "res/custom/11/11.png")
|
|
self.xh = self.cfg.jiesuo[i].xh
|
|
self:setxh()
|
|
|
|
GUI:addOnClickEvent(self.ui.up_btn, function()
|
|
ssrMessage:SubLink(self.__cname .. "_jiesuo", { id = i })
|
|
end)
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
|
|
function JueXueXiuLianOBJ:setxh()
|
|
GUI:removeAllChildren(self.ui.xh_Layout)
|
|
local index = 1
|
|
for i, v in ipairs(self.xh) do
|
|
local list_xh_Text = string.format("list_xh_Text_%d", i)
|
|
self.ui[list_xh_Text] = GUI:Text_Create(self.ui.xh_Layout, list_xh_Text, 0, 0, 14, "#00ff00", string.format("%s x %s", v[1], SL:GetSimpleNumber(v[2], 0)))
|
|
GUI:Text_enableOutline(self.ui[list_xh_Text], "#000000", 2)
|
|
GUI:Win_SetParam(self.ui[list_xh_Text], #self.xh - i)
|
|
end
|
|
|
|
GUI:UserUILayout(self.ui.xh_Layout, {
|
|
dir = 2,
|
|
addDir = 1,
|
|
interval = 0,
|
|
gap = { x = 14 },
|
|
sortfunc = function(lists)
|
|
table.sort(lists, function(a, b)
|
|
return GUI:Win_GetParam(a) > GUI:Win_GetParam(b)
|
|
end)
|
|
end
|
|
})
|
|
end
|
|
|
|
|
|
---* 注册事件
|
|
function JueXueXiuLianOBJ:EventBind()
|
|
local function JueXueXiuLianOBJ_Var_Change(data)
|
|
if GUI:Win_IsNotNull(self._parent) then
|
|
if data.key == "HUMAN(STR_绝学修炼)" then
|
|
self:updata()
|
|
end
|
|
end
|
|
end
|
|
SL:RegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname, JueXueXiuLianOBJ_Var_Change, self._parent)
|
|
|
|
--关闭窗口
|
|
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName)
|
|
self:OnClose(widgetName)
|
|
end)
|
|
end
|
|
|
|
--关闭窗口
|
|
function JueXueXiuLianOBJ:OnClose(widgetName)
|
|
if widgetName == self.__cname then
|
|
self:UnRegisterEvent()
|
|
end
|
|
end
|
|
|
|
function JueXueXiuLianOBJ:UnRegisterEvent()
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname)
|
|
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname)
|
|
end
|
|
|
|
return JueXueXiuLianOBJ
|