feat: Sync map to current ongoing event
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Cryville.EEW.Core;
|
||||
using Cryville.EEW.Core.Map;
|
||||
using Cryville.EEW.CWAOpenData.Map;
|
||||
using Cryville.EEW.GlobalQuake.Map;
|
||||
using Cryville.EEW.JMAAtom.Map;
|
||||
@@ -18,6 +17,7 @@ using UnityMapElement = Cryville.EEW.Unity.Map.Element.MapElement;
|
||||
namespace Cryville.EEW.Unity.Map {
|
||||
sealed class MapElementManager : MonoBehaviour {
|
||||
ReportViewModel _selected;
|
||||
ReportViewModel _current;
|
||||
readonly List<UnityMapElement> _displayingElements = new();
|
||||
readonly List<ReportViewModel> _displayingReports = new();
|
||||
readonly List<int> _displayingOrder = new();
|
||||
@@ -26,29 +26,31 @@ namespace Cryville.EEW.Unity.Map {
|
||||
|
||||
public RectangleF? AABB {
|
||||
get {
|
||||
RectangleF? ret = null;
|
||||
foreach (var element in _displayingElements) {
|
||||
if (element == null) continue;
|
||||
if (element.AABB is not RectangleF aabb) continue;
|
||||
if (ret == null) ret = aabb; // TODO dynamic
|
||||
else ret = MapTileUtils.UnionTileAABBs(ret.Value, aabb);
|
||||
}
|
||||
return ret;
|
||||
if (_selected != null) return AABBOf(_selected);
|
||||
if (_current != null) return AABBOf(_current);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
RectangleF? AABBOf(ReportViewModel e) {
|
||||
int index = _displayingReports.IndexOf(e);
|
||||
if (index == -1) return null;
|
||||
return _displayingElements[index].AABB;
|
||||
}
|
||||
|
||||
public void AddOngoing(ReportViewModel e) => Add(e);
|
||||
public void RemoveOngoing(ReportViewModel e) => Remove(e);
|
||||
public void SetSelected(ReportViewModel e) {
|
||||
if (_selected is not null)
|
||||
Remove(_selected);
|
||||
if (_displayingReports.Contains(e)) {
|
||||
if (e == null || _displayingReports.Contains(e)) {
|
||||
_selected = null;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
Add(e);
|
||||
_selected = e;
|
||||
}
|
||||
Add(e);
|
||||
_selected = e;
|
||||
}
|
||||
public void SetCurrent(ReportViewModel e) {
|
||||
_current = e;
|
||||
}
|
||||
|
||||
void Add(ReportViewModel e) {
|
||||
|
@@ -79,6 +79,7 @@ namespace Cryville.EEW.Unity.UI {
|
||||
_displayingViews[_index].SetCurrent(true);
|
||||
_tickDown = Math.Max(0, keyProp?.Severity ?? 0) * 4 + 4;
|
||||
m_currentView.gameObject.SetActive(true);
|
||||
Worker.Instance.SetCurrent(e);
|
||||
}
|
||||
public void SetCurrent(ReportViewModel viewModel) {
|
||||
int index = _displayingReports.IndexOf(viewModel);
|
||||
|
@@ -1,12 +1,10 @@
|
||||
using Cryville.Common.Unity.UI;
|
||||
using Cryville.EEW.Report;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Utils;
|
||||
using static UnityEditor.Profiling.HierarchyFrameDataView;
|
||||
|
||||
namespace Cryville.EEW.Unity.UI {
|
||||
class EventOngoingView : MonoBehaviour {
|
||||
|
@@ -147,6 +147,10 @@ namespace Cryville.EEW.Unity {
|
||||
m_mapElementManager.SetSelected(e);
|
||||
m_cameraController.OnMapElementUpdated();
|
||||
}
|
||||
public void SetCurrent(ReportViewModel e) {
|
||||
m_mapElementManager.SetCurrent(e);
|
||||
m_cameraController.OnMapElementUpdated();
|
||||
}
|
||||
|
||||
void Update() {
|
||||
while (_uiActionQueue.TryDequeue(out var action)) {
|
||||
|
Reference in New Issue
Block a user