规范对话数据

This commit is contained in:
2026-04-20 19:49:18 +08:00
parent 0f928f6167
commit ef68ccc9e9
43 changed files with 1574 additions and 1092 deletions
@@ -11,6 +11,7 @@ namespace UI
private DialogFormBase _dialogForm;
private int? _formSerialId;
private bool _pendingRefresh;
private Action _pendingCloseCompleted;
public DialogFormController()
{
@@ -31,7 +32,8 @@ namespace UI
UIFormId targetFormId = MapDialogFormId(context.DialogUIMode);
if (targetFormId == UIFormId.Undefined)
{
Log.Warning("DialogFormController open failed. Unsupported mode '{0}'.", context.DialogUIMode.ToString());
Log.Warning("DialogFormController open failed. Unsupported mode '{0}'.",
context.DialogUIMode.ToString());
return null;
}
@@ -48,8 +50,14 @@ namespace UI
}
public void CloseUI()
{
CloseUI(onClosed: null);
}
public void CloseUI(Action onClosed = null)
{
_pendingRefresh = false;
_pendingCloseCompleted = onClosed;
if (_formSerialId.HasValue)
{
@@ -61,6 +69,8 @@ namespace UI
{
_dialogForm.Close();
}
InvokeCloseCompletedIfNeeded();
}
public void OnDialogStarted(DialogFormContext context)
@@ -163,6 +173,19 @@ namespace UI
_dialogForm = null;
_formSerialId = null;
_pendingRefresh = false;
InvokeCloseCompletedIfNeeded();
}
private void InvokeCloseCompletedIfNeeded()
{
if (_pendingCloseCompleted == null)
{
return;
}
Action callback = _pendingCloseCompleted;
_pendingCloseCompleted = null;
callback.Invoke();
}
}
}
}