preview strumline stuff
This commit is contained in:
@@ -4,6 +4,7 @@ import flixel.math.FlxPoint;
|
||||
import funkin.backend.chart.ChartData.ChartMetaData;
|
||||
import funkin.backend.chart.ChartData;
|
||||
import funkin.game.Stage;
|
||||
import funkin.game.HudCamera;
|
||||
|
||||
using StringTools;
|
||||
|
||||
@@ -15,6 +16,9 @@ class ChartDataScreen extends UISubstateWindow {
|
||||
public var scrollSpeedStepper:UINumericStepper;
|
||||
public var stageTextBox:UIAutoCompleteTextBox;
|
||||
|
||||
public var strumLineCam:HudCamera;
|
||||
public var previewStrumLine:CharterPreviewStrumLine;
|
||||
|
||||
public function new(data:ChartData) {
|
||||
super();
|
||||
this.data = data;
|
||||
@@ -59,6 +63,15 @@ class ChartDataScreen extends UISubstateWindow {
|
||||
add(closeButton);
|
||||
closeButton.color = 0xFFFF0000;
|
||||
closeButton.x -= closeButton.bWidth;
|
||||
|
||||
strumLineCam = new HudCamera();
|
||||
strumLineCam.downscroll = Options.downscroll;
|
||||
strumLineCam.bgColor = 0;
|
||||
strumLineCam.alpha = 0;
|
||||
FlxG.cameras.add(strumLineCam, false);
|
||||
previewStrumLine = new CharterPreviewStrumLine(96, 50, 1, 4, 0);
|
||||
previewStrumLine.camera = strumLineCam;
|
||||
add(previewStrumLine);
|
||||
}
|
||||
|
||||
public function saveInfo()
|
||||
@@ -72,4 +85,19 @@ class ChartDataScreen extends UISubstateWindow {
|
||||
|
||||
Charter.undos.addToUndo(CEditChartData(oldData, {stage: stageTextBox.label.text, speed: scrollSpeedStepper.value}));
|
||||
}
|
||||
|
||||
override public function update(elapsed:Float) {
|
||||
var scrollSpeed:Float = 0.0;
|
||||
if (scrollSpeedStepper.hovered || scrollSpeedStepper.focused)
|
||||
scrollSpeed = scrollSpeedStepper.value;
|
||||
|
||||
strumLineCam.alpha = CoolUtil.fpsLerp(strumLineCam.alpha, scrollSpeed == 0.0 ? 0.0 : 1.0, 0.2);
|
||||
previewStrumLine.updatePos(96, 50, 1, 4, scrollSpeed);
|
||||
|
||||
super.update(elapsed);
|
||||
}
|
||||
override public function destroy() {
|
||||
super.destroy();
|
||||
FlxG.cameras.remove(strumLineCam);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package funkin.editors.charter;
|
||||
|
||||
import funkin.game.Note;
|
||||
|
||||
class CharterPreviewStrumLine extends FlxTypedGroup<FlxSprite>
|
||||
{
|
||||
public function new(x:Float, y:Float, scale:Float, keyCount:Int, scrollSpeed:Float){
|
||||
super();
|
||||
updatePos(x, y, scale, keyCount, scrollSpeed);
|
||||
}
|
||||
|
||||
private var note:FlxSprite;
|
||||
|
||||
public function generateStrums(x:Float, y:Float, scale:Float, keyCount:Int, scrollSpeed:Float){
|
||||
for (member in members){
|
||||
member.destroy();
|
||||
}
|
||||
clear();
|
||||
|
||||
var strumAnimPrefix = ["left", "down", "up", "right"];
|
||||
for (i in 0...keyCount){
|
||||
var strum = new FlxSprite();
|
||||
strum.frames = Paths.getFrames("game/notes/default");
|
||||
strum.setGraphicSize(Std.int((strum.width * 0.7) * scale));
|
||||
strum.updateHitbox();
|
||||
|
||||
var animPrefix = strumAnimPrefix[i % 4];
|
||||
strum.animation.addByPrefix('static', 'arrow${animPrefix.toUpperCase()}');
|
||||
strum.animation.play('static');
|
||||
strum.alpha = 0.4;
|
||||
add(strum);
|
||||
}
|
||||
|
||||
note = new FlxSprite();
|
||||
note.frames = Paths.getFrames("game/notes/default");
|
||||
note.setGraphicSize(Std.int((note.width * 0.7) * scale));
|
||||
note.updateHitbox();
|
||||
note.animation.addByPrefix('purple', 'purple0');
|
||||
note.animation.play('purple');
|
||||
note.alpha = 0.4;
|
||||
add(note);
|
||||
}
|
||||
|
||||
var noteTime:Float = FlxG.height;
|
||||
var scroll:Float = 1.0;
|
||||
|
||||
public function updatePos(x:Float, y:Float, scale:Float, keyCount:Int, scrollSpeed:Float){
|
||||
if (members.length-1 != keyCount) //strumline + note
|
||||
generateStrums(x, y, scale, keyCount, scrollSpeed);
|
||||
|
||||
for (i in 0...keyCount){
|
||||
var strum = members[i];
|
||||
|
||||
strum.x = CoolUtil.fpsLerp(strum.x, x + ((Note.swagWidth * scale * (4 / keyCount)) * i), 0.2);
|
||||
strum.y = CoolUtil.fpsLerp(strum.y, y, 0.2);
|
||||
strum.scale.x = strum.scale.y = CoolUtil.fpsLerp(strum.scale.x, 0.7 * scale, 0.2);
|
||||
strum.updateHitbox();
|
||||
}
|
||||
|
||||
|
||||
scroll = CoolUtil.fpsLerp(scroll, scrollSpeed, 0.2);
|
||||
noteTime -= FlxG.elapsed * scroll * 1000 * 0.45;
|
||||
if (noteTime <= 0.0)
|
||||
noteTime = FlxG.height;
|
||||
|
||||
note.x = members[0].x;
|
||||
note.y = members[0].y + noteTime;
|
||||
note.scale.x = note.scale.y = members[0].scale.x;
|
||||
note.updateHitbox();
|
||||
note.alpha = CoolUtil.fpsLerp(note.alpha, scrollSpeed == 0.0 ? 0.0 : 0.4, 0.2);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,10 @@ package funkin.editors.charter;
|
||||
import flixel.math.FlxPoint;
|
||||
import funkin.backend.chart.ChartData.ChartStrumLine;
|
||||
import funkin.game.Character;
|
||||
import funkin.game.Note;
|
||||
import funkin.game.HudCamera;
|
||||
import funkin.game.HealthIcon;
|
||||
import flixel.tweens.FlxTween;
|
||||
|
||||
class CharterStrumlineScreen extends UISubstateWindow {
|
||||
public var strumLineID:Int = -1;
|
||||
@@ -26,6 +29,9 @@ class CharterStrumlineScreen extends UISubstateWindow {
|
||||
public var saveButton:UIButton;
|
||||
public var closeButton:UIButton;
|
||||
|
||||
public var strumLineCam:HudCamera;
|
||||
public var previewStrumLine:CharterPreviewStrumLine;
|
||||
|
||||
private var onSave:ChartStrumLine -> Void = null;
|
||||
|
||||
public function new(strumLineID:Int, strumLine:ChartStrumLine, ?onSave:ChartStrumLine->Void) {
|
||||
@@ -159,9 +165,20 @@ class CharterStrumlineScreen extends UISubstateWindow {
|
||||
add(vocalsSuffixDropDown);
|
||||
addLabelOn(vocalsSuffixDropDown, "Vocal Suffix");
|
||||
|
||||
keyCountStepper = new UINumericStepper(vocalsSuffixDropDown.x + 200 + 26, vocalsSuffixDropDown.y, strumLine.keyCount != null ? strumLine.keyCount : 4, 1, 0, 1, null, 84);
|
||||
keyCountStepper = new UINumericStepper(vocalsSuffixDropDown.x + 200 + 26, vocalsSuffixDropDown.y, strumLine.keyCount != null ? strumLine.keyCount : 4, 1, 0, 1, 1000, 84);
|
||||
add(keyCountStepper);
|
||||
addLabelOn(keyCountStepper, "Key Count");
|
||||
|
||||
|
||||
strumLineCam = new HudCamera();
|
||||
strumLineCam.downscroll = Options.downscroll;
|
||||
strumLineCam.bgColor = 0;
|
||||
strumLineCam.alpha = 0;
|
||||
FlxG.cameras.add(strumLineCam, false);
|
||||
previewStrumLine = new CharterPreviewStrumLine(0, 0, 0, 4, 0);
|
||||
previewStrumLine.camera = strumLineCam;
|
||||
add(previewStrumLine);
|
||||
FlxTween.tween(strumLineCam, {alpha: 1}, 0.25, {ease: FlxEase.cubeOut});
|
||||
}
|
||||
|
||||
function saveStrumline() {
|
||||
@@ -186,6 +203,23 @@ class CharterStrumlineScreen extends UISubstateWindow {
|
||||
if(!usesChartscrollSpeed.checked) newStrumLine.scrollSpeed = scrollSpeedStepper.value;
|
||||
if (onSave != null) onSave(newStrumLine);
|
||||
}
|
||||
|
||||
override public function update(elapsed:Float) {
|
||||
var scrollSpeed:Float = 0.0;
|
||||
if (usesChartscrollSpeed.hovered || scrollSpeedStepper.hovered || scrollSpeedStepper.focused)
|
||||
scrollSpeed = scrollSpeedStepper.value;
|
||||
|
||||
previewStrumLine.visible = visibleCheckbox.checked;
|
||||
var xOffset:Float = (FlxG.width * hudXStepper.value) - (Note.swagWidth * hudScaleStepper.value * 2);
|
||||
previewStrumLine.updatePos(xOffset, hudYStepper.value, hudScaleStepper.value, Std.int(keyCountStepper.value), scrollSpeed);
|
||||
|
||||
super.update(elapsed);
|
||||
}
|
||||
override public function destroy() {
|
||||
super.destroy();
|
||||
FlxTween.cancelTweensOf(strumLineCam);
|
||||
FlxG.cameras.remove(strumLineCam);
|
||||
}
|
||||
}
|
||||
|
||||
class CharacterButton extends UIButton {
|
||||
|
||||
Reference in New Issue
Block a user