-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Remove "Special" ManiaAction
s for center columns
#29342
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85805bf
Remove `Special#` values from `ManiaAction` and remove enum offset
cl8n 606b055
Fix key binding generators
cl8n e7f9bba
Fix replay frames and auto generator
cl8n 5ad255e
Remove special actions from `Stage` constructor
cl8n 93e193d
Add realm migration to remap key bindings
cl8n 48d9bc9
Fix tests
cl8n 8e63c17
Apply CodeFactor lint
cl8n 12a1889
Use key offsets instead of cast
smoogipoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Replays.Legacy; | ||
using osu.Game.Rulesets.Mania.Beatmaps; | ||
using osu.Game.Rulesets.Replays; | ||
using osu.Game.Rulesets.Replays.Types; | ||
|
||
|
@@ -27,118 +25,27 @@ public ManiaReplayFrame(double time, params ManiaAction[] actions) | |
|
||
public void FromLegacy(LegacyReplayFrame legacyFrame, IBeatmap beatmap, ReplayFrame? lastFrame = null) | ||
{ | ||
var maniaBeatmap = (ManiaBeatmap)beatmap; | ||
|
||
var normalAction = ManiaAction.Key1; | ||
var specialAction = ManiaAction.Special1; | ||
|
||
var action = ManiaAction.Key1; | ||
int activeColumns = (int)(legacyFrame.MouseX ?? 0); | ||
int counter = 0; | ||
|
||
while (activeColumns > 0) | ||
{ | ||
bool isSpecial = isColumnAtIndexSpecial(maniaBeatmap, counter); | ||
|
||
if ((activeColumns & 1) > 0) | ||
Actions.Add(isSpecial ? specialAction : normalAction); | ||
|
||
if (isSpecial) | ||
specialAction++; | ||
else | ||
normalAction++; | ||
Actions.Add(action); | ||
|
||
counter++; | ||
action++; | ||
activeColumns >>= 1; | ||
} | ||
} | ||
|
||
public LegacyReplayFrame ToLegacy(IBeatmap beatmap) | ||
{ | ||
var maniaBeatmap = (ManiaBeatmap)beatmap; | ||
|
||
int keys = 0; | ||
|
||
foreach (var action in Actions) | ||
{ | ||
switch (action) | ||
{ | ||
case ManiaAction.Special1: | ||
keys |= 1 << getSpecialColumnIndex(maniaBeatmap, 0); | ||
break; | ||
|
||
case ManiaAction.Special2: | ||
keys |= 1 << getSpecialColumnIndex(maniaBeatmap, 1); | ||
break; | ||
|
||
default: | ||
// the index in lazer, which doesn't include special keys. | ||
int nonSpecialKeyIndex = action - ManiaAction.Key1; | ||
|
||
// the index inclusive of special keys. | ||
int overallIndex = 0; | ||
|
||
// iterate to find the index including special keys. | ||
for (; overallIndex < maniaBeatmap.TotalColumns; overallIndex++) | ||
{ | ||
// skip over special columns. | ||
if (isColumnAtIndexSpecial(maniaBeatmap, overallIndex)) | ||
continue; | ||
// found a non-special column to use. | ||
if (nonSpecialKeyIndex == 0) | ||
break; | ||
// found a non-special column but not ours. | ||
nonSpecialKeyIndex--; | ||
} | ||
|
||
keys |= 1 << overallIndex; | ||
break; | ||
} | ||
} | ||
keys |= 1 << (int)action; | ||
|
||
return new LegacyReplayFrame(Time, keys, null, ReplayButtonState.None); | ||
} | ||
|
||
/// <summary> | ||
/// Find the overall index (across all stages) for a specified special key. | ||
/// </summary> | ||
/// <param name="maniaBeatmap">The beatmap.</param> | ||
/// <param name="specialOffset">The special key offset (0 is S1).</param> | ||
/// <returns>The overall index for the special column.</returns> | ||
private int getSpecialColumnIndex(ManiaBeatmap maniaBeatmap, int specialOffset) | ||
{ | ||
for (int i = 0; i < maniaBeatmap.TotalColumns; i++) | ||
{ | ||
if (isColumnAtIndexSpecial(maniaBeatmap, i)) | ||
{ | ||
if (specialOffset == 0) | ||
return i; | ||
|
||
specialOffset--; | ||
} | ||
} | ||
|
||
throw new ArgumentException("Special key index is too high.", nameof(specialOffset)); | ||
} | ||
|
||
/// <summary> | ||
/// Check whether the column at an overall index (across all stages) is a special column. | ||
/// </summary> | ||
/// <param name="beatmap">The beatmap.</param> | ||
/// <param name="index">The overall index to check.</param> | ||
private bool isColumnAtIndexSpecial(ManiaBeatmap beatmap, int index) | ||
{ | ||
foreach (var stage in beatmap.Stages) | ||
{ | ||
if (index >= stage.Columns) | ||
{ | ||
index -= stage.Columns; | ||
continue; | ||
} | ||
|
||
return stage.IsSpecialColumn(index); | ||
} | ||
|
||
throw new ArgumentException("Column index is too high.", nameof(index)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wanted to make the enum match the key number, we could do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied this via 952a73b (smoogi agrees to it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or not, something relies on zero index somewhere who knows. Was hoping this would be agreed upon before committing to this.