mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-01 04:14:47 +00:00
save data bullshit
This commit is contained in:
parent
4d4a724d72
commit
427ca3cb03
|
@ -1,11 +1,77 @@
|
||||||
package;
|
package;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
import flixel.FlxState;
|
import flixel.FlxState;
|
||||||
|
import flixel.ui.FlxButton;
|
||||||
|
import haxe.Json;
|
||||||
|
import openfl.events.Event;
|
||||||
|
import openfl.events.IOErrorEvent;
|
||||||
|
import openfl.events.IOErrorEvent;
|
||||||
|
import openfl.events.IOErrorEvent;
|
||||||
|
import openfl.net.FileReference;
|
||||||
|
|
||||||
class ChartingState extends FlxState
|
class ChartingState extends MusicBeatState
|
||||||
{
|
{
|
||||||
|
var _file:FileReference;
|
||||||
|
|
||||||
override function create()
|
override function create()
|
||||||
{
|
{
|
||||||
|
var saveButton:FlxButton = new FlxButton(0, 0, "Save", function()
|
||||||
|
{
|
||||||
|
// bullshit
|
||||||
|
|
||||||
|
var json = {
|
||||||
|
"song": "Bopeebo",
|
||||||
|
"bpm": 100,
|
||||||
|
"sections": 15
|
||||||
|
};
|
||||||
|
|
||||||
|
var data:String = Json.stringify(json);
|
||||||
|
|
||||||
|
if ((data != null) && (data.length > 0))
|
||||||
|
{
|
||||||
|
_file = new FileReference();
|
||||||
|
_file.addEventListener(Event.COMPLETE, onSaveComplete);
|
||||||
|
_file.addEventListener(Event.CANCEL, onSaveCancel);
|
||||||
|
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
||||||
|
_file.save(data, "swag.json");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
saveButton.screenCenter();
|
||||||
|
add(saveButton);
|
||||||
|
|
||||||
super.create();
|
super.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onSaveComplete(_):Void
|
||||||
|
{
|
||||||
|
_file.removeEventListener(Event.COMPLETE, onSaveComplete);
|
||||||
|
_file.removeEventListener(Event.CANCEL, onSaveCancel);
|
||||||
|
_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
||||||
|
_file = null;
|
||||||
|
FlxG.log.notice("Successfully saved LEVEL DATA.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the save file dialog is cancelled.
|
||||||
|
*/
|
||||||
|
function onSaveCancel(_):Void
|
||||||
|
{
|
||||||
|
_file.removeEventListener(Event.COMPLETE, onSaveComplete);
|
||||||
|
_file.removeEventListener(Event.CANCEL, onSaveCancel);
|
||||||
|
_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
||||||
|
_file = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called if there is an error while saving the gameplay recording.
|
||||||
|
*/
|
||||||
|
function onSaveError(_):Void
|
||||||
|
{
|
||||||
|
_file.removeEventListener(Event.COMPLETE, onSaveComplete);
|
||||||
|
_file.removeEventListener(Event.CANCEL, onSaveCancel);
|
||||||
|
_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
||||||
|
_file = null;
|
||||||
|
FlxG.log.error("Problem saving Level data");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Main extends Sprite
|
||||||
public function new()
|
public function new()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
addChild(new FlxGame(0, 0, TitleState));
|
addChild(new FlxGame(0, 0, ChartingState));
|
||||||
|
|
||||||
#if !mobile
|
#if !mobile
|
||||||
addChild(new FPS(10, 3, 0xFFFFFF));
|
addChild(new FPS(10, 3, 0xFFFFFF));
|
||||||
|
|
|
@ -15,18 +15,16 @@ class MusicBeatState extends FlxTransitionableState
|
||||||
super.create();
|
super.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function everyBeat():Void
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
if (Conductor.songPosition > lastBeat + Conductor.crochet - Conductor.safeZoneOffset
|
everyStep();
|
||||||
|| Conductor.songPosition < lastBeat + Conductor.safeZoneOffset)
|
|
||||||
{
|
super.update(elapsed);
|
||||||
if (Conductor.songPosition > lastBeat + Conductor.crochet)
|
|
||||||
{
|
|
||||||
beatHit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CHECKS EVERY FRAME
|
||||||
|
*/
|
||||||
private function everyStep():Void
|
private function everyStep():Void
|
||||||
{
|
{
|
||||||
if (Conductor.songPosition > lastStep + Conductor.stepCrochet - Conductor.safeZoneOffset
|
if (Conductor.songPosition > lastStep + Conductor.stepCrochet - Conductor.safeZoneOffset
|
||||||
|
@ -43,6 +41,9 @@ class MusicBeatState extends FlxTransitionableState
|
||||||
{
|
{
|
||||||
totalSteps += 1;
|
totalSteps += 1;
|
||||||
lastStep += Conductor.stepCrochet;
|
lastStep += Conductor.stepCrochet;
|
||||||
|
|
||||||
|
if (totalSteps % 4 == 0)
|
||||||
|
beatHit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beatHit():Void
|
public function beatHit():Void
|
||||||
|
|
|
@ -424,6 +424,9 @@ class PlayState extends MusicBeatState
|
||||||
openSubState(new PauseSubState());
|
openSubState(new PauseSubState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
|
||||||
|
FlxG.watch.addQuick('VOLRight', vocals.amplitudeRight);
|
||||||
|
|
||||||
healthHeads.setGraphicSize(Std.int(FlxMath.lerp(100, healthHeads.width, 0.98)));
|
healthHeads.setGraphicSize(Std.int(FlxMath.lerp(100, healthHeads.width, 0.98)));
|
||||||
healthHeads.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.percent, 0, 100, 100, 0) * 0.01)) - (healthHeads.width / 2);
|
healthHeads.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(healthBar.percent, 0, 100, 100, 0) * 0.01)) - (healthHeads.width / 2);
|
||||||
|
|
||||||
|
@ -512,8 +515,6 @@ class PlayState extends MusicBeatState
|
||||||
FlxG.switchState(new PlayState());
|
FlxG.switchState(new PlayState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
everyBeat();
|
|
||||||
everyStep();
|
|
||||||
// better streaming of shit
|
// better streaming of shit
|
||||||
|
|
||||||
if (health <= 0)
|
if (health <= 0)
|
||||||
|
@ -1021,6 +1022,17 @@ class PlayState extends MusicBeatState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override function stepHit()
|
||||||
|
{
|
||||||
|
if (vocals.time > Conductor.songPosition + Conductor.stepCrochet || vocals.time < Conductor.songPosition - Conductor.stepCrochet)
|
||||||
|
{
|
||||||
|
vocals.pause();
|
||||||
|
vocals.time = Conductor.songPosition;
|
||||||
|
vocals.play();
|
||||||
|
}
|
||||||
|
super.stepHit();
|
||||||
|
}
|
||||||
|
|
||||||
override function beatHit()
|
override function beatHit()
|
||||||
{
|
{
|
||||||
super.beatHit();
|
super.beatHit();
|
||||||
|
|
Loading…
Reference in a new issue