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

645 lines
24 KiB

пре 1 месец
  1. --个性化聊天界面
  2. IndividuationView = IndividuationView or BaseClass(BaseView)
  3. local IndividuationView = IndividuationView
  4. local BTN_COUNT = 4 -- 页签数
  5. function IndividuationView:__init()
  6. self.base_file = "chat"
  7. self.layout_file = "individuationView"
  8. self.layer_name = "Top"
  9. -- self.use_local_view = true
  10. self.destroy_imm = true
  11. self.change_scene_close = true
  12. -- self.append_to_ctl_queue = true
  13. self.face_item_list = {}
  14. self.textFace_item_list = {}
  15. self.history_text_item_list = {}
  16. self.good_item_list = {}
  17. self.use_background = true
  18. self.background_alpha = 0
  19. self.hide_maincancas = false
  20. self.open_wnd_anim = 0
  21. self.click_bg_toClose = true
  22. self.is_moving = false
  23. self.tabbar_list = {}
  24. self.tabbar_icon = {}
  25. self.tabbar_label_select = {}
  26. self.tabbar_label_normal = {}
  27. self.tabbar_line = {}
  28. self.tabbar_shadow_list = {}
  29. self.tabbar_text_list = {}
  30. self.curr_selected_bar_index = 0
  31. self.init_bar_index = 1
  32. self.face_count = 48--表情数量
  33. self.scale_num = 1
  34. self.model = ChatModel:getInstance()
  35. self.load_callback = function ()
  36. self:LoadSuccess()
  37. self:InitEvent()
  38. --切换toggle
  39. self.tabbar_list[1]:GetComponent("Toggle").isOn = false
  40. self.tabbar_list[2]:GetComponent("Toggle").isOn = false
  41. self:SetBtnState( 1, false )
  42. self:SetBtnState( 2, false )
  43. self.tabbar_list[self.init_bar_index]:GetComponent("Toggle").isOn = true
  44. self:SetBtnState( self.init_bar_index, true )
  45. end
  46. self.open_callback = function ()
  47. self:SwitchBar(self.init_bar_index)
  48. local function onCompleted()
  49. self.is_moving = false
  50. self:ClearTweener()
  51. end
  52. self.is_moving = true
  53. --输入框高度
  54. self.tween_id = TweenLite.to(self, self.info_con, TweenLite.UiAnimationType.ANCHORED_POSY, self.pos_y, 0.1, onCompleted)
  55. end
  56. self.close_callback = function ()
  57. self.is_moving = false
  58. end
  59. self.destroy_callback = function ()
  60. self:Clear()
  61. end
  62. if SceneManager:getInstance():IsGuildScene() then
  63. self.use_background = true
  64. self.click_bg_toClose = true
  65. end
  66. end
  67. function IndividuationView:ClearTweener()
  68. if self.tween_id then
  69. TweenLite.Stop(self.tween_id)
  70. self.tween_id = nil
  71. end
  72. end
  73. function IndividuationView:SetBtnState( index, is_select )
  74. self.tabbar_icon[index]:SetActive(is_select)
  75. self.tabbar_label_select[index]:SetActive(is_select)
  76. self.tabbar_label_normal[index]:SetActive(not is_select)
  77. end
  78. function IndividuationView:Clear()
  79. self.model.chat_bag_view_is_open = false
  80. self.model.selected_face_item = nil
  81. self.model.selected_good_item = nil
  82. self.model.selected_histroy_item = nil
  83. self.model.selected_textface_item = nil
  84. self.model.selected_history_text_item = nil
  85. for i, item in pairs(self.good_item_list) do
  86. item:DeleteMe()
  87. end
  88. for i, item in pairs(self.face_item_list) do
  89. item:DeleteMe()
  90. end
  91. for i, item in pairs(self.textFace_item_list) do
  92. item:DeleteMe()
  93. end
  94. for i, item in ipairs(self.history_text_item_list) do
  95. item:DeleteMe()
  96. end
  97. self.face_item_list = {}
  98. self.textFace_item_list = {}
  99. if self.update_event_id then
  100. self.model:UnBind(self.update_event_id)
  101. self.update_event_id = nil
  102. end
  103. if self.orientation_change_id then
  104. GlobalEventSystem:UnBind(self.orientation_change_id)
  105. self.orientation_change_id = nil
  106. end
  107. self:ClearTweener()
  108. end
  109. function IndividuationView:Open(bar_index, pos_x, pos_y, is_close_after_sendpos, chating_key_id,is_rest_anchor,scale_num)
  110. self.isOpen = true
  111. if bar_index then
  112. self.init_bar_index = bar_index
  113. end
  114. self.pos_x = pos_x or ClientConfig.iphone_x_offset_left
  115. self.pos_y = pos_y or 0
  116. self.is_close_after_sendpos = is_close_after_sendpos
  117. self.chating_key_id = chating_key_id --对于社交中对象 需要有特定的对象聊天记录
  118. self.is_rest_anchor = is_rest_anchor
  119. self.scale_num = scale_num or 1
  120. BaseView.Open(self)
  121. end
  122. function IndividuationView:Close()
  123. if self.is_moving == false then
  124. self.model.clicked_role_item = nil
  125. BaseView.Close(self)
  126. end
  127. end
  128. function IndividuationView:LoadSuccess()
  129. self.info_con,
  130. self.ScrollView,
  131. self.scroll_content
  132. = GetChildTransforms(self.transform, {
  133. "InfoCon",
  134. "InfoCon/ScrollView",
  135. "InfoCon/ScrollView/Viewport/Content",
  136. })
  137. self.closeBtn,
  138. self.closeBtn2,
  139. self.bagToggleGroupObj,
  140. self.bagAllBtn,
  141. self.bagEquipBtn,
  142. self.bagMaterialBtn,
  143. self.bagWarehouseBtn
  144. = GetChildGameObjects(self.transform, {
  145. "InfoCon/closeBtn",
  146. "closeBtn2",
  147. "InfoCon/bagToggleGroup",
  148. "InfoCon/bagToggleGroup/allBtn",
  149. "InfoCon/bagToggleGroup/equipBtn",
  150. "InfoCon/bagToggleGroup/materialBtn",
  151. "InfoCon/bagToggleGroup/warehouseBtn",
  152. })
  153. self.closeBtn2:SetActive(false)
  154. for i = 1, BTN_COUNT do
  155. self.tabbar_list[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i).gameObject
  156. self.tabbar_icon[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/Background/Checkmark/icon").gameObject
  157. self.tabbar_label_select[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/Background/Checkmark/Label2").gameObject
  158. self.tabbar_label_normal[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/Label2").gameObject
  159. self.tabbar_line[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/line").gameObject
  160. -- self.tabbar_text_list[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i.."/Label2"):GetComponent("TextMeshProUGUI")
  161. -- self.tabbar_text_list[i].color = Color(167 / 255, 119 / 255, 85 / 255, 1)
  162. --self.tabbar_shadow_list[i] = self.tabbar_text_list[i]:GetComponent("Shadow")
  163. end
  164. self.grid_layout = self.scroll_content:GetComponent("GridLayoutGroup")
  165. self.transform.sizeDelta = Vector2(SrcScreenWidth, ScreenHeight)
  166. self.transform.anchoredPosition = Vector3.zero
  167. if self.pos_x and self.pos_y then
  168. self.info_con.anchoredPosition = Vector2(self.pos_x, self.pos_y)
  169. self.closeBtn2.transform.sizeDelta = co.TableXY(120, 50)
  170. self.closeBtn2.transform.anchoredPosition = co.TableXYZ(1280 + self.pos_x + 60 + 16, -720 + self.pos_y + self.info_con.sizeDelta.y + 25, 0)
  171. end
  172. self.info_con.anchoredPosition = Vector2(self.info_con.anchoredPosition.x+ClientConfig.iphone_x_offset_left, 63)
  173. if self.is_rest_anchor then
  174. self:ReSetInfoConAnchor()
  175. end
  176. self.allBtn_txt = self:GetChild("InfoCon/bagToggleGroup/allBtn/Label2"):GetComponent("TextMeshProUGUI")
  177. self.equipBtn_txt = self:GetChild("InfoCon/bagToggleGroup/equipBtn/Label2"):GetComponent("TextMeshProUGUI")
  178. self.materialBtn_txt = self:GetChild("InfoCon/bagToggleGroup/materialBtn/Label2"):GetComponent("TextMeshProUGUI")
  179. self.warehouseBtn_txt = self:GetChild("InfoCon/bagToggleGroup/warehouseBtn/Label2"):GetComponent("TextMeshProUGUI")
  180. -- self.allBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/allBtn/Label2"):GetComponent("Shadow")
  181. -- self.equipBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/equipBtn/Label2"):GetComponent("Shadow")
  182. -- self.materialBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/materialBtn/Label2"):GetComponent("Shadow")
  183. -- self.warehouseBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/warehouseBtn/Label2"):GetComponent("Shadow")
  184. SetLocalScale(self.info_con.transform, self.scale_num, self.scale_num, self.scale_num)
  185. end
  186. function IndividuationView:ReSetAllBtnText()
  187. self.allBtn_txt.color = ColorUtilValue.GRAY_DARK
  188. self.equipBtn_txt.color = ColorUtilValue.GRAY_DARK
  189. self.materialBtn_txt.color = ColorUtilValue.GRAY_DARK
  190. self.warehouseBtn_txt.color = ColorUtilValue.GRAY_DARK
  191. -- self.allBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0)
  192. -- self.equipBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0)
  193. -- self.materialBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0)
  194. -- self.warehouseBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0)
  195. end
  196. function IndividuationView:ReSetInfoConAnchor()
  197. self.info_con.anchorMin = Vector2(0.5, 0.5)
  198. self.info_con.anchorMax = Vector2(0.5, 0.5)
  199. end
  200. function IndividuationView:InitEvent()
  201. local function onOrientationChange()
  202. self.info_con.anchoredPosition = Vector2(self.info_con.anchoredPosition.x+ClientConfig.iphone_x_offset_left, 63)
  203. end
  204. self.orientation_change_id = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  205. local function onTarBtnClickHandler(target)
  206. local index = string.gsub(target.name, "btn", "")
  207. self:SwitchBar(tonumber(index))
  208. for k,v in pairs(self.tabbar_line) do
  209. local show_line = (tonumber(index) - 1 ~= k) and (tonumber(index) ~= k)
  210. v:SetActive(show_line)
  211. end
  212. if tonumber(index) == 4 and self.is_close_after_sendpos then
  213. self:Close()
  214. end
  215. end
  216. for i = 1, BTN_COUNT do
  217. AddClickEvent(self.tabbar_list[i], onTarBtnClickHandler)
  218. end
  219. local function onClickBtnHandler(target)
  220. if target == self.alphaBtn or target == self.closeBtn then
  221. self:Close()
  222. elseif target == self.closeBtn2 then
  223. GlobalEventSystem:Fire(EventName.CLOSE_CHAT_VIEW)
  224. self:Close()
  225. elseif target == self.bagAllBtn then
  226. self:UpdateAllBagView()
  227. --Message.show("bagAllBtn")
  228. elseif target == self.bagEquipBtn then
  229. self:SetEquipView()
  230. --Message.show("bagEquipBtn")
  231. elseif target == self.bagMaterialBtn then
  232. self:SetMaterialView()
  233. -- Message.show("bagMaterialBtn")
  234. elseif target == self.bagWarehouseBtn then
  235. --Message.show("bagWarehouseBtn")
  236. self:SetDepotView()
  237. end
  238. end
  239. AddClickEvent(self.alphaBtn, onClickBtnHandler)
  240. AddClickEvent(self.closeBtn, onClickBtnHandler)
  241. AddClickEvent(self.closeBtn2, onClickBtnHandler)
  242. AddClickEvent(self.bagAllBtn, onClickBtnHandler)
  243. AddClickEvent(self.bagEquipBtn, onClickBtnHandler)
  244. AddClickEvent(self.bagMaterialBtn, onClickBtnHandler)
  245. AddClickEvent(self.bagWarehouseBtn, onClickBtnHandler)
  246. local function onUpdate()
  247. self:UpdateView()
  248. end
  249. self.update_event_id = self.model:Bind(ChatModel.UPDATE_INDIVID_VIEW, onUpdate)
  250. end
  251. function IndividuationView:SwitchBar(index)
  252. if self.curr_selected_bar_index == index then return end
  253. self:ChangeTabBtnTextColor(index)
  254. self:ChangeBtnState(index)
  255. self.curr_selected_bar_index = index
  256. self.model.curr_individuation_bar_index = index
  257. self.scroll_content.localPosition = Vector3(0, 0, 0)
  258. self:UpdateView()
  259. -- self.bagToggleGroupObj:SetActive(index == 2)
  260. end
  261. function IndividuationView:UpdateView()
  262. for i, item in pairs(self.face_item_list) do
  263. item:SetSelfActive(false)
  264. end
  265. for i, item in pairs(self.textFace_item_list) do
  266. item:SetSelfActive(false)
  267. end
  268. for i, item in ipairs(self.history_text_item_list) do
  269. item:SetSelfActive(false)
  270. end
  271. for i, item in pairs(self.good_item_list) do
  272. item:SetSelfActive(false)
  273. end
  274. self.model.chat_bag_view_is_open = false
  275. local item = nil
  276. self.bagToggleGroupObj:SetActive(false)
  277. if self.curr_selected_bar_index == 1 or self.isOpen then--表情
  278. if self.isOpen then-- 强制重置为1,self.isOpen
  279. self.curr_selected_bar_index = 1
  280. for i = 1, BTN_COUNT do
  281. self.tabbar_list[i]:GetComponent("Toggle").isOn = false
  282. self:SetBtnState(i, false)
  283. end
  284. self.tabbar_list[1]:GetComponent("Toggle").isOn = true
  285. self:SetBtnState(1, true)
  286. self:ChangeTabBtnTextColor(self.curr_selected_bar_index)
  287. end
  288. for i = 1, self.face_count do
  289. item = self.face_item_list[i]
  290. if item == nil then
  291. item = FaceItem.New(self.scroll_content)
  292. table.insert(self.face_item_list, item)
  293. end
  294. item:SetData(i)
  295. item:SetSelfActive(true)
  296. end
  297. self.ScrollView.anchoredPosition = Vector2(56.33, 7)
  298. self.ScrollView.sizeDelta = Vector2(537.6, 215)
  299. self.grid_layout.cellSize = Vector2(96, 96)
  300. self.grid_layout.constraintCount = 6
  301. self.grid_layout.spacing = Vector2(-9, -3)
  302. --[[ elseif self.curr_selected_bar_index == 6 then--文字
  303. local len = #Config.ConfigChat.text_face + Config.ConfigChat.custom_num
  304. for i = 1, len do
  305. item = self.textFace_item_list[i]
  306. if item == nil then
  307. item = TextFaceItem.New(self.scroll_content)
  308. table.insert(self.textFace_item_list, item)
  309. end
  310. item:SetData(i)
  311. item:SetVisible(true)
  312. end
  313. self.grid_layout.cellSize = Vector2(154, 69)
  314. self.grid_layout.constraintCount = 3
  315. self.grid_layout.spacing = Vector2(2, 0)
  316. --]]
  317. elseif self.curr_selected_bar_index == 2 then -- 背包
  318. self.model.chat_bag_view_is_open = true
  319. self.ScrollView.anchoredPosition = Vector2(92.8, 8)
  320. self.ScrollView.sizeDelta = Vector2(467.2, 224.3)
  321. self.grid_layout.cellSize = Vector2(96, 96)
  322. self.grid_layout.constraintCount = BTN_COUNT
  323. self.grid_layout.spacing = Vector2(-4.9, 0)
  324. self:UpdateAllBagView()
  325. -- Message.show("bagAllBtn")
  326. self.bagToggleGroupObj:SetActive(true)
  327. elseif self.curr_selected_bar_index == 3 then
  328. -- if self.model.curr_channel == ChatModel.CHANNEL_CROSS then
  329. -- Message.show("跨服频道无法发送坐标")
  330. -- return
  331. -- end
  332. --跳跃中不能发坐标,障碍点也不能发
  333. if Scene.Instance.main_role:IsInState(PoseState.JUMP) or Scene.Instance.main_role:IsInState(PoseState.FLY) then return end
  334. --发送坐标 用超链接的方法
  335. local role = Scene.Instance:GetMainRole()
  336. if not role then return end
  337. local scene_id = SceneManager:getInstance():GetSceneId()
  338. local line = MapModel:getInstance():GetServerLine()
  339. local x = role.logic_pos.x
  340. local y = role.logic_pos.y
  341. if (self.model.curr_bar_index == ChatModel.CHANNEL_CROSS or
  342. self.model.curr_bar_index == ChatModel.CHANNEL_COUNTRY) and
  343. not SceneManager:getInstance():InServerScene(scene_id) then
  344. Message.show("跨服频道无法发送本服坐标")
  345. self:Close()
  346. return
  347. end
  348. if not SceneManager:getInstance():IsBlockXY(x, y) then
  349. local scene_name = SceneManager:getInstance():GetSceneInfo(scene_id).name
  350. local content = string.format("%s<a@pos@%s@%s@%s@%s><color=%s>[%s(%d,%d)]</color></a>","我在", scene_id, line, role.real_pos.x, role.real_pos.y, ColorUtil.PURPLE_DARK,scene_name, x, y)
  351. -- local show_str = "我在["..scene_name.."("..math.floor(x + 0.5) .. ","..math.floor(y + 0.5) .. ")]"
  352. -- self.model:Fire(ChatModel.CLICK_POS_BTN, content, show_str) -- 显示在输入框
  353. local tmpArgs = self.model:GetAllArgsText(content)
  354. -- tmpArgs =..tmpArgs.."</color>"
  355. content = self.model:GetHyperlinkText(content)
  356. local sendChannal = self.model.curr_bar_index
  357. sendChannal = (self.chating_key_id) and ChatModel.CHANNEL_CECRET or self.model.curr_bar_index --私聊频道的秒发
  358. self.model:Fire(ChatModel.SEND_MSG, sendChannal, content, self.chating_key_id, tmpArgs, ChatModel.CHAT_COMMON_TYPE.SYSTEM)
  359. self:Close()
  360. end
  361. elseif self.curr_selected_bar_index == 4 then --晒娃
  362. --Message.show("晒娃")
  363. if ChildModel:GetInstance():IsPlayerHadChild() then
  364. ChildModel:GetInstance():Fire(ChildConst.CHILD_REQ_EVENT, 16509,self.model:getInstance().curr_bar_index)
  365. else
  366. Message.show("您还没有娃娃哦~")
  367. end
  368. self:Close()
  369. --[[
  370. elseif self.curr_selected_bar_index == 5 then--历史 -- 暂时屏蔽
  371. if self.chating_key_id then
  372. local list = CookieWrapper.Instance:GetChatHistroy(self.chating_key_id,true)
  373. if list and list[tostring(self.chating_key_id)] then
  374. for k,v in pairs(list[tostring(self.chating_key_id)]) do
  375. if v and v.msg and v.player_id==RoleManager.Instance.mainRoleInfo.role_id then
  376. item = self.history_text_item_list[i]
  377. if item == nil then
  378. item = HistoryTextItem.New(self.scroll_content)
  379. table.insert(self.history_text_item_list, item)
  380. end
  381. item:SetData(v.msg)
  382. item:SetVisible(true)
  383. end
  384. end
  385. end
  386. end--]]
  387. else
  388. --[[
  389. local cookie = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, ChatModel.SAVE_CHAT_HISTORY_INFO)
  390. if cookie and #cookie > 0 then
  391. for i, v in ipairs(cookie) do
  392. item = self.history_text_item_list[i]
  393. if item == nil then
  394. item = HistoryTextItem.New(self.scroll_content)
  395. table.insert(self.history_text_item_list, item)
  396. end
  397. item:SetData(v)
  398. item:SetVisible(true)
  399. end
  400. end
  401. self.grid_layout.cellSize = Vector2(154, 69)
  402. self.grid_layout.constraintCount = 3
  403. self.grid_layout.spacing = Vector2(2, 0)]]
  404. end
  405. self.isOpen = false
  406. end
  407. function IndividuationView:UpdateAllBagView() -- 全部
  408. local index = 1
  409. local wear_equip_list = {}
  410. local bag_goods_list = {}
  411. self.bagAllBtn:GetComponent("Toggle").isOn = true
  412. self.bagEquipBtn:GetComponent("Toggle").isOn = false
  413. self.bagMaterialBtn:GetComponent("Toggle").isOn = false
  414. self.bagWarehouseBtn:GetComponent("Toggle").isOn = false
  415. self:ReSetAllBtnText()
  416. self.allBtn_txt.color = ColorUtilValue.WHITE
  417. --self.allBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1)
  418. for k, v in pairs(GoodsModel:getInstance().wear_equip_dic) do
  419. table.insert(wear_equip_list, v)
  420. table.insert(bag_goods_list, v)
  421. end
  422. -- for k, v in pairs(GoodsModel:getInstance().warehouse_goods_list) do
  423. -- table.insert(wear_equip_list, v)
  424. -- end
  425. for k, v in pairs(GoodsModel:getInstance().bag_goods_dic) do
  426. table.insert(bag_goods_list, v)
  427. end
  428. -- local function sort_func(v1, v2)
  429. -- return v1.type_id > v2.type_id
  430. --end
  431. -- table.sort(wear_equip_list, sort_func)
  432. --table.sort(bag_goods_list, sort_func)
  433. local createItem = function (vo)
  434. item = self.good_item_list[index]
  435. if item == nil then
  436. item = EquipShowItem.New(self.scroll_content)
  437. self.good_item_list[index] = item
  438. end
  439. item:ChangeCountVisible(false, 0)
  440. item:SetData(vo)
  441. item:SetItemSize(84, 84)
  442. item.selectImage.transform.sizeDelta = Vector2(96, 96)--imgSelect
  443. item:SetSelfActive(true)
  444. item:SetVisible(true)
  445. index = index + 1
  446. end
  447. for i, v in ipairs(wear_equip_list) do
  448. v.used = true
  449. --createItem(v)
  450. end
  451. --for i, v in ipairs(GoodsModel:getInstance().warehouse_goods_list) do
  452. -- createItem(v)
  453. --end
  454. GoodsModel:getInstance():SortBagListByBagView(bag_goods_list)
  455. for i, v in ipairs(bag_goods_list) do
  456. createItem(v)
  457. end
  458. end
  459. function IndividuationView:SetDepotView( ) -- 仓库
  460. local warehouse_goods_list = GoodsModel:getInstance().warehouse_goods_list
  461. local index = 1
  462. self:ReSetAllBtnText()
  463. self.warehouseBtn_txt.color = ColorUtilValue.WHITE
  464. --self.warehouseBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1)
  465. --local function sort_func(v1,v2)
  466. -- return v1.type_id > v2.type_id
  467. --end
  468. --table.sort(warehouse_goods_list,sort_func)
  469. for _,item in pairs(self.good_item_list) do
  470. item:SetSelfActive(false)
  471. end
  472. local createItem = function (vo)
  473. item = self.good_item_list[index]
  474. if item == nil then
  475. item = EquipShowItem.New(self.scroll_content)
  476. self.good_item_list[index] = item
  477. end
  478. item:ChangeCountVisible(false,0)
  479. item:SetData(vo)
  480. item:SetSelfActive(true)
  481. item:SetVisible(true)
  482. index = index + 1
  483. end
  484. GoodsModel:getInstance():SortBagListByBagView(warehouse_goods_list)
  485. for i,v in ipairs(warehouse_goods_list) do
  486. createItem(v)
  487. end
  488. end
  489. function IndividuationView:SetEquipView( ) -- 装备
  490. --local equip_goods_list = GoodsModel:getInstance():GetGoodsByMianType(5)
  491. local good_model = GoodsModel:getInstance()
  492. local equip_goods_list ={}
  493. self:ReSetAllBtnText()
  494. self.equipBtn_txt.color = ColorUtilValue.WHITE
  495. --self.equipBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1)
  496. --print("=============>>> YiRan:IndividuationView [start:461] good_model.bag_goods_dic ------------------------------------------")
  497. ----PrintTable(good_model.bag_goods_dic)
  498. --print("=============>>> YiRan:IndividuationView [end] ------------------------------------------")
  499. --local wear_equip_list = {}
  500. for k, v in pairs(GoodsModel:getInstance().wear_equip_dic) do
  501. table.insert(equip_goods_list, v)
  502. end
  503. for k,v in pairs(good_model.bag_goods_dic) do
  504. if good_model:GetGoodsTab(v.type, v.subtype) == 2 then
  505. table.insert(equip_goods_list, v)
  506. end
  507. end
  508. local index = 1
  509. --local function sort_func(v1,v2)
  510. -- return v1.type_id > v2.type_id
  511. --end
  512. --table.sort(equip_goods_list,sort_func)
  513. for _,item in pairs(self.good_item_list) do
  514. item:SetSelfActive(false)
  515. end
  516. local createItem = function (vo)
  517. item = self.good_item_list[index]
  518. if item == nil then
  519. item = EquipShowItem.New(self.scroll_content)
  520. self.good_item_list[index] = item
  521. end
  522. item:ChangeCountVisible(false,0)
  523. item:SetData(vo)
  524. item:SetSelfActive(true)
  525. item:SetVisible(true)
  526. index = index + 1
  527. end
  528. -- 排排序
  529. good_model:SortBagListByBagView( equip_goods_list)
  530. for i,v in ipairs(equip_goods_list) do
  531. createItem(v)
  532. end
  533. -- for i,v in ipairs(wear_equip_list) do
  534. -- createItem(v)
  535. -- end
  536. end
  537. function IndividuationView:SetMaterialView( ) -- 材料
  538. local good_model = GoodsModel:getInstance()
  539. local material_goods_list ={}
  540. self:ReSetAllBtnText()
  541. self.materialBtn_txt.color = ColorUtilValue.WHITE
  542. --self.materialBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1)
  543. for k,v in pairs(good_model.bag_goods_dic) do
  544. if good_model:GetGoodsTab(v.type, v.subtype) == 3 then
  545. table.insert(material_goods_list, v)
  546. end
  547. end
  548. --local material_goods_list = GoodsModel:getInstance():GetGoodsByMianType(0)
  549. local index = 1
  550. --local function sort_func(v1,v2)
  551. -- return v1.type_id > v2.type_id
  552. --end
  553. --table.sort(material_goods_list,sort_func)
  554. for _,item in pairs(self.good_item_list) do
  555. item:SetSelfActive(false)
  556. end
  557. local createItem = function (vo)
  558. item = self.good_item_list[index]
  559. if item == nil then
  560. item = EquipShowItem.New(self.scroll_content)
  561. self.good_item_list[index] = item
  562. end
  563. item:ChangeCountVisible(false,0)
  564. item:SetData(vo)
  565. item:SetSelfActive(true)
  566. item:SetVisible(true)
  567. index = index + 1
  568. end
  569. GoodsModel:getInstance():SortBagListByBagView(material_goods_list)
  570. for i,v in ipairs(material_goods_list) do
  571. createItem(v)
  572. end
  573. end
  574. function IndividuationView:ChangeTabBtnTextColor(index)
  575. -- for i = 1, BTN_COUNT do
  576. -- self.tabbar_text_list[i].color = (i == index) and Color(204 / 255, 88 / 255, 18 / 255, 1) or Color(105 / 255, 111 / 255, 138 / 255, 1)
  577. -- self.tabbar_shadow_list[i].effectColor = (i == index) and Color(255/255,255/255,255/255,87/255) or Color(199/255,198/255,206/255,118/255)
  578. -- end
  579. end
  580. function IndividuationView:ChangeBtnState(index)
  581. logWarn('=======Msh:IndividuationView.lua[627]=======', index)
  582. for i = 1, 4 do
  583. self:SetBtnState(i, i == index)
  584. end
  585. end