Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit c0ee280

Browse files
Integrating the LoadingView to the main Window
1 parent d6c9511 commit c0ee280

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/LoadingView.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
using System;
2-
using System.Linq;
3-
using System.Threading.Tasks;
4-
using Octokit;
5-
using Rackspace.Threading;
6-
using UnityEditor;
1+
using UnityEditor;
72
using UnityEngine;
83

94
namespace GitHub.Unity
105
{
116
class LoadingView : Subview
127
{
13-
private static readonly Vector2 viewSize = new Vector2(300, 250);
8+
private static readonly Vector2 MinViewSize = new Vector2(300, 250);
149

1510
private const string WindowTitle = "Loading...";
16-
private const string Header = "";
17-
1811

1912
public override void InitializeView(IView parent)
2013
{
2114
base.InitializeView(parent);
2215
Title = WindowTitle;
23-
Size = viewSize;
16+
Size = MinViewSize;
2417
}
2518

2619
public override void OnGUI()
27-
{}
20+
{
21+
22+
}
2823

2924
public override bool IsBusy
3025
{

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/Window.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Window : BaseWindow
2626
[SerializeField] private SubTab changeTab = SubTab.History;
2727
[SerializeField] private SubTab activeTab = SubTab.History;
2828
[SerializeField] private InitProjectView initProjectView = new InitProjectView();
29+
[SerializeField] private LoadingView loadingView = new LoadingView();
2930
[SerializeField] private BranchesView branchesView = new BranchesView();
3031
[SerializeField] private ChangesView changesView = new ChangesView();
3132
[SerializeField] private HistoryView historyView = new HistoryView();
@@ -39,6 +40,7 @@ class Window : BaseWindow
3940

4041
[SerializeField] private CacheUpdateEvent lastCurrentBranchAndRemoteChangedEvent;
4142
[NonSerialized] private bool currentBranchAndRemoteHasUpdate;
43+
[NonSerialized] private bool gitExecutableIsSet;
4244

4345
[MenuItem(LaunchMenu)]
4446
public static void Window_GitHub()
@@ -84,9 +86,18 @@ public override void Initialize(IApplicationManager applicationManager)
8486
{
8587
base.Initialize(applicationManager);
8688

87-
if (!HasRepository && activeTab != SubTab.InitProject && activeTab != SubTab.Settings)
89+
gitExecutableIsSet = Environment.GitExecutablePath != null;
90+
91+
if (!gitExecutableIsSet && activeTab != SubTab.Loading)
92+
{
93+
changeTab = activeTab = SubTab.Loading;
94+
}
95+
else if (!HasRepository && activeTab != SubTab.InitProject && activeTab != SubTab.Settings)
96+
{
8897
changeTab = activeTab = SubTab.InitProject;
98+
}
8999

100+
LoadingView.InitializeView(this);
90101
HistoryView.InitializeView(this);
91102
ChangesView.InitializeView(this);
92103
BranchesView.InitializeView(this);
@@ -165,12 +176,15 @@ public override void OnUI()
165176
{
166177
base.OnUI();
167178

168-
if (HasRepository)
169-
{
170-
DoHeaderGUI();
171-
}
179+
if(gitExecutableIsSet)
180+
{
181+
if (HasRepository)
182+
{
183+
DoHeaderGUI();
184+
}
172185

173-
DoToolbarGUI();
186+
DoToolbarGUI();
187+
}
174188

175189
// GUI for the active tab
176190
if (ActiveView != null)
@@ -442,6 +456,8 @@ private Subview ToView(SubTab tab)
442456
{
443457
switch (tab)
444458
{
459+
case SubTab.Loading:
460+
return loadingView;
445461
case SubTab.InitProject:
446462
return initProjectView;
447463
case SubTab.History:
@@ -457,6 +473,11 @@ private Subview ToView(SubTab tab)
457473
}
458474
}
459475

476+
public LoadingView LoadingView
477+
{
478+
get { return loadingView; }
479+
}
480+
460481
public HistoryView HistoryView
461482
{
462483
get { return historyView; }
@@ -495,6 +516,7 @@ public override bool IsBusy
495516
private enum SubTab
496517
{
497518
None,
519+
Loading,
498520
InitProject,
499521
History,
500522
Changes,

0 commit comments

Comments
 (0)