feat: Draft ongoing list view
This commit is contained in:
52
Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs
Normal file
52
Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using Cryville.EEW.Report;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Cryville.EEW.Unity.UI {
|
||||||
|
class EventOngoingListView : MonoBehaviour {
|
||||||
|
[SerializeField] EventReportView m_currentView;
|
||||||
|
|
||||||
|
readonly List<ReportViewModel> _displayingReports = new();
|
||||||
|
|
||||||
|
public void Add(ReportViewModel e) {
|
||||||
|
_displayingReports.Add(e);
|
||||||
|
SwitchTo(_displayingReports.Count - 1);
|
||||||
|
}
|
||||||
|
public void Remove(ReportViewModel e) {
|
||||||
|
int index = _displayingReports.IndexOf(e);
|
||||||
|
if (index == -1) return;
|
||||||
|
_displayingReports.RemoveAt(index);
|
||||||
|
if (_displayingReports.Count == 0) {
|
||||||
|
m_currentView.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (_index > index) --_index;
|
||||||
|
else if (_index == index) SwitchTo(index % _displayingReports.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
m_currentView.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _index;
|
||||||
|
float _tickDown;
|
||||||
|
void Update() {
|
||||||
|
if (_displayingReports.Count == 0) return;
|
||||||
|
_tickDown -= Time.deltaTime;
|
||||||
|
if (_tickDown < 0) {
|
||||||
|
SwitchTo((_index + 1) % _displayingReports.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void SwitchTo(int index) {
|
||||||
|
_index = index;
|
||||||
|
var e = _displayingReports[index];
|
||||||
|
m_currentView.SetViewModel(e);
|
||||||
|
var keyProp = e.Properties.FirstOrDefault();
|
||||||
|
_tickDown = Math.Max(0, keyProp?.Severity ?? 0) * 4 + 4;
|
||||||
|
m_currentView.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs.meta
Normal file
11
Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a0bef35c7c4889f4a895fe709447b867
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -23,12 +23,10 @@ namespace Cryville.EEW.Unity {
|
|||||||
sealed class Worker : MonoBehaviour {
|
sealed class Worker : MonoBehaviour {
|
||||||
public static Worker Instance { get; private set; }
|
public static Worker Instance { get; private set; }
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField] CameraController m_cameraController;
|
||||||
CameraController m_cameraController;
|
[SerializeField] MapElementManager m_mapElementManager;
|
||||||
[SerializeField]
|
[SerializeField] EventOngoingListView m_ongoingEventList;
|
||||||
MapElementManager m_mapElementManager;
|
[SerializeField] EventGroupListView m_historyEventGroupList;
|
||||||
[SerializeField]
|
|
||||||
EventGroupListView m_historyEventGroupList;
|
|
||||||
|
|
||||||
GroupingCoreWorker _worker;
|
GroupingCoreWorker _worker;
|
||||||
CancellationTokenSource _cancellationTokenSource;
|
CancellationTokenSource _cancellationTokenSource;
|
||||||
@@ -127,10 +125,16 @@ 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(() => m_mapElementManager.AddOngoing(item));
|
_uiActionQueue.Enqueue(() => {
|
||||||
|
m_mapElementManager.AddOngoing(item);
|
||||||
|
m_ongoingEventList.Add(item);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (action == CollectionChangeAction.Remove) {
|
else if (action == CollectionChangeAction.Remove) {
|
||||||
_uiActionQueue.Enqueue(() => m_mapElementManager.RemoveOngoing(item));
|
_uiActionQueue.Enqueue(() => {
|
||||||
|
m_mapElementManager.RemoveOngoing(item);
|
||||||
|
m_ongoingEventList.Remove(item);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OnGroupUpdated(object sender, ReportGroup e) {
|
void OnGroupUpdated(object sender, ReportGroup e) {
|
||||||
|
2603
Assets/Main.unity
2603
Assets/Main.unity
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user