源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

100 linhas
3.9 KiB

CheatClientView = CheatClientView or BaseClass(BaseView)
function CheatClientView:__init()
self.base_file = "cheat"
self.layout_file = "CheatClientView"
self.layer_name = "Activity"
self.close_mode = CloseMode.CloseDestroy
self.destroy_imm = false
self.use_background = true
self.change_scene_close = true
self.hide_maincancas = false
self.item_list = {}
self.data = nil
self.model = CheatModel:getInstance()
self.load_callback = function()
self:LoadSuccess()
self:InitEvent()
self:InitData()
end
self.destroy_callback = function()
self:DestorySuccess()
end
end
function CheatClientView:DestorySuccess()
if self.event_id then
self.model:UnBind(self.event_id)
self.event_id = nil
end
end
function CheatClientView:LoadSuccess()
self.scroll_content = self:GetChild("ScrollView/Viewport/Content")
self.log_Text = self:GetChild("logText"):GetComponent("InputField")
end
function CheatClientView:InitEvent()
local appendInfoHandler = function (info_text)
info_text = tostring(info_text)
logWarn(info_text)
self.log_Text.text = self.log_Text.text .. info_text .. "\n"
end
self.event_id = self.model:Bind(CheatModel.CHEAT_PRINT_DEBUG_INFO, appendInfoHandler)
end
function CheatClientView:InitData()
CheatClientView.data = CheatClientView.data or {"自定义Log", "粒子特效数据", "设备类型", "设备ID", "屏幕宽", "显示主界面", "隐藏主界面", "查看帧数", "设备硬件"}
local cheatHandler = function(cheat_name)
if cheat_name == "自定义Log" then
self.model:Fire(CheatModel.CHEAT_PRINT_DEBUG_INFO, myclientlog)
elseif cheat_name == "粒子特效数据" then
ParticleManager:getInstance():PrintEffectCount()
elseif cheat_name == "设备类型" then
self.model:Fire(CheatModel.CHEAT_PRINT_DEBUG_INFO, Application.platform)
elseif cheat_name == "设备ID" then
self.model:Fire(CheatModel.CHEAT_PRINT_DEBUG_INFO, SystemInfo.deviceModel)
elseif cheat_name == "屏幕宽" then
self.model:Fire(CheatModel.CHEAT_PRINT_DEBUG_INFO, ScreenWidth .. " | " .. SrcScreenWidth)
elseif cheat_name == "显示主界面" then
lua_viewM:Fire(LuaViewManager.CHANGE_MAIN_CANVAS_VISIBLE, self, true)
elseif cheat_name == "隐藏主界面" then
lua_viewM:Fire(LuaViewManager.CHANGE_MAIN_CANVAS_VISIBLE, self, false)
elseif cheat_name == "查看帧数" then
self.model:Fire(CheatModel.CHEAT_PRINT_DEBUG_INFO, " FINAL_FRAMERATE: " .. FINAL_FRAMERATE.." CurFrame: "..Application.targetFrameRate)
elseif cheat_name == "设备硬件" then
local str = "memory:" .. SystemInfo.systemMemorySize .. "M\n"
.."graphicsMemory:" .. SystemInfo.graphicsMemorySize .. "M\n"
.."graphicsShaderLevel:" .. SystemInfo.graphicsShaderLevel .. "\n"
.."supportedRenderTargetCount:" .. SystemInfo.supportedRenderTargetCount .. "\n"
.."processorCount:" .. SystemInfo.processorCount .. "\n"
.."processorFrequency:" .. SystemInfo.processorFrequency .. "\n"
.."processorType:" .. SystemInfo.processorType .. "\n"
self.model:Fire(CheatModel.CHEAT_PRINT_DEBUG_INFO, str)
end
end
for k, v in ipairs(CheatClientView.data) do
local item = self.item_list[k]
if item == nil then
item = UiFactory.createChild(self.scroll_content, UIType.SmallButton1, v)
end
local x = 193 * ((k - 1) % 6)
local y = -70 * math.floor((k - 1) / 6) - 5
item.transform.pivot = Vector2(0,1)
item.transform.anchorMin = Vector2(0, 1)
item.transform.anchorMax = Vector2(0, 1)
item.transform.localPosition = Vector3(x,y,0)
item.transform:Find("Text"):GetComponent("Text").text = v
item.transform.sizeDelta = Vector2(180, 50)
item:SetActive(true)
local ClickFun = function (target)
cheatHandler(target.name)
end
AddClickEvent(item, ClickFun)
self.item_list[k] = item
end
self.scroll_content.sizeDelta = Vector2(1160, math.ceil((#CheatClientView.data) / 6) * 70)
self.scroll_content.localPosition = Vector3(0,0,0)
end