Skip to content

Commit

Permalink
优化:【封版本】版本号0.1.0。
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiTingHu committed Jun 16, 2020
1 parent a2d78d1 commit 7379872
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Editor/Utility/AdminLogin/AdminLoginWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace HT.Framework
/// <summary>
/// 管理员身份登录窗口
/// </summary>
public sealed class AdminLoginWindow : HTFEditorWindow
internal sealed class AdminLoginWindow : HTFEditorWindow
{
public static void OpenWindow(IAdminLoginWindow parent)
{
Expand Down
2 changes: 1 addition & 1 deletion Editor/Utility/AdminLogin/IAdminLoginWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// 拥有管理员模式的窗口
/// </summary>
public interface IAdminLoginWindow
internal interface IAdminLoginWindow
{
/// <summary>
/// 是否是管理员模式
Expand Down
30 changes: 6 additions & 24 deletions Editor/Utility/System/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static void OnEditorStart()
private GUIContent _androidGUIContent;
private GUIContent _webglGUIContent;
private VersionInfo _versionInfo;
private string _version;
private string _versionNumber;
private bool _isShowOnStart;
private Vector2 _scroll;

Expand Down Expand Up @@ -72,7 +72,7 @@ private void OnEnable()
private void ReadCurrentVersion()
{
_versionInfo = AssetDatabase.LoadAssetAtPath<VersionInfo>("Assets/HTFramework/Editor/Utility/Version/Version.asset");
_version = _versionInfo.CurrentVersion.GetFullNumber();
_versionNumber = _versionInfo.CurrentVersion.GetFullNumber();
_isShowOnStart = EditorPrefs.GetBool(EditorPrefsTable.AboutIsShowOnStart, true);
}

Expand All @@ -88,7 +88,7 @@ protected override void OnBodyGUI()
private void LOGOGUI()
{
GUI.DrawTexture(new Rect(10, 0, 400, 100), _frameworkLogo);
GUI.Label(new Rect(80, 100, 100, 20), "Version: " + _version);
GUI.Label(new Rect(80, 100, 100, 20), "Version: " + _versionNumber);
if (GUI.Button(new Rect(200, 100, 120, 16), "Previous Versions", EditorGlobalTools.Styles.MiniPopup))
{
VersionViewer.OpenWindow(_versionInfo);
Expand Down Expand Up @@ -127,21 +127,9 @@ private void AboutGUI()

GUILayout.BeginHorizontal();
GUILayout.Label("Supported Runtime Platforms: ");
for (int i = 0; i < _versionInfo.CurrentVersion.Platforms.Count; i++)
{
switch (_versionInfo.CurrentVersion.Platforms[i])
{
case Platform.PC:
GUILayout.Label(_pcGUIContent, EditorGlobalTools.Styles.Wordwrapminibutton);
break;
case Platform.Android:
GUILayout.Label(_androidGUIContent, EditorGlobalTools.Styles.Wordwrapminibutton);
break;
case Platform.WebGL:
GUILayout.Label(_webglGUIContent, EditorGlobalTools.Styles.Wordwrapminibutton);
break;
}
}
GUILayout.Label(_pcGUIContent, EditorGlobalTools.Styles.Wordwrapminibutton);
GUILayout.Label(_androidGUIContent, EditorGlobalTools.Styles.Wordwrapminibutton);
GUILayout.Label(_webglGUIContent, EditorGlobalTools.Styles.Wordwrapminibutton);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();

Expand All @@ -162,12 +150,6 @@ private void AboutGUI()

GUILayout.BeginHorizontal();
GUI.color = Color.yellow;
if (GUILayout.Button("Check for the latest updates", EditorGlobalTools.Styles.Label))
{
Application.OpenURL("https://github.com/SaiTingHu/HTFramework/commits/master");
}
EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
GUILayout.Space(10);
if (GUILayout.Button("Copyright (c) 2019 HuTao", EditorGlobalTools.Styles.Label))
{
Application.OpenURL("https://github.com/SaiTingHu/HTFramework/blob/master/LICENSE");
Expand Down
29 changes: 2 additions & 27 deletions Editor/Utility/Version/Version.asset
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,8 @@ MonoBehaviour:
MajorNumber: 0
MinorNumber: 1
ReviseNumber: 0
ReleaseNotes: "1.\u53D1\u884C\u7684\u7B2C\u4E00\u4E2A\u7A33\u5B9A\u7248\u3002\r\n\u98CE\u534E\u7EDD\u4EE3\u548C\u7FFB\u6C5F\u5012\u6D77\u53D1\u5EFA\u534E\u5927\u8857\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE\r\n\u5C31\u770B\u5F97\u89C1\u98DE"
Platforms: 010000000200000003000000
ReleaseNotes: "1.\u53D1\u884C\u7684\u7B2C\u4E00\u4E2A\u7A33\u5B9A\u7248\u672C\u3002"
UnityVersions: 2018.3.0 or higher
ScriptingVersions: .NET 4.x Equivalent
APIVersions: .NET 4.x
PreviousVersions:
- MajorNumber: 0
MinorNumber: 1
ReviseNumber: 2
ReleaseNotes: "11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n0"
Platforms:
UnityVersions:
ScriptingVersions:
APIVersions:
- MajorNumber: 0
MinorNumber: 1
ReviseNumber: 3
ReleaseNotes: "11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n1"
Platforms:
UnityVersions:
ScriptingVersions:
APIVersions:
- MajorNumber: 0
MinorNumber: 1
ReviseNumber: 4
ReleaseNotes: "11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n11111111111111111111111\r\n1111111111111111111111111111\r\n111111111111111111111111111111\r\n2"
Platforms:
UnityVersions:
ScriptingVersions:
APIVersions:
PreviousVersions: []
27 changes: 6 additions & 21 deletions Editor/Utility/Version/Version.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;

namespace HT.Framework
{
Expand All @@ -24,41 +23,27 @@ internal sealed class Version
/// <summary>
/// 发行说明
/// </summary>
public string ReleaseNotes;
/// <summary>
/// 版本号支持的平台
/// </summary>
public List<Platform> Platforms = new List<Platform>();
public string ReleaseNotes = "";
/// <summary>
/// 版本号支持的Unity版本
/// </summary>
public string UnityVersions;
public string UnityVersions = "2018.3.0 or higher";
/// <summary>
/// 版本号支持的运行时编码.Net版本
/// </summary>
public string ScriptingVersions;
public string ScriptingVersions = ".NET 4.x Equivalent";
/// <summary>
/// 版本号支持的.Net API版本
/// </summary>
public string APIVersions;

public string APIVersions = ".NET 4.x";
/// <summary>
/// 获取完成的版本号
/// 获取完整的版本号
/// </summary>
/// <returns>版本号</returns>
public string GetFullNumber()
{
return string.Format("{0}.{1}.{2}", MajorNumber, MinorNumber, ReviseNumber);
}
}

/// <summary>
/// 版本支持的平台
/// </summary>
internal enum Platform
{
PC = 1,
Android = 2,
WebGL = 3
}
}
101 changes: 100 additions & 1 deletion Editor/Utility/Version/VersionViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal sealed class VersionViewer : HTFEditorWindow, IAdminLoginWindow
public static void OpenWindow(VersionInfo info)
{
VersionViewer window = GetWindow<VersionViewer>();
window.titleContent.image = EditorGUIUtility.IconContent("d_ViewToolZoom On").image;
window.titleContent.text = "Version Viewer";
window._versionInfo = info;
window._version = info.PreviousVersions.Count > 0 ? info.PreviousVersions[0] : null;
Expand All @@ -22,6 +23,8 @@ public static void OpenWindow(VersionInfo info)
private VersionInfo _versionInfo;
private Version _version;
private string _versionNumber;
private bool _isRelease = false;
private Version _releaseVersion;
private Vector2 _scroll;

public bool IsAdminMode { get; set; } = false;
Expand Down Expand Up @@ -110,6 +113,24 @@ private void VersionGUI()
gm.ShowAsContext();
GUI.FocusControl(null);
}
if (IsAdminMode)
{
GUI.backgroundColor = _adminModeColor;
if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.Width(50)))
{
if (EditorUtility.DisplayDialog("Prompt", "Are you sure you want to delete this version?", "Yes", "No"))
{
if (_version != null)
{
_versionInfo.PreviousVersions.Remove(_version);
_version = _versionInfo.PreviousVersions.Count > 0 ? _versionInfo.PreviousVersions[0] : null;
_versionNumber = _version != null ? _version.GetFullNumber() : "<None>";
HasChanged(_versionInfo);
}
}
}
GUI.backgroundColor = Color.white;
}
GUI.enabled = true;
GUILayout.EndHorizontal();

Expand All @@ -121,15 +142,93 @@ private void VersionGUI()

GUILayout.BeginVertical();
_scroll = GUILayout.BeginScrollView(_scroll);
EditorGUILayout.TextArea(_version.ReleaseNotes);
GUILayout.Label(_version.ReleaseNotes);
GUILayout.EndScrollView();
GUILayout.EndVertical();
}

if (IsAdminMode)
{
GUI.backgroundColor = _adminModeColor;

GUILayout.BeginHorizontal();
GUI.enabled = !_isRelease;
if (GUILayout.Button("Version Release"))
{
_isRelease = true;
}
GUI.enabled = true;
GUILayout.EndHorizontal();

if (_isRelease)
{
ReleaseGUI();
}

GUI.backgroundColor = Color.white;
}
}

private void ReleaseGUI()
{
if (_releaseVersion == null)
{
_releaseVersion = new Version();
}

GUILayout.BeginHorizontal();
GUILayout.Label("Version Number: ", GUILayout.Width(180));
_releaseVersion.MajorNumber = EditorGUILayout.IntField(_releaseVersion.MajorNumber);
_releaseVersion.MinorNumber = EditorGUILayout.IntField(_releaseVersion.MinorNumber);
_releaseVersion.ReviseNumber = EditorGUILayout.IntField(_releaseVersion.ReviseNumber);
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("Supported Unity Versions: ", GUILayout.Width(180));
_releaseVersion.UnityVersions = EditorGUILayout.TextField(_releaseVersion.UnityVersions);
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("Scripting Runtime Versions: ", GUILayout.Width(180));
_releaseVersion.ScriptingVersions = EditorGUILayout.TextField(_releaseVersion.ScriptingVersions);
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("Api Compatibility Level: ", GUILayout.Width(180));
_releaseVersion.APIVersions = EditorGUILayout.TextField(_releaseVersion.APIVersions);
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("Release Notes:");
GUILayout.EndHorizontal();

GUILayout.BeginVertical();
_releaseVersion.ReleaseNotes = EditorGUILayout.TextArea(_releaseVersion.ReleaseNotes);
GUILayout.EndVertical();

GUILayout.BeginHorizontal();
if (GUILayout.Button("Release", EditorStyles.miniButtonLeft))
{
if (EditorUtility.DisplayDialog("Prompt", "Are you sure you want to release new version?Current version will be changed to [" + _releaseVersion.GetFullNumber() + "]!", "Yes", "No"))
{
_versionInfo.PreviousVersions.Add(_versionInfo.CurrentVersion);
_versionInfo.CurrentVersion = _releaseVersion;
_releaseVersion = null;
_isRelease = false;
HasChanged(_versionInfo);
}
}
if (GUILayout.Button("Cancel", EditorStyles.miniButtonRight))
{
_isRelease = false;
}
GUILayout.EndHorizontal();
}

public void AdminCheck(string password)
{
IsAdminMode = MathfToolkit.MD5Encrypt(password) == Password;
_isRelease = false;
GUI.changed = true;

if (!IsAdminMode)
Expand Down

0 comments on commit 7379872

Please sign in to comment.