From c90e50eed9003297bfdcc45582fad733239e3ef3 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Tue, 18 Nov 2025 14:10:29 +0700 Subject: [PATCH] feat: add base uimanger and dlg manager. --- Assets/PerfectWorld/Scripts/UI/AUIManager.cs | 258 ++++++ .../Scripts/UI/AUIManager.cs.meta | 2 + .../Scripts/UI/Dialogs/AUIDialog.cs | 84 ++ .../Scripts/UI/Dialogs/AUIDialog.cs.meta | 2 + .../PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs | 830 ++++++++++++------ .../Scripts/UI/GamePlay/EC_GameUIMan.cs | 250 +----- Assets/Scripts/CECUIManager.cs | 10 +- 7 files changed, 912 insertions(+), 524 deletions(-) create mode 100644 Assets/PerfectWorld/Scripts/UI/AUIManager.cs create mode 100644 Assets/PerfectWorld/Scripts/UI/AUIManager.cs.meta create mode 100644 Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs create mode 100644 Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs.meta diff --git a/Assets/PerfectWorld/Scripts/UI/AUIManager.cs b/Assets/PerfectWorld/Scripts/UI/AUIManager.cs new file mode 100644 index 0000000000..f50a08f130 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/UI/AUIManager.cs @@ -0,0 +1,258 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEngine; + +namespace BrewMonster.UI +{ + public class AUIManager + { + protected DialogScriptTableObject m_dialogResouce; + protected Canvas m_canvas; + protected Dictionary m_StringTable = new Dictionary(); + protected Dictionary m_auiDialog_stringTable = new Dictionary(); + + public string GetStringFromTable(int idString) + { + if (m_StringTable.TryGetValue(idString, out var str)) + return str; + return null; + } + + + public string GetStringFromAuiDialogTable(int idString) + { + if (m_auiDialog_stringTable.TryGetValue(idString, out var str)) + return str; + return null; + } + + public void SetDependency(DialogScriptTableObject resouce, Canvas canvas) + { + m_dialogResouce = resouce; + m_canvas = canvas; + } + + public void Init() + { + ImportStringTable("ingame.stf"); + ImportAuiDialogStringTable("msgbox.stf"); + } + + public string Translate(ushort[] str) + { + if (str == null || str.Length == 0) + return null; + string m_AWString = ""; + string input = new string(str.Where(c => c != 0).Select(c => (char)c).ToArray()); + m_AWString = input; + + var result = new System.Text.StringBuilder(); + + int i = 0; + while (i < input.Length) + { + char c = input[i]; + + if (c != '\\') + { + result.Append(c); + i++; + continue; + } + + i++; + if (i >= input.Length) + break; + + char next = input[i]; + + switch (next) + { + case '\n': + i++; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + int value = 0; + int count = 3; + while (i < input.Length && input[i] >= '0' && input[i] <= '7' && count > 0) + { + count--; + value = value * 8 + (input[i] - '0'); + i++; + } + if (value <= 255) + result.Append((char)(value & 0xFF)); + break; + } + + case '"': + case '\'': + case '\\': + result.Append(next); + i++; + break; + + case 'n': + result.Append('\n'); + i++; + break; + case 'r': + result.Append('\r'); + i++; + break; + case 't': + result.Append('\t'); + i++; + break; + case 'v': + result.Append('\v'); + i++; + break; + + default: + i++; + break; + } + } + + m_AWString = result.ToString(); + return m_AWString; + } + + public bool ImportStringTable(string pszFilename) + { + //AWScriptFile s = new AWScriptFile(); + string szFilename = Path.Combine(Application.streamingAssetsPath, pszFilename); + + foreach (var line in File.ReadLines(szFilename)) + { + if (string.IsNullOrWhiteSpace(line)) + continue; + + var parts = line.Split('\t', StringSplitOptions.RemoveEmptyEntries); + if (parts.Length < 2) + continue; + + if (int.TryParse(parts[0], out int key)) + { + string value = parts[1].Trim(); + if (value.StartsWith("\"") && value.EndsWith("\"")) + value = value.Substring(1, value.Length - 2); + + m_StringTable[key] = value; + } + } + + return true; + //bool bval = s.Open(szFilename); + //if (!bval) return false; + + //while (!s.IsEnd()) + //{ + // bval = s.GetNextToken(true); + // if (!bval) break; // End of file. + // int idString = int.Parse(ByteToStringUtils.UshortArrayToUnicodeString(s.m_szToken)); + + // bval = s.GetNextToken(true); + // if (!bval) return false; + // string str = (Translate(s.m_szToken)); + // m_StringTable[idString] = str; + //} + //s.Close(); + + //if (a_stricmp(GetStringFromTable(1), _AL("")) == 0) //1 默认字体 + // m_StringTable[1] = _AL("方正细黑一简体"); + //m_strDefaultFontName = GetStringFromTable(1); + //if (a_stricmp(GetStringFromTable(2), _AL("")) == 0) //2 默认字体大小 + // m_StringTable[2] = _AL("10"); + //m_nDefaultFontSize = a_atoi(GetStringFromTable(2)); + //if (a_stricmp(GetStringFromTable(3), _AL("")) == 0) //3 符号 '\t' 相当于多少个 'W'的宽度 + // m_StringTable[3] = _AL("30"); + //_tab_char = a_atoi(GetStringFromTable(3)); + //if (a_stricmp(GetStringFromTable(4), _AL("")) == 0) //4 m_FontImagePicture 字体大小 + // m_StringTable[4] = m_StringTable[2]; + //if (a_stricmp(GetStringFromTable(5), _AL("")) == 0) //5 MessageBox 字体大小 + // m_StringTable[5] = m_StringTable[2]; + //if (a_stricmp(GetStringFromTable(6), _AL("")) == 0) //6 MessageBox shadow + // m_StringTable[6] = _AL("0"); + //if (a_stricmp(GetStringFromTable(7), _AL("")) == 0) //7 MessageBox outline + // m_StringTable[7] = _AL("0"); + //if (a_stricmp(GetStringFromTable(8), _AL("")) == 0) //8 MessageBox outline color + // m_StringTable[8] = _AL("0"); + + //m_FontHint.szFontName = GetStringFromTable(1); + //m_FontHint.nFontSize = a_atoi(GetStringFromTable(2)); + //m_FontImagePicture.szFontName = GetStringFromTable(1); + //m_FontImagePicture.nFontSize = a_atoi(GetStringFromTable(4)); + //m_FontImagePicture.nOutline = 1; + //m_FontMessageBox.szFontName = GetStringFromTable(1); + //m_FontMessageBox.nFontSize = a_atoi(GetStringFromTable(5)); + //m_FontMessageBox.nShadow = a_atoi(GetStringFromTable(6)); + //m_FontMessageBox.nOutline = a_atoi(GetStringFromTable(7)); + //return true; + } + + public bool ImportAuiDialogStringTable(string pszFilename) + { + + //bool bval; + //int idString; + //string str; + //AWScriptFile s = new AWScriptFile(); + string szFilename = Path.Combine(Application.streamingAssetsPath, pszFilename); + //bval = s.Open(szFilename); + //if (!bval) return true; // Ignore error. + //while (!s.IsEnd()) + //{ + // bval = s.GetNextToken(true); + // if (!bval) break; // End of file. + // idString = int.Parse(ByteToStringUtils.UshortArrayToUnicodeString(s.m_szToken)); + + // bval = s.GetNextToken(true); + // if (!bval) return false; + + // str = ByteToStringUtils.UshortArrayToUnicodeString(s.m_szToken); + // if(m_auiDialog_stringTable.TryGetValue(idString, out string value)) + // { + // m_auiDialog_stringTable[idString] = str; + // } + // else + // { + // m_auiDialog_stringTable.Add(idString, str); + // } + //} + + //s.Close(); + foreach (var line in File.ReadLines(szFilename)) + { + if (string.IsNullOrWhiteSpace(line)) + continue; + + var parts = line.Split('\t', StringSplitOptions.RemoveEmptyEntries); + if (parts.Length < 2) + continue; + + if (int.TryParse(parts[0], out int key)) + { + string value = parts[1].Trim(); + if (value.StartsWith("\"") && value.EndsWith("\"")) + value = value.Substring(1, value.Length - 2); + + m_auiDialog_stringTable[key] = value; + } + } + return true; + } + } +} diff --git a/Assets/PerfectWorld/Scripts/UI/AUIManager.cs.meta b/Assets/PerfectWorld/Scripts/UI/AUIManager.cs.meta new file mode 100644 index 0000000000..f2d9e01663 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/UI/AUIManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c2c1d56888edf9142b5d12309b832bba \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs new file mode 100644 index 0000000000..0c6c9146b6 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs @@ -0,0 +1,84 @@ +using BrewMonster.Network; +using System.Collections.Generic; +using UnityEngine; + +namespace BrewMonster.UI +{ + public abstract class AUIDialog : MonoBehaviour + { + protected Dictionary m_StringTable = new Dictionary(); + protected bool m_bShow = false; + protected string m_strDataName = ""; + protected string m_strDataPtrName = ""; + protected uint m_dwData; + protected object m_pvData; + protected AUIManager m_pAUIManager = null; + + public virtual void Show(bool value) + { + gameObject.SetActive(value); + } + + public void SetData(uint dwData, string strName) + { + m_strDataName = strName; + m_dwData = dwData; + } + + public uint GetData() + { + return m_dwData; + } + + public object GetDataPtr(string strName) + { + //if (0 != m_pvData && strName != m_strDataPtrName) + // AUI_ReportError(__LINE__, 1, "AUIDialog::GetDataPtr(), data name not match"); + return m_pvData; + } + + public bool IsShow() + { + return m_bShow; + } + + public void SetDataPtr(object pvData, string strName) + { + m_strDataPtrName = strName; + m_pvData = pvData; + } + + + public CECGameUIMan GetGameUIMan() + { + return EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + } + + public CECHostPlayer GetHostPlayer() + { + return EC_Game.GetGameRun().GetHostPlayer(); + } + + public string GetStringFromTable(int idString) + { + CECGameUIMan gameUIMan = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + string str = gameUIMan.GetStringFromAuiDialogTable(idString); + if (str == null) + { + return gameUIMan.GetStringFromTable(idString); + } + return str; + } + + + public AUIManager GetAUIManager() + { + return m_pAUIManager; + } + + public void SetAUIManager(AUIManager pAUIManager) + { + m_pAUIManager = pAUIManager; + } + } +} diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs.meta b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs.meta new file mode 100644 index 0000000000..d052134434 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 923726bcb1a5625448a832da43198b7e \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs index 153ed5311a..8816e48fca 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs @@ -8,16 +8,18 @@ using CSNetwork.GPDataType; using ModelRenderer.Scripts.Common; using ModelRenderer.Scripts.GameData; using System; +using System.Drawing; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using TMPro; using UnityEngine; +using UnityEngine.UI; using static CSNetwork.Common.ExpTypes; namespace BrewMonster.UI { - public class DlgNPC : MonoBehaviour + public class DlgNPC : AUIDialog { [SerializeField] private TextMeshProUGUI m_pTxt_npc; [SerializeField] private TextMeshProUGUI m_pTxt_Content; @@ -26,11 +28,6 @@ namespace BrewMonster.UI int m_iTracedTaskID; int m_iTracedTaskNPCID; CECTimeSafeChecker m_tracedTaskTimer; - bool m_bShow = false; - string m_strDataName = ""; - string m_strDataPtrName = ""; - uint m_dwData; - object m_pvData; bool HasTracedTask() { @@ -128,23 +125,23 @@ namespace BrewMonster.UI bool PopupTracedTaskDialog(NPC_ESSENCE pEssence) { PopupNPCDialog(pEssence); - //if (GetData() == NPC_DIALOG.NPC_DIALOG_ESSENCE) - //{ - // for (int i = 0; i < m_pLst_Main.GetCount() - 1; ++i) - // { - // object pData = m_pLst_Main.GetItemDataPtr(i, 0, ""); - // uint iService = m_pLst_Main.GetItemData(i, 0, ""); - // DATA_TYPE DataType = DATA_TYPE.DT_INVALID; - // EC_Game.GetElementDataMan().get_data_ptr(iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); - // if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE || - // DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE || - // DataType == DATA_TYPE.DT_NPC_TASK_MATTER_SERVICE) - // { - // SelectListItem(i); - // break; - // } - // } - //} + if (GetData() == NPC_DIALOG.NPC_DIALOG_ESSENCE) + { + for (int i = 0; i < m_pLst_Main.GetCount() - 1; ++i) + { + object pData = m_pLst_Main.GetItemDataPtr(i, 0, ""); + uint iService = m_pLst_Main.GetItemData(i, 0, ""); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + EC_Game.GetElementDataMan().get_data_ptr(iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + if (DataType == DATA_TYPE.DT_NPC_TASK_IN_SERVICE || + DataType == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE || + DataType == DATA_TYPE.DT_NPC_TASK_MATTER_SERVICE) + { + SelectListItem(i); + break; + } + } + } //if (GetData() == NPC_DIALOG.NPC_DIALOG_TASK_LIST) //{ // for (int i = 0; i < m_pLst_Main.GetCount() - 1; ++i) @@ -199,30 +196,11 @@ namespace BrewMonster.UI } } - private string GetStringFromTable(int idString) - { - CECGameUIMan gameUIMan = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); - string str = gameUIMan.GetStringFromAuiDialogTable(idString); - if(str == null) - { - return gameUIMan.GetStringFromTable(idString); - } - return str; - } - private void Show(bool value) - { - } - - private CECGameUIMan GetGameUIMan() + public override void Show(bool value) { - return EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); - } - - private CECHostPlayer GetHostPlayer() - { - return EC_ManMessageMono.Instance.EC_ManPlayer.GetHostPlayer(); + base.Show(value); } void PopupNPCDialog(NPC_ESSENCE pEssence) @@ -1105,251 +1083,222 @@ namespace BrewMonster.UI void PopupTaskDialog(bool bTaskNPC) { - NPC_ESSENCE pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; - NPC_ESSENCE pEssence = pCurNPCEssence; - //if (!pEssence) return; + //NPC_ESSENCE pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + //NPC_ESSENCE pEssence = pCurNPCEssence; + ////if (!pEssence) return; - int i, j, idTask; - object pData; - DATA_TYPE DataType = new DATA_TYPE(); - unsigned int* a_idTask; - uint[] a_uiService = - { - pEssence.id_task_out_service, // 任务相关的服务ID: 发放任务服务 - pEssence.id_task_in_service, // 任务相关的服务ID: 验证完成任务服务 - pEssence.id_task_matter_service // 任务相关的服务ID: 发放任务物品服务 - }; - int idLastTask = 0, nLastTaskTime = 0, nFinishTime; - elementdataman pDataMan = EC_Game.GetElementDataMan(); - abase::vector taskIn, taskOut, taskMatter; - CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); + //int i, j, idTask; + //object pData; + //DATA_TYPE DataType = new DATA_TYPE(); + //unsigned int* a_idTask; + //uint[] a_uiService = + //{ + // pEssence.id_task_out_service, // 任务相关的服务ID: 发放任务服务 + // pEssence.id_task_in_service, // 任务相关的服务ID: 验证完成任务服务 + // pEssence.id_task_matter_service // 任务相关的服务ID: 发放任务物品服务 + // }; + //int idLastTask = 0, nLastTaskTime = 0, nFinishTime; + //elementdataman pDataMan = EC_Game.GetElementDataMan(); + //abase::vector taskIn, taskOut, taskMatter; + //CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); - for (i = 0; i < sizeof(a_uiService) / sizeof(unsigned int) ; i++ ) - { - pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE_ESSENCE, DataType); + //for (i = 0; i < sizeof(a_uiService) / sizeof(unsigned int) ; i++ ) + //{ + // pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE_ESSENCE, DataType); - if (DataType == DT_NPC_TASK_IN_SERVICE || - DataType == DT_NPC_TASK_OUT_SERVICE) - { - int total_count = 0; + // if (DataType == DT_NPC_TASK_IN_SERVICE || + // DataType == DT_NPC_TASK_OUT_SERVICE) + // { + // int total_count = 0; - if (DataType == DT_NPC_TASK_IN_SERVICE) - { - NPC_TASK_IN_SERVICE* pService = (NPC_TASK_IN_SERVICE*)pData; - a_idTask = pService.id_tasks; - total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); - } - else - { - NPC_TASK_OUT_SERVICE* pService = (NPC_TASK_OUT_SERVICE*)pData; + // if (DataType == DT_NPC_TASK_IN_SERVICE) + // { + // NPC_TASK_IN_SERVICE* pService = (NPC_TASK_IN_SERVICE*)pData; + // a_idTask = pService.id_tasks; + // total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); + // } + // else + // { + // NPC_TASK_OUT_SERVICE* pService = (NPC_TASK_OUT_SERVICE*)pData; - // if storage task not exists - if (pService.storage_id == 0 || pService.storage_open_item == 0) - { - a_idTask = pService.id_tasks; - total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); - } - } + // // if storage task not exists + // if (pService.storage_id == 0 || pService.storage_open_item == 0) + // { + // a_idTask = pService.id_tasks; + // total_count = sizeof(pService.id_tasks) / sizeof(pService.id_tasks[0]); + // } + // } - for (j = 0; j < total_count; j++) - { - idTask = a_idTask[j]; - if (idTask <= 0) continue; + // for (j = 0; j < total_count; j++) + // { + // idTask = a_idTask[j]; + // if (idTask <= 0) continue; - if (DataType == DT_NPC_TASK_IN_SERVICE) - taskIn.push_back(TASK_ITEM(idTask, a_uiService[i])); - else - taskOut.push_back(TASK_ITEM(idTask, a_uiService[i])); + // if (DataType == DT_NPC_TASK_IN_SERVICE) + // taskIn.push_back(TASK_ITEM(idTask, a_uiService[i])); + // else + // taskOut.push_back(TASK_ITEM(idTask, a_uiService[i])); - nFinishTime = (int)pTask.GetTaskFinishedTime(idTask); - if (nFinishTime > nLastTaskTime) - { - idLastTask = idTask; - nLastTaskTime = nFinishTime; - } - } - } - else if (DataType == DT_NPC_TASK_MATTER_SERVICE) - { - NPC_TASK_MATTER_SERVICE* pService = (NPC_TASK_MATTER_SERVICE*)pData; + // nFinishTime = (int)pTask.GetTaskFinishedTime(idTask); + // if (nFinishTime > nLastTaskTime) + // { + // idLastTask = idTask; + // nLastTaskTime = nFinishTime; + // } + // } + // } + // else if (DataType == DT_NPC_TASK_MATTER_SERVICE) + // { + // NPC_TASK_MATTER_SERVICE* pService = (NPC_TASK_MATTER_SERVICE*)pData; - for (j = 0; j < 16; j++) - { - idTask = pService.tasks[j].id_task; - if (idTask > 0) - { - taskMatter.push_back(TASK_ITEM(idTask, a_uiService[i])); - } - } - } - } + // for (j = 0; j < 16; j++) + // { + // idTask = pService.tasks[j].id_task; + // if (idTask > 0) + // { + // taskMatter.push_back(TASK_ITEM(idTask, a_uiService[i])); + // } + // } + // } + //} - A3DCOLOR color; - string strText; - const talk_proc* pTalk; - ATaskTempl* pTemp, *pTempRoot; - int nIndex, nNumTasks = 0; - int nHostLevel = GetHostPlayer().GetBasicProps().iLevel; - ATaskTemplMan* pTempMan = g_pGame.GetTaskTemplateMan(); + //A3DCOLOR color; + //string strText; + //const talk_proc* pTalk; + //ATaskTempl* pTemp, *pTempRoot; + //int nIndex, nNumTasks = 0; + //int nHostLevel = GetHostPlayer().GetBasicProps().iLevel; + //ATaskTemplMan* pTempMan = g_pGame.GetTaskTemplateMan(); - m_pLst_Main.ResetContent(); - abase::vector* a_uiTasks[] = { &taskIn, &taskOut, &taskMatter }; - for (int idx = 0; idx < sizeof(a_uiTasks) / sizeof(a_uiTasks[0]); idx++) - { - abase::vector::iterator it; - for (it = a_uiTasks[idx].begin(); it != a_uiTasks[idx].end(); ++it) - { - idTask = it.task_id; + //m_pLst_Main.ResetContent(); + //abase::vector* a_uiTasks[] = { &taskIn, &taskOut, &taskMatter }; + //for (int idx = 0; idx < sizeof(a_uiTasks) / sizeof(a_uiTasks[0]); idx++) + //{ + // abase::vector::iterator it; + // for (it = a_uiTasks[idx].begin(); it != a_uiTasks[idx].end(); ++it) + // { + // idTask = it.task_id; - color = 0; - bool bNeedSetSpecialColor = false; - pTemp = NULL; - pTalk = NULL; - color = m_pLst_Main.GetColor(); - strText = GetStringFromTable(249); + // color = 0; + // bool bNeedSetSpecialColor = false; + // pTemp = NULL; + // pTalk = NULL; + // color = m_pLst_Main.GetColor(); + // strText = GetStringFromTable(249); - if (idx == 1) - { - if (pTask.HasTask(idTask)) - { - if (!pTask.CanFinishTask(idTask)) - { - pTemp = pTempMan.GetTaskTemplByID(idTask); - pTalk = pTemp.GetUnfinishedTalk(); - } - } - else if (pTask.CanShowTask(idTask)) - { - pTemp = pTempMan.GetTaskTemplByID(idTask); + // if (idx == 1) + // { + // if (pTask.HasTask(idTask)) + // { + // if (!pTask.CanFinishTask(idTask)) + // { + // pTemp = pTempMan.GetTaskTemplByID(idTask); + // pTalk = pTemp.GetUnfinishedTalk(); + // } + // } + // else if (pTask.CanShowTask(idTask)) + // { + // pTemp = pTempMan.GetTaskTemplByID(idTask); - if (0 == pTask.CanDeliverTask(idTask)) - pTalk = pTemp.GetDeliverTaskTalk(); - else - { - pTalk = pTemp.GetUnqualifiedTalk(); - color = A3DCOLORRGB(128, 128, 128); - bNeedSetSpecialColor = true; - } - } - } + // if (0 == pTask.CanDeliverTask(idTask)) + // pTalk = pTemp.GetDeliverTaskTalk(); + // else + // { + // pTalk = pTemp.GetUnqualifiedTalk(); + // color = A3DCOLORRGB(128, 128, 128); + // bNeedSetSpecialColor = true; + // } + // } + // } - if (idx == 0 && pTask.HasTask(idTask) - && pTask.CanFinishTask(idTask) && !pTalk) - { - pTemp = pTempMan.GetTaskTemplByID(idTask); - pTalk = pTemp.GetAwardTalk(); - strText = GetStringFromTable(302); - } + // if (idx == 0 && pTask.HasTask(idTask) + // && pTask.CanFinishTask(idTask) && !pTalk) + // { + // pTemp = pTempMan.GetTaskTemplByID(idTask); + // pTalk = pTemp.GetAwardTalk(); + // strText = GetStringFromTable(302); + // } - if (pTemp && pTalk && (pTalk.num_window > 1 || pTalk.num_window == 1 && wcslen(pTalk.windows[0].talk_text))) - { - if (pTemp.IsKeyTask()) - { - color = A3DCOLORRGB(255, 162, 0); - bNeedSetSpecialColor = true; - } - else if (color != 0) - { - // 去掉根据人物和任务级别差来改变颜色的逻辑 - /* - nLevel = pTemp.GetSuitableLevel(); - if( nHostLevel <= nLevel - 2 ) - color = A3DCOLORRGB(255, 54, 0); - else if( nHostLevel >= nLevel + 3 ) - color = A3DCOLORRGB(22, 142, 54); - */ - } + // if (pTemp && pTalk && (pTalk.num_window > 1 || pTalk.num_window == 1 && wcslen(pTalk.windows[0].talk_text))) + // { + // if (pTemp.IsKeyTask()) + // { + // color = A3DCOLORRGB(255, 162, 0); + // bNeedSetSpecialColor = true; + // } + // else if (color != 0) + // { + // // 去掉根据人物和任务级别差来改变颜色的逻辑 + // /* + // nLevel = pTemp.GetSuitableLevel(); + // if( nHostLevel <= nLevel - 2 ) + // color = A3DCOLORRGB(255, 54, 0); + // else if( nHostLevel >= nLevel + 3 ) + // color = A3DCOLORRGB(22, 142, 54); + // */ + // } - pTempRoot = (ATaskTempl*)pTemp.GetTopTask(); - if (pTemp != pTempRoot) - { - if (bNeedSetSpecialColor) - { - strText += CDlgTask::GetTaskNameWithOutColor(pTempRoot); - } - else - { - strText += CDlgTask::GetTaskNameWithColor(pTempRoot); - } - strText += _AL(" - "); - } - if (bNeedSetSpecialColor) - { - strText += CDlgTask::GetTaskNameWithOutColor(pTemp); - } - else - { - strText += CDlgTask::GetTaskNameWithColor(pTemp); - } - m_pLst_Main.AddString(strText); - nIndex = m_pLst_Main.GetCount() - 1; - m_pLst_Main.SetItemData(nIndex, it.service); // Service ID. - m_pLst_Main.SetItemDataPtr(nIndex, (void*)pTalk); // Talk data. - m_pLst_Main.SetItemData64(nIndex, pTemp.GetID(), 0, "TaskID"); + // pTempRoot = (ATaskTempl*)pTemp.GetTopTask(); + // if (pTemp != pTempRoot) + // { + // if (bNeedSetSpecialColor) + // { + // strText += CDlgTask::GetTaskNameWithOutColor(pTempRoot); + // } + // else + // { + // strText += CDlgTask::GetTaskNameWithColor(pTempRoot); + // } + // strText += _AL(" - "); + // } + // if (bNeedSetSpecialColor) + // { + // strText += CDlgTask::GetTaskNameWithOutColor(pTemp); + // } + // else + // { + // strText += CDlgTask::GetTaskNameWithColor(pTemp); + // } + // m_pLst_Main.AddString(strText); + // nIndex = m_pLst_Main.GetCount() - 1; + // m_pLst_Main.SetItemData(nIndex, it.service); // Service ID. + // m_pLst_Main.SetItemDataPtr(nIndex, (void*)pTalk); // Talk data. + // m_pLst_Main.SetItemData64(nIndex, pTemp.GetID(), 0, "TaskID"); - if (bNeedSetSpecialColor) - { - m_pLst_Main.SetItemTextColor(nIndex, color); - } - nNumTasks++; - } - } - } + // if (bNeedSetSpecialColor) + // { + // m_pLst_Main.SetItemTextColor(nIndex, color); + // } + // nNumTasks++; + // } + // } + //} - if (idLastTask > 0) - { - pTemp = pTempMan.GetTaskTemplByID(idLastTask); - if (a_strlen(pTemp.GetTribute()) > 0) - m_pTxt_Content.SetText(pTemp.GetTribute()); - else - { - if (nNumTasks > 0) - m_pTxt_Content.SetText(GetStringFromTable(502)); - else - m_pTxt_Content.SetText(GetStringFromTable(501)); - } - } - else if (bTaskNPC) - m_pTxt_Content.SetText(pCurNPCEssence.hello_msg); - else - { - if (nNumTasks > 0) - m_pTxt_Content.SetText(GetStringFromTable(502)); - else - m_pTxt_Content.SetText(GetStringFromTable(501)); - } + //if (idLastTask > 0) + //{ + // pTemp = pTempMan.GetTaskTemplByID(idLastTask); + // if (a_strlen(pTemp.GetTribute()) > 0) + // m_pTxt_Content.SetText(pTemp.GetTribute()); + // else + // { + // if (nNumTasks > 0) + // m_pTxt_Content.SetText(GetStringFromTable(502)); + // else + // m_pTxt_Content.SetText(GetStringFromTable(501)); + // } + //} + //else if (bTaskNPC) + // m_pTxt_Content.SetText(pCurNPCEssence.hello_msg); + //else + //{ + // if (nNumTasks > 0) + // m_pTxt_Content.SetText(GetStringFromTable(502)); + // else + // m_pTxt_Content.SetText(GetStringFromTable(501)); + //} - SetData(NPC_DIALOG_TASK_LIST); - } - - void SetData(uint dwData, string strName) - { - m_strDataName = strName; - m_dwData = dwData; - } - - uint GetData() - { - return m_dwData; - } - - object GetDataPtr(string strName) - { - //if (0 != m_pvData && strName != m_strDataPtrName) - // AUI_ReportError(__LINE__, 1, "AUIDialog::GetDataPtr(), data name not match"); - return m_pvData; - } - - bool IsShow() - { - return m_bShow; - } - - void SetDataPtr(object pvData, string strName) - { - m_strDataPtrName = strName; - m_pvData = pvData; + //SetData(NPC_DIALOG_TASK_LIST); } public void PopupNPCDialog(talk_proc pTalk) @@ -1379,6 +1328,341 @@ namespace BrewMonster.UI if (!IsShow()) Show(true); } + bool PopupCorrespondingServiceDialog(int idFunction, int iService, object pData) + { + //AUIDialog pShow1 = null, pShow2 = null; + //NPC_ESSENCE? pCurNPCEssence = GetGameUIMan().m_pCurNPCEssence; + + //if (idFunction == (int)SERVICE_TYPE.NPC_SELL || idFunction == (int)SERVICE_TYPE.NPC_BUY) + //{ + // Button pButton; + + // pShow1 = m_pAUIManager.GetDialog("Win_Shop"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + + // GetHostPlayer().PrepareNPCService(iService); + // GetGameUIMan().m_pDlgShop.UpdateShop(1); + + // if (pCurNPCEssence && pCurNPCEssence.id_repair_service) + // { + // pShow1.GetDlgItem("Btn_Repair").Show(true); + // pShow1.GetDlgItem("Btn_RepairAll").Show(true); + // } + // else + // { + // pShow1.GetDlgItem("Btn_Repair").Show(false); + // pShow1.GetDlgItem("Btn_RepairAll").Show(false); + // } + + // pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_NormalItem"); + // pButton.SetPushed(true); + // pButton = (PAUISTILLIMAGEBUTTON)pShow2.GetDlgItem("Btn_QuestItem"); + // pButton.SetPushed(false); + // GetGameUIMan().m_pDlgInventory.SetShowItem(CDlgInventory::INVENTORY_ITEM_NORMAL); + //} + //else if (idFunction == NPC_INSTALL) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Enchase"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //} + //else if (idFunction == NPC_UNINSTALL) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Disenchase"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //} + //else if (idFunction == NPC_HEAL) + //{ + // GetGameSession().c2s_CmdNPCSevHeal(); + // GetGameUIMan().EndNPCService(); + //} + //else if (idFunction == NPC_TRANSMIT) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_WorldMapTravel"); + // ((CDlgWorldMap*)pShow1).BuildTravelMap(DT_NPC_TRANSMIT_SERVICE, pData); + //} + //else if (idFunction == NPC_SKILL) + //{ + // string strText = m_pLst_Main.GetText(m_pLst_Main.GetCurSel()); + // string strHead = GetStringFromTable(249); + // string strComp = string(strHead + GetStringFromTable(7107)); + // if (0 == a_stricmp(strText, strComp)) + // { + // pShow1 = m_pAUIManager.GetDialog("Win_ELFLearn"); + // ((CDlgELFLearn*)pShow1).SetNPCName(pCurNPCEssence.name); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DT_NPC_SKILL_SERVICE); + // } + // else + // { + // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DT_NPC_SKILL_SERVICE); + // GetGameUIMan().UpdateTeach(0); + // } + //} + //else if (idFunction == NPC_MAKE) + //{ + // NPC_MAKE_SERVICE* pMake = (NPC_MAKE_SERVICE*)pData; + // if (pMake.produce_type == 2) + // pShow1 = m_pAUIManager.GetDialog("Win_Produce1"); + // else + // pShow1 = m_pAUIManager.GetDialog("Win_Produce"); + // GetGameUIMan().m_pDlgProduce = (CDlgProduce*)pShow1; + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetDataPtr(pMake, "ptr_NPC_MAKE_SERVICE"); + // if (pMake.produce_type == 1 || + // pMake.produce_type == 3 || + // pMake.produce_type == 4 || + // pMake.produce_type == 5) + // GetGameUIMan().m_pDlgProduce.ClearMaterial(); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // GetGameUIMan().m_pDlgProduce.UpdateProduce(1, 0); + //} + //else if (idFunction == NPC_DECOMPOSE) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Split"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // pShow1.SetDataPtr(pData, "ptr_NPC_DECOMPOSE_SERVICE"); + + // PAUIPROGRESS pProgress; + // PAUIIMAGEPICTURE pImage; + + // pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_a"); + // pImage.ClearCover(); + // pImage.SetDataPtr(NULL); + + // pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item_b"); + // pImage.ClearCover(); + // pImage.SetDataPtr(NULL); + + // pProgress = (PAUIPROGRESS)pShow1.GetDlgItem("Prgs_1"); + // pProgress.SetProgress(0); + + // pShow1.GetDlgItem("Btn_Start").Enable(false); + // pShow1.GetDlgItem("Btn_Cancel").Enable(true); + // pShow1.GetDlgItem("Txt_no1").SetText(_AL("")); + // pShow1.GetDlgItem("Txt_no2").SetText(_AL("")); + // pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); + // pShow1.GetDlgItem("Txt_SkillName").SetText(_AL("")); + // pShow1.GetDlgItem("Txt_SkillLevel").SetText(_AL("")); + //} + //else if (idFunction == NPC_WAR_TOWERBUILD) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_WarTower"); + //} + //else if (idFunction == NPC_RESETPROP) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_ResetProp"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //} + //else if (idFunction == NPC_PETNAME) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_PetRename"); + // pShow2 = m_pAUIManager.GetDialog("Win_PetList"); + //} + //else if (idFunction == NPC_PETLEARNSKILL) + //{ + // CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); + // CECPetData* pPet = pPetCorral.GetActivePet(); + // if (!pPet) + // { + // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); + // GetGameUIMan().EndNPCService(); + // } + // else + // { + // pShow1 = m_pAUIManager.GetDialog("Win_Teach"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetData(DT_NPC_PETLEARNSKILL_SERVICE); + // GetGameUIMan().UpdateTeach(0); + // } + //} + //else if (idFunction == NPC_PETFORGETSKILL) + //{ + // CECPetCorral* pPetCorral = GetHostPlayer().GetPetCorral(); + // CECPetData* pPet = pPetCorral.GetActivePet(); + // if (!pPet) + // { + // GetGameUIMan().MessageBox("", GetStringFromTable(814), MB_OK, A3DCOLORRGB(255, 255, 255)); + // GetGameUIMan().EndNPCService(); + // } + // else + // pShow1 = m_pAUIManager.GetDialog("Win_PetRetrain"); + //} + //else if (idFunction == NPC_EQUIPBIND) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_EquipBind"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // pShow1.SetData((DWORD)pData, "ptr_NPC_EQUIPBIND_SERVICE"); + //} + //else if (idFunction == NPC_EQUIPDESTROY) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_EquipDestroy"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //} + //else if (idFunction == NPC_EQUIPUNDESTROY) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_EquipUndestroy"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //} + //else if (idFunction == NPC_IDENTIFY) + //{ + // PAUIIMAGEPICTURE pImage; + + // pShow1 = m_pAUIManager.GetDialog("Win_Identify"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // pShow1.SetDataPtr(pData, "ptr_NPC_IDENTIFY_SERVICE"); + + // pImage = (PAUIIMAGEPICTURE)pShow1.GetDlgItem("Item"); + // pImage.ClearCover(); + // pImage.SetDataPtr(NULL); + + // pShow1.GetDlgItem("Txt").SetText(_AL("")); + // pShow1.GetDlgItem("Txt_Gold").SetText(_AL("")); + // pShow1.GetDlgItem("Btn_Confirm").Enable(false); + // pShow1.GetDlgItem("Btn_Cancel").Enable(true); + //} + //else if (idFunction == NPC_GIVE_TASK) + //{ + // talk_proc::option* opt = (talk_proc::option*)pData; + // int idTask = opt.param; + // if (g_pGame.GetConfigs().IsMiniClient() && CECUIConfig::Instance().GetGameUI().IsTaskDisabledInMiniClient(idTask)) + // { + // GetGameUIMan().MessageBox("", GetStringFromTable(10714), MB_OK, A3DCOLORRGBA(255, 255, 255, 160)); + // } + // else + // { + // GetGameSession().c2s_CmdNPCSevAcceptTask(idTask, 0, 0); + // } + // GetGameUIMan().EndNPCService(); + //} + //else if (idFunction == NPC_COMPLETE_TASK) + //{ + // AWARD_DATA ad; + // talk_proc::option* opt = (talk_proc::option*)pData; + // CECTaskInterface* pTask = GetHostPlayer().GetTaskInterface(); + + // pTask.GetAwardCandidates(opt.param, &ad); + // if (ad.m_ulCandItems > 1) + // { + // pShow1 = m_pAUIManager.GetDialog("Win_Award"); + // CDlgAward* pAward = dynamic_cast(pShow1); + // if (pAward) pAward.UpdateAwardItem(opt.param, true); + // } + // else + // { + // GetGameSession().c2s_CmdNPCSevReturnTask(opt.param, 0); + // GetGameUIMan().EndNPCService(); + // } + //} + //else if (idFunction == NPC_GIVE_TASK_MATTER) + //{ + // talk_proc::option* opt = (talk_proc::option*)pData; + // GetGameSession().c2s_CmdNPCSevTaskMatter(opt.param); + // GetGameUIMan().EndNPCService(); + //} + //else if (idFunction == NPC_STORAGE) + //{ + // if (GetHostPlayer().TrashBoxHasPsw()) + // { + // pShow1 = m_pAUIManager.GetDialog("Win_InputString"); + // pShow1.GetDlgItem("DEFAULT_Txt_Input").SetText(_AL("")); + // } + // else + // g_pGame.GetGameSession().c2s_CmdNPCSevOpenTrash(""); + //} + //else if (idFunction == NPC_STORAGE_PASSWORD) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_InputString3"); + //} + //else if (idFunction == NPC_ACCOUNT_STORAGE) + //{ + // if (CECCrossServer::Instance().IsOnSpecialServer()) + // { + // GetGameUIMan().ShowErrorMsg(10130); + // GetGameUIMan().EndNPCService(); + // } + // else g_pGame.GetGameSession().c2s_CmdNPCSevOpenAccountBox(); + //} + //else if (idFunction == NPC_ENGRAVE) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_Engrave"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + //} + //else if (idFunction == NPC_RANDPROP) + //{ + // pShow1 = m_pAUIManager.GetDialog("Win_RandProp"); + // pShow2 = m_pAUIManager.GetDialog("Win_Inventory"); + // GetHostPlayer().PrepareNPCService(iService); + // pShow1.SetDataPtr(pData, "ptr_NPC_RANDPROP_SERVICE"); + //} + //else if (idFunction == TALK_RETURN) + //{ + // OnCommand_back("back"); + // return true; // To avoid to close NPC dialog. + //} + //else if (idFunction == TALK_EXIT) + //{ + // GetGameUIMan().EndNPCService(); + + // int idCurFinishTask = GetGameUIMan().m_idCurFinishTask; + // if (GetData() == CDlgNPC::NPC_DIALOG_TASK_TALK && idCurFinishTask > 0) + // { + // GetHostPlayer().GetTaskInterface().OnUIDialogEnd(idCurFinishTask); + // GetGameUIMan().m_idCurFinishTask = -1; + // } + //} + //else if (idFunction == TALK_GIVEUP_TASK) + //{ + // talk_proc::option* opt = (talk_proc::option*)pData; + // GetHostPlayer().GetTaskInterface().GiveUpTask(opt.param); + // GetGameUIMan().EndNPCService(); + //} + //else + //{ + // GetHostPlayer().GetPack(IVTRTYPE_PACK).UnfreezeAllItems(); + // GetGameUIMan().EndNPCService(); + //} + + //if (pShow1) + //{ + // DATA_TYPE DataType; + // elementdataman* pDataMan = g_pGame.GetElementDataMan(); + + // pDataMan.get_data_ptr(iService, ID_SPACE_ESSENCE, DataType); + + // pShow1.Show(true); + + // if (pShow2) + // { + // POINT ptPos = pShow1.GetPos(); + // if (ptPos.x == 0 && ptPos.y == 0) + // { + // SIZE s1 = pShow1.GetSize(); + // SIZE s2 = pShow2.GetSize(); + // A3DVIEWPORTPARAM* p = m_pA3DEngine.GetActiveViewport().GetParam(); + // int x, y = (p.Height - max(s1.cy, s2.cy)) / 2; + + // x = (p.Width - s1.cx - s2.cx) / 2; + + // // old : pShow1.SetPos(x, y); + // pShow1.SetPosEx(x, y); + + // x += s1.cx; + + // // old : pShow2.SetPos(x, y); + // pShow2.SetPosEx(x, y); + // } + + // pShow2.Show(true); + // } + //} + Show(false); + + return true; + } + void SelectListItem(int index) { m_pLst_Main.SetCurSel(index); @@ -1446,15 +1730,15 @@ namespace BrewMonster.UI }; //TO DO: fix later // This show popup service NPC - PopupCorrespondingServiceDialog(id, - a_uiService[nIndex], m_pLst_Main.GetItemDataPtr(nCurSel)); + PopupCorrespondingServiceDialog((int)id, + (int)a_uiService[nIndex1], m_pLst_Main.GetItemDataPtr(nCurSel, 0, "")); } else { //TO DO: fix later // This show popup service NPC PopupCorrespondingServiceDialog( - id, 0, m_pLst_Main.GetItemDataPtr(nCurSel)); + (int)id, 0, m_pLst_Main.GetItemDataPtr(nCurSel, 0, "")); } } else // Window. @@ -2427,7 +2711,7 @@ namespace BrewMonster.UI } } - int idFunction, id_dialog = 0; + int idFunction = 0, id_dialog = 0; object pData = m_pLst_Main.GetItemDataPtr(nCurSel, 0, ""); EC_Game.GetElementDataMan().get_data_ptr((uint)iService, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); @@ -2442,7 +2726,7 @@ namespace BrewMonster.UI NPC_TASK_OUT_SERVICE pService = (NPC_TASK_OUT_SERVICE)pData; if (!(pService.storage_id == 0 || pService.storage_open_item == 0)) { - PopupStorageTaskDialog(pService, false); + //PopupStorageTaskDialog(pService, false); return; } } diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs index e96094ab29..86657af0a7 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs @@ -10,14 +10,10 @@ using UnityEngine; namespace BrewMonster.UI { - public class CECGameUIMan + public class CECGameUIMan : AUIManager { DlgNPC m_pDlgNPC; public NPC_ESSENCE? m_pCurNPCEssence; - private DialogScriptTableObject m_dialogResouce; - private Canvas m_canvas; - Dictionary m_StringTable = new Dictionary(); - Dictionary m_auiDialog_stringTable = new Dictionary(); public static bool TALKPROC_IS_TERMINAL(uint id) { @@ -34,254 +30,13 @@ namespace BrewMonster.UI return ((id) & 0x7FFFFFFF); } - public string GetStringFromTable(int idString) - { - if (m_StringTable.TryGetValue(idString, out var str)) - return str; - return null; - } - - - public string GetStringFromAuiDialogTable(int idString) - { - if (m_auiDialog_stringTable.TryGetValue(idString, out var str)) - return str; - return null; - } - - public void SetDependency(DialogScriptTableObject resouce, Canvas canvas) - { - m_dialogResouce = resouce; - m_canvas = canvas; - } - - public void Init() - { - ImportStringTable("ingame.stf"); - ImportAuiDialogStringTable("msgbox.stf"); - } - - public string Translate(ushort[] str) - { - if (str == null || str.Length == 0) - return null; - string m_AWString = ""; - string input = new string(str.Where(c => c != 0).Select(c => (char)c).ToArray()); - m_AWString = input; - - var result = new System.Text.StringBuilder(); - - int i = 0; - while (i < input.Length) - { - char c = input[i]; - - if (c != '\\') - { - result.Append(c); - i++; - continue; - } - - i++; - if (i >= input.Length) - break; - - char next = input[i]; - - switch (next) - { - case '\n': - i++; - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int value = 0; - int count = 3; - while (i < input.Length && input[i] >= '0' && input[i] <= '7' && count > 0) - { - count--; - value = value * 8 + (input[i] - '0'); - i++; - } - if (value <= 255) - result.Append((char)(value & 0xFF)); - break; - } - - case '"': - case '\'': - case '\\': - result.Append(next); - i++; - break; - - case 'n': - result.Append('\n'); - i++; - break; - case 'r': - result.Append('\r'); - i++; - break; - case 't': - result.Append('\t'); - i++; - break; - case 'v': - result.Append('\v'); - i++; - break; - - default: - i++; - break; - } - } - - m_AWString = result.ToString(); - return m_AWString; - } - - private bool ImportStringTable(string pszFilename) - { - //AWScriptFile s = new AWScriptFile(); - string szFilename = Path.Combine(Application.streamingAssetsPath, pszFilename); - - foreach (var line in File.ReadLines(szFilename)) - { - if (string.IsNullOrWhiteSpace(line)) - continue; - - var parts = line.Split('\t', StringSplitOptions.RemoveEmptyEntries); - if (parts.Length < 2) - continue; - - if (int.TryParse(parts[0], out int key)) - { - string value = parts[1].Trim(); - if (value.StartsWith("\"") && value.EndsWith("\"")) - value = value.Substring(1, value.Length - 2); - - m_StringTable[key] = value; - } - } - - return true; - //bool bval = s.Open(szFilename); - //if (!bval) return false; - - //while (!s.IsEnd()) - //{ - // bval = s.GetNextToken(true); - // if (!bval) break; // End of file. - // int idString = int.Parse(ByteToStringUtils.UshortArrayToUnicodeString(s.m_szToken)); - - // bval = s.GetNextToken(true); - // if (!bval) return false; - // string str = (Translate(s.m_szToken)); - // m_StringTable[idString] = str; - //} - //s.Close(); - - //if (a_stricmp(GetStringFromTable(1), _AL("")) == 0) //1 脛卢脠脧脳脰脤氓 - // m_StringTable[1] = _AL("路陆脮媒脧赂潞脷脪禄录貌脤氓"); - //m_strDefaultFontName = GetStringFromTable(1); - //if (a_stricmp(GetStringFromTable(2), _AL("")) == 0) //2 脛卢脠脧脳脰脤氓麓贸脨隆 - // m_StringTable[2] = _AL("10"); - //m_nDefaultFontSize = a_atoi(GetStringFromTable(2)); - //if (a_stricmp(GetStringFromTable(3), _AL("")) == 0) //3 路没潞脜 '\t' 脧脿碌卤脫脷露脿脡脵赂枚 'W'碌脛驴铆露脠 - // m_StringTable[3] = _AL("30"); - //_tab_char = a_atoi(GetStringFromTable(3)); - //if (a_stricmp(GetStringFromTable(4), _AL("")) == 0) //4 m_FontImagePicture 脳脰脤氓麓贸脨隆 - // m_StringTable[4] = m_StringTable[2]; - //if (a_stricmp(GetStringFromTable(5), _AL("")) == 0) //5 MessageBox 脳脰脤氓麓贸脨隆 - // m_StringTable[5] = m_StringTable[2]; - //if (a_stricmp(GetStringFromTable(6), _AL("")) == 0) //6 MessageBox shadow - // m_StringTable[6] = _AL("0"); - //if (a_stricmp(GetStringFromTable(7), _AL("")) == 0) //7 MessageBox outline - // m_StringTable[7] = _AL("0"); - //if (a_stricmp(GetStringFromTable(8), _AL("")) == 0) //8 MessageBox outline color - // m_StringTable[8] = _AL("0"); - - //m_FontHint.szFontName = GetStringFromTable(1); - //m_FontHint.nFontSize = a_atoi(GetStringFromTable(2)); - //m_FontImagePicture.szFontName = GetStringFromTable(1); - //m_FontImagePicture.nFontSize = a_atoi(GetStringFromTable(4)); - //m_FontImagePicture.nOutline = 1; - //m_FontMessageBox.szFontName = GetStringFromTable(1); - //m_FontMessageBox.nFontSize = a_atoi(GetStringFromTable(5)); - //m_FontMessageBox.nShadow = a_atoi(GetStringFromTable(6)); - //m_FontMessageBox.nOutline = a_atoi(GetStringFromTable(7)); - //return true; - } - - public bool ImportAuiDialogStringTable(string pszFilename) - { - - //bool bval; - //int idString; - //string str; - //AWScriptFile s = new AWScriptFile(); - string szFilename = Path.Combine(Application.streamingAssetsPath, pszFilename); - //bval = s.Open(szFilename); - //if (!bval) return true; // Ignore error. - //while (!s.IsEnd()) - //{ - // bval = s.GetNextToken(true); - // if (!bval) break; // End of file. - // idString = int.Parse(ByteToStringUtils.UshortArrayToUnicodeString(s.m_szToken)); - - // bval = s.GetNextToken(true); - // if (!bval) return false; - - // str = ByteToStringUtils.UshortArrayToUnicodeString(s.m_szToken); - // if(m_auiDialog_stringTable.TryGetValue(idString, out string value)) - // { - // m_auiDialog_stringTable[idString] = str; - // } - // else - // { - // m_auiDialog_stringTable.Add(idString, str); - // } - //} - - //s.Close(); - foreach (var line in File.ReadLines(szFilename)) - { - if (string.IsNullOrWhiteSpace(line)) - continue; - - var parts = line.Split('\t', StringSplitOptions.RemoveEmptyEntries); - if (parts.Length < 2) - continue; - - if (int.TryParse(parts[0], out int key)) - { - string value = parts[1].Trim(); - if (value.StartsWith("\"") && value.EndsWith("\"")) - value = value.Substring(1, value.Length - 2); - - m_auiDialog_stringTable[key] = value; - } - } - return true; - } - public void PopupNPCDialog(NPC_ESSENCE pEssence) { if(m_pDlgNPC == null) { GameObject ob = m_dialogResouce.GetPrefabDialog("DialogNPC"); m_pDlgNPC = GameObject.Instantiate(ob, m_canvas.transform).GetComponent(); + m_pDlgNPC.SetAUIManager(this); } m_pDlgNPC.PopupDialog(pEssence); } @@ -292,6 +47,7 @@ namespace BrewMonster.UI { GameObject ob = m_dialogResouce.GetPrefabDialog("DialogNPC"); m_pDlgNPC = GameObject.Instantiate(ob, m_canvas.transform).GetComponent(); + m_pDlgNPC.SetAUIManager(this); } m_pDlgNPC.PopupNPCDialog(pTalk); } diff --git a/Assets/Scripts/CECUIManager.cs b/Assets/Scripts/CECUIManager.cs index 34c4e98d6c..783db64dc9 100644 --- a/Assets/Scripts/CECUIManager.cs +++ b/Assets/Scripts/CECUIManager.cs @@ -15,6 +15,7 @@ public class CECUIManager : MonoSingleton [SerializeField] private int currentTargetNPCID; CECGameUIMan gameUI; + AUIManager aUIManager; [SerializeField] private DialogScriptTableObject dialogResouce; [SerializeField] private Canvas canvasDlg; protected override void Awake() @@ -110,11 +111,12 @@ public class CECUIManager : MonoSingleton public CECGameUIMan GetInGameUIMan() { - if (gameUI == null) + if (aUIManager == null) { - gameUI = new CECGameUIMan(); - gameUI.SetDependency(dialogResouce, canvasDlg); - gameUI.Init(); + aUIManager = new AUIManager(); + aUIManager.SetDependency(dialogResouce, canvasDlg); + aUIManager.Init(); + gameUI = aUIManager as CECGameUIMan; } return gameUI; }