Example #1
0
        private void applyAspectRatio(BindableNumber <float> sizeChanged)
        {
            try
            {
                if (!aspectLock.Value)
                {
                    float proposedAspectRatio = currentAspectRatio;

                    if (proposedAspectRatio >= aspectRatio.MinValue && proposedAspectRatio <= aspectRatio.MaxValue)
                    {
                        // aspect ratio was in a valid range.
                        updateAspectRatio();
                        return;
                    }
                }

                // if lock is applied (or the specified values were out of range) aim to adjust the axis the user was not adjusting to conform.
                if (sizeChanged == sizeX)
                {
                    sizeY.Value = (int)(areaSize.Value.X / aspectRatio.Value);
                }
                else
                {
                    sizeX.Value = (int)(areaSize.Value.Y * aspectRatio.Value);
                }
            }
            finally
            {
                // cancel any event which may have fired while updating variables as a result of aspect ratio limitations.
                // this avoids a potential feedback loop.
                aspectRatioApplication?.Cancel();
            }
        }
Example #2
0
        public DifficultyPointPiece(HitObject hitObject)
            : base(hitObject.DifficultyControlPoint)
        {
            HitObject = hitObject;

            speedMultiplier = hitObject.DifficultyControlPoint.SliderVelocityBindable.GetBoundCopy();
        }
Example #3
0
 public SamplePointPiece(HitObject hitObject)
     : base(hitObject.SampleControlPoint)
 {
     HitObject = hitObject;
     volume    = hitObject.SampleControlPoint.SampleVolumeBindable.GetBoundCopy();
     bank      = hitObject.SampleControlPoint.SampleBankBindable.GetBoundCopy();
 }
Example #4
0
 public EffectRowAttribute(EffectControlPoint effect)
     : base(effect, "effect")
 {
     kiaiMode    = effect.KiaiModeBindable.GetBoundCopy();
     omitBarLine = effect.OmitFirstBarLineBindable.GetBoundCopy();
     scrollSpeed = effect.ScrollSpeedBindable.GetBoundCopy();
 }
        public DifficultyPointPiece(DifficultyControlPoint point)
            : base(point)
        {
            speedMultiplier = point.SpeedMultiplierBindable.GetBoundCopy();

            Y = Height;
        }
Example #6
0
        protected SliderBar()
        {
            if (typeof(T) == typeof(int))
            {
                CurrentNumber = new BindableInt() as BindableNumber <T>;
            }
            else if (typeof(T) == typeof(long))
            {
                CurrentNumber = new BindableLong() as BindableNumber <T>;
            }
            else if (typeof(T) == typeof(double))
            {
                CurrentNumber = new BindableDouble() as BindableNumber <T>;
            }
            else if (typeof(T) == typeof(float))
            {
                CurrentNumber = new BindableFloat() as BindableNumber <T>;
            }

            if (CurrentNumber == null)
            {
                throw new NotSupportedException($"We don't support the generic type of {nameof(BindableNumber<T>)}.");
            }

            CurrentNumber.ValueChanged += v => UpdateValue(NormalizedValue);
        }
Example #7
0
 /// <summary>
 /// Applies a setting from a configuration bindable using <paramref name="applyFunc"/>, if it has been changed by the user.
 /// </summary>
 protected void ApplySetting <T>(BindableNumber <T> setting, Action <T> applyFunc)
     where T : struct, IComparable <T>, IConvertible, IEquatable <T>
 {
     if (userChangedSettings.TryGetValue(setting, out bool userChangedSetting) && userChangedSetting)
     {
         applyFunc.Invoke(setting.Value);
     }
 }
Example #8
0
        private void load(PippidonPlayfield playfield, TextureStore textures)
        {
            AddInternal(new Sprite
            {
                RelativeSizeAxes = Axes.Both,
                Texture          = textures.Get("coin"),
            });

            currentLane = playfield.CurrentLane.GetBoundCopy();
        }
Example #9
0
            private void load()
            {
                sampleBank = samplePoint.SampleBankBindable.GetBoundCopy();
                sampleBank.BindValueChanged(_ => recreate());

                sampleVolume = samplePoint.SampleVolumeBindable.GetBoundCopy();
                sampleVolume.BindValueChanged(_ => recreate());

                recreate();
            }
Example #10
0
        public RomajiTagSelectionBlueprint(ITextTag item)
            : base(item)
        {
            if (!(item is RomajiTag romajiTag))
            {
                throw new InvalidCastException(nameof(item));
            }

            text       = romajiTag.TextBindable.GetBoundCopy();
            startIndex = romajiTag.StartIndexBindable.GetBoundCopy();
            endIndex   = romajiTag.EndIndexBindable.GetBoundCopy();
        }
Example #11
0
        public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
        {
            if (HiddenComboCount.Value == 0)
            {
                return;
            }

            currentCombo = scoreProcessor.Combo.GetBoundCopy();
            currentCombo.BindValueChanged(combo =>
            {
                targetAlpha = Math.Max(min_alpha, 1 - (float)combo.NewValue / HiddenComboCount.Value);
            }, true);
        }
Example #12
0
        public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
        {
            if (HiddenComboCount.Value == 0)
            {
                return;
            }

            CurrentCombo = scoreProcessor.Combo.GetBoundCopy();
            CurrentCombo.BindValueChanged(combo =>
            {
                ComboBasedAlpha = Math.Max(MIN_ALPHA, 1 - (float)combo.NewValue / HiddenComboCount.Value);
            }, true);
        }
