fix: Improve ongoing report round-robin period
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
child.SetViewModel(e);
|
child.SetViewModel(e);
|
||||||
child.transform.SetParent(m_listView, false);
|
child.transform.SetParent(m_listView, false);
|
||||||
_displayingViews.Add(child);
|
_displayingViews.Add(child);
|
||||||
|
OnDisplayingViewsChanged();
|
||||||
|
|
||||||
SwitchTo(_displayingReports.Count - 1);
|
SwitchTo(_displayingReports.Count - 1);
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
child.SetParent(null, false);
|
child.SetParent(null, false);
|
||||||
Destroy(child.gameObject);
|
Destroy(child.gameObject);
|
||||||
_displayingViews.RemoveAt(index);
|
_displayingViews.RemoveAt(index);
|
||||||
|
OnDisplayingViewsChanged();
|
||||||
|
|
||||||
if (_displayingReports.Count == 0) {
|
if (_displayingReports.Count == 0) {
|
||||||
m_currentView.gameObject.SetActive(false);
|
m_currentView.gameObject.SetActive(false);
|
||||||
@@ -49,6 +51,14 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
|
|
||||||
if (_displayingReports.Count <= 1) m_listView.gameObject.SetActive(false);
|
if (_displayingReports.Count <= 1) m_listView.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
void OnDisplayingViewsChanged() {
|
||||||
|
_maxBaseDuration = 1;
|
||||||
|
foreach (var e in _displayingReports) {
|
||||||
|
float duration = GetBaseDuration(e);
|
||||||
|
if (duration > _maxBaseDuration)
|
||||||
|
_maxBaseDuration = duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
if (Instance != null) {
|
if (Instance != null) {
|
||||||
@@ -63,6 +73,7 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
|
|
||||||
int _index = -1;
|
int _index = -1;
|
||||||
float _tickDown;
|
float _tickDown;
|
||||||
|
float _maxBaseDuration;
|
||||||
void Update() {
|
void Update() {
|
||||||
if (_displayingReports.Count == 0) return;
|
if (_displayingReports.Count == 0) return;
|
||||||
_tickDown -= Time.deltaTime;
|
_tickDown -= Time.deltaTime;
|
||||||
@@ -77,12 +88,15 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
_index = index;
|
_index = index;
|
||||||
var e = _displayingReports[index];
|
var e = _displayingReports[index];
|
||||||
m_currentView.SetViewModel(e, true);
|
m_currentView.SetViewModel(e, true);
|
||||||
var keyProp = e.Properties.FirstOrDefault();
|
|
||||||
_displayingViews[_index].SetCurrent(true);
|
_displayingViews[_index].SetCurrent(true);
|
||||||
_tickDown = MathF.Exp(Math.Max(-1f, keyProp?.Severity ?? -1f) + 1);
|
_tickDown = GetBaseDuration(e) / Math.Min(_maxBaseDuration, 4) * 4;
|
||||||
m_currentView.gameObject.SetActive(true);
|
m_currentView.gameObject.SetActive(true);
|
||||||
Worker.Instance.SetCurrent(e);
|
Worker.Instance.SetCurrent(e);
|
||||||
}
|
}
|
||||||
|
static float GetBaseDuration(ReportViewModel e) {
|
||||||
|
return MathF.Exp(Math.Max(-1f, e.Properties.FirstOrDefault()?.Severity ?? -1f) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnItemClicked(ReportViewModel viewModel) {
|
public void OnItemClicked(ReportViewModel viewModel) {
|
||||||
int index = _displayingReports.IndexOf(viewModel);
|
int index = _displayingReports.IndexOf(viewModel);
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
|
Reference in New Issue
Block a user