diff --git a/source/TitleState.hx b/source/TitleState.hx index 0054f25b25a..1e79fa409fe 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -59,6 +59,7 @@ class TitleState extends MusicBeatState 'ANNOUNCER' ]; final allowedKeys:String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + final allowedShit = ~/^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]+$/; var sarcasmKeysBuffer:String = ''; var blackScreen:FlxSprite; @@ -364,19 +365,24 @@ class TitleState extends MusicBeatState throw 'Crash test'; */ - // Sarcasm Easter Egg, this might not work! :D - function sarcasmEasterEgg() + sarcasmKeysBuffer += KeyboardFunctions.keypressToString(); + if (sarcasmKeysBuffer.length >= 32) + sarcasmKeysBuffer = sarcasmKeysBuffer.substring(1); + + for (wordRaw in sarcasmKeys) { - //if(FlxG.save.data == null) FlxG.save.data = ''; // Crash prevention - switch(sarcasmEgg) + final word:String = wordRaw.toUpperCase(); + if (sarcasmKeysBuffer.contains(word) && allowedShit.match(word)) { - case 'ANNOUNCER': - FlxG.sound.play(Paths.sound('sarcasmComplete')); + switch (word) + { + case 'ANNOUNCER': + FlxG.sound.play(Paths.sound('sarcasmComplete')); + sarcasmKeysBuffer = ''; + } } } - sarcasmEasterEgg(); - if (initialized && !transitioning && skippedIntro) { if (newTitle && !pressedEnter) @@ -565,3 +571,32 @@ class TitleState extends MusicBeatState } } } + +// copied & pasted from an haxelib, but it's better +private class KeyboardFunctions +{ + /** + * Just a simple function to determine which key was pressed. Good for sequential keypresses. An example of how to use this is by simply adding the value to a string in the update function. + * + * Ex: + * ``` + * public var value:String = ''; + * override function update(elapsed:Float) { + * value += keypressToString(); // This will add a key to the string everytime a key is pressed + * } + * ``` + * @return Key that was pressed as a String + */ + public static function keypressToString():String + { + var characterToAdd:String = ""; + if (FlxG.keys.justPressed.ANY) { + final key = cast(FlxG.keys.firstJustPressed(), FlxKey); + if (key != FlxKey.NONE){ + final i = key.toString().toUpperCase(); + characterToAdd += FlxKey.fromStringMap.get(i); + } + } + return characterToAdd; + } +} \ No newline at end of file diff --git a/source/VideoSprite.hx b/source/VideoSprite.hx index 6fbc85a7f1b..de10ff98c69 100644 --- a/source/VideoSprite.hx +++ b/source/VideoSprite.hx @@ -28,6 +28,8 @@ class VideoSprite extends FlxSpriteGroup public var waiting:Bool = false; public var didPlay:Bool = false; + public var addCover:Bool = true; + private var controls(get, never):Controls; inline function get_controls():Controls @@ -42,7 +44,7 @@ class VideoSprite extends FlxSpriteGroup cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]]; waiting = isWaiting; - if (!waiting) // for mid song videos, if not mid song, don't add the cover since it's not needed + if (!waiting || addCover) // for mid song videos, if not mid song, don't add the cover since it's not needed { cover = new FlxSprite().makeGraphic(1, 1, FlxColor.BLACK); cover.scale.set(FlxG.width + 100, FlxG.height + 100); @@ -73,7 +75,12 @@ class VideoSprite extends FlxSpriteGroup cover.destroy(); } - PlayState.instance.remove(this); + final curState = FlxG.state; + + if (PlayState.instance != null) + PlayState.instance.remove(this); + else if (curState != null) + curState.remove(this, true); destroy(); alreadyDestroyed = true; }); @@ -119,7 +126,12 @@ class VideoSprite extends FlxSpriteGroup finishCallback(); onSkip = null; - PlayState.instance.remove(this); + final curState = FlxG.state; + + if (PlayState.instance != null) + PlayState.instance.remove(this); + else if (curState != null) + curState.remove(this, true); super.destroy(); }