Compare commits
8 Commits
04ba735ea6
...
75124a4f62
Author | SHA1 | Date | |
---|---|---|---|
75124a4f62 | |||
9193eb9c8c | |||
c0b3449cc8 | |||
d986418927 | |||
0adea1a325 | |||
399fb577f3 | |||
c3cd512611 | |||
f783d45e23 |
3
Assets/Cryville.EEW.Unity/AssemblyInfo.cs
Normal file
3
Assets/Cryville.EEW.Unity/AssemblyInfo.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("0.0.1")]
|
11
Assets/Cryville.EEW.Unity/AssemblyInfo.cs.meta
Normal file
11
Assets/Cryville.EEW.Unity/AssemblyInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c468580e7742d414e96822c2dfe6e4b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Cryville.EEW.Unity {
|
||||
record Config(
|
||||
string SeverityScheme,
|
||||
string SeverityColorMapping,
|
||||
float SeverityColorMappingLuminanceMultiplier,
|
||||
bool UseContinuousColor,
|
||||
string ColorScheme,
|
||||
@@ -16,7 +16,6 @@ namespace Cryville.EEW.Unity {
|
||||
IReadOnlyCollection<EventSourceConfig> EventSources
|
||||
) {
|
||||
public static Config Default => new(
|
||||
"Default",
|
||||
"Default",
|
||||
1f,
|
||||
false,
|
||||
@@ -27,9 +26,9 @@ namespace Cryville.EEW.Unity {
|
||||
true,
|
||||
|
||||
new List<EventSourceConfig> {
|
||||
new JMAAtomEventSourceConfig(),
|
||||
new JMAAtomEventSourceConfig(Array.Empty<string>()),
|
||||
new UpdateCheckerEventSourceConfig(),
|
||||
new WolfxEventSourceConfig(),
|
||||
new WolfxEventSourceConfig(Array.Empty<string>()),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ namespace Cryville.EEW.Unity.Map {
|
||||
_tiles.CacheDir = Application.temporaryCachePath;
|
||||
_camera.orthographicSize = 0.5f / MathF.Max(1, (float)_camera.pixelWidth / _camera.pixelHeight);
|
||||
_elementLayerZ = m_layerElement.transform.position.z;
|
||||
UpdateTransform();
|
||||
_mapElementUpdated = true;
|
||||
}
|
||||
void OnDestroy() {
|
||||
_tiles.Dispose();
|
||||
@@ -39,7 +39,9 @@ namespace Cryville.EEW.Unity.Map {
|
||||
|
||||
static readonly Rect _viewportRect = new(0, 0, 1, 1);
|
||||
Vector3? ppos;
|
||||
bool _mapElementUpdated;
|
||||
void Update() {
|
||||
bool flag = false;
|
||||
var cpos = Input.mousePosition;
|
||||
bool isMouseInViewport = _viewportRect.Contains(_camera.ScreenToViewportPoint(Input.mousePosition));
|
||||
if (Input.GetMouseButtonDown(0) && isMouseInViewport) {
|
||||
@@ -49,18 +51,25 @@ namespace Cryville.EEW.Unity.Map {
|
||||
var delta = _camera.ScreenToWorldPoint(pos0) - _camera.ScreenToWorldPoint(cpos);
|
||||
transform.position += delta;
|
||||
ppos = cpos;
|
||||
UpdateTransform();
|
||||
flag = true;
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0)) {
|
||||
ppos = null;
|
||||
}
|
||||
if (Input.mouseScrollDelta.y != 0 && isMouseInViewport) {
|
||||
Scale *= Mathf.Pow(2, -Input.mouseScrollDelta.y / 8);
|
||||
UpdateTransform();
|
||||
flag = true;
|
||||
}
|
||||
if (_mapElementUpdated) {
|
||||
_mapElementUpdated = false;
|
||||
ZoomToMapElement();
|
||||
flag = true;
|
||||
}
|
||||
if (flag) {
|
||||
UpdateTransform(); // Ensure UpdateTransform is called at most once per frame for tiles to unload correctly
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapElementUpdated() {
|
||||
void ZoomToMapElement() {
|
||||
var aabb = m_layerElement.AABB;
|
||||
if (aabb is not RectangleF b) return;
|
||||
if (b.Width * _camera.pixelHeight < _camera.pixelWidth * b.Height)
|
||||
@@ -70,7 +79,9 @@ namespace Cryville.EEW.Unity.Map {
|
||||
Scale *= 0.6f;
|
||||
if (Scale < 0.01f) Scale = 0.01f;
|
||||
transform.localPosition = new PointF(b.X + b.Width / 2, b.Y + b.Height / 2).ToVector2();
|
||||
UpdateTransform();
|
||||
}
|
||||
public void OnMapElementUpdated() {
|
||||
_mapElementUpdated = true;
|
||||
}
|
||||
|
||||
void UpdateTransform() {
|
||||
|
@@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: 5
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
@@ -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);
|
||||
|
@@ -69,11 +69,14 @@ namespace Cryville.EEW.Unity {
|
||||
"Legacy" => new LegacySeverityScheme(),
|
||||
_ => throw new InvalidOperationException("Unknown severity scheme."),
|
||||
};
|
||||
SeverityColorMapping = config.SeverityColorMapping switch {
|
||||
SeverityColorMapping = config.ColorScheme switch {
|
||||
"Default" => new DefaultSeverityColorMapping(config.SeverityColorMappingLuminanceMultiplier),
|
||||
"SREV" => new SREVSeverityColorMapping(config.SeverityColorMappingLuminanceMultiplier),
|
||||
"SREVBorder" => new SREVBorderSeverityColorMapping(config.SeverityColorMappingLuminanceMultiplier),
|
||||
_ => throw new InvalidOperationException("Unknown severity color mapping."),
|
||||
"DichromaticYB" => new DichromaticSeverityColorMapping(0.62f, 0.20f, 90, config.SeverityColorMappingLuminanceMultiplier),
|
||||
"DichromaticRC" => new DichromaticSeverityColorMapping(0.62f, 0.25f, 30, config.SeverityColorMappingLuminanceMultiplier),
|
||||
"DichromaticPG" => new DichromaticSeverityColorMapping(0.62f, 0.30f, -30, config.SeverityColorMappingLuminanceMultiplier),
|
||||
"Monochromatic" => new MonochromaticSeverityColorMapping(config.SeverityColorMappingLuminanceMultiplier),
|
||||
_ => throw new InvalidOperationException("Unknown color scheme."),
|
||||
};
|
||||
UseContinuousColor = config.UseContinuousColor;
|
||||
ColorScheme = config.ColorScheme switch {
|
||||
|
@@ -79,15 +79,15 @@ namespace Cryville.EEW.Unity.UI {
|
||||
m_currentView.SetViewModel(e, true);
|
||||
var keyProp = e.Properties.FirstOrDefault();
|
||||
_displayingViews[_index].SetCurrent(true);
|
||||
_tickDown = Math.Max(0, keyProp?.Severity ?? 0) * 4 + 4;
|
||||
_tickDown = MathF.Exp(Math.Max(-1f, keyProp?.Severity ?? -1f) + 1);
|
||||
m_currentView.gameObject.SetActive(true);
|
||||
Worker.Instance.SetCurrent(e);
|
||||
}
|
||||
public void SetCurrent(ReportViewModel viewModel) {
|
||||
public void OnItemClicked(ReportViewModel viewModel) {
|
||||
int index = _displayingReports.IndexOf(viewModel);
|
||||
if (index == -1) return;
|
||||
SwitchTo(index);
|
||||
Worker.Instance.SetSelected(viewModel);
|
||||
Worker.Instance.SetSelected(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ namespace Cryville.EEW.Unity.UI {
|
||||
m_button.onClick.AddListener(OnViewClicked);
|
||||
}
|
||||
void OnViewClicked() {
|
||||
EventOngoingListView.Instance.SetCurrent(_viewModel);
|
||||
EventOngoingListView.Instance.OnItemClicked(_viewModel);
|
||||
}
|
||||
void Update() {
|
||||
_dockRatioTweener.Advance(Time.deltaTime);
|
||||
|
@@ -163,7 +163,8 @@ namespace Cryville.EEW.Unity {
|
||||
readonly ConcurrentQueue<Action> _uiActionQueue = new();
|
||||
ReportViewModel _latestHistoryReport;
|
||||
void OnReported(object sender, ReportViewModel e) {
|
||||
Debug.Log(e);
|
||||
if (e.Model is Exception && e.Model is not SourceWorkerNetworkException)
|
||||
Debug.LogError(e);
|
||||
_ongoingReportManager.Report(e);
|
||||
_uiActionQueue.Enqueue(() => {
|
||||
m_mapElementManager.SetSelected(e);
|
||||
@@ -176,20 +177,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();
|
||||
});
|
||||
}
|
||||
@@ -205,8 +206,9 @@ namespace Cryville.EEW.Unity {
|
||||
m_cameraController.OnMapElementUpdated();
|
||||
}
|
||||
public void SetCurrent(ReportViewModel e) {
|
||||
m_mapElementManager.SetCurrent(e);
|
||||
m_cameraController.OnMapElementUpdated();
|
||||
if (m_mapElementManager.SetCurrent(e)) {
|
||||
m_cameraController.OnMapElementUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
void Update() {
|
||||
|
@@ -1368,7 +1368,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 1180, y: 620}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1925427753
|
||||
MonoBehaviour:
|
||||
|
Reference in New Issue
Block a user