コード例 #1
0
        /// <summary>
        /// Display GUI for posting to DevLog and Discord.
        /// </summary>
        /// <returns>True if it is possible to post to Discord.</returns>
        private bool DiscordPostingGUI()
        {
            if (!DiscordSettings.IsConfigured || !m_EntryPanel.isNewEntry)
            {
                return(false);
            }

            bool canPost = !string.IsNullOrEmpty(m_EntryPanel.shortText) && mediaPanel.hasSelectedImages;

            GUI.enabled = canPost;
            if (GUILayout.Button("Post to DevLog and Discord"))
            {
                Message message;
                if (string.IsNullOrEmpty(m_EntryPanel.detailText))
                {
                    message = new Message(DiscordSettings.Username, m_EntryPanel.shortText + m_EntryPanel.GetSelectedMetaData(false), m_ScreenCaptures);
                }
                else
                {
                    message = new Message(DiscordSettings.Username, m_EntryPanel.shortText + m_EntryPanel.GetSelectedMetaData(false), m_EntryPanel.detailText, mediaPanel.ScreenCaptures);
                }

                currentEntry = m_EntryPanel.AppendDevlogEntry(false, true);
                Discord.PostEntry(currentEntry);
            }
            GUI.enabled = true;

            return(canPost);
        }
コード例 #2
0
        /// <summary>
        /// Display GUI for posting to DevLog and Discord.
        /// </summary>
        /// <returns>True if it is possible to post to Discord.</returns>
        private bool DiscordPostingGUI()
        {
            if (!DiscordSettings.IsConfigured)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(m_EntryPanel.shortText))
            {
                if (GUILayout.Button("Post to Devlog and Discord"))
                {
                    Message message;
                    if (string.IsNullOrEmpty(m_EntryPanel.detailText))
                    {
                        message = new Message(DiscordSettings.Username, m_EntryPanel.shortText + m_EntryPanel.GetSelectedMetaData(false), m_ScreenCaptures);
                    }
                    else
                    {
                        message = new Message(DiscordSettings.Username, m_EntryPanel.shortText + m_EntryPanel.GetSelectedMetaData(false), m_EntryPanel.detailText, m_MediaPanel.ScreenCaptures);
                    }

                    DevLogEntry entry = m_EntryPanel.AppendDevlog(false, true);
                    Discord.PostEntry(entry);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: DevLogMarkdown.cs プロジェクト: Necronaut/DevLogger
        /// <summary>
        /// Get the markdown for an entry.
        /// </summary>
        /// <param name="entry">The DevLogEntry to convert to markdown.</param>
        private static string GetMarkdown(DevLogEntry entry)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(GetNewEntryHeading(entry));

            if (!string.IsNullOrEmpty(entry.longDescription))
            {
                sb.AppendLine(entry.longDescription);
                sb.AppendLine();
                sb.AppendLine(DateTime.Now.ToString("dddd d MMMM yyyy, HH:mm"));
                sb.AppendLine();
            }

            if (entry.captures != null)
            {
                for (int i = 0; i < entry.captures.Count; i++)
                {
                    sb.Append("![Screenshot](");
                    sb.Append(entry.captures[i].ImagePath);
                    sb.AppendLine(")");
                    sb.AppendLine();
                }
            }

            return(sb.ToString());
        }
コード例 #4
0
        internal void OnSelect(ReorderableList list)
        {
            DevLogEntry entry = validEntries[list.index];

            EditorGUIUtility.PingObject(entry);
            Selection.activeObject = entry;
        }
コード例 #5
0
        internal void EditEntry(DevLogEntry entry)
        {
            isNewEntry           = false;
            windowScrollPos      = Vector2.zero;
            status               = entry.status;
            detailScrollPosition = Vector2.zero;
            shortText            = entry.shortDescription;
            detailText           = entry.longDescription;
            assets               = entry.assets;
            isSocial             = entry.isSocial;
            gitCommit            = entry.commitHash;

            MetaDataItems items = EntryPanelSettings.GetSuggestedMetaDataItems();

            for (int i = 0; i < items.Count; i++)
            {
                if (devLogWindow.currentEntry.metaData.Contains(items.GetItem(i).name))
                {
                    items.GetItem(i).IsSelected = true;
                }
            }

            List <string> mediaFilePaths = new List <string>();

            for (int i = 0; i < ScreenCaptures.Count; i++)
            {
                DevLogScreenCapture capture = ScreenCaptures.captures[i];
                if (devLogWindow.currentEntry.captures.Contains(capture))
                {
                    ScreenCaptures.captures[i].IsSelected = true;
                }
            }
        }
コード例 #6
0
ファイル: DevLogMarkdown.cs プロジェクト: Necronaut/DevLogger
        private static string GetNewEntryHeading(DevLogEntry entry)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("### ");
            sb.AppendLine(entry.shortDescription);
            return(sb.ToString());
        }
