コード例 #1
0
        public void AddView(VisualElement parent)
        {
            parent.Add(new IMGUIContainer(() => EditorGUILayout.LabelField("APIアクセストークン", EditorStyles.boldLabel)));

            var accessToken = new TextField();

            accessToken.RegisterValueChangedCallback(ev =>
            {
                ValidateAndLogin(ev.newValue);
            });
            parent.Add(accessToken);

            parent.Add(
                new Button(() => Application.OpenURL(Constants.WebBaseUrl + "/app/my/tokens"))
            {
                text = "トークンを入手"
            });

            var messageLabel = new Label();

            parent.Add(messageLabel);
            ReactiveBinder.Bind(this.reactiveMessage, msg => { messageLabel.text = msg; });

            // TODO: 他のwindowでloginしたときにも自動で同期する
            if (!string.IsNullOrEmpty(EditorPrefsUtils.SavedAccessToken))
            {
                accessToken.value = EditorPrefsUtils.SavedAccessToken;
            }

            // 初期状態 or 既存のトークンをvalidateして何かのメッセージを出すのに必要
            ValidateAndLogin(EditorPrefsUtils.SavedAccessToken);
        }
コード例 #2
0
        VisualElement CreateVenueUi(UserInfo userInfo)
        {
            var selectVenue = new SelectVenueView(userInfo);

            var container = new VisualElement();
            var editAndUploadContainer = new VisualElement();
            var scrollView             = new ScrollView(ScrollViewMode.Vertical);

            {
                selectVenue.AddView(scrollView);
                scrollView.Add(UiUtils.Separator());
                scrollView.Add(editAndUploadContainer);
            }
            container.Add(scrollView);
            container.Add(UiUtils.Separator());

            var previewVenueView = new PreviewVenueView(selectVenue.reactiveCurrentVenue);

            previewVenueView.AddView(container);

            ReactiveBinder.Bind(selectVenue.reactiveCurrentVenue, currentVenue =>
            {
                editAndUploadContainer.Clear();
                if (currentVenue != null)
                {
                    new EditAndUploadVenueView(userInfo, currentVenue, () =>
                    {
                        selectVenue.RefetchVenueWithoutChangingSelection();
                    }).AddView(editAndUploadContainer);
                }
            });

            return(container);
        }
コード例 #3
0
        public void AddView(VisualElement parent)
        {
            selector = new VisualElement();
            var venueInfo = new VisualElement();

            parent.Add(selector);
            parent.Add(venueInfo);

            ReactiveBinder.Bind(reactiveCurrentVenue, venue =>
            {
                venueInfo.Clear();
                if (venue == null)
                {
                    return;
                }

                var thumbnailView = new DrawThumbnailView();
                venueInfo.Add(new IMGUIContainer(() =>
                {
                    EditorGUILayout.LabelField("説明");
                    EditorGUILayout.HelpBox(venue.Description, MessageType.None);

                    if (venue.ThumbnailUrls.Any())
                    {
                        thumbnailView.OverwriteDownloadUrl(venue.ThumbnailUrls.First(x => x != null));
                    }
                    thumbnailView.DrawUI(false);
                }));
            });

            RefreshVenueSelector();
        }
コード例 #4
0
        void OnEnable()
        {
            var tokenAuth = new TokenAuthWidget();

            tokenAuth.AddView(rootVisualElement);
            rootVisualElement.Add(UiUtils.Separator());

            VisualElement loggedInUiContainer = null;

            ReactiveBinder.Bind(tokenAuth.reactiveUserInfo, userInfo =>
            {
                if (loggedInUiContainer != null)
                {
                    rootVisualElement.Remove(loggedInUiContainer);
                }

                if (userInfo.HasValue)
                {
                    loggedInUiContainer = CreateVenueUi(userInfo.Value);
                    rootVisualElement.Add(loggedInUiContainer);
                }
                else
                {
                    loggedInUiContainer = null;
                }
            });
        }
