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

Make ctrl-up/down change speed modifier of mods #28071

Merged
merged 27 commits into from
May 24, 2024

Conversation

Fabiano1337
Copy link
Contributor

PageUp and PageDown now increase or decrease speed in song select.

Example
(Song Select screen and no mod is selected)

  1. Page Down is pressed
  2. HalfTime mod gets applied with 0.95x speed modifier
  3. Page Down is pressed again
  4. HalfTime mod speed modifier changes to 0.9x
    same goes with PageUp and DoubleTime.

If Daycore or Nightcore are currently selected it increases those.
If the minimum rate gets surpassed Half-/Double-Time get applied

Video of it in action:
https://github.com/ppy/osu/assets/28962347/e95228d2-0e77-4ec8-9e60-17472bdc4545

Im open to any suggestions for changes and i hope this feature finds its way into osu!lazer

@bdach
Copy link
Collaborator

bdach commented May 2, 2024

  • What is the reason for wanting this?
  • Why should DT/HT get preferential hotkey treatment for their settings over every other mod in the game?
  • Was this feature discussed anywhere at all before this PR?

@Fabiano1337
Copy link
Contributor Author

What is the reason for wanting this?
It is a quality of life feature that makes adjusting the speed of your map faster (useful for people who often push their limits and increase the speed every run of a map), with this implementation you can adjust speed the using only your keyboard.

Why should DT/HT get preferential hotkey treatment over every other mod in the game?
DT/HT are some of the most used mods in the game, HR/HD don't have any adjustability. HR and HD can be fully utilized with only a keyboard whereas DT/HT cannot. DC/NC are lesser used than DT/HT which is why i opted for DT/HT, this is up for debate tho.

Was this feature discussed anywhere at all before this PR?
No, i haven't seen this feature being discussed anywhere before, since isn't that big of a feature i thought it didn't need one. Do you want me to open a Discussion about this topic first ?

@longnguyen2004
Copy link

(Not lazer dev, just my opinion) The hotkey for this cannot be PgUp/PgDown, since those are used to scroll the carousel, and I also don't like the semantic of PgUp/PgDown being changed like that, since those keys are almost always used to scroll, and not to adjust a setting. Maybe Ctrl+Up and Ctrl+Down?

@bdach
Copy link
Collaborator

bdach commented May 3, 2024

No, i haven't seen this feature being discussed anywhere before, since isn't that big of a feature i thought it didn't need one. Do you want me to open a Discussion about this topic first ?

I generally prefer all unsolicited feature requests to go through discussions first in order to reduce wasted contributor effort and to gauge interest in the feature. At this time I have no idea as to whether anyone but yourself wants this feature to exist.


UX-wise I have a whole mess of doubts.

  • As stated above this should not use page up/down by default.
  • If you manually select daycore and then page-up enough to progress into track speed-up I'd probably expect nightcore to be activated. Right now double time activates.
  • If you manually change "adjust pitch" on DT/HT and then page-up/down enough to progress into HT/DT then mod setting is lost. It should probably be preserved.
  • It's not very clear what's happening if you press the binding but don't look at the footer. This gets especially weird if you e.g. speed up DT from 1.45x to 1.5x because the speed indicator on the right of the right of the mod icon in the footer disappears. I'd say there should be a toast or something showing what's changing.

Not to mention something like wind up/down that also have speed adjustments but don't get any special hotkeys.

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.

Missing unit tests

Comment on lines 1113 to 1119
case GlobalAction.IncreaseSpeed:
increaseSpeed();
return true;

case GlobalAction.DecreaseSpeed:
decreaseSpeed();
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

increaseSpeed() and decreaseSpeed() should probably be one method that accept a delta or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 3fdbd73

Comment on lines 814 to 816
var rateAdjustStates = ModSelect.AllAvailableMods.Where(pair => pair.Mod is ModRateAdjust);
var stateDoubleTime = ModSelect.AllAvailableMods.First(pair => pair.Mod is ModDoubleTime);
bool rateModActive = ModSelect.AllAvailableMods.Count(pair => pair.Mod is ModRateAdjust && pair.Active.Value) > 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should not be doing mod queries or mutations via ModSelect. Use selectedMods and OsuGameBase.AvailableMods instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 3fdbd73

}

// Find current active rateAdjust mod and modify speed, enable DoubleTime if necessary
foreach (var state in rateAdjustStates)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be asserting that there is only one rate adjust mod present rather than doing some weird loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 3fdbd73

