[WIP] notetypes !
This commit is contained in:
@@ -52,6 +52,7 @@ class Charter extends UIState {
|
||||
public var gridBackdrops:CharterBackdropGroup;
|
||||
public var eventsBackdrop:EventBackdrop;
|
||||
public var addEventSpr:CharterEventAdd;
|
||||
public var noteTypeWindow:UIButtonList<CharterNoteTypeButton>;
|
||||
|
||||
public var gridBackdropDummy:CharterBackdropDummy;
|
||||
public var noteHoverer:CharterNote;
|
||||
@@ -66,9 +67,10 @@ class Charter extends UIState {
|
||||
public var vocals:FlxSound;
|
||||
|
||||
public var noteSnap:Int = 16;
|
||||
|
||||
public var quantArray:Array<Int> = [4, 8, 12, 16, 20, 24, 32, 48, 64, 192]; // different quants
|
||||
|
||||
public var curNoteType:String = null;
|
||||
|
||||
/**
|
||||
* ACTUAL CHART DATA
|
||||
*/
|
||||
@@ -399,6 +401,13 @@ class Charter extends UIState {
|
||||
songPosInfo.alignment = RIGHT; songPosInfo.optimized = true;
|
||||
uiGroup.add(songPosInfo);
|
||||
|
||||
noteTypeWindow = new UIButtonList<CharterNoteTypeButton>(1, 200, 300, 500, "Note Types", FlxPoint.get(296, 30), FlxPoint.get(2, 2));
|
||||
noteTypeWindow.buttons.add(new CharterNoteTypeButton("Default Note", noteTypeWindow, this, null));
|
||||
noteTypeWindow.cameras = [uiCamera];
|
||||
noteTypeWindow.addButton.callback = function() {
|
||||
noteTypeWindow.buttons.add(new CharterNoteTypeButton("New NoteType", noteTypeWindow, this, Paths.getFolderContent("data/notes")));
|
||||
}
|
||||
|
||||
playBackSlider = new UISlider(FlxG.width - 160 - 26 - 20, (23/2) - (12/2), 160, 1, [{start: 0.25, end: 1, size: 0.5}, {start: 1, end: 2, size: 0.5}], true);
|
||||
playBackSlider.onChange = function (v) {
|
||||
FlxG.sound.music.pitch = vocals.pitch = v;
|
||||
@@ -442,6 +451,7 @@ class Charter extends UIState {
|
||||
add(topMenuSpr);
|
||||
// add the ui group
|
||||
add(uiGroup);
|
||||
add(noteTypeWindow);
|
||||
|
||||
loadSong();
|
||||
|
||||
@@ -467,6 +477,13 @@ class Charter extends UIState {
|
||||
EventsData.reloadEvents();
|
||||
PlayState.loadSong(__song, __diff, false, false);
|
||||
}
|
||||
chart.noteTypes = [for (i in Paths.getFolderContent("data/notes")) haxe.io.Path.withoutExtension(i)];
|
||||
for (i in Paths.getFolderContent("images/game/notes"))
|
||||
if (!chart.noteTypes.contains(haxe.io.Path.withoutExtension(i)) && haxe.io.Path.withoutExtension(i) != "default") chart.noteTypes.push(haxe.io.Path.withoutExtension(i));
|
||||
|
||||
for (i in chart.noteTypes)
|
||||
noteTypeWindow.buttons.add(new CharterNoteTypeButton(haxe.io.Path.withoutExtension(i), noteTypeWindow, this, Paths.getFolderContent("data/notes")));
|
||||
for(i in noteTypeWindow.buttons.members) i.alpha = i.theType == "Default Note" ? 1 : 0.25;
|
||||
|
||||
Conductor.setupSong(PlayState.SONG);
|
||||
|
||||
@@ -491,7 +508,7 @@ class Charter extends UIState {
|
||||
for (note in strL.notes) {
|
||||
var n = new CharterNote();
|
||||
var t = Conductor.getStepForTime(note.time);
|
||||
n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, strumLines.members[i]);
|
||||
n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, (PlayState.SONG.noteTypes[note.type] != null ? PlayState.SONG.noteTypes[note.type] : "Default Note"), strumLines.members[i]);
|
||||
notesGroup.members[notesCreated++] = n;
|
||||
}
|
||||
notesGroup.sortNotes();
|
||||
@@ -689,7 +706,7 @@ class Charter extends UIState {
|
||||
if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) {
|
||||
var note = new CharterNote();
|
||||
var gridmult = 40 / (noteSnap / 16);
|
||||
note.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), id % 4, 0, 0, strumLines.members[Std.int(id/4)]);
|
||||
note.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), id % 4, 0, curNoteType, strumLines.members[Std.int(id/4)]);
|
||||
notesGroup.add(note);
|
||||
selection = [note];
|
||||
undos.addToUndo(CCreateSelection([note]));
|
||||
@@ -730,7 +747,7 @@ class Charter extends UIState {
|
||||
noteHoverer.alpha = lerp(noteHoverer.alpha, 0.35, 0.25);
|
||||
addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25);
|
||||
var gridmult = 40 / (noteSnap / 16);
|
||||
if (noteHoverer.id != Math.floor(mousePos.x / 40) % 4) noteHoverer.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), Math.floor(mousePos.x / 40) % 4, 0, 0, null);
|
||||
if (noteHoverer.id != Math.floor(mousePos.x / 40) % 4) noteHoverer.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1), Math.floor(mousePos.x / 40) % 4, 0, null, null);
|
||||
else {
|
||||
noteHoverer.step = FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : snap(mousePos.y, gridmult) / 40, 0, __endStep-1);
|
||||
noteHoverer.y = noteHoverer.step * 40;
|
||||
@@ -842,7 +859,7 @@ class Charter extends UIState {
|
||||
for(note in strL.notes) {
|
||||
var n = new CharterNote();
|
||||
var t = Conductor.getStepForTime(note.time);
|
||||
n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, cStr);
|
||||
n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, PlayState.SONG.noteTypes[note.type], cStr);
|
||||
notesGroup.add(n);
|
||||
}
|
||||
createSelection(toBeCreated, false);
|
||||
@@ -1332,8 +1349,9 @@ class Charter extends UIState {
|
||||
|
||||
public inline function buildNote(note:CharterNote):ChartNote {
|
||||
var time = Conductor.getTimeForStep(note.step);
|
||||
if (!PlayState.SONG.noteTypes.contains(note.type) && note.type != "Default Note") PlayState.SONG.noteTypes.push(note.type);
|
||||
return {
|
||||
type: note.type,
|
||||
type: (PlayState.SONG.noteTypes.contains(note.type) ? PlayState.SONG.noteTypes.indexOf(note.type) + 1 : -1),
|
||||
time: time,
|
||||
sLen: Conductor.getTimeForStep(note.step + note.susLength) - time,
|
||||
id: note.id
|
||||
@@ -1342,6 +1360,7 @@ class Charter extends UIState {
|
||||
|
||||
public function buildChart() {
|
||||
PlayState.SONG.strumLines = [];
|
||||
PlayState.SONG.noteTypes = [];
|
||||
for(s in strumLines) {
|
||||
s.strumLine.notes = [];
|
||||
PlayState.SONG.strumLines.push(s.strumLine);
|
||||
@@ -1350,6 +1369,7 @@ class Charter extends UIState {
|
||||
if (PlayState.SONG.strumLines[n.strumLineID] != null)
|
||||
PlayState.SONG.strumLines[n.strumLineID].notes.push(buildNote(n));
|
||||
}
|
||||
trace(PlayState.SONG.noteTypes);
|
||||
buildEvents();
|
||||
}
|
||||
|
||||
@@ -1391,7 +1411,7 @@ enum CharterChange {
|
||||
}
|
||||
|
||||
enum CharterCopyboardObject {
|
||||
CNote(step:Float, id:Int, strumLineID:Int, susLength:Float, type:Int);
|
||||
CNote(step:Float, id:Int, strumLineID:Int, susLength:Float, type:String);
|
||||
CEvent(step:Float, events:Array<ChartEvent>);
|
||||
}
|
||||
|
||||
@@ -1421,6 +1441,39 @@ typedef SelectionDragChange = {
|
||||
}
|
||||
}
|
||||
|
||||
class CharterNoteTypeButton extends UIButton {
|
||||
public var theType:String;
|
||||
public var textBox:UIAutoCompleteTextBox;
|
||||
public function new(type:String, parent:UIButtonList<CharterNoteTypeButton>, state:Charter, suggestList:Array<String>) {
|
||||
theType = type;
|
||||
super(0,0,"" ,function() {
|
||||
state.curNoteType = theType;
|
||||
for(i in parent.buttons.members)
|
||||
i.alpha = i == this ? 1 : 0.25;
|
||||
},296,30);
|
||||
if (suggestList != null && suggestList.length > 0) {
|
||||
members.push(textBox = new UIAutoCompleteTextBox((bWidth - 200) / 2, y + 4, theType, 200, bHeight - 8));
|
||||
textBox.suggestItems = suggestList;
|
||||
textBox.antialiasing = true;
|
||||
textBox.onChange = function(typer:String) {
|
||||
if (!chart.noteTypes.contains(typer) && chart.noteTypes.contains(theType))
|
||||
chart.noteTypes[chart.noteTypes.indexOf(theType)] = typer;
|
||||
else if (chart.noteTypes.contains(typer) && chart.noteTypes.contains(theType))
|
||||
chart.noteTypes.remove(theType);
|
||||
else chart.noteTypes.push(typer);
|
||||
if (state.curNoteType == theType) state.curNoteType = typer;
|
||||
theType = typer;
|
||||
}
|
||||
}
|
||||
else field.text = type;
|
||||
autoAlpha = false;
|
||||
}
|
||||
override function update(elapsed) {
|
||||
super.update(elapsed);
|
||||
if (textBox != null) textBox.y = y + 4;
|
||||
//x = alpha == 0.25 ? -50 : 10;
|
||||
}
|
||||
}
|
||||
interface ICharterSelectable {
|
||||
public var x(default, set):Float;
|
||||
public var y(default, set):Float;
|
||||
|
||||
@@ -18,6 +18,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
];
|
||||
|
||||
public var sustainSpr:FlxSprite;
|
||||
public var noteTypeText:flixel.text.FlxText;
|
||||
var __doAnim:Bool = false;
|
||||
|
||||
public var selected:Bool = false;
|
||||
@@ -38,6 +39,9 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
sustainSpr = new FlxSprite(10, 40);
|
||||
sustainSpr.makeGraphic(1, 1, -1);
|
||||
members.push(sustainSpr);
|
||||
|
||||
noteTypeText = new flixel.text.FlxText(0, 0, 40, (type == null || type == "Default Note" ? "" : '${PlayState.SONG.noteTypes.indexOf(type)}'), 30);
|
||||
noteTypeText.alignment = "center";
|
||||
}
|
||||
|
||||
public override function updateButtonHandler() {
|
||||
@@ -51,7 +55,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
public var step:Float;
|
||||
public var id:Int;
|
||||
public var susLength:Float;
|
||||
public var type:Int;
|
||||
public var type:String;
|
||||
|
||||
public var strumLine:CharterStrumline;
|
||||
public var strumLineID(get, never):Int;
|
||||
@@ -64,11 +68,12 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
public function get_fullID():Int
|
||||
return (strumLineID * 4) + id;
|
||||
|
||||
public function updatePos(step:Float, id:Int, susLength:Float = 0, ?type:Int = 0, ?strumLine:CharterStrumline = null) {
|
||||
public function updatePos(step:Float, id:Int, susLength:Float = 0, ?type:String = null, ?strumLine:CharterStrumline = null) {
|
||||
this.step = step;
|
||||
this.id = id;
|
||||
this.susLength = susLength;
|
||||
this.type = type;
|
||||
noteTypeText.text = (type == null || type == "Default Note" ? "" : '${PlayState.SONG.noteTypes.indexOf(type)}');
|
||||
if (strumLine != null) this.strumLine = strumLine;
|
||||
y = step * 40;
|
||||
|
||||
@@ -123,7 +128,8 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
var __passed:Bool = false;
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
|
||||
if(noteTypeText.exists)
|
||||
noteTypeText.follow(this, 0, 0);
|
||||
if(sustainSpr.exists)
|
||||
sustainSpr.follow(this, 15, 20);
|
||||
|
||||
@@ -164,5 +170,6 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
|
||||
drawMembers();
|
||||
drawSuper();
|
||||
if(noteTypeText.text != "") noteTypeText.draw();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user