Files
XCharts/Editor/Window/CheckVersionEditor.cs

108 lines
4.0 KiB
C#
Raw Normal View History

2021-01-11 08:54:28 +08:00
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
2019-10-23 18:59:34 +08:00
using UnityEditor;
using UnityEngine;
namespace XCharts
{
public class CheckVersionEditor : EditorWindow
{
private Vector2 scrollPos;
private static CheckVersionEditor window;
2021-01-11 08:54:28 +08:00
[MenuItem("XCharts/Upgrade Check")]
2020-05-24 08:06:40 +08:00
public static void ShowWindow()
2019-10-23 18:59:34 +08:00
{
window = GetWindow<CheckVersionEditor>();
2021-01-11 08:54:28 +08:00
window.titleContent = new GUIContent("XCharts Upgrade Check");
2019-10-23 18:59:34 +08:00
window.minSize = new Vector2(550, window.minSize.y);
window.Show();
XChartsMgr.Instance.CheckVersion();
}
2020-05-24 08:06:40 +08:00
void OnInspectorUpdate()
{
Repaint();
}
2019-10-23 18:59:34 +08:00
private void OnGUI()
{
var mgr = XChartsMgr.Instance;
GUILayout.Label("");
2021-01-11 08:54:28 +08:00
GUILayout.Label("The current version: " + mgr.nowVersion);
2019-10-23 18:59:34 +08:00
if (mgr.needUpdate && !mgr.isCheck)
{
2021-01-25 09:12:22 +08:00
GUILayout.Label("The remote version: " + mgr.newVersion);
2020-05-24 08:06:40 +08:00
GUILayout.Label("");
2021-01-11 08:54:28 +08:00
if (mgr.isCheck) GUILayout.Label("check ...");
else if (mgr.isNetworkError) GUILayout.Label("check failed: " + mgr.networkError);
2020-05-24 08:06:40 +08:00
else
2019-10-23 18:59:34 +08:00
{
2021-01-11 08:54:28 +08:00
GUILayout.Label("There is a new version to upgrade!");
2019-10-23 18:59:34 +08:00
}
GUILayout.Label("");
if (!string.IsNullOrEmpty(mgr.desc))
{
GUILayout.Label(mgr.desc);
}
2021-01-11 08:54:28 +08:00
if (GUILayout.Button("Github Homepage"))
2020-05-24 08:06:40 +08:00
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
}
2021-01-11 08:54:28 +08:00
if (GUILayout.Button("Star Support"))
2020-05-24 08:06:40 +08:00
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
}
2021-01-11 08:54:28 +08:00
if (GUILayout.Button("Issues"))
2020-05-24 08:06:40 +08:00
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
}
if (!string.IsNullOrEmpty(mgr.changeLog))
{
scrollPos = GUILayout.BeginScrollView(scrollPos);
GUILayout.TextArea(mgr.changeLog);
GUILayout.EndScrollView();
}
2019-10-23 18:59:34 +08:00
}
else
{
2021-01-25 09:12:22 +08:00
if (mgr.isCheck) GUILayout.Label("The remote version: checking ...");
2021-01-11 08:54:28 +08:00
else if (mgr.isNetworkError) GUILayout.Label("check failed: " + mgr.networkError);
2021-01-25 09:12:22 +08:00
else GUILayout.Label("The remote version: " + mgr.newVersion);
2019-10-23 18:59:34 +08:00
2020-04-09 08:02:46 +08:00
GUILayout.Label("");
if (!mgr.isNetworkError && !mgr.needUpdate && !mgr.isCheck)
2019-10-23 18:59:34 +08:00
{
2021-01-11 08:54:28 +08:00
GUILayout.Label("It is the latest version!");
2020-04-09 08:02:46 +08:00
}
GUILayout.Label("");
if (!string.IsNullOrEmpty(mgr.desc))
{
GUILayout.Label(mgr.desc);
}
2021-01-11 08:54:28 +08:00
if (GUILayout.Button("Github Homepage"))
2020-04-09 08:02:46 +08:00
{
2020-05-24 08:06:40 +08:00
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
}
2021-01-11 08:54:28 +08:00
if (GUILayout.Button("Star Support"))
2020-05-24 08:06:40 +08:00
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
}
2021-01-11 08:54:28 +08:00
if (GUILayout.Button("Issues"))
2020-05-24 08:06:40 +08:00
{
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
2020-04-09 08:02:46 +08:00
}
2021-01-11 08:54:28 +08:00
if (mgr.isNetworkError && GUILayout.Button("Check Again"))
2020-04-09 08:02:46 +08:00
{
XChartsMgr.Instance.CheckVersion();
2019-10-23 18:59:34 +08:00
}
}
}
}
}