コード例 #7
0
 internal void DeleteEntry(DevLogEntry entry)
 {
     if (EditorUtility.DisplayDialog("Delete DevLog Entry?",
                                     "Are you sure you want delete the entry '" + entry.title
                                     + "'?", "Delete", "Cancel"))
     {
         m_EntryPanel.entries.RemoveEntry(entry);
         AssetDatabase.RemoveObjectFromAsset(entry);
         EditorUtility.SetDirty(m_EntryPanel.entries);
         AssetDatabase.SaveAssets();
     }
 }
コード例 #8
0
ファイル: Discord.cs プロジェクト: Necronaut/DevLogger
        internal Message(string username, DevLogEntry entry)
        {
            this.entry = entry;

            this.username = username;

            this.introText = entry.shortDescription;
            for (int i = 0; i < entry.metaData.Count; i++)
            {
                if (!entry.metaData[i].StartsWith("#"))
                {
                    introText += " " + entry.metaData[i];
                }
            }

            this.bodyText = entry.longDescription;

            for (int i = 0; i < entry.captures.Count; i++)
            {
                DevLogScreenCapture capture = entry.captures[i];
                ImageContent        image   = new ImageContent("File" + i, capture);
                files.Add(image);
            }
        }
コード例 #9
0
        /// <summary>
        /// Append a devlog entry.
        /// </summary>
        /// <param name="withTweet">If true record that the entry was tweeted at the current time.</param>
        /// <param name="withDiscord">If true record that the entry was posted to discord at the current time.</param>
        /// <returns></returns>
        public DevLogEntry AppendDevlog(bool withTweet = false, bool withDiscord = false)
        {
            DevLogEntry entry = ScriptableObject.CreateInstance <DevLogEntry>();

            entry.name = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();

            entry.status = status;

            entry.shortDescription = shortText;
            StringBuilder text = new StringBuilder(entry.shortDescription);

            entry.isSocial = isSocial;

            if (!string.IsNullOrEmpty(gitCommit))
            {
                entry.commitHash = gitCommit;

                text.Append("\n\nGit Commit: " + gitCommit);
                gitCommit = "";
            }

            MetaDataItems items = EntryPanelSettings.GetSuggestedMetaDataItems();

            for (int i = 0; i < items.Count; i++)
            {
                if (items.GetItem(i).IsSelected)
                {
                    entry.metaData.Add(items.GetItem(i).name);
                }
            }

            if (withTweet)
            {
                entry.tweeted           = true;
                entry.lastTweetFileTime = DateTime.Now.ToFileTimeUtc();
                text.Append("\n\n[This DevLog entry was last Tweeted at " + entry.lastTweetPrettyTime + ".]");
            }

            if (withDiscord)
            {
                entry.discordPost             = true;
                entry.lastDiscordPostFileTime = DateTime.Now.ToFileTimeUtc();
                text.Append("\n\n[This DevLog entry was last posted to Discord at " + entry.lastTweetPrettyTime + ".]");
            }

            List <string> mediaFilePaths = new List <string>();

            for (int i = 0; i < ScreenCaptures.Count; i++)
            {
                if (ScreenCaptures.captures[i].IsSelected)
                {
                    DevLogScreenCapture capture = ScreenCaptures.captures[i];
                    entry.captures.Add(capture);
                    ScreenCaptures.captures[i].IsSelected = false;
                }
            }
            entry.longDescription = detailText;

            entries.AddEntry(entry);
            AssetDatabase.AddObjectToAsset(entry, entries);
            EditorUtility.SetDirty(entries);
            AssetDatabase.SaveAssets();

            shortText  = "";
            detailText = "";

            return(entry);
        }
