Exemple #1
0
        private Drawable createColumn(ScrollingDirection direction, ManiaAction action, int index)
        {
            var column = new Column(index)
            {
                Anchor       = Anchor.Centre,
                Origin       = Anchor.Centre,
                Height       = 0.85f,
                AccentColour = Color4.OrangeRed,
                Action       = { Value = action },
            };

            columns.Add(column);

            return(new ScrollingTestContainer(direction)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                AutoSizeAxes = Axes.X,
                RelativeSizeAxes = Axes.Y,
                TimeRange = 2000,
                Child = column
            });
        }
Exemple #2
0
        public void ComputeInitialStates(IEnumerable <DrawableHitObject> hitObjects, ScrollingDirection direction, double timeRange, Vector2 length)
        {
            foreach (var obj in hitObjects)
            {
                // To reduce iterations when updating hitobject positions later on, their initial positions are cached
                var startPosition = hitObjectPositions[obj] = positionAt(obj.HitObject.StartTime, timeRange);

                // Todo: This is approximate and will be incorrect in the case of extreme speed changes
                obj.LifetimeStart = obj.HitObject.StartTime - timeRange - 1000;

                if (obj.HitObject is IHasEndTime endTime)
                {
                    var hitObjectLength = positionAt(endTime.EndTime, timeRange) - startPosition;

                    switch (direction)
                    {
                    case ScrollingDirection.Up:
                    case ScrollingDirection.Down:
                        obj.Height = (float)(hitObjectLength * length.Y);
                        break;

                    case ScrollingDirection.Left:
                    case ScrollingDirection.Right:
                        obj.Width = (float)(hitObjectLength * length.X);
                        break;
                    }
                }

                if (obj.HasNestedHitObjects)
                {
                    ComputeInitialStates(obj.NestedHitObjects, direction, timeRange, length);

                    // Nested hitobjects don't need to scroll, but they do need accurate positions
                    UpdatePositions(obj.NestedHitObjects, direction, obj.HitObject.StartTime, timeRange, length);
                }
            }
        }
        // sets up the scrolling in the correct direction
        // utilizes CSDisplayLink, a timer synchronized to the display refresh rate, to execute the smooth automated scrolling 
        private void SetupScrollTimerInDirection(ScrollingDirection direction)
        {
            if (DisplayLink != null && !DisplayLink.Paused)
            {
                var userInfo = userInfos[DisplayLink];
                var scrollingDirection = userInfo[ScrollingDirectionKey];
                var number = (NSNumber)NSNumber.FromObject(scrollingDirection);

                ScrollingDirection oldDirection = (ScrollingDirection)number.Int32Value;

                if (direction == oldDirection)
                {
                    return;
                }
            }
            InvalidatesScrollTimer();

            DisplayLink = CADisplayLink.Create(HandleScroll);
            userInfos.Add(DisplayLink, NSDictionary.FromObjectAndKey(NSNumber.FromInt32((int)direction), new NSString(ScrollingDirectionKey)));

            DisplayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSRunLoopCommonModes);
        }
Exemple #4
0
 public ScrollingTestContainer(ScrollingDirection direction)
 {
     this.direction = direction;
 }
 private void setScrollStep(ScrollingDirection direction)
 => AddStep($"set scroll direction = {direction}", () => ((Bindable <ScrollingDirection>)composer.Composer.ScrollingInfo.Direction).Value = direction);
Exemple #6
0
 /// <summary>
 /// Creates a new <see cref="ScrollingPlayfield"/>.
 /// </summary>
 /// <param name="direction">The direction in which <see cref="DrawableHitObject"/>s in this container should scroll.</param>
 /// <param name="customWidth">The width to scale the internal coordinate space to.
 /// May be null if scaling based on <paramref name="customHeight"/> is desired. If <paramref name="customHeight"/> is also null, no scaling will occur.
 /// </param>
 /// <param name="customHeight">The height to scale the internal coordinate space to.
 /// May be null if scaling based on <paramref name="customWidth"/> is desired. If <paramref name="customWidth"/> is also null, no scaling will occur.
 /// </param>
 protected ScrollingPlayfield(ScrollingDirection direction, float?customWidth = null, float?customHeight = null)
     : base(customWidth, customHeight)
 {
     this.direction = direction;
 }
