outdated check

This commit is contained in:
Cameron Taylor 2020-12-25 00:17:21 -05:00
parent 087d735aa3
commit e1df3e98f6
3 changed files with 22 additions and 12 deletions

View File

@ -87,12 +87,14 @@ class MainMenuState extends MusicBeatState
versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); versionShit.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
add(versionShit); 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(); changeItem();

View File

@ -2,6 +2,7 @@ package;
import flixel.FlxG; import flixel.FlxG;
import flixel.util.FlxSignal; import flixel.util.FlxSignal;
import flixel.util.FlxTimer;
import io.newgrounds.NG; import io.newgrounds.NG;
import io.newgrounds.components.ScoreBoardComponent.Period; import io.newgrounds.components.ScoreBoardComponent.Period;
import io.newgrounds.objects.Medal; import io.newgrounds.objects.Medal;
@ -27,6 +28,7 @@ class NGio
public static var ngScoresLoaded(default, null):FlxSignal = new FlxSignal(); public static var ngScoresLoaded(default, null):FlxSignal = new FlxSignal();
public static var GAME_VER:String = ""; public static var GAME_VER:String = "";
public static var gotOnlineVer:Bool = false;
public static function noLogin(api:String) public static function noLogin(api:String)
{ {
@ -35,13 +37,13 @@ class NGio
NG.create(api); NG.create(api);
NG.onCoreReady.add(function() new FlxTimer().start(2, function(tmr:FlxTimer)
{ {
trace('READY SHIT??'); var call = NG.core.calls.app.getCurrentVersion(GAME_VER).addDataHandler(function(response:Response<GetCurrentVersionResult>)
var call = NG.core.calls.gateway.getVersion().addDataHandler(function(response:Response<GetVersionResult>)
{ {
GAME_VER = response.result.data.version; GAME_VER = response.result.data.current_version;
trace('CURRENT NG VERSION: ' + GAME_VER); trace('CURRENT NG VERSION: ' + GAME_VER);
gotOnlineVer = true;
}); });
call.send(); call.send();

View File

@ -1,18 +1,23 @@
package; package;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxSubState; import flixel.FlxSubState;
import flixel.text.FlxText; import flixel.text.FlxText;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import lime.app.Application; 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 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 " "HEY! You're running an outdated version of the game!\nCurrent version is "
+ ver + ver
+ " while the current version is " + " while the current version is "
@ -32,7 +37,8 @@ class OutdatedSubState extends MusicBeatSubstate
} }
if (controls.BACK) if (controls.BACK)
{ {
close(); leftState = true;
FlxG.switchState(new MainMenuState());
} }
super.update(elapsed); super.update(elapsed);
} }