源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

103 行
4.1 KiB

  1. AttrDetailView = AttrDetailView or BaseClass(BaseView)
  2. local AttrDetailView = AttrDetailView
  3. function AttrDetailView:__init()
  4. self.base_file = "newMainRole"
  5. self.layout_file = "AttrDetailView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.blur_activity_bg = true
  10. self.is_set_zdepth = true
  11. self.index = 1 -- 页签index 1为普通属性 2为特殊属性
  12. --self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
  13. --self.append_to_ctl_queue = false --是否要添加进界面堆栈
  14. --self.need_show_money = false --是否要显示顶部的金钱栏
  15. self.model = NewMainRoleModel:getInstance()
  16. self.load_callback = function ()
  17. self:LoadSuccess()
  18. self:AddEvent()
  19. end
  20. self.open_callback = function ( )
  21. self:OpenSuccess()
  22. end
  23. self.destroy_callback = function ( )
  24. self:DestroySuccess()
  25. end
  26. end
  27. function AttrDetailView:Open(index)
  28. self.index = index or 1
  29. BaseView.Open(self)
  30. end
  31. function AttrDetailView:LoadSuccess()
  32. local nodes = {
  33. "window:raw","window/CloseBtn:obj","attr_scroll","attr_scroll/Viewport/attr_con",
  34. "tab_con/tab_2:obj:tmp","tab_con/tab_1:obj:tmp",
  35. "tab_con/selectedBg",
  36. }
  37. self:GetChildren(nodes)
  38. lua_resM:setOutsideRawImage(self, self.window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"))
  39. end
  40. function AttrDetailView:AddEvent()
  41. local function click_event(target)
  42. if target == self.CloseBtn_obj then
  43. self:Close()
  44. elseif target == self.tab_1_obj then
  45. self:SwitchTabIndex(1)
  46. elseif target == self.tab_2_obj then
  47. self:SwitchTabIndex(2)
  48. end
  49. end
  50. AddClickEvent(self.CloseBtn_obj, click_event, LuaSoundManager.SOUND_UI.NONE)
  51. AddClickEvent(self.tab_1_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
  52. AddClickEvent(self.tab_2_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
  53. end
  54. function AttrDetailView:OpenSuccess()
  55. self:SwitchTabIndex(self.index)
  56. end
  57. function AttrDetailView:UpdateView()
  58. self.attritem_list_creator = self.attritem_list_creator or self:AddUIComponent(UI.ItemListCreator)
  59. local attr_list = self.index == 1 and Config.ConfigAttrInfo.NormalAttr or Config.ConfigAttrInfo.SpecialAttr
  60. SetAnchoredPosition(self.attr_con, 0, 0)
  61. local info = {
  62. data_list = attr_list,
  63. item_con = self.attr_con,
  64. scroll_view = self.attr_scroll,
  65. prefab_ab_name = "newMainRole",
  66. prefab_res_name = "AttrDetailItem",
  67. item_height = 49.75,
  68. start_y = -5,
  69. start_x = 4,
  70. space_y = 1,
  71. child_names = {"bg:img","desc:tmp","attr_icon:img",},
  72. on_update_item = function(item, i, v)
  73. lua_resM:setImageSprite(self, item.bg_img, "newMainRole_asset", self.index == 1 and "newMainRole_di_13" or "newMainRole_di_14",true)
  74. SetAttrIconByColorType(item, item.attr_icon_img, v.attr_id, false, self.index == 1 and 1 or 2)
  75. local attr_name = HtmlColorTxt( (v.name or "") .. "", self.index == 1 and '#a9c1e1' or '#fdffc2')
  76. local attr_desc = Config.ConfigRoleAttrDes[v.attr_id] or ""
  77. item.desc_tmp.text = attr_name .. HtmlColorTxt( attr_desc , self.index == 1 and '#f3fcff' or '#fdffc2')
  78. end,
  79. }
  80. self.attritem_list_creator:UpdateItems(info)
  81. end
  82. function AttrDetailView:SwitchTabIndex( index )
  83. self.index = index
  84. SetAnchoredPosition(self.selectedBg, 2, index == 1 and 86 or 25)
  85. self.tab_1_tmp.text = HtmlColorTxt( "基础属性" , index == 1 and '#ffffff' or '#7d91ac')
  86. self.tab_2_tmp.text = HtmlColorTxt( "特殊属性" , index == 2 and '#ffffff' or '#7d91ac')
  87. SetTMPSharedMaterial(self.tab_1_tmp, index == 1 and ShaderTools.TMPSharedMaterialType.FZZZOutlineBlueTab or ShaderTools.TMPSharedMaterialType.FZZZDefault)
  88. SetTMPSharedMaterial(self.tab_2_tmp, index == 2 and ShaderTools.TMPSharedMaterialType.FZZZOutlineBlueTab or ShaderTools.TMPSharedMaterialType.FZZZDefault)
  89. self:UpdateView()
  90. end
  91. function AttrDetailView:DestroySuccess( )
  92. end