Example #1
0
        void DrawGoogleSheetDownload()
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding);
            GUIContent content = new GUIContent(GDEConstants.DownloadGoogleSheetLbl);
            Vector2    size    = headerStyle.CalcSize(content);

            GUILayout.Label(content, headerStyle, GUILayout.Width(size.x), GUILayout.Height(size.y));
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding);
            content.text = GDEConstants.SelectSheetLbl;
            size         = labelStyle.CalcSize(content);
            GUILayout.Label(content, labelStyle, GUILayout.Width(size.x), GUILayout.Height(size.y));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding);
            downloadSelectionIndex = EditorGUILayout.Popup(downloadSelectionIndex, GDEDriveHelper.Instance.SpreadSheetNames, comboBoxStyle);
            GUILayout.Space(windowPadding);
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding * 2f);
            if (GUILayout.Button(GDEConstants.BackBtn, buttonStyle))
            {
                nextView = GDEImportView.Default;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(GDEConstants.DownloadBtn, buttonStyle))
            {
                googleSheetImportName = GDEDriveHelper.Instance.SpreadSheetNames[downloadSelectionIndex];

                // Save import settings
                GDESettings settings = GDESettings.Instance;
                settings.ImportedGoogleSpreadsheetName = googleSheetImportName;
                settings.ImportType = ImportExportType.Google;
                settings.Save();

                /*
                 * GoogleDriveHelper driveHelper = GoogleDriveHelper.Instance;
                 * spreadsheetPath = driveHelper.DownloadSpreadSheet(driveHelper.SpreadSheetNames[downloadSelectionIndex],
                 *                                                "import_" + googleSheetImportName + ".xlsx");
                 */

                GDEExcelManager.DoImport();
                nextView = GDEImportView.ImportComplete;
            }
            GUILayout.Space(windowPadding * 2f);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(windowPadding);
        }
        void DrawExportLocalFile()
        {
            content.text = GDEConstants.ExportExcelWorkbookLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeExportExcelWorkbookLblKey, content, headerStyle, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CenteredOnLine(size.x), drawHelper.TopOfLine(), size.x, size.y), content, headerStyle);

            drawHelper.NewLine(2);

            content.text = GDEConstants.ExcelFileExportLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeExcelFileExportLblKey, content, labelStyle, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);
            drawHelper.CurrentLinePosition += size.x + 2f;
            drawHelper.NewLine();

            spreadsheetPath = EditorGUI.TextField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), drawHelper.FullSeparatorWidth(),
                                                           textFieldStyle.fixedHeight), spreadsheetPath, textFieldStyle);
            drawHelper.CurrentLinePosition += size.x + 2f;
            drawHelper.NewLine(1.1f);

            content.text = GDEConstants.BrowseBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeBrowseBtnKey, content, buttonStyle, out size);
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, buttonStyle))
            {
                string newSpreadSheetPath = EditorUtility.OpenFilePanel(GDEConstants.OpenWBLbl, spreadsheetPath, string.Empty);
                if (!string.IsNullOrEmpty(newSpreadSheetPath) && !newSpreadSheetPath.Equals(spreadsheetPath))
                {
                    spreadsheetPath = newSpreadSheetPath;
                }
                GUI.FocusControl(string.Empty);
            }

            // Draw Back & Export Buttons
            content.text = GDEConstants.BackBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeBackBtnKey, content, buttonStyle, out size);
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, position.height - size.y - drawHelper.BottomBuffer, size.x, size.y), content, buttonStyle))
            {
                nextView = View.Default;
            }

            content.text = GDEConstants.ExportBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeExportBtnKey, content, buttonStyle, out size);
            if (GUI.Button(new Rect(position.width - size.x - drawHelper.LeftBuffer, position.height - size.y - drawHelper.BottomBuffer, size.x, size.y), content, buttonStyle))
            {
                GDESettings settings = GDESettings.Instance;
                settings.ExportedLocalSpreadsheetName = spreadsheetPath;
                settings.ExportType = ImportExportType.Local;
                settings.Save();

                GDEExcelManager.DoExport();
                nextView = View.ImportComplete;
            }
        }
        void DrawUploadNewView()
        {
            content.text = GDEConstants.ExportNewGoogleSheetLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeExportToNewSheetBtnKey, content, headerStyle, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CenteredOnLine(size.x), drawHelper.TopOfLine(), size.x, size.y), content, headerStyle);

            drawHelper.NewLine(2);

            content.text = GDEConstants.NewSheetFileNameLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeNewSheetFileNameLblKey, content, labelStyle, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);

            drawHelper.NewLine(1.1f);

            spreadsheetName = EditorGUI.TextField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), drawHelper.FullSeparatorWidth(), size.y),
                                                  spreadsheetName, textFieldStyle);

            // Draw Back & Upload Buttons
            content.text = GDEConstants.BackBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeBackBtnKey, content, buttonStyle, out size);
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, position.height - size.y - drawHelper.BottomBuffer, size.x, size.y), content, buttonStyle))
            {
                nextView = View.Default;
            }

            content.text = GDEConstants.UploadBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeUploadBtnKey, content, buttonStyle, out size);
            if (!string.IsNullOrEmpty(spreadsheetName) &&
                GUI.Button(new Rect(position.width - size.x - drawHelper.LeftBuffer, position.height - size.y - drawHelper.BottomBuffer, size.x, size.y), content, buttonStyle))
            {
                GDESettings settings = GDESettings.Instance;
                settings.ExportedGoogleSpreadsheetPath = spreadsheetName;
                settings.ExportType = ImportExportType.Google;
                settings.Save();

                GDEExcelManager.DoExport(true);
                nextView = View.ImportComplete;
            }
        }
        void DrawUploadExistingView()
        {
            content.text = GDEConstants.ExportGoogleSheetLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeExportGoogleSheetLblKey, content, headerStyle, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CenteredOnLine(size.x), drawHelper.TopOfLine(), size.x, size.y), content, headerStyle);

            drawHelper.NewLine(2);

            content.text = GDEConstants.SelectExportSpreadSheetLbl;
            drawHelper.TryGetCachedSize(GDEConstants.SizeSelectExportSpreadSheetLblKey, content, labelStyle, out size);
            EditorGUI.LabelField(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content, labelStyle);

            drawHelper.NewLine(1.1f);

            downloadSelectionIndex = EditorGUI.Popup(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), drawHelper.FullSeparatorWidth(), size.y),
                                                     downloadSelectionIndex, GDEDriveHelper.Instance.SpreadSheetNames, comboBoxStyle);

            // Draw Back & Upload Buttons
            content.text = GDEConstants.BackBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeBackBtnKey, content, buttonStyle, out size);
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, position.height - size.y - drawHelper.BottomBuffer, size.x, size.y), content, buttonStyle))
            {
                nextView = View.Default;
            }

            content.text = GDEConstants.UploadBtn;
            drawHelper.TryGetCachedSize(GDEConstants.SizeUploadBtnKey, content, buttonStyle, out size);
            if (GUI.Button(new Rect(position.width - size.x - drawHelper.LeftBuffer, position.height - size.y - drawHelper.BottomBuffer, size.x, size.y), content, buttonStyle))
            {
                GDESettings settings = GDESettings.Instance;
                settings.ExportedGoogleSpreadsheetPath = GDEDriveHelper.Instance.SpreadSheetNames[downloadSelectionIndex];
                settings.ExportType = ImportExportType.Google;
                settings.Save();

                GDEExcelManager.DoExport();
                nextView = View.ImportComplete;
            }
        }
