note spacing option + reworked positioning

This commit is contained in:
TheZoroForce240
2024-08-28 19:49:10 +01:00
parent bef678a3a8
commit c6af3690fb
6 changed files with 37 additions and 19 deletions
+1
View File
@@ -40,6 +40,7 @@ typedef ChartStrumLine = {
var ?visible:Null<Bool>;
var ?strumPos:Array<Float>;
var ?strumScale:Float;
var ?strumSpacing:Float;
var ?scrollSpeed:Float;
var ?vocalsSuffix:String;
var ?keyCount:Int; // default=4
@@ -69,7 +69,7 @@ class ChartDataScreen extends UISubstateWindow {
strumLineCam.bgColor = 0;
strumLineCam.alpha = 0;
FlxG.cameras.add(strumLineCam, false);
previewStrumLine = new CharterPreviewStrumLine(96, 50, 1, 4, 0);
previewStrumLine = new CharterPreviewStrumLine(96, 50, 1, 1, 4, 0);
previewStrumLine.camera = strumLineCam;
add(previewStrumLine);
}
@@ -92,7 +92,7 @@ class ChartDataScreen extends UISubstateWindow {
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);
previewStrumLine.updatePos(96, 50, 1, 1, 4, scrollSpeed);
super.update(elapsed);
}
@@ -4,14 +4,14 @@ import funkin.game.Note;
class CharterPreviewStrumLine extends FlxTypedGroup<FlxSprite>
{
public function new(x:Float, y:Float, scale:Float, keyCount:Int, scrollSpeed:Float){
public function new(x:Float, y:Float, scale:Float, spacing:Float, keyCount:Int, scrollSpeed:Float){
super();
updatePos(x, y, scale, keyCount, scrollSpeed);
updatePos(x, y, scale, spacing, keyCount, scrollSpeed);
}
private var note:FlxSprite;
public function generateStrums(x:Float, y:Float, scale:Float, keyCount:Int, scrollSpeed:Float){
public function generateStrums(x:Float, y:Float, scale:Float, spacing:Float, keyCount:Int, scrollSpeed:Float){
for (member in members){
member.destroy();
}
@@ -44,14 +44,14 @@ class CharterPreviewStrumLine extends FlxTypedGroup<FlxSprite>
var noteTime:Float = FlxG.height;
var scroll:Float = 1.0;
public function updatePos(x:Float, y:Float, scale:Float, keyCount:Int, scrollSpeed:Float){
public function updatePos(x:Float, y:Float, scale:Float, spacing:Float, keyCount:Int, scrollSpeed:Float){
if (members.length-1 != keyCount) //strumline + note
generateStrums(x, y, scale, keyCount, scrollSpeed);
generateStrums(x, y, scale, spacing, 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.x = CoolUtil.fpsLerp(strum.x, x + (Note.swagWidth * scale * spacing * 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();
@@ -1,5 +1,6 @@
package funkin.editors.charter;
import funkin.game.StrumLine;
import flixel.math.FlxPoint;
import funkin.backend.chart.ChartData.ChartStrumLine;
import funkin.game.Character;
@@ -23,6 +24,7 @@ class CharterStrumlineScreen extends UISubstateWindow {
public var scrollSpeedStepper:UINumericStepper;
public var usesChartscrollSpeed:UICheckbox;
public var keyCountStepper:UINumericStepper;
public var hudSpacingStepper:UINumericStepper;
public var characterIcons:Array<HealthIcon> = [];
@@ -55,7 +57,7 @@ class CharterStrumlineScreen extends UISubstateWindow {
};
winTitle = creatingStrumLine ? 'Creating strumline #$strumLineID' : 'Editing strumline #$strumLineID properties';
winWidth = 690; winHeight = 400;
winWidth = 720; winHeight = 400;
FlxG.sound.music.pause();
Charter.instance.vocals.pause();
@@ -113,17 +115,21 @@ class CharterStrumlineScreen extends UISubstateWindow {
add(stagePositionDropdown);
addLabelOn(stagePositionDropdown, "Stage Position");
hudScaleStepper = new UINumericStepper(typeDropdown.x, typeDropdown.y + 64, strumLine.strumScale == null ? 1 : strumLine.strumScale, 0.001, 2, null, null, 74);
hudScaleStepper = new UINumericStepper(typeDropdown.x, typeDropdown.y + 64, strumLine.strumScale == null ? 1 : strumLine.strumScale, 0.001, 2, null, null, 84);
add(hudScaleStepper);
addLabelOn(hudScaleStepper, "Scale");
hudSpacingStepper = new UINumericStepper(hudScaleStepper.x + 80 - 32 + 26, hudScaleStepper.y, strumLine.strumSpacing != null ? strumLine.strumSpacing : 1, 0.001, 10, null, null, 84);
add(hudSpacingStepper);
addLabelOn(hudSpacingStepper, "Spacing");
var strOffset:Float = strumLine.strumLinePos == null ? (strumLine.type == 1 ? 0.75 : 0.25) : strumLine.strumLinePos;
var startingPos:FlxPoint = strumLine.strumPos == null ?
FlxPoint.get(strOffset, 50) :
FlxPoint.get(strOffset, strumLine.strumPos[1]);
hudXStepper = new UINumericStepper(hudScaleStepper.x + 80 - 32 + 26, hudScaleStepper.y, startingPos.x, 0.01, 2, 0, 2, 84);
hudXStepper = new UINumericStepper(hudSpacingStepper.x + 80, hudScaleStepper.y, startingPos.x, 0.01, 2, 0, 2, 84);
add(hudXStepper);
addLabelOn(hudXStepper, "Hud Position (X [Ratio 0-1],Y)");
@@ -165,7 +171,7 @@ 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, 1000, 84);
keyCountStepper = new UINumericStepper(stagePositionDropdown.x, vocalsSuffixDropDown.y, strumLine.keyCount != null ? strumLine.keyCount : 4, 1, 0, 1, 1000, 84);
add(keyCountStepper);
addLabelOn(keyCountStepper, "Key Count");
@@ -175,14 +181,14 @@ class CharterStrumlineScreen extends UISubstateWindow {
strumLineCam.bgColor = 0;
strumLineCam.alpha = 0;
FlxG.cameras.add(strumLineCam, false);
previewStrumLine = new CharterPreviewStrumLine(0, 0, 0, 4, 0);
previewStrumLine = new CharterPreviewStrumLine(0, 0, 0, 1, 4, 0);
previewStrumLine.camera = strumLineCam;
add(previewStrumLine);
FlxTween.tween(strumLineCam, {alpha: 1}, 0.25, {ease: FlxEase.cubeOut});
}
function saveStrumline() {
for (stepper in [hudXStepper, hudYStepper, hudScaleStepper, keyCountStepper])
for (stepper in [hudXStepper, hudYStepper, hudScaleStepper, keyCountStepper, hudSpacingStepper])
@:privateAccess stepper.__onChange(stepper.label.text);
var newStrumLine:ChartStrumLine = {
@@ -197,6 +203,7 @@ class CharterStrumlineScreen extends UISubstateWindow {
strumPos: [0, hudYStepper.value],
strumLinePos: hudXStepper.value,
strumScale: hudScaleStepper.value,
strumSpacing: hudSpacingStepper.value,
vocalsSuffix: vocalsSuffixDropDown.options[vocalsSuffixDropDown.index] != "NONE" ? vocalsSuffixDropDown.options[vocalsSuffixDropDown.index] : "",
keyCount: Std.int(keyCountStepper.value)
};
@@ -210,11 +217,13 @@ class CharterStrumlineScreen extends UISubstateWindow {
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);
var xOffset:Float = StrumLine.calculateStartingXPos(hudXStepper.value, hudScaleStepper.value, hudSpacingStepper.value, Std.int(keyCountStepper.value));
previewStrumLine.updatePos(xOffset, hudYStepper.value, hudScaleStepper.value, hudSpacingStepper.value, Std.int(keyCountStepper.value), scrollSpeed);
super.update(elapsed);
}
override public function destroy() {
super.destroy();
FlxTween.cancelTweensOf(strumLineCam);
+6 -2
View File
@@ -654,9 +654,13 @@ class PlayState extends MusicBeatState
}
var strOffset:Float = strumLine.strumLinePos == null ? (strumLine.type == 1 ? 0.75 : 0.25) : strumLine.strumLinePos;
var strumScale:Float = (strumLine.strumScale == null ? 1 : strumLine.strumScale);
var strumSpacing:Float = (strumLine.strumSpacing == null ? 1 : strumLine.strumSpacing);
var keyCount:Int = (strumLine.keyCount == null ? 4 : strumLine.keyCount);
var startingPos:FlxPoint = strumLine.strumPos == null ?
FlxPoint.get((FlxG.width * strOffset) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2), this.strumLine.y) :
FlxPoint.get(strumLine.strumPos[0] == 0 ? ((FlxG.width * strOffset) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2)) : strumLine.strumPos[0], strumLine.strumPos[1]);
FlxPoint.get(StrumLine.calculateStartingXPos(strOffset, strumScale, strumSpacing, keyCount), this.strumLine.y) :
FlxPoint.get(strumLine.strumPos[0] == 0 ? StrumLine.calculateStartingXPos(strOffset, strumScale, strumSpacing, keyCount) : strumLine.strumPos[0], strumLine.strumPos[1]);
var strLine = new StrumLine(chars,
startingPos,
strumLine.strumScale == null ? 1 : strumLine.strumScale,
+5 -1
View File
@@ -307,7 +307,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
public function createStrum(i:Int, ?animPrefix:String) {
if (animPrefix == null)
animPrefix = strumAnimPrefix[i % strumAnimPrefix.length];
var babyArrow:Strum = new Strum(startingPos.x + ((Note.swagWidth * strumScale * (4 / (data.keyCount != null ? data.keyCount : 4))) * i), startingPos.y);
var babyArrow:Strum = new Strum(startingPos.x + (Note.swagWidth * strumScale * (data.strumSpacing != null ? data.strumSpacing : 1) * i), startingPos.y);
babyArrow.ID = i;
babyArrow.strumLine = this;
@@ -367,6 +367,10 @@ class StrumLine extends FlxTypedGroup<Strum> {
}
}
public static inline function calculateStartingXPos(hudXRatio:Float, scale:Float, spacing:Float, keyCount:Int) {
return (FlxG.width * hudXRatio) - ((Note.swagWidth * scale * ((keyCount/2)-0.5) * spacing) + Note.swagWidth * 0.5 * scale);
}
/**
* SETTERS & GETTERS
*/