ro-webgl/Assets/Lua/UI/UIChat/UIChatView.lua

1421 lines
46 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local UIChatView = require("UIChat/UIChatView_Generate")
local UIChatRoot = require("UIChat/UIChatRoot")
local regexPattern = "%[e%d+%]"
local emojiFormat = "[e%s]"
local BottomTabType = {
MessageTab = 1,
SearchTab = 2,
MeTab = 3
}
local ChatType = {
Private = 1,
Group = 2
}
local BottonTabNames = {
[BottomTabType.MessageTab] = "消息",
[BottomTabType.SearchTab] = "发现",
[BottomTabType.MeTab] = "通讯录",
}
local CONST_CHANNEL_WORLD = "10000"
local CONST_CHANNEL_GUILD = "10001"
local CONST_CHANNEL_STORY = "20000"
local CONST_TOGGLE_EMOJI = 1
local CONST_TOGGLE_GIFT = 2
local CONST_TOGGLE_STORY = 3
local CONST_TOGGLE_DATE = 4
local CONST_TOGGLE_PHOTO = 5
local CONST_TITLE_HEIGHT = 150
local CONST_INPUT_BAR_HEIGHT = 270
local CONST_INPUT_WINDOW_HEIGHT = 730
local uIChatRootWorld
function UIChatView:OnAwake(data)
self.controller = require("UIChat/UIChatCtr")
self.controller:Init(self)
self.controller:SetData(data)
end
function UIChatView:AddEventListener()
ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_WOLRD_CHAT, function(channelType)
local channelId = CONST_CHANNEL_WORLD
if channelType == Enum.ChatChannel.World then
channelId = CONST_CHANNEL_WORLD
elseif channelType == Enum.ChatChannel.Guild then
channelId = CONST_CHANNEL_GUILD
end
self:RefreshMessageTab()
self:RefreshChatLayer2(channelId)
end)
ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_PRIVATE_CHAT, function(idx, uid)
local channelId = uid
self:RefreshMessageTab()
self:RefreshChatLayer2(channelId)
end)
ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CHAT_STORY_REWARD, function(story_rewards)
local rewards = {}
for k, v in pairs(story_rewards) do
table.insert(rewards,{cfgId = v.key, num = v.value})
end
ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPOPGot, {rewards = rewards})
self:RefreshChatLayer2(CONST_CHANNEL_STORY, self.currStoryData)
end)
ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CHAT_STORY_ADD_HEART_NTF, function(storyNpcId, heart, addHeart)
LogError("[EID_CHAT_STORY_ADD_HEART_NTF] storyNpcId="..storyNpcId.." heart="..heart.." addHeart="..addHeart)
self:PlayAddHeartAnimation(storyNpcId, heart, addHeart)
end)
end
function UIChatView:FillContent(data, uiBase)
self.pageToggleData = {}
self.uiBase = uiBase
local gameObject = self.uiBase:GetRoot()
if gameObject ~= nil then
self.gameObject = gameObject
self.transform = gameObject.transform
end
self:InitGenerate(self.transform, data)
self:OnceInit()
self:Init()
end
function UIChatView:OnceInit()
self:InitEmojiPanel()
self:InitGiftWindow()
self:InitDateWindow()
self:InitPhotoWindow()
end
function UIChatView:Init()
local channel = ManagerContainer.DataMgr.ChatData:GetChatChannelType()
-- if uIChatRootWorld == nil then
-- uIChatRootWorld = UIChatRoot:new()
-- uIChatRootWorld:Init(self,channel, self.chatWindow, self.chatInputField1)
-- end
self:SetToggleGroupStatus(channel)
self:OnChannelChange(nil, channel, true)
self.uiBase:AddButtonUniqueEventListener(self.chatLayer2.titleBarReturnBtn.button, self, self.Layer2_OnClickReturnBtn)
self.uiBase:AddButtonUniqueEventListener(self.chatLayer2.AnyBtn.button, self, self.OnChatLayer2AnyBtn)
self.uiBase:AddButtonUniqueEventListener(self.chatLayer2.btnSend.button, self, self.OnChatLayer2BtnSend)
self.uiBase:AddButtonUniqueEventListener(self.chatLayer2.storyInputTip.button, self, self.OnChatLayer2StoryInputTip)
self.currChatChannelId = "0"
self.tabViews = {
[BottomTabType.MessageTab] = self.chatTab,
[BottomTabType.SearchTab] = self.searchTab,
[BottomTabType.MeTab] = self.meTab
}
self:RefreshTable(BottomTabType.MessageTab)
self.InputBarWindows = {
[CONST_TOGGLE_EMOJI] = self.chatLayer2.emojiWindow,
[CONST_TOGGLE_GIFT] = self.chatLayer2.giftWindow,
[CONST_TOGGLE_STORY] = self.chatLayer2.storyWindow,
[CONST_TOGGLE_DATE] = self.chatLayer2.dateWindow,
[CONST_TOGGLE_PHOTO] = self.chatLayer2.photoWindow
}
self.InputBarToggles = {
[CONST_TOGGLE_EMOJI] = self.chatLayer2.emojiToggle,
[CONST_TOGGLE_GIFT] = self.chatLayer2.giftToggle,
[CONST_TOGGLE_STORY] = self.chatLayer2.storyToggle,
[CONST_TOGGLE_DATE] = self.chatLayer2.dateToggle,
[CONST_TOGGLE_PHOTO] = self.chatLayer2.photoToggle
}
-- local subType = self.controller:CheckChatSubType("[gift-2]")
-- LogError("[gift-2], "..tostring(subType))
if self.controller:IsOpenStoryMode() then
-- TODO: 这里使用storyData的channelId
local channelId = CONST_CHANNEL_STORY
local storyData = self.controller:GetOpenStoryData()
self:EnterChatLayer2(channelId, storyData)
end
end
function UIChatView:OnChatLayer2StoryInputTip()
LogError("UIChatView:OnChatLayer2StoryInputTip")
if self.currStoryChatInputOptions then
self.chatLayer2.storyInputTip.button.interactable = false
self:ShowStoryMenuWindow(self.currStoryChatInputOptions)
self.currStoryChatInputOptions = nil
end
end
function UIChatView:OnChatLayer2BtnSend()
if self.chatLayer2.inputField.inputField.text == "" then return end
local contentStr = self.chatLayer2.inputField.inputField.text
self.chatLayer2.inputField.inputField.text = ""
local subType = self.controller:CheckChatSubType(contentStr)
--LogError("UIChatView-OnChatLayer2BtnSend: "..contentStr..", "..subType)
self:CloseAllInputToolBarToggles()
if self.sendStoryId and self.sendStoryId ~= 0 then
self.controller:SendStoryChat(self.sendStoryId, self.sendPerformStoryCfgId)
self.sendStoryId = 0
self.sendPerformStoryCfgId = 0
else
local chatDataType = Enum.ChatDataType.Private
if self.currChatChannelId == CONST_CHANNEL_WORLD then
chatDataType = Enum.ChatDataType.World
elseif self.currChatChannelId == CONST_CHANNEL_GUILD then
chatDataType = Enum.ChatDataType.Guild
end
self.controller:SendChatReq(contentStr, chatDataType, subType)
end
-- self.delaySendFrameTimer = FrameTimer.New(function()
-- self:CloseAllInputToolBarToggles()
-- end, 60)
-- self.delaySendFrameTimer:Start()
end
function UIChatView:OnChatLayer2AnyBtn()
self:CloseAllInputToolBarToggles()
end
function UIChatView:InitEmojiPanel()
local emojis = ManagerContainer.CfgMgr:GetEmojiCfg()
CommonUtil.LoopGridViewEleCreateNoItem(self,
self.chatLayer2.emojiWindow.loopVerticalScrollRect,
emojis, 0, self,
function (owner, go, idx, logicData)
local textTrans = go.transform:Find("Text")
local text = textTrans:GetComponent(Enum.TypeInfo.SymbolText)
local index = idx
if idx < 10 then
index = "0"..idx
end
text.text = string.format(emojiFormat, index)
local uiTrigger = textTrans:GetComponent(Enum.TypeInfo.UIEventTriggerListener)
uiTrigger.onClick = function()
self:OnEmojiClick(idx)
end
uiTrigger.onBeginDrag = function()
self.chatLayer2.emojiWindow.loopVerticalScrollRect:OnBeginDrag(UIEventTriggerListener.currentEventData)
end
uiTrigger.onDrag = function()
self.chatLayer2.emojiWindow.loopVerticalScrollRect:OnDrag(UIEventTriggerListener.currentEventData)
end
uiTrigger.onEndDrag = function()
self.chatLayer2.emojiWindow.loopVerticalScrollRect:OnEndDrag(UIEventTriggerListener.currentEventData)
end
end)
end
function UIChatView:InitGiftWindow()
local gifts = ManagerContainer.CfgMgr:GetChatGiftCfg()
CommonUtil.LoopGridViewEleCreateNoItem(
self, self.chatLayer2.giftWindow.loopVerticalScrollRect, gifts, 0, self,
function (owner, go, idx, logicData)
local iconPath = logicData['Icon']
local name = logicData['Name']
local id = logicData['Id']
local uiTrigger = go:GetComponent(Enum.TypeInfo.UIEventTriggerListener)
uiTrigger.onClick = function() self:OnGiftClick(id) end
local iconImage = go.transform:Find("Icon"):GetComponent(Enum.TypeInfo.Image)
local title = go.transform:Find("Info/Title"):GetComponent(Enum.TypeInfo.TextMeshProUGUI)
title.text = name
CommonUtil.LoadIcon(self, iconPath, function(sprite)
iconImage.sprite = sprite
end)
end
)
end
function UIChatView:ShowStoryMenuWindow(storyOptionDatas)
local storyDatas = CommonUtil.TableClone(storyOptionDatas)
if not storyDatas or #storyDatas == 0 then return end
self.chatLayer2.inputToolBar:SetActive(true)
self.chatLayer2.storyWindow:SetActive(true)
local width = self.chatLayer2.storyWindow.rectTransform.sizeDelta.x
local height = 0
if #storyDatas == 1 then
height = 200
elseif #storyDatas == 2 then
height = 345
elseif #storyDatas == 3 then
height = 480
end
self.chatLayer2.storyWindow.rectTransform.sizeDelta = Vector2(width, height)
self.chatLayer2.storyWindow.loopVerticalScrollRect:ClearCells()
CommonUtil.LoopGridViewEleCreateNoItem(
self, self.chatLayer2.storyWindow.loopVerticalScrollRect,
storyDatas, 0, self,
function (owner, go, idx, logicData)
local txtTrans = go.transform:Find("Txt")
local txt = txtTrans:GetComponent(Enum.TypeInfo.TextMeshProUGUI)
txt.text = logicData.optionText
local uiTrigger = go:GetComponent(Enum.TypeInfo.UIEventTriggerListener)
uiTrigger.onClick = function() self:OnStoryClick(logicData.storyId, logicData.performStoryCfgId, logicData.optionText) end
end
)
end
function UIChatView:HideStoryMenuWindow()
self.chatLayer2.inputToolBar:SetActive(false)
self.chatLayer2.storyWindow:SetActive(false)
end
function UIChatView:InitDateWindow()
local dates = ManagerContainer.CfgMgr:GetChatDateCfg()
CommonUtil.LoopGridViewEleCreateNoItem(
self, self.chatLayer2.dateWindow.loopVerticalScrollRect,
dates, 0, self,
function (owner, go, idx, logicData)
local iconPath = logicData['Icon']
local name = logicData['Name']
local id = logicData['Id']
local uiTrigger = go:GetComponent(Enum.TypeInfo.UIEventTriggerListener)
uiTrigger.onClick = function() self:OnDateClick(id) end
local iconImage = go.transform:Find("Icon"):GetComponent(Enum.TypeInfo.Image)
local title = go.transform:Find("Info/Title"):GetComponent(Enum.TypeInfo.TextMeshProUGUI)
title.text = name
CommonUtil.LoadIcon(self, iconPath, function(sprite)
iconImage.sprite = sprite
end)
end
)
end
function UIChatView:InitPhotoWindow()
local photos = ManagerContainer.CfgMgr:GetChatPhotoCfg()
CommonUtil.LoopGridViewEleCreateNoItem(
self, self.chatLayer2.photoWindow.loopVerticalScrollRect,
photos, 0, self,
function (owner, go, idx, logicData)
local iconPath = logicData['Icon']
local name = logicData['Name']
local id = logicData['Id']
local uiTrigger = go:GetComponent(Enum.TypeInfo.UIEventTriggerListener)
uiTrigger.onClick = function() self:OnPhotoClick(id) end
local iconImage = go.transform:Find("Icon"):GetComponent(Enum.TypeInfo.Image)
local title = go.transform:Find("Info/Title"):GetComponent(Enum.TypeInfo.TextMeshProUGUI)
title.text = name
CommonUtil.LoadIcon(self, iconPath, function(sprite)
iconImage.sprite = sprite
end)
end
)
end
function UIChatView:OnPhotoClick(photoId)
--LogError("OnPhotoClick: "..photoId)
local format = "[photo-%s]"
self.chatLayer2.inputField.inputField.text = string.format(format, photoId)
--self:CloseAllInputToolBarToggles()
end
function UIChatView:OnStoryClick(storyId, performStoryCfgId, optionText)
--LogError("OnStoryClick: "..storyId..", "..performStoryCfgId)
self.chatLayer2.inputField.inputField.text = optionText
self:CloseAllInputToolBarToggles()
self.sendStoryId = storyId
self.sendPerformStoryCfgId = performStoryCfgId
--self:OnChatLayer2BtnSend()
end
function UIChatView:OnGiftClick(giftId)
--LogError("OnGiftClick: "..giftId)
local format = "[gift-%s]"
self.chatLayer2.inputField.inputField.text = string.format(format, giftId)
--self:CloseAllInputToolBarToggles()
end
function UIChatView:OnDateClick(dateId)
--LogError("OnGiftClick: "..dateId)
local format = "[date-%s]"
self.chatLayer2.inputField.inputField.text = string.format(format, dateId)
--self:CloseAllInputToolBarToggles()
end
function UIChatView:OnEmojiClick(idx)
local count = 0
for k, v in string.gmatch(self.chatLayer2.inputField.inputField.text, regexPattern) do
count = count + 1
end
if count >= 5 then
ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("ChatError2")
return
end
if idx < 10 then
idx = "0"..idx
end
self.chatLayer2.inputField.inputField.text = self.chatLayer2.inputField.inputField.text..string.format(emojiFormat, idx)
self:OnEmojiBgClick()
--self:CloseAllInputToolBarToggles()
end
function UIChatView:ResetInputField()
self.chatLayer2.inputField.inputField.text = ""
end
function UIChatView:OnChannelChange(toggle, chatType, isOn)
if not isOn then return end
if self:IsSomeFrameCount('ChatChannelToggle') then
return
end
ManagerContainer.DataMgr.ChatData:SetChatChannelType(chatType)
end
function UIChatView:RemoveEventListener()
ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
end
function UIChatView:OnBtnClose(button, params)
if self.chatLayer2.emojiWindow.activeSelf then
self:OnEmojiBgClick()
return
end
self:UIClose()
end
function UIChatView:OnEmojiBgClick(button, params)
self.chatLayer2.emojiWindow:SetActive(not self.chatLayer2.emojiWindow.activeSelf)
end
function UIChatView:OnBottomTabChange2(toggle, tabType, isOn)
if isOn then
self:RefreshTable(tabType)
end
end
function UIChatView:OnBottomTabChange(tabType)
--LogError("OnBottomTabChange: "..tabType)
self:RefreshTable(tabType)
end
function UIChatView:RefreshTitleBarForTab(tabType)
if tabType == BottomTabType.MessageTab then
local str = BottonTabNames[tabType]
self.chatLayer0.titleBarText.text.text = str
elseif tabType == BottomTabType.SearchTab then
local str = BottonTabNames[tabType]
self.chatLayer0.titleBarText.text.text = str
elseif tabType == BottomTabType.MeTab then
local str = BottonTabNames[tabType]
self.chatLayer0.titleBarText.text.text = str
end
end
function UIChatView:RefreshTitleBarForChatLayer2(channelId)
end
function UIChatView:RefreshTable(tabType)
self.currTabType = tabType
for k, v in pairs(self.tabViews) do
v:SetActive(k == tabType)
end
self:RefreshTitleBarForTab(tabType)
if tabType == BottomTabType.MessageTab then
self:RefreshMessageTab()
elseif tabType == BottomTabType.SearchTab then
self:RefreshSearchTab()
elseif tabType == BottomTabType.MeTab then
self:RefreshMeTab()
end
end
--[[
1. worldChats:
[
{
"isSystem": true,
"nickname": "",
"paramIds": [
15,
0
],
"sendTime": "1753858800",
"sendTime64": "1753858800268",
"type": 6
},
{
"isSystem": true,
"nickname": "",
"paramIds": [
16,
0
],
"sendTime": "1753858800",
"sendTime64": "1753858800267",
"type": 6
},
{
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_500102",
"jobId": 50010,
"level": 79,
"nickname": "丫咩爹",
"sex": 2,
"titleId": 0,
"uid": "7482229966215577633",
"vipLv": 19
},
"message": {
"message": "123",
"sendTime64": "1753757369925",
"subType": 0,
"used": false
},
"targetId": "0",
"type": 2
},
{
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_500102",
"jobId": 50010,
"level": 79,
"nickname": "丫咩爹",
"sex": 2,
"titleId": 0,
"uid": "7482229966215577633",
"vipLv": 19
},
"message": {
"message": "[e01]",
"sendTime64": "1753757637655",
"subType": 0,
"used": false
},
"targetId": "0",
"type": 2
},
{
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_500102",
"jobId": 50010,
"level": 79,
"nickname": "丫咩爹",
"sex": 2,
"titleId": 0,
"uid": "7482229966215577633",
"vipLv": 19
},
"message": {
"message": "[e02]",
"sendTime64": "1753760515287",
"subType": 0,
"used": false
},
"targetId": "0",
"type": 2
},
{
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_500102",
"jobId": 50010,
"level": 79,
"nickname": "丫咩爹",
"sex": 2,
"titleId": 0,
"uid": "7482229966215577633",
"vipLv": 19
},
"message": {
"message": "[e03]",
"sendTime64": "1753761406564",
"subType": 0,
"used": false
},
"targetId": "0",
"type": 2
},
{
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_500102",
"jobId": 50010,
"level": 79,
"nickname": "丫咩爹",
"sex": 2,
"titleId": 0,
"uid": "7482229966215577633",
"vipLv": 19
},
"message": {
"message": "13441111",
"sendTime64": "1753767151426",
"subType": 0,
"used": false
},
"targetId": "0",
"type": 2
}
]
2. guildChats:
3. privateChats:
[
{
"chats": [
{
"fromData": {
"imgId": "Heads/head_500102",
"nickname": "丫咩爹",
"sex": 2,
"uid": "7482229966215577633"
},
"message": {
"message": "[e09]",
"sendTime64": "1743335693618",
"subType": 0,
"used": false
},
"type": 1
},
{
"fromData": {
"headFrameId": 325,
"imgId": "Heads/head_200212_pro",
"jobId": 20031,
"level": 119,
"nickname": "寿",
"onlineState": false,
"sex": 2,
"titleId": 611,
"uid": "7482034996175175713",
"vipLv": 25
},
"message": {
"message": "111",
"sendTime64": "1744085032907",
"subType": 0,
"used": false
},
"type": 1
},
{
"fromData": {
"headFrameId": 325,
"imgId": "Heads/head_200212_pro",
"jobId": 20031,
"level": 119,
"nickname": "寿",
"onlineState": false,
"sex": 2,
"titleId": 611,
"uid": "7482034996175175713",
"vipLv": 25
},
"message": {
"message": "1111",
"sendTime64": "1745292716759",
"subType": 0,
"used": false
},
"type": 1
},
{
"fromData": {
"headFrameId": 325,
"imgId": "Heads/head_200212_pro",
"jobId": 20031,
"level": 119,
"nickname": "寿",
"onlineState": false,
"sex": 2,
"titleId": 611,
"uid": "7482034996175175713",
"vipLv": 25
},
"message": {
"message": "[e03]",
"sendTime64": "1747211047131",
"subType": 0,
"used": false
},
"type": 1
},
{
"fromData": {
"headFrameId": 325,
"imgId": "Heads/head_200212_pro",
"jobId": 20031,
"level": 119,
"nickname": "寿",
"onlineState": false,
"sex": 2,
"titleId": 611,
"uid": "7482034996175175713",
"vipLv": 25
},
"message": {
"message": "你在吗?",
"sendTime64": "1747211561438",
"subType": 0,
"used": false
},
"type": 1
},
{
"fromData": {
"headFrameId": 325,
"imgId": "Heads/head_200212_pro",
"jobId": 20031,
"level": 119,
"nickname": "寿",
"onlineState": false,
"sex": 2,
"titleId": 611,
"uid": "7482034996175175713",
"vipLv": 25
},
"message": {
"message": "[e09]",
"sendTime64": "1747361099991",
"subType": 0,
"used": false
},
"type": 1
}
],
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_200212_pro",
"jobId": 20031,
"level": 120,
"nickname": "寿",
"onlineState": true,
"sex": 2,
"titleId": 611,
"uid": "7482034996175175713",
"vipLv": 25
},
"isNew": false
},
{
"chats": Array[1],
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_100001",
"jobId": 10000,
"level": 9,
"nickname": "",
"onlineState": false,
"sex": 1,
"uid": "7483067416118820897"
},
"isNew": false
}
]
]]
function UIChatView:RefreshMessageTab()
-- channelId-10000-世界channelId-10001-工会channelId-uid-私聊
local chatTabDataList = {}
-------------------------- 1. 世界群聊 --------------------------
local worldChats = ManagerContainer.DataMgr.ChatData:GetWorldChatDatas()
local worldHeadIcons = {}
for k, v in pairs(worldChats) do
if v.type == Enum.ChatSystemType.Hero then
table.insert(worldHeadIcons, v.fromData.imgId)
end
if #worldHeadIcons >= 9 then break end
end
local worldTitle = "世界"
local worldSubTitle = "给世界发一条消息吧!"
if #worldHeadIcons > 0 and worldChats[#worldChats].fromData then
worldSubTitle = worldChats[#worldChats].fromData.nickname..": "..worldChats[#worldChats].message.message
else
worldHeadIcons = {"Heads/head_100102"}
end
table.insert(chatTabDataList, {
chatType = ChatType.Group,
channelId = CONST_CHANNEL_WORLD,
title = worldTitle,
headIcons = worldHeadIcons,
subTitle = worldSubTitle
})
-------------------------- 2. 公会群聊 --------------------------
local guildChats = ManagerContainer.DataMgr.ChatData:GetGuildChatDatas()
local guildHeadIcons = {}
for k, v in pairs(guildChats) do
if v.type == Enum.ChatSystemType.Hero then
table.insert(guildHeadIcons, v.fromData.imgId)
end
if #guildHeadIcons >= 9 then break end
end
if #guildHeadIcons > 0 then
table.insert(chatTabDataList, {
chatType = ChatType.Group,
channelId = CONST_CHANNEL_GUILD,
title = "公会",
headIcons = guildHeadIcons,
subTitle = guildChats[#guildChats].fromData.nickname..": "..guildChats[#guildChats].message.message,
})
else
guildHeadIcons = {"Heads/head_100102"}
table.insert(chatTabDataList, {
chatType = ChatType.Group,
channelId = CONST_CHANNEL_GUILD,
title = "公会",
headIcons = guildHeadIcons,
subTitle = "",
})
end
-------------------------- 3. 剧情聊天 --------------------------
local storyChatDatas = self.controller:GetStoryChatDatasForMessageTab()
for i = 1, #storyChatDatas do
local storyCfg = storyChatDatas[i]
local firstStoryPerformCfg = ManagerContainer.CfgMgr:GetFirstStoryPerformCfg(storyCfg.StoryId)
LogError("firstStoryPerformCfg: "..Inspect(firstStoryPerformCfg))
local headImg, name
if firstStoryPerformCfg.SpeakSite == 1 then
headImg = firstStoryPerformCfg.LeftImg
name = firstStoryPerformCfg.LeftName
else
headImg = firstStoryPerformCfg.RightImg
name = firstStoryPerformCfg.RightName
end
local chatTabData = {
chatType = ChatType.Private,
channelId = CONST_CHANNEL_STORY,
title = name,
headIcons = {headImg},
subTitle = firstStoryPerformCfg.SpeakId,
storyCfg = storyCfg
}
table.insert(chatTabDataList, chatTabData)
end
-------------------------- 4. 好友私聊 --------------------------
local privateChats = ManagerContainer.DataMgr.ChatData:GetPrivateSortChatDatas()
for k, v in pairs(privateChats) do
local privateChat = v
local newestIdx = #privateChat.chats
if newestIdx > 0 then
local chatTabData = {
chatType = ChatType.Private,
channelId = privateChat.fromData.uid,
title = privateChat.fromData.nickname,
headIcons = { privateChat.fromData.imgId },
subTitle = privateChat.chats[newestIdx].message.message,
}
table.insert(chatTabDataList, chatTabData)
end
end
CommonUtil.LoopGridViewEleCreateNew(self,
self.chatTab.chatTabLoopScrollView.loopVerticalScrollRect,
self.chatTab.chatTabContent.verticalLayoutGroup,
chatTabDataList, 0, self, self.SetChatTabItem)
end
function UIChatView:SetChatTabItem(itemLua, idx, itemData)
itemLua.title.text.text = itemData.title
itemLua.subTitle.text.text = itemData.subTitle
for i = 1, 9 do
itemLua["c"..i]:SetActive(false)
end
for i = 1, #itemData.headIcons do
local icon = itemLua["c"..i]
icon:SetActive(true)
local iconPath = itemData.headIcons[i]
CommonUtil.LoadIcon(self, iconPath, function (sprite)
icon.image.sprite = sprite
end)
end
if #itemData.headIcons == 1 then
itemLua.headIcons.gridLayoutGroup.cellSize = Vector2(150, 150)
elseif #itemData.headIcons >= 3 and #itemData.headIcons <= 4 then
itemLua.headIcons.gridLayoutGroup.cellSize = Vector2(60, 60)
elseif #itemData.headIcons >= 5 and #itemData.headIcons <= 9 then
itemLua.headIcons.gridLayoutGroup.cellSize = Vector2(40, 40)
end
self.uiBase:AddButtonUniqueEventListener(itemLua.button, self, self.OnClickChatItem, itemLua, itemData)
end
function UIChatView:OnClickChatItem(btn, params)
local itemLua = params[0]
local chatItemData = params[1]
local channelId = chatItemData.channelId
local storyCfg = chatItemData.storyCfg
self:EnterChatLayer2(channelId, storyCfg)
end
function UIChatView:RefreshSearchTab()
local storyDatas = ManagerContainer.DataMgr.StoryData:GetStoryDatas()
--LogError("-RefreshSearchTab-"..Inspect(storyDatas))
local searchTabDataList = ManagerContainer.CfgMgr:GetStoryNpcCfgNotIn(storyDatas)
CommonUtil.LoopGridViewEleCreateNew(
self, self.searchTab.searchTabLoopScrollView.loopVerticalScrollRect,
self.searchTab.searchTabContent.verticalLayoutGroup,
searchTabDataList, 0, self, self.SetSearchTabItem
)
end
function UIChatView:SetSearchTabItem(itemLua, idx, itemData)
local mapLevel = self.controller:GetMapLevel()
local isUnlock = false
if itemData['MapLevel'] <= mapLevel then
isUnlock = true
end
itemLua.name.text.text = itemData['Name']
itemLua.location.text.text = itemData['Location']
itemLua.age.text.text = itemData['Age']
itemLua.nation.text.text = itemData['Nation']
itemLua.marry.text.text = itemData['Marry']
itemLua.post.text.text = itemData['Post']
itemLua.upVote.text.text = itemData['Upvote']
itemLua.commentNum.text.text = itemData['Comment']
--itemLua.headItem.levelText:SetActive(false)
-- CommonUtil.LoadIcon(self, itemData['HeadImg'], function(sprite)
-- itemLua.headItem.head.image.sprite = sprite
-- end)
CommonUtil.LoadIcon(self, itemData['HeadImg'], function(sprite)
itemLua.headIconNode.headIcon.image.sprite = sprite
end)
itemLua.photoPart:SetActive(itemData['Photos'] and #itemData['Photos'] > 0)
for i = 1, 3 do
if itemData['Photos'] and itemData['Photos'][i] then
itemLua.photoPart['mask'..i]:SetActive(true)
CommonUtil.LoadIcon(self, itemData['Photos'][i], function(sprite)
itemLua.photoPart['photo'..i].image.sprite = sprite
end)
else
itemLua.photoPart['mask'..i]:SetActive(false)
end
end
if idx == 0 then
self['searchTabGreetBtn1'] = itemLua.greetBtn
end
itemLua.greetBtn.lock:SetActive(isUnlock==false)
itemLua.greetBtn.button.interactable = isUnlock
if isUnlock then
self.uiBase:AddButtonUniqueEventListener(itemLua.greetBtn.button, self, function() self:OnGreetBtn(itemData) end)
end
end
function UIChatView:OnGreetBtn(itemData)
LogError("OnGreetBtn: for StoryId "..itemData['StoryId'])
local storyId = itemData['StoryId']
local channelId = CONST_CHANNEL_STORY
local storyCfgData = ManagerContainer.CfgMgr:GetStoryDataById(storyId)
self:EnterChatLayer2(channelId, storyCfgData)
end
function UIChatView:RefreshMeTab()
local contactDatas = {
{
type = 2,
name = "妻子",
num = 2,
},
{
type = 1,
name = "海拉1",
head = "NpcHeads/npc_head_1",
heart = 12
},
{
type = 1,
name = "海拉2",
head = "NpcHeads/npc_head_2",
heart = 90
},
{
type = 2,
name = "情人",
num = 2,
},
{
type = 1,
name = "海拉3",
head = "NpcHeads/npc_head_3",
heart = 12
},
{
type = 1,
name = "海拉4",
head = "NpcHeads/npc_head_4",
heart = 56
},
}
CommonUtil.LoopGridViewEleCreateNew(
self, self.meTab.meTabLoopScrollView.loopVerticalScrollRect,
self.meTab.meTabContent.verticalLayoutGroup,
contactDatas, 0, self, self.SetMeTabItem
)
end
function UIChatView:SetMeTabItem(itemLua, idx, itemData)
local isGroup = itemData.type == 2
local height = 190
if isGroup then height = 100 end
itemLua.layoutElement.preferredHeight = height
itemLua.contact:SetActive(isGroup == false)
itemLua.contactGroupTitle:SetActive(isGroup == true)
if isGroup then
itemLua.groupName.text.text = itemData.name
itemLua.contactNum.text.text = itemData.num
else
itemLua.name.text.text = itemData.name
itemLua.heartNum.text.text = itemData.heart
itemLua.progress.image.fillAmount = itemData.heart/100
CommonUtil.LoadIcon(self, itemData.head, function(sprite)
itemLua.headIcon.image.sprite = sprite
end)
self.uiBase:AddButtonUniqueEventListener(itemLua.button, self, self.OnClickContactItem, itemLua, itemData)
end
end
function UIChatView:OnClickContactItem(btn, params)
local itemLua = params[0]
local itemData = params[1]
PrintJson("OnClickContactItem: ", itemData)
end
function UIChatView:Layer2_OnClickReturnBtn()
self.chatLayer2:SetActive(false)
self.currChatChannelId = "0"
self:RefreshTable(self.currTabType)
end
function UIChatView:EnterChatLayer2(channelId, storyData)
self.currChatChannelId = channelId
self.chatLayer2:SetActive(true)
self:CloseAllInputToolBarToggles()
self:RefreshTitleBarForChatLayer2(channelId)
self:ResetInputField()
--self.chatLayer2.loopListView.layoutElement.preferredHeight = UnityEngine.Screen.height - CONST_TITLE_HEIGHT - CONST_INPUT_BAR_HEIGHT
-- 开启聊天模拟
if channelId == CONST_CHANNEL_STORY then
self.controller:ResetStoryChatDatas()
local newMessageNtfFunc = function(currStoryId, currStoryPerformCfgId)
-- TODO: Check chatContent type If Reward Message: [Gift-11111]
local tmpStoryCfg = ManagerContainer.CfgMgr:GetStoryDataById(currStoryId)
local storyPerformCfg = ManagerContainer.CfgMgr:GetStoryPerformCfgV2(currStoryPerformCfgId)
if storyPerformCfg then
local chatContent = I18N.T(storyPerformCfg.SpeakId)
local subType = self.controller:CheckChatSubType(chatContent)
if subType == Enum.ChatSubType.Heart then
local rewardId = chatContent:match("%[heart%-(%d+)%]")
local rewardIdNum = tonumber(rewardId)
if rewardIdNum ~= nil then
ManagerContainer.DataMgr.StoryData:AddHeart(currStoryId, rewardIdNum)
end
end
end
self:RefreshChatLayer2(channelId, tmpStoryCfg)
end
local chatInputNtfFunc = function(options)
--self:ShowInputToolBarWindow(CONST_TOGGLE_STORY, options)
--PrintJson("UIChatView:OnChatLayer2StoryInputTip", options)
self.chatLayer2.storyInputTip.button.interactable = true
--self.currStoryChatInputOptions = options
self:ShowStoryMenuWindow(options)
end
local storyPlayFinishNtfFunc = function()
local data = self.controller:GetData()
if data.onStoryFinish then data.onStoryFinish() end
self.chatLayer2.titleBarReturnBtn.button.interactable = true
end
local storyRecordDatas = ManagerContainer.DataMgr.StoryData:GetStoryDatas()
--LogError("storyRecordDatas: "..Inspect(storyRecordDatas))
if true or not storyRecordDatas[storyData.StoryId] then
self:SetUIStoryMode(true)
self.controller:StartStoryChat(storyData.Id, newMessageNtfFunc, chatInputNtfFunc, storyPlayFinishNtfFunc, true)
else
-- 显示历史聊天剧情
self:SetUIStoryMode(false)
end
self:RefreshChatLayer2(channelId, storyData)
else
self:SetUIStoryMode(false)
self:RefreshChatLayer2(channelId, storyData)
end
end
function UIChatView:SetUIStoryMode(isStoryMode)
local canInteractable = (isStoryMode == false)
for k, v in pairs(self.InputBarToggles) do
v:SetActive(not isStoryMode)
end
for k, v in pairs(self.InputBarToggles) do
v.toggle.interactable = canInteractable
end
self.chatLayer2.titleBarHeart:SetActive(isStoryMode)
self.chatLayer2.storyInputTip:SetActive(isStoryMode)
self.chatLayer2.titleBarReturnBtn.button.interactable = canInteractable
self.chatLayer2.AnyBtn.button.interactable = canInteractable
end
function UIChatView:UpdateChatLayer2Item(gridView, itemIndex)
local datas = self.currChatData.chats
if not datas then return nil end
local logicData = datas[itemIndex + 1]
if not logicData then return nil end
local item = gridView:NewListViewItem(Enum.PrefabNames.ChatContentItem)
item.gameObject.name = itemIndex
local itemLua = CommonUtil.BindGridViewItem2Lua(self, Enum.PrefabNames.ChatContentItem, item.gameObject)
CommonUtil.UpdateItemPrefab(self, itemLua, logicData, Enum.ItemIEnterType.System, self, self.OnChatContentItemClicked)
return item
end
--[[
params[0]:
{
fromData = {
headFrameId = 300,
imgId = "PlayerHeads/player_head_furuiya",
nickname = "芙蕾雅",
uid = "1000"
},
message = {
message = "[gift-1]",
sendTime64 = "1742893748043",
subType = 3,
used = false
},
targetId = "58017",
type = 2
}
]]
function UIChatView:OnChatContentItemClicked(button, params)
local p1 = params[0]
--LogError("[UIChatView] OnChatContentItemClicked " .. Inspect(p1))
local storyPerformCfgId = p1.targetId
local contentStr = p1.message.message
if p1.message.subType == Enum.ChatSubType.Gift then
local rewardId = tonumber(contentStr:match("%[gift%-(%d+)%]"))
local storyPerformCfgV2 = ManagerContainer.CfgMgr:GetStoryPerformCfgV2(storyPerformCfgId)
local storyId = storyPerformCfgV2.StoryId
LogError("OnChatContentItemClicked: rewardId="..rewardId)
ManagerContainer.DataMgr.StoryData:RecordGetReward(storyId, rewardId)
end
end
function UIChatView:RefreshChatLayer2(channelId, storyData)
if self.currChatChannelId ~= channelId then return end
self.currChatData = {}
-- world chat
if channelId == CONST_CHANNEL_WORLD then
self.currChatData.fromData = {
["headFrameId"] = 300,
["imgId"] = "Heads/head_100001",
["jobId"] = 10000,
["level"] = 9,
["nickname"] = "世界",
["onlineState"] = false,
["sex"] = 1,
["uid"] = channelId
}
self.currChatData.chats = ManagerContainer.DataMgr.ChatData:GetWorldChatDatas()
-- guild chat
elseif channelId == CONST_CHANNEL_GUILD then
self.currChatData.fromData = {
["headFrameId"] = 300,
["imgId"] = "Heads/head_100001",
["jobId"] = 10000,
["level"] = 9,
["nickname"] = "工会",
["onlineState"] = false,
["sex"] = 1,
["uid"] = channelId
}
self.currChatData.chats = ManagerContainer.DataMgr.ChatData:GetGuildChatDatas()
-- story chat
elseif channelId == CONST_CHANNEL_STORY then
if storyData == nil then return end
--[[ storyData:
{AddHeart = 2, ForceGuideGroup = 0, HideUi = false, Id = 301, NeedBg = false,
NeedSave = false, PlayInterval = 5, ProgramControl = true, Skip = false,
StoryId = 301, StoryNpcId = 20001, Transition = false, TransitionType = 3, Type = 1} ]]
self:RefreshTitleForStoryNpc(storyData.StoryNpcId)
self.currStoryData = storyData
self.currChatData.fromData = {
["headFrameId"] = 300,
["imgId"] = "Heads/head_100001",
["jobId"] = 10000,
["level"] = 9,
["nickname"] = "剧情",
["onlineState"] = false,
["sex"] = 1,
["uid"] = channelId
}
local storyPerformCfgId = self.controller:GetCurrStoryPerformCfgId(storyData.StoryId)
self.currChatData.chats = self.controller:GetStoryChatDatas(storyData.StoryId, storyPerformCfgId)
-- private chat
else
self.currChatData.chats = {}
local privateChats = ManagerContainer.DataMgr.ChatData:GetPrivateSortChatDatas()
for k, v in pairs(privateChats) do
if v.fromData.uid == channelId then
chatData = v
break
end
end
end
-- table.insert(chatData.chats, {
-- type = 2,
-- targetId = "0",
-- fromData = {},
-- message = {
-- message = "这是系统通知消息",
-- sendTime64 = "1756966829316",
-- used = false,
-- subType = 7
-- }
-- })
if self.currChatData.fromData then
self.chatLayer2.titleBarText.text.text = self.currChatData.fromData.nickname
end
local datas = self.currChatData.chats
local max = datas and #datas or 0
if self.chatLayer2.loopListView.loopListView.ListViewInited == false then
self.chatLayer2.loopListView.loopListView:InitListView(0, function(gridView, itemIndex)
return self:UpdateChatLayer2Item(gridView, itemIndex)
end)
end
self.chatLayer2.loopListView.loopListView:ResetListView(true)
self.chatLayer2.loopListView.loopListView:SetListItemCount(max)
self.chatLayer2.loopListView.loopListView:RefreshAllShownItem()
self.chatLayer2.loopListView.loopListView:MovePanelToItemIndex(#self.currChatData.chats, 0)
end
function UIChatView:PlayAddHeartAnimation(storyNpcId, heart, addHeart)
self:RefreshTitleForStoryNpc(storyNpcId)
end
function UIChatView:RefreshTitleForStoryNpc(storyNpcId)
local heart = ManagerContainer.DataMgr.StoryData:GetStoryNpcHeart(storyNpcId)
self.chatLayer2.heartNum.text.text = heart
end
-- itemData format:
--[[
{
"isSystem": true,
"nickname": "",
"paramIds": [15, 0],
"sendTime": "1747292400",
"sendTime64": "1747292400020",
"type": 6
}
{
"fromData": {
"headFrameId": 300,
"imgId": "Heads/head_400212_pro",
"jobId": 40031,
"level": 95,
"nickname": "寿",
"sex": 2,
"titleId": 423,
"uid": "7482034996175175713",
"vipLv": 24
},
"message": {
"message": "[e03][e03][e03][e03][e03]",
"sendTime64": "1742893748043",
"subType": 0,
"used": false
},
"targetId": "0",
"type": 2
}
]]
function UIChatView:AddUIEventListener()
ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
-- CommonUtil.CreateToggleMouduleOnlyBtns(self, self.pageToggleData, self.toggle, Enum.ChatChannel.World, self.OnChannelChange)
self.uiBase:AddToggleEventListener(self.chWorld.toggle, self, self.OnChannelChange, Enum.ChatChannel.World)
self.uiBase:AddToggleEventListener(self.chGuild.toggle, self, self.OnChannelChange, Enum.ChatChannel.Guild)
self.uiBase:AddToggleEventListener(self.chSystem.toggle, self, self.OnChannelChange, Enum.ChatChannel.System)
--self.uiBase:AddButtonEventListener(self.AnyBtn.button, self, self.OnBtnClose)
--uIChatRootWorld:AddUIEventListener()
self.uiBase:AddButtonEventListener(self.BtnClose.button, self, self.OnBtnClose)
--self.uiBase:AddToggleEventListener(self.messageTabBtn.toggle, self, self.OnBottomTabChange, BottomTabType.MessageTab)
--self.uiBase:AddToggleEventListener(self.searchTabBtn.toggle, self, self.OnBottomTabChange, BottomTabType.SearchTab)
--self.uiBase:AddToggleEventListener(self.meTabBtn.toggle, self, self.OnBottomTabChange, BottomTabType.MeTab)
self.bottomTabToggleData = {}
CommonUtil.CreateToggleMouduleOnlyBtns(self, self.bottomTabToggleData, self.bottomTabBar.toggleGroup, 1, self.OnBottomTabChange, self)
self.uiBase:AddToggleEventListener(self.chatLayer2.emojiToggle.toggle, self, self.OnValueChanged_InputToolBarToggleGroup, CONST_TOGGLE_EMOJI)
self.uiBase:AddToggleEventListener(self.chatLayer2.giftToggle.toggle, self, self.OnValueChanged_InputToolBarToggleGroup, CONST_TOGGLE_GIFT)
self.uiBase:AddToggleEventListener(self.chatLayer2.storyToggle.toggle, self, self.OnValueChanged_InputToolBarToggleGroup, CONST_TOGGLE_STORY)
self.uiBase:AddToggleEventListener(self.chatLayer2.dateToggle.toggle, self, self.OnValueChanged_InputToolBarToggleGroup, CONST_TOGGLE_DATE)
self.uiBase:AddToggleEventListener(self.chatLayer2.photoToggle.toggle, self, self.OnValueChanged_InputToolBarToggleGroup, CONST_TOGGLE_PHOTO)
self.uiBase:AddButtonEventListener(self.btnBack.button, self, self.OnBtnBack)
end
local currInputToolBarToggleType = 0
function UIChatView:OnValueChanged_InputToolBarToggleGroup(toggle, toggleType, isOn)
--LogError("toggle: "..tostring(toggleType).."-"..tostring(isOn))
if isOn == false then
self:CloseAllInputToolBarToggles()
return
end
if currInputToolBarToggleType == toggleType then
--LogError("UIChatView: close "..tostring(toggleType))
self:CloseAllInputToolBarToggles()
else
--LogError("UIChatView: open "..tostring(toggleType))
self:ShowInputToolBarWindow(toggleType)
end
end
function UIChatView:ShowInputToolBarWindow(toggleType, windowData)
--self:CloseAllInputToolBarToggles()
self.InputBarToggles[toggleType].on:SetActive(true)
self.InputBarToggles[toggleType].off:SetActive(false)
self.InputBarWindows[toggleType]:SetActive(true)
--self.chatLayer2.loopListView.layoutElement.preferredHeight = UnityEngine.Screen.height - CONST_TITLE_HEIGHT - CONST_INPUT_BAR_HEIGHT - CONST_INPUT_WINDOW_HEIGHT
self.chatLayer2.AnyBtn:SetActive(true)
self.chatLayer2.inputToolBar:SetActive(true)
currInputToolBarToggleType = toggleType
self:UpInputBar()
if toggleType == CONST_TOGGLE_STORY then
local storyDatas = windowData
-- storyDatas = {
-- {storyId=10089, performStoryCfgId=100000, optionText="好的好的!"},
-- {storyId=20098, performStoryCfgId=100000, optionText="不行啊,我有事"},
-- {storyId=20198, performStoryCfgId=100000, optionText="让我考虑一下!"}
-- }
self:ShowStoryMenuWindow(storyDatas)
end
end
function UIChatView:UpInputBar()
--[[
self.chatLayer2.inputPanel.layoutElement.preferredHeight = 1000
if self.currChatData then
self.delayShowInputFrameTimer = FrameTimer.New(function()
self.chatLayer2.loopListView.loopListView:ResetListView(false)
self.chatLayer2.loopListView.loopListView:MovePanelToItemIndex(#self.currChatData.chats, 0)
self.chatLayer2.loopListView.loopListView:RefreshAllShownItem()
end, 3)
self.delayShowInputFrameTimer:Start()
end
]]
end
function UIChatView:DownInputBar()
--[[
self.chatLayer2.inputPanel.layoutElement.preferredHeight = 270
--self.chatLayer2.loopListView.layoutElement.preferredHeight = UnityEngine.Screen.height - CONST_TITLE_HEIGHT - CONST_INPUT_BAR_HEIGHT
if self.currChatData then
self.delayHideInputFrameTimer = FrameTimer.New(function()
self.chatLayer2.loopListView.loopListView:ResetListView(false)
self.chatLayer2.loopListView.loopListView:MovePanelToItemIndex(#self.currChatData.chats, 0)
self.chatLayer2.loopListView.loopListView:RefreshAllShownItem()
end, 3)
self.delayHideInputFrameTimer:Start()
end
]]
end
function UIChatView:CloseAllInputToolBarToggles()
self:DownInputBar()
for k, v in pairs(self.InputBarToggles) do
v.on:SetActive(false)
v.off:SetActive(true)
end
for k, v in pairs(self.InputBarWindows) do
v:SetActive(false)
end
self.chatLayer2.AnyBtn:SetActive(false)
self.chatLayer2.inputToolBar:SetActive(false)
currInputToolBarToggleType = 0
end
function UIChatView:OnBtnBack(btn)
self.chatLayer2.loopListView.loopListView:Dispose()
ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIChat)
end
function UIChatView:OnHide()
end
function UIChatView:OnShow(data)
self:OnChannelChange(nil, ManagerContainer.DataMgr.ChatData:GetChatChannelType(), true)
self:Init()
end
function UIChatView:OnClose()
if not self.closed then
self.closed = true
end
ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.WORLD_CHAT_UI_CLOSE)
-- if uIChatRootWorld then
-- uIChatRootWorld:Dispose()
-- uIChatRootWorld = nil
-- end
end
function UIChatView:OnDispose()
self.chatLayer2.emojiWindow:SetActive(false)
self.chatLayer2.inputField.inputField:DeactivateInputField()
self.chatLayer2.emojiWindow.loopVerticalScrollRect:ClearCells()
self.chatLayer2.loopListView.loopListView:Dispose()
end
function UIChatView:IsSomeFrameCount(keyName)
local value = self[keyName]
if value and value >= Time.frameCount then
return true
end
self[keyName] = Time.frameCount
return false
end
function UIChatView:SetToggleGroupStatus(chatChannelType)
local toggleGroup = self.toggle.toggleGroup
local oldAllowSwitchOff = toggleGroup.allowSwitchOff
toggleGroup.allowSwitchOff = false
self.chWorld.toggle.isOn = (chatChannelType == Enum.ChatChannel.World)
self.chGuild.toggle.isOn = (chatChannelType == Enum.ChatChannel.Guild)
self.chSystem.toggle.isOn = (chatChannelType == Enum.ChatChannel.System)
toggleGroup.allowSwitchOff = oldAllowSwitchOff
end
return UIChatView