コード例 #1
0
        /// <summary>
        ///     Called when the selected value changes
        /// </summary>
        /// <param name="val"></param>
        /// <param name="index"></param>
        private static void OnSelected(string val, int index)
        {
            if (val == "1.0x")
            {
                ModManager.RemoveSpeedMods();
                return;
            }

            ModManager.AddMod(ModHelper.GetModsFromRate(float.Parse(val.Replace("x", ""))));
        }
コード例 #2
0
ファイル: ModManager.cs プロジェクト: harish-kumar13/Quaver
        /// <summary>
        ///     Adds speed mods from a given rate.
        /// </summary>
        /// <param name="rate"></param>
        public static void AddSpeedMods(float rate)
        {
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (rate == 1.0f)
            {
                RemoveSpeedMods();
                return;
            }

            var speedMod = ModHelper.GetModsFromRate(rate);

            if (speedMod == ModIdentifier.None)
            {
                return;
            }

            AddMod(speedMod);
        }
コード例 #3
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="container"></param>
        /// <param name="item"></param>
        /// <param name="index"></param>
        /// <param name="header"></param>
        public ResultMultiplayerScoreboardUser(PoolableScrollContainer <ScoreboardUser> container, ScoreboardUser item, int index, ResultMultiplayerScoreboardTableHeader header)
            : base(container, item, index)
        {
            Header = header;
            Size   = new ScalableVector2(container.Width, HEIGHT);
            Alpha  = 0.85f;

            Button = new ResultMultiplayerScoreboardUserButton(Item, container)
            {
                Parent = this,
                Size   = Size,
                UsePreviousSpriteBatchOptions = true
            };

            // ReSharper disable once ObjectCreationAsStatement
            var rank = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{item.Rank}.")
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                X         = 20,
                FontSize  = 16,
                Tint      = Item.Type == ScoreboardUserType.Self ? Colors.SecondaryAccent : Color.White,
                UsePreviousSpriteBatchOptions = true
            };

            var avatar = new Sprite
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                Size      = new ScalableVector2(32, 32),
                X         = 56,
                Image     = item.Avatar.Image,
                UsePreviousSpriteBatchOptions = true
            };

            avatar.AddBorder(Color.White, 2);

            var username = new SpriteTextBitmap(FontsBitmap.GothamRegular, item.UsernameRaw)
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                X         = avatar.X + avatar.Width + 16,
                FontSize  = 16,
                Tint      = Item.Type == ScoreboardUserType.Self ? Colors.SecondaryAccent : Color.White,
                UsePreviousSpriteBatchOptions = true
            };

            if (item.Processor == null)
            {
                return;
            }

            CreateData(new Dictionary <string, string>
            {
                { "Rating", item.CalculateRating().ToString("00.00") },
                { "Grade", "" },
                { "Accuracy", StringHelper.AccuracyToString(item.Processor.Accuracy) },
                { "Max Combo", item.Processor.MaxCombo + "x" },
                { "Marv", item.Processor.CurrentJudgements[Judgement.Marv].ToString() },
                { "Perf", item.Processor.CurrentJudgements[Judgement.Perf].ToString() },
                { "Great", item.Processor.CurrentJudgements[Judgement.Great].ToString() },
                { "Good", item.Processor.CurrentJudgements[Judgement.Good].ToString() },
                { "Okay", item.Processor.CurrentJudgements[Judgement.Okay].ToString() },
                { "Miss", item.Processor.CurrentJudgements[Judgement.Miss].ToString() },
                { "Mods", item.Processor.Mods <= 0 ? "None" : ModHelper.GetModsString(ModHelper.GetModsFromRate(ModHelper.GetRateFromMods(item.Processor.Mods))) }
            });

            // ReSharper disable once ObjectCreationAsStatement
            new Sprite
            {
                Parent    = this,
                Alignment = Alignment.BotLeft,
                Size      = new ScalableVector2(Width, 1),
                Alpha     = 0.3f
            };
        }
