From 7b4f28f0a74b9a7ad5ce079f97867069166f4ded Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Sat, 18 Jan 2025 00:41:38 +0530 Subject: [PATCH] replay submitting, rewind pic, change endpoint --- src/Leaderboards.hx | 2 +- src/MarbleGame.hx | 2 +- src/collision/CollisionEntity.hx | 4 ---- src/gui/EndGameGui.hx | 36 +++++++++++++++++++++----------- src/gui/LeaderboardsGui.hx | 8 ++++++- 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/Leaderboards.hx b/src/Leaderboards.hx index 7acad469..0f3e646c 100644 --- a/src/Leaderboards.hx +++ b/src/Leaderboards.hx @@ -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 = "Ultra"; public static function submitScore(mission:String, score:Float, rewindUsed:Bool, needsReplayCb:(Bool, Int) -> Void) { diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 839ea819..377236f7 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -40,7 +40,7 @@ class MarbleGame { static var canvas:Canvas; static var instance:MarbleGame; - static var currentVersion = "1.1.3"; + static var currentVersion = "1.2.0"; var world:MarbleWorld; var previewWorld:PreviewWorld; diff --git a/src/collision/CollisionEntity.hx b/src/collision/CollisionEntity.hx index ce0e77fb..41349ea8 100644 --- a/src/collision/CollisionEntity.hx +++ b/src/collision/CollisionEntity.hx @@ -246,10 +246,6 @@ class CollisionEntity implements IOctreeObject implements IBVHObject { if (position.sub(closest).dot(surfacenormal) > 0) { 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 // var testDot = normal.dot(surfacenormal); // if (testDot > bestDot) { diff --git a/src/gui/EndGameGui.hx b/src/gui/EndGameGui.hx index 57db6ea5..fc7004ae 100644 --- a/src/gui/EndGameGui.hx +++ b/src/gui/EndGameGui.hx @@ -194,19 +194,18 @@ class EndGameGui extends GuiImage { continueFunc(nextButton); } bottomBar.addChild(nextButton); - + var replayData = MarbleGame.instance.world.replay.write(); + var submitScore = () -> { + var lbScoreValue = score; + if (scoreType == Score) + lbScoreValue = 1000 - score; + Leaderboards.submitScore(mission.path, lbScoreValue, MarbleGame.instance.world.rewindUsed, (needsReplay, ref) -> { + if (needsReplay) { + Leaderboards.submitReplay(ref, replayData); + } + }); + } if (bestScore.time == score) { - var submitScore = () -> { - var lbScoreValue = score; - if (scoreType == Score) - lbScoreValue = 1000 - score; - Leaderboards.submitScore(mission.path, lbScoreValue, MarbleGame.instance.world.rewindUsed, (needsReplay, ref) -> { - if (needsReplay) { - Leaderboards.submitReplay(ref, MarbleGame.instance.world.replay.write()); - } - }); - } - if (Settings.highscoreName == "" || Settings.highscoreName == "Player Name") { haxe.Timer.delay(() -> { MarbleGame.canvas.pushDialog(new EnterNamePopupDlg(() -> { @@ -216,6 +215,19 @@ class EndGameGui extends GuiImage { } else { 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(); + } + }); } } diff --git a/src/gui/LeaderboardsGui.hx b/src/gui/LeaderboardsGui.hx index 61810261..a1d0ba2f 100644 --- a/src/gui/LeaderboardsGui.hx +++ b/src/gui/LeaderboardsGui.hx @@ -96,6 +96,8 @@ class LeaderboardsGui extends GuiImage { ResourceLoader.getResource("data/ui/xbox/platform_android_white.png", ResourceLoader.getImage, this.imageResources).toTile(); case "unknown": 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 _: return null; }; @@ -168,7 +170,11 @@ class LeaderboardsGui extends GuiImage { var scoreTexts = []; var i = 1; for (score in scoreList) { - var scoreText = '${i}. ${score.name}${Util.formatTime(score.score)}'; + var scoreText = '${i}. + ${score.name} + ${score.rewind > 0 ? "" : ""} + ${Util.formatTime(score.score)} + '; scoreTexts.push(scoreText); i++; }