Skip to content

Commit 0001017

Browse files
KoloInDaCribEliteMasterEric
authored andcommitted
the grand reopening
1 parent 7d6a4cb commit 0001017

7 files changed

Lines changed: 109 additions & 583 deletions

File tree

source/funkin/ui/freeplay/FreeplayState.hx

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import funkin.graphics.shaders.HSVShader;
2828
import funkin.graphics.shaders.PureColor;
2929
import funkin.graphics.shaders.StrokeShader;
3030
import funkin.input.Controls;
31+
import funkin.modding.events.ScriptEvent;
32+
import funkin.modding.events.ScriptEventDispatcher;
3133
import funkin.play.PlayStatePlaylist;
3234
import funkin.play.scoring.Scoring.ScoringRank;
3335
import funkin.play.song.Song;
@@ -255,16 +257,25 @@ class FreeplayState extends MusicBeatSubState
255257

256258
if (stickers?.members != null) stickerSubState = stickers;
257259

258-
switch (currentCharacterId)
260+
if (PlayerRegistry.instance.hasNewCharacter())
259261
{
260-
case(PlayerRegistry.instance.hasNewCharacter()) => true:
261-
backingCard = new NewCharacterCard(currentCharacter);
262-
case 'bf':
263-
backingCard = new BoyfriendCard(currentCharacter);
264-
case 'pico':
265-
backingCard = new PicoCard(currentCharacter);
266-
default:
267-
backingCard = new BackingCard(currentCharacter);
262+
backingCard = new NewCharacterCard(currentCharacterId);
263+
}
264+
else
265+
{
266+
var allScriptedCards:Array<String> = ScriptedBackingCard.listScriptClasses();
267+
for (cardClass in allScriptedCards)
268+
{
269+
var card:BackingCard = ScriptedBackingCard.init(cardClass, "unknown");
270+
if (card.currentCharacter == currentCharacterId)
271+
{
272+
backingCard = card;
273+
break;
274+
}
275+
}
276+
277+
// Return the default backing card if there isn't one specific for the character.
278+
if (backingCard == null) backingCard = new BackingCard(currentCharacterId);
268279
}
269280

270281
// We build a bunch of sprites BEFORE create() so we can guarantee they aren't null later on.
@@ -359,10 +370,10 @@ class FreeplayState extends MusicBeatSubState
359370

360371
if (backingCard != null)
361372
{
373+
backingCard.instance = this;
362374
add(backingCard);
363-
backingCard.init();
375+
ScriptEventDispatcher.callEvent(backingCard, new ScriptEvent(CREATE, false));
364376
backingCard.applyExitMovers(exitMovers, exitMoversCharSel);
365-
backingCard.instance = this;
366377
}
367378

368379
if (currentCharacter?.getFreeplayDJData() != null)
@@ -788,6 +799,12 @@ class FreeplayState extends MusicBeatSubState
788799
}
789800
}
790801

802+
override public function dispatchEvent(event:ScriptEvent)
803+
{
804+
super.dispatchEvent(event);
805+
if (backingCard != null) ScriptEventDispatcher.callEvent(backingCard, event);
806+
}
807+
791808
var currentFilter:Null<SongFilter> = null;
792809
var currentFilteredSongs:Array<Null<FreeplaySongData>> = [];
793810

source/funkin/ui/freeplay/backcards/BackingCard.hx

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ import funkin.graphics.FunkinSprite;
1111
import funkin.ui.freeplay.charselect.PlayableCharacter;
1212
import openfl.display.BlendMode;
1313
import flixel.group.FlxSpriteGroup;
14+
import funkin.modding.IScriptedClass.IBPMSyncedScriptedClass;
15+
import funkin.modding.IScriptedClass.IStateChangingScriptedClass;
16+
import funkin.modding.events.ScriptEvent;
1417
import funkin.ui.FullScreenScaleMode;
1518
import funkin.util.BitmapUtil;
1619
import openfl.utils.Assets;
1720

