Ejemplo n.º 1
0
        void DrawTask(SimpleTask task)
        {
            GUIStyle style = new GUIStyle();

            switch (task.status)
            {
            case SimpleTaskStatus.Created:
                style.normal.background = GetBackground(1);
                break;

            case SimpleTaskStatus.Started:
                style.normal.background = GetBackground(2);
                break;

            case SimpleTaskStatus.Done:
                style.normal.background = GetBackground(3);
                break;
            }
            //style.normal.background = GetBackground(0);

            EditorStyles.label.alignment = TextAnchor.LowerLeft;
            EditorGUILayout.BeginVertical(style, GUILayout.Width(columnWidth - 10), GUILayout.Height(100));


            EditorGUILayout.LabelField("Name", task.name);
            EditorGUILayout.LabelField("Task", task.description, EditorStyles.textArea);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.Width(columnWidth - 100));

            GUI.backgroundColor = typeColors[(int)task.type];
            GUILayout.Button(task.type.ToString(), GUILayout.Width(60));

            GUI.backgroundColor = priorityColors[task.priority];
            GUILayout.Button(task.priority.ToString());
            GUI.backgroundColor = oldColor;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("e", GUILayout.Width(30)))
            {
                TaskEditor.OpenTaskEditor(task);
            }

            if (GUILayout.Button("-", GUILayout.Width(30)))
            {
                if (EditorUtility.DisplayDialog("Delete task?", "Are you sure delete task " + task.name + "?", "Delete", "Cancel"))
                {
                    manager.tasksList.Remove(task);
                }
            }

            if (task.status != SimpleTaskStatus.Done)
            {
                EditorGUILayout.LabelField("");
                if (task.status == SimpleTaskStatus.Created)
                {
                    if (GUILayout.Button("start", GUILayout.Width(60)))
                    {
                        task.status = SimpleTaskStatus.Started;
                    }
                }
                if (task.status == SimpleTaskStatus.Started)
                {
                    if (GUILayout.Button("cancel", GUILayout.Width(60)))
                    {
                        task.status = SimpleTaskStatus.Created;
                    }
                    if (GUILayout.Button("done", GUILayout.Width(60)))
                    {
                        task.status = SimpleTaskStatus.Done;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            //EditorGUILayout.LabelField("", GUI.skin.horizontalSlider, GUILayout.Width(columnWidth));
        }
Ejemplo n.º 2
0
        void DrawSection(SimpleTaskStatus status)
        {
            string caption = "";

            switch (status)
            {
            case SimpleTaskStatus.Created:
                caption = "created tasks";
                break;

            case SimpleTaskStatus.Started:
                caption = "started tasks";
                break;

            case SimpleTaskStatus.Done:
                caption = "completed tasks";
                break;
            }

            EditorStyles.label.alignment = TextAnchor.LowerCenter;
            EditorGUILayout.BeginVertical(GUILayout.Width(columnWidth + 20));

            EditorGUILayout.LabelField(caption, GUILayout.Width(columnWidth));
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider, GUILayout.Width(columnWidth));

            if (status == SimpleTaskStatus.Created)
            {
                if (GUILayout.Button("Create"))
                {
                    SimpleTask t = new SimpleTask()
                    {
                        name     = "new task",
                        status   = SimpleTaskStatus.Created,
                        priority = 3
                    };
                    manager.tasksList.Add(t);
                    TaskEditor.OpenTaskEditor(t);
                }
                EditorGUILayout.Space();
            }
            scrolls[(int)status] = GUILayout.BeginScrollView(scrolls[(int)status], GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

            List <SimpleTask> tasks = new List <SimpleTask>(manager.tasksList);

            tasks.Sort((p1, p2) => p1.priority.CompareTo(p2.priority));

            foreach (SimpleTask task in tasks)
            {
                if (task.status != status)
                {
                    continue;
                }
                if (currentFilter > -1 && currentFilter != (int)task.type)
                {
                    continue;
                }
                if (searchString != "" && !task.name.ToLower().Contains(searchString.ToLower()))
                {
                    continue;
                }

                DrawTask(task);
            }

            GUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            EditorGUILayout.LabelField("", GUI.skin.verticalSlider, GUILayout.Width(10));
        }