Пример #1
0
        public static Rect DrawDefaultAccordionHeader(SimpleAccordion accordion, string icon, int height = 20, int fontSize = 14)
        {
            if (accordion.headerStyle == null)
            {
                accordion.headerStyle = new GUIStyle(AssetReferences.AccordionHeader);
            }

            accordion.headerStyle.fontSize = fontSize;
            GUILayout.Box(accordion.Title, accordion.headerStyle, GUILayout.ExpandWidth(true), GUILayout.Height(height));
            var rect = GUILayoutUtility.GetLastRect();

            DrawerHelper.FAIcon(rect, icon, FAOption.TextAnchor(TextAnchor.MiddleLeft),
                                //FAOption.FontSize(fontSize),
                                FAOption.Padding(new RectOffset(5, 0, 0, 0))

                                );
            return(rect);
        }
        private Rect DrawLocalizedLanguageHeader(LocalizedLanguage language, int index, int languagesCount, bool drawRemoveButton = false)
        {
            var icon = accordion.IsExpanded ? FA.angle_double_down : FA.angle_double_right;

            var rect = EditorGUILayout.BeginVertical();

            var boxTitle = new GUIContent(language.LanguageName);

            GUILayout.Box(boxTitle, AssetReferences.AccordionHeader, GUILayout.ExpandWidth(true), GUILayout.Height(20));

            DrawerHelper.FAIcon(rect, icon, FAOption.TextAnchor(TextAnchor.UpperLeft), FAOption.FontSize(20), FAOption.Padding(new RectOffset(5, 0, 0, 0)));

            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(100);
            // draw translation progress bar
            if (language.isBeingAutoTranslated)
            {
                var r = GUILayoutUtility.GetRect(250, 32);
                EditorGUI.ProgressBar(r, language.translationProgress, string.Empty);
            }

            GUILayout.FlexibleSpace();

            // draw google translate button
            if (index > 0 && selectedTab == 0)
            {
                if (GUI.Button(new Rect(rect.width - 82, rect.y, 24, rect.height), AssetReferences.GoogleTranslateIcon, EditorStyles.label))
                {
                    AutoTranslateAllKeyOfLanguage(language);
                }
            }

            GUILayout.Space(10);

            // draw up arrow
            if (index > 0 && DrawerHelper.FAButton(new Rect(rect.width - 58, rect.y, 24, rect.height), FA.arrow_up))
            {
                SwapLanguagesPosition(index, index - 1);
            }

            GUILayout.Space(10);

            // draw down arrao
            if (index < languagesCount - 1 && DrawerHelper.FAButton(new Rect(rect.width - 34, rect.y, 24, rect.height), FA.arrow_down))
            {
                SwapLanguagesPosition(index, index + 1);
            }

            GUILayout.Space(10);

            // draw remove button
            if (drawRemoveButton && DrawerHelper.FAButton(new Rect(rect.width - 10, rect.y, 24, rect.height), FA.trash, FAOption.TextColor(Color.red)))
            {
                script.LocalizedLanguages.Remove(language);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            return(rect);
        }