源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

656 line
24 KiB

  1. CheatInputView = CheatInputView or BaseClass(BaseView)
  2. function CheatInputView:__init()
  3. self.base_file = "cheat"
  4. self.layout_file = "CheatInputView"
  5. self.layer_name = "Top"
  6. self.close_mode = CloseMode.CloseDestroy
  7. self.destroy_imm = false
  8. self.use_background = true
  9. self.change_scene_close = true
  10. self.hide_maincancas = true
  11. -- self.blur_activity_bg = true
  12. self.item_list = {}
  13. self.cheat_history_list = {}
  14. self.data = nil
  15. self.is_set_zdepth = true
  16. self.model = CheatModel:getInstance()
  17. self.load_callback = function()
  18. self:LoadSuccess()
  19. self:InitEvent()
  20. end
  21. self.open_callback = function ( )
  22. self.model.is_open_cheat_view = true
  23. GlobalEventSystem:Fire(EventName.REQUEST_MIJI_DATA)
  24. if self.model.cache_text and self.model.cache_text ~= "" then
  25. self.cheatInputText.text = self.model.cache_text
  26. end
  27. end
  28. self.destroy_callback = function()
  29. self:DestorySuccess()
  30. end
  31. self.close_callback = function()
  32. self.model.is_open_cheat_view = false
  33. end
  34. self.history = CookieWrapper.Instance:GetCookie(CookieLevelType.Common,CookieKey.CHEAT_HISTORY) or {}
  35. end
  36. function CheatInputView:DestorySuccess()
  37. if self.event_id then
  38. self.model:UnBind(self.event_id)
  39. self.event_id = nil
  40. end
  41. if self.event_id2 then
  42. self.model:UnBind(self.event_id2)
  43. self.event_id2 = nil
  44. end
  45. if self.question_time_id then
  46. GlobalTimerQuest:CancelQuest(self.question_time_id)
  47. self.question_time_id = nil
  48. end
  49. end
  50. function CheatInputView:LoadSuccess()
  51. self.cheatInputText = self:GetChild("cheatInput"):GetComponent("InputField")
  52. -- self.holderText = self:GetChild("cheatInput/Placeholder"):GetComponent("Text")
  53. self.okBtn = self:GetChild("okBtn").gameObject
  54. self.scroll_content = self:GetChild("ScrollView/Viewport/Content")
  55. self.serachInputText = self:GetChild("serachInput"):GetComponent("InputField")
  56. self.serachBtn = self:GetChild("serachBtn").gameObject
  57. self.history_scroll_content = self:GetChild("historybg/ScrollView/Viewport/Content")
  58. self.clearBtn = self:GetChild("historybg/clearBtn").gameObject
  59. self.closeBtn = self:GetChild("WindowNew2/di_head/windowCloseBtn").gameObject
  60. end
  61. function CheatInputView:InitEvent()
  62. local function onBtnClickHandler(target)
  63. if target == self.closeBtn then
  64. self:Close()
  65. end
  66. end
  67. AddClickEvent(self.closeBtn, onBtnClickHandler, 1)
  68. local function onBtnClickHandler(target)
  69. local is_search_goods_id = self:IsSearchGoods()
  70. local is_send_pt = is_search_goods_id and false or self:IsSendPT()
  71. if target == self.okBtn then
  72. print("秘籍的内容是===:", self.cheatInputText.text)
  73. self.model.cache_text = self.cheatInputText.text
  74. self:SaveCheatHidtory()
  75. self:CreateCheatHistory()
  76. if self:IsParmCheat(self.cheatInputText.text) then
  77. local list = Split(self.cheatInputText.text,"_")
  78. local str = list[1]
  79. if str == "guide" then
  80. local lv = tonumber(list[2])
  81. if lv then
  82. GlobalEventSystem:Fire(EventName.TEST_HELP_STEP,lv)
  83. end
  84. self:Close()
  85. elseif str == "autorotate" then
  86. local rotate_type = tonumber(list[2])
  87. G_AUTO_ROTATE = rotate_type
  88. print("tanar: [CheatInputView 98]=> rotate_type: ",rotate_type)
  89. elseif str == "blink" then
  90. local x = tonumber(list[2])
  91. local y = tonumber(list[3])
  92. if Scene.Instance.main_role then
  93. GlobalEventSystem:Fire(SceneEventType.MOVEREQUEST, x,y, MOVE_TYPE.BLINK)
  94. Scene.Instance.main_role:SetRealPos(x,y)
  95. end
  96. elseif str == "damageflag" then
  97. local flag = tonumber(list[2])
  98. G_DEBUG_DAMAGE_FLAG = flag
  99. print("tanar - [ CheatInputView ] [59] ==> G_DEBUG_DAMAGE_FLAG: ",G_DEBUG_DAMAGE_FLAG)
  100. return
  101. elseif str == "dragon" then
  102. -- WelecomeController.Instance:PlayEnd()
  103. -- WelecomeModel.Instance.horse_fly_movie_is_playEnd = false
  104. -- local onDelay = function ( )
  105. -- WelecomeController.Instance:CreateCoud()
  106. -- WelecomeController.Instance:StartUpdate()
  107. -- local ond = function ( )
  108. -- GlobalEventSystem:Fire(EventName.JUMP_UP_HORSE)
  109. -- end
  110. -- setTimeout(ond, 0.5)
  111. -- end
  112. -- setTimeout(onDelay, 0.5)
  113. elseif str == "task_auto" then
  114. TaskModel:getInstance():AutoDoTaskByType()
  115. elseif str == "update" then
  116. local step = tonumber(list[2])
  117. G_DEBUG_UPDATE_STEP = step
  118. Message.show("update_step = "..step)
  119. end
  120. -- self:Close()
  121. return
  122. end
  123. if self.cheatInputText.text == "ban_auto_connect" then
  124. ClientConfig.is_ban_auto_connect = true
  125. Message.show("已禁止自动重连")
  126. elseif self.cheatInputText.text == "hot_ele_cfg" then
  127. self:Close()
  128. Scene.Instance.mapView:UnRegiestElevatorModelList()
  129. package.loaded["config.client.ConfigSceneElevatorModel"] = nil
  130. pcall(require, "config.client.ConfigSceneElevatorModel")
  131. Scene.Instance.mapView:RegisterElevatorModelList()
  132. elseif self.cheatInputText.text == "on_mon_list" then
  133. self.model:OnCreateMonList()
  134. self:Close()
  135. elseif self.cheatInputText.text == "change_dir" then
  136. if ClientConfig.orientation_did_change == 3 then
  137. ClientConfig.orientation_did_change = 4
  138. else
  139. ClientConfig.orientation_did_change = 3
  140. end
  141. if ClientConfig.orientation_did_change == 3 then
  142. ClientConfig.iphone_x_offset_left = 55
  143. ClientConfig.iphone_x_offset_right = 0
  144. elseif ClientConfig.orientation_did_change == 4 then
  145. ClientConfig.iphone_x_offset_left = 0
  146. ClientConfig.iphone_x_offset_right = 55
  147. end
  148. GlobalEventSystem:Fire(EventName.ORIENTATION_DID_CHANGE)
  149. elseif self.cheatInputText.text == "perform" then
  150. GlobalEventSystem:Fire(EventName.OPEN_LUA_STATE_VIEW) --lua状态
  151. elseif self.cheatInputText.text == "Position" then
  152. local role_vo = RoleManager.Instance.mainRoleInfo
  153. print("[ Position ] ==> role_vo.pos_x: ",role_vo.pos_x)
  154. print("[ Position ] ==> role_vo.pos_y: ",role_vo.pos_y)
  155. local sceneInfo = SceneManager:getInstance():GetSceneInfo(scene_id)
  156. print("[ Position ] ==> sceneInfo.type: ",sceneInfo.type)
  157. print("[ Position ] ==> sceneInfo.subtype: ",sceneInfo.subtype)
  158. print("[ Position ] ==> sceneInfo.id: ",sceneInfo.id)
  159. local main_camera_transform = MainCamera:getInstance().transform
  160. local camera_pos = main_camera_transform.position
  161. print("tanar: [CheatInputView 174]=> camera_pos.x: ",camera_pos.x)
  162. print("tanar: [CheatInputView 174]=> camera_pos.y: ",camera_pos.y)
  163. print("tanar: [CheatInputView 174]=> camera_pos.z: ",camera_pos.z)
  164. elseif self.cheatInputText.text == "role_id" then
  165. local role_id = RoleManager.Instance.mainRoleInfo.role_id or "木有id"
  166. Message.show("role_id输入框复制走起")
  167. print("role_id = ", role_id)
  168. self.cheatInputText.text = role_id
  169. elseif string.find(self.cheatInputText.text,"framecount") then
  170. local tbl = Split(self.cheatInputText.text,"_")
  171. FINAL_FRAMERATE = tonumber(tbl[2])
  172. SetGameFrameRate(tonumber(tbl[2]))
  173. elseif string.find(self.cheatInputText.text, "setplatform") then --平台设置
  174. local mystr = self.cheatInputText.text
  175. ClientConfig.plat_name = tostring(string.sub(mystr, 13, string.len(mystr)))
  176. -- print("======= set platform", ClientConfig.plat_name)
  177. elseif self.cheatInputText.text == "auto_upgrade" then
  178. self.model:AutoUpgradeFight()
  179. elseif string.find(self.cheatInputText.text,"open_story") then
  180. local args = Split(self.cheatInputText.text,"_")
  181. local id = tonumber(args[3])
  182. local index = tonumber(args[4])
  183. local time = tonumber(args[5]) or 0
  184. GlobalEventSystem:Fire(EventName.STORY_PLAY_TRIGGER,id,index,time)
  185. elseif self.cheatInputText.text == "f" then
  186. HonourModel:getInstance():SetResultData()
  187. elseif self.cheatInputText.text == "camera_edit" then
  188. self.model:Fire(CheatModel.OPEN_CAMERA_EDIt_VIEW)
  189. elseif self.cheatInputText.text == "ui_camera_edit" then
  190. self.model:Fire(CheatModel.OPEN_UI_CAMERA_EDIT_VIEW)
  191. elseif self.cheatInputText.text == "bloomobj" then
  192. self.main_role = Scene.Instance:GetMainRole()
  193. self.main_role_transform = self.main_role and self.main_role.parent_transform
  194. if self.main_role_transform then
  195. Optimizer.ChangeLayer(self.main_role_transform, "BloomObj")
  196. end
  197. -- self.camera_gameObject = MainCamera.Instance.camera_gameObject
  198. -- if not self.camera_pp_volume then
  199. -- self.camera_pp_volume = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessVolume))
  200. -- end
  201. -- self.camera_pp_volume.enabled = true
  202. -- if not self.camera_pp_layer then
  203. -- self.camera_pp_layer = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessLayer))
  204. -- end
  205. -- self.camera_pp_layer.enabled = true
  206. elseif self.cheatInputText.text == "hide_pp" then
  207. self.camera_gameObject = MainCamera.Instance.camera_gameObject
  208. if not self.camera_pp_volume then
  209. self.camera_pp_volume = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessVolume))
  210. end
  211. self.camera_pp_volume.enabled = false
  212. if not self.camera_pp_layer then
  213. self.camera_pp_layer = self.camera_gameObject:GetComponent(typeof(UnityEngine.Rendering.PostProcessing.PostProcessLayer))
  214. end
  215. self.camera_pp_layer.enabled = false
  216. elseif self.cheatInputText.text == "change_bloom" then
  217. -- self.camera_obj = MainCamera:getInstance().camera_gameObject
  218. -- if not self.bloom_effect then
  219. -- self.bloom_effect = self.camera_obj:GetComponent(typeof(UnityStandardAssets.ImageEffects.BloomOptimized))
  220. -- end
  221. -- local cur_enabled = self.bloom_effect.enabled
  222. -- self.bloom_effect.enabled = not cur_enabled
  223. self.model:Fire(CheatModel.OPEN_BLOOM_EDIt_VIEW)
  224. GlobalEventSystem:Fire(EventName.OPEN_CHEAT_INPUT_VIEW)
  225. return
  226. elseif self.cheatInputText.text == "hide_main_canvas" then
  227. if not m_hide_main_canvas_btn then
  228. m_hide_main_canvas_btn = UiFactory.createChild(panelMgr:GetParent("Top"),UIType.ImageButton,"m_hide_main_canvas_btn")
  229. SetSizeDelta(m_hide_main_canvas_btn.transform, 100, 100)
  230. SetLocalPosition(m_hide_main_canvas_btn.transform, 0, 0, 0)
  231. local function callback( )
  232. local main_canvas = panelMgr:GetParent("Main")
  233. local cur_visible = main_canvas.gameObject.activeSelf
  234. main_canvas.gameObject:SetActive(not cur_visible)
  235. end
  236. AddClickEvent(m_hide_main_canvas_btn, callback)
  237. end
  238. elseif self.cheatInputText.text == "hide_scene" then
  239. if not m_hide_scene_btn then
  240. m_hide_scene_btn = UiFactory.createChild(panelMgr:GetParent("Top"),UIType.ImageButton,"m_hide_main_canvas_btn")
  241. SetSizeDelta(m_hide_scene_btn.transform, 100, 100)
  242. SetLocalPosition(m_hide_scene_btn.transform, 100, 0, 0)
  243. local function callback( )
  244. m_hide_scene_flag = m_hide_scene_flag == nil and false or m_hide_scene_flag
  245. m_hide_scene_flag = not m_hide_scene_flag
  246. if m_hide_scene_flag then
  247. GlobalEventSystem:Fire(EventName.DO_MODULE_DEBUG_FUNC, "mapview", "hiderootall")
  248. else
  249. GlobalEventSystem:Fire(EventName.DO_MODULE_DEBUG_FUNC, "mapview", "showrootall")
  250. end
  251. end
  252. AddClickEvent(m_hide_scene_btn, callback)
  253. end
  254. elseif self.cheatInputText.text == "hide_main_role" then
  255. G_DEBUG_HIDE_MAIN_ROLE = G_DEBUG_HIDE_MAIN_ROLE or false
  256. G_DEBUG_HIDE_MAIN_ROLE = not G_DEBUG_HIDE_MAIN_ROLE
  257. Message.show("G_DEBUG_HIDE_MAIN_ROLE = " .. tostring(G_DEBUG_HIDE_MAIN_ROLE))
  258. local main_role = Scene.Instance.main_role
  259. if main_role then
  260. main_role:SetModelHideFlag(SceneObj.ModelHideFlag.PerformanceHide, G_DEBUG_HIDE_MAIN_ROLE)
  261. end
  262. return
  263. elseif self.cheatInputText.text == "client_property" then
  264. self.model:Fire(CheatModel.OPEN_CLIENT_PROPERTY_VIEW)
  265. elseif self.cheatInputText.text == "lua_profiler" then
  266. Message.show("lua_profiler")
  267. LuaProfiler.SwitchState()
  268. return
  269. elseif self.cheatInputText.text == "stop_action" then
  270. G_DEBUG_STOP_ACTION = G_DEBUG_STOP_ACTION or false
  271. G_DEBUG_STOP_ACTION = not G_DEBUG_STOP_ACTION
  272. Message.show("G_DEBUG_STOP_ACTION = " .. tostring(G_DEBUG_STOP_ACTION))
  273. return
  274. elseif self.cheatInputText.text == "client_gyro" then
  275. self.model:Fire(CheatModel.OPEN_CLIENT_ACCELERATION_VIEW)
  276. elseif string.find(self.cheatInputText.text,"open_fun_") then
  277. self:Close()
  278. local str = string.gsub(self.cheatInputText.text,"open_fun_","")
  279. setTimeout(function ( ... )
  280. GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE,tonumber(str)) -- 触发升级引导
  281. end,0.2)
  282. elseif is_search_goods_id then
  283. local str = string.gsub(self.cheatInputText.text,"search_goods_","")
  284. local type_id = GoodsModel:getInstance():GetGoodsCfgByName(str)
  285. if type_id then
  286. self.cheatInputText.text = "goods_"..type_id.."_1"
  287. else
  288. Message.show("没找到这个名字的物品啊~你有没有打错字")
  289. end
  290. elseif string.find(self.cheatInputText.text,"RunCode:") then
  291. -- 范例local str = "@RunCode:local a = BossModel:GetInstance().world_boss_status; Message.show(a)"
  292. self.model:Fire(CheatModel.Quick_Run_Code,self.cheatInputText.text)
  293. elseif self:IsGuildTVBarrageCheat(self.cheatInputText.text) then
  294. local list = Split(text,"_")
  295. local time = tonumber(list[2]) or 100
  296. local function on_add_barrage( ... )
  297. local time = TimeUtil:getServerTimeMs( )
  298. local id = math.random(100000,999999)
  299. local name_len = math.random(1,6)
  300. local text_len = math.random(1,20)
  301. local name_str = "玩家名字六字"
  302. local text_str = "一二三四五六七八九十一二三四五六七八九十"
  303. local data = {
  304. name = string.sub(name_str, name_len),
  305. id = id,
  306. time = time,
  307. }
  308. data.content = string.sub(text_str, text_len)
  309. GuildTVModel:GetInstance():AddGuildTVBarrageMessage(data)
  310. end
  311. local function on_answer_time( )
  312. if time <= 0 then
  313. if self.question_time_id then
  314. GlobalTimerQuest:CancelQuest(self.question_time_id)
  315. self.question_time_id = nil
  316. end
  317. else
  318. time = time - 1
  319. on_add_barrage()
  320. end
  321. end
  322. if not self.question_time_id then
  323. self.question_time_id = GlobalTimerQuest:AddPeriodQuest(on_answer_time, 0.01, -1)
  324. end
  325. elseif self.cheatInputText.text == "fxaa_edit" then
  326. self.model:Fire(CheatModel.OPEN_FXAA_TEST_VIEW, true)
  327. GlobalEventSystem:Fire(EventName.OPEN_CHEAT_INPUT_VIEW)
  328. return
  329. elseif self.cheatInputText.text == "free_camera" then
  330. self.model:Fire(CheatModel.OPEN_FREE_CAMERA_VIEW, true)
  331. GlobalEventSystem:Fire(EventName.OPEN_CHEAT_INPUT_VIEW)
  332. return
  333. elseif self.cheatInputText.text == "enablegs" then
  334. LoginModel.ENABLE_GREEN_SCREEN = true
  335. Message.show("绿屏模式启动,打开支持绿屏的窗口即生效,界面内左上角热区可以切换绿屏")
  336. elseif self.cheatInputText.text == "hide_ui" then -- 隐藏主UI
  337. panelMgr:GetParent("Main").gameObject:SetActive(false)
  338. panelMgr:GetParent("NameBoard").gameObject:SetActive(false)
  339. panelMgr:GetParent("Dynamic_NameBoard").gameObject:SetActive(false)
  340. elseif self.cheatInputText.text == "show_ui" then -- 显示主UI
  341. panelMgr:GetParent("Main").gameObject:SetActive(true)
  342. panelMgr:GetParent("NameBoard").gameObject:SetActive(true)
  343. panelMgr:GetParent("Dynamic_NameBoard").gameObject:SetActive(true)
  344. --拼图游戏
  345. elseif self.cheatInputText.text == "jipsaw" then
  346. RechargeActivityModel.getInstance():Fire(RechargeActivityModel.OPEN_JIPSAW_VIEW)
  347. self:Close()
  348. return
  349. --刮刮乐
  350. elseif self.cheatInputText.text == "guaguale" then
  351. RechargeActivityModel.getInstance():Fire(RechargeActivityModel.OPEN_GUAGUALE_VIEW)
  352. self:Close()
  353. return
  354. elseif self.cheatInputText.text == "load_base_scene" then
  355. CheatModel:getInstance():LoadBaseSceneRes( )
  356. return
  357. elseif string.find(self.cheatInputText.text, "play_story_") then
  358. local txt = self.cheatInputText.text
  359. local t_id = string.gsub(txt, "play_story_", "")
  360. local id = tonumber(t_id)
  361. local exit = false
  362. local cfg = Config.Story
  363. for k,v in pairs(cfg) do
  364. for kk,vv in pairs(v) do
  365. if kk == id then
  366. local main_role = Scene.Instance.main_role
  367. if vv and main_role then
  368. main_role:DoStory(vv)
  369. exit = true
  370. end
  371. end
  372. end
  373. end
  374. if exit then
  375. self:Close()
  376. else
  377. Message.show("不存在当前剧情 id ",id)
  378. end
  379. return
  380. elseif self.cheatInputText.text == "galaxy" then
  381. OpenFun.Open(148,1)
  382. self:Close()
  383. return
  384. elseif self.cheatInputText.text == "ChangeSceneMovie" then
  385. self:Close()
  386. local function on_delay( )
  387. ChangeSceneMovie.getInstance():TryOpen()
  388. end
  389. setTimeout(on_delay, 1)
  390. return
  391. elseif self.cheatInputText.text == "ChangeSceneMovieRT" then
  392. self:Close()
  393. local function on_delay( )
  394. ChangeSceneMovieRT.getInstance():TryOpen()
  395. end
  396. setTimeout(on_delay, 1)
  397. return
  398. elseif self.cheatInputText.text == "MemoryLevel" then
  399. local men = Util.GetSystemMemorySize()/1024
  400. local men_ceil = math.ceil(men)
  401. Message.show("men = " .. tostring(men) .. " men_floor = " ..tostring(men_ceil))
  402. return
  403. elseif self.cheatInputText.text == "ChangeGuildMapRes" then
  404. local function on_delay( )
  405. Scene.Instance.mapView.ignore_reset_guild_res_id = true
  406. Scene.Instance.mapView:OnUpdateGuildMapResByTime(true)
  407. end
  408. self:Close()
  409. setTimeout(on_delay, 2)
  410. return
  411. elseif is_send_pt then
  412. local str = Split(self.cheatInputText.text,"_")
  413. local len = TableSize(str)
  414. if tonumber(str[len]) then
  415. local text = string.gsub(self.cheatInputText.text,"_"..str[len], "")
  416. for i=1,tonumber(str[len]) do
  417. self.model:Fire(CheatModel.SEND_CHEAT_TO_SERVER, text)
  418. end
  419. else
  420. self.model:Fire(CheatModel.SEND_CHEAT_TO_SERVER, self.cheatInputText.text)
  421. end
  422. else
  423. local is_change_scene = string.find(self.cheatInputText.text, "scene_")
  424. if is_change_scene then
  425. Scene.Instance.mapView.ignore_reset_guild_res_id = true
  426. end
  427. self.model:Fire(CheatModel.SEND_CHEAT_TO_SERVER, self.cheatInputText.text)
  428. end
  429. -- self:Close()
  430. end
  431. end
  432. AddClickEvent(self.okBtn,onBtnClickHandler)
  433. local function on_click_ok_btn()
  434. onBtnClickHandler(self.okBtn)
  435. end
  436. self.event_id2 = self.model:Bind(CheatModel.CLICK_BTN_OK, on_click_ok_btn)
  437. local function onBtnClickHandler(target)
  438. if target == self.serachBtn then
  439. print("秘籍的内容是===:", self.serachInputText.text)
  440. if Trim(self.serachInputText.text) == "" then
  441. self:SetData()
  442. return
  443. end
  444. self:SetSearchData(self.serachInputText.text)
  445. end
  446. end
  447. AddClickEvent(self.serachBtn,onBtnClickHandler)
  448. local function onBtnClearBtn(target)
  449. if target == self.clearBtn then
  450. local function ok( ... )
  451. self.history = {}
  452. self:SaveCheatHidtory(true)
  453. self:CreateCheatHistory()
  454. end
  455. local ask_str = "确定要清理记录?"
  456. Alert.show(ask_str,Alert.Type.Two,ok,nil,"确定","取消")
  457. end
  458. end
  459. AddClickEvent(self.clearBtn,onBtnClearBtn)
  460. local update_fun = function ()
  461. self:SetData()
  462. end
  463. self.event_id = self.model:Bind(CheatModel.UPDATE_CHEAT_INPUT_VIEW, update_fun)
  464. self:SetData()
  465. self:CreateCheatHistory()
  466. end
  467. function CheatInputView:SetData()
  468. self.data = self.model.cheats_data
  469. if self.data == nil then return end
  470. self:CreateCheatList(self.data.command_list)
  471. end
  472. function CheatInputView:CreateCheatList(data)
  473. local item = nil
  474. for i = 1,#self.item_list do
  475. item = self.item_list[i]
  476. item:SetActive(false)
  477. end
  478. if not IsTableEmpty(data) then
  479. for k,v in ipairs(data) do
  480. local item = self.item_list[k]
  481. if item == nil then
  482. item = UiFactory.createChild(self.scroll_content, UIType.SmallButton3, k)
  483. end
  484. local x = 157 * ((k - 1) % 7)
  485. local y = -70 * math.floor((k - 1) / 7) - 5
  486. item.transform.pivot = Vector2(0,1)
  487. item.transform.anchorMin = Vector2(0, 1)
  488. item.transform.anchorMax = Vector2(0, 1)
  489. item.transform.localPosition = Vector3(x,y,0)
  490. item.transform:Find("Text"):GetComponent(typeof(TMPro.TextMeshProUGUI)).text = v.command_name
  491. item.transform:Find("Text"):GetComponent(typeof(TMPro.TextMeshProUGUI)).fontSize = 18
  492. item:SetActive(true)
  493. local ClickFun = function (target)
  494. local temp = data[tonumber(target.name)]
  495. local str = temp.command
  496. for i,v in ipairs(temp.args_list) do
  497. str = str .. "_" .. v.args
  498. end
  499. self.cheatInputText.text = str
  500. if string.find(self.cheatInputText.text, "show_view_") then --打开隐藏界面
  501. self:Close()
  502. self.model:Fire(CheatModel.OPEN_CHEAT_SHOW_VIEW, Trim(self.cheatInputText.text))
  503. end
  504. end
  505. AddClickEvent(item, ClickFun)
  506. self.item_list[k] = item
  507. end
  508. self.scroll_content.sizeDelta = Vector2(1160, math.ceil((#data) / 7) * 70)
  509. self.scroll_content.localPosition = Vector3(0,0,0)
  510. end
  511. end
  512. function CheatInputView:SetSearchData(text)
  513. local data = {}
  514. if self.model.cheats_data then
  515. for i,v in ipairs(self.model.cheats_data.command_list) do
  516. local find = false
  517. for j, vo in ipairs(v.args_list) do
  518. local index, _ = string.find(vo.args, text)
  519. if index then
  520. find = true
  521. break
  522. end
  523. end
  524. local name_find = string.find(v.command_name, text)
  525. if v.command == text or find or name_find then
  526. table.insert(data, v)
  527. end
  528. end
  529. end
  530. self:CreateCheatList(data)
  531. end
  532. function CheatInputView:IsParmCheat(text)
  533. local list = Split(text,"_")
  534. local str = list[1]
  535. if str == "blink" then
  536. return true
  537. end
  538. if list and #list == 2 then
  539. local lv = tonumber(list[2])
  540. if str == "guide" or str == "damageflag" or str == "autorotate" then
  541. return true
  542. elseif str == "dragon" then
  543. return true
  544. elseif str == "task_auto" then
  545. return true
  546. end
  547. end
  548. local flag = list and list[#list]
  549. if flag and flag == "parm" then
  550. return true
  551. end
  552. return false
  553. end
  554. function CheatInputView:IsGuildTVBarrageCheat( text )
  555. local list = Split(text,"_")
  556. local str = list[1]
  557. if str == "TVB" then
  558. return true
  559. end
  560. end
  561. function CheatInputView:SaveCheatHidtory(clear)
  562. if clear then
  563. self.history = {}
  564. CookieWrapper.Instance:SaveCookie(CookieLevelType.Common,CookieTimeType.TYPE_ALWAYS,CookieKey.CHEAT_HISTORY,self.history)
  565. CookieWrapper.Instance:WriteAll()
  566. else
  567. local text = self.cheatInputText.text
  568. if text == "" or text == self.history[1] then return end
  569. for i,v in ipairs(self.history) do
  570. if v == text then
  571. table.remove(self.history, i)
  572. break
  573. end
  574. end
  575. table.insert(self.history, 1, text)
  576. CookieWrapper.Instance:SaveCookie(CookieLevelType.Common,CookieTimeType.TYPE_ALWAYS,CookieKey.CHEAT_HISTORY,self.history)
  577. CookieWrapper.Instance:WriteAll()
  578. end
  579. end
  580. function CheatInputView:CreateCheatHistory()
  581. local item = nil
  582. for i = 1,#self.cheat_history_list do
  583. item = self.cheat_history_list[i]
  584. item:SetActive(false)
  585. end
  586. local data = self.history
  587. if not IsTableEmpty(data) then
  588. for k,v in ipairs(data) do
  589. local item = self.cheat_history_list[k]
  590. if item == nil then
  591. item = UiFactory.createChild(self.history_scroll_content, UIType.SmallButton3, k)
  592. end
  593. local x = 20
  594. local y = -70 *(k - 1) - 5
  595. item.transform.pivot = Vector2(0,1)
  596. item.transform.anchorMin = Vector2(0, 1)
  597. item.transform.anchorMax = Vector2(0, 1)
  598. item.transform.localPosition = Vector3(x,y,0)
  599. item.transform:Find("Text"):GetComponent(typeof(TMPro.TextMeshProUGUI)).text = v
  600. item:SetActive(true)
  601. local ClickFun = function (target)
  602. local str = v
  603. self.cheatInputText.text = str
  604. end
  605. AddClickEvent(item, ClickFun)
  606. self.cheat_history_list[k] = item
  607. end
  608. self.history_scroll_content.sizeDelta = Vector2(185, math.ceil((#data)) * 70)
  609. self.history_scroll_content.localPosition = Vector3(0,0,0)
  610. end
  611. end
  612. function CheatInputView:IsSearchGoods( )
  613. local bool = string.find(self.cheatInputText.text,"search_goods_")
  614. return bool
  615. end
  616. --是否多次发送协议
  617. function CheatInputView:IsSendPT( )
  618. local bool = string.find(self.cheatInputText.text,"pt")
  619. return bool
  620. end