Skip to content

Commit

Permalink
Trying to fix HoldCovers Part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
glowsoony committed Aug 31, 2024
1 parent 896bc20 commit 78877f5
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://lime.openfl.org/project/1.0.4 http://lime.openfl.org/xsd/project-1.0.4.xsd">
<!-- _________________________ Application Settings _________________________ -->

<app title="Friday Night Funkin': Sick Coders Engine" file="SCE" packageName="com.SCTeam.SCEE" package="com.SCTeam.SCE" main="Main" version="1.5.25" company="SCTeam" />
<app title="Friday Night Funkin': Sick Coders Engine" file="SCE" packageName="com.SCTeam.SCEE" package="com.SCTeam.SCE" main="Main" version="1.5.2" company="SCTeam" />

<!--Switch Export with Unique ApplicationID and Icon-->
<set name="APP_ID" value="0x0100f6c013bbc000" />
Expand Down
15 changes: 13 additions & 2 deletions funkinscsource/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ import states.TitleState;

public var coloredText:Bool = false;

public var noteSplashes:Bool = true;
public var noteSplashesOP:Bool = true;
public var splashOption:String = 'Both';

public var characters:Bool = true;
public var background:Bool = true;
Expand Down Expand Up @@ -400,4 +399,16 @@ class ClientPrefs
}
return keys[0] == '---' ? keys[1] : keys[1] == '---' ? keys[0] : keys[0] + separator + keys[1];
}

public static function splashOption(type:String):Bool
{
switch (type)
{
case 'Player':
return (data.splashOption == 'Player' || data.splashOption == 'Both') ? true : false;
default:
return (data.splashOption == 'Opponent' || data.splashOption == 'Both') ? true : false;
}
return false;
}
}
60 changes: 41 additions & 19 deletions funkinscsource/objects/note/HoldCoverGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HoldCoverGroup extends FlxTypedSpriteGroup<HoldCoverSprite>

public dynamic function addHolds(i:Int)
{
var colors:Array<String> = ["Purple", "Blue", "Green", "Red"];
var colors:Array<String> = ["Purple", "Blue", "Green", "Red", "Purple", "Blue", "Green", "Red"];
var hcolor:String = colors[i];
var hold:HoldCoverSprite = new HoldCoverSprite();
hold.initFrames(i, hcolor);
Expand All @@ -28,56 +28,78 @@ class HoldCoverGroup extends FlxTypedSpriteGroup<HoldCoverSprite>
hold.activatedSprite = enabled;
hold.spriteId = '$hcolor-$i';
hold.spriteIntID = i;
this.add(hold);
add(hold);
}

public dynamic function spawnOnNoteHit(note:Note):Void
{
var noteData:Int = note.noteData;
var noteData:Int = note.noteData % 4;
var isSus:Bool = note.isSustainNote;
var isHoldEnd:Bool = note.isHoldEnd;
if (enabled && isReady)
{
if (isSus)
{
this.members[noteData].affectSplash(HOLDING, noteData, note);
members[noteData].affectSplash('Holding', noteData, note);
if (isHoldEnd)
{
if (isPlayer) this.members[noteData].affectSplash(SPLASHING, noteData);
if (isPlayer) members[noteData].affectSplash('Splashing', noteData);
else
this.members[noteData].affectSplash(DONE, noteData);
members[noteData].affectSplash('Done', noteData);
}
}
}
}

public dynamic function despawnOnMiss(direction:Int, ?note:Note = null):Void
{
var noteData:Int = (note != null ? note.noteData : direction);
if (enabled && isReady) this.members[noteData].affectSplash(STOP, noteData, note);
}

public function setParentStrums(strumLine:Strumline)
{
for (i in 0...maxSize)
this.members[i].parentStrum = strumLine.members[i];
var noteData:Int = (note != null ? note.noteData % 4 : direction % 4);
if (enabled && isReady) members[noteData].affectSplash('Stop', noteData, note);
}

