private void Init(IColorPreset colorPreset)
        {
            bgSprite = CreateChild <UguiSprite>("bg", -1);
            {
                bgSprite.Anchor = AnchorType.Fill;
                bgSprite.Offset = Offset.Zero;

                var gradient = bgSprite.AddEffect(new GradientEffect());
                gradient.Component.direction = UIGradient.Direction.Vertical;
                gradient.Component.color1    = colorPreset.Passive;
                gradient.Component.color2    = colorPreset.DarkBackground;
            }
            searchMenu = CreateChild <SearchMenu>("search-menu", 1);
            {
                searchMenu.Anchor = AnchorType.Fill;
                searchMenu.Pivot  = PivotType.Top;
                searchMenu.Offset = new Offset(0f, MenuBarHeight, 0f, 0f);
            }
            resultArea = CreateChild <UguiObject>("result-area", 1);
            {
                resultArea.Anchor = AnchorType.Fill;
                resultArea.Offset = new Offset(0f, searchMenu.FoldedHeight + MenuBarHeight, 0f, 0f);

                resultList = resultArea.CreateChild <ResultList>("list", 0);
                {
                    resultList.Anchor = AnchorType.Fill;
                    resultList.Offset = new Offset(8f, 0f);
                }
                resultLoader = resultArea.CreateChild <ResultLoader>("loader", 1);
                {
                    resultLoader.Anchor = AnchorType.Fill;
                    resultLoader.Offset = Offset.Zero;
                }
            }

            model.MapsetsRequest.OnNewValue += OnRequestChange;
        }
示例#2
0
        private void Init()
        {
            container = CreateChild <UguiObject>("container", 0);
            {
                container.Anchor = AnchorType.TopStretch;
                container.Pivot  = PivotType.Top;
                container.Y      = 0f;
                container.SetOffsetHorizontal(0f);
                container.Height = FoldedHeight;

                providerContainer = container.CreateChild <ProviderContainer>("provider", 1);
                {
                    providerContainer.Anchor = AnchorType.TopStretch;
                    providerContainer.Pivot  = PivotType.Top;
                    providerContainer.SetOffsetHorizontal(0f);
                    providerContainer.Y      = 0f;
                    providerContainer.Height = ProviderControllerHeight;
                }
                bannerContainer = container.CreateChild <BannerContainer>("banner", 0);
                {
                    bannerContainer.Anchor         = AnchorType.Fill;
                    bannerContainer.Offset         = new Offset(0f, 54f, 0f, 96f);
                    bannerContainer.IsInteractible = false;
                }
                searchBarContainer = container.CreateChild <SearchBarContainer>("search-bar", 2);
                {
                    searchBarContainer.Anchor = AnchorType.BottomStretch;
                    searchBarContainer.Pivot  = PivotType.Bottom;
                    searchBarContainer.SetOffsetHorizontal(0f);
                    searchBarContainer.Y      = 0f;
                    searchBarContainer.Height = SearchBarHeight;

                    searchBarContainer.AdvancedButton.OnTriggered += OnAdvancedButton;
                }
            }
            shadowButton = CreateChild <ShadowButton>("shadow", 1);
            {
                shadowButton.Anchor = AnchorType.Fill;
                shadowButton.Offset = new Offset(0f, FoldedHeight, 0f, 0f);
                shadowButton.Active = false;
                shadowButton.Alpha  = 0f;

                shadowButton.OnTriggered += OnShadowButton;
            }
            scrollTopButton = CreateChild <ScrollTopButton>("scroll-button", 2);
            {
                scrollTopButton.Anchor = AnchorType.Bottom;
                scrollTopButton.Y      = -28f;
                scrollTopButton.Size   = new Vector2(120f, 24f);
                scrollTopButton.Active = false;

                scrollTopButton.OnTriggered += OnScrollTopButton;
            }

            foldAni = new Anime();
            foldAni.AddEvent(0f, () => bannerContainer.IsInteractible = false);
            foldAni.AnimateFloat(h =>
            {
                container.Height = h;
                shadowButton.SetOffsetTop(h);
                bannerContainer.AdjustBannerTexture();
            })
            .AddTime(0f, () => container.Height)
            .AddTime(0.25f, FoldedHeight)
            .Build();
            foldAni.AnimateFloat(a => shadowButton.Alpha = a)
            .AddTime(0f, () => shadowButton.Alpha)
            .AddTime(0.25f, 0f)
            .Build();
            foldAni.AddEvent(0f, () => shadowButton.Active = false);

            unfoldAni = new Anime();
            unfoldAni.AddEvent(0f, () => shadowButton.Active = true);
            unfoldAni.AnimateFloat(h =>
            {
                container.Height = h;
                shadowButton.SetOffsetTop(h);
                bannerContainer.AdjustBannerTexture();
            })
            .AddTime(0f, () => container.Height)
            .AddTime(0.25f, UnfoldedHeight)
            .Build();
            unfoldAni.AnimateFloat(a => shadowButton.Alpha = a)
            .AddTime(0f, () => shadowButton.Alpha)
            .AddTime(0.25f, 0.5f)
            .Build();
            unfoldAni.AddEvent(unfoldAni.Duration, () => bannerContainer.IsInteractible = true);

            scrollButtonShowAni = new Anime();
            scrollButtonShowAni.AddEvent(0f, () => scrollTopButton.Active = true);
            scrollButtonShowAni.AnimateFloat((i) =>
            {
                scrollTopButton.Alpha = Easing.Linear(i, 0f, 1f, 0f);
                scrollTopButton.Y     = Easing.Linear(i, 0f, 28f, 0f);
            }).AddTime(0f, 0f, EaseType.BackEaseOut)
            .AddTime(0.25f, 1f)
            .Build();

            scrollButtonHideAni = new Anime();
            scrollButtonHideAni.AnimateFloat((i) =>
            {
                scrollTopButton.Alpha = Easing.Linear(i, 1f, -1f, 0f);
                scrollTopButton.Y     = Easing.Linear(i, 28f, -28f, 0f);
            }).AddTime(0f, 0f, EaseType.SineEaseOut)
            .AddTime(0.25f, 1f)
            .Build();
            scrollButtonHideAni.AddEvent(scrollButtonHideAni.Duration, () => scrollTopButton.Active = false);

            OnEnableInited();
        }
