8 Commits

52 changed files with 150 additions and 33 deletions

View File

@@ -56,7 +56,7 @@ namespace Cryville.Common.Unity.UI {
const float _placeholderLength = 100; const float _placeholderLength = 100;
int _firstIndex, _lastIndex; int _firstIndex, _lastIndex;
readonly Stack<GameObject> _pool = new(); readonly Stack<GameObject> _pool = new();
void Update() { void LateUpdate() {
int axis = (int)m_direction; int axis = (int)m_direction;
int sign = m_direction == 0 ? 1 : -1; int sign = m_direction == 0 ? 1 : -1;
float padding = axis == 0 ? m_padding.left : m_padding.top; float padding = axis == 0 ? m_padding.left : m_padding.top;

View File

@@ -1,3 +1,3 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("0.0.2")] [assembly: AssemblyVersion("0.0.3")]

View File

@@ -98,24 +98,25 @@ namespace Cryville.EEW.Unity.Map.Element {
for (int d = 0; d < 360; d++) { for (int d = 0; d < 360; d++) {
Quaternion q = Quaternion.AngleAxis(d, axis); Quaternion q = Quaternion.AngleAxis(d, axis);
Vector3 p = q * rp; Vector3 p = q * rp;
Vector2 p2 = ToTilePos(p).ToVector2(); AddVertex(renderer, ref lp2, ref segmentIndex, d, p);
if (lp2 != null) {
float dx = p2.x - lp2.Value.x;
if (MathF.Abs(dx) >= 0.5) {
_vertexBuffer[d] = p2.x < 0.5 ? p2 + new Vector2(1, 0) : p2 - new Vector2(1, 0);
renderer.AddSegment(_vertexBuffer, segmentIndex, d - segmentIndex + 1);
segmentIndex = d;
}
}
_vertexBuffer[d] = p2;
lp2 = p2;
} }
Vector2 rp2 = ToTilePos(rp).ToVector2(); AddVertex(renderer, ref lp2, ref segmentIndex, 360, rp);
_vertexBuffer[360] = rp2;
renderer.AddSegment(_vertexBuffer, segmentIndex, 361 - segmentIndex); renderer.AddSegment(_vertexBuffer, segmentIndex, 361 - segmentIndex);
} }
renderer.SetMaterial(isHistory ? m_historyMaterial : m_ongoingMaterial); renderer.SetMaterial(isHistory ? m_historyMaterial : m_ongoingMaterial);
} }
void AddVertex(MultiLineRenderer renderer, ref Vector2? lp2, ref int segmentIndex, int d, Vector3 p) {
Vector2 p2 = ToTilePos(p).ToVector2();
if (lp2 != null && MathF.Abs(p2.x - lp2.Value.x) >= 0.5) {
_vertexBuffer[d] = p2.x < 0.5 ? p2 + new Vector2(1, 0) : p2 - new Vector2(1, 0);
renderer.AddSegment(_vertexBuffer, segmentIndex, d - segmentIndex + 1);
segmentIndex = d;
}
_vertexBuffer[d] = p2;
lp2 = p2;
}
static PointF ToTilePos(Vector3 p) => MapTileUtils.WorldToTilePos(new(MathF.Atan2(p.z, p.x) / MathF.PI * 180f, MathF.Asin(p.y) / MathF.PI * 180f)); static PointF ToTilePos(Vector3 p) => MapTileUtils.WorldToTilePos(new(MathF.Atan2(p.z, p.x) / MathF.PI * 180f, MathF.Asin(p.y) / MathF.PI * 180f));
} }
} }

View File

