From fac6bbc2594196bd8e12715376be9adf23aa07e0 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 25 Dec 2020 00:17:21 -0500 Subject: [PATCH] outdated check --- source/MainMenuState.hx | 8 +++++--- source/NGio.hx | 10 ++++++---- source/OutdatedSubState.hx | 16 +++++++++++----- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index e8aa27b01..0f287a040 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -87,12 +87,14 @@ class MainMenuState extends MusicBeatState versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); add(versionShit); - if (versionShit.text != NGio.GAME_VER) + if (versionShit.text != NGio.GAME_VER && !OutdatedSubState.leftState) { - openSubState(new OutdatedSubState()); + trace('OLD VERSION!'); + + FlxG.switchState(new OutdatedSubState()); } - NG.core.calls.event.logEvent('swag').send(); + // NG.core.calls.event.logEvent('swag').send(); changeItem(); diff --git a/source/NGio.hx b/source/NGio.hx index 2b25adf36..96ced6257 100644 --- a/source/NGio.hx +++ b/source/NGio.hx @@ -2,6 +2,7 @@ package; import flixel.FlxG; import flixel.util.FlxSignal; +import flixel.util.FlxTimer; import io.newgrounds.NG; import io.newgrounds.components.ScoreBoardComponent.Period; import io.newgrounds.objects.Medal; @@ -27,6 +28,7 @@ class NGio public static var ngScoresLoaded(default, null):FlxSignal = new FlxSignal(); public static var GAME_VER:String = ""; + public static var gotOnlineVer:Bool = false; public static function noLogin(api:String) { @@ -35,13 +37,13 @@ class NGio NG.create(api); - NG.onCoreReady.add(function() + new FlxTimer().start(2, function(tmr:FlxTimer) { - trace('READY SHIT??'); - var call = NG.core.calls.gateway.getVersion().addDataHandler(function(response:Response) + var call = NG.core.calls.app.getCurrentVersion(GAME_VER).addDataHandler(function(response:Response) { - GAME_VER = response.result.data.version; + GAME_VER = response.result.data.current_version; trace('CURRENT NG VERSION: ' + GAME_VER); + gotOnlineVer = true; }); call.send(); diff --git a/source/OutdatedSubState.hx b/source/OutdatedSubState.hx index 865c70d46..06d0aae70 100644 --- a/source/OutdatedSubState.hx +++ b/source/OutdatedSubState.hx @@ -1,18 +1,23 @@ package; import flixel.FlxG; +import flixel.FlxSprite; import flixel.FlxSubState; import flixel.text.FlxText; import flixel.util.FlxColor; import lime.app.Application; -class OutdatedSubState extends MusicBeatSubstate +class OutdatedSubState extends MusicBeatState { - public function new() + public static var leftState:Bool = false; + + override function create() { - super(); + super.create(); + var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); + add(bg); var ver = "v" + Application.current.meta.get('version'); - var txt:FlxText = new FlxText(0, 0, 0, + var txt:FlxText = new FlxText(0, 0, FlxG.width, "HEY! You're running an outdated version of the game!\nCurrent version is " + ver + " while the current version is " @@ -32,7 +37,8 @@ class OutdatedSubState extends MusicBeatSubstate } if (controls.BACK) { - close(); + leftState = true; + FlxG.switchState(new MainMenuState()); } super.update(elapsed); }