Example #13
0
        /// <summary>
        /// Transfer a setting from <see cref="BeatmapDifficulty"/> to a configuration bindable.
        /// Only performs the transfer if the user is not currently overriding.
        /// </summary>
        protected void TransferSetting <T>(BindableNumber <T> bindable, T beatmapDefault)
            where T : struct, IComparable <T>, IConvertible, IEquatable <T>
        {
            bindable.UnbindEvents();

            userChangedSettings.TryAdd(bindable, false);

            bindable.Default = beatmapDefault;

            // users generally choose a difficulty setting and want it to stick across multiple beatmap changes.
            // we only want to value transfer if the user hasn't changed the value previously.
            if (!userChangedSettings[bindable])
            {
                bindable.Value = beatmapDefault;
            }

            bindable.ValueChanged += _ => userChangedSettings[bindable] = !bindable.IsDefault;
        }
Example #14
0
 public ColourPropertyDisplay(string name, Func <int, Color4> resultColour)
 {
     resultFunction   = resultColour;
     RelativeSizeAxes = Axes.X;
     Height           = height;
     Children         = new Drawable[]
     {
         new SpriteText
         {
             Text = name,
             Font = new FontUsage(null, font_size)
         },
         new FillFlowContainer <GridItem>
         {
             RelativeSizeAxes = Axes.X,
             Height           = slider_height,
             Direction        = FillDirection.Horizontal,
             Spacing          = new osuTK.Vector2(spacing),
             Anchor           = Anchor.BottomLeft,
             Origin           = Anchor.BottomLeft,
             Children         = new GridItem[]
             {
                 new GridItem(new HBSliderBar <int>
                 {
                     RelativeSizeAxes = Axes.Both,
                     Current          = Bindable = new BindableNumber <int>
                     {
                         MinValue  = 0,
                         MaxValue  = 255,
                         Value     = 127,
                         Precision = 1
                     }
                 }),
                 new GridItem(0.2f, resultBox = new Box
                 {
                     RelativeSizeAxes = Axes.Both
                 })
             }
         }
     };
     Bindable.BindValueChanged(OnValueChanged, true);
 }
            public BindableDisplayContainer(BindableNumber <T> bindable)
            {
                Anchor = Anchor.Centre;
                Origin = Anchor.Centre;

                SpriteText valueText;

                InternalChild = new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Direction    = FillDirection.Vertical,
                    Children     = new Drawable[]
                    {
                        new SpriteText {
                            Text = $"{typeof(T).Name} value:"
                        },
                        valueText = new SpriteText {
                            Text = bindable.Value.ToString(CultureInfo.InvariantCulture)
                        }
                    }
                };

                bindable.ValueChanged += v => valueText.Text = v.ToString(CultureInfo.InvariantCulture);
            }
Example #16
0
 public DifficultyPointPiece(DifficultyControlPoint difficultyPoint)
 {
     this.difficultyPoint = difficultyPoint;
     speedMultiplier      = difficultyPoint.SpeedMultiplierBindable.GetBoundCopy();
 }
Example #17
0
 public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
 {
     health = scoreProcessor.Health.GetBoundCopy();
 }
Example #18
0
 public void RemoveAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable)
 => getAggregate(type).RemoveSource(adjustBindable);
Example #19
0
 public void AddAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) => throw new NotImplementedException();
 public void RemoveAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) =>
 adjustments.RemoveAdjustment(type, adjustBindable);
Example #21
0
 public SamplePointPiece(SampleControlPoint samplePoint)
 {
     this.samplePoint = samplePoint;
     volume           = samplePoint.SampleVolumeBindable.GetBoundCopy();
     bank             = samplePoint.SampleBankBindable.GetBoundCopy();
 }
Example #22
0
 public DifficultyRowAttribute(DifficultyControlPoint difficulty)
     : base(difficulty, "difficulty")
 {
     speedMultiplier = difficulty.SpeedMultiplierBindable.GetBoundCopy();
 }
Example #23
0
 public TimingPointPiece(TimingControlPoint point)
 {
     this.point = point;
     beatLength = point.BeatLengthBindable.GetBoundCopy();
 }
Example #24
0
 public TimingRowAttribute(TimingControlPoint timing)
     : base(timing, "timing")
 {
     timeSignature = timing.TimeSignatureBindable.GetBoundCopy();
     beatLength    = timing.BeatLengthBindable.GetBoundCopy();
 }
Example #25
0
 public void RemoveAdjustment(AdjustableProperty type, BindableNumber <double> adjustBindable) => throw new NotSupportedException();
Example #26
0
 public TimingPointPiece(TimingControlPoint point)
     : base(point)
 {
     beatLength = point.BeatLengthBindable.GetBoundCopy();
 }
Example #27
0
 private void load(SolosuPlayfield playfield)
 {
     currentLane = playfield.CurrentLane.GetBoundCopy();
 }
Example #28
0
 public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
 {
     health = healthProcessor.Health.GetBoundCopy();
 }
Example #29
0
 public SampleRowAttribute(SampleControlPoint sample)
     : base(sample, "sample")
 {
     sampleBank = sample.SampleBankBindable.GetBoundCopy();
     volume     = sample.SampleVolumeBindable.GetBoundCopy();
 }