Skip to content

Commit

Permalink
enable codename charts
Browse files Browse the repository at this point in the history
  • Loading branch information
crowplexus committed Nov 27, 2023
1 parent 6deca11 commit b52324c
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 244 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions source/external/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# External Components

---

These components aren't directly tied to Forever Engine and can be used anywhere else,
When doing so, please make SURE you link the original repository.
6 changes: 5 additions & 1 deletion source/forever/AssetHelper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ class AssetHelper {
return loadedGraphics.get(keyName);

try {
final bd:BitmapData = #if sys OptimizedBitmapData.fromFile(file, vram) #else OpenFLAssets.getBitmapData(file) #end;
final bd:BitmapData =
#if (sys && !hl) OptimizedBitmapData.fromFile(file, vram)
#elseif hl BitmapData.fromFile(file)
#else OpenFLAssets.getBitmapData(file) #end;

final graphic:FlxGraphic = FlxGraphic.fromBitmapData(bd, false, file);
graphic.persist = true;
graphic.destroyOnNoUse = false;
Expand Down
7 changes: 7 additions & 0 deletions source/forever/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Forever Backend

---

Hey! Quick Disclaimer that it isn't really recommended to mess with Forever's Backend unless you wanna do something that isn't possible with scripts.

If you just wanna add a new Setting or a new Control Keybind though, feel free.
130 changes: 0 additions & 130 deletions source/forever/tools/CodenameTools.hx

This file was deleted.

45 changes: 27 additions & 18 deletions source/funkin/components/ChartLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,37 @@ package funkin.components;

import flixel.util.FlxSort;
import funkin.components.parsers.*;
import funkin.components.parsers.ForeverChartData;
import funkin.components.parsers.ChartFormat;

typedef ForeverEvent = ChartEvent<ForeverEvents>;

class ChartLoader {
public static function load(folder:String, file:String):Chart {
var chart:Chart = new Chart();

// -- IDENTIFY CHART TYPE HERE -- //

var json = cast(AssetHelper.parseAsset('songs/${folder}/${file}', JSON));
var dataType:EngineImpl = FOREVER;

if (Reflect.hasField(json, "song") && Reflect.hasField(json.song, "player2"))
dataType = VANILLA_V1;
if (Reflect.hasField(json, "codenameChart"))
dataType = CODENAME;
if (Reflect.hasField(json, "mustHitSections"))
dataType = CROW;
if (Reflect.hasField(json, "song") && Reflect.hasField(json.song, "needsVoices")) dataType = VANILLA_V1;
if (Reflect.hasField(json, "codenameChart")) dataType = CODENAME;
if (Reflect.hasField(json, "mustHitSections")) dataType = CROW;

// -- PARSING -- //

try {
switch (dataType) {
// MISSING CROW
case VANILLA_V1 | PSYCH:
var ver:Int = dataType == PSYCH ? -1 : 1;
// v-1 -> Psych | v1 -> 0.2.8 | v2 -> 0.3
chart = VanillaParser.parseChart(json.song, ver);
// its unfinished rn so yeah.
// case CODENAME: chart = CodenameParser.parseChart(json, file);
case VANILLA_V1 | PSYCH: // v-1 -> Psych | v1 -> 0.2.8 | v2 -> 0.3
chart = VanillaParser.parseChart(json.song, dataType == PSYCH ? -1 : 1);
case CODENAME:
chart = CodenameParser.parseChart(folder, file);
case FOREVER:
// welcome to my tutorial on how to parse charts, first off. -Crow
// first you get the die
// and then pour it all over yourself -Swordcube

if (json.notes != null && json.notes.length > 0)
chart.notes = cast(json.notes);
if (json.events != null && json.events.length > 0)
Expand All @@ -45,19 +46,27 @@ class ChartLoader {
};
}
if (json.gameInfo != null) {
var chars:Array<String> = json.gameInfo?.chars ?? ["bf", "dad", "gf"];
chart.gameInfo = {noteSpeed: json.gameInfo?.noteSpeed ?? 1.0, chars: chars, stageBG: json.gameInfo?.stageBG ?? null, skin: json.gameInfo?.skin ?? "normal"};
final chars:Array<String> = json.gameInfo?.chars ?? ["bf", "dad", "gf"];
chart.gameInfo = {
noteSpeed: json.gameInfo?.noteSpeed ?? 1.0,
chars: chars, stageBG: json.gameInfo?.stageBG ?? null,
skin: json.gameInfo?.skin ?? "normal"
};
}

default:
trace('${dataType.toString()} Chart Type is not implemented *yet*');
}

if (chart.notes.length > 1) chart.notes.sort((a:NoteData, b:NoteData) -> FlxSort.byValues(FlxSort.ASCENDING, a.time, b.time));
if (chart.events.length > 1) chart.events.sort((a:ForeverEvent, b:ForeverEvent) -> FlxSort.byValues(FlxSort.ASCENDING, a.time, b.time));
}
catch (e:haxe.Exception)
catch (e:haxe.Exception) {
trace('Failed to parse chart, type was ${dataType.toString()}, Error:\n${e.details()} '
+ haxe.CallStack.toString(haxe.CallStack.exceptionStack()));
}

// -- -- -- //

return chart;
}
Expand All @@ -78,8 +87,8 @@ class ChartLoader {
class Chart {
public var notes:Array<NoteData> = [];
public var events:Array<ForeverEvent> = [];
public var songInfo:ForeverSongData = {beatsPerMinute: 100.0, stepsPerBeat: 4, beatsPerBar: 4};
public var gameInfo:ForeverGameplayData = {noteSpeed: 1.0, chars: ["bf", "dad", "gf"], stageBG: null, skin: "normal"};
public var songInfo:BeatSignature = {beatsPerMinute: 100.0, stepsPerBeat: 4, beatsPerBar: 4};
public var gameInfo:GameplayData = {noteSpeed: 1.0, chars: ["bf", "dad", "gf"], stageBG: null, skin: "normal"};

public static var current:Chart;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@ package funkin.components.parsers;
*
* Contains BPM and Time Signature Information, along with additional helper data.
**/
typedef ForeverSongData = {
@:structInit class BeatSignature {
/** Declares how many beats per minute there are in a song. **/
var beatsPerMinute:Float;
public var beatsPerMinute:Float = 100.0;

/** Declares how many steps there are in a beat (time signatures part 1). **/
var stepsPerBeat:Int;
public var stepsPerBeat:Int = 4;

/** Declares how many steps there are in a bar/measure (time signatures part 2). **/
var beatsPerBar:Int;
public var beatsPerBar:Int = 4;
}

typedef ForeverGameplayData = { // :3

@:structInit class GameplayData { // :3
/** Declares the gameplay's note speed. **/
var noteSpeed:Float;
public var noteSpeed:Float = 1.0;

/** Declares your chart characters, in order, player, enemy, crowd. **/
var chars:Array<String>;
public var chars:Array<String> = ["bf", "dad", "gf"];

/** Declares the game's background/stage during gameplay. **/
var stageBG:String;
public var stageBG:String = "stage";

/** Declares the name of the skin used in game. **/
var skin:String;
public var skin:String = "default";
}

typedef NoteData = {
Expand Down
Loading

0 comments on commit b52324c

Please sign in to comment.