Example #1
0
        void DrawNews(float width)
        {
            if (News == null)
            {
                return;
            }

            QLabel.text  = !showAddNews.target ? "" : "New Article";
            QLabel.style = Style.Text.Title;
            QUI.BeginHorizontal(width, 16);
            {
                if (showAddNews.target)
                {
                    QUI.SetGUIColor(QUI.AccentColorBlue);
                }
                QUI.Label(QLabel);
                QUI.ResetColors();
#if dUI_SOURCE
                QUI.Space(width - QLabel.x - 104 - 100 * showAddNews.faded);
                if (QUI.GhostButton(showAddNews.target ? "Save" : "Add News", showAddNews.target ? QColors.Color.Green : QColors.Color.Gray, 100, showAddNews.target))
                {
                    showAddNews.target = !showAddNews.target;
                    if (!showAddNews.target)
                    {
                        News.articles.Add(new NewsArticleData(newNewsArticle));
                        QUI.SetDirty(News);
                        AssetDatabase.SaveAssets();
                    }
                    newNewsArticle.Reset();
                }
                if (showAddNews.faded > 0.2f)
                {
                    if (QUI.GhostButton("Cancel", QColors.Color.Red, 100 * showAddNews.faded, showAddNews.target))
                    {
                        showAddNews.target = false;
                        newNewsArticle.Reset();
                    }
                }
#else
                QUI.FlexibleSpace();
#endif
            }
            QUI.EndHorizontal();
            QUI.Space(SPACE_2);
            if (QUI.BeginFadeGroup(showAddNews.faded))
            {
                QUI.BeginVertical(width);
                {
                    QUI.Space(SPACE_4 * showAddNews.faded);
                    QUI.DrawLine(QColors.Color.Blue, width);
                    QUI.Space(SPACE_4 * showAddNews.faded);
                    QUI.SetGUIBackgroundColor(QUI.AccentColorBlue);
                    QUI.BeginHorizontal(width);
                    {
                        QLabel.text  = "Title";
                        QLabel.style = Style.Text.Normal;
                        QUI.Label(QLabel);
                        newNewsArticle.title = QUI.TextField(newNewsArticle.title, width - QLabel.x - 8);
                    }
                    QUI.EndHorizontal();
                    QUI.Space(SPACE_2 * showAddNews.faded);
                    QUI.BeginHorizontal(width);
                    {
                        QLabel.text  = "Content";
                        QLabel.style = Style.Text.Normal;
                        QUI.Label(QLabel);
                        newNewsArticle.content = EditorGUILayout.TextArea(newNewsArticle.content, GUILayout.Width(width - QLabel.x - 8));
                    }
                    QUI.EndHorizontal();
                    QUI.ResetColors();
                    QUI.Space(SPACE_4 * showAddNews.faded);
                    QUI.DrawLine(QColors.Color.Blue, width);
                    QUI.Space(SPACE_16 * showAddNews.faded);
                }
                QUI.EndVertical();
            }
            QUI.EndFadeGroup();

            if (News.articles.Count == 0)
            {
                //QLabel.text = "There are no news...";
                //QLabel.style = Style.Text.Help;
                //QUI.Label(QLabel);
                return;
            }

            QUI.Space(SPACE_2);

            for (int i = 0; i < News.articles.Count; i++)
            {
#if dUI_SOURCE
                DrawNewsArticle(News.articles, i, News, true, width);
#else
                DrawNewsArticle(News.articles, i, News, false, width);
#endif
                QUI.Space(9 + 4);
            }
        }