コード例 #1
0
        public static void ToggleInput(string in_label, ref bool in_currentValue, string in_savedName)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(in_label + ": ", GUILayout.MaxWidth(MaxWidth));
            var tmpvar = EditorGUILayout.Toggle(in_currentValue);

            if (!string.IsNullOrEmpty(in_savedName) && tmpvar != in_currentValue)
            {
                Google2uGUIUtil.SetBool(in_savedName, tmpvar);
            }
            in_currentValue = tmpvar;
            EditorGUILayout.EndHorizontal();
        }
コード例 #2
0
ファイル: Google2uDocs.cs プロジェクト: Torresgts/circles
        public void ShowFade(string in_label, string in_savedVar, bool in_isOuter, FadeOpenCallback[] in_callbacks)
        {
            var savedVar = Google2uGUIUtil.GetBool(in_savedVar, false);
            var fadeVar  = MyGUILayout.BeginFadeArea(savedVar, in_label, in_savedVar,
                                                     in_isOuter ? MyGUILayout.OuterBox : MyGUILayout.InnerBox,
                                                     in_isOuter ? MyGUILayout.OuterBoxHeader : MyGUILayout.InnerBoxHeader);

            Google2uGUIUtil.SetBool(in_savedVar, fadeVar.Open);
            if (fadeVar.Show())
            {
                foreach (var fadeOpenCallback in in_callbacks)
                {
                    fadeOpenCallback();
                }
            }
            MyGUILayout.EndFadeArea();
        }
