Skip to content

Commit 88c2286

Browse files
committed
frakits: "check it out: Inst.[ogg,mp3,flac,opus,wav]"
1 parent 68ea2b3 commit 88c2286

4 files changed

Lines changed: 33 additions & 14 deletions

File tree

source/funkin/backend/assets/AssetsLibraryList.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ class AssetsLibraryList extends AssetLibrary {
123123
return existsSpecific(id, type, BOTH);
124124

125125
public function getSpecificPath(id:String, source:AssetSource = BOTH):Null<String> {
126-
final library = getAssetPathLibrary(id, type, source);
126+
// idk if this should be null ? cus theres no mentions of type here
127+
// but also adding one makes actions not work
128+
final library = getAssetPathLibrary(id, null, source);
127129
if (library != null) {
128130
final path = library.getPath(id);
129131
if (path != null) return path;

source/funkin/editors/charter/CharterSelection.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ class CharterSelectionScreen extends EditorTreeMenuScreen {
122122
// Save Files
123123
var instSuffix = creation.meta.instSuffix != null ? creation.meta.instSuffix : '', vocalsSuffix = creation.meta.vocalsSuffix != null ? creation.meta.vocalsSuffix : '';
124124
CoolUtil.safeSaveFile('$songFolder/meta${variant != null ? "-" + variant : ""}.json', Json.stringify(Chart.filterMetaForSaving(creation.meta), null, Flags.JSON_PRETTY_PRINT));
125-
if (creation.instBytes != null) sys.io.File.saveBytes('$songFolder/song/Inst$instSuffix.${Flags.SOUND_EXT}', creation.instBytes);
126-
if (creation.voicesBytes != null) sys.io.File.saveBytes('$songFolder/song/Voices$vocalsSuffix.${Flags.SOUND_EXT}', creation.voicesBytes);
125+
if (creation.instBytes != null) sys.io.File.saveBytes('$songFolder/song/Inst$instSuffix.${creation.instExt}', creation.instBytes);
126+
if (creation.voicesBytes != null) sys.io.File.saveBytes('$songFolder/song/Voices$vocalsSuffix.${creation.voicesExt}', creation.voicesBytes);
127127

128-
if (creation.playerVocals != null) sys.io.File.saveBytes('$songFolder/song/Voices-Player$vocalsSuffix.${Flags.SOUND_EXT}', creation.playerVocals);
129-
if (creation.oppVocals != null) sys.io.File.saveBytes('$songFolder/song/Voices-Opponent$vocalsSuffix.${Flags.SOUND_EXT}', creation.oppVocals);
128+
if (creation.playerVocals != null) sys.io.File.saveBytes('$songFolder/song/Voices-Player$vocalsSuffix.${creation.playerExt}', creation.playerVocals);
129+
if (creation.oppVocals != null) sys.io.File.saveBytes('$songFolder/song/Voices-Opponent$vocalsSuffix.${creation.oppExt}', creation.oppVocals);
130130
#end
131131

132132
if (callback != null) callback(songFolder);

source/funkin/editors/charter/SongCreationScreen.hx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ typedef SongCreationData = {
2121
var voicesBytes:Bytes;
2222
@:optional var playerVocals:Bytes;
2323
@:optional var oppVocals:Bytes;
24+
25+
var instExt:String;
26+
var voicesExt:String;
27+
@:optional var playerExt:String;
28+
@:optional var oppExt:String;
2429
}
2530

2631
class SongCreationScreen extends UISubstateWindow {
@@ -300,7 +305,7 @@ class SongCreationScreen extends UISubstateWindow {
300305
saveButton.selectable = #if TEST_BUILD true #else project ? true : (importInstExplorer.file != null) #end;
301306
} else if (curPage == 2) {
302307
importIdTextBox.selectable = !project;
303-
importChartFile.fileType = project ? ["fnfc"] : ["json"];
308+
importChartFile.fileType = [project ? "fnfc" : "json"];
304309
importMetaFile.selectable = name == translate("vslice");
305310
saveButton.selectable = importChartFile.file != null && (!importMetaFile.selectable || importMetaFile.file != null) && (!importIdTextBox.selectable || importIdTextBox.label.text.trim().length > 0);
306311
} else
@@ -378,12 +383,13 @@ class SongCreationScreen extends UISubstateWindow {
378383
}
379384
saveFromVSlice(files);
380385
case 1 /*"V-Slice"*/:
386+
final ogg = Flags.SOUND_EXT[0];
381387
var songId = importIdTextBox.label.text;
382388
var files:Map<String, Any> = [];
383389
files.set('${songId}-metadata.json', importMetaFile.file);
384390
files.set('${songId}-chart.json', importChartFile.file);
385-
files.set('Inst.${Flags.SOUND_EXT}', importInstExplorer.file);
386-
files.set('Voices.${Flags.SOUND_EXT}', importVoicesExplorer.file);
391+
files.set('Inst.$ogg', importInstExplorer.file);
392+
files.set('Voices.$ogg', importVoicesExplorer.file);
387393
saveFromVSlice(files, songId);
388394
default /*"Psych/Legacy FNF"*/:
389395
var songId = importIdTextBox.label.text;
@@ -410,6 +416,8 @@ class SongCreationScreen extends UISubstateWindow {
410416
meta: meta,
411417
instBytes: importInstExplorer.file,
412418
voicesBytes: importVoicesExplorer.file,
419+
instExt: importInstExplorer.fileExt,
420+
voicesExt: importVoicesExplorer.fileExt
413421
}, (songFolder:String) -> {
414422
#if sys
415423
CoolUtil.safeSaveFile('$songFolder/${getChartSavePath(meta, "normal")}', Json.stringify(base, Flags.JSON_PRETTY_PRINT));
@@ -441,18 +449,21 @@ class SongCreationScreen extends UISubstateWindow {
441449
if (onSave != null) onSave({
442450
meta: meta,
443451
instBytes: instExplorer.file,
444-
voicesBytes: voicesExplorer.file
452+
voicesBytes: voicesExplorer.file,
453+
instExt: instExplorer.fileExt,
454+
voicesExt: voicesExplorer.fileExt
445455
}, null);
446456
}
447457
}
448458

449459
function saveFromVSlice(files:Map<String, Any>, ?name:String) {
460+
final ogg = Flags.SOUND_EXT[0]; // vslice doesnt know about anything that isnt ogg. this should just be a constant
450461
var songId = name == null && files.exists("manifest.json") ? Json.parse(files.get("manifest.json")).songId : name;
451462
var vslicemeta:SwagMetadata = Json.parse(files.get('${songId}-metadata.json'));
452463
var vslicechart:NewSwagSong = Json.parse(files.get('${songId}-chart.json'));
453464
var playData = vslicemeta.playData;
454465

455-
var meta:ChartMetaData = formatMeta({name: songId, needsVoices: files.get('Voices.${Flags.SOUND_EXT[0]}') != null});
466+
var meta:ChartMetaData = formatMeta({name: songId, needsVoices: files.get('Voices.$ogg') != null});
456467
var diffCharts:Array<ChartDataWithInfo> = [], events:Array<ChartEvent> = null;
457468
VSliceParser.parse(vslicemeta, vslicechart, meta, diffCharts, songId);
458469

@@ -461,10 +472,14 @@ class SongCreationScreen extends UISubstateWindow {
461472

462473
if (onSave != null) onSave({
463474
meta: meta,
464-
instBytes: files.get('Inst.${Flags.SOUND_EXT[0]}'),
465-
voicesBytes: files.get('Voices.${Flags.SOUND_EXT[0]}'), //it may exist
466-
playerVocals: files.get('Voices-${playData.characters.playerVocals != null ? playData.characters.playerVocals[0] : playData.characters.player}.${Flags.SOUND_EXT[0]}'),
467-
oppVocals: files.get('Voices-${playData.characters.opponentVocals != null ? playData.characters.opponentVocals[0] : playData.characters.opponent}.${Flags.SOUND_EXT[0]}'),
475+
instBytes: files.get('Inst.$ogg'),
476+
voicesBytes: files.get('Voices.$ogg'), //it may exist
477+
playerVocals: files.get('Voices-${playData.characters.playerVocals != null ? playData.characters.playerVocals[0] : playData.characters.player}.$ogg'),
478+
oppVocals: files.get('Voices-${playData.characters.opponentVocals != null ? playData.characters.opponentVocals[0] : playData.characters.opponent}.$ogg'),
479+
instExt: ogg,
480+
voicesExt: ogg,
481+
playerExt: ogg,
482+
oppExt: ogg
468483
}, (songFolder:String) -> {
469484
#if sys
470485
for (diff in diffCharts) CoolUtil.safeSaveFile('$songFolder/${getChartSavePath(meta, diff.diffName)}', Json.stringify(diff.chart, Flags.JSON_PRETTY_PRINT));

source/funkin/editors/ui/UIFileExplorer.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class UIFileExplorer extends UISliceSprite {
1616

1717
public var file:Bytes = null;
1818
public var filePath:String = null;
19+
public var fileExt:String = null; // avoid constant Path.extension checks
1920
public var onFile:(String, Bytes)->Void;
2021

2122
public var uiElement:FlxSprite;
@@ -78,6 +79,7 @@ class UIFileExplorer extends UISliceSprite {
7879
public function loadFile(path:String) {
7980
if (path == null) return;
8081
file = cast sys.io.File.getBytes(filePath = path);
82+
fileExt = haxe.io.Path.extension(filePath);
8183
deleteButton.visible = deleteButton.selectable = deleteIcon.visible = !(uploadButton.visible = uploadButton.selectable = false);
8284

8385
if (this.onFile != null) this.onFile(filePath, file);

0 commit comments

Comments
 (0)