//TODO: Use the much better-written MusicPanel populateDropdownBox to refactor this mess
@Override
protected void populateDropdownBox()
{
currentDropdown.removeAllItems();
Set heroList = new CopyOnWriteArraySet();
//Build list of heroes and populate dropwdown with it
File file = new File(vpkPath);
VPKArchive vpk = new VPKArchive();
System.out.println(file);
try
{
vpk.load(file);
}
catch (Exception ex)
{
System.err.println("Can't open archive: " + ex.getMessage());
return;
}
for (VPKEntry entry : vpk.getEntries())
{
if (entry.getPath().contains("scripts/game_sounds_heroes/"))
{
heroList.add(entry.getName());
}
}
//Format and prettify hero list
for (Object hero : heroList)
{
String heroString = hero.toString();
heroString = heroString.replace("game_sounds_", "");
NamedHero tempNamedHero = new NamedHero(heroString);
heroList.remove(hero);
heroList.add(tempNamedHero);
}
Object[] heroListArray = heroList.toArray();
Arrays.sort(heroListArray);
for (Object h : heroListArray)
{
NamedHero tempHero = (NamedHero) h;
currentDropdown.addItem(tempHero);