Skip to content

Commit

Permalink
Added AboutWindow work
Browse files Browse the repository at this point in the history
  • Loading branch information
jzapdot committed Mar 9, 2020
2 parents 4e78fdf + 86f8211 commit 200205d
Show file tree
Hide file tree
Showing 14 changed files with 394 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Unity/Assets/JCMG/Curves/Docs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Unity/Assets/JCMG/Curves/Docs/Images.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions Unity/Assets/JCMG/Curves/Docs/Images/portrait.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions Unity/Assets/JCMG/Curves/Docs/Images/social_share_image.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Unity/Assets/JCMG/Curves/Scripts/Editor/MenuItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,27 @@ internal static void CreateBezierSpline()

EditorGUIUtility.PingObject(obj.gameObject);
}

[MenuItem("Tools/JCMG/Curves/Submit bug or feature request")]
internal static void OpenURLToGitHubIssuesSection()
{
const string GITHUB_ISSUES_URL = "https://github.com/jeffcampbellmakesgames/unity-curves/issues";

Application.OpenURL(GITHUB_ISSUES_URL);
}

[MenuItem("Tools/JCMG/Curves/Donate to support development")]
internal static void OpenURLToKoFi()
{
const string KOFI_URL = "https://ko-fi.com/stampyturtle";

Application.OpenURL(KOFI_URL);
}

[MenuItem("Tools/JCMG/Curves/About")]
internal static void OpenAboutModalDialog()
{
AboutWindow.View();
}
}
}
11 changes: 11 additions & 0 deletions Unity/Assets/JCMG/Curves/Scripts/Editor/VersionConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace JCMG.Curves.Editor
{
/// <summary>
/// Version info for this library.
/// </summary>
internal static class VersionConstants
{
// Version
public const string VERSION = "1.1.1";
}
}
11 changes: 11 additions & 0 deletions Unity/Assets/JCMG/Curves/Scripts/Editor/VersionConstants.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Unity/Assets/JCMG/Curves/Scripts/Editor/Window.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 126 additions & 0 deletions Unity/Assets/JCMG/Curves/Scripts/Editor/Window/AboutWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using UnityEditor;
using UnityEngine;

namespace JCMG.Curves.Editor
{
/// <summary>
/// A window that shows information about the library and its contributors.
/// </summary>
internal sealed class AboutWindow : EditorWindow
{
#pragma warning disable 0649

[SerializeField]
private Texture2D _socialShareImage;

[SerializeField]
private Texture2D _portraitImage;

#pragma warning restore 0649

private const string WINDOW_TITLE = "JCMG Curves";
private const string VERSION_LABEL = "Version:";
private const string GITHUB_LABEL = "GitHub:";
private const string KOFI_LABEL = "KOFI:";
private const string TWITTER_LABEL = "Twitter:";

private const string GITHUB_URL = "https://github.com/jeffcampbellmakesgames";
private const string KOFI_URL = "https://ko-fi.com/stampyturtle";
private const string TWITTER_URL = "https://twitter.com/StampyTurtle";

private const string SHARE_MESSAGE = "Hi there! My name is Jeff Campbell and I make open source tools for game " +
"developers.\n\nIf you enjoy using this tool and want to support its development " +
"and other high-quality, free open-source tools, follow me on Twitter, " +
"GitHub, and consider buying me a coffee on Ko-Fi.";

public static void View()
{
var window = CreateInstance<AboutWindow>();
window.minSize = new Vector2(512f, 490f);
window.maxSize = window.minSize;
window.titleContent = new GUIContent(WINDOW_TITLE);
window.position = new Rect(
Screen.currentResolution.width / 2f,
Screen.currentResolution.height / 2f,
0f,
0f);
window.ShowUtility();
}

private void OnGUI()
{
// JCMG Share Image
if (_socialShareImage != null)
{
GUILayout.Label(_socialShareImage);

DrawSeparator();
}

// COC Version
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(VERSION_LABEL, EditorStyles.boldLabel, GUILayout.Width(75f));
EditorGUILayout.LabelField(VersionConstants.VERSION);
}

DrawSeparator();

// Share message and portrait
using (new EditorGUILayout.HorizontalScope())
{
if (_portraitImage != null)
{
GUILayout.Label(_portraitImage, GUILayout.Width(96f), GUILayout.Height(96f));
}
EditorGUILayout.SelectableLabel(SHARE_MESSAGE, EditorStyles.textArea, GUILayout.Height(96f));
}

// Links for Github, KoFi, and Twitter
var originalColor = GUI.contentColor;

// Twitter
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(TWITTER_LABEL, EditorStyles.boldLabel, GUILayout.Width(75f));
GUI.contentColor = Color.cyan;
if (GUILayout.Button(TWITTER_URL, GUI.skin.label))
{
Application.OpenURL(TWITTER_URL);
}

GUI.contentColor = originalColor;
}

// Github
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(GITHUB_LABEL, EditorStyles.boldLabel, GUILayout.Width(75f));
GUI.contentColor = Color.cyan;
if (GUILayout.Button(GITHUB_URL, GUI.skin.label))
{
Application.OpenURL(GITHUB_URL);
}
GUI.contentColor = originalColor;
}

// KOFI
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(KOFI_LABEL, EditorStyles.boldLabel, GUILayout.Width(75f));
GUI.contentColor = Color.cyan;
if (GUILayout.Button(KOFI_URL, GUI.skin.label))
{
Application.OpenURL(KOFI_URL);
}

GUI.contentColor = originalColor;
}
}

private void DrawSeparator()
{
GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));
}
}
}
Loading

0 comments on commit 200205d

Please sign in to comment.