Skip to content

Add ability to toggle mods during replay - #19925

Closed
cdwcgt wants to merge 61 commits into
ppy:masterfrom
cdwcgt:mod-disable
Closed

Add ability to toggle mods during replay#19925
cdwcgt wants to merge 61 commits into
ppy:masterfrom
cdwcgt:mod-disable

Conversation

@cdwcgt

@cdwcgt cdwcgt commented Aug 23, 2022

Copy link
Copy Markdown
Contributor

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

@bdach bdach left a comment

Copy link
Copy Markdown
Collaborator

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 thread osu.Game/Rulesets/Mods/ICanBeToggledDuringReplay.cs Outdated
Comment thread osu.Game/Rulesets/UI/ModIcon.cs Outdated
Comment thread osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs Outdated
Comment on lines +11 to +17
/// <summary>
/// A property to set whether the mod has been disabled.
/// </summary>
bool IsDisable
{
get;
}

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread osu.Game/Rulesets/UI/DrawableRuleset.cs Outdated
mod.ReadFromConfig(config);

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

Copy link
Copy Markdown
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.

private const float leniency = 0.1f;

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

Copy link
Copy Markdown
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