예제 #1
0
 private void LogOut()
 {
     MichelangeloSession.LogOut()
     .Then(() => {
         errorMessage = null;
         Repaint();
     })
     .Catch(OnRejected);
 }
예제 #2
0
 private void LogIn()
 {
     MichelangeloSession.LogIn(loginEmail, loginPassword)
     .Then(_ => {
         errorMessage = null;
         Repaint();
         MichelangeloSession.UpdateGrammarList();
     })
     .Catch(OnRejected);
 }
        public override void OnInspectorGUI()
        {
            if (!MichelangeloSession.IsAuthenticated)
            {
                EditorGUILayout.HelpBox("To use this feature, please log in to Michelangelo first.", MessageType.Warning);
                MichelangeloEditorWindow.OpenMichelangeloWindowButton();
                GUI.enabled = false;
            }
            else if (MichelangeloSession.IsLoading)
            {
                EditorGUILayout.HelpBox("Loading, please wait...", MessageType.Info);
                if (GUILayout.Button("Stop generation", GUILayout.Height(40.0f)))
                {
                    MichelangeloSession.CancelGeneration();
                }
                GUI.enabled = false;
            }

            RenderBody();

            EditorGUILayout.Space();
            GUI.enabled = GUI.enabled && Object.CanGenerate;
            if (GUILayout.Button(new GUIContent("Generate new mesh", GenerateButtonTooltip), GUILayout.Height(40.0f)))
            {
                Generate();
            }
            EditorGUILayout.Space();

            parseTreeFoldout = EditorGUILayout.Foldout(parseTreeFoldout, "Parse tree");
            if (parseTreeFoldout)
            {
                EditorGUILayout.BeginVertical("Box", GUILayout.ExpandHeight(true));
                TreeView.OnGUI(GUILayoutUtility.GetRect(100, 400, GUILayout.ExpandHeight(true)));
                EditorGUILayout.EndVertical();

                using (new EditorGUILayout.HorizontalScope()) {
                    if (GUILayout.Button("Expand All", "miniButton") && (Object.ParseTree.Count < 200 || EditorUtility.DisplayDialog("Expand large tree?", $"This tree contains a total of {Object.ParseTree.Count} nodes. Expanding it may cause unity to freeze.", "Expand anyway", "Cancel")))
                    {
                        TreeView.ExpandAll();
                    }
                    if (GUILayout.Button("Collapse All", "miniButton"))
                    {
                        TreeView.CollapseAll();
                    }
                }
            }

            RenderCompilationOutput();
        }
예제 #4
0
        private void OnGUI()
        {
            if (MichelangeloSession.IsUnreachable)
            {
                EditorGUILayout.HelpBox("Michelangelo web server seems to be unreachable\nPlease try again later...", MessageType.Error);
                if (GUILayout.Button("Refresh"))
                {
                    Refresh();
                }
                GUI.enabled = false;
            }
            else if (MichelangeloSession.IsLoading)
            {
                EditorGUILayout.HelpBox("Loading, please wait...", MessageType.Info);
                GUI.enabled = false;
            }

            if (MichelangeloSession.IsAuthenticated)
            {
                if (MichelangeloSession.User == null)
                {
                    MichelangeloSession.UpdateUserInfo().Then(_ => { Repaint(); }).Catch(OnRejected);
                    MichelangeloSession.UpdateGrammarList();
                    return;
                }

                LoggedIn();
            }
            else
            {
                NotLoggedIn();
            }

            EditorGUILayout.Space();
            if (RequestErrorMessage.IsRequestError(errorMessage))
            {
                RequestErrorMessage.Draw(ref errorMessage);
            }
        }
예제 #5
0
        private void PrintGrammarList()
        {
            EditorGUILayout.LabelField("Grammars", EditorStyles.boldLabel);
            if (MichelangeloSession.GrammarList.Count == 0)
            {
                EditorGUILayout.HelpBox("Loading, please wait...", MessageType.Info);
                return;
            }
            if (GUILayout.Button("Create Grammar"))
            {
                MichelangeloSession.CreateGrammar().Then(_ => { Repaint(); }).Catch(OnRejected);
            }
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            var pageCount           = 0;
            var filteredGrammarList = MichelangeloSession.GrammarList.Values.OrderByDescending(x => x.LastModifiedDate).Where(FilterGrammar).ToList();

            if (grammarsPerPage <= 0)
            {
                foreach (var grammar in filteredGrammarList)
                {
                    grammar.Draw(Repaint, OnRejected, true);
                }
            }
            else
            {
                pageCount = (filteredGrammarList.Count - 1) / grammarsPerPage;
                if (pageCount < grammarPage)
                {
                    grammarPage = pageCount;
                }

                foreach (var grammar in filteredGrammarList.Skip(grammarPage * grammarsPerPage).Take(grammarsPerPage))
                {
                    grammar.Draw(Repaint, OnRejected, true);
                }
            }
            EditorGUILayout.EndScrollView();

            if (pageCount > 0)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth));
                if (GUILayout.Button("Prev") && grammarPage != 0)
                {
                    --grammarPage;
                }
                EditorGUILayout.LabelField($"{grammarPage + 1}/{pageCount + 1}", new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleCenter
                });
                if (GUILayout.Button("Next") && grammarPage < pageCount)
                {
                    ++grammarPage;
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.LabelField("Filters", EditorStyles.boldLabel);

            DrawNameFilter();
            sourceFilter    = (GrammarSource)EditorGUILayout.EnumPopup("Source", sourceFilter);
            grammarsPerPage = EditorGUILayout.IntField(new GUIContent("Items per page", "0 = unlimited"), grammarsPerPage);
            localOnly       = EditorGUILayout.Toggle(new GUIContent("Local only", "Filter out not downloaded grammars."), localOnly);
        }
예제 #6
0
 private void Refresh()
 {
     MichelangeloSession.UpdateUserInfo().Catch(e => OnRejected(e));
     MichelangeloSession.UpdateGrammarList();
 }