global player leaderboards and update the rating curves locally

This commit is contained in:
RandomityGuy 2025-06-21 19:43:07 +05:30
parent 7d0c0ac096
commit 6e461a6125
59 changed files with 265 additions and 97 deletions

View file

@ -9,7 +9,7 @@ new SimGroup(MissionGroup) {
type = "advanced";
include = "1";
level = "49";
difficulty = "9";
difficulty = "10";
name = $Text::LevelName79;
};
new Sky(Sky) {

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
artist = "Alex Swanson";
include = "1";
difficulty = "9";
difficulty = "6";
type = "advanced";
time = "120000";
level = "47";

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "8";
difficulty = "10";
type = "advanced";
time = "180000";
level = "44";

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
level = "41";
artist = "Alex Swanson";
include = "1";
difficulty = "8";
difficulty = "7";
desc = "divergence";
name = $Text::LevelName104;
gameType = "SinglePlayer";

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
level = "50";
type = "advanced";
name = $Text::LevelName106;
difficulty = "9";
difficulty = "7";
time = "70000";
artist = "Alex Swanson";
};

View file

@ -9,7 +9,7 @@ new SimGroup(MissionGroup) {
level = "56";
include = "1";
artist = "Alex Swanson";
difficulty = "10";
difficulty = "9";
name = $Text::LevelName75;
};
new Sky(Sky) {

View file

@ -2,7 +2,7 @@
new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
difficulty = "9";
difficulty = "7";
type = "advanced";
level = "53";
gameType = "SinglePlayer";

View file

@ -9,7 +9,7 @@ new SimGroup(MissionGroup) {
type = "advanced";
artist = "Alex Swanson";
gameType = "SinglePlayer";
difficulty = "10";
difficulty = "11";
level = "58";
hasEggIndex = "16";
};

View file

@ -8,7 +8,7 @@ new SimGroup(MissionGroup) {
name = $Text::LevelName58;
include = "1";
time = "75000";
difficulty = "10";
difficulty = "9";
type = "advanced";
artist = "Alex Swanson";
hasEggIndex = "20";

View file

@ -18,7 +18,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
artist = "Alex Swanson";
include = "1";
difficulty = "8";
difficulty = "9";
type = "advanced";
time = "70000";
level = "43";

View file

@ -2,7 +2,7 @@
new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
difficulty = "8";
difficulty = "9";
artist = "Alex Swanson";
type = "advanced";
gameType = "SinglePlayer";

View file

@ -6,7 +6,7 @@ new SimGroup(MissionGroup) {
time = "60000";
level = "48";
include = "1";
difficulty = "9";
difficulty = "8";
gameType = "SinglePlayer";
name = $Text::LevelName83;
artist = "Alex Swanson";

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
level = "42";
artist = "Alex Swanson";
include = "1";
difficulty = "8";
difficulty = "7";
name = $Text::LevelName59;
gameType = "SinglePlayer";
};

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
level = "45";
artist = "Alex Swanson";
include = "1";
difficulty = "8";
difficulty = "7";
name = $Text::LevelName72;
gameType = "SinglePlayer";
};

View file

@ -8,7 +8,7 @@ new SimGroup(MissionGroup) {
include = "1";
type = "advanced";
time = "180000";
difficulty = "9";
difficulty = "10";
level = "52";
name = $Text::LevelName57;
hasEggIndex = "19";

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
level = "55";
artist = "Alex Swanson";
include = "1";
difficulty = "10";
difficulty = "8";
name = $Text::LevelName97;
gameType = "SinglePlayer";
};

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
time = "105000";
level = "54";
include = "1";
difficulty = "10";
difficulty = "11";
name = $Text::LevelName70;
artist = "Alex Swanson";
hasEggIndex = "18";

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
type = "beginner";
include = "1";
difficulty = "3";
difficulty = "6";
time = "30000";
level = "14";
name = $Text::LevelName34;

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "1";
difficulty = "5";
time = "45000";
type = "beginner";
level = "4";

View file

@ -9,7 +9,7 @@ new SimGroup(MissionGroup) {
level = "12";
include = "1";
artist = "Alex Swanson";
difficulty = "2";
difficulty = "5";
desc = "Change gravity to solve this puzzle.";
};
new MissionArea(MissionArea) {

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "2";
difficulty = "5";
time = "45000";
level = "9";
type = "beginner";

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
artist = "Alex Swanson";
difficulty = "4";
difficulty = "5";
time = "60000";
type = "beginner";
level = "18";

View file

@ -8,7 +8,7 @@ new SimGroup(MissionGroup) {
level = "8";
time = "100000";
include = "1";
difficulty = "3";
difficulty = "6";
name = $Text::LevelName9;
artist = "Alex Swanson";
};

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "3";
difficulty = "6";
time = "20000";
level = "19";
type = "Beginner";

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
type = "Beginner";
name = $Text::LevelName7;
time = "45000";
difficulty = "2";
difficulty = "5";
include = "1";
gameType = "SinglePlayer";
artist = "Alex Swanson";

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "2";
difficulty = "4";
time = "45000";
type = "beginner";
level = "6";

View file

@ -11,7 +11,7 @@ new SimGroup(MissionGroup) {
level = "1";
artist = "Alex Swanson";
name = $Text::LevelName1;
difficulty = "1";
difficulty = "4";
hasEggIndex = "1";
goldTime = "7000";
proTime = "16000";

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "1";
difficulty = "4";
time = "45000";
isInDemoMode = "1";
type = "beginner";

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "1";
difficulty = "4";
time = "70000";
isInDemoMode = "1";
level = "3";

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
artist = "Alex Swanson";
difficulty = "1";
difficulty = "3";
time = "45000";
type = "beginner";
level = "2";

View file

@ -2,7 +2,7 @@
new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
difficulty = "2";
difficulty = "5";
type = "beginner";
level = "10";
isInDemoMode = "1";

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
desc = "Be careful crossing these bridges.";
level = "11";
time = "60000";
difficulty = "2";
difficulty = "5";
name = $Text::LevelName21;
gameType = "SinglePlayer";
include = true;

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
level = "13";
name = $Text::LevelName22;
time = "60000";
difficulty = "3";
difficulty = "5";
gameType = "SinglePlayer";
artist = "Alex Swanson";
desc = "Practice with moving platforms.";

View file

@ -10,7 +10,7 @@ new SimGroup(MissionGroup) {
artist = "Alex Swanson";
include = "1";
name = $Text::LevelName28;
difficulty = "3";
difficulty = "6";
hasEggIndex = "4";
};
new MissionArea(MissionArea) {

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
include = "1";
difficulty = "3";
difficulty = "6";
artist = "Kevin Ryan & Tim Aste";
type = "beginner";
time = "90000";

View file

@ -9,7 +9,7 @@ new SimGroup(MissionGroup) {
artist = "Alex Swanson";
type = "beginner";
level = "20";
difficulty = "4";
difficulty = "6";
name = $Text::LevelName48;
hasEggIndex = "5";
};

View file

@ -6,7 +6,7 @@ new SimGroup(MissionGroup) {
level = "15";
name = $Text::LevelName23;
time = "80000";
difficulty = "3";
difficulty = "5";
gameType = "SinglePlayer";
artist = "Alex Swanson";
desc = "Follow the path and fly to the goal.";

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
gameType = "SinglePlayer";
include = "1";
difficulty = "5";
difficulty = "7";
type = "Intermediate";
artist = "Kevin Ryan and Tim Aste";
time = "30000";

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
gameType = "SinglePlayer";
desc = "Gather all the gems around the globe in less than 30 seconds.";
include = "1";
difficulty = "4";
difficulty = "7";
type = "Intermediate";
artist = "Kevin Ryan";
time = "30000";

View file

@ -5,7 +5,7 @@ new SimGroup(MissionGroup) {
type = "Intermediate";
include = "1";
level = "35";
difficulty = "6";
difficulty = "8";
name = $Text::LevelName103;
desc = "Black Diamond";
gameType = "SinglePlayer";

View file

@ -5,7 +5,7 @@ new SimGroup(MissionGroup) {
level = "27";
name = $Text::LevelName86;
time = "30000";
difficulty = "4";
difficulty = "6";
gameType = "SinglePlayer";
artist = "Alex Swanson";
type = "intermediate";

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
time = "120000";
include = "1";
difficulty = "5";
difficulty = "7";
type = "Intermediate";
level = "23";
artist = "Alex Swanson";

View file

@ -7,7 +7,7 @@ new SimGroup(MissionGroup) {
include = "1";
time = "60000";
artist = "Alex Swanson";
difficulty = "7";
difficulty = "6";
type = "Intermediate";
level = "39";
name = $Text::LevelName36;

View file

@ -3,7 +3,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
time = "50000";
include = "1";
difficulty = "4";
difficulty = "7";
type = "Intermediate";
level = "21";
isInDemoMode = "1";

View file

@ -9,7 +9,7 @@ new SimGroup(MissionGroup) {
gameType = "SinglePlayer";
time = "50000";
include = "1";
difficulty = "5";
difficulty = "6";
artist = "Alex Swanson";
};
new MissionArea(MissionArea) {

View file

@ -48,7 +48,7 @@ new SimGroup(MissionGroup) {
artist = "Alex Swanson";
include = "1";
name = $Text::LevelName101;
difficulty = "5";
difficulty = "7";
isInDemoMode = "1";
};
new MissionArea(MissionArea) {

View file

@ -2,7 +2,7 @@
new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
difficulty = "7";
difficulty = "6";
type = "Intermediate";
level = "36";
desc = "Careful, its slippery!";

View file

@ -6,7 +6,7 @@ new SimGroup(MissionGroup) {
level = "33";
name = $Text::LevelName37;
time = "120000";
difficulty = "6";
difficulty = "7";
gameType = "SinglePlayer";
artist = "Kevin Ryan";
desc = "Find the gems in the maze of roads!";

View file

@ -6,7 +6,7 @@ new SimGroup(MissionGroup) {
level = "22";
name = $Text::LevelName107;
time = "120000";
difficulty = "4";
difficulty = "8";
gameType = "SinglePlayer";
desc = "Its a jungle out there!";
type = "Intermediate";

View file

@ -6,7 +6,7 @@ new SimGroup(MissionGroup) {
include = "1";
artist = "Alex Swanson";
level = "38";
difficulty = "7";
difficulty = "6";
startHelpTest = "Climb to the top!";
desc = "Climb to the top!";
name = $Text::LevelName80;

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
type = "intermediate";
include = "1";
difficulty = "6";
difficulty = "8";
level = "37";
time = "120000";
name = $Text::LevelName73;

View file

@ -12,7 +12,7 @@ new SimGroup(MissionGroup) {
type = "advanced";
gameMode = "Scrum";
name = $Text::LevelNameMP21;
difficulty = "8";
difficulty = "9";
numgems = "1";
goldTime = "0";
guid = "{3DCFC6EE-A2DE-465F-B040-6FC31D5C0B6E}";

View file

@ -11,7 +11,7 @@ new SimGroup(MissionGroup) {
type = "beginner";
gameMode = "Scrum";
name = $Text::LevelNameMP18;
difficulty = "4";
difficulty = "6";
gemGroupRadius = "25";
goldTime = "0";
numgems = "1";

View file

@ -4,7 +4,7 @@ new SimGroup(MissionGroup) {
new ScriptObject(MissionInfo) {
gameMode = "Scrum";
level = "84";
difficulty = "9";
difficulty = "7";
maxGemsPerGroup = "6";
time = "300000";
type = "intermediate";

View file

@ -12,6 +12,13 @@ typedef LBScore = {
score:Float,
platform:Int,
rewind:Int,
rating:Int,
}
typedef LBPlayer = {
uid:String,
name:String,
rating:Int,
}
enum abstract LeaderboardsKind(Int) {
@ -59,6 +66,17 @@ class Leaderboards {
});
}
public static function getTopPlayers(kind:LeaderboardsKind, cb:Array<LBPlayer>->Void) {
return Http.get('${host}/api/players?&game=${game}&view=${kind}', (b) -> {
var s = b.toString();
var players:Array<LBPlayer> = Json.parse(s).players;
cb(players);
}, (e) -> {
Console.log("Failed to get players: " + e);
cb([]);
});
}
public static function submitReplay(ref:Int, replay:haxe.io.Bytes) {
return Http.uploadFile('${host}/api/record?ref=${ref}', replay, (b) -> {
Console.log("Replay submitted");

View file

@ -118,9 +118,9 @@ class EndGameGui extends GuiImage {
var completionBonus = 1000;
var timeBonus = 0;
if (t < parTime)
timeBonus = Math.floor(parTime / t) * 1000;
timeBonus = Math.floor((parTime / t) * 1000);
else
timeBonus = Math.floor(parTime / t) * 500;
timeBonus = Math.floor((parTime / t) * 500);
return (completionBonus + timeBonus) * difficulty;
}

View file

@ -17,7 +17,7 @@ import gui.HtmlText;
class LeaderboardsGui extends GuiImage {
var innerCtrl:GuiControl;
public function new(index:Int, levelSelectDifficulty:String, levelSelectGui:Bool = false,) {
public function new(index:Int, levelSelectDifficulty:String, levelSelectGui:Bool = false) {
var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile();
super(res);
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
@ -116,7 +116,8 @@ class LeaderboardsGui extends GuiImage {
return null;
}
var headerText = '<font face="arial12">Rank<offset value="50">Name</offset><offset value="500">Score</offset><offset value="600">Platform</offset></font>';
var headerText = '<font face="arial12">Rank<offset value="50">Name</offset><offset value="400">Score</offset><offset value="500">Rating</offset><offset value="600">Platform</offset></font>';
var playerHeaderText = '<font face="arial12">Rank<offset value="50">Name</offset><offset value="575">Rating</offset></font>';
var scores = [
'<offset value="10">1. </offset><offset value="50">Nardo Polo</offset><offset value="500">99:59:999</offset><offset value="625"><img src="unknown"/></offset>',
@ -145,7 +146,7 @@ class LeaderboardsGui extends GuiImage {
.concat(MissionList.missionList.get('ultra').get('advanced'))
.concat(MissionList.missionList.get('ultra').get('multiplayer'));
var actualIndex = allMissions.indexOf(MissionList.missionList.get('ultra').get(levelSelectDifficulty)[index]);
var actualIndex = levelSelectDifficulty != "players" ? allMissions.indexOf(MissionList.missionList.get('ultra').get(levelSelectDifficulty)[index]) : 0;
levelTitle.text.text = 'Level ${actualIndex + 1}';
@ -154,6 +155,10 @@ class LeaderboardsGui extends GuiImage {
var scoreCategories = ["Overall", "Rewind", "Non-Rewind"];
var scoreView:LeaderboardsKind = cast Settings.optionsSettings.currentView;
if (levelSelectDifficulty == "players") {
levelTitle.text.text = 'Top Players: ${scoreCategories[cast scoreView]}';
}
var currentMission = allMissions[actualIndex];
var scoreTok = 0;
@ -171,8 +176,9 @@ class LeaderboardsGui extends GuiImage {
for (score in scoreList) {
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">${isHuntScore ? Std.string(1000 - score.score) : Util.formatTime(score.score)}</offset>
<offset value="375">${score.rewind > 0 ? "<img src='rewind'/>" : ""}</offset>
<offset value="400">${isHuntScore ? Std.string(1000 - score.score) : Util.formatTime(score.score)}</offset>
<offset value="500">${score.rating}</offset>
<offset value="625"><img src="${platformToString(score.platform)}"/></offset>';
scoreTexts.push(scoreText);
i++;
@ -187,6 +193,31 @@ class LeaderboardsGui extends GuiImage {
scoreCtrl.text.text = headerText + "<br/><br/><br/><br/><br/>" + '<p align="center">Loading...</p>';
}
function fetchPlayers() {
var ourToken = scoreTok++;
Leaderboards.getTopPlayers(scoreView, (scoreList) -> {
if (ourToken + 1 != scoreTok)
return;
var scoreTexts = [];
var i = 1;
for (score in scoreList) {
var scoreText = '<offset value="10">${i}. </offset>
<offset value="50">${score.name}</offset>
<offset value="575">${score.rating}</offset>';
scoreTexts.push(scoreText);
i++;
}
while (i <= 10) {
var scoreText = '<offset value="10">${i}. </offset><offset value="475">10000</offset>';
scoreTexts.push(scoreText);
i++;
}
scoreCtrl.text.text = playerHeaderText + "<br/>" + scoreTexts.join('<br/>');
});
scoreCtrl.text.text = playerHeaderText + "<br/><br/><br/><br/><br/>" + '<p align="center">Loading...</p>';
}
var levelSelectOpts = new GuiXboxOptionsList(2, "Overall", levelNames);
levelSelectOpts.position = new Vector(380, 485);
levelSelectOpts.extent = new Vector(815, 94);
@ -194,13 +225,20 @@ class LeaderboardsGui extends GuiImage {
levelSelectOpts.horizSizing = Right;
levelSelectOpts.alwaysActive = true;
levelSelectOpts.onChangeFunc = (l) -> {
if (levelSelectDifficulty == "players") {
fetchPlayers();
levelTitle.text.text = 'Top Players: ${scoreCategories[cast scoreView]}';
return true;
}
levelTitle.text.text = 'Level ${l + 1}';
currentMission = allMissions[l];
fetchScores();
return true;
}
levelSelectOpts.setCurrentOption(actualIndex);
innerCtrl.addChild(levelSelectOpts);
if (levelSelectDifficulty != "players")
innerCtrl.addChild(levelSelectOpts);
var bottomBar = new GuiControl();
bottomBar.position = new Vector(0, 590);
@ -218,7 +256,7 @@ class LeaderboardsGui extends GuiImage {
if (levelSelectGui)
backButton.pressedAction = (e) -> MarbleGame.canvas.setContent(new LevelSelectGui(levelSelectDifficulty));
else {
backButton.pressedAction = (e) -> MarbleGame.canvas.setContent(new MainMenuGui());
backButton.pressedAction = (e) -> MarbleGame.canvas.setContent(new LeaderboardsSelectGui());
}
bottomBar.addChild(backButton);
@ -231,47 +269,56 @@ class LeaderboardsGui extends GuiImage {
scoreView = scoreView == All ? Rewind : (scoreView == Rewind ? NoRewind : All);
Settings.optionsSettings.currentView = cast scoreView;
levelSelectOpts.labelText.text.text = scoreCategories[cast(scoreView, Int)];
fetchScores();
if (levelSelectDifficulty == "players") {
levelTitle.text.text = 'Top Players: ${scoreCategories[cast scoreView]}';
fetchPlayers();
} else
fetchScores();
}
bottomBar.addChild(changeViewButton);
var replayButton = new GuiXboxButton("Watch Replay", 220);
replayButton.position = new Vector(750, 0);
replayButton.vertSizing = Bottom;
replayButton.gamepadAccelerator = [Settings.gamepadSettings.alt2];
replayButton.horizSizing = Right;
replayButton.pressedAction = (e) -> {
Leaderboards.watchTopReplay(currentMission.path, scoreView, (b) -> {
if (b != null) {
var replayF = new Replay("");
if (replayF.read(b)) {
var repmis = replayF.mission;
// Strip data/ from the mission name
if (StringTools.startsWith(repmis, "data/")) {
repmis = repmis.substr(5);
if (levelSelectDifficulty != "players") {
var replayButton = new GuiXboxButton("Watch Replay", 220);
replayButton.position = new Vector(750, 0);
replayButton.vertSizing = Bottom;
replayButton.gamepadAccelerator = [Settings.gamepadSettings.alt2];
replayButton.horizSizing = Right;
replayButton.pressedAction = (e) -> {
Leaderboards.watchTopReplay(currentMission.path, scoreView, (b) -> {
if (b != null) {
var replayF = new Replay("");
if (replayF.read(b)) {
var repmis = replayF.mission;
// Strip data/ from the mission name
if (StringTools.startsWith(repmis, "data/")) {
repmis = repmis.substr(5);
}
var mi = MissionList.missions.get(repmis);
// try with data/ added
if (mi == null) {
if (!StringTools.contains(repmis, "data/"))
repmis = "data/" + repmis;
mi = MissionList.missions.get(repmis);
}
MarbleGame.instance.watchMissionReplay(mi, replayF, DifficultySelectGui);
} else {
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("Could not load replay for this level."));
}
var mi = MissionList.missions.get(repmis);
// try with data/ added
if (mi == null) {
if (!StringTools.contains(repmis, "data/"))
repmis = "data/" + repmis;
mi = MissionList.missions.get(repmis);
}
MarbleGame.instance.watchMissionReplay(mi, replayF, DifficultySelectGui);
} else {
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("Could not load replay for this level."));
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("No top replay found for this level."));
}
} else {
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("No top replay found for this level."));
}
});
});
}
bottomBar.addChild(replayButton);
}
bottomBar.addChild(replayButton);
fetchScores();
if (levelSelectDifficulty == "players") {
fetchPlayers();
} else
fetchScores();
}
override function onResize(width:Int, height:Int) {

View file

@ -0,0 +1,103 @@
package gui;
import h2d.filter.DropShadow;
import src.MarbleGame;
import gui.GuiControl.MouseState;
import hxd.res.BitmapFont;
import h3d.Vector;
import src.ResourceLoader;
import src.Settings;
class LeaderboardsSelectGui extends GuiImage {
var innerCtrl:GuiControl;
var btnList:GuiXboxList;
public function new() {
var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile();
super(res);
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
var domcasual32 = domcasual32b.toSdfFont(cast 42 * Settings.uiScale, MultiChannel);
this.horizSizing = Width;
this.vertSizing = Height;
this.position = new Vector();
this.extent = new Vector(640, 480);
#if hl
var scene2d = hxd.Window.getInstance();
#end
#if js
var scene2d = MarbleGame.instance.scene2d;
#end
var offsetX = (scene2d.width - 1280) / 2;
var offsetY = (scene2d.height - 720) / 2;
var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width;
var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height;
innerCtrl = new GuiControl();
innerCtrl.position = new Vector(offsetX, offsetY);
innerCtrl.extent = new Vector(640 - subX, 480 - subY);
innerCtrl.horizSizing = Width;
innerCtrl.vertSizing = Height;
this.addChild(innerCtrl);
var coliseumfontdata = ResourceLoader.getFileEntry("data/font/ColiseumRR.fnt");
var coliseumb = new BitmapFont(coliseumfontdata.entry);
@:privateAccess coliseumb.loader = ResourceLoader.loader;
var coliseum = coliseumb.toSdfFont(cast 44 * Settings.uiScale, MultiChannel);
var rootTitle = new GuiText(coliseum);
rootTitle.position = new Vector(100, 30);
rootTitle.extent = new Vector(1120, 80);
rootTitle.text.textColor = 0xFFFFFF;
rootTitle.text.text = "SELECT LEADERBOARDS";
rootTitle.text.alpha = 0.5;
innerCtrl.addChild(rootTitle);
btnList = new GuiXboxList();
btnList.position = new Vector(70 - offsetX, 165);
btnList.horizSizing = Left;
btnList.extent = new Vector(502, 500);
innerCtrl.addChild(btnList);
btnList.addButton(0, 'Level Leaderboards', (e) -> {
MarbleGame.canvas.setContent(new LeaderboardsGui(0, "beginner", false));
});
btnList.addButton(0, 'Player Leaderboards', (e) -> {
MarbleGame.canvas.setContent(new LeaderboardsGui(0, "players", false));
});
var bottomBar = new GuiControl();
bottomBar.position = new Vector(0, 590);
bottomBar.extent = new Vector(640, 200);
bottomBar.horizSizing = Width;
bottomBar.vertSizing = Bottom;
innerCtrl.addChild(bottomBar);
var backButton = new GuiXboxButton("Back", 160);
backButton.position = new Vector(400, 0);
backButton.vertSizing = Bottom;
backButton.horizSizing = Right;
backButton.gamepadAccelerator = [Settings.gamepadSettings.back];
backButton.accelerators = [hxd.Key.ESCAPE, hxd.Key.BACKSPACE];
backButton.pressedAction = (e) -> MarbleGame.canvas.setContent(new MainMenuGui());
bottomBar.addChild(backButton);
}
override function onResize(width:Int, height:Int) {
var offsetX = (width - 1280) / 2;
var offsetY = (height - 720) / 2;
var subX = 640 - (width - offsetX) * 640 / width;
var subY = 480 - (height - offsetY) * 480 / height;
innerCtrl.position = new Vector(offsetX, offsetY);
innerCtrl.extent = new Vector(640 - subX, 480 - subY);
btnList.position = new Vector(70 - offsetX, 165);
super.onResize(width, height);
}
}

View file

@ -80,7 +80,7 @@ class MainMenuGui extends GuiImage {
}
});
btnList.addButton(2, "Leaderboards", (e) -> {
cast(this.parent, Canvas).setContent(new LeaderboardsGui(0, "beginner", false));
cast(this.parent, Canvas).setContent(new LeaderboardsSelectGui());
}, 20);
btnList.addButton(2, "Achievements", (e) -> {
cast(this.parent, Canvas).setContent(new AchievementsGui());