@@ -150,12 +150,8 @@ namespace Cryville.EEW.Unity.Map {
_mesh.Clear(); _mesh.Clear();
if (_positions == null) return; if (_positions == null) return;
if (_positionCount <= 1) return; if (_positionCount <= 1) return;
float hw = m_width / 2;
int maxVertexCount = 4 * (_positionCount - 1);
var vbuf = ArrayPool<Vector3>.Shared.Rent(maxVertexCount);
var ubuf = ArrayPool<Vector2>.Shared.Rent(maxVertexCount);
var ibuf = ArrayPool<int>.Shared.Rent(3 * (2 + 4 * (_positionCount - 2)));
float hw = m_width / 2;
int i, vi = 0, ii = 0, li = 0, ri = 1; int i, vi = 0, ii = 0, li = 0, ri = 1;
float uvScale = 1 / (m_tilingScale * m_width); float uvScale = 1 / (m_tilingScale * m_width);
Vector2 p0 = _positions[0], p1 = default; Vector2 p0 = _positions[0], p1 = default;
@@ -163,6 +159,12 @@ namespace Cryville.EEW.Unity.Map {
if ((p1 = _positions[i]) != p0) break; if ((p1 = _positions[i]) != p0) break;
} }
if (i >= _positionCount) return; if (i >= _positionCount) return;
int maxVertexCount = 4 * (_positionCount - 1);
var vbuf = ArrayPool<Vector3>.Shared.Rent(maxVertexCount);
var ubuf = ArrayPool<Vector2>.Shared.Rent(maxVertexCount);
var ibuf = ArrayPool<int>.Shared.Rent(3 * (2 + 4 * (_positionCount - 2)));
Vector2 dp0 = NormalizeSmallVector(p1 - p0), np0 = GetNormal(dp0 * hw); Vector2 dp0 = NormalizeSmallVector(p1 - p0), np0 = GetNormal(dp0 * hw);
vbuf[vi] = p0 - np0; ubuf[vi++] = new(0, 0); vbuf[vi] = p0 - np0; ubuf[vi++] = new(0, 0);
vbuf[vi] = p0 + np0; ubuf[vi++] = new(0, 1); vbuf[vi] = p0 + np0; ubuf[vi++] = new(0, 1);

View File