コード例 #5
0
ファイル: VenueUploadWindow.cs プロジェクト: AkimiM/stage_360
        void OnEnable()
        {
            var tokenAuth     = new TokenAuthWidget();
            var tokenAuthView = tokenAuth.CreateView(); // .Bindで作り直すとなぜかYogaNodeがStackoverflowするので使い回す

            rootVisualElement.Add(tokenAuthView);

            VisualElement venueUi = null;

            ReactiveBinder.Bind(tokenAuth.reactiveUserInfo, userInfo =>
            {
                if (venueUi != null)
                {
                    rootVisualElement.Remove(venueUi);
                    venueUi = null;
                }

                if (userInfo.HasValue)
                {
                    venueUi = CreateVenueUi(tokenAuth, userInfo.Value);
                    rootVisualElement.Add(venueUi);

                    tokenAuthView.style.display = DisplayStyle.None;
                }
                else
                {
                    tokenAuthView.style.display = DisplayStyle.Flex;
                }
            });
        }
コード例 #6
0
ファイル: VenueUploadWindow.cs プロジェクト: AkimiM/stage_360
        VisualElement CreateVenueUi(TokenAuthWidget tokenAuth, UserInfo userInfo)
        {
            var container = new VisualElement()
            {
                style =
                {
                    flexDirection = FlexDirection.Row,
                    flexGrow      =                 1,
                }
            };
            var sidePane = new VisualElement()
            {
                style =
                {
                    borderColor      = new StyleColor(Color.gray),
                    borderRightWidth =                          1,
                    paddingRight     =                          4,
                }
            };
            var mainPane = new VisualElement()
            {
                style = { flexGrow = 1 }
            };

            container.Add(sidePane);
            container.Add(mainPane);

            // Side
            var sideMenu = new SideMenuVenueList(userInfo);

            sideMenu.AddView(sidePane);
            ReactiveBinder.Bind(sideMenu.reactiveForceLogout, forceLogout =>
            {
                if (forceLogout)
                {
                    tokenAuth.Logout();
                }
            });

            // Main
            ReactiveBinder.Bind(sideMenu.reactiveCurrentVenue, currentVenue =>
            {
                mainPane.Clear();
                if (currentVenue != null)
                {
                    var venueContent = new ScrollView(ScrollViewMode.Vertical)
                    {
                        style = { flexGrow = 1 }
                    };
                    new EditAndUploadVenueView(userInfo, currentVenue, () =>
                    {
                        sideMenu.RefetchVenueWithoutChangingSelection();
                    }).AddView(venueContent);
                    mainPane.Add(venueContent);
                }
            });

            return(container);
        }
コード例 #7
0
        public VisualElement CreateView()
        {
            var container = new VisualElement();

            container.Add(
                new Button(() => Application.OpenURL(ClusterVR.CreatorKit.Editor.Core.Constants.WebBaseUrl + "/account/tokens"))
            {
                text = "Webでトークンを発行"
            });

            container.Add(UiUtils.Separator());
            container.Add(new Label()
            {
                text = "アクセストークンを貼り付けてください"
            });

            var accessToken = new TextField();

            accessToken.RegisterValueChangedCallback(ev =>
            {
                Validate(ev.newValue);
            });
            container.Add(accessToken);

            var messageLabel = new Label();

            container.Add(messageLabel);
            ReactiveBinder.Bind(reactiveErrorMessage, msg => { messageLabel.text = msg; });

            var useTokenButton = new Button(() => ValidateAndLogin(accessToken.value))
            {
                text = "このトークンを使用",
            };

            ReactiveBinder.Bind(reactiveIsValidToken, useTokenButton.SetEnabled);
            container.Add(useTokenButton);

            // TODO: 他のwindowでloginしたときにも自動で同期する
            if (!string.IsNullOrEmpty(EditorPrefsUtils.SavedAccessToken))
            {
                accessToken.value = EditorPrefsUtils.SavedAccessToken;
            }

            // 初期状態 or 既存のトークンをvalidateして何かのメッセージを出すのに必要
            ValidateAndLogin(EditorPrefsUtils.SavedAccessToken);
            return(container);
        }
