diff --git a/README.md b/README.md index 654a3d309..7a796d16a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ IF YOU WANT TO COMPILE THE GAME YOURSELF, CONTINUE READING!!! ### Installing the Required Programs First, you need to install Haxe and HaxeFlixel. I'm too lazy to write and keep updated with that setup (which is pretty simple). -1. [Install Haxe 4.1.5](https://haxe.org/download/version/4.1.5/) (Download 4.1.5 instead of 4.2.0 because 4.2.0 is broken and is not working with gits properly...) +1. [Install latest Haxe](https://haxe.org/download) (Haxe 4.3.1 is the latest, when writing this) 2. [Install HaxeFlixel](https://haxeflixel.com/documentation/install-haxeflixel/) after downloading Haxe Other installations you'd need are the additional libraries, a fully updated list will be in `Project.xml` in the project root. Currently, these are all of the things you need to install: diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 1030c19ba..8bb3c1a5b 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -19,7 +19,7 @@ import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup; import flixel.math.FlxMath; import flixel.math.FlxPoint; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import flixel.text.FlxText; import flixel.ui.FlxButton; import flixel.ui.FlxSpriteButton; diff --git a/source/Controls.hx b/source/Controls.hx index 760fc0af0..f72be486c 100644 --- a/source/Controls.hx +++ b/source/Controls.hx @@ -36,8 +36,7 @@ enum Control #end } -@:enum -abstract Action(String) to String from String +enum abstract Action(String) to String from String { var UI_UP = "ui_up"; var UI_LEFT = "ui_left"; diff --git a/source/InputFormatter.hx b/source/InputFormatter.hx index 413910543..2b6305acb 100644 --- a/source/InputFormatter.hx +++ b/source/InputFormatter.hx @@ -145,7 +145,7 @@ class InputFormatter } @:forward -@:enum abstract ControllerName(String) from String to String +enum abstract ControllerName(String) from String to String { var OUYA = "Ouya" ; var PS4 = "PS4" ; diff --git a/source/Main.hx b/source/Main.hx index b5f1dcb87..c79c2553e 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -84,7 +84,7 @@ class Main extends Sprite initialState = TitleState; #end - addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen)); + addChild(new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen)); #if !mobile fpsCounter = new FPS(10, 3, 0xFFFFFF); diff --git a/source/NGio.hx b/source/NGio.hx index f82323e4b..80736ec30 100644 --- a/source/NGio.hx +++ b/source/NGio.hx @@ -11,13 +11,15 @@ import io.newgrounds.objects.Error; import io.newgrounds.objects.Medal; import io.newgrounds.objects.Score; import io.newgrounds.objects.ScoreBoard; +import io.newgrounds.objects.events.Outcome; import io.newgrounds.objects.events.Response; -import io.newgrounds.objects.events.Result.GetCurrentVersionResult; -import io.newgrounds.objects.events.Result.GetVersionResult; +import io.newgrounds.objects.events.Result; import lime.app.Application; import openfl.display.Stage; using StringTools; +using io.newgrounds.objects.events.Outcome.TypedOutcomeTools; +using io.newgrounds.objects.events.Outcome.OutcomeTools; #end /** * MADE BY GEOKURELI THE LEGENED GOD HERO MVP @@ -50,11 +52,17 @@ class NGio GAME_VER = "v" + Application.current.meta.get('version'); NG.core.calls.app.getCurrentVersion(GAME_VER) - .addDataHandler(function(response) + .addOutcomeHandler(function (outcome) { - GAME_VER = response.result.data.currentVersion; - trace('CURRENT NG VERSION: ' + GAME_VER); - callback(GAME_VER); + switch(outcome) + { + case SUCCESS(data): + GAME_VER = data.currentVersion; + trace('CURRENT NG VERSION: ' + GAME_VER); + callback(GAME_VER); + case FAIL(error): + throw 'Error getting NG version: $error'; + } }) .send(); } @@ -71,12 +79,12 @@ class NGio #if NG_FORCE_EXPIRED_SESSION var sessionId:String = "fake_session_id"; - function onSessionFail(error:Error) - { - trace("Forcing an expired saved session. " - + "To disable, comment out NG_FORCE_EXPIRED_SESSION in Project.xml"); - savedSessionFailed = true; - } + // function onSessionFail(error:String) + // { + // trace("Forcing an expired saved session. " + // + "To disable, comment out NG_FORCE_EXPIRED_SESSION in Project.xml"); + // savedSessionFailed = true; + // } #else var sessionId:String = NGLite.getSessionId(); if (sessionId != null) @@ -90,20 +98,29 @@ class NGio } #end - var onSessionFail:Error->Void = null; - if (sessionId == null && FlxG.save.data.sessionId != null) - { - trace("using stored session id"); - sessionId = FlxG.save.data.sessionId; - onSessionFail = function (error) savedSessionFailed = true; - } + // var onSessionFail:Error->Void = null; + // if (sessionId == null && FlxG.save.data.sessionId != null) + // { + // trace("using stored session id"); + // sessionId = FlxG.save.data.sessionId; + // onSessionFail = function (error) savedSessionFailed = true; + // } #end - NG.create(api, sessionId, #if NG_DEBUG true #else false #end, onSessionFail); + NG.create(api, sessionId, #if NG_DEBUG true #else false #end, function (outcome) + { + switch(outcome) + { + case SUCCESS: + case FAIL(CANCELLED(PASSPORT)): trace('Login cancelled by user'); + case FAIL(CANCELLED(MANUAL)): trace('Login cancelled'); + case FAIL(ERROR(error)): trace('Error logging in: $error'); + } + }); #if NG_VERBOSE NG.core.verbose = true; #end // Set the encryption cipher/format to RC4/Base64. AES128 and Hex are not implemented yet - NG.core.initEncryption(APIStuff.EncKey); // Found in you NG project view + NG.core.setupEncryption(APIStuff.EncKey, RC4); // Found in you NG project view if (NG.core.attemptingLogin) { @@ -129,30 +146,25 @@ class NGio * a user input event or the popup blocker will block it. * @param onComplete A callback with the result of the connection. */ - static public function login(?popupLauncher:(Void->Void)->Void, onComplete:ConnectionResult->Void) + static public function login(?popupLauncher:(()->Void)->Void, onComplete:LoginOutcome->Void) { trace("Logging in manually"); - var onPending:Void->Void = null; + var onPending:String->Void = null; if (popupLauncher != null) { - onPending = function () popupLauncher(NG.core.openPassportUrl); + onPending = function (_) popupLauncher(NG.core.openPassportUrl); } - var onSuccess:Void->Void = onNGLogin; - var onFail:Error->Void = null; - var onCancel:Void->Void = null; - if (onComplete != null) + NG.core.requestLogin(function (outcome) { - onSuccess = function () + switch (outcome) { - onNGLogin(); - onComplete(Success); + case SUCCESS: + onNGLogin(); + default: } - onFail = function (e) onComplete(Fail(e.message)); - onCancel = function() onComplete(Cancelled); - } - - NG.core.requestLogin(onSuccess, onPending, onFail, onCancel); + onComplete(outcome); + }, onPending); } inline static public function cancelLogin():Void @@ -166,10 +178,10 @@ class NGio FlxG.save.data.sessionId = NG.core.sessionId; FlxG.save.flush(); // Load medals then call onNGMedalFetch() - NG.core.requestMedals(onNGMedalFetch); + NG.core.medals.loadList((outcome)->outcome.assertSuccessHandler(onNGMedalFetch)); // Load Scoreboards hten call onNGBoardsFetch() - NG.core.requestScoreBoards(onNGBoardsFetch); + NG.core.scoreBoards.loadList((outcome)->outcome.assertSuccessHandler(onNGBoardsFetch)); ngDataLoaded.dispatch(); } @@ -291,13 +303,3 @@ class NGio #end } } - -enum ConnectionResult -{ - /** Log in successful */ - Success; - /** Could not login */ - Fail(msg:String); - /** User cancelled the login */ - Cancelled; -} diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index 1bb3750cf..c5559ba69 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -7,7 +7,7 @@ import flixel.FlxSubState; import flixel.addons.transition.FlxTransitionableState; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.input.keyboard.FlxKey; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; diff --git a/source/PlayState.hx b/source/PlayState.hx index 522755b00..c6c80bd23 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -25,7 +25,7 @@ import flixel.math.FlxAngle; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxRect; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; diff --git a/source/ui/AtlasMenuList.hx b/source/ui/AtlasMenuList.hx index 68232da5c..b12d7529b 100644 --- a/source/ui/AtlasMenuList.hx +++ b/source/ui/AtlasMenuList.hx @@ -14,7 +14,7 @@ class AtlasMenuList extends MenuTypedList { super(navControls, wrapMode); - if (Std.is(atlas, String)) + if (atlas is String) this.atlas = Paths.getSparrowAtlas(cast atlas); else this.atlas = cast atlas; diff --git a/source/ui/NgPrompt.hx b/source/ui/NgPrompt.hx index 4bf75997f..b8e8ff8d3 100644 --- a/source/ui/NgPrompt.hx +++ b/source/ui/NgPrompt.hx @@ -1,5 +1,6 @@ package ui; +import io.newgrounds.NGLite; import NGio; import ui.Prompt; @@ -57,24 +58,24 @@ class NgPrompt extends Prompt openPassportUrl(); } }, - function onLoginComplete(result:ConnectionResult) + function onLoginComplete(result:LoginOutcome) { switch (result) { - case Success: + case SUCCESS: { prompt.setText("Login Successful"); prompt.setButtons(Ok); prompt.onYes = prompt.close; } - case Fail(msg): + case FAIL(ERROR(error)): { - trace("Login Error:" + msg); + trace("Login Error:" + error.toString()); prompt.setText("Login failed"); prompt.setButtons(Ok); prompt.onYes = prompt.close; } - case Cancelled: + case FAIL(CANCELLED(PASSPORT)): { if (prompt != null) { @@ -85,6 +86,17 @@ class NgPrompt extends Prompt else trace("Login cancelled via prompt"); } + case FAIL(CANCELLED(MANUAL)): + { + if (prompt != null) + { + prompt.setText("Login cancelled"); + prompt.setButtons(Ok); + prompt.onYes = prompt.close; + } + else + trace("Login cancelled via prompt"); + } } } );