int index = selectedIndex != null ? selectedIndex : 0;
for (int i = 0; i < options.length; i++) {
Object option = options[i];
if (option.equals(current))
index = i;
ListEntry entry = null;
if (option instanceof ListEntry) {
entry = (ListEntry) option;
entry = list.add(entry);
} else {
entry = new ListEntry(list);
// Simplify names for art items
String name = option instanceof com.scriptographer.ai.Item
? ((com.scriptographer.ai.Item) option).getName()
: null;
entry.setText(name != null ? name : option.toString());
}
}
if (index < 0)
index = 0;
else if (index >= options.length)