Exemple #7
0
        public ManiaStage(ScrollingDirection direction, int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
            : base(direction)
        {
            this.firstColumnIndex = firstColumnIndex;

            Name = "Stage";

            Anchor           = Anchor.Centre;
            Origin           = Anchor.Centre;
            RelativeSizeAxes = Axes.Y;
            AutoSizeAxes     = Axes.X;

            InternalChildren = new Drawable[]
            {
                new Container
                {
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    RelativeSizeAxes = Axes.Y,
                    AutoSizeAxes     = Axes.X,
                    Children         = new Drawable[]
                    {
                        new Container
                        {
                            Name             = "Columns mask",
                            RelativeSizeAxes = Axes.Y,
                            AutoSizeAxes     = Axes.X,
                            Masking          = true,
                            CornerRadius     = 5,
                            Children         = new Drawable[]
                            {
                                new Box
                                {
                                    Name             = "Background",
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black
                                },
                                columnFlow = new FillFlowContainer <Column>
                                {
                                    Name             = "Columns",
                                    RelativeSizeAxes = Axes.Y,
                                    AutoSizeAxes     = Axes.X,
                                    Direction        = FillDirection.Horizontal,
                                    Padding          = new MarginPadding {
                                        Left = 1, Right = 1
                                    },
                                    Spacing = new Vector2(1, 0)
                                },
                            }
                        },
                        new Container
                        {
                            Name               = "Barlines mask",
                            Anchor             = Anchor.TopCentre,
                            Origin             = Anchor.TopCentre,
                            RelativeSizeAxes   = Axes.Y,
                            Width              = 1366, // Bar lines should only be masked on the vertical axis
                            BypassAutoSizeAxes = Axes.Both,
                            Masking            = true,
                            Child              = barLineContainer = new Container
                            {
                                Name             = "Bar lines",
                                Anchor           = Anchor.TopCentre,
                                Origin           = Anchor.TopCentre,
                                RelativeSizeAxes = Axes.Y,
                            }
                        },
                        judgements = new JudgementContainer <DrawableManiaJudgement>
                        {
                            Anchor             = Anchor.TopCentre,
                            Origin             = Anchor.Centre,
                            AutoSizeAxes       = Axes.Both,
                            Y                  = HIT_TARGET_POSITION + 150,
                            BypassAutoSizeAxes = Axes.Both
                        },
                        topLevelContainer = new Container {
                            RelativeSizeAxes = Axes.Both
                        }
                    }
                }
            };

            for (int i = 0; i < definition.Columns; i++)
            {
                var isSpecial = definition.IsSpecialColumn(i);
                var column    = new Column(direction)
                {
                    IsSpecial = isSpecial,
                    Action    = { Value = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++ }
                };

                AddColumn(column);
            }

            Direction.BindValueChanged(d =>
            {
                barLineContainer.Padding = new MarginPadding
                {
                    Top    = d == ScrollingDirection.Up ? HIT_TARGET_POSITION : 0,
                    Bottom = d == ScrollingDirection.Down ? HIT_TARGET_POSITION : 0,
                };
            }, true);
        }
Exemple #8
0
        protected override void OnDirectionChanged(ScrollingDirection direction)
        {
            base.OnDirectionChanged(direction);

            headPiece.Anchor = headPiece.Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
        }
Exemple #9
0
 public ScrollingTestContainer(ScrollingDirection direction)
 {
     scrollingInfo.Direction.Value = direction;
 }
Exemple #10
0
 protected virtual void OnDirectionChanged(ScrollingDirection direction)
 {
     Anchor = Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
 }
Exemple #11
0
        // actual scrolling logic that gets called by the CADisplayInfo timer
        // only matters if we have an active scroll animation command
        public void HandleScroll()
        {
            if (DisplayLink == null)
            {
                return;
            }
            var userInfo           = userInfos[DisplayLink];
            var scrollingDirection = userInfo[ScrollingDirectionKey];
            var number             = (NSNumber)NSNumber.FromObject(scrollingDirection);

            ScrollingDirection direction = (ScrollingDirection)(number.Int32Value);

            if (direction == ScrollingDirection.ScrollingDirectionUnknown)
            {
                return;
            }

            var frameSize     = CollectionView.Bounds.Size;
            var contentSize   = CollectionView.ContentSize;
            var contentOffset = CollectionView.ContentOffset;
            var distance      = (float)Math.Round(ScrollingSpeed / LX_FRAMES_PER_SECOND);
            var translation   = new PointF();

            switch (direction)
            {
            case ScrollingDirection.ScrollingDirectionUp:
                distance = -distance;
                var minY = 0.0f;
                if ((contentOffset.Y + distance) <= minY)
                {
                    distance = -contentOffset.Y;
                }

                translation = new PointF(0.0f, distance);
                break;

            case ScrollingDirection.ScrollingDirectionDown:
                float maxY = Math.Max(contentSize.Height, frameSize.Height) - frameSize.Height;

                if ((contentOffset.Y + distance) >= maxY)
                {
                    distance = maxY - contentOffset.Y;
                }

                translation = new PointF(0.0f, distance);
                break;

            case ScrollingDirection.ScrollingDirectionLeft:
                distance = -distance;
                float minX = 0.0f;

                if ((contentOffset.X + distance) <= minX)
                {
                    distance = -contentOffset.X;
                }

                translation = new PointF(distance, 0.0f);
                break;

            case ScrollingDirection.ScrollingDirectionRight:
                float maxX = Math.Max(contentSize.Width, frameSize.Width) - frameSize.Width;

                if ((contentOffset.X + distance) >= maxX)
                {
                    distance = maxX - contentOffset.X;
                }

                translation = new PointF(distance, 0.0f);
                break;

            default:
                break;
            }

            CurrentViewCenter = AddPoints(CurrentViewCenter, translation);
            if (CurrentView != null)
            {
                CurrentView.Center = AddPoints(CurrentViewCenter, PanTranslationInCollectionView);
            }
            CollectionView.ContentOffset = AddPoints(contentOffset, translation);
        }
Exemple #12
0
        protected override void OnDirectionChanged(ScrollingDirection direction)
        {
            base.OnDirectionChanged(direction);

            bodyPiece.Anchor = bodyPiece.Origin = direction == ScrollingDirection.Up ? Anchor.TopLeft : Anchor.BottomLeft;
        }
 public ManiaScrollingPlayfield(ScrollingDirection direction)
     : base(direction)
 {
 }