源战役客户端
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.

156 line
5.8 KiB

  1. CheatUICameraView = CheatUICameraView or BaseClass(BaseView)
  2. local CheatUICameraView = CheatUICameraView
  3. function CheatUICameraView:__init()
  4. self.base_file = "cheat"
  5. self.layout_file = "CheatUICameraView"
  6. self.layer_name = "Top"
  7. self.destroy_imm = true
  8. self.use_background = false
  9. self.change_scene_close = true
  10. self.load_callback = function ()
  11. self:LoadSuccess()
  12. self:AddEvent()
  13. end
  14. self.open_callback = function ( )
  15. self:OpenSuccess()
  16. end
  17. self.destroy_callback = function ( )
  18. self:DestroySuccess()
  19. end
  20. end
  21. function CheatUICameraView:Open( )
  22. --self.data = data
  23. BaseView.Open(self)
  24. end
  25. function CheatUICameraView:LoadSuccess()
  26. self.uicamrotateXName = self:GetChild("uicamrotateXName"):GetComponent("Text")
  27. self.uicamrotateXInput = self:GetChild("uicamrotateXInput"):GetComponent("InputField")
  28. self.uicamrotateYName = self:GetChild("uicamrotateYName"):GetComponent("Text")
  29. self.uicamrotateYInput = self:GetChild("uicamrotateYInput"):GetComponent("InputField")
  30. self.uicamPosXName = self:GetChild("uicamPosXName"):GetComponent("Text")
  31. self.uicamPosXInput = self:GetChild("uicamPosXInput"):GetComponent("InputField")
  32. self.uicamPosYName = self:GetChild("uicamPosYName"):GetComponent("Text")
  33. self.uicamPosYInput = self:GetChild("uicamPosYInput"):GetComponent("InputField")
  34. self.uicamPosZName = self:GetChild("uicamPosZName"):GetComponent("Text")
  35. self.uicamPosZInput = self:GetChild("uicamPosZInput"):GetComponent("InputField")
  36. self.uicamfieldName = self:GetChild("uicamfieldName"):GetComponent("Text")
  37. self.uicamfieldInput = self:GetChild("uicamfieldInput"):GetComponent("InputField")
  38. self.sureBtn = self:GetChild("sureBtn").gameObject
  39. self.copyBtn = self:GetChild("copyBtn").gameObject
  40. SetAnchoredPosition(self.transform, 0, 0)
  41. end
  42. function CheatUICameraView:AddEvent()
  43. local function onBtnClickHandler( target )
  44. if target == self.sureBtn then
  45. local camera_obj = self.camera_obj
  46. if not camera_obj then
  47. Message.show("模型摄像机还没创建好")
  48. end
  49. local cam = camera_obj.transform:GetComponent("Camera")
  50. local temp_rotate = self.camera_obj.transform.rotation.eulerAngles
  51. local temp_rotate_x = tonumber(self.uicamrotateXInput.text)
  52. if temp_rotate_x then
  53. temp_rotate = Vector3(temp_rotate_x, temp_rotate.y, 0)
  54. end
  55. local temp_rotate_y = tonumber(self.uicamrotateYInput.text)
  56. if temp_rotate_y then
  57. temp_rotate = Vector3(temp_rotate.x, temp_rotate_y, 0)
  58. end
  59. print("tanar: [CheatUICameraView 67]=> temp_rotate: ",temp_rotate)
  60. camera_obj.transform.localRotation = Quaternion.Euler(temp_rotate)
  61. local temp_offset = tonumber(self.uicamPosXInput.text)
  62. if temp_offset then
  63. SetLocalPositionX(camera_obj.transform, temp_offset)
  64. end
  65. local temp_height = tonumber(self.uicamPosYInput.text)
  66. if temp_height then
  67. SetLocalPositionY(camera_obj.transform, temp_height)
  68. end
  69. local temp_distance = tonumber(self.uicamPosZInput.text)
  70. if temp_distance then
  71. SetLocalPositionZ(camera_obj.transform, temp_distance)
  72. end
  73. local temp_field = tonumber(self.uicamfieldInput.text)
  74. if temp_field then
  75. cam.fieldOfView = temp_field
  76. end
  77. self:UpdateView()
  78. GlobalEventSystem:Fire(EventName.UPDATE_UIMODEL_CAMERA_DEFAULT_ARGS)
  79. elseif target == self.copyBtn then
  80. self:CopyData()
  81. end
  82. end
  83. AddClickEvent(self.sureBtn, onBtnClickHandler)
  84. AddClickEvent(self.copyBtn, onBtnClickHandler)
  85. end
  86. function CheatUICameraView:OpenSuccess()
  87. self:UpdateView()
  88. end
  89. function CheatUICameraView:UpdateView()
  90. self.camera_obj = LuaViewManager.role_back_camera
  91. if not self.camera_obj then
  92. self.camera_obj = GameObject.Find("root").transform:Find("UIBackRoleCamera")
  93. end
  94. if not self.camera_obj then
  95. Message.show("模型摄像机还没创建好")
  96. return
  97. end
  98. local pos = self.camera_obj.transform.localPosition
  99. local rotate = self.camera_obj.transform.localRotation
  100. local vet3 = self.camera_obj.transform.rotation.eulerAngles
  101. local cam = self.camera_obj.transform:GetComponent("Camera")
  102. local filed = cam.fieldOfView
  103. local temp_uicam_rotatex_name = string.format("倾斜RotateX ( %.2f ):", vet3.x)
  104. self.uicamrotateXName.text = temp_uicam_rotatex_name
  105. local temp_uicam_rotatey_name = string.format("旋转RotateY ( %.2f ):", vet3.y)
  106. self.uicamrotateYName.text = temp_uicam_rotatey_name
  107. -- self.uicamrotateXInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Rotate) or ""
  108. local temp_uicam_posx_name = string.format("偏移PosX ( %.2f ):", pos.x)
  109. self.uicamPosXName.text = temp_uicam_posx_name
  110. local temp_uicam_height_name = string.format("高度PosY ( %.2f ):", pos.y)
  111. self.uicamPosYName.text = temp_uicam_height_name
  112. -- self.uicamPosYInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Height) or ""
  113. local temp_uicam_dis_name = "距离PosZ [480-495] (".. pos.z .. "):"
  114. self.uicamPosZName.text = temp_uicam_dis_name
  115. -- self.uicamPosYInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Height) or ""
  116. local temp_uicam_field_name = "透视Field (".. filed .. "):"
  117. self.uicamfieldName.text = temp_uicam_field_name
  118. -- self.uicamPosYInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Height) or ""
  119. end
  120. function CheatUICameraView:CopyData( )
  121. local str1 = string.format("--%s\n%s = %.1f", "倾斜RotateX", "rotate.x", self.uicamrotateXInput.text)
  122. local str2 = string.format("\n--%s\n%s = %.1f", "旋转RotatesY", "rotate.y", self.uicamrotateYInput.text)
  123. local str3 = string.format("\n--%s\n%s = %.1f", "偏移PosX", "pos.x", self.uicamPosXInput.text)
  124. local str4 = string.format("\n--%s\n%s = %.1f", "高度PosY", "pos.y", self.uicamPosYInput.text)
  125. local str5 = string.format("\n--%s\n%s = %.1f", "距离PosZ", "pos.z", self.uicamPosZInput.text)
  126. local str6 = string.format("\n--%s\n%s = %.1f", "透视Field", "filed", self.uicamfieldInput.text)
  127. local str = str1 .. str2 .. str3 .. str4 .. str5 .. str6
  128. Optimizer.CopyOnPC(str)
  129. Message.show("复制成功")
  130. end
  131. function CheatUICameraView:DestroySuccess( )
  132. end