--个性化聊天界面 IndividuationView = IndividuationView or BaseClass(BaseView) local IndividuationView = IndividuationView local BTN_COUNT = 4 -- 页签数 function IndividuationView:__init() self.base_file = "chat" self.layout_file = "individuationView" self.layer_name = "Top" -- self.use_local_view = true self.destroy_imm = true self.change_scene_close = true -- self.append_to_ctl_queue = true self.face_item_list = {} self.textFace_item_list = {} self.history_text_item_list = {} self.good_item_list = {} self.use_background = true self.background_alpha = 0 self.hide_maincancas = false self.open_wnd_anim = 0 self.click_bg_toClose = true self.is_moving = false self.tabbar_list = {} self.tabbar_icon = {} self.tabbar_label_select = {} self.tabbar_label_normal = {} self.tabbar_line = {} self.tabbar_shadow_list = {} self.tabbar_text_list = {} self.curr_selected_bar_index = 0 self.init_bar_index = 1 self.face_count = 48--表情数量 self.scale_num = 1 self.model = ChatModel:getInstance() self.load_callback = function () self:LoadSuccess() self:InitEvent() --切换toggle self.tabbar_list[1]:GetComponent("Toggle").isOn = false self.tabbar_list[2]:GetComponent("Toggle").isOn = false self:SetBtnState( 1, false ) self:SetBtnState( 2, false ) self.tabbar_list[self.init_bar_index]:GetComponent("Toggle").isOn = true self:SetBtnState( self.init_bar_index, true ) end self.open_callback = function () self:SwitchBar(self.init_bar_index) local function onCompleted() self.is_moving = false self:ClearTweener() end self.is_moving = true --输入框高度 self.tween_id = TweenLite.to(self, self.info_con, TweenLite.UiAnimationType.ANCHORED_POSY, self.pos_y, 0.1, onCompleted) end self.close_callback = function () self.is_moving = false end self.destroy_callback = function () self:Clear() end if SceneManager:getInstance():IsGuildScene() then self.use_background = true self.click_bg_toClose = true end end function IndividuationView:ClearTweener() if self.tween_id then TweenLite.Stop(self.tween_id) self.tween_id = nil end end function IndividuationView:SetBtnState( index, is_select ) self.tabbar_icon[index]:SetActive(is_select) self.tabbar_label_select[index]:SetActive(is_select) self.tabbar_label_normal[index]:SetActive(not is_select) end function IndividuationView:Clear() self.model.chat_bag_view_is_open = false self.model.selected_face_item = nil self.model.selected_good_item = nil self.model.selected_histroy_item = nil self.model.selected_textface_item = nil self.model.selected_history_text_item = nil for i, item in pairs(self.good_item_list) do item:DeleteMe() end for i, item in pairs(self.face_item_list) do item:DeleteMe() end for i, item in pairs(self.textFace_item_list) do item:DeleteMe() end for i, item in ipairs(self.history_text_item_list) do item:DeleteMe() end self.face_item_list = {} self.textFace_item_list = {} if self.update_event_id then self.model:UnBind(self.update_event_id) self.update_event_id = nil end if self.orientation_change_id then GlobalEventSystem:UnBind(self.orientation_change_id) self.orientation_change_id = nil end self:ClearTweener() end function IndividuationView:Open(bar_index, pos_x, pos_y, is_close_after_sendpos, chating_key_id,is_rest_anchor,scale_num) self.isOpen = true if bar_index then self.init_bar_index = bar_index end self.pos_x = pos_x or ClientConfig.iphone_x_offset_left self.pos_y = pos_y or 0 self.is_close_after_sendpos = is_close_after_sendpos self.chating_key_id = chating_key_id --对于社交中对象 需要有特定的对象聊天记录 self.is_rest_anchor = is_rest_anchor self.scale_num = scale_num or 1 BaseView.Open(self) end function IndividuationView:Close() if self.is_moving == false then self.model.clicked_role_item = nil BaseView.Close(self) end end function IndividuationView:LoadSuccess() self.info_con, self.ScrollView, self.scroll_content = GetChildTransforms(self.transform, { "InfoCon", "InfoCon/ScrollView", "InfoCon/ScrollView/Viewport/Content", }) self.closeBtn, self.closeBtn2, self.bagToggleGroupObj, self.bagAllBtn, self.bagEquipBtn, self.bagMaterialBtn, self.bagWarehouseBtn = GetChildGameObjects(self.transform, { "InfoCon/closeBtn", "closeBtn2", "InfoCon/bagToggleGroup", "InfoCon/bagToggleGroup/allBtn", "InfoCon/bagToggleGroup/equipBtn", "InfoCon/bagToggleGroup/materialBtn", "InfoCon/bagToggleGroup/warehouseBtn", }) self.closeBtn2:SetActive(false) for i = 1, BTN_COUNT do self.tabbar_list[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i).gameObject self.tabbar_icon[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/Background/Checkmark/icon").gameObject self.tabbar_label_select[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/Background/Checkmark/Label2").gameObject self.tabbar_label_normal[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/Label2").gameObject self.tabbar_line[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i .. "/line").gameObject -- self.tabbar_text_list[i] = self:GetChild("InfoCon/tabbarScrollView/Viewport/Content/btn"..i.."/Label2"):GetComponent("TextMeshProUGUI") -- self.tabbar_text_list[i].color = Color(167 / 255, 119 / 255, 85 / 255, 1) --self.tabbar_shadow_list[i] = self.tabbar_text_list[i]:GetComponent("Shadow") end self.grid_layout = self.scroll_content:GetComponent("GridLayoutGroup") self.transform.sizeDelta = Vector2(SrcScreenWidth, ScreenHeight) self.transform.anchoredPosition = Vector3.zero if self.pos_x and self.pos_y then self.info_con.anchoredPosition = Vector2(self.pos_x, self.pos_y) self.closeBtn2.transform.sizeDelta = co.TableXY(120, 50) self.closeBtn2.transform.anchoredPosition = co.TableXYZ(1280 + self.pos_x + 60 + 16, -720 + self.pos_y + self.info_con.sizeDelta.y + 25, 0) end self.info_con.anchoredPosition = Vector2(self.info_con.anchoredPosition.x+ClientConfig.iphone_x_offset_left, 63) if self.is_rest_anchor then self:ReSetInfoConAnchor() end self.allBtn_txt = self:GetChild("InfoCon/bagToggleGroup/allBtn/Label2"):GetComponent("TextMeshProUGUI") self.equipBtn_txt = self:GetChild("InfoCon/bagToggleGroup/equipBtn/Label2"):GetComponent("TextMeshProUGUI") self.materialBtn_txt = self:GetChild("InfoCon/bagToggleGroup/materialBtn/Label2"):GetComponent("TextMeshProUGUI") self.warehouseBtn_txt = self:GetChild("InfoCon/bagToggleGroup/warehouseBtn/Label2"):GetComponent("TextMeshProUGUI") -- self.allBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/allBtn/Label2"):GetComponent("Shadow") -- self.equipBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/equipBtn/Label2"):GetComponent("Shadow") -- self.materialBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/materialBtn/Label2"):GetComponent("Shadow") -- self.warehouseBtn_shadow = self:GetChild("InfoCon/bagToggleGroup/warehouseBtn/Label2"):GetComponent("Shadow") SetLocalScale(self.info_con.transform, self.scale_num, self.scale_num, self.scale_num) end function IndividuationView:ReSetAllBtnText() self.allBtn_txt.color = ColorUtilValue.GRAY_DARK self.equipBtn_txt.color = ColorUtilValue.GRAY_DARK self.materialBtn_txt.color = ColorUtilValue.GRAY_DARK self.warehouseBtn_txt.color = ColorUtilValue.GRAY_DARK -- self.allBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0) -- self.equipBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0) -- self.materialBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0) -- self.warehouseBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 0) end function IndividuationView:ReSetInfoConAnchor() self.info_con.anchorMin = Vector2(0.5, 0.5) self.info_con.anchorMax = Vector2(0.5, 0.5) end function IndividuationView:InitEvent() local function onOrientationChange() self.info_con.anchoredPosition = Vector2(self.info_con.anchoredPosition.x+ClientConfig.iphone_x_offset_left, 63) end self.orientation_change_id = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, onOrientationChange) local function onTarBtnClickHandler(target) local index = string.gsub(target.name, "btn", "") self:SwitchBar(tonumber(index)) for k,v in pairs(self.tabbar_line) do local show_line = (tonumber(index) - 1 ~= k) and (tonumber(index) ~= k) v:SetActive(show_line) end if tonumber(index) == 4 and self.is_close_after_sendpos then self:Close() end end for i = 1, BTN_COUNT do AddClickEvent(self.tabbar_list[i], onTarBtnClickHandler) end local function onClickBtnHandler(target) if target == self.alphaBtn or target == self.closeBtn then self:Close() elseif target == self.closeBtn2 then GlobalEventSystem:Fire(EventName.CLOSE_CHAT_VIEW) self:Close() elseif target == self.bagAllBtn then self:UpdateAllBagView() --Message.show("bagAllBtn") elseif target == self.bagEquipBtn then self:SetEquipView() --Message.show("bagEquipBtn") elseif target == self.bagMaterialBtn then self:SetMaterialView() -- Message.show("bagMaterialBtn") elseif target == self.bagWarehouseBtn then --Message.show("bagWarehouseBtn") self:SetDepotView() end end AddClickEvent(self.alphaBtn, onClickBtnHandler) AddClickEvent(self.closeBtn, onClickBtnHandler) AddClickEvent(self.closeBtn2, onClickBtnHandler) AddClickEvent(self.bagAllBtn, onClickBtnHandler) AddClickEvent(self.bagEquipBtn, onClickBtnHandler) AddClickEvent(self.bagMaterialBtn, onClickBtnHandler) AddClickEvent(self.bagWarehouseBtn, onClickBtnHandler) local function onUpdate() self:UpdateView() end self.update_event_id = self.model:Bind(ChatModel.UPDATE_INDIVID_VIEW, onUpdate) end function IndividuationView:SwitchBar(index) if self.curr_selected_bar_index == index then return end self:ChangeTabBtnTextColor(index) self:ChangeBtnState(index) self.curr_selected_bar_index = index self.model.curr_individuation_bar_index = index self.scroll_content.localPosition = Vector3(0, 0, 0) self:UpdateView() -- self.bagToggleGroupObj:SetActive(index == 2) end function IndividuationView:UpdateView() for i, item in pairs(self.face_item_list) do item:SetSelfActive(false) end for i, item in pairs(self.textFace_item_list) do item:SetSelfActive(false) end for i, item in ipairs(self.history_text_item_list) do item:SetSelfActive(false) end for i, item in pairs(self.good_item_list) do item:SetSelfActive(false) end self.model.chat_bag_view_is_open = false local item = nil self.bagToggleGroupObj:SetActive(false) if self.curr_selected_bar_index == 1 or self.isOpen then--表情 if self.isOpen then-- 强制重置为1,self.isOpen self.curr_selected_bar_index = 1 for i = 1, BTN_COUNT do self.tabbar_list[i]:GetComponent("Toggle").isOn = false self:SetBtnState(i, false) end self.tabbar_list[1]:GetComponent("Toggle").isOn = true self:SetBtnState(1, true) self:ChangeTabBtnTextColor(self.curr_selected_bar_index) end for i = 1, self.face_count do item = self.face_item_list[i] if item == nil then item = FaceItem.New(self.scroll_content) table.insert(self.face_item_list, item) end item:SetData(i) item:SetSelfActive(true) end self.ScrollView.anchoredPosition = Vector2(56.33, 7) self.ScrollView.sizeDelta = Vector2(537.6, 215) self.grid_layout.cellSize = Vector2(96, 96) self.grid_layout.constraintCount = 6 self.grid_layout.spacing = Vector2(-9, -3) --[[ elseif self.curr_selected_bar_index == 6 then--文字 local len = #Config.ConfigChat.text_face + Config.ConfigChat.custom_num for i = 1, len do item = self.textFace_item_list[i] if item == nil then item = TextFaceItem.New(self.scroll_content) table.insert(self.textFace_item_list, item) end item:SetData(i) item:SetVisible(true) end self.grid_layout.cellSize = Vector2(154, 69) self.grid_layout.constraintCount = 3 self.grid_layout.spacing = Vector2(2, 0) --]] elseif self.curr_selected_bar_index == 2 then -- 背包 self.model.chat_bag_view_is_open = true self.ScrollView.anchoredPosition = Vector2(92.8, 8) self.ScrollView.sizeDelta = Vector2(467.2, 224.3) self.grid_layout.cellSize = Vector2(96, 96) self.grid_layout.constraintCount = BTN_COUNT self.grid_layout.spacing = Vector2(-4.9, 0) self:UpdateAllBagView() -- Message.show("bagAllBtn") self.bagToggleGroupObj:SetActive(true) elseif self.curr_selected_bar_index == 3 then -- if self.model.curr_channel == ChatModel.CHANNEL_CROSS then -- Message.show("跨服频道无法发送坐标") -- return -- end --跳跃中不能发坐标,障碍点也不能发 if Scene.Instance.main_role:IsInState(PoseState.JUMP) or Scene.Instance.main_role:IsInState(PoseState.FLY) then return end --发送坐标 用超链接的方法 local role = Scene.Instance:GetMainRole() if not role then return end local scene_id = SceneManager:getInstance():GetSceneId() local line = MapModel:getInstance():GetServerLine() local x = role.logic_pos.x local y = role.logic_pos.y if (self.model.curr_bar_index == ChatModel.CHANNEL_CROSS or self.model.curr_bar_index == ChatModel.CHANNEL_COUNTRY) and not SceneManager:getInstance():InServerScene(scene_id) then Message.show("跨服频道无法发送本服坐标") self:Close() return end if not SceneManager:getInstance():IsBlockXY(x, y) then local scene_name = SceneManager:getInstance():GetSceneInfo(scene_id).name local content = string.format("%s[%s(%d,%d)]","我在", scene_id, line, role.real_pos.x, role.real_pos.y, ColorUtil.PURPLE_DARK,scene_name, x, y) -- local show_str = "我在["..scene_name.."("..math.floor(x + 0.5) .. ","..math.floor(y + 0.5) .. ")]" -- self.model:Fire(ChatModel.CLICK_POS_BTN, content, show_str) -- 显示在输入框 local tmpArgs = self.model:GetAllArgsText(content) -- tmpArgs =..tmpArgs.."" content = self.model:GetHyperlinkText(content) local sendChannal = self.model.curr_bar_index sendChannal = (self.chating_key_id) and ChatModel.CHANNEL_CECRET or self.model.curr_bar_index --私聊频道的秒发 self.model:Fire(ChatModel.SEND_MSG, sendChannal, content, self.chating_key_id, tmpArgs, ChatModel.CHAT_COMMON_TYPE.SYSTEM) self:Close() end elseif self.curr_selected_bar_index == 4 then --晒娃 --Message.show("晒娃") if ChildModel:GetInstance():IsPlayerHadChild() then ChildModel:GetInstance():Fire(ChildConst.CHILD_REQ_EVENT, 16509,self.model:getInstance().curr_bar_index) else Message.show("您还没有娃娃哦~") end self:Close() --[[ elseif self.curr_selected_bar_index == 5 then--历史 -- 暂时屏蔽 if self.chating_key_id then local list = CookieWrapper.Instance:GetChatHistroy(self.chating_key_id,true) if list and list[tostring(self.chating_key_id)] then for k,v in pairs(list[tostring(self.chating_key_id)]) do if v and v.msg and v.player_id==RoleManager.Instance.mainRoleInfo.role_id then item = self.history_text_item_list[i] if item == nil then item = HistoryTextItem.New(self.scroll_content) table.insert(self.history_text_item_list, item) end item:SetData(v.msg) item:SetVisible(true) end end end end--]] else --[[ local cookie = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, ChatModel.SAVE_CHAT_HISTORY_INFO) if cookie and #cookie > 0 then for i, v in ipairs(cookie) do item = self.history_text_item_list[i] if item == nil then item = HistoryTextItem.New(self.scroll_content) table.insert(self.history_text_item_list, item) end item:SetData(v) item:SetVisible(true) end end self.grid_layout.cellSize = Vector2(154, 69) self.grid_layout.constraintCount = 3 self.grid_layout.spacing = Vector2(2, 0)]] end self.isOpen = false end function IndividuationView:UpdateAllBagView() -- 全部 local index = 1 local wear_equip_list = {} local bag_goods_list = {} self.bagAllBtn:GetComponent("Toggle").isOn = true self.bagEquipBtn:GetComponent("Toggle").isOn = false self.bagMaterialBtn:GetComponent("Toggle").isOn = false self.bagWarehouseBtn:GetComponent("Toggle").isOn = false self:ReSetAllBtnText() self.allBtn_txt.color = ColorUtilValue.WHITE --self.allBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1) for k, v in pairs(GoodsModel:getInstance().wear_equip_dic) do table.insert(wear_equip_list, v) table.insert(bag_goods_list, v) end -- for k, v in pairs(GoodsModel:getInstance().warehouse_goods_list) do -- table.insert(wear_equip_list, v) -- end for k, v in pairs(GoodsModel:getInstance().bag_goods_dic) do table.insert(bag_goods_list, v) end -- local function sort_func(v1, v2) -- return v1.type_id > v2.type_id --end -- table.sort(wear_equip_list, sort_func) --table.sort(bag_goods_list, sort_func) local createItem = function (vo) item = self.good_item_list[index] if item == nil then item = EquipShowItem.New(self.scroll_content) self.good_item_list[index] = item end item:ChangeCountVisible(false, 0) item:SetData(vo) item:SetItemSize(84, 84) item.selectImage.transform.sizeDelta = Vector2(96, 96)--imgSelect item:SetSelfActive(true) item:SetVisible(true) index = index + 1 end for i, v in ipairs(wear_equip_list) do v.used = true --createItem(v) end --for i, v in ipairs(GoodsModel:getInstance().warehouse_goods_list) do -- createItem(v) --end GoodsModel:getInstance():SortBagListByBagView(bag_goods_list) for i, v in ipairs(bag_goods_list) do createItem(v) end end function IndividuationView:SetDepotView( ) -- 仓库 local warehouse_goods_list = GoodsModel:getInstance().warehouse_goods_list local index = 1 self:ReSetAllBtnText() self.warehouseBtn_txt.color = ColorUtilValue.WHITE --self.warehouseBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1) --local function sort_func(v1,v2) -- return v1.type_id > v2.type_id --end --table.sort(warehouse_goods_list,sort_func) for _,item in pairs(self.good_item_list) do item:SetSelfActive(false) end local createItem = function (vo) item = self.good_item_list[index] if item == nil then item = EquipShowItem.New(self.scroll_content) self.good_item_list[index] = item end item:ChangeCountVisible(false,0) item:SetData(vo) item:SetSelfActive(true) item:SetVisible(true) index = index + 1 end GoodsModel:getInstance():SortBagListByBagView(warehouse_goods_list) for i,v in ipairs(warehouse_goods_list) do createItem(v) end end function IndividuationView:SetEquipView( ) -- 装备 --local equip_goods_list = GoodsModel:getInstance():GetGoodsByMianType(5) local good_model = GoodsModel:getInstance() local equip_goods_list ={} self:ReSetAllBtnText() self.equipBtn_txt.color = ColorUtilValue.WHITE --self.equipBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1) --print("=============>>> YiRan:IndividuationView [start:461] good_model.bag_goods_dic ------------------------------------------") ----PrintTable(good_model.bag_goods_dic) --print("=============>>> YiRan:IndividuationView [end] ------------------------------------------") --local wear_equip_list = {} for k, v in pairs(GoodsModel:getInstance().wear_equip_dic) do table.insert(equip_goods_list, v) end for k,v in pairs(good_model.bag_goods_dic) do if good_model:GetGoodsTab(v.type, v.subtype) == 2 then table.insert(equip_goods_list, v) end end local index = 1 --local function sort_func(v1,v2) -- return v1.type_id > v2.type_id --end --table.sort(equip_goods_list,sort_func) for _,item in pairs(self.good_item_list) do item:SetSelfActive(false) end local createItem = function (vo) item = self.good_item_list[index] if item == nil then item = EquipShowItem.New(self.scroll_content) self.good_item_list[index] = item end item:ChangeCountVisible(false,0) item:SetData(vo) item:SetSelfActive(true) item:SetVisible(true) index = index + 1 end -- 排排序 good_model:SortBagListByBagView( equip_goods_list) for i,v in ipairs(equip_goods_list) do createItem(v) end -- for i,v in ipairs(wear_equip_list) do -- createItem(v) -- end end function IndividuationView:SetMaterialView( ) -- 材料 local good_model = GoodsModel:getInstance() local material_goods_list ={} self:ReSetAllBtnText() self.materialBtn_txt.color = ColorUtilValue.WHITE --self.materialBtn_shadow.effectColor = Color(208 / 255, 211 / 255, 222 / 255, 1) for k,v in pairs(good_model.bag_goods_dic) do if good_model:GetGoodsTab(v.type, v.subtype) == 3 then table.insert(material_goods_list, v) end end --local material_goods_list = GoodsModel:getInstance():GetGoodsByMianType(0) local index = 1 --local function sort_func(v1,v2) -- return v1.type_id > v2.type_id --end --table.sort(material_goods_list,sort_func) for _,item in pairs(self.good_item_list) do item:SetSelfActive(false) end local createItem = function (vo) item = self.good_item_list[index] if item == nil then item = EquipShowItem.New(self.scroll_content) self.good_item_list[index] = item end item:ChangeCountVisible(false,0) item:SetData(vo) item:SetSelfActive(true) item:SetVisible(true) index = index + 1 end GoodsModel:getInstance():SortBagListByBagView(material_goods_list) for i,v in ipairs(material_goods_list) do createItem(v) end end function IndividuationView:ChangeTabBtnTextColor(index) -- for i = 1, BTN_COUNT do -- 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) -- 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) -- end end function IndividuationView:ChangeBtnState(index) logWarn('=======Msh:IndividuationView.lua[627]=======', index) for i = 1, 4 do self:SetBtnState(i, i == index) end end