fix: improve handling of unrecognized pack formats
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
43a7af3f44
commit
bedd3c50b6
@ -23,8 +23,7 @@ void ResourcePack::setPackFormat(int new_format_id)
|
|||||||
QMutexLocker locker(&m_data_lock);
|
QMutexLocker locker(&m_data_lock);
|
||||||
|
|
||||||
if (!s_pack_format_versions.contains(new_format_id)) {
|
if (!s_pack_format_versions.contains(new_format_id)) {
|
||||||
qCritical() << "Error: Pack format '%1' is not a recognized resource pack id.";
|
qWarning() << "Pack format '%1' is not a recognized resource pack id!";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pack_format = new_format_id;
|
m_pack_format = new_format_id;
|
||||||
@ -71,10 +70,6 @@ QPixmap ResourcePack::image(QSize size)
|
|||||||
std::pair<Version, Version> ResourcePack::compatibleVersions() const
|
std::pair<Version, Version> ResourcePack::compatibleVersions() const
|
||||||
{
|
{
|
||||||
if (!s_pack_format_versions.contains(m_pack_format)) {
|
if (!s_pack_format_versions.contains(m_pack_format)) {
|
||||||
// Not having a valid pack format is fine if we didn't yet parse the .mcmeta file,
|
|
||||||
// but if we did and we still don't have a valid pack format, that's a bit concerning.
|
|
||||||
Q_ASSERT(!isResolved());
|
|
||||||
|
|
||||||
return { {}, {} };
|
return { {}, {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,12 +60,17 @@ QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const
|
|||||||
case NameColumn:
|
case NameColumn:
|
||||||
return m_resources[row]->name();
|
return m_resources[row]->name();
|
||||||
case PackFormatColumn: {
|
case PackFormatColumn: {
|
||||||
auto version_bounds = at(row)->compatibleVersions();
|
auto resource = at(row);
|
||||||
|
auto pack_format = resource->packFormat();
|
||||||
|
if (pack_format == 0)
|
||||||
|
return tr("Unrecognized");
|
||||||
|
|
||||||
|
auto version_bounds = resource->compatibleVersions();
|
||||||
if (version_bounds.first.toString().isEmpty())
|
if (version_bounds.first.toString().isEmpty())
|
||||||
return QString::number(at(row)->packFormat());
|
return QString::number(pack_format);
|
||||||
|
|
||||||
return QString("%1 (%2 - %3)")
|
return QString("%1 (%2 - %3)")
|
||||||
.arg(QString::number(at(row)->packFormat()), version_bounds.first.toString(), version_bounds.second.toString());
|
.arg(QString::number(pack_format), version_bounds.first.toString(), version_bounds.second.toString());
|
||||||
}
|
}
|
||||||
case DateColumn:
|
case DateColumn:
|
||||||
return m_resources[row]->dateTimeChanged();
|
return m_resources[row]->dateTimeChanged();
|
||||||
|
Loading…
Reference in New Issue
Block a user