From 65100721396b94031b9a2a35df277a5d0f73ffd2 Mon Sep 17 00:00:00 2001 From: Yoshman29 Date: Sat, 15 Oct 2022 20:42:58 +0200 Subject: [PATCH] some titlestate stuff --- .../{ => titlescreen}/newgrounds_logo.png | Bin buildnumber.txt | 2 +- source/funkin/menus/TitleState.hx | 110 ++++++++++++++++-- source/funkin/ui/Alphabet.hx | 1 + 4 files changed, 101 insertions(+), 12 deletions(-) rename assets/images/{ => titlescreen}/newgrounds_logo.png (100%) diff --git a/assets/images/newgrounds_logo.png b/assets/images/titlescreen/newgrounds_logo.png similarity index 100% rename from assets/images/newgrounds_logo.png rename to assets/images/titlescreen/newgrounds_logo.png diff --git a/buildnumber.txt b/buildnumber.txt index 5f5c3898..eed0d1a4 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -496 \ No newline at end of file +506 \ No newline at end of file diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index f5f64161..7c0fae5b 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -1,5 +1,7 @@ package funkin.menus; +import flixel.util.typeLimit.OneOfThree; +import flixel.util.typeLimit.OneOfTwo; #if desktop import funkin.system.Discord.DiscordClient; import sys.thread.Thread; @@ -27,6 +29,7 @@ import funkin.system.Conductor; import lime.app.Application; import openfl.Assets; import funkin.ui.Alphabet; +import haxe.xml.Access; using StringTools; @@ -34,13 +37,13 @@ class TitleState extends MusicBeatState { static var initialized:Bool = false; - var blackScreen:FlxSprite; - var textGroup:FlxGroup; - var ngSpr:FlxSprite; + public var curWacky:Array = []; - var curWacky:Array = []; + public var blackScreen:FlxSprite; + public var textGroup:FlxGroup; + public var ngSpr:FlxSprite; - var wackyImage:FlxSprite; + public var wackyImage:FlxSprite; override public function create():Void { @@ -123,9 +126,11 @@ class TitleState extends MusicBeatState skipIntro(); else initialized = true; + + add(textGroup); } - function getIntroTextShit():Array> + public function getIntroTextShit():Array> { var fullText:String = Assets.getText(Paths.txt('titlescreen/introText')); @@ -195,7 +200,7 @@ class TitleState extends MusicBeatState super.update(elapsed); } - function createCoolText(textArray:Array) + public function createCoolText(textArray:Array) { for (i=>text in textArray) { @@ -206,14 +211,14 @@ class TitleState extends MusicBeatState } } - function addMoreText(text:String) + public function addMoreText(text:String) { var coolText:Alphabet = new Alphabet(0, (textGroup.length * 60) + 200, text, true, false); coolText.screenCenter(X); textGroup.add(coolText); } - function deleteCoolText() + public function deleteCoolText() { while (textGroup.members.length > 0) textGroup.remove(textGroup.members[0], true); } @@ -231,7 +236,13 @@ class TitleState extends MusicBeatState gfDance.animation.play('danceLeft'); #if TITLESCREEN_XML - + if (curBeat >= 16) { + if (!skippedIntro) skipIntro(); + return; + } + var introText = titleLines[curBeat]; + if (introText != null) + introText.show(); #else switch (curBeat) { @@ -252,9 +263,43 @@ class TitleState extends MusicBeatState #end } + #if TITLESCREEN_XML + public var xml:Access; + public var titleLength:Int = 16; + public var titleLines:Map = [ + 1 => new IntroText(['ninjamuffin99', 'phantomArcade', 'kawaisprite', 'evilsk8er']), + 3 => new IntroText(['ninjamuffin99', 'phantomArcade', 'kawaisprite', 'evilsk8er', 'present']), + 4 => new IntroText(), + 5 => new IntroText(['In association', 'with']), + 7 => new IntroText(['In association', 'with', 'newgrounds', { + name: "newgroundsLogo", + sprite: "titlescreen/newgrounds_logo", + scale: 0.8 + }]), + 8 => new IntroText(), + 9 => new IntroText(["{introText1}"]), + 11 => new IntroText(["{introText1}", "{introText2}"]), + 12 => new IntroText(), + 13 => new IntroText(['Friday']), + 14 => new IntroText(['Friday', 'Night']), + 15 => new IntroText(['Friday', 'Night', "Funkin'"]), + ]; + + public function loadXML() { + try { + xml = new Access(Xml.parse(Assets.getText('data/titlescreen.xml')).firstElement()); + + // for(e in xml.) + } catch(e) { + // TODO: Logging!! + trace(e.details()); + } + } + #end + var skippedIntro:Bool = false; - function skipIntro():Void + public function skipIntro():Void { if (!skippedIntro) { @@ -263,7 +308,50 @@ class TitleState extends MusicBeatState FlxG.camera.flash(FlxColor.WHITE, 4); remove(blackScreen); blackScreen.destroy(); + remove(textGroup); skippedIntro = true; } } } + +class IntroText { + public var lines:Array> = []; + + public function new(?lines:Array>) { + this.lines = lines; + } + + public function show() { + var state = cast(FlxG.state, TitleState); + state.deleteCoolText(); + if (lines == null) return; + for(e in lines) { + if (e is String) { + var text = cast(e, String); + for(k=>e in state.curWacky) text = text.replace('{introText${k+1}', e); + state.addMoreText(text); + } else if (e is Dynamic) { + var image:TitleStateImage = e; + if (image.sprite == null) continue; + + var scale:Float = CoolUtil.getDefault(image.scale, 1); + + var sprite = new FlxSprite(0, 200, Paths.image(image.sprite)); + sprite.flipX = CoolUtil.getDefault(image.flipX, false); + sprite.flipY = CoolUtil.getDefault(image.flipY, false); + sprite.scale.set(scale, scale); + sprite.updateHitbox(); + sprite.screenCenter(X); + state.textGroup.add(sprite); + } + } + } +} + +typedef TitleStateImage = { + var name:String; + var sprite:String; + @:optional var scale:Null; + @:optional var flipX:Null; + @:optional var flipY:Null; +} \ No newline at end of file diff --git a/source/funkin/ui/Alphabet.hx b/source/funkin/ui/Alphabet.hx index e297b458..0fa5428d 100644 --- a/source/funkin/ui/Alphabet.hx +++ b/source/funkin/ui/Alphabet.hx @@ -56,6 +56,7 @@ class Alphabet extends FlxSpriteGroup return super.set_color(c); } + // TODO: fix this shit refreshing public function refreshAlphabetXML(path:String) { trace("Needs refresh!!"); AlphaCharacter.__alphaPath = path;