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