コード例 #4
0
        /// <summary>
        ///     Closes the dialog.
        /// </summary>
        public void Close(bool changeMods = true)
        {
            if (isClosing)
            {
                return;
            }

            if (OnlineManager.CurrentGame != null && changeMods)
            {
                if (ModsWhenDialogOpen != ModManager.Mods)
                {
                    var diffRating = OnlineManager.CurrentGame.DifficultyRating;

                    // Only update the difficulty rating when closing if the selected map is still the same.
                    // If the user switches maps, but changes modifiers, it'll be incorrect.
                    if (MapManager.Selected.Value != null && MapManager.Selected.Value.Md5Checksum == OnlineManager.CurrentGame.MapMd5)
                    {
                        diffRating = MapManager.Selected.Value.DifficultyFromMods(ModManager.Mods);
                    }

                    var rateNow = ModHelper.GetRateFromMods(ModManager.Mods);

                    // Change the global mods of the game
                    var rateMod = (long)ModHelper.GetModsFromRate(rateNow);

                    if (rateMod == -1)
                    {
                        rateMod = 0;
                    }

                    var           activeModsWithoutRate  = (long)ModManager.Mods - rateMod;
                    ModIdentifier hostOnlyMods           = 0L;
                    var           onlyHostChangeableMods = ModManager.CurrentModifiersList.FindAll(x => x.OnlyMultiplayerHostCanCanChange);

                    if (onlyHostChangeableMods.Count != 0)
                    {
                        onlyHostChangeableMods.ForEach(x =>
                        {
                            // ReSharper disable once AccessToModifiedClosure
                            activeModsWithoutRate -= (long)x.ModIdentifier;
                            hostOnlyMods          |= x.ModIdentifier;
                        });
                    }

                    if (activeModsWithoutRate == -1)
                    {
                        activeModsWithoutRate = 0;
                    }

                    // If we're on regular free mod mode, when we change the rate,
                    // ReSharper disable once CompareOfFloatsByEqualityOperator
                    if (OnlineManager.CurrentGame.FreeModType == MultiplayerFreeModType.Regular &&
                        (ModHelper.GetRateFromMods(ModsWhenDialogOpen) != rateNow || hostOnlyMods != 0) &&
                        OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                    {
                        OnlineManager.Client?.MultiplayerChangeGameModifiers(rateMod + (long)hostOnlyMods, diffRating);

                        // Change the mods of ourselves minus the mods rate (gets all other activated modes)
                        OnlineManager.Client?.MultiplayerChangePlayerModifiers(activeModsWithoutRate);
                    }
                    // Free mod is enabled, but we haven't done any rate changing, so just
                    // enable player modifiers for us
                    else if (OnlineManager.CurrentGame.FreeModType != MultiplayerFreeModType.None)
                    {
                        // Free Mod + Free Rate
                        if (OnlineManager.CurrentGame.FreeModType.HasFlag(MultiplayerFreeModType.Regular) &&
                            OnlineManager.CurrentGame.FreeModType.HasFlag(MultiplayerFreeModType.Rate))
                        {
                            if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                            {
                                OnlineManager.Client?.MultiplayerChangeGameModifiers((long)hostOnlyMods, diffRating);
                            }

                            OnlineManager.Client?.MultiplayerChangePlayerModifiers((long)ModManager.Mods);
                        }
                        // Either Free Mod OR Free Rate
                        else
                        {
                            switch (OnlineManager.CurrentGame.FreeModType)
                            {
                            case MultiplayerFreeModType.Regular:
                                OnlineManager.Client?.MultiplayerChangePlayerModifiers(activeModsWithoutRate);

                                if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                                {
                                    OnlineManager.Client?.MultiplayerChangeGameModifiers(rateMod + (long)hostOnlyMods, diffRating);
                                }
                                break;

                            case MultiplayerFreeModType.Rate:
                                OnlineManager.Client?.MultiplayerChangePlayerModifiers((long)ModHelper.GetModsFromRate(rateNow));

                                if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                                {
                                    OnlineManager.Client?.MultiplayerChangeGameModifiers(activeModsWithoutRate + (long)hostOnlyMods, diffRating);
                                }
                                break;
                            }
                        }
                    }
                    // We're host & free mod isn't enabled, so change the global game mods
                    else if (OnlineManager.CurrentGame.Host == OnlineManager.Self.OnlineUser)
                    {
                        OnlineManager.Client?.MultiplayerChangeGameModifiers((long)ModManager.Mods, diffRating);
                    }
                }
            }

            isClosing = true;
            InterfaceContainer.Animations.Clear();
            InterfaceContainer.Animations.Add(new Animation(AnimationProperty.Y, Easing.OutQuint, InterfaceContainer.Y, InterfaceContainer.Height, 600));
            ThreadScheduler.RunAfter(() => DialogManager.Dismiss(this), 450);
        }