예제 #1
0
        public void CreateGUI()
        {
            InitializeButlerIfNecessary();

            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(MainStyleSheet);

            if (!IsEditorSupported())
            {
                var platformNotSupported = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(WrongPlatformUXML).CloneTree();
                platformNotSupported.styleSheets.Add(styleSheet);
                ShowPage(platformNotSupported);
                return;
            }

            // Create Download Page
            _downloadPage = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(DownloadUXML).CloneTree();
            _downloadPage.styleSheets.Add(styleSheet);

            var downloadButton   = _downloadPage.Q <Button>("downloadButton");
            var downloadProgress = _downloadPage.Q <ProgressBar>("downloadProgress");

            downloadProgress.visible = false;
            downloadButton.clicked  += () =>
            {
                downloadProgress.visible = true;
                _butler.DownloadButler(
                    progress => downloadProgress.value = progress,
                    onComplete: () => ShowPage(_sharePage));
            };

            // Create Share Page
            var settingsSo = new SerializedObject(_settings);

            // Import Share UXML
            _sharePage = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(ShareUXML).CloneTree();
            _sharePage.styleSheets.Add(styleSheet);

            // Authenticate Butler
            _sharePage.Q <Button>("auth").clicked   += _butler.Login;
            _sharePage.Q <Button>("deAuth").clicked += () => SetConsoleContents(_butler.Logout());
            _sharePage.Q <Button>("update").clicked += () => SetConsoleContents(_butler.CheckForUpdates());


            _sharePage.Q <EnumField>("buildTarget").BindProperty(settingsSo.FindProperty("BuildTarget"));
            // Account, Project & URL
            var acct = _sharePage.Q <TextField>("account");

            acct.BindProperty(settingsSo.FindProperty("Account"));
            var prjct = _sharePage.Q <TextField>("project");

            prjct.BindProperty(settingsSo.FindProperty("Project"));
            var urlDisplay = _sharePage.Q <Label>("projectUrl");

            urlDisplay.RegisterCallback <MouseUpEvent>((cb) => Application.OpenURL(_settings.GetURL()));
            urlDisplay.text = _settings.GetURL();
            acct.RegisterValueChangedCallback((_) => urlDisplay.text  = _settings.GetURL());
            prjct.RegisterValueChangedCallback((_) => urlDisplay.text = _settings.GetURL());

            // Channel
            var channel = _sharePage.Q <TextField>("channel");

            channel.BindProperty(settingsSo.FindProperty("Channel"));
            var overrideChannel = _sharePage.Q <Toggle>("overrideChannel");

            overrideChannel.BindProperty(settingsSo.FindProperty("OverrideChannel"));
            channel.visible = overrideChannel.value;
            overrideChannel.RegisterValueChangedCallback((x) => channel.visible = x.newValue);
            // Version
            var version = _sharePage.Q <TextField>("version");

            version.BindProperty(settingsSo.FindProperty("Version"));
            var overrideVersion = _sharePage.Q <Toggle>("overrideVersion");

            overrideVersion.BindProperty(settingsSo.FindProperty("OverrideVersion"));
            version.visible = overrideVersion.value;
            overrideVersion.RegisterValueChangedCallback((x) => version.visible = x.newValue);

            //buildPath
            var buildPath = _sharePage.Q <TextField>("buildPath");

            buildPath.BindProperty(settingsSo.FindProperty("BuildPath"));
            var overridebuildPath = _sharePage.Q <Toggle>("overrideBuildPath");

            buildPath.visible = overridebuildPath.value;
            overridebuildPath.RegisterValueChangedCallback((x) => buildPath.visible = x.newValue);


            _devBuildToggle = _sharePage.Q <Toggle>("devBuild");
            _devBuildToggle.SetValueWithoutNotify(EditorUserBuildSettings.development);
            _devBuildToggle.RegisterValueChangedCallback((x) => EditorUserBuildSettings.development = x.newValue);

            // Build button
            var buildButton = _sharePage.Q <Button>("build");

            buildButton.clicked += Build;

            // Console
            _console            = _sharePage.Q <TextField>("console");
            _console.isReadOnly = true;

            // Initialize page
            if (!_butler.IsInstalled)
            {
                ShowPage(_downloadPage);
                return;
            }
            ShowPage(_sharePage);
        }
예제 #2
0
        void OnGUI()
        {
            if (!IsEditorSupported())
            {
                EditorGUILayout.HelpBox("ButlerWindow is only supported on Windows.", MessageType.Error);
                return;
            }

            if (!_butler.IsInstalled)
            {
                ButlerNotInstalledGUI();
                return;
            }



            GUILayout.Space(10f);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Butler Authentication");
            //TODO: Can check the pc for credentials to find out if it is authenticated.
            if (GUILayout.Button("Authenticate"))
            {
                _butler.Login();
            }
            if (GUILayout.Button("Remove Authentication"))
            {
                Console.Contents = _butler.Logout();
            }
            if (GUILayout.Button("Check for Updates"))
            {
                Console.SetContents(_butler.CheckForUpdates());
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            _settingsEditor.OnInspectorGUI();

            var webGLAvailable = true; //ModuleManagerProxy.IsBuildPlatformInstalled(BuildTarget.WebGL);

            if (!webGLAvailable)
            {
                EditorGUILayout.HelpBox(NO_WEBGL, MessageType.Warning);
            }

            EditorUserBuildSettings.development =
                EditorGUILayout.Toggle("Development Build", EditorUserBuildSettings.development);

            if (GUILayout.Button(_settings.GetURL(), EditorStyles.linkLabel))
            {
                Application.OpenURL(_settings.GetURL());
            }

            EditorGUILayout.BeginHorizontal();
            GUI.enabled = webGLAvailable && !_butler.IsUploading;
            if (GUILayout.Button("Build & Share"))
            {
                Build();
            }
            if (GUILayout.Button("Share"))
            {
                Share();
            }
            if (_butler.IsUploading)
            {
                EditorGUILayout.HelpBox("Uploading build to Itch.IO. Check console for progress.", MessageType.Info);
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
        }