コード例 #10
0
        void OnGUI()
        {
            try
            {
                selectedTab = GUILayout.Toolbar(selectedTab, toolbarLabels);
                switch (selectedTab)
                {
                case 0:
                    if (m_DevLogEntries != null && m_ScreenCaptures != null)     // Check we are correctly configured
                    {
                        Skin.StartSection("Posting", false);
                        GUILayout.BeginHorizontal();

                        m_EntryPanel.DevLogPostingGUI();

                        bool canPostToAll;
                        canPostToAll  = DiscordPostingGUI();
                        canPostToAll &= TwitterPostingGUI();

                        GUI.enabled = canPostToAll;
                        if (GUILayout.Button("Post to All"))
                        {
                            DevLogEntry entry = PostToDevLogAndTwitter();
                            Discord.PostEntry(entry);
                        }
                        GUI.enabled = true;

                        GUILayout.EndHorizontal();
                        Skin.EndSection();

                        entryScrollPosition       = EditorGUILayout.BeginScrollView(entryScrollPosition);
                        mediaPanel.ScreenCaptures = m_ScreenCaptures;
                        m_EntryPanel.entries      = m_DevLogEntries;
                        m_EntryPanel.OnGUI();

                        EditorGUILayout.Space();

                        mediaPanel.ScreenCaptures = m_ScreenCaptures;
                        mediaPanel.OnGUI();
                        EditorGUILayout.EndScrollView();
                    }
                    else
                    {
                        SettingsTabUI();
                    }
                    break;

                case 1:
                    if (m_DevLogPanel == null)
                    {
                        m_DevLogPanel = new DevLogPanel(m_DevLogEntries);
                    }

                    DevLogList.isDirty = true;

                    m_DevLogPanel.ScreenCaptures = m_ScreenCaptures;
                    m_DevLogPanel.entries        = m_DevLogEntries;
                    m_DevLogPanel.OnGUI();
                    break;

                case 2:
                    m_SchedulingPanel.OnGUI();
                    break;

                case 3:
                    m_GitPanel.OnGUI();
                    break;

                case 4:
                    SettingsTabUI();
                    break;
                }
            } catch (InvalidCastException e)
            {
                //TODO Don't silently catch errors
                // this is a workaround. An exception is thrown when a new scene is loaded.
                Repaint();
            }
        }
コード例 #11
0
 internal void RemoveEntry(DevLogEntry entry)
 {
     m_Entries.Remove(entry);
 }
コード例 #12
0
 internal void AddEntry(DevLogEntry entry)
 {
     m_Entries.Add(entry);
 }
コード例 #13
0
ファイル: Discord.cs プロジェクト: Necronaut/DevLogger
        public static void PostEntry(DevLogEntry entry)
        {
            string username = DiscordSettings.Username;

            PostMessage(new Message(username, entry));
        }