Example #5
0
        void DrawImportLocalFile()
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding);
            GUIContent content = new GUIContent(GDEConstants.ImportWBLbl);
            Vector2    size    = headerStyle.CalcSize(content);

            GUILayout.Label(content, headerStyle, GUILayout.Width(size.x), GUILayout.Height(size.y));
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding);
            content.text = GDEConstants.ExcelFileLbl;
            size         = labelStyle.CalcSize(content);
            GUILayout.Label(content, labelStyle, GUILayout.Width(size.x), GUILayout.Height(size.y));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding);
            spreadsheetPath = EditorGUILayout.TextField(spreadsheetPath, textFieldStyle);
            GUILayout.Space(windowPadding);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding);
            if (GUILayout.Button(GDEConstants.BrowseBtn, buttonStyle))
            {
                string newSpreadSheetPath = EditorUtility.OpenFilePanel(GDEConstants.OpenWBLbl, spreadsheetPath, string.Empty);
                if (!string.IsNullOrEmpty(newSpreadSheetPath) && !newSpreadSheetPath.Equals(spreadsheetPath))
                {
                    spreadsheetPath = newSpreadSheetPath;
                }
                GUI.FocusControl(string.Empty);
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(windowPadding * 2f);
            if (GUILayout.Button(GDEConstants.BackBtn, buttonStyle))
            {
                nextView = GDEImportView.Default;
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(GDEConstants.ImportBtn, buttonStyle))
            {
                // Save the import settings
                GDESettings settings = GDESettings.Instance;
                settings.ImportedLocalSpreadsheetName = spreadsheetPath;
                settings.ImportType = ImportExportType.Local;
                settings.Save();

                // Do the import
                GDEExcelManager.DoImport();
                nextView = GDEImportView.ImportComplete;
            }
            GUILayout.Space(windowPadding * 2f);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(windowPadding);
        }