From d13d221165be1294f252575e3b1646c193359ed0 Mon Sep 17 00:00:00 2001 From: parax0 Date: Mon, 27 Jul 2015 17:10:26 -0400 Subject: [PATCH] Minor cleanup + allow multiple extensions to be set with one string input --- UI/UICommon.cpp | 94 +--------------------------------------- UI/WResourceSelector.cpp | 6 +-- 2 files changed, 4 insertions(+), 96 deletions(-) diff --git a/UI/UICommon.cpp b/UI/UICommon.cpp index 5528f85f..77adf8a5 100644 --- a/UI/UICommon.cpp +++ b/UI/UICommon.cpp @@ -50,104 +50,12 @@ QMap FilterMap = { QString ExtensionFilterString(const QString& extension) { - QMap::const_iterator it = FilterMap.find(extension); + QMap::const_iterator it = FilterMap.find(extension.toUpper()); if (it != FilterMap.end()) return it.value(); else 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;*/ } } diff --git a/UI/WResourceSelector.cpp b/UI/WResourceSelector.cpp index 0b4e2225..99bb04e0 100644 --- a/UI/WResourceSelector.cpp +++ b/UI/WResourceSelector.cpp @@ -154,8 +154,8 @@ void WResourceSelector::SetResource(CResource *pRes) void WResourceSelector::SetAllowedExtensions(const QString& extension) { - mSupportedExtensions.clear(); - mSupportedExtensions << extension; + CStringList list = StringUtil::Tokenize(extension.toStdString(), ","); + SetAllowedExtensions(list); } void WResourceSelector::SetAllowedExtensions(const CStringList& extensions) @@ -209,7 +209,7 @@ void WResourceSelector::OnBrowseButtonClicked() if (mSupportedExtensions.size() > 1) { - QString all = "All supported extensions ("; + QString all = "All allowed extensions ("; for (u32 iExt = 0; iExt < mSupportedExtensions.size(); iExt++) {