replay submitting, rewind pic, change endpoint

This commit is contained in:
RandomityGuy 2025-01-18 00:41:38 +05:30
parent d8ae54df77
commit 7b4f28f0a7
5 changed files with 33 additions and 19 deletions

View file

@ -21,7 +21,7 @@ enum abstract LeaderboardsKind(Int) {
} }
class Leaderboards { class Leaderboards {
static var host = "http://127.0.0.1:7000"; static var host = "https://lb.randomityguy.me";
static var game = "Ultra"; static var game = "Ultra";
public static function submitScore(mission:String, score:Float, rewindUsed:Bool, needsReplayCb:(Bool, Int) -> Void) { public static function submitScore(mission:String, score:Float, rewindUsed:Bool, needsReplayCb:(Bool, Int) -> Void) {

View file

@ -40,7 +40,7 @@ class MarbleGame {
static var canvas:Canvas; static var canvas:Canvas;
static var instance:MarbleGame; static var instance:MarbleGame;
static var currentVersion = "1.1.3"; static var currentVersion = "1.2.0";
var world:MarbleWorld; var world:MarbleWorld;
var previewWorld:PreviewWorld; var previewWorld:PreviewWorld;

View file

@ -246,10 +246,6 @@ class CollisionEntity implements IOctreeObject implements IBVHObject {
if (position.sub(closest).dot(surfacenormal) > 0) { if (position.sub(closest).dot(surfacenormal) > 0) {
normal.normalize(); normal.normalize();
trace(v0);
trace(v);
trace(v2);
// We find the normal that is closest to the surface normal, sort of fixes weird edge cases of when colliding with // We find the normal that is closest to the surface normal, sort of fixes weird edge cases of when colliding with
// var testDot = normal.dot(surfacenormal); // var testDot = normal.dot(surfacenormal);
// if (testDot > bestDot) { // if (testDot > bestDot) {

View file

@ -194,19 +194,18 @@ class EndGameGui extends GuiImage {
continueFunc(nextButton); continueFunc(nextButton);
} }
bottomBar.addChild(nextButton); bottomBar.addChild(nextButton);
var replayData = MarbleGame.instance.world.replay.write();
if (bestScore.time == score) {
var submitScore = () -> { var submitScore = () -> {
var lbScoreValue = score; var lbScoreValue = score;
if (scoreType == Score) if (scoreType == Score)
lbScoreValue = 1000 - score; lbScoreValue = 1000 - score;
Leaderboards.submitScore(mission.path, lbScoreValue, MarbleGame.instance.world.rewindUsed, (needsReplay, ref) -> { Leaderboards.submitScore(mission.path, lbScoreValue, MarbleGame.instance.world.rewindUsed, (needsReplay, ref) -> {
if (needsReplay) { if (needsReplay) {
Leaderboards.submitReplay(ref, MarbleGame.instance.world.replay.write()); Leaderboards.submitReplay(ref, replayData);
} }
}); });
} }
if (bestScore.time == score) {
if (Settings.highscoreName == "" || Settings.highscoreName == "Player Name") { if (Settings.highscoreName == "" || Settings.highscoreName == "Player Name") {
haxe.Timer.delay(() -> { haxe.Timer.delay(() -> {
MarbleGame.canvas.pushDialog(new EnterNamePopupDlg(() -> { MarbleGame.canvas.pushDialog(new EnterNamePopupDlg(() -> {
@ -216,6 +215,19 @@ class EndGameGui extends GuiImage {
} else { } else {
submitScore(); submitScore();
} }
} else {
Leaderboards.getScores(mission.path, All, lbscores -> {
var foundScore = false;
for (lb in lbscores) {
if (lb.name == Settings.highscoreName) {
foundScore = true;
break;
}
}
if (!foundScore) {
submitScore();
}
});
} }
} }

View file

@ -96,6 +96,8 @@ class LeaderboardsGui extends GuiImage {
ResourceLoader.getResource("data/ui/xbox/platform_android_white.png", ResourceLoader.getImage, this.imageResources).toTile(); ResourceLoader.getResource("data/ui/xbox/platform_android_white.png", ResourceLoader.getImage, this.imageResources).toTile();
case "unknown": case "unknown":
ResourceLoader.getResource("data/ui/xbox/platform_unknown_white.png", ResourceLoader.getImage, this.imageResources).toTile(); ResourceLoader.getResource("data/ui/xbox/platform_unknown_white.png", ResourceLoader.getImage, this.imageResources).toTile();
case "rewind":
ResourceLoader.getResource("data/ui/xbox/rewind_ico.png", ResourceLoader.getImage, this.imageResources).toTile();
case _: case _:
return null; return null;
}; };
@ -168,7 +170,11 @@ class LeaderboardsGui extends GuiImage {
var scoreTexts = []; var scoreTexts = [];
var i = 1; var i = 1;
for (score in scoreList) { for (score in scoreList) {
var scoreText = '<offset value="10">${i}. </offset><offset value="50">${score.name}</offset><offset value="500">${Util.formatTime(score.score)}</offset><offset value="625"><img src="${platformToString(score.platform)}"/></offset>'; var scoreText = '<offset value="10">${i}. </offset>
<offset value="50">${score.name}</offset>
<offset value="475">${score.rewind > 0 ? "<img src='rewind'/>" : ""}</offset>
<offset value="500">${Util.formatTime(score.score)}</offset>
<offset value="625"><img src="${platformToString(score.platform)}"/></offset>';
scoreTexts.push(scoreText); scoreTexts.push(scoreText);
i++; i++;
} }