コード例 #8
0
        public VisualElement CreateView()
        {
            var img = new Label()
            {
                style =
                {
                    unityTextAlign           = TextAnchor.MiddleCenter,
                    unityBackgroundScaleMode = ScaleMode.ScaleToFit,
                    // 16:9
                    width  =                     256,
                    height =                     144,
                }
            };

            ReactiveBinder.Bind(reactiveImageTex, imageTex => img.style.backgroundImage = imageTex);
            ReactiveBinder.Bind(reactiveOverlay, overlay => img.text = overlay);
            return(img);
        }
コード例 #9
0
        void OnEnable()
        {
            Input.imeCompositionMode = IMECompositionMode.On;
            rootVisualElement.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>("Packages/mu.cluster.cluster-creator-kit/Editor/ClusterStyle.uss"));

            var tokenAuth     = new TokenAuthWidget();
            var tokenAuthView = tokenAuth.CreateView(); // .Bindで作り直すとなぜかYogaNodeがStackoverflowするので使い回す

            VisualElement venueUi = null;

            ReactiveBinder.Bind(tokenAuth.reactiveUserInfo, userInfo =>
            {
                if (venueUi != null)
                {
                    rootVisualElement.Remove(venueUi);
                    venueUi = null;
                }

                venueUi = CreateVenueUi(tokenAuth, tokenAuthView, userInfo);
                rootVisualElement.Add(venueUi);
                tokenAuthView.style.display = userInfo.HasValue ? DisplayStyle.None : DisplayStyle.Flex;
            });
        }
コード例 #10
0
        public VisualElement CreateView()
        {
            var container  = new VisualElement();
            var topSection = new VisualElement()
            {
                style = { flexDirection = FlexDirection.Row }
            };

            container.Add(topSection);

            {
                var thumbnailSection = new VisualElement();

                thumbnailSection.Add(thumbnailView.CreateView());

                var changeImageButton = new Button(() =>
                {
                    if (!updatingVenue)
                    {
                        newThumbnailPath =
                            EditorUtility.OpenFilePanelWithFilters(
                                "画像を選択",
                                "",
                                new[] { "Image files", "png,jpg,jpeg", "All files", "*" }
                                );
                        thumbnailView.SetImagePath(newThumbnailPath);
                        UpdateVenue();
                    }
                })
                {
                    text = "画像を変更"
                };
                thumbnailSection.Add(changeImageButton);

                topSection.Add(thumbnailSection);
            }

            {
                var editSection = new VisualElement()
                {
                    style = { flexGrow = 1 }
                };

                var venueIdSection = new VisualElement()
                {
                    style = { flexDirection = FlexDirection.Row }
                };
                venueIdSection.Add(new Label($"会場id: {venue.VenueId.Value}")
                {
                    style = { color = new StyleColor(Color.gray) }
                });
                venueIdSection.Add(new Button(() => EditorGUIUtility.systemCopyBuffer = venue.VenueId.Value)
                {
                    text = "copy"
                });

                editSection.Add(venueIdSection);

                editSection.Add(new Label("名前"));
                var venueName = new TextField();
                venueName.value = venue.Name;
                venueName.RegisterValueChangedCallback(ev =>
                {
                    newVenueName       = ev.newValue;
                    reactiveEdited.Val = true;
                });
                editSection.Add(venueName);

                editSection.Add(new Label("説明"));
                var venueDesc = new TextField()
                {
                    multiline = true,
                    style     = { height = 40, unityTextAlign = TextAnchor.UpperLeft },
                };
                foreach (var child in venueDesc.Children())
                {
                    child.style.unityTextAlign = TextAnchor.UpperLeft;
                }

                venueDesc.value = venue.Description;
                venueDesc.RegisterValueChangedCallback(ev =>
                {
                    newVenueDesc       = ev.newValue;
                    reactiveEdited.Val = true;
                });
                editSection.Add(venueDesc);

                var buttons = new VisualElement()
                {
                    style = { flexDirection = FlexDirection.Row }
                };
                var applyEdit = new Button(() =>
                {
                    if (!updatingVenue)
                    {
                        UpdateVenue();
                    }
                })
                {
                    text = "変更を保存"
                };
                var cancelEdit = new Button(() =>
                {
                    venueName.SetValueWithoutNotify(venue.Name);
                    venueDesc.SetValueWithoutNotify(venue.Description);
                    reactiveEdited.Val = false;
                })
                {
                    text = "キャンセル"
                };
                buttons.Add(applyEdit);
                buttons.Add(cancelEdit);
                ReactiveBinder.Bind(reactiveEdited, edited =>
                {
                    buttons.style.display = edited ? DisplayStyle.Flex : DisplayStyle.None;
                });

                editSection.Add(buttons);

                editSection.Add(new IMGUIContainer(() =>
                {
                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        EditorGUILayout.HelpBox(errorMessage, MessageType.Error);
                    }
                }));

                topSection.Add(editSection);
            }

            return(container);
        }
