fix sorting replays messing up hitdata
This commit is contained in:
parent
2b83657907
commit
0a6412e03f
|
@ -59,6 +59,7 @@ import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.SlickException;
|
import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
import yugecin.opsudance.*;
|
import yugecin.opsudance.*;
|
||||||
|
import yugecin.opsudance.ReplayPlayback.HitData;
|
||||||
import yugecin.opsudance.core.state.ComplexOpsuState;
|
import yugecin.opsudance.core.state.ComplexOpsuState;
|
||||||
import yugecin.opsudance.objects.curves.FakeCombinedCurve;
|
import yugecin.opsudance.objects.curves.FakeCombinedCurve;
|
||||||
import yugecin.opsudance.options.OptionGroups;
|
import yugecin.opsudance.options.OptionGroups;
|
||||||
|
@ -1478,6 +1479,14 @@ public class Game extends ComplexOpsuState {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class ReplayData {
|
||||||
|
final HitData hitdata;
|
||||||
|
final Replay replay;
|
||||||
|
ReplayData(HitData hitdata, Replay replay) {
|
||||||
|
this.hitdata = hitdata;
|
||||||
|
this.replay = replay;
|
||||||
|
}
|
||||||
|
}
|
||||||
private ReplayPlayback[] replays;
|
private ReplayPlayback[] replays;
|
||||||
private ReplayCursors replayCursors;
|
private ReplayCursors replayCursors;
|
||||||
@Override
|
@Override
|
||||||
|
@ -1508,8 +1517,7 @@ public class Game extends ComplexOpsuState {
|
||||||
if (replayCursors != null) {
|
if (replayCursors != null) {
|
||||||
replayCursors.destroy();
|
replayCursors.destroy();
|
||||||
}
|
}
|
||||||
final ArrayList<Replay> actualReplays = new ArrayList<>(50);
|
final ArrayList<ReplayData> rdata = new ArrayList<>(50);
|
||||||
final ArrayList<ReplayPlayback.HitData> hitdatas = new ArrayList<>(50);
|
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
final String datafilename = file.getName().substring(0, file.getName().length() - 3) + "ope";
|
final String datafilename = file.getName().substring(0, file.getName().length() - 3) + "ope";
|
||||||
final File hitdatafile = new File(file.getParentFile(), datafilename);
|
final File hitdatafile = new File(file.getParentFile(), datafilename);
|
||||||
|
@ -1529,39 +1537,36 @@ public class Game extends ComplexOpsuState {
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Replay r = new Replay(file);
|
final Replay r = new Replay(file);
|
||||||
try {
|
try {
|
||||||
r.load();
|
r.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
bubNotifs.sendf(Colors.BUB_RED, "could not load replay %s", file.getName());
|
bubNotifs.sendf(Colors.BUB_RED, "could not load replay %s", file.getName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
actualReplays.add(r);
|
rdata.add(new ReplayData(hitdata, r));
|
||||||
hitdatas.add(hitdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actualReplays.sort(new Comparator<Replay>() {
|
rdata.sort(new Comparator<ReplayData>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Replay o1, Replay o2) {
|
public int compare(ReplayData o1, ReplayData o2) {
|
||||||
return Integer.compare(o2.score, o1.score);
|
return Integer.compare(o2.replay.score, o1.replay.score);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
replayCursors = new ReplayCursors(actualReplays.size());
|
replayCursors = new ReplayCursors(rdata.size());
|
||||||
replays = new ReplayPlayback[actualReplays.size()];
|
replays = new ReplayPlayback[rdata.size()];
|
||||||
|
|
||||||
float hueshift = 360f / actualReplays.size();
|
float hueshift = 360f / rdata.size();
|
||||||
float hue = 180;
|
float hue = 180;
|
||||||
|
|
||||||
final Iterator<ReplayPlayback.HitData> hitdataIter = hitdatas.iterator();
|
|
||||||
final Iterator<Replay> replayIter = actualReplays.iterator();
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
while (replayIter.hasNext()) {
|
for (ReplayData d : rdata) {
|
||||||
final Color c = new Color(java.awt.Color.HSBtoRGB((hue) / 360f, .7f, 1.0f));
|
final Color c = new Color(java.awt.Color.HSBtoRGB((hue) / 360f, .7f, 1.0f));
|
||||||
final ReplayCursor cursor = new ReplayCursor(c);
|
final ReplayCursor cursor = new ReplayCursor(c);
|
||||||
replays[idx] = new ReplayPlayback(
|
replays[idx] = new ReplayPlayback(
|
||||||
replayIter.next(),
|
d.replay,
|
||||||
hitdataIter.next(),
|
d.hitdata,
|
||||||
c,
|
c,
|
||||||
cursor
|
cursor
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user