コード例 #3
0
        public override bool DrawGUIList(EditorGUILayoutEx in_layout, bool in_showAll)
        {
            var ret = true;

            var spreadsheetVisibleString = "workbook" + WorkbookName.Replace(' ', '_') + "_Visible";

            SpreadsheetVisible = Google2uGUIUtil.GetBool(spreadsheetVisibleString, SpreadsheetVisible);
            if ((SpreadsheetVisible == false) && !in_showAll)
            {
                return(true);
            }

            ShowSpreadsheet = Google2uGUIUtil.GetBool("workbook" + WorkbookName.Replace(' ', '_') + "_Open",
                                                      ShowSpreadsheet);
            var mainFadeArea = in_layout.BeginFadeArea(ShowSpreadsheet, WorkbookName,
                                                       "workbook" + WorkbookName.Replace(' ', '_'), in_layout.OuterBox, in_layout.OuterBoxHeader,
                                                       spreadsheetVisibleString);

            ShowSpreadsheet = mainFadeArea.Open;
            Google2uGUIUtil.SetBool("workbook" + WorkbookName.Replace(' ', '_') + "_Open", ShowSpreadsheet);

            // We have to do this here. Otherwise there is a threading issue (Can't initialize from EditorPreferences outside the main thread)
            if (ExportOptions == null)
            {
                ExportOptions = new Google2uExportOptions("workbook" + WorkbookName.Replace(' ', '_') + "_Option_");
            }

            if (mainFadeArea.Show())
            {
                var showExport   = false;
                var exportsheets = new List <Google2uWorksheet>();

                switch (WorksheetQueryStatus)
                {
                case QueryStatus.Idle:
                {
                    WorksheetQueryStatus = QueryStatus.Uninitialized;
                }
                break;

                case QueryStatus.Querying:
                    EditorGUILayout.LabelField(
                        Google2u.LocalizationInfo.Localize(Localization.rowIds.ID_MESSAGE_QUERYING_WORKSHEETS) +
                        Google2u.Ellipses);
                    break;

                case QueryStatus.QueryComplete:
                    if (WorksheetsDisplay.Length > 0)
                    {
                        foreach (var google2UWorksheet in WorksheetsDisplay)
                        {
                            if (google2UWorksheet.DrawGUIList(in_layout))
                            {
                                exportsheets.Add(google2UWorksheet);
                                showExport = true;
                            }
                        }

                        if (_OpenInvalidSheet)
                        {
                            var stillQuerying = false;
                            for (var i = 0; i < Worksheets.Count; ++i)
                            {
                                if (!exportsheets.Contains(Worksheets[i]))
                                {
                                    continue;
                                }

                                if (Worksheets[i].UpdateValidation || Worksheets[i].Validating)
                                {
                                    stillQuerying = true;
                                }


                                if (Worksheets[i].IsDataValid == false)
                                {
                                    var ed = EditorWindow.GetWindow <Google2uEditor>();
                                    Google2u.ActiveWorkbookWindow = ed;
                                    ed.Workbook = this;
                                    ed.Layout   = in_layout;


#if (UNITY_4)
                                    ed.title = WorkbookName;
#elif (UNITY_5_0)
                                    ed.title = WorkbookName;
#else
                                    ed.titleContent.text = WorkbookName;
#endif

                                    ed.wantsMouseMove    = true;
                                    ActiveWorksheetIndex = i;
                                    Worksheets[i].HighlightFirstInvalidCell();
                                    _OpenInvalidSheet = false;
                                    break;
                                }
                            }
                            if (!stillQuerying)
                            {
                                _OpenInvalidSheet = false;
                            }
                        }

                        EditorGUILayout.BeginHorizontal();
                        var content = new GUIContent(in_layout.RefreshButton,
                                                     Google2u.LocalizationInfo.Localize(Localization.rowIds.ID_LABEL_REFRESH_WORKBOOK));
                        if (GUILayout.Button(content, GUILayout.Height(EditorGUILayoutEx.ButtonHeight),
                                             GUILayout.Width(EditorGUILayoutEx.ButtonWidth)))
                        {
                            Worksheets.Clear();
                            WorksheetQueryStatus = QueryStatus.Uninitialized;
                        }


                        var querying            = false;
                        var bAllWorksheetsValid = true;
                        foreach (var google2UWorksheet in exportsheets)
                        {
                            if (google2UWorksheet.IsDataValid == false)
                            {
                                bAllWorksheetsValid = false;
                            }
                            if (google2UWorksheet.WorksheetQueryStatus != QueryStatus.Idle)
                            {
                                querying = true;
                            }
                        }
                        {
                            var guiEnabled = GUI.enabled;
                            if (querying)
                            {
                                GUI.enabled = false;
                            }

                            content = bAllWorksheetsValid
                                    ? new GUIContent(in_layout.ValidateButtonGreen,
                                                     Google2u.LocalizationInfo.Localize(
                                                         Localization.rowIds.ID_LABEL_VALIDATE_WORKBOOK))
                                    : new GUIContent(in_layout.ValidateButtonRed,
                                                     Google2u.LocalizationInfo.Localize(
                                                         Localization.rowIds.ID_LABEL_VALIDATE_WORKBOOK));

                            if (GUILayout.Button(content, GUILayout.Height(EditorGUILayoutEx.ButtonHeight),
                                                 GUILayout.Width(EditorGUILayoutEx.ButtonWidth)))
                            {
                                // Do Validation for the worksheets we will be exporting
                                foreach (var google2UWorksheet in exportsheets)
                                {
                                    google2UWorksheet.UpdateValidation = true;
                                    google2UWorksheet.Validating       = true;
                                }
                                _OpenInvalidSheet = true;
                            }
                            GUI.enabled = guiEnabled;
                        }

                        content = new GUIContent(in_layout.EditButton,
                                                 Google2u.LocalizationInfo.Localize(Localization.rowIds.ID_LABEL_EDIT_WORKBOOK));
                        if (GUILayout.Button(content, GUILayout.Height(EditorGUILayoutEx.ButtonHeight),
                                             GUILayout.Width(EditorGUILayoutEx.ButtonWidth)))
                        {
                            var ed = EditorWindow.GetWindow <Google2uEditor>();
                            Google2u.ActiveWorkbookWindow = ed;
                            ed.Workbook = this;
                            ed.Layout   = in_layout;
#if (UNITY_4)
                            ed.title = WorkbookName;
#elif (UNITY_5_0)
                            ed.title = WorkbookName;
#else
                            ed.titleContent.text = WorkbookName;
#endif
                            ed.wantsMouseMove = true;
                        }

                        GUILayout.FlexibleSpace();

                        if (showExport)
                        {
                            var oldEnabled = GUI.enabled;
                            if (bAllWorksheetsValid == false)
                            {
                                GUI.enabled = false;
                            }
                            content = new GUIContent(in_layout.SaveButton,
                                                     Google2u.LocalizationInfo.Localize(Localization.rowIds.ID_LABEL_EXPORT));
                            if (GUILayout.Button(content, GUILayout.Height(EditorGUILayoutEx.ButtonHeight),
                                                 GUILayout.Width(EditorGUILayoutEx.ButtonWidth)))
                            {
                                DoExport(exportsheets);
                            }
                            GUI.enabled = oldEnabled;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.LabelField(
                            Google2u.LocalizationInfo.Localize(Localization.rowIds.ID_MESSAGE_NO_WORKSHEETS));
                    }
                    break;
                }
            }
            in_layout.EndFadeArea();
            return(ret);
        }
コード例 #4
0
        public FadeArea BeginFadeArea(bool in_open, string in_label, string in_id, GUIStyle in_areaStyle,
                                      GUIStyle in_labelStyle, string in_WorkbookVisibilityString)
        {
            var tmp1 = GUI.color;

            var fadeArea = BeginFadeArea(in_open, in_id, 26, in_areaStyle);

            var tmp2 = GUI.color;

            GUI.color = tmp1;

            EditorGUILayout.BeginHorizontal();

            if (!in_open)
            {
                if (GUILayout.Button(string.Empty, PlusButton))
                {
                    fadeArea.Open = !fadeArea.Open;
                    GuiEditor.Repaint();
                }
            }
            else
            {
                if (GUILayout.Button(string.Empty, MinusButton))
                {
                    fadeArea.Open = !fadeArea.Open;
                    GuiEditor.Repaint();
                }
            }

            if (in_label != "")
            {
                if (GUILayout.Button(in_label, in_labelStyle))
                {
                    fadeArea.Open = !fadeArea.Open;
                    GuiEditor.Repaint();
                }
            }

            GUILayout.FlexibleSpace();

            var spreadsheetVisible = true;

            if (!string.IsNullOrEmpty(in_WorkbookVisibilityString))
            {
                spreadsheetVisible = Google2uGUIUtil.GetBool(in_WorkbookVisibilityString, true);
            }
            if (spreadsheetVisible)
            {
                if (GUILayout.Button(string.Empty, VisibilityButton))
                {
                    Google2uGUIUtil.SetBool(in_WorkbookVisibilityString, false);
                }
            }
            else
            {
                if (GUILayout.Button(string.Empty, VisibilityHiddenButton))
                {
                    Google2uGUIUtil.SetBool(in_WorkbookVisibilityString, true);
                }
            }

            EditorGUILayout.EndHorizontal();

            GUI.color = tmp2;
            return(fadeArea);
        }