diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs index ab93cf28b4..44f2dfedf3 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgNPC.cs @@ -3,6 +3,7 @@ using BrewMonster.Managers; using BrewMonster.Network; using CSNetwork; using CSNetwork.GPDataType; +using ModelRenderer.Scripts.Common; using ModelRenderer.Scripts.GameData; using System; using System.Runtime.InteropServices; @@ -195,7 +196,13 @@ namespace BrewMonster.UI private string GetStringFromTable(int idString) { - return EC_Game.GetGameRun().GetUIManager().GetInGameUIMan().GetStringFromTable(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) @@ -678,17 +685,17 @@ namespace BrewMonster.UI { if (a_uiService[i] == 0) continue; - pData = pDataMan.get_data_ptr(a_uiService[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + pData = ElementDataManProvider.GetElementDataMan().get_data_ptr(a_uiService[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); if (DataType == DATA_TYPE.DT_NPC_TALK_SERVICE) { NPC_TALK_SERVICE pService = (NPC_TALK_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_SELL_SERVICE) { NPC_SELL_SERVICE pService = (NPC_SELL_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_BUY_SERVICE) { @@ -697,17 +704,17 @@ namespace BrewMonster.UI else if (DataType == DATA_TYPE.DT_NPC_REPAIR_SERVICE) { NPC_REPAIR_SERVICE pService = (NPC_REPAIR_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_INSTALL_SERVICE) { NPC_INSTALL_SERVICE pService = (NPC_INSTALL_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_UNINSTALL_SERVICE) { NPC_UNINSTALL_SERVICE pService = (NPC_UNINSTALL_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_SKILL_SERVICE) { @@ -717,32 +724,32 @@ namespace BrewMonster.UI m_pLst_Main.AddString(strText + GetStringFromTable(7107)); } else - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_HEAL_SERVICE) { NPC_HEAL_SERVICE pService = (NPC_HEAL_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_TRANSMIT_SERVICE) { NPC_TRANSMIT_SERVICE pService = (NPC_TRANSMIT_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_TRANSPORT_SERVICE) { NPC_TRANSPORT_SERVICE pService = (NPC_TRANSPORT_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_PROXY_SERVICE) { NPC_PROXY_SERVICE pService = (NPC_PROXY_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_STORAGE_SERVICE) { NPC_STORAGE_SERVICE pService = (NPC_STORAGE_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]); m_pLst_Main.AddString(strText + GetStringFromTable(253)); m_pLst_Main.SetItemData(m_pLst_Main.GetCount() - 1, a_uiService[i]); @@ -751,7 +758,7 @@ namespace BrewMonster.UI else if (DataType == DATA_TYPE.DT_NPC_MAKE_SERVICE) { NPC_MAKE_SERVICE pService = (NPC_MAKE_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_DECOMPOSE_SERVICE) { @@ -776,57 +783,57 @@ namespace BrewMonster.UI else if (DataType == DATA_TYPE.DT_NPC_IDENTIFY_SERVICE) { NPC_IDENTIFY_SERVICE pService = (NPC_IDENTIFY_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_WAR_TOWERBUILD_SERVICE) { NPC_WAR_TOWERBUILD_SERVICE pService = (NPC_WAR_TOWERBUILD_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_RESETPROP_SERVICE) { NPC_RESETPROP_SERVICE pService = (NPC_RESETPROP_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_PETNAME_SERVICE) { NPC_PETNAME_SERVICE pService = (NPC_PETNAME_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_PETLEARNSKILL_SERVICE) { NPC_PETLEARNSKILL_SERVICE pService = (NPC_PETLEARNSKILL_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_PETFORGETSKILL_SERVICE) { NPC_PETFORGETSKILL_SERVICE pService = (NPC_PETFORGETSKILL_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_EQUIPBIND_SERVICE) { NPC_EQUIPBIND_SERVICE pService = (NPC_EQUIPBIND_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_EQUIPDESTROY_SERVICE) { NPC_EQUIPDESTROY_SERVICE pService = (NPC_EQUIPDESTROY_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_EQUIPUNDESTROY_SERVICE) { NPC_EQUIPUNDESTROY_SERVICE pService = (NPC_EQUIPUNDESTROY_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_ENGRAVE_SERVICE) { NPC_ENGRAVE_SERVICE pService = (NPC_ENGRAVE_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_RANDPROP_SERVICE) { NPC_RANDPROP_SERVICE pService = (NPC_RANDPROP_SERVICE)pData; - m_pLst_Main.AddString(strText + pService.name); + m_pLst_Main.AddString(strText + Encoding.Unicode.GetString(MemoryMarshal.AsBytes(pService.name))); } else if (DataType == DATA_TYPE.DT_NPC_FORCE_SERVICE) { @@ -1019,9 +1026,9 @@ namespace BrewMonster.UI uint[] a_uiService2 = { - pEssence.id_task_out_service, // 任务相关的服务ID: 发放任务服务 - pEssence.id_task_in_service, // 任务相关的服务ID: 验证完成任务服务 - pEssence.id_task_matter_service, // 任务相关的服务ID: 发放任务物品服务 + pEssence.id_task_out_service, // 任务相关的服务ID: 发放任务服务 + pEssence.id_task_in_service, // 任务相关的服务ID: 验证完成任务服务 + pEssence.id_task_matter_service, // 任务相关的服务ID: 发放任务物品服务 }; object pData; @@ -1045,8 +1052,8 @@ namespace BrewMonster.UI for (int i = 0; i < a_uiService2.Length; i++) { if (a_uiService2[i] == 0) continue; - - pData = pDataMan.get_data_ptr(a_uiService2[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + + pData = ElementDataManProvider.GetElementDataMan().get_data_ptr(a_uiService2[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); // ignore other service if (DataType != DATA_TYPE.DT_NPC_TASK_IN_SERVICE && diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs index e468ef6ecb..766e02e7d9 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs @@ -17,12 +17,21 @@ namespace BrewMonster.UI private DialogScriptTableObject m_dialogResouce; private Canvas m_canvas; Dictionary m_StringTable = new Dictionary(); + Dictionary m_auiDialog_stringTable = new Dictionary(); public string GetStringFromTable(int idString) { if (m_StringTable.TryGetValue(idString, out var str)) return str; - return ""; + 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) @@ -34,6 +43,7 @@ namespace BrewMonster.UI public void Init() { ImportStringTable("ingame.stf"); + ImportAuiDialogStringTable("msgbox.stf"); } public string Translate(ushort[] str) @@ -41,7 +51,7 @@ namespace BrewMonster.UI if (str == null || str.Length == 0) return null; string m_AWString = ""; - string input = new string(str.Select(c => (char)c).ToArray()); + string input = new string(str.Where(c => c != 0).Select(c => (char)c).ToArray()); m_AWString = input; var result = new System.Text.StringBuilder(); @@ -128,24 +138,44 @@ namespace BrewMonster.UI private bool ImportStringTable(string pszFilename) { - AWScriptFile s = new AWScriptFile(); + //AWScriptFile s = new AWScriptFile(); string szFilename = Path.Combine(Application.streamingAssetsPath, pszFilename); - bool bval = s.Open(szFilename); - if (!bval) return false; - - while (!s.IsEnd()) + foreach (var line in File.ReadLines(szFilename)) { - bval = s.GetNextToken(true); - if (!bval) break; // End of file. - int idString = int.Parse(ByteToStringUtils.UshortArrayToUnicodeString(s.m_szToken)); + if (string.IsNullOrWhiteSpace(line)) + continue; - bval = s.GetNextToken(true); - if (!bval) return false; - string str = (Translate(s.m_szToken)); - m_StringTable[idString] = str; + 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; + } } - s.Close(); + + 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("路陆脮媒脧赂潞脷脪禄录貌脤氓"); @@ -179,6 +209,58 @@ namespace BrewMonster.UI 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) { GameObject ob = m_dialogResouce.GetPrefabDialog("DialogNPC"); diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/UINPC.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/UINPC.cs index 2d2ca6fd84..60536c8431 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/UINPC.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/UINPC.cs @@ -16,11 +16,13 @@ namespace BrewMonster } public void SetHealthImage(float health) { - _healthImage.fillAmount = health; + if(_healthImage != null) + _healthImage.fillAmount = health; } public void SetHealthText(string healthText) { - _healthText.text = healthText; + if(_healthText != null) + _healthText.text = healthText; } } } diff --git a/Assets/Prefabs/UI/DialogNPC.prefab b/Assets/Prefabs/UI/DialogNPC.prefab index 6d1dd5897d..2b720e15bb 100644 --- a/Assets/Prefabs/UI/DialogNPC.prefab +++ b/Assets/Prefabs/UI/DialogNPC.prefab @@ -962,7 +962,7 @@ MonoBehaviour: m_Calls: [] m_text: New Text m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2} m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} @@ -987,12 +987,12 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 36 - m_fontSizeBase: 36 + m_fontSize: 30 + m_fontSizeBase: 30 m_fontWeight: 400 m_enableAutoSizing: 0 - m_fontSizeMin: 18 - m_fontSizeMax: 72 + m_fontSizeMin: 1 + m_fontSizeMax: 20 m_fontStyle: 0 m_HorizontalAlignment: 1 m_VerticalAlignment: 512 @@ -1028,7 +1028,7 @@ MonoBehaviour: m_margin: {x: 0, y: 0, z: 0, w: 0} m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 - m_hasFontAssetChanged: 1 + m_hasFontAssetChanged: 0 m_baseMaterial: {fileID: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0} --- !u!1 &6297753662624094075 @@ -1088,7 +1088,7 @@ MonoBehaviour: m_ChildAlignment: 1 m_StartCorner: 1 m_StartAxis: 1 - m_CellSize: {x: 550, y: 50} + m_CellSize: {x: 550, y: 30} m_Spacing: {x: 0, y: 9} m_Constraint: 1 m_ConstraintCount: 1 diff --git a/Assets/StreamingAssets/msgbox.stf b/Assets/StreamingAssets/msgbox.stf new file mode 100644 index 0000000000..52c84ea390 Binary files /dev/null and b/Assets/StreamingAssets/msgbox.stf differ diff --git a/Assets/StreamingAssets/msgbox.stf.meta b/Assets/StreamingAssets/msgbox.stf.meta new file mode 100644 index 0000000000..e58db4bc55 --- /dev/null +++ b/Assets/StreamingAssets/msgbox.stf.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: de3ba170288dec647b1957bf1af29f86 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: