New add strumline button + editing + other charter bug fixes

This commit is contained in:
lunarcleint
2023-06-30 23:05:51 -07:00
parent 6f526476c7
commit b8643ad1f7
12 changed files with 279 additions and 61 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

@@ -34,7 +34,6 @@ class BaseGameParser {
position: "girlfriend",
notes: [],
visible: false,
strumLinePos: 0.5
});
}
+2 -1
View File
@@ -36,8 +36,9 @@ typedef ChartStrumLine = {
var type:ChartStrumLineType;
var notes:Array<ChartNote>;
var position:String;
var ?strumLinePos:Float; // 0.25 = default opponent pos, 0.75 = default boyfriend pos
var ?visible:Null<Bool>;
var ?strumPos:Array<Float>;
var ?strumScale:Float;
}
typedef ChartNote = {
@@ -46,12 +46,15 @@ class MainState extends FlxState {
EventsData.reloadEvents();
TitleState.initialized = false;
/*
if (betaWarningShown)
FlxG.switchState(new TitleState());
else {
FlxG.switchState(new BetaWarningState());
betaWarningShown = true;
}
*/
FlxG.switchState(new funkin.editors.charter.Charter("ultra field", "ultra-field"));
#if sys
sys.FileSystem.createDirectory('./.temp/');
+43 -28
View File
@@ -54,6 +54,7 @@ class Charter extends UIState {
public var topLimit:FlxSprite;
public var strumlineInfoBG:FlxSprite;
public var strumlineAddButton:CharterStrumlineAddButton;
public var hitsound:FlxSound;
public var metronome:FlxSound;
@@ -203,22 +204,6 @@ class Charter extends UIState {
}
]
},
{
label: "Strumline",
childs: [
{
label: "Create Strumline",
onSelect: function (_) {
createStrumline(strumLines.members.length, {
characters: [],
type: ADDITIONAL,
notes: [],
position: "girlfriend"
});
}
},
]
},
{
label: "Note",
childs: [
@@ -403,6 +388,9 @@ class Charter extends UIState {
strumlineInfoBG.y = 23;
strumlineInfoBG.scrollFactor.set();
strumlineAddButton = new CharterStrumlineAddButton();
strumlineAddButton.cameras = [charterCamera];
strumlineInfoBG.cameras = [charterCamera];
strumLines.cameras = [charterCamera];
@@ -422,6 +410,7 @@ class Charter extends UIState {
add(conductorFollowerSpr);
add(selectionBox);
add(strumlineInfoBG);
add(strumlineAddButton);
add(strumLines);
// add the top menu last OUT of the ui group so that it stays on top
add(topMenuSpr);
@@ -448,13 +437,6 @@ class Charter extends UIState {
for(strL in PlayState.SONG.strumLines)
createStrumline(strumLines.members.length, strL, false);
trace("sorting notes...");
notesGroup.sort(function(i, n1, n2) {
if (n1.step == n2.step)
return FlxSort.byValues(FlxSort.ASCENDING, n1.id, n2.id);
return FlxSort.byValues(FlxSort.ASCENDING, n1.step, n2.step);
});
trace("generating events...");
var __last:CharterEvent = null;
var __lastTime:Float = Math.NaN;
@@ -695,8 +677,6 @@ class Charter extends UIState {
// STRUMLINE DELETION/CREATION
public function createStrumline(strumLineID:Int, strL:ChartStrumLine, addToUndo:Bool = true) {
selection = []; // dont fuck with selected notes
var cStr = new CharterStrumline(strL);
strumLines.insert(strumLineID, cStr);
@@ -719,9 +699,10 @@ class Charter extends UIState {
}
public function deleteStrumline(strumLineID:Int, addToUndo:Bool = true) {
selection = []; // dont fuck with selected notes
removeStrumlineFromSelection(strumLineID);
var strL = strumLines.members[strumLineID].strumLine;
strumLines.members[strumLineID].destroy();
strumLines.members.remove(strumLines.members[strumLineID]);
var deletedstrumNotes:Array<CharterNote> = [];
@@ -769,6 +750,32 @@ class Charter extends UIState {
return -1;
}
public function createStrumWithUI() {
FlxG.state.openSubState(new CharterStrumlineScreen(strumLines.members.length, null, (_) -> {
createStrumline(strumLines.members.length, _);
}));
}
public inline function deleteStrumlineFromData(strL:ChartStrumLine)
deleteStrumline(getStrumlineID(strL));
public inline function editStrumline(strL:ChartStrumLine) {
var strID = getStrumlineID(strL);
FlxG.state.openSubState(new CharterStrumlineScreen(strID, strL, (_) -> {
strumLines.members[strID].strumLine = _;
}));
}
public inline function removeStrumlineFromSelection(strumLineID:Int) {
var i = 0;
while(i < selection.length) {
var note = selection[i];
if (Std.int(note.id / 4) == strumLineID)
selection.remove(note);
else i++;
}
}
// UNDO/REDO LOGIC
#if REGION
public inline function addToUndo(c:CharterChange) {
@@ -779,8 +786,13 @@ class Charter extends UIState {
}
#end
public inline function sortNotes()
notesGroup.sort((i, c1, c2) -> FlxSort.byValues(i, c1.step, c2.step), FlxSort.ASCENDING);
public inline function sortNotes() {
notesGroup.sort(function(i, n1, n2) {
if (n1.step == n2.step)
return FlxSort.byValues(FlxSort.ASCENDING, n1.id, n2.id);
return FlxSort.byValues(FlxSort.ASCENDING, n1.step, n2.step);
});
}
#end
var __crochet:Float;
@@ -865,6 +877,9 @@ class Charter extends UIState {
str.x = id * 40 * 4;
str.y = strumlineInfoBG.y;
}
strumlineAddButton.x = strumLines.members.length * (40 * 4);
strumlineAddButton.y = strumlineInfoBG.y;
}
var zoom(default, set):Float = 0;
@@ -34,6 +34,7 @@ class CharterEventScreen extends UISubstateWindow {
super.create();
FlxG.sound.music.pause(); // prevent the song from continuing
Charter.instance.vocals.pause();
var bg:FlxSprite = new FlxSprite(windowSpr.x + 1, windowSpr.y + 31, Paths.image('editors/ui/scrollbar-bg'));
bg.setGraphicSize(30, windowSpr.bHeight - 32);
@@ -65,28 +65,6 @@ class CharterStrumlineButton extends UITopMenuButton {
public override function openContextMenu() {
contextMenu = [
{
label: "Player",
onSelect: function(_) {
strLine.strumLine.type = PLAYER;
},
icon: strLine.strumLine.type == PLAYER ? 1 : 0
},
{
label: "Opponent",
onSelect: function(_) {
strLine.strumLine.type = OPPONENT;
},
icon: strLine.strumLine.type == OPPONENT ? 1 : 0
},
{
label: "Additional",
onSelect: function(_) {
strLine.strumLine.type = ADDITIONAL;
},
icon: strLine.strumLine.type == ADDITIONAL ? 1 : 0
},
null,
{
label: "Visible",
onSelect: function(_) {
@@ -105,9 +83,15 @@ class CharterStrumlineButton extends UITopMenuButton {
},
null,
{
label: "Delete",
label: "Edit",
onSelect: function (_) {
Charter.instance.deleteStrumline(Charter.instance.getStrumlineID(strLine.strumLine));
Charter.instance.editStrumline(strLine.strumLine);
}
},
{
label: "Delete",
onSelect: function (_) {
Charter.instance.deleteStrumlineFromData(strLine.strumLine);
}
}
];
@@ -0,0 +1,50 @@
package funkin.editors.charter;
import flixel.math.FlxPoint;
class CharterStrumlineAddButton extends UISprite {
public var addButton:UISprite;
public var addText:UIText;
public override function new(?x:Float, ?y:Float) {
super();
scrollFactor.set(1, 0);
alpha = 0;
addButton = new UISprite();
addButton.loadGraphic(Paths.image("editors/charter/add-strumline"));
addButton.scale.set(0.75,0.75);
addButton.updateHitbox();
addButton.antialiasing = false;
members.push(addButton);
addText = new UIText(0,0, 160, "Add New");
addText.alignment = CENTER;
members.push(addText);
}
var addButtonScale:FlxPoint = FlxPoint.get(0,0);
public override function update(elapsed:Float) {
addButton.follow(this, ((40 * 4) - addButton.width) / 2, 18);
addText.follow(this, 0, 84);
super.update(elapsed);
addButton.__rect.x = addButton.x;
addButton.__rect.y = addButton.y;
addButton.__rect.width = addButton.width;
addButton.__rect.height = addButton.height;
if(UIState.state.isOverlapping(addButton, addButton.__rect)) {
addButtonScale.set(0.85, 0.85);
if (FlxG.mouse.justReleased) Charter.instance.createStrumWithUI();
}
else addButtonScale.set(0.75, 0.75);
addButton.scale.set(
FlxMath.lerp(addButton.scale.x, addButtonScale.x, 1/6),
FlxMath.lerp(addButton.scale.y, addButtonScale.y, 1/6)
);
}
}
@@ -0,0 +1,148 @@
package funkin.editors.charter;
import flixel.math.FlxPoint;
import funkin.game.Note;
import funkin.game.Character;
import funkin.game.HealthIcon;
import funkin.backend.chart.ChartData.ChartStrumLine;
class CharterStrumlineScreen extends UISubstateWindow {
public var strumLineID:Int = -1;
public var strumLine:ChartStrumLine;
public var charactersTextBox:UITextBox;
public var typeDropdown:UIDropDown;
public var stagePositionDropdown:UIDropDown;
public var hudScaleStepper:UINumericStepper;
public var hudXStepper:UINumericStepper;
public var hudYStepper:UINumericStepper;
public var characterIcons:Array<HealthIcon> = [];
public var saveButton:UIButton;
public var closeButton:UIButton;
private var onSave:ChartStrumLine -> Void = null;
public function new(strumLineID:Int, strumLine:ChartStrumLine, ?onSave:ChartStrumLine->Void) {
super();
this.strumLineID = strumLineID;
this.strumLine = strumLine;
if (onSave != null) this.onSave = onSave;
}
public override function create() {
var creatingStrumLine:Bool = strumLine == null;
if (creatingStrumLine)
strumLine = {
characters: ["dad"],
type: OPPONENT,
notes: [],
position: "dad",
visible: true
};
winTitle = creatingStrumLine ? 'Creating Strumline #$strumLineID' : 'Strumline #$strumLineID properties';
winWidth = 690; winHeight = 334;
FlxG.sound.music.pause();
Charter.instance.vocals.pause();
super.create();
function addLabelOn(ui:UISprite, text:String)
add(new UIText(ui.x, ui.y - 24, 0, text));
var title:UIText;
add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, creatingStrumLine ? "Create New Strumline" : "Edit Strumline Properties", 28));
charactersTextBox = new UITextBox(title.x, title.y + title.height + 38, strumLine.characters.join(", "));
charactersTextBox.onChange = (newChars:String) -> {
updateCharacterIcons([for (char in newChars.split(",")) char.trim()]);
};
add(charactersTextBox);
addLabelOn(charactersTextBox, "Characters");
updateCharacterIcons(strumLine.characters);
typeDropdown = new UIDropDown(charactersTextBox.x, charactersTextBox.y + 32 + 58, 200, 32, ["OPPONENT", "PLAYER", "ADDITIONAL"], strumLine.type);
add(typeDropdown);
addLabelOn(typeDropdown, "Type");
var stagePositionI = strumLine.position == null ? strumLine.type : ["DAD", "BOYFRIEND", "GIRLFRIEND"].indexOf(strumLine.position.toUpperCase());
stagePositionDropdown = new UIDropDown(typeDropdown.x + 200 - 32 + 26, typeDropdown.y, 200, 32, ["DAD", "BOYFRIEND", "GIRLFRIEND"], stagePositionI);
add(stagePositionDropdown);
addLabelOn(stagePositionDropdown, "Stage Position");
hudScaleStepper = new UINumericStepper(stagePositionDropdown.x + 200 - 32 + 26, stagePositionDropdown.y, strumLine.strumScale == null ? 1 : strumLine.strumScale, 0.001, 2, null, null, 74);
add(hudScaleStepper);
addLabelOn(hudScaleStepper, "Scale");
var startingPos:FlxPoint = strumLine.strumPos == null ? switch (strumLine.type) {
case 1: FlxPoint.get((FlxG.width * 0.75) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2), 50);
default: FlxPoint.get((FlxG.width * 0.25) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2), 50);
} : FlxPoint.get(strumLine.strumPos[0], strumLine.strumPos[1]);
hudXStepper = new UINumericStepper(hudScaleStepper.x + 80 - 32 + 26, hudScaleStepper.y, startingPos.x, 0.001, 2, null, null, 84);
add(hudXStepper);
addLabelOn(hudXStepper, "Hud Position (X,Y)");
add(new UIText(hudXStepper.x + 84 - 32 + 0, hudXStepper.y + 9, 0, ",", 22));
hudYStepper = new UINumericStepper(hudXStepper.x + 84 - 32 + 26, hudXStepper.y, startingPos.y, 0.001, 2, null, null, 84);
add(hudYStepper);
saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20 - 125, windowSpr.y + windowSpr.bHeight - 16 - 32, "Save & Close", function() {
saveStrumline();
close();
}, 125);
add(saveButton);
if (!creatingStrumLine) {
closeButton = new UIButton(saveButton.x - 20, saveButton.y, "Close", function() {
close();
}, 125);
add(closeButton);
closeButton.x -= closeButton.bWidth;
}
}
function updateCharacterIcons(characters:Array<String>) {
for (icon in characterIcons) {
remove(icon);
icon.destroy();
}
characterIcons = [];
for (i => char in characters) {
var iconSprite = new HealthIcon(Character.getIconFromCharName(char));
iconSprite.scrollFactor.set(1,1);
iconSprite.scale.set(0.5, 0.5);
iconSprite.updateHitbox();
iconSprite.setPosition(
charactersTextBox.x + 320 + 8 + ((iconSprite.width + 4) * i),
(charactersTextBox.y + 16) - (iconSprite.height/2)
);
add(iconSprite);
}
}
function saveStrumline() {
for (stepper in [hudXStepper, hudYStepper, hudScaleStepper])
@:privateAccess stepper.__onChange(stepper.label.text);
strumLine = {
characters: [for (char in charactersTextBox.label.text.split(",")) char.trim()],
type: typeDropdown.index,
notes: strumLine.notes,
position: ["DAD", "BOYFRIEND", "GIRLFRIEND"][stagePositionDropdown.index].toLowerCase(),
visible: strumLine.visible,
strumPos: [hudXStepper.value, hudYStepper.value],
strumScale: hudScaleStepper.value
};
if (onSave != null) onSave(strumLine);
}
}
@@ -35,7 +35,9 @@ class MetaDataScreen extends UISubstateWindow {
winWidth = 748 - 32 + 40;
super.create();
FlxG.sound.music.pause();
Charter.instance.vocals.pause();
function addLabelOn(ui:UISprite, text:String)
add(new UIText(ui.x, ui.y - 24, 0, text));
@@ -132,6 +134,9 @@ class MetaDataScreen extends UISubstateWindow {
}
public function saveMeta() {
for (stepper in [bpmStepper, stepsPerBeatStepper, beatsPerMesureStepper])
@:privateAccess stepper.__onChange(stepper.label.text);
PlayState.SONG.meta = {
name: songNameTextBox.label.text,
bpm: bpmStepper.value,
+11 -2
View File
@@ -622,8 +622,17 @@ class PlayState extends MusicBeatState
chars.push(char);
}
var strOffset:Float = strumLine.strumLinePos == null ? (strumLine.type == 1 ? 0.75 : 0.25) : strumLine.strumLinePos;
var strLine = new StrumLine(chars, strOffset, strumLine.type == 2 || (!coopMode && !((strumLine.type == 1 && !opponentMode) || (strumLine.type == 0 && opponentMode))), strumLine.type != 1, coopMode ? (strumLine.type == 1 ? controlsP1 : controlsP2) : controls);
var startingPos:FlxPoint = strumLine.strumPos == null ? switch (strumLine.type) {
case 1: FlxPoint.get((FlxG.width * 0.75) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2), this.strumLine.y);
default: FlxPoint.get((FlxG.width * 0.25) - ((Note.swagWidth * (strumLine.strumScale == null ? 1 : strumLine.strumScale)) * 2), this.strumLine.y);
} : FlxPoint.get(strumLine.strumPos[0], strumLine.strumPos[1]);
var strLine = new StrumLine(chars,
startingPos,
strumLine.strumScale == null ? 1 : strumLine.strumScale,
strumLine.type == 2 || (!coopMode && !((strumLine.type == 1 && !opponentMode) || (strumLine.type == 0 && opponentMode))),
strumLine.type != 1, coopMode ? (strumLine.type == 1 ? controlsP1 : controlsP2) : controls
);
strLine.cameras = [camHUD];
strLine.data = strumLine;
strLine.visible = (strumLine.visible != false);
+8 -5
View File
@@ -1,5 +1,6 @@
package funkin.game;
import flixel.math.FlxPoint;
import flixel.util.FlxSignal.FlxTypedSignal;
import funkin.backend.scripting.events.*;
@@ -81,12 +82,14 @@ class StrumLine extends FlxTypedGroup<Strum> {
private inline function set_ghostTapping(b:Bool):Bool
return this.ghostTapping = b;
private var strumOffset:Float = 0.25;
private var startingPos:FlxPoint = FlxPoint.get(0,0);
private var strumScale:Float = 1;
public function new(characters:Array<Character>, strumOffset:Float = 0.25, cpu:Bool = false, opponentSide:Bool = true, ?controls:Controls) {
public function new(characters:Array<Character>, startingPos:FlxPoint, strumScale:Float, cpu:Bool = false, opponentSide:Bool = true, ?controls:Controls) {
super();
this.characters = characters;
this.strumOffset = strumOffset;
this.startingPos = startingPos;
this.strumScale = strumScale;
this.cpu = cpu;
this.opponentSide = opponentSide;
this.controls = controls;
@@ -253,7 +256,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((FlxG.width * strumOffset) + (Note.swagWidth * (i - 2)), PlayState.instance.strumLine.y);
var babyArrow:Strum = new Strum(startingPos.x + ((Note.swagWidth * strumScale) * i), startingPos.y);
babyArrow.ID = i;
var event = PlayState.instance.scripts.event("onStrumCreation", EventManager.get(StrumCreationEvent).recycle(babyArrow, PlayState.instance.strumLines.members.indexOf(this), i, animPrefix));
@@ -266,7 +269,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
babyArrow.animation.addByPrefix('red', 'arrowRIGHT');
babyArrow.antialiasing = true;
babyArrow.setGraphicSize(Std.int(babyArrow.width * 0.7));
babyArrow.setGraphicSize(Std.int((babyArrow.width * 0.7) * strumScale));
babyArrow.animation.addByPrefix('static', 'arrow${event.animPrefix.toUpperCase()}');
babyArrow.animation.addByPrefix('pressed', '${event.animPrefix} press', 24, false);