public dynamic function updateHold(elapsed:Float):Void
{
if (enabled && isReady)
{
for (i in 0...this.members.length - 1)
for (i in 0...members.length)
{
if (this.members[i].boom)
if (members[i].x != pos(i, "x") - 110)
{
members[i].x = pos(i, "x") - 110;
}
if (members[i].y != pos(i, "y") - 100)
{
if (this.members[i].isAnimationFinished())
members[i].y = pos(i, "y") - 100;
}

if (members[i].boom)
{
if (members[i].isAnimationFinished())
{
this.members[i].visible = false;
this.members[i].boom = false;
members[i].visible = false;
members[i].boom = false;
}
}
}
}
}

public dynamic function pos(note:Int, variable:String):Float
{
if (enabled && isReady)
{
if (PlayState.instance != null)
{
var game:PlayState = PlayState.instance;
if (game.strumLineNotes != null)
{
if (variable == "x") return game.strumLineNotes.members[isPlayer ? note + 4 : note].x;
else if (variable == "y") return game.strumLineNotes.members[isPlayer ? note + 4 : note].y;
}
return 0;
}
return 0;
}
return 0;
}
}
21 changes: 5 additions & 16 deletions funkinscsource/objects/note/HoldCoverSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ typedef HoldCoverData =

enum abstract HoldCoverStep(String) to String from String
{
var STOP = 'STOP';
var DONE = 'DONE';
var HOLDING = 'HOLDING';
var SPLASHING = 'SPLAHING';
var STOP = 'Stop';
var DONE = 'Done';
var HOLDING = 'Holding';
var SPLASHING = 'Splashing';
}

class HoldCoverSprite extends FunkinSCSprite
Expand All @@ -49,7 +49,6 @@ class HoldCoverSprite extends FunkinSCSprite
}
public var offsetX:Float = 0;
public var offsetY:Float = 0;
public var parentStrum:StrumArrow = null;

public dynamic function initShader(noteData:Int)
{
Expand Down Expand Up @@ -134,10 +133,9 @@ class HoldCoverSprite extends FunkinSCSprite
rgbShader.copyValues(tempShader);
}

public dynamic function affectSplash(splashStep:HoldCoverStep = HOLDING, ?noteData:Int = -1, ?note:Note = null)
public dynamic function affectSplash(splashStep:HoldCoverStep, ?noteData:Int = -1, ?note:Note = null)
{
if (noteData == -1 && note == null) return;

switch (splashStep)
{
// Stop
Expand All @@ -160,13 +158,4 @@ class HoldCoverSprite extends FunkinSCSprite
playAnim(Std.string(noteData) + 'p');
}
}

override public function update(elapsed:Float):Void
{
if (parentStrum != null)
{
setPosition(parentStrum.x - 110 + offsetX, parentStrum.y - 100 + offsetY);
}
super.update(elapsed);
}
}
6 changes: 2 additions & 4 deletions funkinscsource/options/VisualsSettingsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ class VisualsSettingsSubState extends BaseOptionsMenu
'Mainly all text in playstate will change color on character change and will start with dad\'s character color.', 'coloredText', BOOL);
addOption(option);

var option:Option = new Option('Note Splashes', "If checked, on rating swag or sick will give a splash effect.", 'noteSplashes', BOOL);
addOption(option);

var option:Option = new Option('Note Splashes Opponent', "If checked, on a note being hit it will give a splash effect.", 'noteSplashesOP', BOOL);
var option:Option = new Option('Note Splashes Option', "Different options on how the splashes show.", 'splashOption', STRING,
['Player', 'Opponent', 'Both']);
addOption(option);

