mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-02-16 20:01:49 -05:00
crackhead save/loading chart shit
This commit is contained in:
parent
4f1a413430
commit
5e55a397fe
3 changed files with 61 additions and 41 deletions
|
@ -18,9 +18,9 @@ class Note extends FlxSprite
|
|||
{
|
||||
public var data:NoteData = {
|
||||
strumTime: 0,
|
||||
noteData: 0,
|
||||
sustainLength: 0,
|
||||
altNote: false,
|
||||
noteData: 0
|
||||
altNote: false
|
||||
};
|
||||
|
||||
public var mustPress:Bool = false;
|
||||
|
|
|
@ -140,41 +140,67 @@ class SongLoad
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts the an array to NOTE data (for LOADING shit from json usually)
|
||||
*/
|
||||
public static function castArrayToNoteData(noteStuff:Array<SwagSection>)
|
||||
{
|
||||
for (sectionIndex => section in noteStuff)
|
||||
{
|
||||
for (noteIndex => noteDataArray in section.sectionNotes)
|
||||
{
|
||||
trace(noteDataArray);
|
||||
|
||||
var arrayDipshit:Array<Dynamic> = cast noteDataArray; // crackhead
|
||||
|
||||
// at this point noteStuff[sectionIndex].sectionNotes[noteIndex] is an array because of the cast from the first line in this function
|
||||
// so this line right here turns it back into the NoteData typedef type because of another bastard cast
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex] = cast SongLoad.getDefaultNoteData(); // turn it from an array (because of the cast), back to noteData? yeah that works
|
||||
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].strumTime = arrayDipshit[0];
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].noteData = arrayDipshit[1];
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].sustainLength = arrayDipshit[2];
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].altNote = arrayDipshit[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast notedata to ARRAY (usually used for level SAVING)
|
||||
*/
|
||||
public static function castNoteDataToArray(noteStuff:Array<SwagSection>)
|
||||
{
|
||||
for (sectionIndex => section in noteStuff)
|
||||
{
|
||||
for (noteIndex => noteTypeDefShit in section.sectionNotes)
|
||||
{
|
||||
var dipshitArray:Array<Dynamic> = [
|
||||
noteTypeDefShit.strumTime,
|
||||
noteTypeDefShit.noteData,
|
||||
noteTypeDefShit.sustainLength,
|
||||
noteTypeDefShit.altNote
|
||||
];
|
||||
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex] = cast dipshitArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function parseJSONshit(rawJson:String):SwagSong
|
||||
{
|
||||
var swagShit:SwagSong = cast Json.parse(rawJson).song;
|
||||
|
||||
for (diff in Reflect.fields(Json.parse(rawJson).song.notes))
|
||||
{
|
||||
function funnyNoteSetter(noteStuff:Array<SwagSection>)
|
||||
{
|
||||
for (sectionIndex => section in noteStuff)
|
||||
{
|
||||
for (noteIndex => noteDataArray in section.sectionNotes)
|
||||
{
|
||||
trace(noteDataArray);
|
||||
|
||||
var arrayDipshit:Array<Dynamic> = cast noteDataArray; // crackhead
|
||||
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex] = cast SongLoad.getDefaultNoteData(); // turn it from an array (because of the cast), back to noteData?
|
||||
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].strumTime = arrayDipshit[0];
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].noteData = arrayDipshit[1];
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].sustainLength = arrayDipshit[2];
|
||||
noteStuff[sectionIndex].sectionNotes[noteIndex].altNote = arrayDipshit[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (diff)
|
||||
{
|
||||
case "easy":
|
||||
funnyNoteSetter(swagShit.notes.hard);
|
||||
castArrayToNoteData(swagShit.notes.hard);
|
||||
|
||||
case "normal":
|
||||
funnyNoteSetter(swagShit.notes.normal);
|
||||
castArrayToNoteData(swagShit.notes.normal);
|
||||
case "hard":
|
||||
funnyNoteSetter(swagShit.notes.hard);
|
||||
castArrayToNoteData(swagShit.notes.hard);
|
||||
}
|
||||
trace(diff);
|
||||
}
|
||||
|
|
|
@ -4,41 +4,26 @@ import Conductor.BPMChangeEvent;
|
|||
import Note.NoteData;
|
||||
import Section.SwagSection;
|
||||
import SongLoad.SwagSong;
|
||||
import dsp.FFT;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxStrip;
|
||||
import flixel.addons.display.FlxGridOverlay;
|
||||
import flixel.addons.ui.FlxInputText;
|
||||
import flixel.addons.ui.FlxUI9SliceSprite;
|
||||
import flixel.addons.ui.FlxUI;
|
||||
import flixel.addons.ui.FlxUICheckBox;
|
||||
import flixel.addons.ui.FlxUIDropDownMenu;
|
||||
import flixel.addons.ui.FlxUIInputText;
|
||||
import flixel.addons.ui.FlxUINumericStepper;
|
||||
import flixel.addons.ui.FlxUITabMenu;
|
||||
import flixel.addons.ui.FlxUITooltip.FlxUITooltipStyle;
|
||||
import flixel.graphics.tile.FlxDrawTrianglesItem.DrawData;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.group.FlxGroup;
|
||||
import flixel.input.gamepad.id.SwitchJoyconLeftID;
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.system.FlxSound;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.ui.FlxButton;
|
||||
import flixel.ui.FlxSpriteButton;
|
||||
import flixel.util.FlxColor;
|
||||
import haxe.CallStack.StackItem;
|
||||
import haxe.Json;
|
||||
import haxe.Serializer;
|
||||
import lime.media.AudioBuffer;
|
||||
import lime.utils.Assets;
|
||||
import lime.utils.Int16Array;
|
||||
import openfl.events.Event;
|
||||
import openfl.events.IOErrorEvent;
|
||||
import openfl.media.Sound;
|
||||
import openfl.net.FileReference;
|
||||
import openfl.utils.ByteArray;
|
||||
|
||||
using Lambda;
|
||||
using StringTools;
|
||||
|
@ -1357,11 +1342,16 @@ class ChartingState extends MusicBeatState
|
|||
|
||||
private function saveLevel(?debugSavepath:Bool = false)
|
||||
{
|
||||
// run this for each diff
|
||||
SongLoad.castNoteDataToArray(_song.notes.easy);
|
||||
SongLoad.castNoteDataToArray(_song.notes.normal);
|
||||
SongLoad.castNoteDataToArray(_song.notes.hard);
|
||||
|
||||
var json = {
|
||||
"song": _song
|
||||
};
|
||||
|
||||
var data:String = Json.stringify(json);
|
||||
var data:String = Json.stringify(json, null, "\t");
|
||||
|
||||
#if sys
|
||||
// quick workaround, since it easier to load into hashlink, thus quicker/nicer to test?
|
||||
|
@ -1386,6 +1376,10 @@ class ChartingState extends MusicBeatState
|
|||
_file.save(data.trim(), _song.song.toLowerCase() + ".json");
|
||||
}
|
||||
#end
|
||||
|
||||
SongLoad.castArrayToNoteData(_song.notes.easy);
|
||||
SongLoad.castArrayToNoteData(_song.notes.normal);
|
||||
SongLoad.castArrayToNoteData(_song.notes.hard);
|
||||
}
|
||||
|
||||
function onSaveComplete(_):Void
|
||||
|
|
Loading…
Reference in a new issue