-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started working on a Github Integration for Issue Tracking
- Loading branch information
Showing
7 changed files
with
466 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using OmegaLeo.Toolbox.Editor.Settings; | ||
using OmegaLeo.Toolbox.Runtime.Extensions; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace OmegaLeo.Toolbox.Editor.Models | ||
{ | ||
public class Issue | ||
{ | ||
public string Title { get; set; } | ||
public string Body { get; set; } | ||
public List<Label> Labels { get; set; } | ||
|
||
public string Html_Url { get; set; } | ||
public string Url { get; set; } | ||
public int Number { get; set; } | ||
|
||
public void GenerateIssueBox() | ||
{ | ||
var headerStyle = new GUIStyle(GUI.skin.label); | ||
headerStyle.fontStyle = FontStyle.Bold; | ||
headerStyle.normal.textColor = Color.white; | ||
|
||
var bodyStyle = new GUIStyle(GUI.skin.label); | ||
bodyStyle.normal.textColor = Color.white; | ||
bodyStyle.stretchHeight = true; | ||
bodyStyle.wordWrap = true; | ||
|
||
EditorGUILayout.BeginVertical(); | ||
EditorGUILayout.LabelField(Title, headerStyle); | ||
|
||
if (Body.IsNotNullOrEmpty()) | ||
{ | ||
EditorGUILayout.LabelField(Body.Replace("\n", Environment.NewLine), bodyStyle); | ||
} | ||
|
||
EditorGUILayout.BeginHorizontal(); | ||
foreach (var label in Labels) | ||
{ | ||
label.GenerateLabel(); | ||
} | ||
EditorGUILayout.EndHorizontal(); | ||
|
||
EditorGUILayout.EndVertical(); | ||
} | ||
|
||
public bool CanGoBack() | ||
{ | ||
var order = GithubSettingsProvider.GithubTagOrder.Split(',').ToList(); | ||
|
||
var value = false; | ||
|
||
foreach (var label in Labels) | ||
{ | ||
if (order.Any(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
if (order.FindIndex(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase)) > 0) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public void GoBack() | ||
{ | ||
var order = GithubSettingsProvider.GithubTagOrder.Split(',').ToList(); | ||
|
||
var nextValue = ""; | ||
var labelToReplace= Labels.FirstOrDefault(); | ||
|
||
foreach (var label in Labels) | ||
{ | ||
if (order.Any(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
var currentOrder = order.FindIndex(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase)); | ||
var nextOrder = currentOrder - 1; | ||
nextValue = order[nextOrder]; | ||
labelToReplace = label; | ||
} | ||
} | ||
|
||
Labels = Labels.Replace(labelToReplace, new Label() { Color = "", Name = nextValue }).ToList(); | ||
} | ||
|
||
public void GoForward() | ||
{ | ||
var order = GithubSettingsProvider.GithubTagOrder.Split(',').ToList(); | ||
|
||
var nextValue = ""; | ||
var labelToReplace= Labels.FirstOrDefault(); | ||
|
||
foreach (var label in Labels) | ||
{ | ||
if (order.Any(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
var currentOrder = order.FindIndex(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase)); | ||
var nextOrder = currentOrder + 1; | ||
nextValue = order[nextOrder]; | ||
labelToReplace = label; | ||
} | ||
} | ||
|
||
Labels = Labels.Replace(labelToReplace, new Label() { Color = "", Name = nextValue }).ToList(); | ||
} | ||
|
||
public bool CanGoForward() | ||
{ | ||
var order = GithubSettingsProvider.GithubTagOrder.Split(',').ToList(); | ||
|
||
var value = false; | ||
|
||
foreach (var label in Labels) | ||
{ | ||
if (order.Any(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
if (order.FindIndex(x => x.Equals(label.Name, StringComparison.OrdinalIgnoreCase)) < order.Count) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
public class Label | ||
{ | ||
public string Name { get; set; } | ||
public string Color { get; set; } | ||
|
||
public void GenerateLabel() | ||
{ | ||
GUIStyle style = new GUIStyle(GUI.skin.label); | ||
var color = $"#{Color}"; | ||
style.normal.textColor = color.ColorFromHex(); | ||
|
||
EditorGUILayout.LabelField(Name, style); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace OmegaLeo.Toolbox.Editor.Settings | ||
{ | ||
public class GithubSettingsProvider : SettingsProvider | ||
{ | ||
private const string TOKEN_OPTION_PREF = "GithubToken"; | ||
private const string USERNAME_OPTION_PREF = "GithubUsername"; | ||
private const string REPOSITORY_OPTION_PREF = "GithubRepo"; | ||
private const string TAG_FILTER_OPTION_PREF = "GithubTagFilter"; | ||
private const string TAG_ORDER_OPTION_PREF = "GithubTagOrder"; | ||
|
||
public static string GithubToken | ||
{ | ||
get | ||
{ | ||
return EditorPrefs.GetString(TOKEN_OPTION_PREF); | ||
} | ||
set | ||
{ | ||
EditorPrefs.SetString(TOKEN_OPTION_PREF, value); | ||
} | ||
} | ||
|
||
public static string GithubUsername | ||
{ | ||
get | ||
{ | ||
return EditorPrefs.GetString(USERNAME_OPTION_PREF); | ||
} | ||
set | ||
{ | ||
EditorPrefs.SetString(USERNAME_OPTION_PREF, value); | ||
} | ||
} | ||
|
||
public static string GithubRepo | ||
{ | ||
get | ||
{ | ||
return EditorPrefs.GetString(REPOSITORY_OPTION_PREF); | ||
} | ||
set | ||
{ | ||
EditorPrefs.SetString(REPOSITORY_OPTION_PREF, value); | ||
} | ||
} | ||
|
||
public static string GithubTagFilter | ||
{ | ||
get | ||
{ | ||
return EditorPrefs.GetString(TAG_FILTER_OPTION_PREF); | ||
} | ||
set | ||
{ | ||
EditorPrefs.SetString(TAG_FILTER_OPTION_PREF, value); | ||
} | ||
} | ||
|
||
public static string GithubTagOrder | ||
{ | ||
get | ||
{ | ||
return EditorPrefs.GetString(TAG_ORDER_OPTION_PREF); | ||
} | ||
set | ||
{ | ||
EditorPrefs.SetString(TAG_ORDER_OPTION_PREF, value); | ||
} | ||
} | ||
|
||
public GithubSettingsProvider(string path, SettingsScope scopes, IEnumerable<string> keywords = null) : base(path, scopes, keywords) | ||
{ | ||
} | ||
|
||
public override void OnGUI(string searchContext) | ||
{ | ||
base.OnGUI(searchContext); | ||
|
||
GUILayout.Space(20f); | ||
|
||
string token = GithubToken; | ||
string value = EditorGUILayout.PasswordField("Token", token); | ||
|
||
if (!token.Equals(value)) | ||
{ | ||
GithubToken = value; | ||
} | ||
|
||
string username = GithubUsername; | ||
string value1 = EditorGUILayout.TextField("Username", username); | ||
|
||
if (!username.Equals(value1)) | ||
{ | ||
GithubUsername = value1; | ||
} | ||
|
||
string repo = GithubRepo; | ||
string value2 = EditorGUILayout.TextField("Repository", repo); | ||
|
||
if (!repo.Equals(value2)) | ||
{ | ||
GithubRepo = value2; | ||
} | ||
|
||
string tags = GithubTagFilter; | ||
string value3 = EditorGUILayout.TextField("Tags to show (Comma Separated)", tags); | ||
|
||
if (!tags.Equals(value3)) | ||
{ | ||
GithubTagFilter = value3; | ||
} | ||
|
||
string tagOrder = GithubTagOrder; | ||
string value4 = EditorGUILayout.TextField("Tag Order (Comma Separated)", tagOrder); | ||
|
||
if (!tagOrder.Equals(value4)) | ||
{ | ||
GithubTagOrder = value4; | ||
} | ||
} | ||
|
||
[SettingsProvider] | ||
public static SettingsProvider CreateSettingsProvider() | ||
{ | ||
return new GithubSettingsProvider("Omega Leo/Github Integration", SettingsScope.Project); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.