101 lines
3.3 KiB
C#
101 lines
3.3 KiB
C#
|
|
|
||
|
|
//------------------------------------------------------------------------------
|
||
|
|
// <auto-generated>
|
||
|
|
// This code was generated by a tool.
|
||
|
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||
|
|
// the code is regenerated.
|
||
|
|
// </auto-generated>
|
||
|
|
//------------------------------------------------------------------------------
|
||
|
|
|
||
|
|
using System;
|
||
|
|
using Luban;
|
||
|
|
using AlicizaX.Config.Runtime;
|
||
|
|
|
||
|
|
namespace Game.Config
|
||
|
|
{
|
||
|
|
public partial class TablesComponent
|
||
|
|
{
|
||
|
|
internal Tables.TbLocalization TbLocalization { private set; get; }
|
||
|
|
internal Tables.TbAchievement TbAchievement { private set; get; }
|
||
|
|
internal Tables.TbSounds TbSounds { private set; get; }
|
||
|
|
private ConfigComponent m_ConfigComponent;
|
||
|
|
|
||
|
|
public void Init(ConfigComponent configComponent)
|
||
|
|
{
|
||
|
|
m_ConfigComponent = configComponent;
|
||
|
|
configComponent.RemoveAllConfigs();
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 是否加载完成
|
||
|
|
/// </summary>
|
||
|
|
public bool IsLoaded { get; private set; }
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 异步加载配置文件
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="loader">加载器</param>
|
||
|
|
public async System.Threading.Tasks.Task LoadAsync(System.Func<string, System.Threading.Tasks.Task<ByteBuf>> loader)
|
||
|
|
{
|
||
|
|
if (IsLoaded)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
IsLoaded = false;
|
||
|
|
m_ConfigComponent.RemoveAllConfigs();
|
||
|
|
var loadTasks = new System.Collections.Generic.List<System.Threading.Tasks.Task>();
|
||
|
|
|
||
|
|
TbLocalization = new Tables.TbLocalization(() => loader("tables_tblocalization"));
|
||
|
|
loadTasks.Add(TbLocalization.LoadAsync());
|
||
|
|
m_ConfigComponent.Add(nameof(Tables.TbLocalization), TbLocalization);
|
||
|
|
|
||
|
|
TbAchievement = new Tables.TbAchievement(() => loader("tables_tbachievement"));
|
||
|
|
loadTasks.Add(TbAchievement.LoadAsync());
|
||
|
|
m_ConfigComponent.Add(nameof(Tables.TbAchievement), TbAchievement);
|
||
|
|
|
||
|
|
TbSounds = new Tables.TbSounds(() => loader("tables_tbsounds"));
|
||
|
|
loadTasks.Add(TbSounds.LoadAsync());
|
||
|
|
m_ConfigComponent.Add(nameof(Tables.TbSounds), TbSounds);
|
||
|
|
|
||
|
|
|
||
|
|
await System.Threading.Tasks.Task.WhenAll(loadTasks);
|
||
|
|
|
||
|
|
Refresh();
|
||
|
|
IsLoaded = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 设置本地化的适配器
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="translator">适配器对象</param>
|
||
|
|
/// <exception cref="InvalidOperationException">如果未加载完成将抛出此异常</exception>
|
||
|
|
public void SetTranslateText(System.Func<string, string, string> translator)
|
||
|
|
{
|
||
|
|
if (IsLoaded == false)
|
||
|
|
{
|
||
|
|
throw new InvalidOperationException("Table is not loaded!");
|
||
|
|
}
|
||
|
|
TbLocalization.TranslateText(translator);
|
||
|
|
TbAchievement.TranslateText(translator);
|
||
|
|
TbSounds.TranslateText(translator);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void ResolveRef()
|
||
|
|
{
|
||
|
|
TbLocalization.ResolveRef(this);
|
||
|
|
TbAchievement.ResolveRef(this);
|
||
|
|
TbSounds.ResolveRef(this);
|
||
|
|
PostResolveRef();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Refresh()
|
||
|
|
{
|
||
|
|
PostInit();
|
||
|
|
ResolveRef();
|
||
|
|
}
|
||
|
|
|
||
|
|
partial void PostInit();
|
||
|
|
partial void PostResolveRef();
|
||
|
|
}
|
||
|
|
}
|