Skip to content

Commit

Permalink
Added missing substates to freeplay
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolka9144 committed Jan 11, 2025
1 parent a5d0e3a commit 8557e76
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 61 deletions.
7 changes: 5 additions & 2 deletions source/mikolka/compatibility/FreeplaySongData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ using mikolka.funkin.utils.ArrayTools;
// this.songName = songDifficulty.songName;
// this.difficultyRating = songDifficulty.difficultyRating;
this.scoringRank = Scoring.calculateRankForSong(Highscore.formatSong(songId, loadAndGetDiffId()));

var wasCompleted = false;
updateIsNewTag();

}
public function updateIsNewTag() {
var wasCompleted = false;
var saveSongName = Paths.formatToSongPath(songId);
for (x in Highscore.songScores.keys()){
if(x.startsWith(saveSongName) && Highscore.songScores[x] > 0){
Expand Down
148 changes: 92 additions & 56 deletions source/mikolka/vslice/freeplay/FreeplayState.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mikolka.vslice.freeplay;

import substates.ResetScoreSubState;
import options.GameplayChangersSubstate;
import mikolka.vslice.freeplay.obj.CapsuleOptionsMenu;
import mikolka.compatibility.FunkinControls;
import mikolka.vslice.charSelect.CharSelectSubState;
Expand Down Expand Up @@ -240,7 +242,8 @@ class FreeplayState extends MusicBeatSubstate
currentCharacter = result;

styleData = FreeplayStyleRegistry.instance.fetchEntry(currentCharacter.getFreeplayStyleID());
if (styleData == null) styleData = FreeplayStyleRegistry.instance.fetchEntry("bf");
if (styleData == null)
styleData = FreeplayStyleRegistry.instance.fetchEntry("bf");

fromCharSelect = params?.fromCharSelect;

Expand All @@ -257,10 +260,6 @@ class FreeplayState extends MusicBeatSubstate
{
stickerSubState = stickers;
}




}

var fadeShader:BlueFade = new BlueFade();
Expand All @@ -269,26 +268,28 @@ class FreeplayState extends MusicBeatSubstate

override function create():Void
{
//? Psych might've reloaded the mod list. Make sure we select current character's mod for the style
// ? Psych might've reloaded the mod list. Make sure we select current character's mod for the style
var saveBox = VsliceOptions.LAST_MOD;
if (ModsHelper.isModDirEnabled(saveBox.mod_dir))
ModsHelper.loadModDir(saveBox.mod_dir);
// We build a bunch of sprites BEFORE create() so we can guarantee they aren't null later on.
//? but doing it here, because psych 0.6.3 can destroy graphics created in the constructor
if(VsliceOptions.FP_CARDS){
switch (currentCharacterId)
// ? but doing it here, because psych 0.6.3 can destroy graphics created in the constructor
if (VsliceOptions.FP_CARDS)
{
case(PlayerRegistry.instance.hasNewCharacter()) => true:
backingCard = new NewCharacterCard(currentCharacter);
case 'bf':
backingCard = new BoyfriendCard(currentCharacter);
case 'pico':
backingCard = new PicoCard(currentCharacter);
default:
backingCard = new BoyfriendCard(currentCharacter);//new BackingCard(currentCharacter);
}
switch (currentCharacterId)
{
case(PlayerRegistry.instance.hasNewCharacter()) => true:
backingCard = new NewCharacterCard(currentCharacter);
case 'bf':
backingCard = new BoyfriendCard(currentCharacter);
case 'pico':
backingCard = new PicoCard(currentCharacter);
default:
backingCard = new BoyfriendCard(currentCharacter); // new BackingCard(currentCharacter);
}
}
else backingCard = new BoyfriendCard(currentCharacter);
else
backingCard = new BoyfriendCard(currentCharacter);

albumRoll = new AlbumRoll();
fp = new FreeplayScore(460, 60, 7, 100, styleData);
Expand All @@ -310,7 +311,7 @@ class FreeplayState extends MusicBeatSubstate
bgDad = new FlxSprite(backingCard.pinkBack.width * 0.74, 0).loadGraphic(styleData == null ? 'freeplay/freeplayBGdad' : styleData.getBgAssetGraphic());

BPMCache.instance.clearCache(); // for good measure
//? end of init
// ? end of init

super.create();
var diffIdsTotalModBinds:Map<String, String> = ["easy" => "", "normal" => "", "hard" => ""];
Expand All @@ -320,7 +321,7 @@ class FreeplayState extends MusicBeatSubstate
FlxTransitionableState.skipNextTransIn = true;

var fadeShaderFilter:ShaderFilter = new ShaderFilter(fadeShader);
ModsHelper.setFiltersOnCam(funnyCam,[fadeShaderFilter]);
ModsHelper.setFiltersOnCam(funnyCam, [fadeShaderFilter]);

if (stickerSubState != null)
{
Expand Down Expand Up @@ -351,11 +352,15 @@ class FreeplayState extends MusicBeatSubstate
PlayState.isStoryMode = false;
for (sngCard in FreeplayHelpers.loadSongs())
{
if(currentCharacter.shouldShowUnownedChars()){
if(sngCard.songPlayer != '' && sngCard.songPlayer != currentCharacterId) continue;
if (currentCharacter.shouldShowUnownedChars())
{
if (sngCard.songPlayer != '' && sngCard.songPlayer != currentCharacterId)
continue;
}
else{
if(sngCard.songPlayer == '' || sngCard.songPlayer != currentCharacterId) continue;
else
{
if (sngCard.songPlayer == '' || sngCard.songPlayer != currentCharacterId)
continue;
}
songs.push(sngCard);
for (difficulty in sngCard.songDifficulties)
Expand Down Expand Up @@ -387,7 +392,7 @@ class FreeplayState extends MusicBeatSubstate

if (currentCharacter?.getFreeplayDJData() != null)
{
ModsHelper.loadModDir(VsliceOptions.LAST_MOD.mod_dir); //? make sure to load a mod dir of this character!
ModsHelper.loadModDir(VsliceOptions.LAST_MOD.mod_dir); // ? make sure to load a mod dir of this character!
dj = new FreeplayDJ(640, 366, currentCharacter);
exitMovers.set([dj], {
x: -dj.width * 1.6,
Expand Down Expand Up @@ -472,7 +477,7 @@ class FreeplayState extends MusicBeatSubstate
diffSprite.difficultyId = diffId;
grpDifficulties.add(diffSprite);
}
ModsHelper.loadModDir(VsliceOptions.LAST_MOD.mod_dir); //? load stuff for this Char's mod
ModsHelper.loadModDir(VsliceOptions.LAST_MOD.mod_dir); // ? load stuff for this Char's mod

grpDifficulties.group.forEach(function(spr)
{
Expand All @@ -497,15 +502,15 @@ class FreeplayState extends MusicBeatSubstate
// ? changed offsets
if (fromCharSelect == true)
{
blackOverlayBullshitLOLXD.x = black_X+220;
blackOverlayBullshitLOLXD.x = black_X + 220;
overhangStuff.y = -100;
backingCard?.skipIntroTween();
}
else
{
albumRoll.applyExitMovers(exitMovers, exitMoversCharSel);
FlxTween.tween(overhangStuff, {y: -100}, 0.3, {ease: FlxEase.quartOut});
var target = black_X-30;
var target = black_X - 30;
FlxTween.tween(blackOverlayBullshitLOLXD, {x: target}, 0.7, {ease: FlxEase.quintOut});
}

Expand Down Expand Up @@ -642,13 +647,14 @@ class FreeplayState extends MusicBeatSubstate

// when boyfriend hits dat shiii

if (curCapsule != null) //? prevent "random" song from stealing our albums!
if (curCapsule != null) // ? prevent "random" song from stealing our albums!
{
albumRoll.playIntro();
var daSong = grpCapsules.members[curSelected].songData;
albumRoll.albumId = daSong?.albumId;
}
else albumRoll.albumId = '';
else
albumRoll.albumId = '';

if (fromCharSelect == null)
{
Expand Down Expand Up @@ -1510,9 +1516,36 @@ class FreeplayState extends MusicBeatSubstate
}
#end // ^<-- FEATURE_DEBUG_FUNCTIONS

if ((FunkinControls.FREEPLAY_CHAR || (TouchUtil.overlapsComplex(djTouchHitbox) && TouchUtil.justReleased && !SwipeUtil.swipeAny)) && !busy)
if (!busy)
{
tryOpenCharSelect();
if ((FunkinControls.FREEPLAY_CHAR
|| (TouchUtil.overlapsComplex(djTouchHitbox) && TouchUtil.justReleased && !SwipeUtil.swipeAny)))
{
tryOpenCharSelect();
}
else if (FlxG.keys.justPressed.CONTROL #if TOUCH_CONTROLS_ALLOWED || touchPad.buttonX.justPressed #end)
{
persistentUpdate = false;
openSubState(new GameplayChangersSubstate());
#if TOUCH_CONTROLS_ALLOWED
removeTouchPad();
#end
}
else if (controls.RESET && curSelected != 0)
{
persistentUpdate = false;
openSubState(new ResetScoreSubState(songs[curSelected].songName, songs[curSelected].loadAndGetDiffId(), songs[curSelected].songCharacter,-1,() -> {
songs[curSelected].scoringRank = null;
songs[curSelected].updateIsNewTag();
grpCapsules.members[curSelected].refreshDisplay();
intendedScore = 0;
intendedCompletion = 0;
}));
#if TOUCH_CONTROLS_ALLOWED
removeTouchPad();
#end
FunkinSound.playOnce(Paths.sound('scrollMenu'), 0.4);
}
}

if (controls.FAVORITE && !busy) // ? change control binding
Expand Down Expand Up @@ -1693,7 +1726,8 @@ class FreeplayState extends MusicBeatSubstate
changeDiff(-1);
rememberedDifficulty = currentDifficulty; // ? make sure to remember it, because otherwise we'll forget about it
generateSongList(currentFilter, true);
if (diffSelLeft != null) diffSelLeft.setPress(true);
if (diffSelLeft != null)
diffSelLeft.setPress(true);
}
if (controls.UI_RIGHT_P || (TouchUtil.overlapsComplex(diffSelRight) && TouchUtil.justPressed))
{
Expand All @@ -1702,7 +1736,8 @@ class FreeplayState extends MusicBeatSubstate
changeDiff(1);
rememberedDifficulty = currentDifficulty; // ? make sure to remember it, because otherwise we'll forget about it
generateSongList(currentFilter, true);
if (diffSelLeft != null) diffSelRight.setPress(true);
if (diffSelLeft != null)
diffSelRight.setPress(true);
}

if (diffSelLeft != null && diffSelRight != null && TouchUtil.justReleased)
Expand Down Expand Up @@ -1996,17 +2031,16 @@ class FreeplayState extends MusicBeatSubstate
{
// We don't have a good way to do this in psych
// ? yet instVariants



if (cap.songData.instVariants.length > 0 && cap.songData.instVariants[0] != "")
{
var instrumentalIds = ["default"].concat(cap.songData.instVariants);
openInstrumentalList(cap, instrumentalIds);
var instrumentalIds = ["default"].concat(cap.songData.instVariants);
openInstrumentalList(cap, instrumentalIds);
}
else
{
trace('NO ALTS');
capsuleOnConfirmDefault(cap);
trace('NO ALTS');
capsuleOnConfirmDefault(cap);
}
}

Expand All @@ -2016,31 +2050,33 @@ class FreeplayState extends MusicBeatSubstate
}

function openInstrumentalList(cap:SongMenuItem, instrumentalIds:Array<String>):Void
{
busy = true;

capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.x + 175, cap.y + 115, instrumentalIds);
capsuleOptionsMenu.cameras = [funnyCam];
capsuleOptionsMenu.zIndex = 10000;
add(capsuleOptionsMenu);

capsuleOptionsMenu.onConfirm = function(targetInstId:String)
{
busy = true;

capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.x + 175, cap.y + 115, instrumentalIds);
capsuleOptionsMenu.cameras = [funnyCam];
capsuleOptionsMenu.zIndex = 10000;
add(capsuleOptionsMenu);

capsuleOptionsMenu.onConfirm = function(targetInstId:String) {
capsuleOnConfirmDefault(cap, targetInstId);
};
}
};
}

var capsuleOptionsMenu:Null<CapsuleOptionsMenu> = null;

public function cleanupCapsuleOptionsMenu():Void
{
this.busy = false;

if (capsuleOptionsMenu != null)
{
remove(capsuleOptionsMenu);
capsuleOptionsMenu = null;
remove(capsuleOptionsMenu);
capsuleOptionsMenu = null;
}
}

/**
* Called when hitting ENTER to play the song.
*/
Expand Down Expand Up @@ -2089,7 +2125,7 @@ class FreeplayState extends MusicBeatSubstate

new FlxTimer().start(styleData?.getStartDelay(), function(tmr:FlxTimer)
{
FreeplayHelpers.moveToPlaystate(this, cap.songData, currentDifficulty,targetInstId);
FreeplayHelpers.moveToPlaystate(this, cap.songData, currentDifficulty, targetInstId);
});
}

Expand Down Expand Up @@ -2371,4 +2407,4 @@ typedef MoveData =
var ?y:Float;
var ?speed:Float;
var ?wait:Float;
}
}
9 changes: 8 additions & 1 deletion source/options/GameplayChangersSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class GameplayChangersSubstate extends MusicBeatSubstate
private var optionsArray:Array<Dynamic> = [];

private var grpOptions:FlxTypedGroup<Alphabet>;
private var optionsCam:FlxCamera = new FlxCamera();
private var checkboxGroup:FlxTypedGroup<CheckboxThingie>;
private var grpTexts:FlxTypedGroup<AttachedText>;

Expand Down Expand Up @@ -85,21 +86,26 @@ class GameplayChangersSubstate extends MusicBeatSubstate
public function new()
{
controls.isInSubstate = true;

super();
FlxG.cameras.add(optionsCam,false);
optionsCam.bgColor = FlxColor.TRANSPARENT;

var bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
bg.alpha = 0.6;
bg.camera = optionsCam;
add(bg);

// avoids lagspikes while scrolling through menus!
grpOptions = new FlxTypedGroup<Alphabet>();
grpOptions.camera = optionsCam;
add(grpOptions);

grpTexts = new FlxTypedGroup<AttachedText>();
grpTexts.camera = optionsCam;
add(grpTexts);

checkboxGroup = new FlxTypedGroup<CheckboxThingie>();
checkboxGroup.camera = optionsCam;
add(checkboxGroup);

getOptions();
Expand Down Expand Up @@ -160,6 +166,7 @@ class GameplayChangersSubstate extends MusicBeatSubstate
close();
ClientPrefs.saveSettings();
controls.isInSubstate = false;
FlxG.cameras.remove(optionsCam);
FlxG.sound.play(Paths.sound('cancelMenu'));
}

Expand Down
Loading

0 comments on commit 8557e76

Please sign in to comment.