var option:Option = new Option('Hold Cover Animation And Splash', "If checked, A Splash and Hold Note animation wil show.", 'holdCoverPlay', BOOL);
Expand Down
2 changes: 1 addition & 1 deletion funkinscsource/states/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum MainMenuColumn
class MainMenuState extends MusicBeatState
{
public static final psychEngineVersion:String = '1.0-prerelease'; // This is also used for Discord RPC
public static var SCEVersion:String = '1.5.25'; // This is also used for Discord RPC
public static var SCEVersion:String = '1.5.2'; // This is also used for Discord RPC
public static var curSelected:Int = 0;
public static var curColumn:MainMenuColumn = CENTER;

Expand Down
50 changes: 37 additions & 13 deletions funkinscsource/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,8 @@ class PlayState extends MusicBeatState
var enabledHolds:Bool = ((!SONG.options.disableHoldCovers && !SONG.options.notITG) && ClientPrefs.data.holdCoverPlay);
opponentHoldCovers = new HoldCoverGroup(enabledHolds, false);
opponentHoldCovers.isReady = (strumLineNotes != null && strumLineNotes.members.length > 0 && !startingSong && !inCutscene && !inCinematic && generatedMusic);
opponentHoldCovers.setParentStrums(opponentStrums);
playerHoldCovers = new HoldCoverGroup(enabledHolds, true);
playerHoldCovers.isReady = (strumLineNotes != null && strumLineNotes.members.length > 0 && !startingSong && !inCutscene && !inCinematic && generatedMusic);
playerHoldCovers.setParentStrums(playerStrums);

if (isStoryMode)
{
Expand Down Expand Up @@ -1931,8 +1929,6 @@ class PlayState extends MusicBeatState
public var stageIntroSoundsSuffix:String = '';
public var stageIntroSoundsPrefix:String = '';

public var daChar:Character = null;

function cacheCountdown()
{
stageIntroSoundsSuffix = stage.stageIntroSoundsSuffix != null ? stage.stageIntroSoundsSuffix : '';
Expand Down Expand Up @@ -3061,6 +3057,7 @@ class PlayState extends MusicBeatState

if (paused)
{
canResync = true;
FlxG.timeScale = playbackRate;
#if (VIDEOS_ALLOWED && hxvlc)
if (daVideoGroup != null)
Expand Down Expand Up @@ -3276,6 +3273,32 @@ class PlayState extends MusicBeatState
return;
}

if (paused)
{
callOnScripts('onUpdate', [elapsed]);
callOnScripts('update', [elapsed]);

super.update(elapsed);

callOnScripts('onUpdatePost', [elapsed]);
callOnScripts('updatePost', [elapsed]);
return;
}

for (holdCovers in [opponentHoldCovers, playerHoldCovers])
{
if (holdCovers != null)
{
if (!holdCovers.isReady) if (strumLineNotes != null && strumLineNotes.members.length > 0 && !startingSong && !inCutscene && !inCinematic
&& generatedMusic) holdCovers.isReady = true;
else if (holdCovers.isReady) if (((strumLineNotes == null && strumLineNotes.members.length <= 0)
|| startingSong
|| inCutscene
|| inCinematic)
&& !generatedMusic) holdCovers.isReady = false;
}
}

totalElapsed += elapsed;

#if SCEModchartingTools
Expand All @@ -3293,7 +3316,7 @@ class PlayState extends MusicBeatState
{
if (value.startsWith('extraCharacter_'))
{
daChar = cast(MusicBeatState.getVariables().get(value), Character);
var daChar:Character = cast(MusicBeatState.getVariables().get(value), Character);
if (daChar != null)
{
if ((daChar.isPlayer && !daChar.flipMode || !daChar.isPlayer && daChar.flipMode))
Expand Down Expand Up @@ -5362,7 +5385,8 @@ class PlayState extends MusicBeatState
score = daRating.scoreBonus;
daRating.count++;

note.canSplash = ((!note.noteSplashData.disabled && ClientPrefs.data.noteSplashes && daRating.doNoteSplash) && !SONG.options.notITG);
note.canSplash = ((!note.noteSplashData.disabled && ClientPrefs.splashOption('Player') && daRating.doNoteSplash)
&& !SONG.options.notITG);
if (note.canSplash) spawnNoteSplashOnNote(note);

if (playbackRate >= 1.05) score = getRatesScore(playbackRate, score);
Expand Down Expand Up @@ -5566,7 +5590,7 @@ class PlayState extends MusicBeatState
var placement:Float = FlxG.width * 0.38;
var rating:FlxSprite = new FlxSprite();

note.canSplash = ((!note.noteSplashData.disabled && ClientPrefs.data.noteSplashesOP) && !SONG.options.notITG);
note.canSplash = ((!note.noteSplashData.disabled && ClientPrefs.splashOption('Opponent')) && !SONG.options.notITG);
if (note.canSplash) spawnNoteSplashOnNote(note);

if (!showRating && !showComboNum && !showComboNum) return;
Expand Down Expand Up @@ -5960,8 +5984,7 @@ class PlayState extends MusicBeatState
{
if (value.startsWith('extraCharacter_'))
{
daChar = cast(MusicBeatState.getVariables().get(value), Character);

var daChar:Character = cast(MusicBeatState.getVariables().get(value), Character);
if (daChar != null)
{
var daCharConditions:Bool = daChar.allowHoldTimer();
Expand Down Expand Up @@ -6197,7 +6220,7 @@ class PlayState extends MusicBeatState
else
char = opponentMode ? boyfriend : dad;

note.canSplash = ((!note.noteSplashData.disabled && !note.isSustainNote && ClientPrefs.data.noteSplashesOP && !popupScoreForOp)
note.canSplash = ((!note.noteSplashData.disabled && !note.isSustainNote && ClientPrefs.splashOption('Opponent') && !popupScoreForOp)
&& !SONG.options.notITG);
if (note.canSplash) spawnNoteSplashOnNote(note);

Expand Down Expand Up @@ -6582,7 +6605,8 @@ class PlayState extends MusicBeatState
}
}
noteMiss(note);
note.canSplash = ((!note.noteSplashData.disabled && !note.isSustainNote && ClientPrefs.data.noteSplashes) && !SONG.options.notITG);
note.canSplash = ((!note.noteSplashData.disabled && !note.isSustainNote && ClientPrefs.splashOption('Player'))
&& !SONG.options.notITG);
if (note.canSplash) spawnNoteSplashOnNote(note);
}

Expand Down Expand Up @@ -6887,7 +6911,7 @@ class PlayState extends MusicBeatState
{
if (characterValue.startsWith('extraCharacter_'))
{
daChar = cast(MusicBeatState.getVariables().get(characterValue), Character);
var daChar:Character = cast(MusicBeatState.getVariables().get(characterValue), Character);
if (daChar != null) daChar.gfSpeed = value;
}
}
Expand All @@ -6910,7 +6934,7 @@ class PlayState extends MusicBeatState
{
if (value.startsWith('extraCharacter_'))
{
daChar = cast(MusicBeatState.getVariables().get(value), Character);
var daChar:Character = cast(MusicBeatState.getVariables().get(value), Character);
if (daChar != null && daChar.beatDance(beat)) daChar.danceChar('custom_char');
}
}
Expand Down
2 changes: 1 addition & 1 deletion funkinscsource/states/editors/content/EditorPlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class EditorPlayState extends MusicBeatSubState
score = daRating.scoreBonus;
daRating.count++;

note.canSplash = ((!note.noteSplashData.disabled && ClientPrefs.data.noteSplashes && daRating.doNoteSplash)
note.canSplash = ((!note.noteSplashData.disabled && ClientPrefs.splashOption('Player') && daRating.doNoteSplash)
&& !PlayState.SONG.options.notITG);
if (note.canSplash) spawnNoteSplashOnNote(note);

Expand Down
Loading

0 comments on commit 78877f5

Please sign in to comment.