feat: Add fatal error dialog
This commit is contained in:
@@ -23,6 +23,12 @@ namespace Cryville.Common.Unity.UI {
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
protected bool m_ChildScaleHeight;
|
protected bool m_ChildScaleHeight;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
protected bool m_ChildOverflowWidth;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
protected bool m_ChildOverflowHeight;
|
||||||
|
|
||||||
public override void CalculateLayoutInputHorizontal() {
|
public override void CalculateLayoutInputHorizontal() {
|
||||||
base.CalculateLayoutInputHorizontal();
|
base.CalculateLayoutInputHorizontal();
|
||||||
CalcAlongAxis(0);
|
CalcAlongAxis(0);
|
||||||
@@ -60,9 +66,10 @@ namespace Cryville.Common.Unity.UI {
|
|||||||
float size = rectTransform.rect.size[axis];
|
float size = rectTransform.rect.size[axis];
|
||||||
bool controlSize = (axis == 0) ? m_ChildControlWidth : m_ChildControlHeight;
|
bool controlSize = (axis == 0) ? m_ChildControlWidth : m_ChildControlHeight;
|
||||||
bool useScale = (axis == 0) ? m_ChildScaleWidth : m_ChildScaleHeight;
|
bool useScale = (axis == 0) ? m_ChildScaleWidth : m_ChildScaleHeight;
|
||||||
|
bool overflow = (axis == 0) ? m_ChildOverflowWidth : m_ChildOverflowHeight;
|
||||||
bool childForceExpandSize = (axis == 0) ? m_ChildForceExpandWidth : m_ChildForceExpandHeight;
|
bool childForceExpandSize = (axis == 0) ? m_ChildForceExpandWidth : m_ChildForceExpandHeight;
|
||||||
float alignmentOnAxis = GetAlignmentOnAxis(axis);
|
float alignmentOnAxis = GetAlignmentOnAxis(axis);
|
||||||
float innerSize = size - ((axis == 0) ? padding.horizontal : padding.vertical);
|
float innerSize = overflow ? float.PositiveInfinity : (size - ((axis == 0) ? padding.horizontal : padding.vertical));
|
||||||
RectTransform child = rectChildren[0];
|
RectTransform child = rectChildren[0];
|
||||||
GetChildSizes(child, axis, controlSize, childForceExpandSize, out var min2, out var preferred2, out var flexible2);
|
GetChildSizes(child, axis, controlSize, childForceExpandSize, out var min2, out var preferred2, out var flexible2);
|
||||||
float scaleFactor2 = useScale ? child.localScale[axis] : 1f;
|
float scaleFactor2 = useScale ? child.localScale[axis] : 1f;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ MonoImporter:
|
|||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: -95
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
||||||
|
|||||||
37
Assets/Cryville.EEW.Unity/UI/Dialog.cs
Normal file
37
Assets/Cryville.EEW.Unity/UI/Dialog.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using Cryville.Common.Unity;
|
||||||
|
using Cryville.Common.Unity.UI;
|
||||||
|
using System.Globalization;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Cryville.EEW.Unity.UI {
|
||||||
|
public class Dialog : MonoBehaviour {
|
||||||
|
public static Dialog Instance { get; private set; }
|
||||||
|
|
||||||
|
[SerializeField] CanvasGroup m_mask;
|
||||||
|
PropertyTweener<float> _groupAlphaTweener;
|
||||||
|
|
||||||
|
[SerializeField] TMPLocalizedText m_title;
|
||||||
|
[SerializeField] TMPLocalizedText m_message;
|
||||||
|
|
||||||
|
void Awake() {
|
||||||
|
Instance = this;
|
||||||
|
|
||||||
|
m_mask.gameObject.SetActive(false);
|
||||||
|
_groupAlphaTweener = new(() => m_mask.alpha, v => m_mask.alpha = v, Tweeners.Single);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Show(string title, string message) {
|
||||||
|
Show(SharedCultures.CurrentUICulture, title, message);
|
||||||
|
}
|
||||||
|
public void Show(CultureInfo culture, string title, string message) {
|
||||||
|
m_title.SetText(title, culture);
|
||||||
|
m_message.SetText(message, culture);
|
||||||
|
m_mask.gameObject.SetActive(true);
|
||||||
|
_groupAlphaTweener.Start(1, 0.2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
_groupAlphaTweener.Advance(Time.deltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville.EEW.Unity/UI/Dialog.cs.meta
Normal file
11
Assets/Cryville.EEW.Unity/UI/Dialog.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f1b4f209f34bc6e4c8e13aeb4dd5789d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: -5
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -53,40 +53,52 @@ namespace Cryville.EEW.Unity {
|
|||||||
}
|
}
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
App.Init();
|
try {
|
||||||
|
App.Init();
|
||||||
|
|
||||||
_worker = new(new TTSWorker());
|
_worker = new(new TTSWorker());
|
||||||
_grouper = new ReportGrouper();
|
_grouper = new ReportGrouper();
|
||||||
_cancellationTokenSource = new();
|
_cancellationTokenSource = new();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Dialog.Instance.Show("FATAL ERROR", ex.ToString());
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
App.MainLogger.Log(1, "App", null, "Initializing localized resources manager");
|
try {
|
||||||
LocalizedResources.Init(new LocalizedResourcesManager());
|
App.MainLogger.Log(1, "App", null, "Initializing localized resources manager");
|
||||||
RegisterViewModelGenerators(_worker);
|
LocalizedResources.Init(new LocalizedResourcesManager());
|
||||||
RegisterTTSMessageGenerators(_worker);
|
RegisterViewModelGenerators(_worker);
|
||||||
BuildWorkers();
|
RegisterTTSMessageGenerators(_worker);
|
||||||
_worker.RVMGeneratorContext = SharedSettings.Instance;
|
BuildWorkers();
|
||||||
_worker.TTSMessageGeneratorContext = SharedSettings.Instance;
|
_worker.RVMGeneratorContext = SharedSettings.Instance;
|
||||||
_worker.RVMCulture = SharedSettings.Instance.RVMCulture;
|
_worker.TTSMessageGeneratorContext = SharedSettings.Instance;
|
||||||
_worker.SetTTSCultures(SharedSettings.Instance.TTSCultures ?? new TTSCultureConfig[0]);
|
_worker.RVMCulture = SharedSettings.Instance.RVMCulture;
|
||||||
_worker.IgnoreLanguageVariant = SharedSettings.Instance.DoIgnoreLanguageVariant;
|
_worker.SetTTSCultures(SharedSettings.Instance.TTSCultures ?? new TTSCultureConfig[0]);
|
||||||
_ongoingReportManager.Changed += OnOngoingReported;
|
_worker.IgnoreLanguageVariant = SharedSettings.Instance.DoIgnoreLanguageVariant;
|
||||||
_worker.Reported += OnReported;
|
_ongoingReportManager.Changed += OnOngoingReported;
|
||||||
_grouper.GroupUpdated += OnGroupUpdated;
|
_worker.Reported += OnReported;
|
||||||
_grouper.GroupRemoved += OnGroupRemoved;
|
_grouper.GroupUpdated += OnGroupUpdated;
|
||||||
App.MainLogger.Log(1, "App", null, "Worker ready");
|
_grouper.GroupRemoved += OnGroupRemoved;
|
||||||
Task.Run(() => GatewayVerify(_cancellationTokenSource.Token)).ContinueWith(task => {
|
App.MainLogger.Log(1, "App", null, "Worker ready");
|
||||||
if (task.IsFaulted) {
|
Task.Run(() => GatewayVerify(_cancellationTokenSource.Token)).ContinueWith(task => {
|
||||||
OnReported(this, new() { Title = task.Exception.Message });
|
if (task.IsFaulted) {
|
||||||
return;
|
OnReported(this, new() { Title = task.Exception.Message });
|
||||||
}
|
return;
|
||||||
_verified = true;
|
}
|
||||||
_uiActionQueue.Enqueue(() => m_connectingHint.SetActive(false));
|
_verified = true;
|
||||||
Task.Run(() => ScheduledGatewayVerify(_cancellationTokenSource, _cancellationTokenSource.Token));
|
_uiActionQueue.Enqueue(() => m_connectingHint.SetActive(false));
|
||||||
Task.Run(() => _worker.RunAsync(_cancellationTokenSource.Token));
|
Task.Run(() => ScheduledGatewayVerify(_cancellationTokenSource, _cancellationTokenSource.Token));
|
||||||
Task.Run(() => _ongoingReportManager.RunAsync(_cancellationTokenSource.Token));
|
Task.Run(() => _worker.RunAsync(_cancellationTokenSource.Token));
|
||||||
}, TaskScheduler.Current);
|
Task.Run(() => _ongoingReportManager.RunAsync(_cancellationTokenSource.Token));
|
||||||
|
}, TaskScheduler.Current);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Dialog.Instance.Show("FATAL ERROR", ex.ToString());
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDestroy() {
|
void OnDestroy() {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user