@Fabiano1337
Copy link
Contributor Author

I created a Discussion about this feature.
#28085

@bdach
Copy link
Collaborator

bdach commented May 14, 2024

I guess the discussion seems to have gathered some support, but I'd still expect the review above to be addressed for this before this can be considered further.

@Fabiano1337
Copy link
Contributor Author

Fabiano1337 commented May 14, 2024

Sure,
since i still have school and stuff going on it could take me maybe a week or two.
Im currently trying to enable the mods without using ModSelect, i can't just add new mods to selectedMods since thats a readOnlyList right ?

@bdach
Copy link
Collaborator

bdach commented May 14, 2024

i can't just add new mods to selectedMods since thats a readOnlyList right ?

You can replace the entire list.

Fabian van Oeffelt added 4 commits May 18, 2024 18:37
@Fabiano1337
Copy link
Contributor Author

  • Do we add support for holding the button (for example every 500ms speed increases) or do we keep it like it is now that you have to press the key again ?
  • You mentioned a toast showing that something is changing, do you have any idea on what that could look like ?

@bdach
Copy link
Collaborator

bdach commented May 20, 2024

  • Do we add support for holding the button (for example every 500ms speed increases) or do we keep it like it is now that you have to press the key again ?

This would already be supported if not for this early return:

if (e.Repeat)
return false;

  • You mentioned a toast showing that something is changing, do you have any idea on what that could look like ?

Use the existing one. See usages elsewhere on how to display it.

@Fabiano1337
Copy link
Contributor Author

Fabiano1337 commented May 21, 2024

Seems like the toast implementation 148afd1 makes the test fail, locally they still run fine on my side

Edit : Tests fail because the SpeedChange value of RateAdjustMods are not exactly 0.95

@peppy peppy self-requested a review May 22, 2024 03:49
peppy added 2 commits May 22, 2024 11:59
Before I gave up on attempting to fix the method.
@@ -809,6 +823,125 @@ public override bool OnBackButton()
return false;
}

public void ChangeSpeed(double delta)
{
ModNightcore modNc = (ModNightcore)((MultiMod)game.AvailableMods.Value[ModType.DifficultyIncrease].First(mod => mod is MultiMod multiMod && multiMod.Mods.Count(modType => modType is ModNightcore) > 0)).Mods.First(mod => mod is ModNightcore);
Copy link
Member

Choose a reason for hiding this comment

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

This method needs a rewrite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you tell me what needs to change for the rewrite so i don't do the same mistake again? (more readable, more compact, ...)

{
public partial class SpeedChangeToast : Toast
{
public SpeedChangeToast(OsuConfigManager config, double delta)
Copy link
Member

Choose a reason for hiding this comment

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

This probably should actually show the speed?

@bdach bdach self-requested a review May 24, 2024 09:51
@bdach bdach changed the title Make PGUp / PGDown change speed modifier of mods Make ctrl-up/down change speed modifier of mods May 24, 2024
bdach added 6 commits May 24, 2024 13:03
The very base class is the wrong place for it because
`FreeModSelectOverlay` inherits from it, and that one has different
assumptions and rules than "user" selection. In particular, in non-user
selection, more than one rate adjust mod may be active, which breaks the
mod speed hotkey's basic assumptions.
@bdach
Copy link
Collaborator

bdach commented May 24, 2024

I've basically rewritten this.

  • Implementation simplified & shipped off to separate component to not pollute SongSelect with it and reduce coupling between ModSelectOverlay and SongSelect
  • Now does nothing on free mod select screen (I haven't tested but I'm pretty sure the previous implementation would do funky stuff)
  • Now works on user mod select in multi when choosing free mods
  • Now has consistent input handling (song select would handle repeats but not mod select overlay)
  • Fixed broken localisations (you can't concatenate localisable strings via +).

@peppy requesting check as to whether you're willing to accept this feature or not, and if yes, on how the code looks now.
@Fabiano1337 please check my commits for the type of code (wrt simplicity and attention to detail) we expect to see from contributors. If you have follow-up questions please ask.

@bdach bdach requested a review from peppy May 24, 2024 11:25
@peppy
Copy link
Member

peppy commented May 24, 2024

I'm pretty happy with how this feature works (very cool) and now the code is sane. Let's 🚢 it.

@peppy peppy merged commit 2134ff7 into ppy:master May 24, 2024
13 of 17 checks passed
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.

5 participants