Skip to content

Commit

Permalink
Should work now ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
glowsoony committed Jan 22, 2025
1 parent 500a01f commit d28070f
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 252 deletions.
5 changes: 1 addition & 4 deletions funkinscsource/codenameengine/shaders/CustomShader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@ class CustomShader extends FunkinShader
}

public function getCode(path:String):String
{
var code:String = #if MODS_ALLOWED FileSystem.exists(path) ? File.getContent(path) : null #else Assets.exists(path) ? Assets.getText(path) : null #end;
return code;
}
return #if MODS_ALLOWED FileSystem.exists(path) ? File.getContent(path) : null #else Assets.exists(path) ? Assets.getText(path) : null #end;
}
23 changes: 19 additions & 4 deletions funkinscsource/objects/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ import scripting.*;
import crowplexus.iris.Iris;
#end

enum abstract HoldTimerType(String) from String to String
{
var BOTH = "Both";
var PLAYER = "Player";
var OPPONENT = "Opponent";
var CUSTOM = "Custom";
}

class Character extends FunkinSCSprite
{
/**
Expand Down Expand Up @@ -393,6 +401,12 @@ class Character extends FunkinSCSprite
*/
public var singAnimations:Array<String> = ['singLEFT', 'singDOWN', 'singUP', 'singRIGHT'];

/**
* Used when holdTimer function is default and not changed.
* Used to change between a custom usage of **updateHoldTimer(elapsed)**
*/
public var holdTimerType:HoldTimerType = BOTH;

public function new(x:Float, y:Float, ?character:String = 'bf', ?isPlayer:Bool = false, ?characterType:CharacterType = OTHER)
{
super(x, y);
Expand All @@ -404,6 +418,7 @@ class Character extends FunkinSCSprite
switch (character)
{
// case 'your character name in case you want to hardcode them instead':
#if BASE_GAME_FILES
case 'pico-speaker':
changeCharacter(character, isPlayer);
skipDance = true;
Expand All @@ -414,6 +429,7 @@ class Character extends FunkinSCSprite
changeCharacter(character, isPlayer);
stopIdle = false;
skipDance = true;
#end
default:
changeCharacter(character, isPlayer);
}
Expand Down Expand Up @@ -509,8 +525,7 @@ class Character extends FunkinSCSprite
iconColor = isPlayer ? 'FF66FF33' : 'FFFF0000';
iconColorFormatted = isPlayer ? '#66FF33' : '#FF0000';

noteSkinStyleOfCharacter = 'noteSkins/NOTE_assets';
strumSkinStyleOfCharacter = 'noteSkins/NOTE_assets';
noteSkinStyleOfCharacter = strumSkinStyleOfCharacter = 'noteSkins/NOTE_assets';

curColor = 0xFFFFFFFF;

Expand Down Expand Up @@ -812,7 +827,7 @@ class Character extends FunkinSCSprite

public dynamic function updateHoldTimer(elapsed:Float)
{
if (((flipMode && isPlayer) || (!flipMode && !isPlayer)))
if ((((flipMode && isPlayer) || (!flipMode && !isPlayer)) && holdTimerType == BOTH) || holdTimerType == OPPONENT)
{
if (getLastAnimationPlayed().startsWith('sing')) holdTimer += elapsed;

Expand All @@ -823,7 +838,7 @@ class Character extends FunkinSCSprite
}
}

if (isPlayer && !isCustomCharacter && !flipMode)
if (((isPlayer && !isCustomCharacter && !flipMode) && holdTimerType == BOTH) || holdTimerType == PLAYER)
{
if (getLastAnimationPlayed().startsWith('sing')) holdTimer += elapsed;
else
Expand Down
10 changes: 2 additions & 8 deletions funkinscsource/psychlua/LuaUtils.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1076,9 +1076,6 @@ class LuaUtils
animationFrame = PlayState.instance.boyfriend.animation.curAnim.curFrame;
}

var oldTimer:Float->Void = null;
oldTimer = PlayState.instance.boyfriend.updateHoldTimer;

PlayState.instance.playerStrums.characters.remove(PlayState.instance.boyfriend);
PlayState.instance.boyfriend.resetAnimationVars();

Expand Down Expand Up @@ -1136,7 +1133,7 @@ class LuaUtils
if (PlayState.instance.boyfriend.hasOffsetAnimation(animationName)) PlayState.instance.boyfriend.playAnim(animationName, true, false, animationFrame);
}

PlayState.instance.boyfriend.updateHoldTimer = oldTimer;
PlayState.instance.boyfriend.holdTimerType = PlayState.instance.opponentMode ? "Opponent" : "Player";
PlayState.instance.playerStrums.characters.push(PlayState.instance.boyfriend);
PlayState.instance.setOnScripts('boyfriendName', PlayState.instance.boyfriend.curCharacter);
PlayState.instance.boyfriend.loadCharacterScript(PlayState.instance.boyfriend.curCharacter);
Expand All @@ -1154,9 +1151,6 @@ class LuaUtils
animationFrame = PlayState.instance.dad.animation.curAnim.curFrame;
}