1821
/**
1922
* A class for the backing cards so they dont have to be part of freeplayState......
2023
*/
21-
class BackingCard extends FlxSpriteGroup
24+
class BackingCard extends FlxSpriteGroup implements IBPMSyncedScriptedClass implements IStateChangingScriptedClass
2225
{
2326
public var backingTextYeah:FlxAtlasSprite;
2427
public var orangeBackShit:FunkinSprite;
@@ -33,12 +36,13 @@ class BackingCard extends FlxSpriteGroup
3336
var _exitMoversCharSel:Null<FreeplayState.ExitMoverData>;
3437

3538
public var instance:FreeplayState;
39+
public var currentCharacter:String;
3640

37-
public function new(currentCharacter:PlayableCharacter, ?_instance:FreeplayState)
41+
public function new(currentCharacter:String)
3842
{
3943
super();
4044

41-
if (_instance != null) instance = _instance;
45+
this.currentCharacter = currentCharacter;
4246

4347
var bitmap = BitmapUtil.scalePartByWidth(Assets.getBitmapData(Paths.image('freeplay/cardGlow')), FreeplayState.CUTOUT_WIDTH);
4448
cardGlow = new FlxSprite(-30, -30).loadGraphic(bitmap);
@@ -128,43 +132,6 @@ class BackingCard extends FlxSpriteGroup
128132
pinkBack.x = 0;
129133
}
130134

131-
/**
132-
* Called in create. Adds sprites and tweens.
133-
*/
134-
public function init():Void
135-
{
136-
FlxTween.tween(pinkBack, {x: 0}, 0.6, {ease: FlxEase.quartOut});
137-
add(pinkBack);
138-
139-
add(orangeBackShit);
140-
141-
add(alsoOrangeLOL);
142-
143-
FlxSpriteUtil.alphaMaskFlxSprite(orangeBackShit, pinkBack, orangeBackShit);
144-
orangeBackShit.visible = false;
145-
alsoOrangeLOL.visible = false;
146-
147-
confirmTextGlow.blend = BlendMode.ADD;
148-
confirmTextGlow.visible = false;
149-
150-
confirmGlow.blend = BlendMode.ADD;
151-
152-
confirmGlow.visible = false;
153-
confirmGlow2.visible = false;
154-
155-
add(confirmGlow2);
156-
add(confirmGlow);
157-
158-
add(confirmTextGlow);
159-
160-
add(backingTextYeah);
161-
162-
cardGlow.blend = BlendMode.ADD;
163-
cardGlow.visible = false;
164-
165-
add(cardGlow);
166-
}
167-
168135
/**
169136
* Called after the dj finishes their start animation.
170137
*/
@@ -246,6 +213,69 @@ class BackingCard extends FlxSpriteGroup
246213
alsoOrangeLOL.visible = false;
247214
}
248215

216+
public function onScriptEvent(event:ScriptEvent):Void {}
217+
218+
/**
219+
* Called in create. Adds sprites and tweens.
220+
*/
221+
public function onCreate(event:ScriptEvent):Void
222+
{
223+
FlxTween.tween(pinkBack, {x: 0}, 0.6, {ease: FlxEase.quartOut});
224+
add(pinkBack);
225+
226+
add(orangeBackShit);
227+
228+
add(alsoOrangeLOL);
229+
230+
FlxSpriteUtil.alphaMaskFlxSprite(orangeBackShit, pinkBack, orangeBackShit);
231+
orangeBackShit.visible = false;
232+
alsoOrangeLOL.visible = false;
233+
234+
confirmTextGlow.blend = BlendMode.ADD;
235+
confirmTextGlow.visible = false;
236+
237+
confirmGlow.blend = BlendMode.ADD;
238+
239+
confirmGlow.visible = false;
240+
confirmGlow2.visible = false;
241+
242+
add(confirmGlow2);
243+
add(confirmGlow);
244+
245+
add(confirmTextGlow);
246+
247+
add(backingTextYeah);
248+
249+
cardGlow.blend = BlendMode.ADD;
250+
cardGlow.visible = false;
251+
252+
add(cardGlow);
253+
}
254+
255+
public function onDestroy(event:ScriptEvent):Void {}
256+
257+
public function onUpdate(event:UpdateScriptEvent):Void {}
258+
259+
public function onStepHit(event:SongTimeScriptEvent):Void {}
260+
261+
public function onBeatHit(event:SongTimeScriptEvent):Void {}
262+
263+
public function onStateChangeBegin(event:StateChangeScriptEvent):Void {}
264+
265+
public function onStateChangeEnd(event:StateChangeScriptEvent):Void {}
266+
267+
public function onSubStateOpenBegin(event:SubStateScriptEvent):Void {}
268+
269+
public function onSubStateOpenEnd(event:SubStateScriptEvent):Void {}
270+
271+
public function onSubStateCloseBegin(event:SubStateScriptEvent):Void {}
272+
273+
public function onSubStateCloseEnd(event:SubStateScriptEvent):Void {}
274+
275+
public function onFocusLost(event:FocusScriptEvent):Void {}
276+
277+
public function onFocusGained(event:FocusScriptEvent):Void {}
278+
249279
public function centerObjectOnCard(object:flixel.FlxObject)
250280
{
251281
if (pinkBack != null) object.x = (x + ((pinkBack.width - object.width) / 2)) * 0.74;

0 commit comments

Comments
 (0)