Skip to content

Commit

Permalink
1.5.4 preparing for...
Browse files Browse the repository at this point in the history
* Song now is contained along with chart and difficulty.
* Re-doing a bit of EaseUtil Math.
  • Loading branch information
glowsoony committed Feb 19, 2025
1 parent 5d5dd69 commit 7dd4a81
Show file tree
Hide file tree
Showing 49 changed files with 2,135 additions and 1,328 deletions.
6 changes: 3 additions & 3 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ xsi:schemaLocation="http://lime.openfl.org/project/1.0.4 http://lime.openfl.org/
<haxelib name="FlxPartialSound"/>
<haxelib name="flxsoundfilters" />

<define name="FunkinModcharting" />

<!--<define name="FunkinModcharting" /> --> <!--Not used because SCE adapter is not public-->
<define name="FunkinModcharting" /> <!--Not used because SCE adapter is not public-->
<section if="FunkinModcharting">
<haxedef name="FM_ENGINE" value="SCE"/>
<haxedef name="FM_ENGINE_VERSION" value="1.5.3"/>
Expand All @@ -282,6 +280,8 @@ xsi:schemaLocation="http://lime.openfl.org/project/1.0.4 http://lime.openfl.org/
<define name="FunkinModchart" if="funkin-modchart"/>
</section>

<define name="MULTITHREADED_LOADING"/> <!-- UNCOMMENTING THIS LINE WILL ENABLE MULTITHREADED LOADING, WHICH IMPROVES LOADING TIMES, BUT WITH A LOW CHANCE FOR THE GAME FREEZE ON SONG LOAD -->

<!--Disable source traces for release builds-->
<haxeflag name="-D no-traces"/>

Expand Down
2 changes: 1 addition & 1 deletion UnusedButKeptCode.hx.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UnusedButKeptCode
}
}
final type:String = extraTrack.type.toLowerCase();
final finalName:String = extraTrack.name == null ? SONG.songId : finalName;
final finalName:String = extraTrack.name == null ? SONG.getSongData('songId') : finalName;
final finalFolder:String = extraTrack.folder == null ? 'songs' : extraTrack.folder;
final finalPrefix:String = extraTrack.prefix == null ? currentPrefix : extraTrack.prefix;
final finalSuffix:String = extraTrack.suffix == null ? currentSuffix : extraTrack.suffix;
Expand Down
68 changes: 68 additions & 0 deletions scsource/Init.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import flixel.FlxState;
import openfl.Lib;
import lime.app.Application;
import scfunkin.states.TitleState;
import scfunkin.states.PlayState;
import scfunkin.states.FlashingState;
import scfunkin.play.song.data.Highscore;
import scfunkin.debug.Debug;
import scfunkin.debug.FPSCounter;
#if HSCRIPT_ALLOWED
import crowplexus.iris.Iris;
import scfunkin.backend.scripting.psych.HScript.HScriptInfos;
#end

