diff --git a/gitVersion.txt b/gitVersion.txt new file mode 100644 index 0000000000..fb7a04cff8 --- /dev/null +++ b/gitVersion.txt @@ -0,0 +1 @@ +v0.4.0 diff --git a/source/funkin/ui/title/OutdatedSubState.hx b/source/funkin/ui/title/OutdatedState.hx similarity index 52% rename from source/funkin/ui/title/OutdatedSubState.hx rename to source/funkin/ui/title/OutdatedState.hx index bc938f24a5..de5b07d968 100644 --- a/source/funkin/ui/title/OutdatedSubState.hx +++ b/source/funkin/ui/title/OutdatedState.hx @@ -1,28 +1,51 @@ package funkin.ui.title; -import flixel.FlxSprite; -import flixel.FlxSubState; +import flixel.FlxG; import flixel.text.FlxText; import flixel.util.FlxColor; import funkin.ui.MusicBeatState; import lime.app.Application; +import funkin.ui.mainmenu.MainMenuState; +import haxe.Http; -#if newgrounds -class OutdatedSubState extends MusicBeatState +class OutdatedState extends MusicBeatState { public static var leftState:Bool = false; + public static var updateVersion:String = ""; override function create() { super.create(); - var bg:FunkinSprite = new FunkinSprite().makeSolidColor(FlxG.width, FlxG.height, FlxColor.BLACK); - add(bg); + + var url = "https://raw.githubusercontent.com/Ethan-makes-music/Funkin/develop/gitVersion.txt"; + + var request = new Http(url); + + request.onData = function(data:String) { + // Data is the content of the .txt file + updateVersion = data.trim(); + createText(); + }; + + // Set the callback for any errors + request.onError = function(msg:String) { + trace("Error: " + msg); + // In case of an error, proceed to MainMenuState or handle accordingly + FlxG.switchState(() -> new MainMenuState()); + }; + + // Send the request + request.request(false); + } + + function createText():Void + { var ver = "v" + Application.current.meta.get('version'); 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 most recent version is " - + NGio.GAME_VER + + updateVersion + "! Press Space to go to itch.io, or ESCAPE to ignore this!!", 32); txt.setFormat("VCR OSD Mono", 32, FlxColor.WHITE, CENTER); @@ -35,6 +58,8 @@ class OutdatedSubState extends MusicBeatState if (controls.ACCEPT) { FlxG.openURL("https://ninja-muffin24.itch.io/funkin"); + leftState = true; + FlxG.switchState(() -> new MainMenuState()); } if (controls.BACK) { @@ -44,4 +69,3 @@ class OutdatedSubState extends MusicBeatState super.update(elapsed); } } -#end diff --git a/source/funkin/ui/title/TitleState.hx b/source/funkin/ui/title/TitleState.hx index 8087916cbd..8f3b6010f6 100644 --- a/source/funkin/ui/title/TitleState.hx +++ b/source/funkin/ui/title/TitleState.hx @@ -32,6 +32,8 @@ import openfl.media.Video; import openfl.net.NetStream; import funkin.api.newgrounds.NGio; import openfl.display.BlendMode; +import funkin.ui.title.OutdatedState; +import lime.app.Application; #if desktop #end @@ -55,9 +57,12 @@ class TitleState extends MusicBeatState var netStream:NetStream; var overlay:Sprite; + var leftState:Bool = false; + override public function create():Void { super.create(); + swagShader = new ColorSwap(); curWacky = FlxG.random.getObject(getIntroTextShit()); @@ -273,16 +278,6 @@ class TitleState extends MusicBeatState #end Conductor.instance.update(); - - /* if (FlxG.onMobile) - { - if (gfDance != null) - { - gfDance.x = (FlxG.width / 2) + (FlxG.accelerometer.x * (FlxG.width / 2)); - // gfDance.y = (FlxG.height / 2) + (FlxG.accelerometer.y * (FlxG.height / 2)); - } - } - */ if (FlxG.keys.justPressed.I) { FlxTween.tween(outlineShaderShit, {funnyX: 50, funnyY: 50}, 0.6, {ease: FlxEase.quartOut}); @@ -318,10 +313,52 @@ class TitleState extends MusicBeatState FlxG.switchState(() -> new MainMenuState()); } + if (pressedEnter && skippedIntro) + { + var url = "https://raw.githubusercontent.com/Ethan-makes-music/Funkin/develop/gitVersion.txt"; + var request = new haxe.Http(url); + + request.onData = function(data:String) { + // Data is the content of the .txt file + var updateVersion = data.trim(); + var ver = "v" + Application.current.meta.get('version'); + + // Print both versions for debugging + trace("Current Version: " + ver); + trace("Update Version: " + updateVersion); + + // This makes it so if your in debug mode the Outdated screen will not appear + #if debug + FlxG.switchState(() -> new MainMenuState()); + trace("Your in debug mode!"); + #else + trace("Your NOT in debug mode!"); + // Checks to see if the versions are not the same, if so go to the Outdated screen. + if (ver != updateVersion) + { + // Versions are different, switch to OutdatedState + FlxG.switchState(() -> new OutdatedState()); + } + else if (ver == updateVersion) + { + // Versions are the same, switch to MainMenuState + FlxG.switchState(() -> new MainMenuState()); + } + #end + }; + + // Set the callback for any errors + request.onError = function(msg:String) { + trace("Error: " + msg); + }; + + // Send the request + request.request(false); + } + if (pressedEnter && !transitioning && skippedIntro) { if (FlxG.sound.music != null) FlxG.sound.music.onComplete = null; - // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); NGio.unlockMedal(60960); // If it's Friday according to da clock if (Date.now().getDay() == 5) NGio.unlockMedal(61034);