Skip to content

Commit

Permalink
should i do a different credits menu or
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesisfeline committed Oct 5, 2024
1 parent 5fe4620 commit 878b94e
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 24 deletions.
12 changes: 12 additions & 0 deletions source/funkin/graphics/FunkinSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ class FunkinSprite extends FlxSprite
return true;
}

/**
* @param id The animation ID to check.
* @return Whether the animation is dynamic (has multiple frames). `false` for static, one-frame animations.
*/
public function isAnimationDynamic(id:String):Bool
{
if (this.animation == null) return false;
var animData = this.animation.getByName(id);
if (animData == null) return false;
return animData.numFrames > 1;
}

/**
* Acts similarly to `makeGraphic`, but with improved memory usage,
* at the expense of not being able to paint onto the resulting sprite.
Expand Down
14 changes: 10 additions & 4 deletions source/funkin/play/notes/StrumlineNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class StrumlineNote extends FlxSprite
return this.direction;
}

/**
* Set this flag to `true` to disable performance optimizations that cause
* the Strumline note sprite to ignore `velocity` and `acceleration`.
*/
public var forceActive:Bool = false;

public function new(noteStyle:NoteStyle, isPlayer:Bool, direction:NoteDirection)
{
super(0, 0);
Expand Down Expand Up @@ -105,27 +111,27 @@ class StrumlineNote extends FlxSprite

public function playStatic():Void
{
this.active = true;
this.active = (forceActive || isAnimationDynamic('static'));
this.playAnimation('static', true);
}

public function playPress():Void
{
this.active = true;
this.active = (forceActive || isAnimationDynamic('static'));
this.playAnimation('press', true);
}

public function playConfirm():Void
{
this.active = true;
this.active = (forceActive || isAnimationDynamic('static'));
this.playAnimation('confirm', true);
}

public function playConfirmHold():Void
{
if (getCurrentAnimationFrame() >= 3)
{
this.active = true;
this.active = (forceActive || isAnimationDynamic('static'));
this.playAnimation('confirm', true);
}
}
Expand Down
5 changes: 3 additions & 2 deletions source/funkin/ui/credits/CreditsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ class CreditsState extends MusicBeatState
startingVolume: 0.0,
overrideExisting: true,
restartTrack: true,
loop: true
loop: true,
persist: true
});
FlxG.sound.music.fadeIn(6, 0, 0.8);

Expand Down Expand Up @@ -274,7 +275,7 @@ class CreditsState extends MusicBeatState

public function exit():Void
{
FlxG.switchState(() -> new MainMenuState());
FlxG.switchState(() -> new MainCreditsState());
}

public override function destroy():Void
Expand Down
132 changes: 132 additions & 0 deletions source/funkin/ui/credits/MainCreditsState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package funkin.ui.credits;

import flixel.FlxSprite;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import flixel.tweens.FlxTween;
import flixel.group.FlxGroup.FlxTypedGroup;
import funkin.audio.FunkinSound;
import funkin.ui.credits.tweaked.TweakedCredits;
import funkin.ui.mainmenu.MainMenuState;

