charter sustains
This commit is contained in:
@@ -10,16 +10,6 @@
|
||||
"type": "haxelib",
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"name": "flixel-addons",
|
||||
"type": "haxelib",
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"name": "spinehaxe",
|
||||
"type": "haxelib",
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"name": "flixel",
|
||||
"type": "git",
|
||||
|
||||
@@ -32,6 +32,7 @@ class Charter extends UIState {
|
||||
/**
|
||||
* CONFIG & UI (might make this customizable later)
|
||||
*/
|
||||
public var charterBG:FunkinSprite;
|
||||
public var uiGroup:FlxTypedGroup<FlxSprite> = new FlxTypedGroup<FlxSprite>();
|
||||
private var gridColor1:FlxColor = 0xFF272727; // white
|
||||
private var gridColor2:FlxColor = 0xFF545454; // gray
|
||||
@@ -163,6 +164,30 @@ class Charter extends UIState {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Note",
|
||||
childs: [
|
||||
{
|
||||
label: "Add sustain length",
|
||||
keybind: [E],
|
||||
onSelect: _note_addsustain
|
||||
},
|
||||
{
|
||||
label: "Subtract sustain length",
|
||||
keybind: [Q],
|
||||
onSelect: _note_subtractsustain
|
||||
},
|
||||
null,
|
||||
{
|
||||
label: "(0) Default Note",
|
||||
keybind: [ZERO]
|
||||
},
|
||||
{
|
||||
label: "(1) Hurt Note",
|
||||
keybind: [ONE]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "View",
|
||||
childs: [
|
||||
@@ -255,6 +280,12 @@ class Charter extends UIState {
|
||||
uiCamera.bgColor = 0;
|
||||
FlxG.cameras.add(uiCamera);
|
||||
|
||||
charterBG = new FunkinSprite(0, 0, Paths.image('menus/menuDesat'));
|
||||
charterBG.color = 0xFF181818;
|
||||
charterBG.cameras = [charterCamera];
|
||||
charterBG.screenCenter();
|
||||
charterBG.scrollFactor.set();
|
||||
add(charterBG);
|
||||
|
||||
gridBackdrop = new CharterBackdrop();
|
||||
|
||||
@@ -319,7 +350,8 @@ class Charter extends UIState {
|
||||
for(strID=>strL in PlayState.SONG.strumLines) {
|
||||
for(note in strL.notes) {
|
||||
var n = new CharterNote();
|
||||
n.updatePos(Conductor.getStepForTime(note.time), (strID * 4) + note.id, note.sLen, note.type);
|
||||
var t = Conductor.getStepForTime(note.time);
|
||||
n.updatePos(t, (strID * 4) + note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type);
|
||||
notesGroup.add(n);
|
||||
}
|
||||
|
||||
@@ -410,7 +442,7 @@ class Charter extends UIState {
|
||||
}
|
||||
|
||||
selectionBoxEnabled = false;
|
||||
} else if (selection.length > 0) {
|
||||
} else if (selection.length > 1) {
|
||||
selection = [];
|
||||
} else {
|
||||
// place note
|
||||
@@ -419,12 +451,13 @@ class Charter extends UIState {
|
||||
var note = new CharterNote();
|
||||
note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Std.int(mousePos.y / 40), id, 0, 0);
|
||||
notesGroup.add(note);
|
||||
selection = [note];
|
||||
addToUndo(CPlaceNote(note));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (FlxG.mouse.justReleasedRight)
|
||||
openContextMenu(topMenu[2].childs);
|
||||
openContextMenu(topMenu[1].childs);
|
||||
}
|
||||
selectionBox.visible = selectionBoxEnabled;
|
||||
}
|
||||
@@ -509,7 +542,7 @@ class Charter extends UIState {
|
||||
}
|
||||
charterCamera.scroll.set(conductorFollowerSpr.x + ((conductorFollowerSpr.scale.x - FlxG.width) / 2), conductorFollowerSpr.y - (FlxG.height * 0.5));
|
||||
if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, 0.125))) {
|
||||
|
||||
charterBG.scale.set(1 / charterCamera.zoom, 1 / charterCamera.zoom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,6 +607,9 @@ class Charter extends UIState {
|
||||
notesGroup.remove(note, true);
|
||||
note.kill();
|
||||
selection.remove(note);
|
||||
case CSustainChange(changes):
|
||||
for(n in changes)
|
||||
n.note.updatePos(n.note.step, n.note.id, n.before, n.note.type);
|
||||
}
|
||||
if (v != null)
|
||||
redoList.insert(0, v);
|
||||
@@ -609,6 +645,9 @@ class Charter extends UIState {
|
||||
case CPlaceNote(note):
|
||||
notesGroup.add(note);
|
||||
note.revive();
|
||||
case CSustainChange(changes):
|
||||
for(n in changes)
|
||||
n.note.updatePos(n.note.step, n.note.id, n.after, n.note.type);
|
||||
}
|
||||
if (v != null)
|
||||
undoList.insert(0, v);
|
||||
@@ -670,8 +709,32 @@ class Charter extends UIState {
|
||||
t.icon = (Options.charterShowBeats = !Options.charterShowBeats) ? 1 : 0;
|
||||
beatSeparator.visible = Options.charterShowBeats;
|
||||
}
|
||||
|
||||
inline function _note_addsustain(t)
|
||||
changeNoteSustain(1);
|
||||
|
||||
inline function _note_subtractsustain(t)
|
||||
changeNoteSustain(-1);
|
||||
|
||||
#end
|
||||
|
||||
function changeNoteSustain(change:Float) {
|
||||
if (selection.length <= 0 || change == 0) return;
|
||||
|
||||
addToUndo(CSustainChange([
|
||||
for(n in selection) {
|
||||
var old:Float = n.susLength;
|
||||
n.updatePos(n.step, n.id, Math.max(n.susLength + change, 0));
|
||||
|
||||
{
|
||||
before: old,
|
||||
after: n.susLength,
|
||||
note: n
|
||||
};
|
||||
}
|
||||
]));
|
||||
}
|
||||
|
||||
public function playtestChart(time:Float = 0, opponentMode = false) {
|
||||
buildChart();
|
||||
PlayState.opponentMode = opponentMode;
|
||||
@@ -688,10 +751,11 @@ class Charter extends UIState {
|
||||
for(n in notesGroup.members) {
|
||||
var strLineID = Std.int(n.id / 4);
|
||||
if (PlayState.SONG.strumLines[strLineID] != null) {
|
||||
var time = Conductor.getTimeForStep(n.step);
|
||||
PlayState.SONG.strumLines[strLineID].notes.push({
|
||||
type: n.type,
|
||||
time: Conductor.getTimeForStep(n.step),
|
||||
sLen: n.susLength,
|
||||
time: time,
|
||||
sLen: Conductor.getTimeForStep(n.step + n.susLength) - time,
|
||||
id: n.id % 4
|
||||
});
|
||||
}
|
||||
@@ -704,6 +768,7 @@ class Charter extends UIState {
|
||||
|
||||
enum CharterChange {
|
||||
CPlaceNote(note:CharterNote);
|
||||
CSustainChange(notes:Array<NoteSustainChange>);
|
||||
CCreateNotes(notes:Array<CharterNote>);
|
||||
CDeleteNotes(notes:Array<CharterNote>);
|
||||
}
|
||||
@@ -715,4 +780,10 @@ enum CharterCopyboardObject {
|
||||
typedef CharterStrumline = {
|
||||
var strumLine:ChartStrumLine;
|
||||
var hitsounds:Bool;
|
||||
}
|
||||
|
||||
typedef NoteSustainChange = {
|
||||
var note:CharterNote;
|
||||
var before:Float;
|
||||
var after:Float;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ class CharterBackdrop extends FlxBackdrop {
|
||||
pixels.fillRect(new Rectangle(0, 0, 1, 160), 0xFFDDDDDD);
|
||||
pixels.fillRect(new Rectangle(159, 0, 1, 160), 0xFFDDDDDD);
|
||||
pixels.unlock();
|
||||
alpha = 0.9;
|
||||
// loadFrame(frame);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,18 @@ import flixel.util.FlxColor;
|
||||
class CharterNote extends UISprite {
|
||||
var angleTween:FlxTween;
|
||||
|
||||
private static var colors:Array<FlxColor> = [
|
||||
0xFFC24B99,
|
||||
0xFF00FFFF,
|
||||
0xFF12FA05,
|
||||
0xFFF9393F
|
||||
];
|
||||
|
||||
public var sustainSpr:FlxSprite;
|
||||
public var selected:Bool = false;
|
||||
|
||||
var __doAnim:Bool = false;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
antialiasing = true;
|
||||
@@ -18,11 +28,13 @@ class CharterNote extends UISprite {
|
||||
animation.play("note");
|
||||
this.setUnstretchedGraphicSize(40, 40, false);
|
||||
|
||||
angle = 45; // green-red inbetween
|
||||
|
||||
cursor = BUTTON;
|
||||
|
||||
moves = false;
|
||||
|
||||
sustainSpr = new FlxSprite(10, 40);
|
||||
sustainSpr.makeGraphic(1, 1, -1);
|
||||
members.push(sustainSpr);
|
||||
}
|
||||
|
||||
public override function updateButton() {
|
||||
@@ -44,19 +56,33 @@ class CharterNote extends UISprite {
|
||||
this.id = id;
|
||||
this.susLength = susLength;
|
||||
this.type = type;
|
||||
|
||||
|
||||
x = id * 40;
|
||||
y = step * 40;
|
||||
|
||||
sustainSpr.scale.set(10, (40 * susLength));
|
||||
sustainSpr.updateHitbox();
|
||||
|
||||
if (angleTween != null) angleTween.cancel();
|
||||
|
||||
angleTween = FlxTween.tween(this, {angle: switch(animation.curAnim.curFrame = (id % 4)) {
|
||||
var destAngle = switch(animation.curAnim.curFrame = (id % 4)) {
|
||||
case 0: -90;
|
||||
case 1: 180;
|
||||
case 2: 0;
|
||||
case 3: 90;
|
||||
default: 0; // how is that even possible
|
||||
}}, 2/3, {ease: function(t) {
|
||||
};
|
||||
|
||||
sustainSpr.color = colors[animation.curAnim.curFrame];
|
||||
|
||||
if (!__doAnim) {
|
||||
angle = destAngle;
|
||||
return;
|
||||
}
|
||||
|
||||
if (angle == destAngle) return;
|
||||
|
||||
angleTween = FlxTween.tween(this, {angle: destAngle}, 2/3, {ease: function(t) {
|
||||
return ((Math.sin(t * Math.PI) * 0.35) * 3 * t * Math.sqrt(1 - t)) + t;
|
||||
}});
|
||||
}
|
||||
@@ -71,6 +97,7 @@ class CharterNote extends UISprite {
|
||||
case 3: 90;
|
||||
default: 0; // how is that even possible
|
||||
};
|
||||
__doAnim = false;
|
||||
}
|
||||
super.kill();
|
||||
}
|
||||
@@ -79,14 +106,24 @@ class CharterNote extends UISprite {
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
|
||||
sustainSpr.follow(this, 15, 20);
|
||||
|
||||
if (__passed != (__passed = step < Conductor.curStepFloat)) {
|
||||
alpha = __passed ? 0.6 : 1;
|
||||
if (__passed && FlxG.sound.music.playing && Charter.instance.hitsoundsEnabled(id))
|
||||
Charter.instance.hitsound.replay();
|
||||
}
|
||||
|
||||
sustainSpr.alpha = alpha;
|
||||
|
||||
colorTransform.redMultiplier = colorTransform.greenMultiplier = colorTransform.blueMultiplier = selected ? 0.75 : 1;
|
||||
colorTransform.redOffset = colorTransform.greenOffset = selected ? 96 : 0;
|
||||
colorTransform.blueOffset = selected ? 168 : 0;
|
||||
|
||||
__doAnim = true;
|
||||
}
|
||||
|
||||
public override function draw() {
|
||||
drawMembers();
|
||||
drawSuper();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class CharterNoteGroup extends FlxTypedGroup<CharterNote> {
|
||||
__loopSprite = null;
|
||||
|
||||
max = FlxG.height / 70 / camera.zoom;
|
||||
|
||||
|
||||
var oldCur = __currentlyLooping;
|
||||
__currentlyLooping = true;
|
||||
|
||||
@@ -23,7 +23,7 @@ class CharterNoteGroup extends FlxTypedGroup<CharterNote> {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (Math.abs(__loopSprite.step - Conductor.curStepFloat) < max)
|
||||
if (Math.abs(__loopSprite.step - Conductor.curStepFloat) - __loopSprite.susLength < max)
|
||||
noteFunc(__loopSprite);
|
||||
i++;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class CharterNoteGroup extends FlxTypedGroup<CharterNote> {
|
||||
public override function draw() {
|
||||
@:privateAccess var oldDefaultCameras = FlxCamera._defaultCameras;
|
||||
@:privateAccess if (cameras != null) FlxCamera._defaultCameras = cameras;
|
||||
|
||||
|
||||
forEach((n) -> n.draw());
|
||||
|
||||
@:privateAccess FlxCamera._defaultCameras = oldDefaultCameras;
|
||||
@@ -42,7 +42,7 @@ class CharterNoteGroup extends FlxTypedGroup<CharterNote> {
|
||||
public override function update(elapsed:Float) {
|
||||
@:privateAccess var oldDefaultCameras = FlxCamera._defaultCameras;
|
||||
@:privateAccess if (cameras != null) FlxCamera._defaultCameras = cameras;
|
||||
|
||||
|
||||
forEach((n) -> n.update(elapsed));
|
||||
|
||||
@:privateAccess FlxCamera._defaultCameras = oldDefaultCameras;
|
||||
|
||||
@@ -16,7 +16,7 @@ class UIButton extends UISliceSprite {
|
||||
field.borderSize = 1;
|
||||
field.alignment = CENTER;
|
||||
field.fieldWidth = w;
|
||||
|
||||
|
||||
cursor = BUTTON;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class MusicBeatState extends FlxTransitionableState implements IBeatReceiver
|
||||
/**
|
||||
* Whenever the Conductor auto update should be enabled or not.
|
||||
*/
|
||||
public var cancelConductorUpdate:Bool = false;
|
||||
public var cancelConductorUpdate:Bool = false;
|
||||
|
||||
/**
|
||||
* Current step
|
||||
@@ -148,6 +148,7 @@ class MusicBeatState extends FlxTransitionableState implements IBeatReceiver
|
||||
|
||||
public override function createPost() {
|
||||
super.createPost();
|
||||
persistentUpdate = true;
|
||||
call("postCreate");
|
||||
}
|
||||
public function call(name:String, ?args:Array<Dynamic>, ?defaultVal:Dynamic):Dynamic {
|
||||
|
||||
Reference in New Issue
Block a user