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D,2BAAC;KAAA;kBA3EoB,oBAAoB","file":"","sourceRoot":"/","sourcesContent":["import { Presenter } from \"../../../common/classbase/PresenterBase\";\nimport { MessageView, MessageEntryItemProps, MessageViewType } from \"../view/type/MessageView\";\nimport { GameModelManager } from \"../../model/GameModelManager\";\nimport { ReadonlyPlot, SentenceType, SentenceTextContent, SentenceMediaContent } from \"../../../avg/model/PlotModel\";\nimport { DeepReadonly, shallowEqual } from \"simba-utils\";\nimport { richNodesToCocosString } from \"../../../avg/utils/RichTextUtils\";\nimport { UIManager } from \"../../../common/gameplay/managers/UIManager\";\nimport { ChatListViewPresenter } from \"./ChatListViewPresenter\";\nimport { RegPresenter } from \"../PresenterCCViewFactory\";\nimport { MessageSceneModel } from \"../../model/MessageSceneModel\";\nimport { PlotManager } from \"../../../avg/PlotManager\";\nimport { PlotSceneType } from \"../../Enums\";\nimport { PhoneCallViewPresenter } from \"./PhoneCallViewPresenter\";\n\nfunction getSentenceText(content: DeepReadonly<SentenceTextContent> | DeepReadonly<SentenceMediaContent>) {\n let text = \"\"\n switch (content.type) {\n case SentenceType.TEXT:\n text = richNodesToCocosString(content.value);\n break;\n case SentenceType.AUDIO:\n text = \"[Voice]\";\n break;\n case SentenceType.IMAGE:\n text = \"[Image]\";\n break;\n case SentenceType.VIDEO:\n text = \"[Video]\";\n break;\n }\n return text;\n}\n\nfunction getPlotString(plot?: ReadonlyPlot) {\n if (plot) {\n let text = \"\";\n let sentence:any = plot.sentences[0];\n if (sentence.content) {\n if (sentence.content.type === SentenceType.SELECT) {\n let select = PlotManager.getPlotSelection(plot.id);\n if (select !== undefined) {\n let option = sentence.content.value[select];\n if (option.content) {\n text = getSentenceText(option.content);\n } else {\n text = option.summary;\n }\n }\n } else {\n text = getSentenceText(sentence.content);\n }\n }\n return text;\n }\n return \"\";\n}\n\n@RegPresenter(MessageViewType)\nexport default class MessageViewPresenter extends Presenter<undefined, MessageView> {\n static uuid = \"MessageViewPresenter\";\n private _scenesActive: { [key: number]: boolean } = {};\n private _currPlotHasMsg = false;\n\n onOpen() {\n super.onOpen(undefined);\n this.checkScenesActive();\n this.setViewProps();\n this._disposable.add(GameModelManager.MessageSceneChanged.on(() => {\n if (!this._currPlotHasMsg && !this._view.isHidden && !this._isInBackground) {\n this.checkScenesActive();\n this.setViewProps();\n }\n }));\n this._disposable.add(PlotManager.PlotStartEvent.on(() => {\n if (this._currPlotHasMsg && !this._view.isHidden && !this._isInBackground) {\n this.checkScenesActive();\n this.setViewProps();\n }\n }));\n this.checkPhoneCall();\n }\n\n onShow() {\n super.onShow();\n this.checkScenesActive();\n this.setViewProps();\n this.checkPhoneCall();\n }\n\n checkPhoneCall() {\n if (PlotManager.getCurrentPlots()[0].plotSceneType === PlotSceneType.PhoneCall) {\n UIManager.pushPresenter(PhoneCallViewPresenter, undefined);\n }\n }\n\n onEnterForeground() {\n super.onEnterForeground();\n this.checkScenesActive();\n this.setViewProps();\n this.checkPhoneCall();\n }\n\n private checkScenesActive = () => {\n this._currPlotHasMsg = false;\n this._scenesActive = GameModelManager.getMessageScenesModel().reduce((pv, v) => (pv[v.id] = this.checkSceneActive(v), pv), {});\n }\n\n private checkSceneActive = (model: MessageSceneModel) => {\n let ret = PlotManager.getCurrentPlots().findIndex(v => v.plotSceneType === PlotSceneType.Message && v.plotSceneTypeId === model.id) >= 0;\n if (ret) this._currPlotHasMsg = true;\n return ret;\n }\n\n private setViewProps() {\n this._view.setProps({ // 暂每条只有一个头像,群聊显示单独头像,以后可能群聊显示多人头像\n items: GameModelManager.getMessageScenesModel().map(\n v => {\n return {\n key: v.id + \"\", icons: [GameModelManager.getRoleData(v.config.roles[0])!.getHeadIcon(true)],\n title: GameModelManager.getConfigLanguageTxt(v.config.title), lastMsg: getPlotString(v.lastPlot),\n redDot: this._scenesActive[v.id]\n }\n }),\n onItemClick: this.onItemClick\n });\n }\n\n private onItemClick = (key: string) => {\n console.log(\"item click\", key);\n let sceneModel = GameModelManager.getMessageSceneModel(parseInt(key));\n if (!sceneModel) { console.error(\"message scene model not found \", key); return; }\n UIManager.pushPresenter(ChatListViewPresenter, sceneModel);\n }\n}"]}