diff --git a/source/funkin/editors/charter/ChartDataScreen.hx b/source/funkin/editors/charter/ChartDataScreen.hx index 175a51c4..d05f5d0f 100644 --- a/source/funkin/editors/charter/ChartDataScreen.hx +++ b/source/funkin/editors/charter/ChartDataScreen.hx @@ -1,5 +1,6 @@ package funkin.editors.charter; +import funkin.game.Stage; import funkin.backend.chart.ChartData; import flixel.math.FlxPoint; import funkin.backend.chart.ChartData.ChartMetaData; @@ -12,7 +13,7 @@ class ChartDataScreen extends UISubstateWindow { public var closeButton:UIButton; public var scrollSpeedStepper:UINumericStepper; - public var stageTextBox:UITextBox; + public var stageTextBox:UIAutoCompleteTextBox; public function new(data:ChartData) { super(); @@ -34,7 +35,11 @@ class ChartDataScreen extends UISubstateWindow { var title:UIText; add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, "Edit Chart Data", 28)); - stageTextBox = new UITextBox(title.x, title.y + title.height + 38, PlayState.SONG.stage, 200); + var stageFileList = Stage.getList(true); + if (stageFileList.length == 0) stageFileList = Stage.getList(false); + + stageTextBox = new UIAutoCompleteTextBox(title.x, title.y + title.height + 38, PlayState.SONG.stage, 200); + stageTextBox.suggestItems = stageFileList; add(stageTextBox); addLabelOn(stageTextBox, "Stage"); diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index 57914860..e6a04399 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -59,7 +59,9 @@ class CharterStrumlineScreen extends UISubstateWindow { var title:UIText; add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, creatingStrumLine ? "Create New Strumline" : "Edit Strumline Properties", 28)); - var charFileList = Character.getList(false); + var charFileList = Character.getList(true); + if (charFileList.length == 0) charFileList = Character.getList(false); + charactersList = new UIButtonList(15, title.y + title.height + 36, 250, 259, "", FlxPoint.get(250, 54), null, 0); charactersList.addButton.callback = () -> charactersList.add(new CharacterButton(0, 0, "New Char", charFileList, charactersList)); charactersList.cameraSpacing = 0; @@ -133,7 +135,6 @@ class CharterStrumlineScreen extends UISubstateWindow { }, 125); add(closeButton); closeButton.color = 0xFFFF0000; - closeButton.x -= closeButton.bWidth; } function saveStrumline() { diff --git a/source/funkin/editors/ui/UIAutoCompleteTextBox.hx b/source/funkin/editors/ui/UIAutoCompleteTextBox.hx index 8686bd31..091efc7c 100644 --- a/source/funkin/editors/ui/UIAutoCompleteTextBox.hx +++ b/source/funkin/editors/ui/UIAutoCompleteTextBox.hx @@ -63,10 +63,11 @@ class UIAutoCompleteTextBox extends UITextBox { _suggestions = []; if(text.length > 0) { for(i in suggestItems) if(!_suggestions.contains(i) && i.startsWith(text)) _suggestions.push(i); - //for(i in suggestItems) if(!_suggestions.contains(i) && i.contains(text)) _suggestions.push(i); - _suggestions.remove(text); + + // Clean up suggestions + for(i in suggestItems) if(i == text) {_suggestions = [];} + if (_suggestions.length > 0) _suggestions.sort(function(a, b) return a.length - b.length); } - _suggestions.sort(function(a, b) return a.length - b.length); } if(suggestionText.visible = (_suggestions.length != 0)) { diff --git a/source/funkin/editors/ui/UITextBox.hx b/source/funkin/editors/ui/UITextBox.hx index 17f7222e..9e7dae4f 100644 --- a/source/funkin/editors/ui/UITextBox.hx +++ b/source/funkin/editors/ui/UITextBox.hx @@ -140,7 +140,6 @@ class UITextBox extends UISliceSprite implements IUIFocusable { } // untested, but this should be a fix for if the text wont type public function onTextEdit(text:String, start:Int, end:Int):Void { - trace(text, start, end); label.text = label.text.substr(0, position) + text + label.text.substr(position); position += text.length; } diff --git a/source/funkin/game/Stage.hx b/source/funkin/game/Stage.hx index 70fd260f..f8c5f0ce 100644 --- a/source/funkin/game/Stage.hx +++ b/source/funkin/game/Stage.hx @@ -238,6 +238,17 @@ class Stage extends FlxBasic implements IBeatReceiver { public function stepHit(curStep:Int) {} public function measureHit(curMeasure:Int) {} + + public static function getList(?mods:Bool = false):Array { + var list:Array = []; + for (path in Paths.getFolderContent('data/stages/', true, mods ? MODS : BOTH)) + if (Path.extension(path) == "xml" || Path.extension(path) == "hx") { + var file:String = Path.withoutDirectory(Path.withoutExtension(path)); + if (!list.contains(file)) list.push(file); + } + + return list; + } } class StageCharPos extends FlxObject {