aboutsummaryrefslogtreecommitdiff
path: root/source/screens/LeaderBoardState.hx
diff options
context:
space:
mode:
Diffstat (limited to 'source/screens/LeaderBoardState.hx')
-rw-r--r--source/screens/LeaderBoardState.hx74
1 files changed, 74 insertions, 0 deletions
diff --git a/source/screens/LeaderBoardState.hx b/source/screens/LeaderBoardState.hx
new file mode 100644
index 0000000..67f726e
--- /dev/null
+++ b/source/screens/LeaderBoardState.hx
@@ -0,0 +1,74 @@
+package screens;
+
+import flixel.FlxG;
+import flixel.FlxState;
+import flixel.addons.ui.FlxUIGroup;
+import flixel.addons.ui.FlxUIList;
+import flixel.addons.ui.FlxUIRegion;
+import flixel.addons.ui.FlxUIText;
+import flixel.text.FlxText;
+import flixel.ui.FlxButton;
+import flixel.util.FlxColor;
+import shared.PlayerSave;
+import shared.ScoreBoard;
+import shared.Types.Entry;
+import shared.Types.ScoreBoardData;
+
+class LeaderBoardState extends FlxState
+{
+ var scoreBoardList:FlxUIList;
+ var previousState:FlxState;
+
+ public function new()
+ {
+ super();
+ var scoreLabel:FlxText = new FlxText(FlxG.width / 2 - 50, 10, "Leaderboard", 13);
+ scoreLabel.borderSize = 1;
+ scoreLabel.borderColor = FlxColor.PURPLE;
+ scoreLabel.borderQuality = 1;
+ scoreLabel.borderStyle = FlxTextBorderStyle.OUTLINE;
+ scoreBoardList = new FlxUIList(FlxG.width / 2 - 100, 70, [], 300, 300, "More");
+ scoreBoardList.loadGraphic(AssetPaths.space_bg__png);
+ var backButton:FlxButton = new FlxButton(FlxG.width / 2 - 40, 410, "Back", onBackButtonClick);
+ add(scoreLabel);
+ add(scoreBoardList);
+ add(backButton);
+ getScores();
+ }
+
+ override public function create()
+ {
+ super.create();
+ }
+
+ private function getScores()
+ {
+ var scoreboard:ScoreBoard = new ScoreBoard();
+ var scoresData:ScoreBoardData = scoreboard.getScores();
+ trace(scoresData.dreamlo.leaderboard);
+ if (scoresData.dreamlo.leaderboard != null)
+ {
+ var scores:Array<Entry> = scoresData.dreamlo.leaderboard.entry;
+ for (i in 0...400)
+ {
+ scores.push(scores[0]);
+ }
+ for (score in scores)
+ {
+ var widgetGroup:FlxUIGroup = new FlxUIGroup(0, 0);
+ var nameTxt:FlxUIText = new FlxUIText(0, 0, 100, '${score.text}', 11);
+ var scoreTxt:FlxUIText = new FlxUIText(100, 0, 100, '${score.score}', 11);
+ nameTxt.alignment = FlxTextAlign.LEFT;
+ scoreTxt.alignment = FlxTextAlign.RIGHT;
+ widgetGroup.add(nameTxt);
+ widgetGroup.add(scoreTxt);
+ scoreBoardList.add(widgetGroup);
+ }
+ }
+ }
+
+ private function onBackButtonClick()
+ {
+ FlxG.switchState(new MenuState());
+ }
+}