var oldTimer:Float->Void = null;
oldTimer = PlayState.instance.dad.updateHoldTimer;

PlayState.instance.opponentStrums.characters.remove(PlayState.instance.dad);
PlayState.instance.remove(PlayState.instance.dad);
PlayState.instance.dad.destroy();
Expand Down Expand Up @@ -1212,7 +1206,7 @@ class LuaUtils
if (PlayState.instance.dad.hasOffsetAnimation(animationName)) PlayState.instance.dad.playAnim(animationName, true, false, animationFrame);
}

PlayState.instance.dad.updateHoldTimer = oldTimer;
PlayState.instance.dad.holdTimerType = PlayState.instance.opponentMode ? "Player" : "Opponent";
PlayState.instance.opponentStrums.characters.push(PlayState.instance.dad);
PlayState.instance.setOnScripts('dadName', PlayState.instance.dad.curCharacter);
PlayState.instance.dad.loadCharacterScript(PlayState.instance.dad.curCharacter);
Expand Down
16 changes: 16 additions & 0 deletions funkinscsource/scripting/scripted/ScriptedShader.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package scripting.scripted;

class ScriptedShader extends shaders.ShaderBase
{
public var updateShader:Float->Void = null;
public var canShaderUpdate:Bool = true;

public function new(shader:String, ?ignorePref:Bool = false)
super(shader, ignorePref);

override public function update(elapsed:Float)
if (updateShader != null) updateShader(elapsed);

override public function canUpdate():Bool
return canShaderUpdate;
}
2 changes: 1 addition & 1 deletion funkinscsource/shaders/RGBPalette.hx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class RGBShaderReference
return (stealthGlowBlue = parent.stealthGlowBlue = value);
}

public var allowNew:Bool = true;
public var allowNew = true;

private function cloneOriginal()
{
Expand Down
13 changes: 4 additions & 9 deletions funkinscsource/shaders/ShaderBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ class ShaderBase
public var id:String = null;
public var tweens:Array<FlxTween> = [];

public function new(file:String)
public function new(file:String, ?ignorePref:Bool = false)
{
if (!ClientPrefs.data.shaders)
if (!ClientPrefs.data.shaders && !ignorePref)
{
shader = null;
shader = new FlxRuntimeShader();
return;
}
final fragShaderPath:String = Paths.shaderFragment(file);
final vertShaderPath:String = Paths.shaderVertex(file);
final fragCode:String = getCode(fragShaderPath);
final vertCode:String = getCode(vertShaderPath);

shader = new FlxRuntimeShader(fragCode, vertCode);
shader = new FlxRuntimeShader(getCode(Paths.shaderFragment(file)), getCode(Paths.shaderVertex(file)));
}

public function canUpdate():Bool
Expand Down
Loading

0 comments on commit d28070f

Please sign in to comment.