示例#3
0
        private void Init()
        {
            container = CreateChild <UguiObject>("container");
            {
                container.Anchor = AnchorType.TopStretch;
                container.Pivot  = PivotType.Top;
                container.SetOffsetHorizontal(0f);
                container.Height = ContainerHeight;
                container.Y      = 0f;

                backgroundSprite = container.CreateChild <BackgroundSprite>("background");
                {
                    backgroundSprite.Anchor  = AnchorType.Fill;
                    backgroundSprite.RawSize = Vector2.zero;
                    backgroundSprite.SetOffsetVertical(0f);
                }

                comboMenuButton = container.CreateChild <ComboMenuButton>("combo-menu");
                {
                    comboMenuButton.Anchor = AnchorType.LeftStretch;
                    comboMenuButton.Pivot  = PivotType.Left;
                    comboMenuButton.SetOffsetVertical(0f);
                    comboMenuButton.X     = 0f;
                    comboMenuButton.Width = 80f;
                }
                profileButton = container.CreateChild <ProfileMenuButton>("profile-menu");
                {
                    profileButton.Anchor = AnchorType.LeftStretch;
                    profileButton.Pivot  = PivotType.Left;
                    profileButton.SetOffsetVertical(0f);
                    profileButton.X     = comboMenuButton.Width;
                    profileButton.Width = 220f;
                }
                modeButton = container.CreateChild <ModeMenuButton>("mode-menu");
                {
                    modeButton.Anchor = AnchorType.LeftStretch;
                    modeButton.Pivot  = PivotType.Left;
                    modeButton.SetOffsetVertical(0f);
                    modeButton.X     = profileButton.X + profileButton.Width;
                    modeButton.Width = 80f;
                }

                notificationMenuButton = container.CreateChild <NotificationMenuButton>("notification-menu");
                {
                    notificationMenuButton.Anchor = AnchorType.RightStretch;
                    notificationMenuButton.Pivot  = PivotType.Right;
                    notificationMenuButton.SetOffsetVertical(0f);
                    notificationMenuButton.X     = 0f;
                    notificationMenuButton.Width = 80f;
                }
                settingsMenuButton = container.CreateChild <SettingsMenuButton>("settings-menu");
                {
                    settingsMenuButton.Anchor = AnchorType.RightStretch;
                    settingsMenuButton.Pivot  = PivotType.Right;
                    settingsMenuButton.SetOffsetVertical(0f);
                    settingsMenuButton.X     = -notificationMenuButton.Width;
                    settingsMenuButton.Width = 80f;
                }
                musicButton = container.CreateChild <MusicButton>("music-menu");
                {
                    musicButton.Anchor = AnchorType.RightStretch;
                    musicButton.Pivot  = PivotType.Right;
                    musicButton.SetOffsetVertical(0f);
                    musicButton.X     = settingsMenuButton.X - settingsMenuButton.Width;
                    musicButton.Width = 80f;
                }
            }

            menuButtons = GetComponentsInChildren <BaseMenuButton>(true);

            OnEnableInited();
        }
        private void Init()
        {
            Width = 0f;

            isTriggered.Bind(OnTriggeredChange);

            buttonTrigger = CreateChild <BasicTrigger>("trigger");
            {
                buttonTrigger.IsClickToTrigger = false;
                buttonTrigger.Anchor           = AnchorType.CenterStretch;
                buttonTrigger.Width            = 36f;
                buttonTrigger.SetOffsetVertical(0f);

                buttonTrigger.OnPointerDown += () => isTriggered.Value = true;
                buttonTrigger.OnPointerUp   += () => isTriggered.Value = false;

                var bg = buttonTrigger.CreateChild <UguiSprite>("bg");
                {
                    bg.Anchor = AnchorType.CenterStretch;
                    bg.SetOffsetVertical(0f);
                    bg.Width      = 8f;
                    bg.Color      = new Color(1f, 1f, 1f, 0.25f);
                    bg.SpriteName = "circle-8";
                    bg.ImageType  = Image.Type.Sliced;
                }
            }
            indicatorContainer = CreateChild <UguiObject>("container");
            {
                indicatorContainer.Anchor = AnchorType.CenterStretch;
                indicatorContainer.Width  = 0;
                indicatorContainer.SetOffsetVertical(0f);

                indicatorCanvas       = indicatorContainer.RawObject.AddComponent <CanvasGroup>();
                indicatorCanvas.alpha = 0f;

                shadowSprite = indicatorContainer.CreateChild <UguiSprite>("shadow");
                {
                    shadowSprite.Anchor     = AnchorType.Fill;
                    shadowSprite.Offset     = new Offset(0f, 9f, 0f, -9f);
                    shadowSprite.Color      = ColorPreset.Passive.Darken(0.5f);
                    shadowSprite.SpriteName = "parallel-64";
                    shadowSprite.ImageType  = Image.Type.Sliced;

                    shadowFlipEffect = shadowSprite.AddEffect(new FlipEffect());
                }
                bgSprite = indicatorContainer.CreateChild <UguiSprite>("bg");
                {
                    bgSprite.Anchor     = AnchorType.Fill;
                    bgSprite.Offset     = Offset.Zero;
                    bgSprite.Color      = ColorPreset.Passive;
                    bgSprite.SpriteName = "parallel-64";
                    bgSprite.ImageType  = Image.Type.Sliced;

                    bgFlipEffect = bgSprite.AddEffect(new FlipEffect());
                }
                iconSprite = indicatorContainer.CreateChild <UguiSprite>("icon");
                {
                    iconSprite.Y          = 0f;
                    iconSprite.Size       = new Vector2(24f, 24f);
                    iconSprite.SpriteName = "icon-pause";
                    iconSprite.Color      = ColorPreset.PrimaryFocus;
                }

                indicatorContainer.Active = false;
            }

            showAni = new Anime();
            showAni.AddEvent(0f, () => indicatorContainer.Active     = true);
            showAni.AnimateFloat((width) => indicatorContainer.Width = width)
            .AddTime(0f, 0, EaseType.BackEaseOut)
            .AddTime(0.25f, 196f)
            .Build();
            showAni.AnimateFloat((alpha) => indicatorCanvas.alpha = alpha)
            .AddTime(0f, () => indicatorCanvas.alpha)
            .AddTime(0.25f, 1f)
            .Build();

            hideAni = new Anime();
            hideAni.AnimateFloat((width) => indicatorContainer.Width = width)
            .AddTime(0f, 196f, EaseType.CubicEaseIn)
            .AddTime(0.25f, 0f)
            .Build();
            hideAni.AnimateFloat((alpha) => indicatorCanvas.alpha = alpha)
            .AddTime(0f, () => indicatorCanvas.alpha)
            .AddTime(0.25f, 0f)
            .Build();
            hideAni.AddEvent(hideAni.Duration, () => indicatorContainer.Active = false);
        }