fix: Fix ongoing event cycling logic
This commit is contained in:
@@ -39,19 +39,39 @@ namespace Cryville.EEW.Unity.Map {
|
||||
return _displayingElements[index].AABB;
|
||||
}
|
||||
|
||||
public void SetSelected(ReportViewModel e) {
|
||||
if (_selected is not null)
|
||||
public void SetSelected(ReportViewModel e, bool forced = false) {
|
||||
if (e == null) {
|
||||
Remove(_selected);
|
||||
if (e == null || _displayingReports.Contains(e)) {
|
||||
_selected = null;
|
||||
return;
|
||||
}
|
||||
if (_displayingReports.Contains(e)) {
|
||||
if (forced) return;
|
||||
Remove(_selected);
|
||||
_selected = null;
|
||||
return;
|
||||
}
|
||||
if (e.IsExcludedFromHistory)
|
||||
return;
|
||||
if (!Add(e))
|
||||
return;
|
||||
if (_selected is not null)
|
||||
Remove(_selected);
|
||||
_selected = e;
|
||||
}
|
||||
public void SetCurrent(ReportViewModel e) {
|
||||
public bool SetCurrent(ReportViewModel e) {
|
||||
if (e == null) {
|
||||
_current = null;
|
||||
return true;
|
||||
}
|
||||
if (!_displayingReports.Contains(e)) {
|
||||
_current = null;
|
||||
return false;
|
||||
}
|
||||
if (_current == e)
|
||||
return false;
|
||||
_current = e;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Add(ReportViewModel e) {
|
||||
@@ -68,6 +88,7 @@ namespace Cryville.EEW.Unity.Map {
|
||||
return true;
|
||||
}
|
||||
public void Remove(ReportViewModel e) {
|
||||
if (_current == e) _current = null;
|
||||
int index = _displayingReports.IndexOf(e);
|
||||
if (index == -1) return;
|
||||
_displayingElements.RemoveAt(index);
|
||||
|
@@ -87,7 +87,7 @@ namespace Cryville.EEW.Unity.UI {
|
||||
int index = _displayingReports.IndexOf(viewModel);
|
||||
if (index == -1) return;
|
||||
SwitchTo(index);
|
||||
Worker.Instance.SetSelected(viewModel);
|
||||
Worker.Instance.SetSelected(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -176,20 +176,20 @@ namespace Cryville.EEW.Unity {
|
||||
void OnOngoingReported(ReportViewModel item, CollectionChangeAction action) {
|
||||
if (action == CollectionChangeAction.Add) {
|
||||
_uiActionQueue.Enqueue(() => {
|
||||
m_ongoingEventList.Add(item);
|
||||
if (m_mapElementManager.Add(item)) {
|
||||
m_mapElementManager.SetSelected(null);
|
||||
}
|
||||
m_ongoingEventList.Add(item);
|
||||
m_cameraController.OnMapElementUpdated();
|
||||
});
|
||||
}
|
||||
else if (action == CollectionChangeAction.Remove) {
|
||||
_uiActionQueue.Enqueue(() => {
|
||||
m_ongoingEventList.Remove(item);
|
||||
m_mapElementManager.Remove(item);
|
||||
if (m_mapElementManager.Count == 0 && SharedSettings.Instance.DoSwitchBackToHistory && _latestHistoryReport is not null) {
|
||||
m_mapElementManager.SetSelected(_latestHistoryReport);
|
||||
m_mapElementManager.SetSelected(_latestHistoryReport, true);
|
||||
}
|
||||
m_ongoingEventList.Remove(item);
|
||||
m_cameraController.OnMapElementUpdated();
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user