Beispiel #1
0
        void DrawContents()
        {
            if (WindowHelper.Data == null || WindowHelper.CurCategory(selectCategoryId) == null)
            {
                EditorGUILayout.HelpBox("fatal Error.", MessageType.Error);
                selectCategoryId = 0;
                return;
            }

            Header();
            if (selectMode == 0)
            {
                UnityEditorMemoSplitterGUI.BeginVerticalSplit(WindowHelper.VerticalState);
                {
                    MemoContents();
                    PostContents();
                }
                UnityEditorMemoSplitterGUI.EndVerticalSplit();
            }
            else if (selectMode == 1)
            {
                CategoryContents();
                LabelConfigContents();
            }
        }
Beispiel #2
0
        void CategoryMenu()
        {
            var selectedId = 0;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            {
                //searchText = GUILayout.TextField( searchText, GUIHelper.Styles.SearchField, GUILayout.Width( 200 ) );
                //if( GUILayout.Button( "", GUIHelper.Styles.SearchFieldCancel ) ) {
                //    searchText = "";
                //    GUIUtility.keyboardControl = 0;
                //}
                GUILayout.Space(position.width * 0.48f);
                GUI.backgroundColor = Color.yellow;
                selectedId          = EditorGUILayout.Popup(selectCategoryId, WindowHelper.Data.CategoryList, EditorStyles.toolbarPopup);
                GUI.backgroundColor = Color.white;
            }
            EditorGUILayout.EndHorizontal();

            if (selectCategoryId != selectedId)
            {
                Undo.IncrementCurrentGroup();
                UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY);
                GUIUtility.keyboardControl = 0;
                selectLabel  = 0;
                footerToggle = new bool[] { true, false, false, false, false, false };
                WindowHelper.CurCategory(selectedId).OnCategoryChange();
            }
            selectCategoryId = selectedId;
        }
Beispiel #3
0
        //======================================================================
        // Event Process
        //======================================================================

        #region event process
        void EventProcess(Event e)
        {
            if (WindowHelper.Data == null || WindowHelper.CurCategory(selectCategoryId) == null)
            {
                return;
            }

            var memos = WindowHelper.CurCategory(selectCategoryId).Memo;

            for (int i = 0; i < memos.Count; i++)
            {
                var memo = memos[i];
                if (memo.IsContextClick)
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Edit"), false, () => {
                        memo.isFoldout = true;
                    });
                    menu.AddItem(new GUIContent("Delete"), false, () => {
                        UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_MEMO);
                        WindowHelper.CurCategory(selectCategoryId).Memo.Remove(memo);
                    });
                    menu.ShowAsContext();
                    break;
                }
            }
        }