class Init extends FlxState
{
Expand Down Expand Up @@ -43,6 +48,69 @@ class Init extends FlxState

FlxG.autoPause = false;

#if HSCRIPT_ALLOWED
Iris.warn = function(x, ?pos:haxe.PosInfos) {
Iris.logLevel(WARN, x, pos);
var newPos:HScriptInfos = cast pos;
if (newPos.showLine == null) newPos.showLine = true;
var msgInfo:String = (newPos.funcName != null ? '(${newPos.funcName}) - ' : '') + '${newPos.fileName}:';
#if LUA_ALLOWED
if (newPos.isLua == true)
{
msgInfo += 'HScript:';
newPos.showLine = false;
}
#end
if (newPos.showLine == true)
{
msgInfo += '${newPos.lineNumber}:';
}
msgInfo += ' $x';
Debug.logInfo('WARNING: $msgInfo');
if (PlayState.instance != null) PlayState.instance.addTextToDebug('WARNING: $msgInfo', FlxColor.YELLOW);
}
Iris.error = function(x, ?pos:haxe.PosInfos) {
Iris.logLevel(ERROR, x, pos);
var newPos:HScriptInfos = cast pos;
if (newPos.showLine == null) newPos.showLine = true;
var msgInfo:String = (newPos.funcName != null ? '(${newPos.funcName}) - ' : '') + '${newPos.fileName}:';
#if LUA_ALLOWED
if (newPos.isLua == true)
{
msgInfo += 'HScript:';
newPos.showLine = false;
}
#end
if (newPos.showLine == true)
{
msgInfo += '${newPos.lineNumber}:';
}
msgInfo += ' $x';
Debug.logInfo('ERROR: $msgInfo');
if (PlayState.instance != null) PlayState.instance.addTextToDebug('ERROR: $msgInfo', FlxColor.RED);
}
Iris.fatal = function(x, ?pos:haxe.PosInfos) {
Iris.logLevel(FATAL, x, pos);
var newPos:HScriptInfos = cast pos;
if (newPos.showLine == null) newPos.showLine = true;
var msgInfo:String = (newPos.funcName != null ? '(${newPos.funcName}) - ' : '') + '${newPos.fileName}:';
#if LUA_ALLOWED
if (newPos.isLua == true)
{
msgInfo += 'HScript:';
newPos.showLine = false;
}
#end
if (newPos.showLine == true)
{
msgInfo += '${newPos.lineNumber}:';
}
msgInfo += ' $x';
Debug.logInfo('FATAL: $msgInfo');
if (PlayState.instance != null) PlayState.instance.addTextToDebug('FATAL: $msgInfo', 0xFFBB0000);
}
#end

// Setup window events (like callbacks for onWindowClose)
// and fullscreen keybind setup - Not Used
scfunkin.utils.WindowUtil.initWindowEvents();
Expand Down
1 change: 1 addition & 0 deletions scsource/import.hx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import scfunkin.play.input.Controls;
import scfunkin.play.stage.*;
import scfunkin.play.song.Song;
import scfunkin.play.song.data.SongData;
import scfunkin.play.song.data.SongJsonData;
import scfunkin.play.song.data.Difficulty;
// Psych-UI
import scfunkin.backend.ui.*;
Expand Down
18 changes: 14 additions & 4 deletions scsource/scfunkin/backend/assets/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ class Paths

public static function freeGraphicsFromMemory(cache:Bool = true)
{
if (!cache) return;
var protectedGfx:Array<FlxGraphic> = [];
function checkForGraphics(spr:Dynamic)
{
Expand All @@ -252,7 +251,9 @@ class Paths
// trace('is actually a group');
for (member in grp)
{
if (member == null) continue;
checkForGraphics(member);
grp.remove(member);
}
return;
}
Expand All @@ -270,9 +271,18 @@ class Paths
// catch(haxe.Exception) {}
}
for (member in FlxG.state.members)
checkForGraphics(member);
if (FlxG.state.subState != null) for (member in FlxG.state.subState.members)
checkForGraphics(member);
{
if (member != null) checkForGraphics(member);
FlxG.state.remove(member, true);
}
if (FlxG.state.subState != null)
{
for (member in FlxG.state.subState.members)
{
if (member != null) checkForGraphics(member);
FlxG.state.subState.remove(member, true);
}
}
for (key in currentTrackedAssets.keys())
{
// if it is not currently contained within the used local assets
Expand Down
6 changes: 3 additions & 3 deletions scsource/scfunkin/backend/data/StageData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ class StageData

public static var forceNextDirectory:String = null;

public static function loadDirectory(SONG:SwagSong)
public static function loadDirectory(SONG:Song)
{
final stage:String = if (SONG.stage != null) SONG.stage else if (Song.loadedSongName != null)
vanillaSongStage(Paths.formatToSongPath(Song.loadedSongName)) else 'mainStage';
final stage:String = if (SONG.getSongData('stage') != null) SONG.getSongData('stage') else if (SongJsonData.loadedSongName != null)
vanillaSongStage(Paths.formatToSongPath(SongJsonData.loadedSongName)) else 'mainStage';

final stageFile:StageFile = getStageFile(stage);
forceNextDirectory = (stageFile != null) ? stageFile.directory : ''; // preventing crashes
Expand Down
5 changes: 1 addition & 4 deletions scsource/scfunkin/backend/data/files/ExternalSoundFile.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package scfunkin.backend.data.files;

typedef ExternalSoundFile =
{
var ?name:String;
> ExternalFile,
var ?prefix:String;
var ?suffix:String;
var ?character:String;
var ?vocal:String;
var ?difficulty:String;
var ?volume:Float;
var ?folder:String;
var ?tag:String;
var ?type:String;
var ?side:String;
};
65 changes: 41 additions & 24 deletions scsource/scfunkin/backend/scripting/psych/FunkinLua.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ import scfunkin.objects.ui.scripting.ModchartAnimateSprite;
import haxe.PosInfos;
import tjson.TJSON as Json;
import lime.app.Application;
#if HSCRIPT_ALLOWED
import crowplexus.iris.Iris;
import crowplexus.hscript.Expr.Error as IrisError;
import crowplexus.hscript.Printer;
import scfunkin.backend.scripting.psych.HScript.HScriptInfos;
#end

typedef LuaCamera =
{
Expand Down Expand Up @@ -101,11 +107,16 @@ class FunkinLua
{
hscript.scriptCode = code;
hscript.parse(true);
var ret:Dynamic = hscript.execute();
hscript.returnValue = ret;
}
}
catch (e)
catch (e:IrisError)
{
throw e;
var pos:HScriptInfos = cast hscript.interp.posInfos();
pos.isLua = true;
Iris.error(Printer.errorToString(e, false), pos);
hscript.returnValue = null;
}
hscript.varsToBring = varsToBring;
if (instance != null) hscript.changeInstance(instance);
Expand Down Expand Up @@ -176,22 +187,22 @@ class FunkinLua
set('curBpm', Conductor.bpm);
if (PlayState.SONG != null)
{
set('bpm', PlayState.SONG.bpm);
set('scrollSpeed', PlayState.SONG.speed);
set('bpm', PlayState.SONG.getSongData('bpm'));
set('scrollSpeed', PlayState.SONG.getSongData('speed'));
}
set('crochet', Conductor.crochet);
set('stepCrochet', Conductor.stepCrochet);
set('songLength', 0);
if (PlayState.SONG != null)
{
set('songName', PlayState.SONG.songId);
set('songPath', Paths.formatToSongPath(PlayState.SONG.songId));
set('songName', PlayState.SONG.getSongData('songId'));
set('songPath', Paths.formatToSongPath(PlayState.SONG.getSongData('songId')));
}
set('loadedSongName', Song.loadedSongName);
set('loadedSongPath', Paths.formatToSongPath(Song.loadedSongName));
set('chartPath', Song.chartPath);
set('loadedSongName', SongJsonData.loadedSongName);
set('loadedSongPath', Paths.formatToSongPath(SongJsonData.loadedSongName));
set('chartPath', SongJsonData.chartPath);
set('startedCountdown', false);
if (PlayState.SONG != null) set('curStage', PlayState.SONG.stage);
if (PlayState.SONG != null) set('curStage', PlayState.SONG.getSongData('stage'));

set('isStoryMode', PlayState.isStoryMode);
set('difficulty', PlayState.storyDifficulty);
Expand All @@ -201,15 +212,15 @@ class FunkinLua
set('weekRaw', PlayState.storyWeek);
set('week', WeekData.weeksList[PlayState.storyWeek]);
set('seenCutscene', PlayState.seenCutscene);
set('hasVocals', PlayState.SONG.needsVoices);
set('hasVocals', PlayState.SONG.getSongData('needsVoices'));

// Screen stuff
set('screenWidth', FlxG.width);
set('screenHeight', FlxG.height);

if (game != null) @:privateAccess
{
var curSection:SwagSection = PlayState.SONG.notes[game.curSection];
var curSection:SwagSection = PlayState.SONG.getSongData('notes')[game.curSection];
// PlayState variables
set('curSection', game.curSection);
set('curBeat', game.curBeat);
Expand Down Expand Up @@ -276,10 +287,11 @@ class FunkinLua
set('defaultMomX', game.MOM_X);
set('defaultMomY', game.MOM_Y);

set('boyfriendName', game.boyfriend != null ? game.boyfriend.curCharacter : PlayState.SONG != null ? PlayState.SONG.characters.player : 'bf');
set('dadName', game.dad != null ? game.dad.curCharacter : PlayState.SONG != null ? PlayState.SONG.characters.opponent : 'dad');
set('gfName', game.gf != null ? game.gf.curCharacter : PlayState.SONG != null ? PlayState.SONG.characters.girlfriend : 'bf');
set('momName', game.mom != null ? game.mom.curCharacter : PlayState.SONG != null ? PlayState.SONG.characters.secondOpponent : 'mom');
set('boyfriendName',
game.boyfriend != null ? game.boyfriend.curCharacter : PlayState.SONG != null ? PlayState.SONG.getSongData('characters').player : 'bf');
set('dadName', game.dad != null ? game.dad.curCharacter : PlayState.SONG != null ? PlayState.SONG.getSongData('characters').opponent : 'dad');
set('gfName', game.gf != null ? game.gf.curCharacter : PlayState.SONG != null ? PlayState.SONG.getSongData('characters').girlfriend : 'bf');
set('momName', game.mom != null ? game.mom.curCharacter : PlayState.SONG != null ? PlayState.SONG.getSongData('characters').secondOpponent : 'mom');
}

// Other settings
Expand Down Expand Up @@ -749,11 +761,16 @@ class FunkinLua
});

set("loadSong", function(?name:String = null, ?difficultyNum:Int = -1) {
if (name == null || name.length < 1) name = Song.loadedSongName;
if (name == null || name.length < 1) name = SongJsonData.loadedSongName;
if (difficultyNum == -1) difficultyNum = PlayState.storyDifficulty;

final poop = Highscore.formatSong(name, difficultyNum);
Song.loadFromJson(poop, name);
final songInput = Highscore.formatSong(name, difficultyNum);
SongJsonData.loadFromJson({
jsonInput: songInput,
folder: name,
difficulty: Difficulty.getFilePath(difficultyNum),
inputNoDiff: songInput.replace(Difficulty.getFilePath(difficultyNum), '')
});
PlayState.storyDifficulty = difficultyNum;
MusicBeatState.switchState(new PlayState());

Expand Down Expand Up @@ -1091,7 +1108,7 @@ class FunkinLua
// others
set("triggerEventLegacy",
function(name:String, ?arg1:String = '', ?arg2:String = '', ?arg3:String = '', ?arg4:String = '', ?arg5:String = '', ?arg6:String = '') {
game.triggerEventLegacy(name, arg1, arg2, Conductor.songPosition, arg3, arg4, arg5, arg6);
game.songEvents.triggerEvent(name, [arg1, arg2, arg3, arg4, arg5, arg6], Conductor.songPosition);
return true;
});

Expand All @@ -1100,7 +1117,7 @@ class FunkinLua
var args:Array<String> = [];
for (i in 0...luaArgs.length)
args.push(Std.string(luaArgs[i]));
game.triggerEvent(name, args, Conductor.songPosition);
game.songEvents.triggerEvent(name, args, Conductor.songPosition);
return true;
});

Expand Down Expand Up @@ -1567,7 +1584,7 @@ class FunkinLua
if (!ClientPrefs.data.healthColor) return;
final left_color:Null<FlxColor> = left != null && left.length > 0 ? CoolUtil.colorFromString(left) : null;
final right_color:Null<FlxColor> = right != null && right.length > 0 ? CoolUtil.colorFromString(right) : null;
if (PlayState.SONG.options.oldBarSystem)
if (PlayState.SONG.getSongData('options').oldBarSystem)
{
if (!ClientPrefs.data.gradientSystemForOldBars) game.hud.healthBar.createFilledBar(left_color, right_color);
else
Expand All @@ -1583,7 +1600,7 @@ class FunkinLua
set("setTimeBarColors", function(left:String, right:String) {
final left_color:Null<FlxColor> = left != null && left.length > 0 ? CoolUtil.colorFromString(left) : null;
final right_color:Null<FlxColor> = right != null && right.length > 0 ? CoolUtil.colorFromString(right) : null;
if (PlayState.SONG.options.oldBarSystem)
if (PlayState.SONG.getSongData('options').oldBarSystem)
{
if (ClientPrefs.data.colorBarType == 'No Colors') game.hud.timeBar.createFilledBar(FlxColor.fromString(Std.string(right)),
FlxColor.fromString(Std.string(left)));
Expand Down Expand Up @@ -1665,7 +1682,7 @@ class FunkinLua
});
set("startDialogue", function(dialogueFile:String, ?music:String = null) {
var path:String;
var songPath:String = Paths.formatToSongPath(Song.loadedSongName);
var songPath:String = Paths.formatToSongPath(SongJsonData.loadedSongName);
#if TRANSLATIONS_ALLOWED
path = Paths.getPath('data/songs/$songPath/${dialogueFile}_${ClientPrefs.data.language}.json', TEXT);
#if MODS_ALLOWED
Expand Down
Loading

0 comments on commit 7dd4a81

Please sign in to comment.