From a7111abeb3882e278225aa3260a0a7254d86a1c7 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 22 Dec 2020 19:57:55 -0500 Subject: [PATCH] mom chart --- source/MainMenuState.hx | 5 +++++ source/NGio.hx | 28 ++++++++++++++++++++++----- source/OutdatedSubState.hx | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 source/OutdatedSubState.hx diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index fceb951a4..e8aa27b01 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -87,6 +87,11 @@ 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) + { + openSubState(new OutdatedSubState()); + } + NG.core.calls.event.logEvent('swag').send(); changeItem(); diff --git a/source/NGio.hx b/source/NGio.hx index cafc26b37..2b25adf36 100644 --- a/source/NGio.hx +++ b/source/NGio.hx @@ -7,6 +7,10 @@ import io.newgrounds.components.ScoreBoardComponent.Period; import io.newgrounds.objects.Medal; import io.newgrounds.objects.Score; import io.newgrounds.objects.ScoreBoard; +import io.newgrounds.objects.events.Response; +import io.newgrounds.objects.events.Result.GetCurrentVersionResult; +import io.newgrounds.objects.events.Result.GetVersionResult; +import lime.app.Application; import openfl.display.Stage; /** @@ -22,9 +26,26 @@ class NGio public static var ngDataLoaded(default, null):FlxSignal = new FlxSignal(); public static var ngScoresLoaded(default, null):FlxSignal = new FlxSignal(); + public static var GAME_VER:String = ""; + public static function noLogin(api:String) { + trace('INIT NOLOGIN'); + GAME_VER = "v" + Application.current.meta.get('version'); + NG.create(api); + + NG.onCoreReady.add(function() + { + trace('READY SHIT??'); + var call = NG.core.calls.gateway.getVersion().addDataHandler(function(response:Response) + { + GAME_VER = response.result.data.version; + trace('CURRENT NG VERSION: ' + GAME_VER); + }); + + call.send(); + }); } public function new(api:String, encKey:String, ?sessionId:String) @@ -153,11 +174,8 @@ class NGio inline static public function logEvent(event:String) { - if (isLoggedIn) - { - NG.core.calls.event.logEvent(event); - trace('should have logged: ' + event); - } + NG.core.calls.event.logEvent(event).send(); + trace('should have logged: ' + event); } inline static public function unlockMedal(id:Int) diff --git a/source/OutdatedSubState.hx b/source/OutdatedSubState.hx new file mode 100644 index 000000000..865c70d46 --- /dev/null +++ b/source/OutdatedSubState.hx @@ -0,0 +1,39 @@ +package; + +import flixel.FlxG; +import flixel.FlxSubState; +import flixel.text.FlxText; +import flixel.util.FlxColor; +import lime.app.Application; + +class OutdatedSubState extends MusicBeatSubstate +{ + public function new() + { + super(); + var ver = "v" + Application.current.meta.get('version'); + var txt:FlxText = new FlxText(0, 0, 0, + "HEY! You're running an outdated version of the game!\nCurrent version is " + + ver + + " while the current version is " + + NGio.GAME_VER + + " ! Press Space to go to itch.io, or ESCAPE to ignore this!!", + 32); + txt.setFormat("VCR OSD Mono", 32, FlxColor.WHITE, CENTER); + txt.screenCenter(); + add(txt); + } + + override function update(elapsed:Float) + { + if (controls.ACCEPT) + { + FlxG.openURL("https://ninja-muffin24.itch.io/funkin"); + } + if (controls.BACK) + { + close(); + } + super.update(elapsed); + } +}