Skip to content

Commit

Permalink
gonna get working on this again
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Jul 14, 2024
1 parent 67d3c37 commit d3553b2
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 370 deletions.
12 changes: 8 additions & 4 deletions source/funkin/graphics/TypedGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ typedef Group = TypedGroup<FlxBasic>;
@:access(flixel.FlxCamera)
class TypedGroup<T:FlxBasic> extends #if (flixel >= "5.7.0") FlxTypedContainer<T> #else FlxTypedGroup<T> #end
{
public inline function setNull(object:T) {
public inline function setNull(object:T):Void
{
var index:Int = members.indexOf(object);
if (index != -1)
members.unsafeSet(index, null);
}

public function insertTop(object:T) {
public function insertTop(object:T):Void
{
var index:Int = members.length;
while (index > 0) {
index--;
Expand All @@ -31,7 +33,8 @@ class TypedGroup<T:FlxBasic> extends #if (flixel >= "5.7.0") FlxTypedContainer<T
members.push(object);
}

public function insertBelow(object:T) {
public function insertBelow(object:T):Void
{
var index:Int = 0;
final l:Int = members.length;
while (index < l) {
Expand All @@ -45,7 +48,8 @@ class TypedGroup<T:FlxBasic> extends #if (flixel >= "5.7.0") FlxTypedContainer<T
members.unshift(object);
}

override function forEachAlive(func:T -> Void, recurse:Bool = false) {
override function forEachAlive(func:T -> Void, recurse:Bool = false):Void
{
members.fastForEach((basic, i) -> {
if (basic != null) if (basic.exists) if (basic.alive)
func(basic);
Expand Down
2 changes: 2 additions & 0 deletions source/funkin/objects/note/BasicNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class BasicNote extends SmartSprite implements INoteData implements ITimingObjec
loadFromSprite(curSkinData.baseSprite);
}

public function updateAnim():Void {}

public var approachAngle(default, set):Float = 0;
function set_approachAngle(value:Float):Float {
if (approachAngle != value) calcApproachTrig(value);
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/objects/note/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Note extends BasicNote
updateAnim();
}

public function updateAnim() {
override function updateAnim() {
playAnim('scroll' + CoolUtil.directionArray[noteData]);
}

Expand Down
8 changes: 6 additions & 2 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Sustain extends BasicNote
override function updateSprites():Void {
loadFromSprite(curSkinData.baseSprite);

playAnim("hold" + CoolUtil.directionArray[noteData]);
updateAnim();
targetStrum = targetStrum;
smoothTiles = Math.round(125 / height);

Expand All @@ -132,10 +132,14 @@ class Sustain extends BasicNote
clipRect.width = repeatWidth;
}

override function updateAnim() {
playAnim("hold" + CoolUtil.directionArray[noteData]);
}

override function setupTile(tileX:Int, tileY:Int, baseFrame:FlxFrame):FlxPoint {
switch (tileY) {
case 0: playAnim("hold" + CoolUtil.directionArray[noteData] + "-end"); // Tail
case 1: playAnim("hold" + CoolUtil.directionArray[noteData]); // Piece
case 1: updateAnim(); // Piece
}
return super.setupTile(tileX, tileY, frame);
}
Expand Down
216 changes: 216 additions & 0 deletions source/funkin/states/editors/newchart/ChartDebug.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
package funkin.states.editors.newchart;

import flixel.addons.display.FlxBackdrop;
import flixel.addons.display.FlxGridOverlay;

typedef ChartBpm = {
var time:Float;
var bpm:Float;
}

typedef ChartSong = {
notes:Array<NoteJson>,
events:Array<EventJson>,
bpms:Array<ChartBpm>
}

class ChartDebug extends MusicBeatState
{
public var songFile:ChartSong;

var downscroll:Bool = true;
var grid:Grid;

override function create()
{
super.create();

grid = new Grid();
add(grid);

loadSong("bopeebo", "hard");
}

// TODO: draw this based on each bpm change till the end of the song rather than per note

/*function addNote(data:NoteJson):Void
{
var note = grid.notes.recycle(ChartNote);
grid.notes.add(note);
var time:Float = data.time;
var lane:Int = data.lane;
note.y = getTimeY(time);
note.x = grid.notesGrid.x + (lane * Grid.tileSize);
note.load(data, getLastCrochet(time));
}
function addEvent(data:EventJson):Void
{
var event = grid.events.recycle();
grid.events.add(event);
}
function getLastCrochet(time:Float):Float
{
var lastChange:ChartBpm = null;
songFile.bpms.fastForEach((change, i) ->
{
if (change.time > time)
break;
lastChange = change;
});
return (60 / lastChange.bpm) * 1000;
}
// Runs a function for each bpm change of a song before a time and returns the last crochet
function forEachChange(time:Float, call:(ChartBpm, Float)->Void):Float
{
var bpms = songFile.bpms;
var crochet:Float = 0;
var i = 1;
var l = bpms.length;
while (i < l) {
var change = bpms[i];
if (change.time > time)
break;
crochet = (60 / change.bpm) * 1000;
call(change, crochet);
i++;
}
return crochet;
}
function getTimeY(time:Float):Float
{
var yResult:Float = 0;
forEachChange(time, (change, crochet) -> {
yResult += FlxMath.remapToRange(
time - change.time,
0, 4 * crochet,
0, 16 * Grid.tileSize
);
});
if (downscroll) {
yResult *= -1;
yResult += Grid.tileSize * 16;
}
return yResult;
}*/

/** Redraw all notes and events from the song **/
function reload():Void
{
grid.notes.killMembers();
grid.events.killMembers();

//songFile.notes.fastForEach((note, i) -> addNote(note));
//songFile.events.fastForEach((event, i) -> addEvent(event));
}

function loadSong(name:String, difficulty:String)
{
var file = Song.checkSong(Song.loadFromFile(difficulty, name));
Conductor.loadSong(name);

songFile = {
notes: [],
events: [],
bpms: [{time: 0, bpm: file.bpm}]
}

file.notes.fastForEach((section, i) -> {
section.sectionNotes.fastForEach((note, i) -> songFile.notes.push(note));
section.sectionEvents.fastForEach((event, i) -> songFile.events.push(event));
});

reload();
}
}

class Grid extends Group
{
inline public static var tileSize:Int = 40;

public var notesGrid:FlxBackdrop;
public var eventsGrid:FlxBackdrop;

public var notes:TypedGroup<ChartNote>;
public var events:TypedGroup<ChartEvent>;

public function new() {
super();

notesGrid = new FlxBackdrop(makeGrid(8), Y);
notesGrid.screenCenter(X);
add(notesGrid);

eventsGrid = new FlxBackdrop(makeGrid(1), Y);
eventsGrid.x = (notesGrid.x + notesGrid.width) + (tileSize / 2);
add(eventsGrid);

notes = new TypedGroup<ChartNote>();
add(notes);

events = new TypedGroup<ChartEvent>();
add(events);
}

function makeGrid(lanes:Int) {
return FlxGridOverlay.createGrid(
tileSize, tileSize,
tileSize * lanes, tileSize * 18,
true, 0xff7c7c7c, 0xff6e6e6e
);
}
}

class GridItem extends SpriteGroup
{

}

class ChartNote extends GridItem
{
var note:Note;
var sustain:Sustain;

public function new() {
super(0,0,2);

note = new Note();
sustain = new Sustain();

add(sustain);
add(note);

note.setGraphicSize(Grid.tileSize);
note.updateHitbox();

sustain.setScale(note.scale.x, true);
}

public function load(data:NoteJson, crochet:Float)
{
note.noteData = sustain.noteData = data.lane;
note.updateAnim();

//sustain.repeatHeight =
}
}

class ChartEvent extends GridItem
{

}
33 changes: 0 additions & 33 deletions source/funkin/states/newchart/ChartEditor.hx

This file was deleted.

Loading

0 comments on commit d3553b2

Please sign in to comment.