修复多语言空白行
This commit is contained in:
parent
9f72fab4b6
commit
0254e40afe
@ -244,7 +244,7 @@ namespace Logic.Editor
|
||||
}
|
||||
ExportMatchLevelData();
|
||||
|
||||
_asset.RefreshDict();
|
||||
_asset.RefreshDict(true);
|
||||
foreach (var kv in _zhStrDict)
|
||||
{
|
||||
if (_asset.ItemDict.ContainsKey(kv.Value)) continue;
|
||||
@ -262,6 +262,7 @@ namespace Logic.Editor
|
||||
}
|
||||
|
||||
_asset.Items = _asset.Items.OrderBy(i => i.ID).ToList();
|
||||
_asset.RefreshDict(true);
|
||||
|
||||
string filePath = MultilingualTxtPath;
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
@ -1326,7 +1327,7 @@ namespace Logic.Editor
|
||||
// _zhStrDict[kv.Key] = kv.Value;
|
||||
// }
|
||||
|
||||
_asset.RefreshDict();
|
||||
_asset.RefreshDict(true);
|
||||
foreach (var kv in _zhStrDict)
|
||||
{
|
||||
if (_asset.ItemDict.ContainsKey(kv.Value)) continue;
|
||||
@ -1345,6 +1346,7 @@ namespace Logic.Editor
|
||||
|
||||
// 排序 asset.items 保证id从小到大
|
||||
_asset.Items = _asset.Items.OrderBy(i => i.ID).ToList();
|
||||
_asset.RefreshDict(true);
|
||||
|
||||
string filePath = MultilingualTxtPath;
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
|
||||
|
||||
@ -81,7 +81,11 @@ namespace Logic.Multilingual
|
||||
{
|
||||
if (_itemDict == null) RefreshDict();
|
||||
if (_itemDict == null) return string.Empty;
|
||||
if (!_itemDict.TryGetValue(id, out var item)) return string.Empty;
|
||||
if (!_itemDict.TryGetValue(id, out var item))
|
||||
{
|
||||
RefreshDict(true);
|
||||
if (!_itemDict.TryGetValue(id, out item)) return string.Empty;
|
||||
}
|
||||
|
||||
var ret = item.GetStrByType(type);
|
||||
// Fallback 链:
|
||||
@ -159,10 +163,10 @@ namespace Logic.Multilingual
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void RefreshDict()
|
||||
public void RefreshDict(bool force = false)
|
||||
{
|
||||
if (_itemDict == null) _itemDict = new Dictionary<uint, MultilingualItem>();
|
||||
if (_itemDict.Count == Items.Count) return;
|
||||
if (!force && _itemDict.Count == Items.Count) return;
|
||||
_itemDict.Clear();
|
||||
foreach (var item in Items) _itemDict[item.ID] = item;
|
||||
}
|
||||
@ -178,7 +182,11 @@ namespace Logic.Multilingual
|
||||
{
|
||||
if (_itemDict == null) RefreshDict();
|
||||
if (_itemDict == null) return string.Empty;
|
||||
if (!_itemDict.TryGetValue(id, out var item)) return string.Empty;
|
||||
if (!_itemDict.TryGetValue(id, out var item))
|
||||
{
|
||||
RefreshDict(true);
|
||||
if (!_itemDict.TryGetValue(id, out item)) return string.Empty;
|
||||
}
|
||||
|
||||
var ret = item.GetStrByType(type);
|
||||
if (string.IsNullOrEmpty(ret)) return ret;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user