CheatInputView = CheatInputView or BaseClass(BaseView) function CheatInputView:__init() self.base_file = "cheat" self.layout_file = "CheatInputView" self.layer_name = "Top" self.close_mode = CloseMode.CloseDestroy self.destroy_imm = false self.use_background = true self.change_scene_close = true self.hide_maincancas = true -- self.blur_activity_bg = true self.item_list = {} self.cheat_history_list = {} self.data = nil self.is_set_zdepth = true self.model = CheatModel:getInstance() self.load_callback = function() self:LoadSuccess() self:InitEvent() end self.open_callback = function ( ) self.model.is_open_cheat_view = true GlobalEventSystem:Fire(EventName.REQUEST_MIJI_DATA) if self.model.cache_text and self.model.cache_text ~= "" then self.cheatInputText.text = self.model.cache_text end end self.destroy_callback = function() self:DestorySuccess() end self.close_callback = function() self.model.is_open_cheat_view = false end self.history = CookieWrapper.Instance:GetCookie(CookieLevelType.Common,CookieKey.CHEAT_HISTORY) or {} end function CheatInputView:DestorySuccess() if self.event_id then self.model:UnBind(self.event_id) self.event_id = nil end if self.event_id2 then self.model:UnBind(self.event_id2) self.event_id2 = nil end if self.question_time_id then GlobalTimerQuest:CancelQuest(self.question_time_id) self.question_time_id = nil end end function CheatInputView:LoadSuccess() self.cheatInputText = self:GetChild("cheatInput"):GetComponent("InputField") -- self.holderText = self:GetChild("cheatInput/Placeholder"):GetComponent("Text") self.okBtn = self:GetChild("okBtn").gameObject self.scroll_content = self:GetChild("ScrollView/Viewport/Content") self.serachInputText = self:GetChild("serachInput"):GetComponent("InputField") self.serachBtn = self:GetChild("serachBtn").gameObject self.history_scroll_content = self:GetChild("historybg/ScrollView/Viewport/Content") self.clearBtn = self:GetChild("historybg/clearBtn").gameObject self.closeBtn = self:GetChild("WindowNew2/di_head/windowCloseBtn").gameObject end function CheatInputView:InitEvent() local function onBtnClickHandler(target) if target == self.closeBtn then self:Close() end end AddClickEvent(self.closeBtn, onBtnClickHandler, 1) local function onBtnClickHandler(target) local is_search_goods_id = self:IsSearchGoods() local is_send_pt = is_search_goods_id and false or self:IsSendPT() if target == self.okBtn then print("秘籍的内容是===:", self.cheatInputText.text) self.model.cache_text = self.cheatInputText.text self:SaveCheatHidtory() self:CreateCheatHistory() if self:IsParmCheat(self.cheatInputText.text) then local list = Split(self.cheatInputText.text,"_") local str = list[1] if str == "guide" then local lv = tonumber(list[2]) if lv then GlobalEventSystem:Fire(EventName.TEST_HELP_STEP,lv) end self:Close() elseif str == "autorotate" then local rotate_type = tonumber(list[2]) G_AUTO_ROTATE = rotate_type print("tanar: [CheatInputView 98]=> rotate_type: ",rotate_type) elseif str == "blink" then local x = tonumber(list[2]) local y = tonumber(list[3]) if Scene.Instance.main_role then GlobalEventSystem:Fire(SceneEventType.MOVEREQUEST, x,y, MOVE_TYPE.BLINK) Scene.Instance.main_role:SetRealPos(x,y) end elseif str == "damageflag" then local flag = tonumber(list[2]) G_DEBUG_DAMAGE_FLAG = flag print("tanar - [ CheatInputView ] [59] ==> G_DEBUG_DAMAGE_FLAG: ",G_DEBUG_DAMAGE_FLAG) return elseif str == "dragon" then -- WelecomeController.Instance:PlayEnd() -- WelecomeModel.Instance.horse_fly_movie_is_playEnd = false -- local onDelay = function ( ) -- WelecomeController.Instance:CreateCoud() -- WelecomeController.Instance:StartUpdate() -- local ond = function ( ) -- GlobalEventSystem:Fire(EventName.JUMP_UP_HORSE) -- end -- setTimeout(ond, 0.5) -- end -- setTimeout(onDelay, 0.5) elseif str == "task_auto" then TaskModel:getInstance():AutoDoTaskByType() elseif str == "update" then local step = tonumber(list[2]) G_DEBUG_UPDATE_STEP = step Message.show("update_step = "..step) end -- self:Close() return end if self.cheatInputText.text == "ban_auto_connect" then ClientConfig.is_ban_auto_connect = true Message.show("已禁止自动重连") elseif self.cheatInputText.text == "hot_ele_cfg" then self:Close() Scene.Instance.mapView:UnRegiestElevatorModelList() package.loaded["config.client.ConfigSceneElevatorModel"] = nil pcall(require, "config.client.ConfigSceneElevatorModel") Scene.Instance.mapView:RegisterElevatorModelList() elseif self.cheatInputText.text == "on_mon_list" then self.model:OnCreateMonList() self:Close() elseif self.cheatInputText.text == "change_dir" then if ClientConfig.orientation_did_change == 3 then ClientConfig.orientation_did_change = 4 else ClientConfig.orientation_did_change = 3 end if ClientConfig.orientation_did_change == 3 then ClientConfig.iphone_x_offset_left = 55 ClientConfig.iphone_x_offset_right = 0 elseif ClientConfig.orientation_did_change == 4 then ClientConfig.iphone_x_offset_left = 0 ClientConfig.iphone_x_offset_right = 55 end GlobalEventSystem:Fire(EventName.ORIENTATION_DID_CHANGE) elseif self.cheatInputText.text == "perform" then GlobalEventSystem:Fire(EventName.OPEN_LUA_STATE_VIEW) --lua状态 elseif self.cheatInputText.text == "Position" then local role_vo = RoleManager.Instance.mainRoleInfo print("[ Position ] ==> role_vo.pos_x: ",role_vo.pos_x) print("[ Position ] ==> role_vo.pos_y: ",role_vo.pos_y) local sceneInfo = SceneManager:getInstance():GetSceneInfo(scene_id) print("[ Position ] ==> sceneInfo.type: ",sceneInfo.type) print("[ Position ] ==> sceneInfo.subtype: ",sceneInfo.subtype) print("[ Position ] ==> sceneInfo.id: ",sceneInfo.id) local main_camera_transform = MainCamera:getInstance().transform local camera_pos = main_camera_transform.position print("tanar: [CheatInputView 174]=> camera_pos.x: ",camera_pos.x) print("tanar: [CheatInputView 174]=> camera_pos.y: ",camera_pos.y) print("tanar: [CheatInputView 174]=> camera_pos.z: ",camera_pos.z) elseif self.cheatInputText.text == "role_id" then local role_id = RoleManager.Instance.mainRoleInfo.role_id or "木有id" Message.show("role_id输入框复制走起") print("role_id = ", role_id) self.cheatInputText.text = role_id elseif string.find(self.cheatInputText.text,"framecount") then local tbl = Split(self.cheatInputText.text,"_") FINAL_FRAMERATE = tonumber(tbl[2]) SetGameFrameRate(tonumber(tbl[2])) elseif string.find(self.cheatInputText.text, "setplatform") then --平台设置 local mystr = self.cheatInputText.text ClientConfig.plat_name = tostring(string.sub(mystr, 13, string.len(mystr))) -- print("======= set platform", ClientConfig.plat_name) elseif self.cheatInputText.text == "auto_upgrade" then self.model:AutoUpgradeFight() elseif string.find(self.cheatInputText.text,"open_story") then local args = Split(self.cheatInputText.text,"_") local id = tonumber(args[3]) local index = tonumber(args[4]) local time = tonumber(args[5]) or 0 GlobalEventSystem:Fire(EventName.STORY_PLAY_TRIGGER,id,index,time) elseif self.cheatInputText.text == "f" then HonourModel:getInstance():SetResultData() elseif self.cheatInputText.text == "camera_edit" then self.model:Fire(CheatModel.OPEN_CAMERA_EDIt_VIEW) elseif self.cheatInputText.text == "ui_camera_edit" then self.model:Fire(CheatModel.OPEN_UI_CAMERA_EDIT_VIEW) elseif self.cheatInputText.text == "bloomobj" then self.main_role = Scene.Instance:GetMainRole() self.main_role_transform = self.main_role and self.main_role.parent_transform if self.main_role_transform then Optimizer.ChangeLayer(self.main_role_transform, "BloomObj") end -- self.camera_gameObject = MainCamera.Instance.camera_gameObject -- if not self.camera_pp_volume then -- self.camera_pp_volume = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessVolume)) -- end -- self.camera_pp_volume.enabled = true -- if not self.camera_pp_layer then -- self.camera_pp_layer = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessLayer)) -- end -- self.camera_pp_layer.enabled = true elseif self.cheatInputText.text == "hide_pp" then self.camera_gameObject = MainCamera.Instance.camera_gameObject if not self.camera_pp_volume then self.camera_pp_volume = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessVolume)) end self.camera_pp_volume.enabled = false if not self.camera_pp_layer then self.camera_pp_layer = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessLayer)) end self.camera_pp_layer.enabled = false elseif self.cheatInputText.text == "change_bloom" then -- self.camera_obj = MainCamera:getInstance().camera_gameObject -- if not self.bloom_effect then -- self.bloom_effect = self.camera_obj:GetComponent(typeof(UnityStandardAssets.ImageEffects.BloomOptimized)) -- end -- local cur_enabled = self.bloom_effect.enabled -- self.bloom_effect.enabled = not cur_enabled self.model:Fire(CheatModel.OPEN_BLOOM_EDIt_VIEW) GlobalEventSystem:Fire(EventName.OPEN_CHEAT_INPUT_VIEW) return elseif self.cheatInputText.text == "hide_main_canvas" then if not m_hide_main_canvas_btn then m_hide_main_canvas_btn = UiFactory.createChild(panelMgr:GetParent("Top"),UIType.ImageButton,"m_hide_main_canvas_btn") SetSizeDelta(m_hide_main_canvas_btn.transform, 100, 100) SetLocalPosition(m_hide_main_canvas_btn.transform, 0, 0, 0) local function callback( ) local main_canvas = panelMgr:GetParent("Main") local cur_visible = main_canvas.gameObject.activeSelf main_canvas.gameObject:SetActive(not cur_visible) end AddClickEvent(m_hide_main_canvas_btn, callback) end elseif self.cheatInputText.text == "hide_scene" then if not m_hide_scene_btn then m_hide_scene_btn = UiFactory.createChild(panelMgr:GetParent("Top"),UIType.ImageButton,"m_hide_main_canvas_btn") SetSizeDelta(m_hide_scene_btn.transform, 100, 100) SetLocalPosition(m_hide_scene_btn.transform, 100, 0, 0) local function callback( ) m_hide_scene_flag = m_hide_scene_flag == nil and false or m_hide_scene_flag m_hide_scene_flag = not m_hide_scene_flag if m_hide_scene_flag then GlobalEventSystem:Fire(EventName.DO_MODULE_DEBUG_FUNC, "mapview", "hiderootall") else GlobalEventSystem:Fire(EventName.DO_MODULE_DEBUG_FUNC, "mapview", "showrootall") end end AddClickEvent(m_hide_scene_btn, callback) end elseif self.cheatInputText.text == "hide_main_role" then G_DEBUG_HIDE_MAIN_ROLE = G_DEBUG_HIDE_MAIN_ROLE or false G_DEBUG_HIDE_MAIN_ROLE = not G_DEBUG_HIDE_MAIN_ROLE Message.show("G_DEBUG_HIDE_MAIN_ROLE = " .. tostring(G_DEBUG_HIDE_MAIN_ROLE)) local main_role = Scene.Instance.main_role if main_role then main_role:SetModelHideFlag(SceneObj.ModelHideFlag.PerformanceHide, G_DEBUG_HIDE_MAIN_ROLE) end return elseif self.cheatInputText.text == "client_property" then self.model:Fire(CheatModel.OPEN_CLIENT_PROPERTY_VIEW) elseif self.cheatInputText.text == "lua_profiler" then Message.show("lua_profiler") LuaProfiler.SwitchState() return elseif self.cheatInputText.text == "stop_action" then G_DEBUG_STOP_ACTION = G_DEBUG_STOP_ACTION or false G_DEBUG_STOP_ACTION = not G_DEBUG_STOP_ACTION Message.show("G_DEBUG_STOP_ACTION = " .. tostring(G_DEBUG_STOP_ACTION)) return elseif self.cheatInputText.text == "client_gyro" then self.model:Fire(CheatModel.OPEN_CLIENT_ACCELERATION_VIEW) elseif string.find(self.cheatInputText.text,"open_fun_") then self:Close() local str = string.gsub(self.cheatInputText.text,"open_fun_","") setTimeout(function ( ... ) GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE,tonumber(str)) -- 触发升级引导 end,0.2) elseif is_search_goods_id then local str = string.gsub(self.cheatInputText.text,"search_goods_","") local type_id = GoodsModel:getInstance():GetGoodsCfgByName(str) if type_id then self.cheatInputText.text = "goods_"..type_id.."_1" else Message.show("没找到这个名字的物品啊~你有没有打错字") end elseif string.find(self.cheatInputText.text,"RunCode:") then -- 范例local str = "@RunCode:local a = BossModel:GetInstance().world_boss_status; Message.show(a)" self.model:Fire(CheatModel.Quick_Run_Code,self.cheatInputText.text) elseif self:IsGuildTVBarrageCheat(self.cheatInputText.text) then local list = Split(text,"_") local time = tonumber(list[2]) or 100 local function on_add_barrage( ... ) local time = TimeUtil:getServerTimeMs( ) local id = math.random(100000,999999) local name_len = math.random(1,6) local text_len = math.random(1,20) local name_str = "玩家名字六字" local text_str = "一二三四五六七八九十一二三四五六七八九十" local data = { name = string.sub(name_str, name_len), id = id, time = time, } data.content = string.sub(text_str, text_len) GuildTVModel:GetInstance():AddGuildTVBarrageMessage(data) end local function on_answer_time( ) if time <= 0 then if self.question_time_id then GlobalTimerQuest:CancelQuest(self.question_time_id) self.question_time_id = nil end else time = time - 1 on_add_barrage() end end if not self.question_time_id then self.question_time_id = GlobalTimerQuest:AddPeriodQuest(on_answer_time, 0.01, -1) end elseif self.cheatInputText.text == "fxaa_edit" then self.model:Fire(CheatModel.OPEN_FXAA_TEST_VIEW, true) GlobalEventSystem:Fire(EventName.OPEN_CHEAT_INPUT_VIEW) return elseif self.cheatInputText.text == "free_camera" then self.model:Fire(CheatModel.OPEN_FREE_CAMERA_VIEW, true) GlobalEventSystem:Fire(EventName.OPEN_CHEAT_INPUT_VIEW) return elseif self.cheatInputText.text == "enablegs" then LoginModel.ENABLE_GREEN_SCREEN = true Message.show("绿屏模式启动,打开支持绿屏的窗口即生效,界面内左上角热区可以切换绿屏") elseif self.cheatInputText.text == "hide_ui" then -- 隐藏主UI panelMgr:GetParent("Main").gameObject:SetActive(false) panelMgr:GetParent("NameBoard").gameObject:SetActive(false) panelMgr:GetParent("Dynamic_NameBoard").gameObject:SetActive(false) elseif self.cheatInputText.text == "show_ui" then -- 显示主UI panelMgr:GetParent("Main").gameObject:SetActive(true) panelMgr:GetParent("NameBoard").gameObject:SetActive(true) panelMgr:GetParent("Dynamic_NameBoard").gameObject:SetActive(true) --拼图游戏 elseif self.cheatInputText.text == "jipsaw" then RechargeActivityModel.getInstance():Fire(RechargeActivityModel.OPEN_JIPSAW_VIEW) self:Close() return --刮刮乐 elseif self.cheatInputText.text == "guaguale" then RechargeActivityModel.getInstance():Fire(RechargeActivityModel.OPEN_GUAGUALE_VIEW) self:Close() return elseif self.cheatInputText.text == "load_base_scene" then CheatModel:getInstance():LoadBaseSceneRes( ) return elseif string.find(self.cheatInputText.text, "play_story_") then local txt = self.cheatInputText.text local t_id = string.gsub(txt, "play_story_", "") local id = tonumber(t_id) local exit = false local cfg = Config.Story for k,v in pairs(cfg) do for kk,vv in pairs(v) do if kk == id then local main_role = Scene.Instance.main_role if vv and main_role then main_role:DoStory(vv) exit = true end end end end if exit then self:Close() else Message.show("不存在当前剧情 id ",id) end return elseif self.cheatInputText.text == "galaxy" then OpenFun.Open(148,1) self:Close() return elseif self.cheatInputText.text == "ChangeSceneMovie" then self:Close() local function on_delay( ) ChangeSceneMovie.getInstance():TryOpen() end setTimeout(on_delay, 1) return elseif self.cheatInputText.text == "ChangeSceneMovieRT" then self:Close() local function on_delay( ) ChangeSceneMovieRT.getInstance():TryOpen() end setTimeout(on_delay, 1) return elseif self.cheatInputText.text == "MemoryLevel" then local men = Util.GetSystemMemorySize()/1024 local men_ceil = math.ceil(men) Message.show("men = " .. tostring(men) .. " men_floor = " ..tostring(men_ceil)) return elseif self.cheatInputText.text == "ChangeGuildMapRes" then local function on_delay( ) Scene.Instance.mapView.ignore_reset_guild_res_id = true Scene.Instance.mapView:OnUpdateGuildMapResByTime(true) end self:Close() setTimeout(on_delay, 2) return elseif is_send_pt then local str = Split(self.cheatInputText.text,"_") local len = TableSize(str) if tonumber(str[len]) then local text = string.gsub(self.cheatInputText.text,"_"..str[len], "") for i=1,tonumber(str[len]) do self.model:Fire(CheatModel.SEND_CHEAT_TO_SERVER, text) end else self.model:Fire(CheatModel.SEND_CHEAT_TO_SERVER, self.cheatInputText.text) end else local is_change_scene = string.find(self.cheatInputText.text, "scene_") if is_change_scene then Scene.Instance.mapView.ignore_reset_guild_res_id = true end self.model:Fire(CheatModel.SEND_CHEAT_TO_SERVER, self.cheatInputText.text) end -- self:Close() end end AddClickEvent(self.okBtn,onBtnClickHandler) local function on_click_ok_btn() onBtnClickHandler(self.okBtn) end self.event_id2 = self.model:Bind(CheatModel.CLICK_BTN_OK, on_click_ok_btn) local function onBtnClickHandler(target) if target == self.serachBtn then print("秘籍的内容是===:", self.serachInputText.text) if Trim(self.serachInputText.text) == "" then self:SetData() return end self:SetSearchData(self.serachInputText.text) end end AddClickEvent(self.serachBtn,onBtnClickHandler) local function onBtnClearBtn(target) if target == self.clearBtn then local function ok( ... ) self.history = {} self:SaveCheatHidtory(true) self:CreateCheatHistory() end local ask_str = "确定要清理记录?" Alert.show(ask_str,Alert.Type.Two,ok,nil,"确定","取消") end end AddClickEvent(self.clearBtn,onBtnClearBtn) local update_fun = function () self:SetData() end self.event_id = self.model:Bind(CheatModel.UPDATE_CHEAT_INPUT_VIEW, update_fun) self:SetData() self:CreateCheatHistory() end function CheatInputView:SetData() self.data = self.model.cheats_data if self.data == nil then return end self:CreateCheatList(self.data.command_list) end function CheatInputView:CreateCheatList(data) local item = nil for i = 1,#self.item_list do item = self.item_list[i] item:SetActive(false) end if not IsTableEmpty(data) then for k,v in ipairs(data) do local item = self.item_list[k] if item == nil then item = UiFactory.createChild(self.scroll_content, UIType.SmallButton3, k) end local x = 157 * ((k - 1) % 7) local y = -70 * math.floor((k - 1) / 7) - 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(typeof(TMPro.TextMeshProUGUI)).text = v.command_name item.transform:Find("Text"):GetComponent(typeof(TMPro.TextMeshProUGUI)).fontSize = 18 item:SetActive(true) local ClickFun = function (target) local temp = data[tonumber(target.name)] local str = temp.command for i,v in ipairs(temp.args_list) do str = str .. "_" .. v.args end self.cheatInputText.text = str if string.find(self.cheatInputText.text, "show_view_") then --打开隐藏界面 self:Close() self.model:Fire(CheatModel.OPEN_CHEAT_SHOW_VIEW, Trim(self.cheatInputText.text)) end end AddClickEvent(item, ClickFun) self.item_list[k] = item end self.scroll_content.sizeDelta = Vector2(1160, math.ceil((#data) / 7) * 70) self.scroll_content.localPosition = Vector3(0,0,0) end end function CheatInputView:SetSearchData(text) local data = {} if self.model.cheats_data then for i,v in ipairs(self.model.cheats_data.command_list) do local find = false for j, vo in ipairs(v.args_list) do local index, _ = string.find(vo.args, text) if index then find = true break end end local name_find = string.find(v.command_name, text) if v.command == text or find or name_find then table.insert(data, v) end end end self:CreateCheatList(data) end function CheatInputView:IsParmCheat(text) local list = Split(text,"_") local str = list[1] if str == "blink" then return true end if list and #list == 2 then local lv = tonumber(list[2]) if str == "guide" or str == "damageflag" or str == "autorotate" then return true elseif str == "dragon" then return true elseif str == "task_auto" then return true end end local flag = list and list[#list] if flag and flag == "parm" then return true end return false end function CheatInputView:IsGuildTVBarrageCheat( text ) local list = Split(text,"_") local str = list[1] if str == "TVB" then return true end end function CheatInputView:SaveCheatHidtory(clear) if clear then self.history = {} CookieWrapper.Instance:SaveCookie(CookieLevelType.Common,CookieTimeType.TYPE_ALWAYS,CookieKey.CHEAT_HISTORY,self.history) CookieWrapper.Instance:WriteAll() else local text = self.cheatInputText.text if text == "" or text == self.history[1] then return end for i,v in ipairs(self.history) do if v == text then table.remove(self.history, i) break end end table.insert(self.history, 1, text) CookieWrapper.Instance:SaveCookie(CookieLevelType.Common,CookieTimeType.TYPE_ALWAYS,CookieKey.CHEAT_HISTORY,self.history) CookieWrapper.Instance:WriteAll() end end function CheatInputView:CreateCheatHistory() local item = nil for i = 1,#self.cheat_history_list do item = self.cheat_history_list[i] item:SetActive(false) end local data = self.history if not IsTableEmpty(data) then for k,v in ipairs(data) do local item = self.cheat_history_list[k] if item == nil then item = UiFactory.createChild(self.history_scroll_content, UIType.SmallButton3, k) end local x = 20 local y = -70 *(k - 1) - 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(typeof(TMPro.TextMeshProUGUI)).text = v item:SetActive(true) local ClickFun = function (target) local str = v self.cheatInputText.text = str end AddClickEvent(item, ClickFun) self.cheat_history_list[k] = item end self.history_scroll_content.sizeDelta = Vector2(185, math.ceil((#data)) * 70) self.history_scroll_content.localPosition = Vector3(0,0,0) end end function CheatInputView:IsSearchGoods( ) local bool = string.find(self.cheatInputText.text,"search_goods_") return bool end --是否多次发送协议 function CheatInputView:IsSendPT( ) local bool = string.find(self.cheatInputText.text,"pt") return bool end