forked from YARC-Official/YARG
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement basic .chart drums loading (YARC-Official#252)
* Pass in YARG difficulty to ChartLoaders instead of a pre-retrieved MoonChart * Implement basic drums ChartLoaders
- Loading branch information
1 parent
be3ee37
commit 18967b0
Showing
9 changed files
with
171 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using MoonscraperChartEditor.Song; | ||
using YARG.Data; | ||
|
||
namespace YARG.Chart { | ||
public class FiveLaneDrumsChartLoader : IChartLoader<NoteInfo> { | ||
public List<NoteInfo> GetNotesFromChart(MoonSong song, Difficulty difficulty) { | ||
var notes = new List<NoteInfo>(); | ||
bool doubleBass = false; | ||
if (difficulty == Difficulty.EXPERT_PLUS) { | ||
difficulty = Difficulty.EXPERT; | ||
doubleBass = true; | ||
} | ||
var chart = song.GetChart(MoonSong.MoonInstrument.Drums, MoonSong.Difficulty.Easy - (int) difficulty); | ||
|
||
foreach (var moonNote in chart.notes) { | ||
// Ignore double-kicks if not Expert+ | ||
if (!doubleBass && (moonNote.flags & MoonNote.Flags.DoubleKick) != 0) | ||
continue; | ||
|
||
// Convert note value | ||
int pad = MoonDrumNoteToPad(moonNote); | ||
if (pad == -1) | ||
continue; | ||
|
||
// Length of the note in realtime | ||
double timeLength = song.TickToTime(moonNote.tick + moonNote.length, song.resolution) - moonNote.time; | ||
|
||
var note = new NoteInfo { | ||
time = (float) moonNote.time, | ||
length = (float) timeLength, | ||
fret = pad, | ||
hopo = moonNote.type == MoonNote.MoonNoteType.Cymbal | ||
}; | ||
|
||
notes.Add(note); | ||
} | ||
|
||
// TODO: Need to handle playing 4-lane charts on 5-lane | ||
return notes; | ||
} | ||
|
||
private int MoonDrumNoteToPad(MoonNote note) { | ||
return note.drumPad switch { | ||
MoonNote.DrumPad.Kick => 5, | ||
MoonNote.DrumPad.Red => 0, | ||
MoonNote.DrumPad.Yellow => 1, | ||
MoonNote.DrumPad.Blue => 2, | ||
MoonNote.DrumPad.Orange => 3, | ||
MoonNote.DrumPad.Green => 4, | ||
_ => -1 | ||
}; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Script/Chart/Loaders/FiveLaneDrumsChartLoader.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections.Generic; | ||
using MoonscraperChartEditor.Song; | ||
using YARG.Data; | ||
|
||
namespace YARG.Chart { | ||
public class FourLaneDrumsChartLoader : IChartLoader<NoteInfo> { | ||
private bool _proDrums; | ||
|
||
public FourLaneDrumsChartLoader(bool pro) { | ||
_proDrums = pro; | ||
} | ||
|
||
public List<NoteInfo> GetNotesFromChart(MoonSong song, Difficulty difficulty) { | ||
var notes = new List<NoteInfo>(); | ||
bool doubleBass = false; | ||
if (difficulty == Difficulty.EXPERT_PLUS) { | ||
difficulty = Difficulty.EXPERT; | ||
doubleBass = true; | ||
} | ||
var chart = song.GetChart(MoonSong.MoonInstrument.Drums, MoonSong.Difficulty.Easy - (int) difficulty); | ||
|
||
foreach (var moonNote in chart.notes) { | ||
// Ignore double-kicks if not Expert+ | ||
if (!doubleBass && (moonNote.flags & MoonNote.Flags.DoubleKick) != 0) | ||
continue; | ||
|
||
// Convert note value | ||
int pad = MoonDrumNoteToPad(moonNote); | ||
if (pad == -1) | ||
continue; | ||
|
||
// Length of the note in realtime | ||
double timeLength = song.TickToTime(moonNote.tick + moonNote.length, song.resolution) - moonNote.time; | ||
|
||
var note = new NoteInfo { | ||
time = (float) moonNote.time, | ||
length = (float) timeLength, | ||
fret = pad, | ||
hopo = _proDrums && moonNote.type == MoonNote.MoonNoteType.Cymbal | ||
}; | ||
|
||
notes.Add(note); | ||
} | ||
|
||
// TODO: Need to handle playing 5-lane charts on 4-lane | ||
return notes; | ||
} | ||
|
||
private int MoonDrumNoteToPad(MoonNote note) { | ||
return note.drumPad switch { | ||
MoonNote.DrumPad.Kick => 4, | ||
MoonNote.DrumPad.Red => 0, | ||
MoonNote.DrumPad.Yellow => 1, | ||
MoonNote.DrumPad.Blue => 2, | ||
MoonNote.DrumPad.Orange => 3, // Moonscraper internally uses Orange for 4-lane green | ||
MoonNote.DrumPad.Green => 3, // Turn 5-lane green into 4-lane green | ||
_ => -1 | ||
}; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Script/Chart/Loaders/FourLaneDrumsChartLoader.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,10 +1,11 @@ | ||
using System.Collections.Generic; | ||
using MoonscraperChartEditor.Song; | ||
using YARG.Data; | ||
|
||
namespace YARG.Chart { | ||
public interface IChartLoader<T> { | ||
|
||
public List<T> GetNotesFromChart(MoonSong song, MoonChart chart); | ||
public List<T> GetNotesFromChart(MoonSong song, Difficulty chart); | ||
|
||
} | ||
} |
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