194 lines
6.8 KiB
Lua
194 lines
6.8 KiB
Lua
local DevToolManager = require "app/module/gm/dev_tool_manager"
|
|
local GMConst = require "app/module/gm/gm_const"
|
|
-- local ItemConst = require "app/module/item/item_const"
|
|
local GMToolUI = class("GMToolUI",BaseUI)
|
|
|
|
function GMToolUI:ctor()
|
|
end
|
|
|
|
function GMToolUI:getPrefabPath()
|
|
return "assets/prefabs/ui/gm/gm_tool_ui.prefab"
|
|
end
|
|
|
|
function GMToolUI:onLoadRootComplete()
|
|
self.sid = self:scheduleGlobal(function()
|
|
self:updateTime()
|
|
end, 1)
|
|
self:updateTime()
|
|
end
|
|
|
|
function GMToolUI:onRefresh()
|
|
self.uiMap = self.root:genAllChildren()
|
|
|
|
local titleTx = self.uiMap['gm_tool_ui.title']
|
|
local okBtn = self.uiMap['gm_tool_ui.ok_btn']
|
|
local okBtnText = self.uiMap['gm_tool_ui.ok_btn.text']
|
|
local helpBtn = self.uiMap['gm_tool_ui.help_btn']
|
|
local inputField = self.uiMap['gm_tool_ui.InputField']
|
|
local inputFieldText = self.uiMap['gm_tool_ui.InputField.text']
|
|
local scrollView = self.uiMap['gm_tool_ui.ScrollView']
|
|
local textTip = self.uiMap['gm_tool_ui.text_tip']
|
|
local speedUpBtn = self.uiMap["gm_tool_ui.speed_up_btn"]
|
|
local attrBtn = self.uiMap["gm_tool_ui.attr_btn"]
|
|
local attrBtnTx = self.uiMap["gm_tool_ui.attr_btn.text"]
|
|
local heroListNode = self.uiMap["gm_tool_ui.hero_list_node"]
|
|
self.heroListNode = heroListNode
|
|
|
|
self.uiMap['gm_tool_ui.close_btn']:addClickListener(function() self:closeUI() end)
|
|
self.scrollRect = scrollView:getLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
self.scrollRect:clearCells()
|
|
self.scrollRect:setFadeArgs(0, 0.3)
|
|
self.scrollRect:addInitCallback(function()
|
|
return "app/ui/gm/cell/dev_tool_cell"
|
|
end)
|
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
|
self:initScrollRectCell(index, cell)
|
|
end)
|
|
self.scrollRect:refillCells(#GMConst.GM_INFO)
|
|
|
|
self.textTip = textTip
|
|
self.inputField = inputField
|
|
titleTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "GM面板"
|
|
okBtnText:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "确定"
|
|
attrBtnTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "英雄属性"
|
|
|
|
|
|
okBtn:addClickListener(function()
|
|
local gmCommand = self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text
|
|
self:sendMsg(gmCommand)
|
|
self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text = ""
|
|
end)
|
|
|
|
speedUpBtn:addClickListener(function()
|
|
local timeScale = CS.UnityEngine.Time.timeScale
|
|
if timeScale == 1 then
|
|
timeScale = 2
|
|
elseif timeScale == 2 then
|
|
timeScale = 5
|
|
elseif timeScale == 5 then
|
|
timeScale = 10
|
|
else
|
|
timeScale = 1
|
|
end
|
|
CS.UnityEngine.Time.timeScale = timeScale
|
|
end)
|
|
|
|
attrBtn:addClickListener(function()
|
|
local allAttr = DataManager.HeroData:getMainHeroEntity():getAllAttr()
|
|
local allAttr1 = {}
|
|
local cfg = ConfigManager:getConfig("attr")
|
|
for i = 1, #cfg do
|
|
allAttr1[i] = {unit = allAttr[i].unit, value = allAttr[i].value}
|
|
end
|
|
Logger.logHighlight("============================ hero attr")
|
|
Logger.printTable(allAttr1)
|
|
Logger.logHighlight("============================ hero attr")
|
|
local str = json.encode(allAttr1)
|
|
ModuleManager.TipsManager:showHelpTips({desc = str})
|
|
end)
|
|
|
|
self.uiMap["gm_tool_ui.fps_btn"]:addClickListener(function()
|
|
local comp = UIManager.uiRoot:getComponent(typeof(CS.BF.ShowFPS))
|
|
if comp == nil then
|
|
comp = UIManager.uiRoot:addComponent(typeof(CS.BF.ShowFPS))
|
|
else
|
|
comp.enabled = not comp.enabled
|
|
end
|
|
end)
|
|
|
|
heroListNode:addClickListener(function()
|
|
heroListNode:setActive(false)
|
|
end)
|
|
end
|
|
|
|
function GMToolUI:initScrollRectCell(index, cell)
|
|
local data = GMConst.GM_INFO[index]
|
|
cell:addClickListener(function ()
|
|
self.textTip:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = data.desc
|
|
self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text = string.format("%s ", data.type)
|
|
end)
|
|
cell:refresh(data)
|
|
end
|
|
|
|
function GMToolUI:sendMsg(gmCommand)
|
|
if gmCommand == "" then
|
|
GFunc.showToast("GM命令不能为空")
|
|
else
|
|
local args = {}
|
|
args.args = string.split(gmCommand, " ")
|
|
if args.args[1] == "time" then -- 特殊处理
|
|
local args1 = {}
|
|
args1.args = {}
|
|
args1.args[1] = args.args[1]
|
|
args1.args[2] = args.args[2] .. " " .. args.args[3]
|
|
ModuleManager.DevToolManager:dealGM(args1)
|
|
else
|
|
ModuleManager.DevToolManager:dealGM(args)
|
|
end
|
|
end
|
|
end
|
|
|
|
function GMToolUI:initHeroScrollRect(index, cell)
|
|
self.heroList = {}
|
|
-- local HeroConst = require "app/module/hero/hero_const"
|
|
for hid, entity in pairs(DataManager.HeroData:getAllHero()) do
|
|
local star = entity:getStar()
|
|
local qlt = entity:getQuality()
|
|
local group = entity:getGroup()
|
|
local lv = entity:getLv()
|
|
local heroId = entity:getId()
|
|
local sort = 0
|
|
sort = heroId + group*10000000 + qlt*100000000 + star*1000000000 + lv*10000000000
|
|
-- if self.filterType == HeroConst.FILTER_TYPE.ALL then
|
|
-- sort = heroId + group*10000000 + qlt*100000000 + star*1000000000 + lv*10000000000
|
|
-- elseif self.filterType == HeroConst.FILTER_TYPE.STAR then
|
|
-- sort = heroId + group*10000000 + qlt*100000000 + lv*1000000000 + star*100000000000
|
|
-- elseif self.filterType == HeroConst.FILTER_TYPE.LV then
|
|
-- sort = heroId + group*10000000 + qlt*100000000 + star*1000000000 + lv*10000000000
|
|
-- elseif self.filterType == HeroConst.FILTER_TYPE.QLT then
|
|
-- sort = heroId + group*10000000 + star*100000000 + lv*1000000000 + qlt*100000000000
|
|
-- elseif self.filterType == HeroConst.FILTER_TYPE.GROUP then
|
|
-- sort = heroId + qlt*10000000 + star*100000000 + lv*1000000000 + group*100000000000
|
|
-- elseif self.filterType == HeroConst.FILTER_TYPE.USED then
|
|
-- end
|
|
table.insert(self.heroList, {
|
|
heroData = entity,
|
|
sort = sort
|
|
})
|
|
end
|
|
table.sort(self.heroList, function (a, b)
|
|
return a.sort > b.sort
|
|
end)
|
|
if self.heroScrollRect then
|
|
self.heroScrollRect:refillCells(#self.heroList)
|
|
return
|
|
end
|
|
local uiMap = self.root:genAllChildren()
|
|
self.heroScrollRect = uiMap["gm_tool_ui.hero_list_node.ScrollView (1)"]:getLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
self.heroScrollRect:clearCells()
|
|
self.heroScrollRect:setFadeArgs(0, 0.3)
|
|
self.heroScrollRect:addInitCallback(function()
|
|
return GConst.TYPEOF_LUA_CLASS.HERO_CELL
|
|
end)
|
|
self.heroScrollRect:addRefreshCallback(function(index, cell)
|
|
self:refreshHeroCell(cell, self.heroList[index].heroData)
|
|
end)
|
|
self.heroScrollRect:refillCells(#self.heroList)
|
|
end
|
|
|
|
function GMToolUI:refreshHeroCell(cell, heroData)
|
|
cell:refresh(heroData)
|
|
cell:addClickListener(function()
|
|
self.textTip:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "英雄升级 (会清空当前经验) \n arg1:英雄唯一ID arg2 目标等级"
|
|
self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text = string.format("%s %s ", "hero_upgrade", heroData:getHid())
|
|
self.heroListNode:setActive(false)
|
|
end)
|
|
end
|
|
|
|
function GMToolUI:updateTime()
|
|
local uiMap = self.root:genAllChildren()
|
|
uiMap["gm_tool_ui.time"]:setText(Time:formatTimeYMDHMS(Time:getServerTime()))
|
|
end
|
|
|
|
return GMToolUI
|