Minor cleanup + allow multiple extensions to be set with one string input

This commit is contained in:
parax0 2015-07-27 17:10:26 -04:00
parent 0577c8a0fa
commit d13d221165
2 changed files with 4 additions and 96 deletions

View File

@ -50,104 +50,12 @@ QMap<QString,QString> FilterMap = {
QString ExtensionFilterString(const QString& extension) QString ExtensionFilterString(const QString& extension)
{ {
QMap<QString,QString>::const_iterator it = FilterMap.find(extension); QMap<QString,QString>::const_iterator it = FilterMap.find(extension.toUpper());
if (it != FilterMap.end()) if (it != FilterMap.end())
return it.value(); return it.value();
else else
return "Unknown Extension (*." + extension + ")"; return "Unknown Extension (*." + extension + ")";
/*if (extension.isEmpty()) return gskInvalidFilterString;
extension = extension.toUpper();
switch (extension[0])
{
case 'A':
if (extension == "AFSM") return "AI Finite State Machine (*.AFSM)";
if (extension == "ANIM") return "Animation (*.ANIM)";
if (extension == "ANCS") return "Animation Character Set (*.ANCS)";
if (extension == "AGSC") return "Audio Group (*.AGSC)";
if (extension == "ATBL") return "Audio Lookup Table (*.ATBL)";
break;
case 'C':
if (extension[1] <= 'R')
{
if (extension == "CAUD") return "Audio Metadata (*.CAUD)";
if (extension == "CHAR") return "Character (*.CHAR)";
if (extension == "CINF") return "Skeleton (*.CINF)";
if (extension == "CMDL") return "Model (*.CMDL)";
if (extension == "CRSC") return "Collision Response Data (*.CRSC)";
}
else
{
if (extension == "CSKR") return "Skin Rules (*.CSKR)";
if (extension == "CSMP") return "Audio Sample (*.CSMP)";
if (extension == "CSNG") return "MIDI Data (*.CSNG)";
if (extension == "CTWK") return "Tweaks (*.CTWK)";
}
break;
case 'D':
if (extension == "DCLN") return "Collision Mesh (*.DCLN)";
if (extension == "DGRP") return "Dependency Group (*.DGRP)";
if (extension == "DPSC") return "Decal (*.DPSC)";
if (extension == "DSP") return "Music Track (*.DSP)";
if (extension == "DUMB") return "Binary Data Dump (*.DUMB)";
break;
case 'E':
if (extension == "ELSC") return "Electric Particle (*.ELSC)";
if (extension == "EVNT") return "Animation Event Data (*.EVNT)";
break;
case 'F':
if (extension == "FRME") return "GUI Frame (*.FRME)";
if (extension == "FSM2") return "AI Finite State Machine (*.FSM2)";
if (extension == "FONT") return "Font (*.FONT)";
break;
case 'H':
if (extension == "HINT") return "Hint System Data (*.HINT)";
break;
case 'M':
if (extension == "MAPA") return "Area Map (*.MAPA)";
if (extension == "MAPW") return "World Map (*.MAPW)";
if (extension == "MAPU") return "Universe Map (*.MAPU)";
if (extension == "MLVL") return "World (*.MLVL)";
if (extension == "MREA") return "Area (*.MREA)";
break;
case 'N':
if (extension == "NTWK") return "Tweaks (*.ntwk)";
break;
case 'P':
if (extension == "PATH") return "AI Navigation Mesh (*.PATH)";
if (extension == "PAK") return "Pack File (*.pak)";
if (extension == "PART") return "Particle (*.PART)";
break;
case 'S':
if (extension == "SAVW") return "World Save Data (*.SAVW)";
if (extension == "SCAN") return "Scannable Object Info (*.SCAN)";
if (extension == "STRG") return "String Table (*.STRG)";
if (extension == "STRM") return "Audio Stream (*.STRM)";
if (extension == "SWHC") return "Swoosh Particle (*.SWHC)";
break;
case 'T':
if (extension == "THP") return "Video (*.thp)";
if (extension == "TXTR") return "Texture (*.TXTR)";
break;
case 'W':
if (extension == "WPSC") return "Projectile (*.WPSC)";
break;
}
return gskInvalidFilterString;*/
} }
} }

View File

@ -154,8 +154,8 @@ void WResourceSelector::SetResource(CResource *pRes)
void WResourceSelector::SetAllowedExtensions(const QString& extension) void WResourceSelector::SetAllowedExtensions(const QString& extension)
{ {
mSupportedExtensions.clear(); CStringList list = StringUtil::Tokenize(extension.toStdString(), ",");
mSupportedExtensions << extension; SetAllowedExtensions(list);
} }
void WResourceSelector::SetAllowedExtensions(const CStringList& extensions) void WResourceSelector::SetAllowedExtensions(const CStringList& extensions)
@ -209,7 +209,7 @@ void WResourceSelector::OnBrowseButtonClicked()
if (mSupportedExtensions.size() > 1) if (mSupportedExtensions.size() > 1)
{ {
QString all = "All supported extensions ("; QString all = "All allowed extensions (";
for (u32 iExt = 0; iExt < mSupportedExtensions.size(); iExt++) for (u32 iExt = 0; iExt < mSupportedExtensions.size(); iExt++)
{ {