1+ package yutautil .fnf ;
2+
3+ import backend .Song .SwagSong ;
4+ import metadata .STMetaFile .SongMetaSection ;
5+ import haxe .macro .Expr ;
6+ import haxe .io .File ;
7+ import haxe .macro .Context ;
8+
9+ class IntegratedSong {
10+
11+ public var swagSong : SwagSong ; // The chart data
12+ public var metaData : SongMetaSection ; // The metadata
13+ public var instrumental : FlxSound ; // The instrumental sound, if any
14+ public var vocals : {
15+ bf : FlxSound ,
16+ opponent : FlxSound ,
17+ ? gf : FlxSound ,
18+ ? other : Array <FlxSound >
19+ }; // Vocals for each character
20+ public var stage : flixel.util.typeLimit. OneofThree <
21+ stages. BaseStage ,
22+ flixel.util.typeLimit. OneofTwo < psychlua. FunkinLua , psychlua. LegacyFunkinLua > ,
23+ psychlua. HScript
24+ > ; // The stage data, can be a BaseStage, FunkinLua, or HScript
25+
26+ public function new (
27+ swagSong : SwagSong ,
28+ metaData : SongMetaSection ,
29+ instrumental : FlxSound = null ,
30+ vocals : {
31+ bf : FlxSound ,
32+ opponent : FlxSound ,
33+ ? gf : FlxSound ,
34+ ? other : Array <FlxSound >
35+ } = null ,
36+ stage : flixel.util.typeLimit. OneofThree <
37+ stages. BaseStage ,
38+ flixel .util .typeLimit .OneofTwo <psychlua .FunkinLua , psychlua .LegacyFunkinLua >,
39+ psychlua .HScript
40+ > = null
41+ ) {
42+ this .swagSong = swagSong ;
43+ this .metaData = metaData ;
44+ this .instrumental = instrumental ;
45+ this .vocals = vocals != null ? vocals : {
46+ bf : null ,
47+ opponent : null ,
48+ gf : null ,
49+ other : []
50+ };
51+ this .stage = stage ;
52+ }
53+
54+ // public function loadData():Void {
55+ // // Load the song data from the swagSong
56+ // // This could include parsing notes, events, etc.
57+ // // For now, we just ensure the data is loaded
58+ // if (swagSong == null) {
59+ // throw "SwagSong data is not initialized.";
60+ // }
61+ // }
62+ }
63+
64+ class IntegratedSongInit {
65+
66+ public static function create (swagSong : String , metaData : {
67+ name : String ,
68+ artist : String ,
69+ charter : String ,
70+ mod : String
71+ }, ? instrumental : FlxSound , ? vocals : {
72+ bf : FlxSound ,
73+ opponent : FlxSound ,
74+ ? gf : FlxSound ,
75+ ? other : Array <FlxSound >
76+ }, ? stage : flixel.util.typeLimit. OneofThree <
77+ stages. BaseStage ,
78+ flixel .util .typeLimit .OneofTwo <psychlua .FunkinLua , psychlua .LegacyFunkinLua >,
79+ psychlua .HScript
80+ >): IntegratedSong {
81+ // Parse the swagSong JSON string into a SwagSong object
82+ var parsedSwagSong = haxe. Json .parse (swagSong );
83+ var song = new SwagSong (parsedSwagSong );
84+
85+ }
86+
87+ }
88+
89+ public static function fromSwagSong (swagSong : SwagSong ): IntegratedSong {
90+ return new IntegratedSong (swagSong , {
91+ name : swagSong .song ,
92+ artist : " " ,
93+ charter : " " ,
94+ mod : " "
95+ });
96+ }
97+
98+ public macro function getFromFile (filePath : String , ? meta : SongMetaSection ): Expr {
99+ var swagSong = haxe.io. File .getContent (filePath );
100+ var metaData = {
101+ name : " " ,
102+ artist : " " ,
103+ charter : " " ,
104+ mod : " "
105+ };
106+ if (meta != null ) {
107+ metaData = meta ;
108+ }
109+ return macro IntegratedSongInit .create (swagSong , metaData );
110+ }
111+ }
0 commit comments