コード例 #1
0
ファイル: SkinnableTargetContainer.cs プロジェクト: Wieku/osu
        public void Reload()
        {
            ClearInternal();
            components.Clear();
            ComponentsLoaded = false;

            content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetComponentsContainer;

            cancellationSource?.Cancel();
            cancellationSource = null;

            if (content != null)
            {
                LoadComponentAsync(content, wrapper =>
                {
                    AddInternal(wrapper);
                    components.AddRange(wrapper.Children.OfType <ISkinnableDrawable>());
                    ComponentsLoaded = true;
                }, (cancellationSource = new CancellationTokenSource()).Token);
            }
            else
            {
                ComponentsLoaded = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Reload all components in this container from the current skin.
        /// </summary>
        public void Reload()
        {
            ClearInternal();
            components.Clear();

            content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetComponentsContainer;

            if (content != null)
            {
                LoadComponentAsync(content, wrapper =>
                {
                    AddInternal(wrapper);
                    components.AddRange(wrapper.Children.OfType <ISkinnableDrawable>());
                });
            }
        }
コード例 #3
0
        public override Drawable GetDrawableComponent(ISkinComponent component)
        {
            if (base.GetDrawableComponent(component) is Drawable c)
            {
                return(c);
            }

            switch (component)
            {
            case SkinnableTargetComponent target:
                switch (target.Target)
                {
                case SkinnableTarget.MainHUDComponents:
                    var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
                    {
                        var score     = container.OfType <DefaultScoreCounter>().FirstOrDefault();
                        var accuracy  = container.OfType <DefaultAccuracyCounter>().FirstOrDefault();
                        var combo     = container.OfType <DefaultComboCounter>().FirstOrDefault();
                        var ppCounter = container.OfType <PerformancePointsCounter>().FirstOrDefault();

                        if (score != null)
                        {
                            score.Anchor = Anchor.TopCentre;
                            score.Origin = Anchor.TopCentre;

                            // elements default to beneath the health bar
                            const float vertical_offset = 30;

                            const float horizontal_padding = 20;

                            score.Position = new Vector2(0, vertical_offset);

                            if (ppCounter != null)
                            {
                                ppCounter.Y      = score.Position.Y + ppCounter.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).Y - 4;
                                ppCounter.Origin = Anchor.TopCentre;
                                ppCounter.Anchor = Anchor.TopCentre;
                            }

                            if (accuracy != null)
                            {
                                accuracy.Position = new Vector2(-accuracy.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).X / 2 - horizontal_padding, vertical_offset + 5);
                                accuracy.Origin   = Anchor.TopRight;
                                accuracy.Anchor   = Anchor.TopCentre;
                            }

                            if (combo != null)
                            {
                                combo.Position = new Vector2(accuracy.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).X / 2 + horizontal_padding, vertical_offset + 5);
                                combo.Anchor   = Anchor.TopCentre;
                            }

                            var hitError = container.OfType <HitErrorMeter>().FirstOrDefault();

                            if (hitError != null)
                            {
                                hitError.Anchor = Anchor.CentreLeft;
                                hitError.Origin = Anchor.CentreLeft;
                            }

                            var hitError2 = container.OfType <HitErrorMeter>().LastOrDefault();

                            if (hitError2 != null)
                            {
                                hitError2.Anchor = Anchor.CentreRight;
                                hitError2.Scale  = new Vector2(-1, 1);
                                // origin flipped to match scale above.
                                hitError2.Origin = Anchor.CentreLeft;
                            }
                        }
                    })
                    {
                        Children = new Drawable[]
                        {
                            new DefaultComboCounter(),
                            new DefaultScoreCounter(),
                            new DefaultAccuracyCounter(),
                            new DefaultHealthDisplay(),
                            new SongProgress(),
                            new BarHitErrorMeter(),
                            new BarHitErrorMeter(),
                            new PerformancePointsCounter()
                        }
                    };

                    return(skinnableTargetWrapper);
                }

                break;
            }

            return(null);
        }