@@ -14,9 +14,12 @@ namespace Cryville.EEW.Unity.UI {
[SerializeField] GameObject m_listViewRail; [SerializeField] GameObject m_listViewRail;
[SerializeField] GameObject m_expander; [SerializeField] GameObject m_expander;
void Start() { void OnEnable() {
m_groupHeader.onClick.AddListener(OnGroupHeaderClicked); m_groupHeader.onClick.AddListener(OnGroupHeaderClicked);
} }
void OnDisable() {
m_groupHeader.onClick.RemoveListener(OnGroupHeaderClicked);
}
void OnGroupHeaderClicked() { void OnGroupHeaderClicked() {
SetExpanded(!m_listViewContainer.activeSelf); SetExpanded(!m_listViewContainer.activeSelf);
} }

View File

@@ -27,7 +27,7 @@ namespace Cryville.EEW.Unity.UI {
} }
void SetView(float mainSeverity, string title, string location, CultureInfo culture) { void SetView(float mainSeverity, string title, string location, CultureInfo culture) {
SetSeverity(mainSeverity); SetSeverity(mainSeverity);
SetText(m_textView, string.Format("{0} {1}", title, location), culture); SetText(m_textView, string.Format(culture, "{0} {1}", title, location), culture);
} }
static void SetText(TMPLocalizedText view, string text, CultureInfo culture) { static void SetText(TMPLocalizedText view, string text, CultureInfo culture) {
if (string.IsNullOrWhiteSpace(text)) { if (string.IsNullOrWhiteSpace(text)) {
@@ -47,9 +47,12 @@ namespace Cryville.EEW.Unity.UI {
void Awake() { void Awake() {
_dockRatioTweener = new(() => m_dockLayoutGroup.DockOccupiedRatio, v => m_dockLayoutGroup.DockOccupiedRatio = v, Tweeners.Single); _dockRatioTweener = new(() => m_dockLayoutGroup.DockOccupiedRatio, v => m_dockLayoutGroup.DockOccupiedRatio = v, Tweeners.Single);
} }
void Start() { void OnEnable() {
m_button.onClick.AddListener(OnViewClicked); m_button.onClick.AddListener(OnViewClicked);
} }
void OnDisable() {
m_button.onClick.RemoveListener(OnViewClicked);
}
void OnViewClicked() { void OnViewClicked() {
EventOngoingListView.Instance.OnItemClicked(_viewModel); EventOngoingListView.Instance.OnItemClicked(_viewModel);
} }

View File

@@ -14,9 +14,12 @@ namespace Cryville.EEW.Unity.UI {
[SerializeField] TMPLocalizedText m_revisionView; [SerializeField] TMPLocalizedText m_revisionView;
ReportViewModel _viewModel; ReportViewModel _viewModel;
protected virtual void Start() { protected virtual void OnEnable() {
if (m_reportViewButton != null) m_reportViewButton.onClick.AddListener(OnViewClicked); if (m_reportViewButton != null) m_reportViewButton.onClick.AddListener(OnViewClicked);
} }
protected virtual void OnDisable() {
if (m_reportViewButton != null) m_reportViewButton.onClick.RemoveListener(OnViewClicked);
}
void OnViewClicked() { void OnViewClicked() {
Worker.Instance.SetSelected(_viewModel); Worker.Instance.SetSelected(_viewModel);
} }

View File

@@ -8,10 +8,14 @@ namespace Cryville.EEW.Unity.UI {
[SerializeField] Button m_revisionViewContainerButton; [SerializeField] Button m_revisionViewContainerButton;
protected override void Start() { protected override void OnEnable() {
base.Start(); base.OnEnable();
m_revisionViewContainerButton.onClick.AddListener(OnRevisionViewClicked); m_revisionViewContainerButton.onClick.AddListener(OnRevisionViewClicked);
} }
protected override void OnDisable() {
base.OnDisable();
m_revisionViewContainerButton.onClick.RemoveListener(OnRevisionViewClicked);
}
void OnRevisionViewClicked() { void OnRevisionViewClicked() {
m_listView.gameObject.SetActive(!m_listView.gameObject.activeSelf); m_listView.gameObject.SetActive(!m_listView.gameObject.activeSelf);
} }

View File

@@ -1,4 +1,5 @@
using System.Globalization; using System.Globalization;
using System.Text;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@@ -11,17 +12,30 @@ namespace Cryville.EEW.Unity.UI {
_textView = GetComponent<TMP_Text>(); _textView = GetComponent<TMP_Text>();
} }
StringBuilder _sb = new();
char[] _buffer = new char[256];
void Update() { void Update() {
_textView.text = string.Format( _sb.Clear();
_sb.AppendFormat(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"FPS: i{0:0} / s{1:0}\nSMem: {2:N0} / {3:N0}\nIMem: {4:N0} / {5:N0}", "FPS: i{0:0} / s{1:0}\n",
1 / Time.deltaTime, 1 / Time.deltaTime,
1 / Time.smoothDeltaTime, 1 / Time.smoothDeltaTime
);
_sb.AppendFormat(
CultureInfo.InvariantCulture,
"SMem: {0:N0} / {1:N0}\n",
UnityEngine.Profiling.Profiler.GetMonoUsedSizeLong(), UnityEngine.Profiling.Profiler.GetMonoUsedSizeLong(),
UnityEngine.Profiling.Profiler.GetMonoHeapSizeLong(), UnityEngine.Profiling.Profiler.GetMonoHeapSizeLong()
);
_sb.AppendFormat(
CultureInfo.InvariantCulture,
"IMem: {0:N0} / {1:N0}",
UnityEngine.Profiling.Profiler.GetTotalAllocatedMemoryLong(), UnityEngine.Profiling.Profiler.GetTotalAllocatedMemoryLong(),
UnityEngine.Profiling.Profiler.GetTotalReservedMemoryLong() UnityEngine.Profiling.Profiler.GetTotalReservedMemoryLong()
); );
_sb.CopyTo(0, _buffer, _sb.Length);
_textView.SetText(_buffer, 0, _sb.Length);
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Globalization;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@@ -19,7 +18,7 @@ namespace Cryville.EEW.Unity.UI {
time = TimeZoneInfo.ConvertTime(time, timeZone, tTimeZone); time = TimeZoneInfo.ConvertTime(time, timeZone, tTimeZone);
else else
tTimeZone = timeZone; tTimeZone = timeZone;
_textView.text = SharedSettings.Instance.DoDisplayTimeZone ? string.Format(CultureInfo.CurrentCulture, "{0:G} ({1})", time, tTimeZone.ToTimeZoneString()) : time.ToString(CultureInfo.CurrentCulture); _textView.text = SharedSettings.Instance.DoDisplayTimeZone ? string.Format(SharedCultures.CurrentCulture, "{0:G} ({1})", time, tTimeZone.ToTimeZoneString()) : time.ToString(SharedCultures.CurrentCulture);
} }
} }
} }

Binary file not shown.

View File

@@ -0,0 +1,78 @@
fileFormatVersion: 2
guid: 88e8ae9c8ce06934ab7681fb678d7b00
labels:
- RoslynAnalyzer
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1525,6 +1525,16 @@
The culture <c>zh-TW</c>. The culture <c>zh-TW</c>.
</summary> </summary>
</member> </member>
<member name="F:Cryville.EEW.SharedCultures.CurrentCulture">
<summary>
The current culture.
</summary>
</member>
<member name="F:Cryville.EEW.SharedCultures.CurrentUICulture">
<summary>
The current UI culture.
</summary>
</member>
<member name="M:Cryville.EEW.SharedCultures.Get(System.String)"> <member name="M:Cryville.EEW.SharedCultures.Get(System.String)">
<summary> <summary>
Gets a culture of the specified name. Gets a culture of the specified name.

Binary file not shown.

Binary file not shown.

View File

@@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1 16:10: 1
16:9: 1 16:9: 1
Others: 1 Others: 1
bundleVersion: 0.0.2 bundleVersion: 0.0.3
preloadedAssets: [] preloadedAssets: []
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0