const int TC_MESSAGELIST_TYPE_ID_GLOBAL = 00; const int TC_MESSAGELIST_TYPE_ID_PRIVATE = 10; const int TC_MESSAGELIST_TYPE_ID_SYSTEM = 20; // テキストチャットのメッセージ全体の統括担当 class TCMessageManagerList { const int MAX_MESSAGE_LOGSTOCK_SIZE = 20; // リストの種別[全体 / 個人 / システム通知] int _messageListType; string _layerName; // チャットのログ list _messageManagerList; public TCMessageManagerList() { _messageListType = -1; _layerName = ""; _messageManagerList = new list(); } // レイヤー名 public void SetLayerName(string layerName){ _layerName = layerName; } public string GetLayerName(){ return _layerName; } // リストの種別(全体/個人/システム通知) public void SetMessageListType(int messageListType){ _messageListType = messageListType; } public int GetMessageListType(){ return _messageListType; } // public int GetContentCount() { return _messageManagerList.Count(); } // 全部消す public void Clear() { for(int i = 0; i < _messageManagerList.Count(); i++) { _messageManagerList[i].Release(); } _messageManagerList.Clear(); } public void Update(){ TextAretaReize(hsCanvasIsPortrait()); } public void TextAretaReize(bool isPortrait){ bool isResized = false; for(int i = 0; i < _messageManagerList.Count(); i++){ bool isResize = _messageManagerList[i].TextAretaReize(isPortrait); if(isResize){ isResized = true; } } if(isResized){ RefreshSortID(); } } public void Add(TCMessageGUIManager guiManager) { // エモートの場合はメッセージに追加しない if(guiManager.GetMessageContentData().GetMessageTypeID() == TC_MESSAGE_TYPE_ID_EMOTE){ hsDispatchEvent("emoteIcon", guiManager.GetMessageContentData().GetEmoteImageURL()); return; } _messageManagerList.Add(guiManager); // メッセージが最大数よりも多い場合 if(_messageManagerList.Count() > MAX_MESSAGE_LOGSTOCK_SIZE){ //一番古いメッセージをリリースする _messageManagerList[0].Release(); _messageManagerList.RemoveAt(0); } NoticeBatch(guiManager); guiManager.CreateMessageGUI(_layerName); RefreshSortID(); } // public void RefreshSortID(){ TCMessageGUITransform anchorPos = new TCMessageGUITransform(); bool landscape = false; bool portrait = true; int laAncorPosX = 0; int laAncorPosY = 125; // WebXRモード中はアンカーを調整 if (hsSystemIsVRMode()) { laAncorPosX = 295; laAncorPosY = 190; } anchorPos.SetGUIAnchorPos(MakeHS2DI(laAncorPosX, laAncorPosY), landscape); anchorPos.SetGUIAnchorPos(MakeHS2DI(700, 450), portrait); if(_messageListType == TC_MESSAGELIST_TYPE_ID_SYSTEM){ anchorPos.SetGUIAnchorPos(MakeHS2DI(laAncorPosX, laAncorPosY + 85), landscape); anchorPos.SetGUIAnchorPos(MakeHS2DI(700, 625), portrait); } int guiListLastIndex = _messageManagerList.Count - 1; string Anchor = "RM"; if(hsSystemIsVRMode() || hsCanvasIsPortrait()) { Anchor = "CM"; } // 位置を更新 for(int i = guiListLastIndex; i >= 0; i--) { _messageManagerList[i].SetAnchor(Anchor); _messageManagerList[i].RefleshGUIPos(anchorPos.GetGUIAnchorPos(landscape), anchorPos.GetGUIAnchorPos(portrait)); anchorPos = _messageManagerList[i].GetPreMessageTransform(); } } private void NoticeBatch(TCMessageGUIManager guiManager){ // プライベートチャットの切り替えで再発火するので多重送信セーフティを用意。 if(guiManager.IsNotified()) { return; } TCModelCommon tcModelCommon; tcModelCommon = system.Layer_GetComponentByName("textchat_common"); // ワールド内のチャットバルーン表示設定 bool showChatBallonFlag = true; // 正常に処理されなかった場合はバッチ表示しない if(tcModelCommon.DoReceiveSharedProcess(guiManager, showChatBallonFlag) == false){ return; } guiManager.SetNotifiedFlag(true); // 自分が送ったメッセージの場合も表示しない if(guiManager.GetSelfMessageFlag()){ return; } // 送信タイプのセットアップ string chatTypeCode = CHAT_TYPE_PUBLIC; switch(_messageListType){ case TC_MESSAGELIST_TYPE_ID_GLOBAL: chatTypeCode = CHAT_TYPE_PUBLIC; break; case TC_MESSAGELIST_TYPE_ID_PRIVATE: chatTypeCode = CHAT_TYPE_PRIVATE; break; case TC_MESSAGELIST_TYPE_ID_SYSTEM: chatTypeCode = CHAT_TYPE_SYSTEM; break; default: chatTypeCode = CHAT_TYPE_PUBLIC; break; } TCViewModel _viewModel = system.Layer_GetComponentByName("textchat_common"); _viewModel.ShowBadge(chatTypeCode); } private HS2DI MakeHS2DI(int x, int y){ HS2DI hs2di = new HS2DI(); hs2di.SetXY(x, y); return hs2di; } }