コード例 #4
0
ファイル: DefaultSkin.cs プロジェクト: shadiwolf/e
        public override Drawable GetDrawableComponent(ISkinComponent component)
        {
            if (base.GetDrawableComponent(component) is Drawable c)
            {
                return(c);
            }

            switch (component)
            {
            case SkinnableTargetComponent target:
                switch (target.Target)
                {
                case SkinnableTarget.MainHUDComponents:
                    var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
                    {
                        var score    = container.OfType <DefaultScoreCounter>().FirstOrDefault();
                        var accuracy = container.OfType <DefaultAccuracyCounter>().FirstOrDefault();
                        var combo    = container.OfType <DefaultComboCounter>().FirstOrDefault();

                        if (score != null)
                        {
                            score.Anchor = Anchor.TopCentre;
                            score.Origin = Anchor.TopCentre;

                            // elements default to beneath the health bar
                            const float vertical_offset = 30;

                            const float horizontal_padding = 20;

                            score.Position = new Vector2(0, vertical_offset);

                            if (accuracy != null)
                            {
                                accuracy.Position = new Vector2(-accuracy.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).X / 2 - horizontal_padding, vertical_offset + 5);
                                accuracy.Origin   = Anchor.TopRight;
                                accuracy.Anchor   = Anchor.TopCentre;
                            }

                            if (combo != null)
                            {
                                combo.Position = new Vector2(accuracy.ScreenSpaceDeltaToParentSpace(score.ScreenSpaceDrawQuad.Size).X / 2 + horizontal_padding, vertical_offset + 5);
                                combo.Anchor   = Anchor.TopCentre;
                            }
                        }
                    })
                    {
                        Children = new[]
                        {
                            GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ComboCounter)),
                            GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreCounter)),
                            GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter)),
                            GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.HealthDisplay)),
                        }
                    };

                    return(skinnableTargetWrapper);
                }

                break;

            case HUDSkinComponent hudComponent:
            {
                switch (hudComponent.Component)
                {
                case HUDSkinComponents.ComboCounter:
                    return(new DefaultComboCounter());

                case HUDSkinComponents.ScoreCounter:
                    return(new DefaultScoreCounter());

                case HUDSkinComponents.AccuracyCounter:
                    return(new DefaultAccuracyCounter());

                case HUDSkinComponents.HealthDisplay:
                    return(new DefaultHealthDisplay());
                }

                break;
            }
            }

            return(null);
        }
コード例 #5
0
        public override Drawable?GetDrawableComponent(ISkinComponent component)
        {
            if (base.GetDrawableComponent(component) is Drawable c)
            {
                return(c);
            }

            switch (component)
            {
            case SkinnableTargetComponent target:
                switch (target.Target)
                {
                case SkinnableTarget.MainHUDComponents:
                    var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
                    {
                        var score    = container.OfType <LegacyScoreCounter>().FirstOrDefault();
                        var accuracy = container.OfType <GameplayAccuracyCounter>().FirstOrDefault();
                        var combo    = container.OfType <LegacyComboCounter>().FirstOrDefault();

                        if (score != null && accuracy != null)
                        {
                            accuracy.Y = container.ToLocalSpace(score.ScreenSpaceDrawQuad.BottomRight).Y;
                        }

                        var songProgress = container.OfType <SongProgress>().FirstOrDefault();

                        var hitError = container.OfType <HitErrorMeter>().FirstOrDefault();

                        if (hitError != null)
                        {
                            hitError.Anchor   = Anchor.BottomCentre;
                            hitError.Origin   = Anchor.CentreLeft;
                            hitError.Rotation = -90;
                        }

                        if (songProgress != null)
                        {
                            if (hitError != null)
                            {
                                hitError.Y -= SongProgress.MAX_HEIGHT;
                            }
                            if (combo != null)
                            {
                                combo.Y -= SongProgress.MAX_HEIGHT;
                            }
                        }
                    })
                    {
                        Children = new Drawable[]
                        {
                            new LegacyComboCounter(),
                            new LegacyScoreCounter(),
                            new LegacyAccuracyCounter(),
                            new LegacyHealthDisplay(),
                            new SongProgress(),
                            new BarHitErrorMeter(),
                        }
                    };

                    return(skinnableTargetWrapper);
                }

                return(null);

            case GameplaySkinComponent <HitResult> resultComponent:
                // TODO: this should be inside the judgement pieces.
                Func <Drawable?> createDrawable = () => getJudgementAnimation(resultComponent.Component);

                // kind of wasteful that we throw this away, but should do for now.
                if (createDrawable() != null)
                {
                    var particle = getParticleTexture(resultComponent.Component);

                    if (particle != null)
                    {
                        return(new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, particle));
                    }
                    else
                    {
                        return(new LegacyJudgementPieceOld(resultComponent.Component, createDrawable));
                    }
                }

                break;
            }

            return(this.GetAnimation(component.LookupName, false, false));
        }