- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
91 lines
2.6 KiB
C#
91 lines
2.6 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace XFramework.NetOuter
|
|
{
|
|
//消息回调事件
|
|
public delegate void TCPMsgEvent(ProtocolBase proto);
|
|
public class MsgDistribution
|
|
{
|
|
//事件字典
|
|
Dictionary<string, INetExcute> eventDic = new Dictionary<string, INetExcute>();
|
|
|
|
//单次事件字典
|
|
Dictionary<string, INetExcute> onceEventDic = new Dictionary<string, INetExcute>();
|
|
|
|
//Queue<ProtocolBase> msgList = new Queue<ProtocolBase>();
|
|
|
|
Queue<ExcuteParam> serverMsgList = new Queue<ExcuteParam>();
|
|
|
|
//一次调用处理完所有消息,该方法由外部调用
|
|
public void Distribution()
|
|
{
|
|
while (serverMsgList.Count > 0)
|
|
{
|
|
DispatchMsgEvent(serverMsgList.Dequeue());
|
|
}
|
|
}
|
|
|
|
public void Enqueue(ExcuteParam excuteParam)
|
|
{
|
|
lock (serverMsgList)
|
|
{
|
|
serverMsgList.Enqueue(excuteParam);
|
|
}
|
|
}
|
|
|
|
//事件分发
|
|
private void DispatchMsgEvent(ExcuteParam excuteParam)
|
|
{
|
|
string proName = excuteParam.protocolName;
|
|
//Debug.Log("消息分发处理:"+proName);
|
|
if (onceEventDic.ContainsKey(proName))
|
|
{
|
|
onceEventDic[proName].NetExcute(excuteParam);
|
|
onceEventDic[proName] = null;
|
|
onceEventDic.Remove(proName);
|
|
}
|
|
else if (eventDic.ContainsKey(proName))
|
|
{
|
|
eventDic[proName].NetExcute(excuteParam);
|
|
}
|
|
else
|
|
{
|
|
Debug.Log($"接到未注册的网络消息事件:{proName}");
|
|
}
|
|
|
|
}
|
|
//添加监听事件
|
|
public void AddListener(string name, INetExcute cb)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
Debug.Log($"{name}事件覆盖注册");
|
|
eventDic[name] = cb;
|
|
}
|
|
else eventDic.Add(name, cb);
|
|
}
|
|
|
|
//添加单次监听事件,单次事件会在处理完后删除
|
|
public void AddOnceListener(string name, INetExcute cb)
|
|
{
|
|
if (onceEventDic.ContainsKey(name))
|
|
{
|
|
Debug.Log($"{name}事件覆盖注册");
|
|
onceEventDic[name] = cb;
|
|
}
|
|
else onceEventDic.Add(name, cb);
|
|
}
|
|
|
|
//移除回调事件
|
|
public void RemoveListener(string name)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
eventDic.Remove(name);
|
|
}
|
|
}
|
|
}
|
|
}
|