diff --git a/Assets/Cryville/Common/Unity/CallHelper.cs b/Assets/Cryville/Common/Unity/CallHelper.cs index 4d85c87..5463f75 100644 --- a/Assets/Cryville/Common/Unity/CallHelper.cs +++ b/Assets/Cryville/Common/Unity/CallHelper.cs @@ -9,14 +9,6 @@ namespace Cryville.Common.Unity { return (num2 & num) == num; } - public static void ShowException(Exception ex) { - ShowMessageBox(ex.ToString()); - } - - public static void ShowMessageBox(string message) { - GameObject.Instantiate(Resources.Load("Common/Popup")).GetComponent().Message = message; - } - public static void Purge(Transform obj) { foreach (Transform i in obj) GameObject.Destroy(i.gameObject); diff --git a/Assets/Cryville/Common/Unity/Popup.cs b/Assets/Cryville/Common/Unity/Popup.cs deleted file mode 100644 index bb5fb1b..0000000 --- a/Assets/Cryville/Common/Unity/Popup.cs +++ /dev/null @@ -1,34 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; - -namespace Cryville.Common.Unity { - public class Popup : MonoBehaviour { - - public string Message = ""; - - LayoutElement layout; - - float timer = 0; - - const float DURATION = 5.0f; - const float DURIN = 0.4f; - const float DUROUT = 0.4f; - const float HEIGHT = 50f; - -#pragma warning disable IDE0051 - void Start() { - layout = GetComponent(); - GetComponentInChildren().text = Message; - transform.SetParent(GameObject.Find("PopupList").transform); - layout.minHeight = 0; - } - - void Update() { - if (timer <= DURIN) layout.minHeight = timer / DURIN * HEIGHT; - else if (timer >= DURATION) GameObject.Destroy(gameObject); - else if (timer >= DURATION - DUROUT) layout.minHeight = (DURATION - timer) / DUROUT * HEIGHT; - timer += Time.deltaTime; - } -#pragma warning restore IDE0051 - } -} diff --git a/Assets/Cryville/Common/Unity/PropItem.cs b/Assets/Cryville/Common/Unity/PropItem.cs index 5f24887..e0066e9 100644 --- a/Assets/Cryville/Common/Unity/PropItem.cs +++ b/Assets/Cryville/Common/Unity/PropItem.cs @@ -133,10 +133,10 @@ namespace Cryville.Common.Unity { prop.SetValue(Target, v, new object[]{ }); } catch (TargetInvocationException ex) { - CallHelper.ShowMessageBox(ex.InnerException.Message); + // CallHelper.ShowMessageBox(ex.InnerException.Message); } catch (Exception ex) { - CallHelper.ShowMessageBox(ex.Message); + // CallHelper.ShowMessageBox(ex.Message); } } UpdateValue(); diff --git a/Assets/Cryville/Crtr/Browsing/LegacyResourceManager.cs b/Assets/Cryville/Crtr/Browsing/LegacyResourceManager.cs index e136ec6..7f8786d 100644 --- a/Assets/Cryville/Crtr/Browsing/LegacyResourceManager.cs +++ b/Assets/Cryville/Crtr/Browsing/LegacyResourceManager.cs @@ -121,7 +121,7 @@ namespace Cryville.Crtr.Browsing { resources = converter.ConvertFrom(file); } catch (Exception ex) { - CallHelper.ShowMessageBox(ex.Message); + Popup.Create(ex.Message); return false; } foreach (var res in resources) { diff --git a/Assets/Cryville/Crtr/Browsing/ResourceBrowser.cs b/Assets/Cryville/Crtr/Browsing/ResourceBrowser.cs index 44ad453..503be2a 100644 --- a/Assets/Cryville/Crtr/Browsing/ResourceBrowser.cs +++ b/Assets/Cryville/Crtr/Browsing/ResourceBrowser.cs @@ -59,11 +59,11 @@ namespace Cryville.Crtr.Browsing { private void OnAddDialogClosed() { if (_dialog.FileName == null) return; if (ResourceManager.ImportItemFrom(_dialog.FileName)) { - CallHelper.ShowMessageBox("Import succeeded"); + Popup.Create("Import succeeded"); OnPathClicked(ResourceManager.CurrentDirectory.Length - 1); } else { - CallHelper.ShowMessageBox("Import failed"); + Popup.Create("Import failed"); } } } diff --git a/Assets/Cryville/Crtr/ChartPlayer.cs b/Assets/Cryville/Crtr/ChartPlayer.cs index ba06139..766657c 100644 --- a/Assets/Cryville/Crtr/ChartPlayer.cs +++ b/Assets/Cryville/Crtr/ChartPlayer.cs @@ -142,6 +142,7 @@ namespace Cryville.Crtr { } catch (Exception ex) { Game.LogException("Game", "An error occured while playing", ex); + Popup.CreateException(ex); Stop(); } } @@ -396,6 +397,7 @@ namespace Cryville.Crtr { } catch (Exception ex) { Game.LogException("Load/Prehandle", "An error occured while prehandling the data", ex); + Popup.CreateException(ex); Stop(); } } @@ -417,6 +419,7 @@ namespace Cryville.Crtr { catch (Exception ex) { if (!logEnabled) ToggleLogs(); Game.LogException("Game", "An error occured while stopping", ex); + Popup.CreateException(ex); } finally { if (started) { diff --git a/Assets/Cryville/Crtr/Popup.cs b/Assets/Cryville/Crtr/Popup.cs new file mode 100644 index 0000000..3bf6957 --- /dev/null +++ b/Assets/Cryville/Crtr/Popup.cs @@ -0,0 +1,39 @@ +using System; +using UnityEditor.VersionControl; +using UnityEngine; +using UnityEngine.UI; + +namespace Cryville.Crtr { + public class Popup : MonoBehaviour { + public string Message = ""; + CanvasGroup group; + float timer = 0; + + const float DURATION = 5.0f; + const float DURIN = 0.4f; + const float DUROUT = 0.4f; + + void Start() { + group = GetComponent(); + group.alpha = 0; + GetComponentInChildren().text = Message; + transform.SetParent(GameObject.Find("PopupList").transform); + } + + void Update() { + if (timer <= DURIN) group.alpha = timer / DURIN; + else if (timer >= DURATION) GameObject.Destroy(gameObject); + else if (timer >= DURATION - DUROUT) group.alpha = (DURATION - timer) / DUROUT; + timer += Time.deltaTime; + } + + + public static void CreateException(Exception ex) { + Create(ex.Message); + } + + public static void Create(string msg) { + Instantiate(Resources.Load("Common/Popup")).GetComponent().Message = msg; + } + } +} diff --git a/Assets/Cryville/Common/Unity/Popup.cs.meta b/Assets/Cryville/Crtr/Popup.cs.meta similarity index 100% rename from Assets/Cryville/Common/Unity/Popup.cs.meta rename to Assets/Cryville/Crtr/Popup.cs.meta diff --git a/Assets/Menu.unity b/Assets/Menu.unity index 4c700bf..8036f37 100644 Binary files a/Assets/Menu.unity and b/Assets/Menu.unity differ diff --git a/Assets/Resources/Common/Popup.prefab b/Assets/Resources/Common/Popup.prefab index 30f4ecd..4019e2e 100644 Binary files a/Assets/Resources/Common/Popup.prefab and b/Assets/Resources/Common/Popup.prefab differ