107 lines
3.2 KiB
Lua
107 lines
3.2 KiB
Lua
local GMConst = require "app/module/gm/gm_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 inputField = self.uiMap['gm_tool_ui.InputField']
|
|
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"]
|
|
|
|
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 = "确定"
|
|
|
|
|
|
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)
|
|
|
|
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)
|
|
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, " ")
|
|
-- :dealGM(args, function()
|
|
-- :dataOperate(GConst..DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData)
|
|
-- DataManager:initWithServerData(msgData)
|
|
-- ModuleManager.MaincityManager:firstEnterMainCity()
|
|
-- end)
|
|
-- end)
|
|
end
|
|
end
|
|
|
|
function GMToolUI:updateTime()
|
|
local uiMap = self.root:genAllChildren()
|
|
uiMap["gm_tool_ui.time"]:setText(Time:formatTimeYMDHMS(Time:getServerTime()))
|
|
end
|
|
|
|
return GMToolUI
|