Fix the sfx selection gui for playsound (#10095)

* fix the index used to get the sfx substring

* handle cases where the sxf variable is not a built-in

This prevents a crash that happened whenever the sfx
variable's name had less than 5 characters (4 before this
pr), since the substring method was called regardless of
the name's size.
This commit is contained in:
JeanJPNM 2024-08-06 21:27:25 -03:00 committed by GitHub
parent b4a1232407
commit 2ad38fc3b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2149,7 +2149,8 @@ public class LStatements{
table.button(b -> {
b.image(Icon.pencilSmall);
b.clicked(() -> showSelect(b, GlobalVars.soundNames.toArray(String.class), id.substring(4), t -> {
String soundName = id.startsWith("@sfx-") ? id.substring(5) : id;
b.clicked(() -> showSelect(b, GlobalVars.soundNames.toArray(String.class), soundName, t -> {
id = "@sfx-" + t;
rebuild(table);
}, 2, cell -> cell.size(160, 50)));