/**
* A state for handling which credits menu you wanna go to.
*/
class MainCreditsState extends MusicBeatState
{
var optionShit:Array<String> = ['Credits Roll'];
var formattedOptions:Array<String> = ['funkin'];

var bg:FlxSprite;
var grpOptions:FlxTypedGroup<FlxText>;

var curSelected:Int = 0;

var unfinished:FlxText;
var unfinishedBG:FlxSprite;

public function new()
{
super();
}

override function create():Void
{
super.create();

FunkinSound.playMusic('freeplayRandom',
{
startingVolume: 0.0,
overrideExisting: true,
restartTrack: true,
loop: true,
persist: true
});
FlxG.sound.music.fadeIn(6, 0, 0.8);

bg = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
add(bg);

grpOptions = new FlxTypedGroup<FlxText>();
add(grpOptions);

var pos:Int = 0;
for (option in optionShit)
{
pos++;
var pos2:Int = 0;
if (pos == 2) pos2 = 1;

var text:FlxText = new FlxText(50, 150 * pos2, FlxG.width - 50, option, 30);
text.setFormat(Paths.font('arial.ttf'), 50, 0xFFFF0000, CENTER, OUTLINE, 0xFF000000);
grpOptions.add(text);
}

changeSelection();

unfinished = new FlxText(0, 0, 0, "(BTW THIS MENU IS A WIP!!)", 30);
unfinished.setFormat(Paths.font('vcr.ttf'), 50, 0xFFFFFFFF, CENTER, OUTLINE, 0xFF000000);
unfinished.alpha = 0;
unfinishedBG = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
unfinishedBG.alpha = 0;

add(unfinishedBG);
add(unfinished);

#if mobile
addBackButton(FlxG.width * 0.77, FlxG.height * 0.85, FlxColor.WHITE, () -> {
FunkinSound.playOnce(Paths.sound('cancelMenu'));
FlxG.switchState(() -> new MainMenuState());
});
#end
}

var textTween:FlxTween;
var bgTween:FlxTween;

override function update(elapsed:Float):Void
{
final upP:Bool = (controls.UI_UP_P #if mobile || SwipeUtil.swipeUp #end);
final downP:Bool = (controls.UI_DOWN_P #if mobile || SwipeUtil.swipeDown #end);

if (controls.UI_LEFT_P || upP) changeSelection(-1);
if (controls.UI_RIGHT_P || downP) changeSelection(1);

if (controls.ACCEPT #if mobile || TouchUtil.pressed && !TouchUtil.overlaps(backButton) #end)
{
switch (formattedOptions[curSelected])
{
case 'funkin':
FlxG.switchState(() -> new CreditsState());
}
}

if (controls.BACK)
{
FunkinSound.playOnce(Paths.sound('cancelMenu'));
FlxG.switchState(() -> new MainMenuState());
}
}

function changeSelection(change:Int = 0):Void
{
curSelected += change;

if (curSelected >= optionShit.length) curSelected = 0;
if (curSelected < 0) curSelected = optionShit.length - 1;

FunkinSound.playOnce(Paths.sound('scrollMenu'));

for (i in 0...optionShit.length)
{
if (i == curSelected) grpOptions.members[i].color = 0xFFDE4B;
else
grpOptions.members[i].color = 0xFFFFFF;
}
}

public override function destroy():Void
{
super.destroy();
}
}
4 changes: 3 additions & 1 deletion source/funkin/ui/freeplay/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,8 @@ class FreeplayState extends MusicBeatSubState

function changeDiff(change:Int = 0, force:Bool = false):Void
{
var previousVariation:String = currentVariation;

var currentDifficultyIndex:Int = suffixedDiffIdsCurrent.indexOf(currentSuffixedDifficulty);

if (currentDifficultyIndex == -1) currentDifficultyIndex = suffixedDiffIdsCurrent.indexOf(Constants.DEFAULT_DIFFICULTY);
Expand Down Expand Up @@ -1839,7 +1841,7 @@ class FreeplayState extends MusicBeatSubState
songCapsule.init(null, null, null);
}
// Reset the song preview in case we changed variations (normal->erect etc)
playCurSongPreview();
if (currentVariation != previousVariation) playCurSongPreview();
}
// Set the album graphic and play the animation if relevant.
var newAlbumId:Null<String> = daSong?.albumId;
Expand Down
13 changes: 4 additions & 9 deletions source/funkin/ui/mainmenu/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ class MainMenuState extends MusicBeatState
menuItems = new MenuTypedList<AtlasMenuItem>();
add(menuItems);
menuItems.onChange.add(onMenuItemChange);
menuItems.onAcceptPress.add(function(_) {
FlxFlicker.flicker(magenta, 1.1, 0.15, false, true);
});
menuItems.onAcceptPress.add((_) -> FlxFlicker.flicker(magenta, 1.1, 0.15, false, true));

menuItems.enabled = true; // can move on intro
createMenuItem('storymode', 'mainmenu/storymode', () -> openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new StoryMenuState())));
Expand Down Expand Up @@ -137,13 +135,10 @@ class MainMenuState extends MusicBeatState
createMenuItem('merch', 'mainmenu/merch', selectMerch, hasPopupBlocker);
#end

createMenuItem('credits', 'mainmenu/credits', () -> {
startExitState(() -> new funkin.ui.credits.CreditsState());
});
createMenuItem('credits', 'mainmenu/credits', () -> startExitState(() -> new funkin.ui.credits.MainCreditsState()));

createMenuItem('options', 'mainmenu/options', () -> {
openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.options.OptionsState()));
});
createMenuItem('options', 'mainmenu/options',
() -> openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new funkin.ui.options.OptionsState())));

// Reset position of menu items.
var spacing = 160;
Expand Down
10 changes: 2 additions & 8 deletions source/funkin/ui/story/StoryMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,8 @@ class StoryMenuState extends MusicBeatState

function rememberSelection():Void
{
if (rememberedLevelId != null)
{
currentLevelId = rememberedLevelId;
}
if (rememberedDifficulty != null)
{
currentDifficultyId = rememberedDifficulty;
}
if (rememberedLevelId != null) currentLevelId = rememberedLevelId;
if (rememberedDifficulty != null) currentDifficultyId = rememberedDifficulty;
}

function playMenuMusic():Void
Expand Down

0 comments on commit 878b94e

Please sign in to comment.