Beispiel #4
0
        void MemoContents()
        {
            var curCategory = WindowHelper.CurCategory(selectCategoryId);
            var memos       = WindowHelper.DisplayMemoList(curCategory, selectLabel, displayMemoMode);

            EditorGUILayout.BeginVertical();
            {
                CategoryMenu();

                GUILayout.Space(5);

                if (curCategory.IsDevideMemo(selectLabel))
                {
                    displayMemoMode = GUILayout.Toolbar(displayMemoMode, displayMemoModeTexts, EditorStyles.toolbarButton);
                }
                else
                {
                    displayMemoMode = 0;
                }

                if (curCategory.Memo.Count == 0)
                {
                    EditorGUILayout.HelpBox(WindowHelper.TEXT_NO_MEMO, MessageType.Warning);
                }
                else if (memos.Count > 0)
                {
                    //try { // this cause erro!:(
                    memoScrollView = EditorGUILayout.BeginScrollView(memoScrollView);
                    {
                        for (int i = 0; i < memos.Count; i++)
                        {
                            memos[i].OnGUI();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                    //} catch { }
                }

                Footer();
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #5
0
        void OnGUI()
        {
            if (win == null)
            {
                OpenWindow();
                if (WindowHelper.CurCategory(selectCategoryId) != null)
                {
                    WindowHelper.CurCategory(selectCategoryId).Initialize();
                }
            }

            EditorGUI.BeginChangeCheck();
            WindowHelper.OnGUIFirst(position.width);

            DrawContents();
            EventProcess(Event.current);

            WindowHelper.OnGUIEnd();

            if (WindowHelper.Data != null && EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(WindowHelper.Data);
            }
        }
Beispiel #6
0
        void CategoryMenu()
        {
            var selectedId = 0;

            EditorGUILayout.BeginHorizontal(GUIHelper.Styles.NoSpaceBox, GUILayout.ExpandWidth(true));
            {
                GUILayout.Label("Category".ToBold());
                GUI.backgroundColor = Color.yellow;
                selectedId          = EditorGUILayout.Popup(selectCategoryId, WindowHelper.Data.CategoryList, EditorStyles.toolbarPopup);
                GUI.backgroundColor = Color.white;
            }
            EditorGUILayout.EndHorizontal();

            if (selectCategoryId != selectedId)
            {
                Undo.IncrementCurrentGroup();
                UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY);
                GUIUtility.keyboardControl = 0;
                selectLabel  = 0;
                footerToggle = new bool[] { true, false, false, false, false, false };
                WindowHelper.CurCategory(selectCategoryId).OnCategoryChange();
            }
            selectCategoryId = selectedId;
        }
Beispiel #7
0
        /// <summary>
        /// display posting area
        /// </summary>
        void PostContents()
        {
            var category = WindowHelper.CurCategory(selectCategoryId);

            EditorGUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true) });
            {
                GUILayout.Box("", GUIHelper.Styles.NoSpaceBox, new GUILayoutOption[] { GUILayout.Height(2), GUILayout.ExpandWidth(true) });

                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                {
                    GUILayout.Label(DateTime.Now.RenderDate());
                    GUI.backgroundColor = GUIHelper.Colors.LabelColor(postMemoLabel);
                    postMemoLabel       = EditorGUILayout.Popup(postMemoLabel, GUIHelper.LabelMenu, EditorStyles.toolbarPopup, GUILayout.Width(100));
                    GUI.backgroundColor = Color.white;

                    GUILayout.FlexibleSpace();

                    GUILayout.Label("URL", GUILayout.Width(30));
                    postMemoUrl = EditorGUILayout.TextField(postMemoUrl, EditorStyles.toolbarTextField);
                }
                EditorGUILayout.EndHorizontal();

                if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack)
                {
                    EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                    {
                        UnityEditorMemoPrefs.UnityEditorMemoSlackChannel = EditorGUILayout.TextField(UnityEditorMemoPrefs.UnityEditorMemoSlackChannel);
                        postToSlack = GUILayout.Toggle(postToSlack, "Post to Slack", EditorStyles.toolbarButton, GUILayout.Width(100));
                    }
                    EditorGUILayout.EndHorizontal();
                }

                GUILayout.Space(5);

                EditorGUILayout.BeginVertical();
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label((WindowHelper.TEXT_CREATEMEMO_TITLE + category.Name).ToMiddleBold());
                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);

                    // draft
                    Undo.IncrementCurrentGroup();
                    UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT);

                    postScrollView = EditorGUILayout.BeginScrollView(postScrollView);
                    {
                        memoText = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) });
                    }
                    EditorGUILayout.EndScrollView();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        postMemoTex = GUILayout.Toolbar(postMemoTex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.MaxWidth(150) });

                        //if ( GUILayout.Button( "test", new GUILayoutOption[] { GUILayout.Height( 30 ), GUILayout.Width( 50 ) } ) ) {
                        //    for( int i = 0; i < 110; i++ ) {
                        //        category.AddMemo( new UnityEditorMemo( i.ToString(), postMemoLabel, postMemoTex ) );
                        //    }
                        //}

                        // post button
                        GUI.backgroundColor = Color.cyan;
                        if (GUILayout.Button("Post", new GUILayoutOption[] { GUILayout.Height(30), GUILayout.MaxWidth(120) }))
                        {
                            Undo.IncrementCurrentGroup();
                            UndoHelper.WindowUndo(UndoHelper.UNDO_POST);
                            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_POST);
                            if (!string.IsNullOrEmpty(memoText))
                            {
                                var memo = new UnityEditorMemo(memoText, postMemoLabel, postMemoTex, postMemoUrl);
                                if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack && postToSlack)
                                {
                                    if (SlackHelper.Post(memo, category.Name))
                                    {
                                        memoPostProcess(category, memo);
                                    }
                                }
                                else
                                {
                                    memoPostProcess(category, memo);
                                }
                            }
                            else
                            {
                                Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY);
                            }
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #8
0
        /// <summary>
        /// display posting area
        /// </summary>
        void PostContents()
        {
            var category = WindowHelper.CurCategory(selectCategoryId);

            EditorGUILayout.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true) });
            {
                GUILayout.Box("", GUIHelper.Styles.NoSpaceBox, new GUILayoutOption[] { GUILayout.Height(2), GUILayout.ExpandWidth(true) });
                GUILayout.Space(5);
                GUILayout.Label((WindowHelper.TEXT_CREATEMEMO_TITLE + category.Name).ToMiddleBold());
                EditorGUILayout.BeginVertical();
                {
                    // date
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(DateTime.Now.RenderDate(), GUIHelper.Styles.MemoBox, new GUILayoutOption[] { GUILayout.Width(150), GUILayout.Height(25) });
                        postMemoLabel = EditorGUILayout.Popup(postMemoLabel, GUIHelper.Label, GUILayout.Width(100));
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);

                    // draft
                    Undo.IncrementCurrentGroup();
                    UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT);
                    memoText = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) });
                    EditorGUILayout.BeginHorizontal();
                    {
                        postMemoTex = GUILayout.Toolbar(postMemoTex, GUIHelper.Textures.Emotions, new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(150) });
                        GUILayout.FlexibleSpace();

                        //if ( GUILayout.Button( "test", new GUILayoutOption[] { GUILayout.Height( 30 ), GUILayout.Width( 50 ) } ) ) {
                        //    for( int i = 0; i < 110; i++ ) {
                        //        category.AddMemo( new UnityEditorMemo( i.ToString(), postMemoLabel, postMemoTex ) );
                        //    }
                        //}

                        // post button
                        GUI.backgroundColor = Color.cyan;
                        if (GUILayout.Button("Post", new GUILayoutOption[] { GUILayout.Height(30), GUILayout.Width(100) }))
                        {
                            if (!string.IsNullOrEmpty(memoText))
                            {
                                Undo.IncrementCurrentGroup();
                                UndoHelper.EditorMemoUndo(UndoHelper.UNDO_POST);

                                category.AddMemo(new UnityEditorMemo(memoText, postMemoLabel, postMemoTex));
                                memoText                   = "";
                                postMemoLabel              = 0;
                                postMemoTex                = 0;
                                memoScrollView             = Vector2.zero;
                                GUIUtility.keyboardControl = 0;
                            }
                            else
                            {
                                Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY);
                            }
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5);
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
        }