Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to toggle mods during replay #19925

Draft
wants to merge 61 commits into
base: master
Choose a base branch
from
Draft

Conversation

cdwcgt
Copy link
Contributor

@cdwcgt cdwcgt commented Aug 23, 2022

close #8357

create a new interface named ICanBeToggledDuringReplay
Some annotations are missing, probably

add a test for mod can only toggle in replay

Maybe should handle ReplayLoaded in HudOverlay Handle at ClickableModIcon.cs

mod list that I think can be implemented

  • [ ] HR (Unable to implement, need to reload Player, also replay may broken)
  • Flashlight
  • Binds
  • RateAdjust (DT HT NC DC)
  • TimeRamp (Wind up/down)
  • ModAdaptiveSpeed
  • Hidden (ModWithVisibilityAdjustment)
  • NoScope
  • Muted
  • Floating Fruits
  • BarrelRoll
  • OsuModApproachDifferent
  • OsuModFreezeFrame
  • [ ] ManiaModConstantSpeed (Unable to implement, need to reload DrawableScrollingRuleset)
  • OsuModBubbles
  • ModSynesthesia
  • OsuModDepth (maybe not suitable to disable, replay may broken)

@bdach bdach changed the title Add ability to allow mods to disable during replay Add ability to toggle mods to during replay Aug 23, 2022
Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what anything is here.

Comment on lines 11 to 17
/// <summary>
/// A property to set whether the mod has been disabled.
/// </summary>
bool IsDisable
{
get;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without digging too deep into this, this doesn't make sense. A get property to set?

/// <summary>
/// A property to set whether the mod has been disabled.
/// </summary>
bool IsDisable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled or IsDisabled

/// <summary>
/// Method called when mod toggle.
/// </summary>
void OnToggle();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may just want one single BindableBool in this interface, which can handle both value and event flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but I'm a little confused where the event is registered
There are some mods that don't have a constructor

Define an event registration method in an interface?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What "event"? You mean the BindValueChanged callback of the proposed bindable in question?

Mods that don't currently have a constructor can receive one. I'm not sure what the problem is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have decided to use a method to register events and this method will be called once on load

// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no nullable disable on new classes

cdwcgt added 3 commits August 25, 2022 00:10
bring in `DisableToggleEvent` to register event handle for `BindableBool IsDisabled`
/// <summary>
/// Display the specified mod at a fixed size.
/// </summary>
public class ClickableModIcon : ClickableContainer, IHasTooltip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this just ModIcon but copy-pasted in its entirety? This is not okay. There are better methods of code re-use.

/// <summary>
/// Displays a single-line horizontal auto-sized flow of mods. For cases where wrapping is required, use <see cref="ModFlowDisplay"/> instead.
/// </summary>
public class ClickableModDisplay : CompositeDrawable, IHasCurrentValue<IReadOnlyList<Mod>>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above for this. This cannot/should not exist in its current form.

@@ -371,6 +371,9 @@ private void applyRulesetMods(IReadOnlyList<Mod> mods, OsuConfigManager config)

foreach (var mod in mods.OfType<IReadFromConfig>())
mod.ReadFromConfig(config);

foreach (var mod in mods.OfType<ICanBeToggledDuringReplay>())
mod.DisableToggleEvent();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this named DisableToggleEvent()...? It reads completely wrong, like you are disabling the mod's effects or something.

Arguably method shouldn't even exist, as I said already. You can add ctors where you need them.

@@ -87,13 +94,15 @@ public class DrawableOsuBlinds : Container
/// </summary>
private const float leniency = 0.1f;

public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap<OsuHitObject> beatmap)
public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap<OsuHitObject> beatmap, BindableBool disabledBind)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing bindables like this is generally unsafe and shouldn't be done. Create a local bindable in DrawableOsuBlinds and bind to the mod's instance instead.

@frenzibyte frenzibyte changed the title Add ability to toggle mods to during replay Add ability to toggle mods during replay Jun 4, 2023
@peppy peppy marked this pull request as draft June 16, 2023 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to disable/toggle mods during replays
5 participants