From 5f67bd99d227b4cadfd5bac563793a0f899dbd8b Mon Sep 17 00:00:00 2001 From: bctix <51544115+bctix@users.noreply.github.com> Date: Wed, 5 Jul 2023 04:41:18 -0700 Subject: [PATCH] Added window to edit chart data, and added Scrollspeed to each StrumLine in chart data (#176) * edit chart data, and per strumline scrollspeed * forgot to delete a few things uh * almost forgor this * Change strum speed back to charts when disabled * value instead of label * set max scroll speed to 10 --- source/funkin/backend/chart/ChartData.hx | 1 + .../funkin/editors/charter/ChartDataScreen.hx | 61 +++++++++++++++++++ source/funkin/editors/charter/Charter.hx | 7 +++ .../editors/charter/CharterStrumlineScreen.hx | 36 ++++++++++- source/funkin/game/StrumLine.hx | 5 +- 5 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 source/funkin/editors/charter/ChartDataScreen.hx diff --git a/source/funkin/backend/chart/ChartData.hx b/source/funkin/backend/chart/ChartData.hx index 14eee4be..c142c2a1 100644 --- a/source/funkin/backend/chart/ChartData.hx +++ b/source/funkin/backend/chart/ChartData.hx @@ -39,6 +39,7 @@ typedef ChartStrumLine = { var ?visible:Null; var ?strumPos:Array; var ?strumScale:Float; + var ?scrollSpeed:Float; var ?strumLinePos:Float; // Backwards compatability } diff --git a/source/funkin/editors/charter/ChartDataScreen.hx b/source/funkin/editors/charter/ChartDataScreen.hx new file mode 100644 index 00000000..137820e7 --- /dev/null +++ b/source/funkin/editors/charter/ChartDataScreen.hx @@ -0,0 +1,61 @@ +package funkin.editors.charter; + +import funkin.backend.chart.ChartData; +import flixel.math.FlxPoint; +import funkin.backend.chart.ChartData.ChartMetaData; + +using StringTools; + +class ChartDataScreen extends UISubstateWindow { + public var data:ChartData; + public var saveButton:UIButton; + public var closeButton:UIButton; + + public var scrollSpeedStepper:UINumericStepper; + public var stageBox:UITextBox; + + public function new(data:ChartData) { + super(); + this.data = data; + } + + public override function 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)); + + winTitle = 'Editing chart data'; + winWidth = 420; winHeight = 69*4; // guys look, the funny numbers! + + super.create(); + + scrollSpeedStepper = new UINumericStepper(windowSpr.x + 20, windowSpr.y + 60, data.scrollSpeed, 0.1, 2, 0, 10, 82); + add(scrollSpeedStepper); + addLabelOn(scrollSpeedStepper, "Scroll Speed"); + + stageBox = new UITextBox(scrollSpeedStepper.x, scrollSpeedStepper.y + 60, PlayState.SONG.stage); + add(stageBox); + addLabelOn(stageBox, "Stage"); + + saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20 - 125, windowSpr.y + windowSpr.bHeight - 16 - 32, "Save & Close", function() { + onSave(); + close(); + }, 125); + add(saveButton); + + closeButton = new UIButton(saveButton.x - 20, saveButton.y, "Cancel", function() { + close(); + }, 125); + add(closeButton); + closeButton.x -= closeButton.bWidth; + } + + public function onSave() + { + PlayState.SONG.stage = stageBox.label.text; + PlayState.SONG.scrollSpeed = scrollSpeedStepper.value; + } + +} \ No newline at end of file diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 96057a43..a3cfee90 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -201,6 +201,11 @@ class Charter extends UIState { { label: "Edit metadata information", onSelect: chart_edit_metadata + }, + null, + { + label: "Edit chart data", + onSelect: chart_edit_data } ] }, @@ -1085,6 +1090,8 @@ class Charter extends UIState { } function chart_edit_metadata(_) FlxG.state.openSubState(new MetaDataScreen(PlayState.SONG.meta)); + function chart_edit_data(_) + FlxG.state.openSubState(new ChartDataScreen(PlayState.SONG)); function _playback_metronome(t) { t.icon = (Options.charterMetronomeEnabled = !Options.charterMetronomeEnabled) ? 1 : 0; diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index b67d40a7..91167d5c 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -16,6 +16,8 @@ class CharterStrumlineScreen extends UISubstateWindow { public var hudScaleStepper:UINumericStepper; public var hudXStepper:UINumericStepper; public var hudYStepper:UINumericStepper; + public var scrollSpeedStepper:UINumericStepper; + public var usesChartscrollSpeed:UICheckbox; public var characterIcons:Array = []; @@ -44,7 +46,7 @@ class CharterStrumlineScreen extends UISubstateWindow { }; winTitle = creatingStrumLine ? 'Creating Strumline #$strumLineID' : 'Strumline #$strumLineID properties'; - winWidth = 690; winHeight = 334; + winWidth = 690; winHeight = 390; FlxG.sound.music.pause(); Charter.instance.vocals.pause(); @@ -70,6 +72,37 @@ class CharterStrumlineScreen extends UISubstateWindow { add(typeDropdown); addLabelOn(typeDropdown, "Type"); + usesChartscrollSpeed = new UICheckbox(typeDropdown.x + 200 - 32 + 26, typeDropdown.y + 32 + 58, "Uses charts scroll speed?", strumLine.scrollSpeed == null); + usesChartscrollSpeed.onChecked = function(b) { + if(b) + { + scrollSpeedStepper.alpha = 0.4; + scrollSpeedStepper.label.alpha = 0.4; + scrollSpeedStepper.value = PlayState.SONG.scrollSpeed; + scrollSpeedStepper.active = false; + } else { + scrollSpeedStepper.alpha = 1; + scrollSpeedStepper.label.alpha = 1; + scrollSpeedStepper.active = true; + } + + } + add(usesChartscrollSpeed); + + scrollSpeedStepper = new UINumericStepper(typeDropdown.x, typeDropdown.y + 32 + 58, usesChartscrollSpeed.checked ? PlayState.SONG.scrollSpeed : strumLine.scrollSpeed, 0.1, 2, 0, 10, 82); + if(usesChartscrollSpeed.checked) + { + scrollSpeedStepper.alpha = 0.4; + scrollSpeedStepper.label.alpha = 0.4; + scrollSpeedStepper.active = false; + } else { + scrollSpeedStepper.alpha = 1; + scrollSpeedStepper.label.alpha = 1; + scrollSpeedStepper.active = true; + } + add(scrollSpeedStepper); + addLabelOn(scrollSpeedStepper, "Scroll Speed"); + 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); @@ -144,6 +177,7 @@ class CharterStrumlineScreen extends UISubstateWindow { strumPos: [hudXStepper.value, hudYStepper.value], strumScale: hudScaleStepper.value }; + if(!usesChartscrollSpeed.checked) strumLine.scrollSpeed = scrollSpeedStepper.value; if (onSave != null) onSave(strumLine); } } \ No newline at end of file diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index 2f0c6ebd..422c84b4 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -258,7 +258,10 @@ class StrumLine extends FlxTypedGroup { animPrefix = strumAnimPrefix[i % strumAnimPrefix.length]; var babyArrow:Strum = new Strum(startingPos.x + ((Note.swagWidth * strumScale) * i), startingPos.y); babyArrow.ID = i; - + + if(data.scrollSpeed != null) + babyArrow.scrollSpeed = data.scrollSpeed; + var event = PlayState.instance.scripts.event("onStrumCreation", EventManager.get(StrumCreationEvent).recycle(babyArrow, PlayState.instance.strumLines.members.indexOf(this), i, animPrefix)); if (!event.cancelled) {