public void Show()
        {
            GUILayout.Label(_selectedApp.Name, EditorStyles.centeredGreyMiniLabel);
            if (GUILayout.Button(new GUIContent("←", "Change application"), GUILayout.Width(40)))
            {
                if (OnChangeApp != null)
                {
                    OnChangeApp();
                }
            }

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label("\n                                 * Publishing *\n" +
                                " The version will be sent with the following information. \n", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();


            GUILayout.Label("*Version label: ");
            _label = GUILayout.TextField(_label);

            GUILayout.Label("Changelog: ");
            _changelog = GUILayout.TextArea(_changelog, GUILayout.MinHeight(200));

            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Automatically publish after upload");
                _autoPublishAfterUpload = EditorGUILayout.Toggle(_autoPublishAfterUpload);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Override draft version if it exists");
                _forceOverrideDraft = EditorGUILayout.Toggle(_forceOverrideDraft);
            }
            EditorGUILayout.EndHorizontal();

            if (!_forceOverrideDraft)
            {
                EditorGUILayout.HelpBox("If a draft version exists, interaction with the console will be necessary.", MessageType.Warning);
            }

            if (CanBuild())
            {
                EditorGUILayout.Separator();
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Send version", GUILayout.Width(150)))
                    {
                        if (!TextValidation.DoesStringContainOnlyAllowedCharacters(_changelog) || !TextValidation.DoesStringContainOnlyAllowedCharacters(_label))
                        {
                            if (EditorUtility.DisplayDialog("Warning", "Use only English characters and ':', '_' or '-' in label and changelog input.\n \n" +
                                                            "Unfortunately PatchKit plugin does not support other languages encoding. If you need to write correct information, please login to your PatchKit Panel and set Version Properties for your application.",
                                                            "Set using Panel", "Ok"))
                            {
                                Application.OpenURL("https://panel.patchkit.net/apps/" + _selectedApp.Id); //production
                                //Application.OpenURL("http://staging.patchkit.waw.pl/apps/" + _selectedApp.Id+ "/versions"); //staging
                            }
                        }
                        else
                        {
                            if (OnPublishStart != null)
                            {
                                OnPublishStart();
                            }

                            MakeVersionHeadless();
                        }
                    }
                    GUILayout.FlexibleSpace();
                }
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.HelpBox("* Version label cannot be empty.", MessageType.Error);
            }
        }
Пример #2
0
        public void Show()
        {
            if (GUILayout.Button(new GUIContent("←", "Change application"), GUILayout.Width(40)))
            {
                if (OnChangeApp != null)
                {
                    OnChangeApp();
                }
            }

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label("\n Create new application as a target.\n", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            _newAppName = EditorGUILayout.TextField("Name: ", _newAppName);
            EditorGUILayout.BeginHorizontal();
            {
                var buildTargetName = EditorUserBuildSettings.activeBuildTarget;
                EditorGUILayout.LabelField(new GUIContent("Build target platform:      " + buildTargetName.ToString(), "PatchKit application target platform is unambiguous with current active project build platform."));
                if (GUILayout.Button(new GUIContent("Change", "Change PatchKit application target platform"), GUILayout.Width(60)))
                {
                    if (EditorUtility.DisplayDialog("Warning", "To change application platform, you need to switch the project platform. \n\nRemember, PatchKit support only: Windows, Mac, Linux platforms.",
                                                    "Change the project platform", "Cancel"))
                    {
                        EditorWindow.GetWindow(System.Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor"));
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            if (string.IsNullOrEmpty(_newAppName))
            {
                EditorGUILayout.HelpBox("Application name cannot be empty.", MessageType.Error);
            }
            else
            {
                if (!TextValidation.DoesStringContainOnlyAllowedCharacters(_newAppName))
                {
                    EditorGUILayout.HelpBox("Name only allows English characters and ':', '_' or '-'", MessageType.Error);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Add", GUILayout.Width(100)))
                        {
                            if (FindDuplicateApp(_newAppName))
                            {
                                EditorUtility.DisplayDialog("Warning", "Application name is already taken.\nChange it and try again.", "Ok");
                            }
                            else
                            {
                                var newApp = _api.CreateNewApp(_newAppName, EditorUserBuildSettings.activeBuildTarget.ToPatchKitString());
                                if (OnAppSelected != null)
                                {
                                    OnAppSelected(newApp);
                                }
                            }
                        }
                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }