fix: update logic show dialog NPC.
This commit is contained in:
@@ -251,5 +251,10 @@ namespace BrewMonster.Common
|
||||
GetNextToken(bCrossLine);
|
||||
return int.Parse(ByteToStringUtils.UshortArrayToUnicodeString(m_szToken));
|
||||
}
|
||||
|
||||
// Reach end of file ?
|
||||
public bool IsEnd() { return m_Script.pCurIndex >= m_Script.pFileBuf.Length; }
|
||||
// Get current line
|
||||
public int GetCurLine() { return m_Script.iLine; }
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ namespace BrewMonster.UI
|
||||
|
||||
private string GetStringFromTable(int idString)
|
||||
{
|
||||
return EC_Game.GetGameRun().GetUIManager().GetStringFromTable(idString);
|
||||
return EC_Game.GetGameRun().GetUIManager().GetInGameUIMan().GetStringFromTable(idString);
|
||||
}
|
||||
|
||||
private void Show(bool value)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
using BrewMonster.Common;
|
||||
using BrewMonster.Managers;
|
||||
using BrewMonster.Network;
|
||||
using ModelRenderer.Scripts.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BrewMonster.UI
|
||||
@@ -10,13 +16,169 @@ namespace BrewMonster.UI
|
||||
public NPC_ESSENCE? m_pCurNPCEssence;
|
||||
private DialogScriptTableObject m_dialogResouce;
|
||||
private Canvas m_canvas;
|
||||
Dictionary<int, string> m_StringTable = new Dictionary<int, string>();
|
||||
|
||||
public void InitGameUIMan(DialogScriptTableObject resouce, Canvas canvas)
|
||||
public string GetStringFromTable(int idString)
|
||||
{
|
||||
if (m_StringTable.TryGetValue(idString, out var str))
|
||||
return str;
|
||||
return "";
|
||||
}
|
||||
|
||||
public void SetDependency(DialogScriptTableObject resouce, Canvas canvas)
|
||||
{
|
||||
m_dialogResouce = resouce;
|
||||
m_canvas = canvas;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
ImportStringTable("ingame.stf");
|
||||
}
|
||||
|
||||
public string Translate(ushort[] str)
|
||||
{
|
||||
if (str == null || str.Length == 0)
|
||||
return null;
|
||||
string m_AWString = "";
|
||||
string input = new string(str.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);
|
||||
|
||||
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 void PopupNPCDialog(NPC_ESSENCE pEssence)
|
||||
{
|
||||
GameObject ob = m_dialogResouce.GetPrefabDialog("DialogNPC");
|
||||
|
||||
@@ -18,14 +18,6 @@ namespace BrewMonster.UI
|
||||
[SerializeField] private HUDNPC npsUI;
|
||||
|
||||
CECGameUIMan gameUI;
|
||||
Dictionary<int, string> m_StringTable;
|
||||
|
||||
public string GetStringFromTable(int idString)
|
||||
{
|
||||
if (m_StringTable.TryGetValue(idString, out var str))
|
||||
return str;
|
||||
return "";
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -118,7 +110,8 @@ namespace BrewMonster.UI
|
||||
if(gameUI == null)
|
||||
{
|
||||
gameUI = new CECGameUIMan();
|
||||
gameUI.InitGameUIMan(dialogResouce, canvasDlg);
|
||||
gameUI.SetDependency(dialogResouce, canvasDlg);
|
||||
gameUI.Init();
|
||||
}
|
||||
return gameUI;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 900c2b23089d0e1488dfae0059db9425
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user