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