/// <summary> /// </summary> /// <param name="name"></param> /// <returns></returns> private static JudgementWindows CreatePresetWindows(string name, int n) { var windows = new JudgementWindows { Name = name, IsDefault = true, }; const float constant = 1.1f; windows.Marvelous /= (float)Math.Pow(constant, n); windows.Perfect /= (float)Math.Pow(constant, n); windows.Great /= (float)Math.Pow(constant, n); windows.Good /= (float)Math.Pow(constant, n); windows.Okay /= (float)Math.Pow(constant, n); windows.Miss /= (float)Math.Pow(constant, n); windows.Marvelous = (int)windows.Marvelous; windows.Perfect = (int)windows.Perfect; windows.Great = (int)windows.Great; windows.Good = (int)windows.Good; windows.Okay = (int)windows.Okay; windows.Miss = (int)windows.Miss; Logger.Important($"Created preset judgement windows `{windows.Name}` " + $"- Marv: {windows.Marvelous} | Perf: {windows.Perfect} | " + $"Great: {windows.Great} | Good: {windows.Good} | " + $"Okay: {windows.Okay} | Miss: {windows.Miss}", LogType.Runtime); return(windows); }
public JudgementWindowRenameDialog(JudgementWindows windows, JudgementWindowContainer windowContainer) : base(0.75f) { Windows = windows; WindowContainer = windowContainer; CreateContent(); }
/// <summary> /// </summary> /// <param name="windows"></param> public static void Delete(JudgementWindows windows) { try { new SQLiteConnection(DatabasePath).Delete(windows); } catch (Exception e) { Logger.Error(e, LogType.Runtime); } }
/// <summary> /// </summary> public static int Insert(JudgementWindows windows) { try { return(new SQLiteConnection(DatabasePath).Insert(windows)); } catch (Exception e) { Logger.Error(e, LogType.Runtime); return(-1); } }
/// <summary> /// Sets a few defaults the players to use /// </summary> private static void InitializeDefaultPresetWindows() { Standard = CreatePresetWindows("Standard*", 0); Presets.Add(CreatePresetWindows("Peaceful", -3)); Presets.Add(CreatePresetWindows("Lenient", -2)); Presets.Add(CreatePresetWindows("Chill", -1)); Presets.Add(Standard); Presets.Add(CreatePresetWindows("Strict", 1)); Presets.Add(CreatePresetWindows("Tough", 2)); Presets.Add(CreatePresetWindows("Extreme", 3)); Presets.Add(CreatePresetWindows("Impossible", 8)); }
/// <summary> /// </summary> /// <param name="replay"></param> /// <param name="map"></param> /// <param name="windows"></param> /// <param name="dontExtend"></param> public VirtualReplayPlayer(Replay replay, Qua map, JudgementWindows windows = null, bool dontExtend = false) { Replay = replay; Map = map; DontExtendReplay = dontExtend; ScoreProcessor = new ScoreProcessorKeys(map, Replay.Mods, windows); ActiveHitObjects = new List <HitObjectInfo>(); ActiveHeldLongNotes = new List <HitObjectInfo>(); map.HitObjects.ForEach(x => ActiveHitObjects.Add(x)); // Add virtual key bindings based on the game mode of the replay. switch (Map.Mode) { case GameMode.Keys4: InputKeyStore = new List <VirtualReplayKeyBinding>() { new VirtualReplayKeyBinding(ReplayKeyPressState.K1), new VirtualReplayKeyBinding(ReplayKeyPressState.K2), new VirtualReplayKeyBinding(ReplayKeyPressState.K3), new VirtualReplayKeyBinding(ReplayKeyPressState.K4), new VirtualReplayKeyBinding(ReplayKeyPressState.K5), }; break; case GameMode.Keys7: InputKeyStore = new List <VirtualReplayKeyBinding>() { new VirtualReplayKeyBinding(ReplayKeyPressState.K1), new VirtualReplayKeyBinding(ReplayKeyPressState.K2), new VirtualReplayKeyBinding(ReplayKeyPressState.K3), new VirtualReplayKeyBinding(ReplayKeyPressState.K4), new VirtualReplayKeyBinding(ReplayKeyPressState.K5), new VirtualReplayKeyBinding(ReplayKeyPressState.K6), new VirtualReplayKeyBinding(ReplayKeyPressState.K7), new VirtualReplayKeyBinding(ReplayKeyPressState.K8), new VirtualReplayKeyBinding(ReplayKeyPressState.K9), }; break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// </summary> private void CreateSubHeaders() { SubHeaderBackground = new Sprite { Parent = CustomizeContainer, Y = 2, Alignment = Alignment.TopCenter, Size = new ScalableVector2(CustomizeContainer.Width - 4, 47), Tint = ColorHelper.HexToColor("#212121") }; // ReSharper disable once ObjectCreationAsStatement new SpriteTextBitmap(FontsBitmap.GothamRegular, "Presets") { Parent = SubHeaderBackground, Alignment = Alignment.MidLeft, X = 18, FontSize = 18 }; var addButton = new BorderedTextButton("Add", Color.Lime, (sender, args) => { var windows = new JudgementWindows() { Name = "Preset" }; var presetCount = JudgementWindowsDatabaseCache.Presets.FindAll(x => !x.IsDefault).Count; JudgementWindowsDatabaseCache.Insert(windows); windows.Name = $"Preset {presetCount + 1}"; JudgementWindowsDatabaseCache.Update(windows); WindowContainer.AddObject(windows); JudgementWindowsDatabaseCache.Selected.Value = windows; }) { Parent = SubHeaderBackground, Alignment = Alignment.MidRight, X = -15, Text = { FontSize = 14, Font = Fonts.Exo2SemiBold } }; addButton.Size = new ScalableVector2(addButton.Width * 0.85f, addButton.Height * 0.85f); EditButton = new BorderedTextButton("Edit Name", Color.Yellow, (sender, args) => { DialogManager.Show(new JudgementWindowRenameDialog(JudgementWindowsDatabaseCache.Selected.Value, WindowContainer)); }) { Parent = SubHeaderBackground, Alignment = Alignment.MidRight, X = addButton.X - addButton.Width - 12, Text = { FontSize = 14, Font = Fonts.Exo2SemiBold } }; EditButton.Size = new ScalableVector2(EditButton.Width * 0.85f, EditButton.Height * 0.85f); DeleteButton = new BorderedTextButton("Delete", Color.Crimson, (sender, args) => { var index = JudgementWindowsDatabaseCache.Presets.IndexOf(JudgementWindowsDatabaseCache.Selected.Value); JudgementWindowsDatabaseCache.Delete(JudgementWindowsDatabaseCache.Selected.Value); WindowContainer.Remove(JudgementWindowsDatabaseCache.Selected.Value); JudgementWindowsDatabaseCache.Selected.Value = JudgementWindowsDatabaseCache.Presets[index - 1]; }) { Parent = SubHeaderBackground, Alignment = Alignment.MidRight, X = EditButton.X - EditButton.Width - 12, Text = { FontSize = 14, Font = Fonts.Exo2SemiBold } }; DeleteButton.Size = new ScalableVector2(DeleteButton.Width * 0.85f, DeleteButton.Height * 0.85f); ResetToDefaultButton = new BorderedTextButton("Reset", Color.Orange, (sender, args) => { Sliders[Judgement.Marv].BindedValue.Value = (int)JudgementWindowsDatabaseCache.Standard.Marvelous; Sliders[Judgement.Perf].BindedValue.Value = (int)JudgementWindowsDatabaseCache.Standard.Perfect; Sliders[Judgement.Great].BindedValue.Value = (int)JudgementWindowsDatabaseCache.Standard.Great; Sliders[Judgement.Good].BindedValue.Value = (int)JudgementWindowsDatabaseCache.Standard.Good; Sliders[Judgement.Okay].BindedValue.Value = (int)JudgementWindowsDatabaseCache.Standard.Okay; Sliders[Judgement.Miss].BindedValue.Value = (int)JudgementWindowsDatabaseCache.Standard.Miss; }) { Parent = SubHeaderBackground, Alignment = Alignment.MidRight, X = DeleteButton.X - DeleteButton.Width - 12, Text = { FontSize = 14, Font = Fonts.Exo2SemiBold } }; ResetToDefaultButton.Size = new ScalableVector2(ResetToDefaultButton.Width * 0.85f, ResetToDefaultButton.Height * 0.85f); }
/// <summary> /// Returns the score processor to use. Loads hit stats from a replay if needed. /// </summary> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public ScoreProcessor GetScoreProcessor() { // Handles the case when watching a replay in its entirety. This uses the preprocessed // ScoreProcessor/Replay from gameplay to get a 100% accurate score output. // Also avoids having to process the replay again (as done below). if (Gameplay != null && Gameplay.InReplayMode) { var im = Gameplay.Ruleset.InputManager as KeysInputManager; return(im?.ReplayInputManager.VirtualPlayer.ScoreProcessor); } // If we already have stats (for example, this is a result screen right after a player finished playing a map), use them. if (ScoreProcessor.Stats != null) { return(ScoreProcessor); } // Otherwise, get the stats from a replay. Replay replay = null; // FIXME: unify this logic with watching a replay from a ResultScreen. try { switch (ResultsType) { case ResultScreenType.Gameplay: case ResultScreenType.Replay: replay = Replay; break; case ResultScreenType.Score: // Don't do anything for online replays since they aren't downloaded yet. if (!Score.IsOnline) { replay = new Replay($"{ConfigManager.DataDirectory.Value}/r/{Score.Id}.qr"); } break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception e) { NotificationManager.Show(NotificationLevel.Error, "Unable to read replay file"); Logger.Error(e, LogType.Runtime); } // Load a replay if we got one. if (replay == null) { return(ScoreProcessor); } var qua = Map.LoadQua(); qua.ApplyMods(replay.Mods); if (replay.Mods.HasFlag(ModIdentifier.Randomize)) { qua.RandomizeLanes(replay.RandomizeModifierSeed); } JudgementWindows windows = null; // ReSharper disable once CompareOfFloatsByEqualityOperator if (Score != null && Score.JudgementWindowPreset != JudgementWindowsDatabaseCache.Standard.Name && Score.JudgementWindowMarv != 0) { windows = new JudgementWindows() { Marvelous = Score.JudgementWindowMarv, Perfect = Score.JudgementWindowPerf, Great = Score.JudgementWindowGreat, Good = Score.JudgementWindowGood, Okay = Score.JudgementWindowOkay, Miss = Score.JudgementWindowMiss }; } var player = new VirtualReplayPlayer(replay, qua, windows); player.PlayAllFrames(); return(player.ScoreProcessor); }