コード例 #14
0
        internal void DrawLogListElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            DevLogEntry entry = validEntries[index];

            Rect labelRect = new Rect(rect.x, rect.y, listLabelWidth, EditorGUIUtility.singleLineHeight);
            Rect fieldRect = new Rect(labelRect.x, labelRect.y, rect.width, EditorGUIUtility.singleLineHeight);

            DevLogEntry.Status originalStatus = entry.status;
            entry.status = (DevLogEntry.Status)EditorGUI.EnumPopup(fieldRect, entry.status);
            if (originalStatus != entry.status)
            {
                isDirty = true;
            }

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight, labelRect.width, labelRect.height);
            EditorGUI.PrefixLabel(labelRect, new GUIContent("Title"));
            fieldRect = new Rect(fieldRect.x + listLabelWidth, labelRect.y, fieldRect.width - listLabelWidth, labelRect.height);
            entry.shortDescription = EditorGUI.TextField(fieldRect, entry.shortDescription);

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight, labelRect.width, labelRect.height);
            EditorGUI.PrefixLabel(labelRect, new GUIContent("Description"));
            fieldRect             = new Rect(fieldRect.x, labelRect.y, fieldRect.width, EditorGUIUtility.singleLineHeight * listDescriptionLines);
            entry.longDescription = EditorGUI.TextArea(fieldRect, entry.longDescription);

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight * listDescriptionLines, labelRect.width, labelRect.height);
            EditorGUI.PrefixLabel(labelRect, new GUIContent("Created"));
            fieldRect = new Rect(fieldRect.x, labelRect.y, fieldRect.width, labelRect.height);
            EditorGUI.LabelField(fieldRect, entry.created.ToString("dd MMM yyyy"));

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight, labelRect.width, labelRect.height);
            if (validEntries[index].metaData.Count != 0)
            {
                EditorGUI.PrefixLabel(labelRect, new GUIContent("Meta Data"));
                for (int i = 0; i < entry.metaData.Count; i++)
                {
                    fieldRect         = new Rect(fieldRect.x, labelRect.y + EditorGUIUtility.singleLineHeight * i, fieldRect.width, EditorGUIUtility.singleLineHeight);
                    entry.metaData[i] = EditorGUI.TextField(fieldRect, entry.metaData[i]);
                }
            }

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight * validEntries[index].metaData.Count, labelRect.width, labelRect.height);
            if (validEntries[index].captures.Count != 0)
            {
                EditorGUI.PrefixLabel(labelRect, new GUIContent("Captures"));
                for (int i = 0; i < entry.captures.Count; i++)
                {
                    fieldRect = new Rect(fieldRect.x, labelRect.y + EditorGUIUtility.singleLineHeight * i, fieldRect.width, EditorGUIUtility.singleLineHeight);
                    EditorGUI.ObjectField(fieldRect, entry.captures[i], typeof(ScreenCapture), false);
                }
            }

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight * validEntries[index].captures.Count, labelRect.width, labelRect.height);
            EditorGUI.PrefixLabel(labelRect, new GUIContent("Commit"));
            fieldRect = new Rect(fieldRect.x, labelRect.y, fieldRect.width, EditorGUIUtility.singleLineHeight);
            EditorGUI.TextArea(fieldRect, entry.commitHash);

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight, labelRect.width, labelRect.height);
            EditorGUI.PrefixLabel(labelRect, new GUIContent("Social?"));
            fieldRect      = new Rect(fieldRect.x, labelRect.y, fieldRect.width, EditorGUIUtility.singleLineHeight);
            entry.isSocial = EditorGUI.Toggle(fieldRect, entry.isSocial);

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight, labelRect.width, labelRect.height);
            EditorGUI.PrefixLabel(labelRect, new GUIContent("Tweeted?"));
            fieldRect = new Rect(fieldRect.x, labelRect.y, fieldRect.width, EditorGUIUtility.singleLineHeight);
            EditorGUI.Toggle(fieldRect, entry.tweeted);
            if (entry.tweeted)
            {
                Rect timeRect = new Rect(fieldRect.x + 20, fieldRect.y, fieldRect.width - 50, fieldRect.height);
                EditorGUI.LabelField(timeRect, " most recent " + entry.lastTweetPrettyTime);
            }

            labelRect = new Rect(labelRect.x, labelRect.y + EditorGUIUtility.singleLineHeight, labelRect.width, labelRect.height);
            EditorGUI.PrefixLabel(labelRect, new GUIContent("Discord?"));
            fieldRect = new Rect(fieldRect.x, labelRect.y, fieldRect.width, EditorGUIUtility.singleLineHeight);
            EditorGUI.Toggle(fieldRect, entry.discordPost);
            if (entry.discordPost)
            {
                Rect timeRect = new Rect(fieldRect.x + 20, fieldRect.y, fieldRect.width - 50, fieldRect.height);
                EditorGUI.LabelField(timeRect, "most recent" + entry.lastDiscordPostPrettyTime);
            }
        }