コード例 #11
0
        VisualElement CreateVenueUi(TokenAuthWidget tokenAuth, VisualElement tokenAuthView, UserInfo?userInfo)
        {
            var container = new VisualElement
            {
                style =
                {
                    flexDirection = FlexDirection.Row,
                    flexGrow      =                 1,
                }
            };
            var sidePane = new VisualElement
            {
                style =
                {
#if UNITY_2019_3_OR_NEWER
                    borderLeftColor   = new StyleColor(Color.gray),
                    borderRightColor  = new StyleColor(Color.gray),
                    borderTopColor    = new StyleColor(Color.gray),
                    borderBottomColor = new StyleColor(Color.gray),
#else
                    borderColor       = new StyleColor(Color.gray),
#endif
                    borderRightWidth =                          1,
                    width            =                        250,
                }
            };

            sidePane.EnableInClassList("pane", true);
            var mainPane = new VisualElement
            {
                style = { flexGrow = 1 }
            };

            mainPane.EnableInClassList("pane", true);
            container.Add(sidePane);
            container.Add(mainPane);

            // Side
            sidePane.Add(tokenAuthView);

            if (userInfo.HasValue)
            {
                var sideMenu = new SideMenuVenueList(userInfo.Value);
                sideMenu.AddView(sidePane);
                ReactiveBinder.Bind(sideMenu.reactiveForceLogout, forceLogout =>
                {
                    if (forceLogout)
                    {
                        tokenAuth.Logout();
                    }
                });

                // Main
                ReactiveBinder.Bind(sideMenu.reactiveCurrentVenue, currentVenue =>
                {
                    mainPane.Clear();
                    if (currentVenue != null)
                    {
                        var venueContent = new ScrollView(ScrollViewMode.Vertical)
                        {
                            style = { flexGrow = 1 }
                        };
                        new EditAndUploadVenueView(userInfo.Value, currentVenue, () =>
                        {
                            sideMenu.RefetchVenueWithoutChangingSelection();
                        }).AddView(venueContent);
                        mainPane.Add(venueContent);
                    }
                });
            }
            else
            {
                mainPane.Clear();
            }

            return(container);
        }
コード例 #12
0
        public SampleItemViewModel(SampleItemObservable model)
        {
            var binder = new ReactiveBinder <SampleItemObservable, SampleItemViewModel>();

            binder.BindObservable(model, this);
        }
コード例 #13
0
        public SampleItemViewModel(SampleItemModel model)
        {
            var binder = new ReactiveBinder <SampleItemModel, SampleItemViewModel>();

            binder.Bind(model, this);
        }