Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Re-add out of date screen #2720

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gitVersion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.4.0
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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)
{
Expand All @@ -44,4 +69,3 @@ class OutdatedSubState extends MusicBeatState
super.update(elapsed);
}
}
#end
59 changes: 48 additions & 11 deletions source/funkin/ui/title/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -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);
Expand Down
Loading