mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-01-01 04:42:15 +00:00
few fixes for LB
This commit is contained in:
parent
851b52edc6
commit
73eeaf42d7
5 changed files with 44 additions and 9 deletions
|
|
@ -21,7 +21,7 @@ enum abstract LeaderboardsKind(Int) {
|
|||
}
|
||||
|
||||
class Leaderboards {
|
||||
static var host = "http://127.0.0.1:7000";
|
||||
static var host = "https://lb.randomityguy.me";
|
||||
static var game = "Platinum";
|
||||
|
||||
public static function submitScore(mission:String, score:Float, rewindUsed:Bool, needsReplayCb:(Bool, Int) -> Void) {
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ class MarbleGame {
|
|||
Analytics.trackLevelQuit(world.mission.title, world.mission.path, Std.int(world.timeState.timeSinceLoad * 1000), stats.oobs, stats.respawns,
|
||||
Settings.optionsSettings.rewindEnabled);
|
||||
paused = false;
|
||||
if (world.isWatching) {
|
||||
if (world.isWatching && !world.replay.isLBReplay) {
|
||||
#if !js
|
||||
canvas.setContent(new ReplayCenterGui());
|
||||
#else
|
||||
|
|
@ -349,10 +349,10 @@ class MarbleGame {
|
|||
} else {
|
||||
if (!world.mission.isClaMission && !world.mission.isCustom) {
|
||||
PlayMissionGui.currentCategoryStatic = world.mission.type;
|
||||
PlayMissionGui.currentSelectionStatic = world.mission.index;
|
||||
PlayMissionGui.currentGameStatic = world.mission.game;
|
||||
}
|
||||
var pmg = new PlayMissionGui();
|
||||
PlayMissionGui.currentSelectionStatic = world.mission.index;
|
||||
PlayMissionGui.currentGameStatic = world.mission.game;
|
||||
canvas.setContent(pmg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ class Replay {
|
|||
public var mission:String;
|
||||
public var name:String;
|
||||
public var customId:Int;
|
||||
public var isLBReplay:Bool;
|
||||
|
||||
var frames:Array<ReplayFrame>;
|
||||
var initialState:ReplayInitialState;
|
||||
|
|
@ -282,6 +283,7 @@ class Replay {
|
|||
this.mission = mission;
|
||||
this.customId = customId;
|
||||
this.initialState = new ReplayInitialState();
|
||||
this.isLBReplay = false;
|
||||
}
|
||||
|
||||
public function startFrame() {
|
||||
|
|
|
|||
|
|
@ -424,15 +424,41 @@ class EndGameGui extends GuiControl {
|
|||
}
|
||||
|
||||
Settings.saveScore(mission.path, myScore);
|
||||
Leaderboards.submitScore(mission.path, myScore.time, MarbleGame.instance.world.rewindUsed, (sendReplay, rowId) -> {
|
||||
var lbPath = mission.path;
|
||||
if (mission.isClaMission)
|
||||
lbPath = 'custom/${mission.id}';
|
||||
var replayData = MarbleGame.instance.world.replay.write();
|
||||
Leaderboards.submitScore(lbPath, myScore.time, MarbleGame.instance.world.rewindUsed, (sendReplay, rowId) -> {
|
||||
if (sendReplay) {
|
||||
Leaderboards.submitReplay(rowId, MarbleGame.instance.world.replay.write());
|
||||
Leaderboards.submitReplay(rowId, replayData);
|
||||
}
|
||||
});
|
||||
|
||||
scoreSubmitted = true;
|
||||
});
|
||||
this.addChild(end);
|
||||
} else {
|
||||
// Check if we can submit LB scores
|
||||
var replayData = MarbleGame.instance.world.replay.write();
|
||||
var lbPath = mission.path;
|
||||
if (mission.isClaMission)
|
||||
lbPath = 'custom/${mission.id}';
|
||||
Leaderboards.getScores(lbPath, All, (scores) -> {
|
||||
var hasMyScore = false;
|
||||
for (score in scores) {
|
||||
if (score.name == Settings.highscoreName) {
|
||||
hasMyScore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasMyScore) {
|
||||
Leaderboards.submitScore(lbPath, timeState.gameplayClock, MarbleGame.instance.world.rewindUsed, (sendReplay, rowId) -> {
|
||||
if (sendReplay) {
|
||||
Leaderboards.submitReplay(rowId, replayData);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -829,9 +829,13 @@ class PlayMissionGui extends GuiImage {
|
|||
scoreBox.text.onHyperlink = (url) -> {
|
||||
if (url == "watch") {
|
||||
var currentMission = currentList[currentSelection];
|
||||
Leaderboards.watchTopReplay(currentMission.path, scoreView, (b) -> {
|
||||
var lbPath = currentMission.path;
|
||||
if (currentMission.isClaMission)
|
||||
lbPath = 'custom/${currentMission.id}';
|
||||
Leaderboards.watchTopReplay(lbPath, scoreView, (b) -> {
|
||||
if (b != null) {
|
||||
var replayF = new Replay("");
|
||||
replayF.isLBReplay = true;
|
||||
if (replayF.read(b)) {
|
||||
var repmis = replayF.mission;
|
||||
// Strip data/ from the mission name
|
||||
|
|
@ -1221,14 +1225,17 @@ class PlayMissionGui extends GuiImage {
|
|||
Http.cancel(lbRequest);
|
||||
#end
|
||||
var lTok = lbToken++;
|
||||
var req = Leaderboards.getScores(currentMission.path, scoreView, (scoreList) -> {
|
||||
var lbPath = currentMission.path;
|
||||
if (currentMission.isClaMission)
|
||||
lbPath = 'custom/${currentMission.id}';
|
||||
var req = Leaderboards.getScores(lbPath, scoreView, (scoreList) -> {
|
||||
if (lTok + 1 != lbToken || !showLBs)
|
||||
return;
|
||||
var sFmt = [];
|
||||
var i = 1;
|
||||
for (score in scoreList) {
|
||||
sFmt.push('${i}.
|
||||
<offset value="15">${score.name}</offset>
|
||||
<offset value="15">${score.name.substr(0, 30)}</offset>
|
||||
<offset value="215">${Util.formatTime(score.score)}</offset>
|
||||
<offset value="279"><img src="${platformToString(score.platform)}"/></offset>
|
||||
${score.rewind == 1 ? '<offset value="299"><img src="rewind"/></offset> ' : ""}');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue