reveted back LocalResourceParse.cpp
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
60d0013bc4
commit
130abdc562
@ -19,7 +19,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QObject>
|
||||
|
||||
#include "LocalResourceParse.h"
|
||||
|
||||
@ -30,19 +30,25 @@
|
||||
#include "LocalTexturePackParseTask.h"
|
||||
#include "LocalWorldSaveParseTask.h"
|
||||
|
||||
static const QMap<PackedResourceType, QString> s_packed_type_names = { { PackedResourceType::ResourcePack, QObject::tr("resource pack") },
|
||||
{ PackedResourceType::TexturePack, QObject::tr("texture pack") },
|
||||
{ PackedResourceType::DataPack, QObject::tr("data pack") },
|
||||
{ PackedResourceType::ShaderPack, QObject::tr("shader pack") },
|
||||
{ PackedResourceType::WorldSave, QObject::tr("world save") },
|
||||
{ PackedResourceType::Mod, QObject::tr("mod") },
|
||||
{ PackedResourceType::UNKNOWN, QObject::tr("unknown") } };
|
||||
|
||||
static const QMap<PackedResourceType, QString> s_packed_type_names = {
|
||||
{PackedResourceType::ResourcePack, QObject::tr("resource pack")},
|
||||
{PackedResourceType::TexturePack, QObject::tr("texture pack")},
|
||||
{PackedResourceType::DataPack, QObject::tr("data pack")},
|
||||
{PackedResourceType::ShaderPack, QObject::tr("shader pack")},
|
||||
{PackedResourceType::WorldSave, QObject::tr("world save")},
|
||||
{PackedResourceType::Mod , QObject::tr("mod")},
|
||||
{PackedResourceType::UNKNOWN, QObject::tr("unknown")}
|
||||
};
|
||||
|
||||
namespace ResourceUtils {
|
||||
PackedResourceType identify(QFileInfo file)
|
||||
{
|
||||
PackedResourceType identify(QFileInfo file){
|
||||
if (file.exists() && file.isFile()) {
|
||||
if (ResourcePackUtils::validate(file)) {
|
||||
if (ModUtils::validate(file)) {
|
||||
// mods can contain resource and data packs so they must be tested first
|
||||
qDebug() << file.fileName() << "is a mod";
|
||||
return PackedResourceType::Mod;
|
||||
} else if (ResourcePackUtils::validate(file)) {
|
||||
qDebug() << file.fileName() << "is a resource pack";
|
||||
return PackedResourceType::ResourcePack;
|
||||
} else if (TexturePackUtils::validate(file)) {
|
||||
@ -57,12 +63,8 @@ PackedResourceType identify(QFileInfo file)
|
||||
} else if (ShaderPackUtils::validate(file)) {
|
||||
qDebug() << file.fileName() << "is a shader pack";
|
||||
return PackedResourceType::ShaderPack;
|
||||
} else if (ModUtils::validate(file)) {
|
||||
// mods should be already filtered out by the API response
|
||||
qDebug() << file.fileName() << "is a mod";
|
||||
return PackedResourceType::Mod;
|
||||
} else {
|
||||
qDebug() << "Can't Identify" << file.fileName();
|
||||
qDebug() << "Can't Identify" << file.fileName() ;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Can't find" << file.absolutePath();
|
||||
@ -70,9 +72,8 @@ PackedResourceType identify(QFileInfo file)
|
||||
return PackedResourceType::UNKNOWN;
|
||||
}
|
||||
|
||||
QString getPackedTypeName(PackedResourceType type)
|
||||
{
|
||||
QString getPackedTypeName(PackedResourceType type) {
|
||||
return s_packed_type_names.constFind(type).value();
|
||||
}
|
||||
|
||||
} // namespace ResourceUtils
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user