Beispiel #1
0
        private void OnMemoDelete(UnityEditorMemo memo)
        {
            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_DELETE_MEMO);

            WindowHelper.GetCategory(selectCategoryId).Memo.Remove(memo);
            EditorUtility.SetDirty(WindowHelper.Data);
            MemoTreeViewInitialize();
        }
        private void OnMemoOrderChanged(List <UnityEditorMemo> newMemos)
        {
            UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);

            var currentCategory = WindowHelper.GetCategory(selectCategoryId);

            currentCategory.Memo = newMemos;
            Initialize();
        }
Beispiel #3
0
        private void OnCategoryChange()
        {
            Undo.IncrementCurrentGroup();
            UndoHelper.WindowUndo(UndoHelper.UNDO_CHANGE_CATEGORY);

            selectLabel  = 0;
            footerToggle = new bool[] { true, false, false, false, false, false };
            WindowHelper.GetCategory(selectCategoryId).Initialize();
            MemoTreeViewInitialize();
            EditorGUIUtility.keyboardControl = 0;
        }
Beispiel #4
0
 void DrawContents()
 {
     if (WindowHelper.Data == null || WindowHelper.GetCategory(selectCategoryId) == null)
     {
         EditorGUILayout.HelpBox("fatal Error.", MessageType.Error);
         selectCategoryId = 0;
         return;
     }
     HeaderGUI();
     SplitterGUI.BeginVerticalSplit(verticalState);
     {
         MemoGUI();
         PostGUI();
     }
     SplitterGUI.EndVerticalSplit();
 }
Beispiel #5
0
        private void MemoTreeViewInitialize()
        {
            WindowHelper.CheckMemoHasRootElement(selectCategoryId);

            if (memoTreeViewState == null)
            {
                memoTreeViewState = new TreeViewState();
            }

            var rowRectSize = isCategoryVisible ? (preMemoWidth == 0 ? position.width * 0.7f : preMemoWidth) : position.width;
            var treeModel   = new TreeModel <UnityEditorMemo>(WindowHelper.GetCategory(selectCategoryId).Memo);

            memoTreeView = new UnityEditorMemoTreeView(memoTreeViewState, treeModel, rowRectSize);
            memoTreeView.OnContextClicked += OnMemoContextClicked;
            memoTreeView.SelectLabel       = ( UnityEditorMemoLabel )selectLabel;
            memoTreeView.Reload();
        }
Beispiel #6
0
        private void Initialize()
        {
            WindowHelper.LoadData();
            var category = WindowHelper.GetCategory(selectCategoryId);

            if (category == null)
            {
                selectCategoryId = 0;
                return;
            }
            category.Initialize();

            verticalState = new SplitterState(new float[] { position.height * 0.9f, position.height * 0.1f },
                                              new int[] { 200, 180 }, new int[] { 1500, 300 });
            SetHorizontalState();

            CategoryTreeViewInitialize();
            MemoTreeViewInitialize();
            IsInitialized = true;
            EditorGUIUtility.keyboardControl = 0;
            Repaint();
        }
Beispiel #7
0
        private void OnMemoContextClicked(UnityEditorMemo memo)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent(!memo.IsEdit ? "Edit" : "Done"), false, () => {
                UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                memo.IsEdit = !memo.IsEdit;
                memoTreeView.UpdateRowHeight();
            });

            menu.AddItem(new GUIContent("Repost"), false, () => {
                OnMemoDelete(memo);
                memo.Date = DateTime.Now.RenderDate();
                OnMemoPost(WindowHelper.GetCategory(selectCategoryId), memo);
            });

            if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label1))
            {
                menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label1), memo.Label == 0, () => {
                    UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                    memo.Label = 0;
                });
            }

            if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label2))
            {
                menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label2), ( int )memo.Label == 1, () => {
                    UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                    memo.Label = ( UnityEditorMemoLabel )1;
                });
            }

            if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label3))
            {
                menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label3), ( int )memo.Label == 2, () => {
                    UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                    memo.Label = ( UnityEditorMemoLabel )2;
                });
            }

            if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label4))
            {
                menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label4), ( int )memo.Label == 3, () => {
                    UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                    memo.Label = ( UnityEditorMemoLabel )3;
                });
            }

            if (!string.IsNullOrEmpty(UnityEditorMemoPrefs.Label5))
            {
                menu.AddItem(new GUIContent("Label/" + UnityEditorMemoPrefs.Label5), ( int )memo.Label == 5, () => {
                    UndoHelper.EditorMemoUndo(UndoHelper.UNDO_MEMO_EDIT);
                    memo.Label = ( UnityEditorMemoLabel )5;
                });
            }

            menu.AddSeparator("");

            if (!string.IsNullOrEmpty(memo.URL))
            {
                menu.AddItem(new GUIContent("Open URL"), false, () => {
                    Application.OpenURL(memo.URL);
                });
                menu.AddSeparator("");
            }

            menu.AddItem(new GUIContent("Delete"), false, () => {
                OnMemoDelete(memo);
            });

            menu.ShowAsContext();
        }
Beispiel #8
0
        /// <summary>
        /// display posting area
        /// </summary>
        void PostGUI()
        {
            var category = WindowHelper.GetCategory(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());
                    GUILayout.Space(5);
                    GUI.backgroundColor = GUIHelper.Colors.LabelColor(postMemoLabel);
                    postMemoLabel       = EditorGUILayout.Popup(postMemoLabel, GUIHelper.LabelMenu, EditorStyles.toolbarPopup, GUILayout.Width(80));
                    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);

                    postScrollView = EditorGUILayout.BeginScrollView(postScrollView);
                    {
                        // draft
                        var tmp = EditorGUILayout.TextArea(memoText, GUIHelper.Styles.TextAreaWordWrap, new GUILayoutOption[] { GUILayout.MaxHeight(300) });
                        if (tmp != memoText)
                        {
                            Undo.IncrementCurrentGroup();
                            UndoHelper.WindowUndo(UndoHelper.UNDO_DRAFT);
                            memoText = tmp;
                        }
                    }
                    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);
                            if (!string.IsNullOrEmpty(memoText))
                            {
                                var memo = new UnityEditorMemo(memoText, postMemoLabel, postMemoTex, postMemoUrl);
                                memo.id = category.Memo.Count;
                                if (UnityEditorMemoPrefs.UnityEditorMemoUseSlack && postToSlack)
                                {
                                    if (SlackHelper.Post(memo, category.Name))
                                    {
                                        OnMemoPost(category, memo);
                                    }
                                }
                                else
                                {
                                    OnMemoPost(category, memo);
                                }
                            }
                            else
                            {
                                Debug.LogWarning(WindowHelper.WARNING_MEMO_EMPTY);
                            }
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndHorizontal();

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