Skip to content

Commit ccfa26e

Browse files
add recursive option to Character.getList, to include ones in folders for input text suggestions and to fix the character editor command not working with folders
1 parent 7181da2 commit ccfa26e

7 files changed

Lines changed: 26 additions & 13 deletions

File tree

assets/data/editors/layouts/stage/characterEditScreen.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
import funkin.game.Character;
9696

9797
var curCharBox = new UIAutoCompleteTextBox(col(2), charTypeY, char.curCharacter, 145, 32);
98-
curCharBox.suggestItems = Character.getList(false);
98+
curCharBox.suggestItems = Character.getList(false, false, null, true);
9999
self.add(curCharBox);
100100
</exec>
101101
</section>

source/funkin/backend/system/console/BuiltInCommands.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class BuiltInCommands {
152152
return;
153153
}
154154
var name:String = args[0];
155-
var list = Character.getList(false, true);
155+
var list = Character.getList(false, false, null, true);
156156
if (!list.contains(name)) {
157157
Logs.error('Character $name was not found.');
158158
return;

source/funkin/editors/charter/ChartCreationScreen.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class ChartCreationScreen extends UISubstateWindow {
3939
return text;
4040
}
4141

42-
charFileList = Character.getList(true);
43-
if (charFileList.length == 0) charFileList = Character.getList(false);
42+
charFileList = Character.getList(true, false, null, true);
43+
if (charFileList.length == 0) charFileList = Character.getList(false, false, null, true);
4444

4545
var chartTitle:UIText;
4646
add(chartTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, TU.translate("chartCreation.info"), 28));

source/funkin/editors/charter/CharterEventScreen.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class CharterEventScreen extends UISubstateWindow {
185185
dropdown;
186186
case TCharacter:
187187
addLabel();
188-
var charFileList = Character.getList(false);
188+
var charFileList = Character.getList(false, false, null, true);
189189
var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value);
190190
textBox.suggestItems = charFileList;
191191
paramsPanel.add(textBox); paramsFields.push(textBox);

source/funkin/editors/charter/CharterEventScreenNew.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class CharterEventScreenNew extends MusicBeatSubstate {
177177
dropdown;
178178
case TCharacter:
179179
addLabel();
180-
var charFileList = Character.getList(false);
180+
var charFileList = Character.getList(false, false, null, true);
181181
var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x+6, winHeight, cast value);
182182
textBox.suggestItems = charFileList;
183183
paramsPanel.add(textBox); paramsFields.push(textBox);

source/funkin/editors/charter/CharterStrumlineScreen.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ class CharterStrumlineScreen extends UISubstateWindow {
7373
var title:UIText;
7474
add(title = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, TU.translate("charterStrumlineScreen.title" + (creatingStrumLine ? "-creating" : "-editing")), 28));
7575

76-
var charFileList = Character.getList(true);
77-
if (charFileList.length == 0) charFileList = Character.getList(false);
76+
var charFileList = Character.getList(true, false, null, true);
77+
if (charFileList.length == 0) charFileList = Character.getList(false, false, null, true);
7878

7979
charactersList = new UIButtonList<CharacterButton>(15, title.y + title.height + 36, 250, 269, null, FlxPoint.get(250, 54), null, 0);
8080
charactersList.addButton.callback = () -> charactersList.add(new CharacterButton(0, 0, TU.translate("charterStrumLine.newChar"), charFileList, charactersList));

source/funkin/game/Character.hx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,17 +624,30 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
624624
return icon;
625625
}
626626

627-
public static function getList(?mods:Bool = false, includeFolders:Bool = false, folder:String = 'data/characters/'):Array<String> {
627+
public static function getList(?mods:Bool = false, includeFolders:Bool = false, ?folder:String = null, ?recursive:Bool = false):Array<String> {
628+
final defaultFolder:String = 'data/characters/';
629+
if (folder == null) folder = defaultFolder;
628630
var list:Array<String> = [];
629-
if(includeFolders) {
631+
if(includeFolders || recursive) {
630632
for (path in Paths.getFolderDirectories(folder, true, mods ? MODS : BOTH)) {
631633
if(!path.endsWith("/")) path += "/";
632-
list.push(path);
634+
if (recursive) {
635+
list = list.concat(Character.getList(mods, includeFolders, path, recursive));
636+
} else {
637+
list.push(path);
638+
}
633639
}
634640
}
635641
for (path in Paths.getFolderContent(folder, true, mods ? MODS : BOTH))
636-
if (Path.extension(path) == "xml")
637-
list.push(CoolUtil.getFilename(path));
642+
if (Path.extension(path) == "xml") {
643+
if (recursive) {
644+
var file:String = folder + CoolUtil.getFilename(path);
645+
if (file.startsWith(defaultFolder)) file = file.substr(defaultFolder.length);
646+
list.push(file);
647+
} else {
648+
list.push(CoolUtil.getFilename(path));
649+
}
650+
}
638651
return list;
639652
}
640653
}

0 commit comments

Comments
 (0)