diff --git a/Resource/CScan.cpp b/Resource/CScan.cpp index ec076c32..ae37d359 100644 --- a/Resource/CScan.cpp +++ b/Resource/CScan.cpp @@ -18,6 +18,11 @@ EResType CScan::Type() return eScan; } +EGame CScan::Version() +{ + return mVersion; +} + CStringTable* CScan::ScanText() { return mpStringTable; diff --git a/Resource/CScan.h b/Resource/CScan.h index 26a29dd2..99c676e2 100644 --- a/Resource/CScan.h +++ b/Resource/CScan.h @@ -3,6 +3,7 @@ #include "CResource.h" #include "CStringTable.h" +#include "EFormatVersion.h" #include class CScan : public CResource @@ -21,6 +22,7 @@ public: }; private: + EGame mVersion; CResource *mpFrame; CStringTable *mpStringTable; CToken mFrameToken; @@ -33,6 +35,7 @@ public: CScan(); ~CScan(); EResType Type(); + EGame Version(); CStringTable* ScanText(); bool IsImportant(); bool IsSlow(); diff --git a/Resource/factory/CScanLoader.cpp b/Resource/factory/CScanLoader.cpp index 65609e23..074a19ca 100644 --- a/Resource/factory/CScanLoader.cpp +++ b/Resource/factory/CScanLoader.cpp @@ -15,6 +15,7 @@ CScan* CScanLoader::LoadScanMP1(CInputStream &SCAN) mpScan->mIsSlow = (SCAN.ReadLong() != 0); mpScan->mCategory = (CScan::ELogbookCategory) SCAN.ReadLong(); mpScan->mIsImportant = (SCAN.ReadByte() == 1); + mpScan->mVersion = ePrime; return mpScan; } @@ -60,7 +61,9 @@ CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN) case 0x14: LoadParamsMP2(SCAN); break; - + case 0x16: + LoadParamsMP3(SCAN); + break; default: Log::FileError(SCAN.GetSourceString(), SCAN.Tell() - 2, "Invalid SNFO property count: " + StringUtil::ToHexString(NumProperties)); delete mpScan; @@ -70,7 +73,7 @@ CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN) return mpScan; } -void CScanLoader::LoadParamsMP2(CInputStream &SCAN) +void CScanLoader::LoadParamsMP2(CInputStream& SCAN) { // Function begins after the SNFO property count for (u32 iProp = 0; iProp < 20; iProp++) @@ -93,11 +96,39 @@ void CScanLoader::LoadParamsMP2(CInputStream &SCAN) case 0x7B714814: mpScan->mIsImportant = (SCAN.ReadByte() != 0); break; + } - case 0x53336141: - u32 TextureID = SCAN.ReadLong(); - if (TextureID != 0xFFFFFFFF) - Log::FileWarning(SCAN.GetSourceString(), "SCAN with texture found!"); + SCAN.Seek(Next, SEEK_SET); + } + + mpScan->mCategory = CScan::eNone; + mpScan->mVersion = eEchoes; +} + +void CScanLoader::LoadParamsMP3(CInputStream& SCAN) +{ + // Function begins after the SNFO property count + // Function is near-identical to the MP2 one, but when I add support + // for the other params, there will be more differences + for (u32 iProp = 0; iProp < 20; iProp++) + { + u32 PropertyID = SCAN.ReadLong(); + u16 PropertySize = SCAN.ReadShort(); + u32 Next = SCAN.Tell() + PropertySize; + + switch (PropertyID) + { + case 0x2F5B6423: + mpScan->mpStringTable = (CStringTable*) gResCache.GetResource(SCAN.ReadLongLong(), "STRG"); + mpScan->mStringToken = CToken(mpScan->mpStringTable); + break; + + case 0xC308A322: + mpScan->mIsSlow = (SCAN.ReadLong() != 0); + break; + + case 0x7B714814: + mpScan->mIsImportant = (SCAN.ReadByte() != 0); break; } @@ -105,6 +136,7 @@ void CScanLoader::LoadParamsMP2(CInputStream &SCAN) } mpScan->mCategory = CScan::eNone; + mpScan->mVersion = eCorruption; } // ************ STATIC/PUBLIC ************ diff --git a/Resource/factory/CScanLoader.h b/Resource/factory/CScanLoader.h index 3a737ed6..9b88e6a3 100644 --- a/Resource/factory/CScanLoader.h +++ b/Resource/factory/CScanLoader.h @@ -13,6 +13,7 @@ class CScanLoader CScan* LoadScanMP1(CInputStream& SCAN); CScan* LoadScanMP2(CInputStream& SCAN); void LoadParamsMP2(CInputStream& SCAN); + void LoadParamsMP3(CInputStream& SCAN); public: static CScan* LoadSCAN(CInputStream& SCAN); diff --git a/UI/IPreviewPanel.cpp b/UI/IPreviewPanel.cpp index bab5cb68..eb394152 100644 --- a/UI/IPreviewPanel.cpp +++ b/UI/IPreviewPanel.cpp @@ -16,9 +16,9 @@ IPreviewPanel* IPreviewPanel::CreatePanel(EResType Type, QWidget *pParent) { switch (Type) { - case eTexture: return new WTexturePreviewPanel(pParent); + case eTexture: return new WTexturePreviewPanel(pParent); case eStringTable: return new WStringPreviewPanel(pParent); - case eScan: return new WScanPreviewPanel(pParent); + case eScan: return new WScanPreviewPanel(pParent); default: return nullptr; } } diff --git a/UI/WResourceSelector.cpp b/UI/WResourceSelector.cpp index 99bb04e0..e9276fa8 100644 --- a/UI/WResourceSelector.cpp +++ b/UI/WResourceSelector.cpp @@ -139,7 +139,7 @@ void WResourceSelector::SetResource(CResource *pRes) if (pRes) { mResourceValid = HasSupportedExtension(pRes); - mUI.LineEdit->setText(QString::fromStdString(pRes->Source())); + mUI.LineEdit->setText(QString::fromStdString(pRes->FullSource())); } else @@ -272,6 +272,7 @@ void WResourceSelector::LoadResource(const QString& ResPath) { mpResource = gResCache.GetResource(pathStr); mResToken = CToken(mpResource); + mResourceValid = (mpResource != nullptr); if (mPreviewPanelValid) mpPreviewPanel->SetResource(mpResource); } @@ -287,6 +288,7 @@ void WResourceSelector::LoadResource(const QString& ResPath) void WResourceSelector::CreatePreviewPanel() { delete mpPreviewPanel; + mpPreviewPanel = nullptr; if (mResourceValid) mpPreviewPanel = IPreviewPanel::CreatePanel(mpResource->Type(), this); diff --git a/UI/WScanPreviewPanel.cpp b/UI/WScanPreviewPanel.cpp index b1eca7a0..cc55b81b 100644 --- a/UI/WScanPreviewPanel.cpp +++ b/UI/WScanPreviewPanel.cpp @@ -8,8 +8,9 @@ WScanPreviewPanel::WScanPreviewPanel(QWidget *parent) : ui(new Ui::WScanPreviewPanel) { ui->setupUi(this); + ui->ScanTextWidget->setFrameShape(QFrame::NoFrame); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum ); + ui->ScanTextWidget->layout()->setContentsMargins(9,0,9,9); } WScanPreviewPanel::~WScanPreviewPanel() @@ -17,6 +18,11 @@ WScanPreviewPanel::~WScanPreviewPanel() delete ui; } +QSize WScanPreviewPanel::sizeHint() const +{ + return QSize(400, 0); +} + EResType WScanPreviewPanel::ResType() { return eScan; @@ -30,7 +36,7 @@ void WScanPreviewPanel::SetResource(CResource *pRes) ui->ScanCategoryLabel->clear(); // Set up new UI - if (pRes->Type() == eScan) + if (pRes && (pRes->Type() == eScan)) { CScan *pScan = static_cast(pRes); @@ -38,7 +44,12 @@ void WScanPreviewPanel::SetResource(CResource *pRes) if (pScan->IsImportant()) ui->ScanTypeLabel->setText("Important"); else - ui->ScanTypeLabel->setText("Normal"); + { + if (pScan->Version() <= ePrime) + ui->ScanTypeLabel->setText("Normal"); + else + ui->ScanTypeLabel->setText("Normal"); + } // Scan speed if (pScan->IsSlow()) @@ -68,6 +79,19 @@ void WScanPreviewPanel::SetResource(CResource *pRes) // Scan text ui->ScanTextWidget->SetResource(pScan->ScanText()); + + // Show logbook category? (Yes on MP1, no on MP2+) + if (pScan->Version() <= ePrime) + { + ui->CategoryInfoLabel->show(); + ui->ScanCategoryLabel->show(); + } + + else + { + ui->CategoryInfoLabel->hide(); + ui->ScanCategoryLabel->hide(); + } } else diff --git a/UI/WScanPreviewPanel.h b/UI/WScanPreviewPanel.h index 5e613cd4..f5a406cf 100644 --- a/UI/WScanPreviewPanel.h +++ b/UI/WScanPreviewPanel.h @@ -14,6 +14,7 @@ class WScanPreviewPanel : public IPreviewPanel public: explicit WScanPreviewPanel(QWidget *parent = 0); ~WScanPreviewPanel(); + QSize sizeHint() const; EResType ResType(); void SetResource(CResource *pRes); diff --git a/UI/WScanPreviewPanel.ui b/UI/WScanPreviewPanel.ui index 266af950..485cfb12 100644 --- a/UI/WScanPreviewPanel.ui +++ b/UI/WScanPreviewPanel.ui @@ -7,9 +7,15 @@ 0 0 400 - 114 + 47 + + + 0 + 0 + + Form @@ -27,7 +33,7 @@ 0 - + 9 @@ -41,7 +47,7 @@ 0 - + @@ -59,7 +65,7 @@ - + Qt::Horizontal @@ -72,7 +78,38 @@ - + + + + + Logbook: + + + + + + + TextLabel + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -89,41 +126,10 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Logbook: - - - - - - - TextLabel - - - - - - + Qt::Horizontal @@ -132,7 +138,7 @@ - + 0 1 diff --git a/UI/WStringPreviewPanel.cpp b/UI/WStringPreviewPanel.cpp index e8430304..41a2479b 100644 --- a/UI/WStringPreviewPanel.cpp +++ b/UI/WStringPreviewPanel.cpp @@ -11,16 +11,17 @@ WStringPreviewPanel::WStringPreviewPanel(QWidget *pParent) : IPreviewPanel(pPare mpLayout->setAlignment(Qt::AlignTop); mpLayout->addWidget(mpTextLabel); setLayout(mpLayout); - - QFontMetrics metrics(mpTextLabel->font()); - this->resize(400, 100); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); } WStringPreviewPanel::~WStringPreviewPanel() { } +QSize WStringPreviewPanel::sizeHint() const +{ + return QSize(400, 0); +} + EResType WStringPreviewPanel::ResType() { return eStringTable; @@ -30,23 +31,17 @@ void WStringPreviewPanel::SetResource(CResource *pRes) { mpTextLabel->clear(); - if ((pRes) && (pRes->Type() == eStringTable)) + if (pRes && (pRes->Type() == eStringTable)) { CStringTable *pString = static_cast(pRes); QString text; - // Build text string using first four strings from table (or less if there aren't 4) - u32 numStrings = (pString->GetStringCount() < 4 ? pString->GetStringCount() : 4); - for (u32 iStr = 0; iStr < numStrings; iStr++) + for (u32 iStr = 0; iStr < pString->GetStringCount(); iStr++) { + if (iStr > 0) text += "\n"; text += QString::fromStdWString(pString->GetString(0, iStr)); - text += "\n"; } - // Build text layout to determine where to elide the label - QTextLayout layout(text); - - mpTextLabel->setText(text); } } diff --git a/UI/WStringPreviewPanel.h b/UI/WStringPreviewPanel.h index bf169617..493ec5a1 100644 --- a/UI/WStringPreviewPanel.h +++ b/UI/WStringPreviewPanel.h @@ -12,11 +12,11 @@ class WStringPreviewPanel : public IPreviewPanel QLabel *mpTextLabel; QVBoxLayout *mpLayout; - QSpacerItem *mpSpacer; public: explicit WStringPreviewPanel(QWidget *pParent = 0); ~WStringPreviewPanel(); + QSize sizeHint() const; EResType ResType(); void SetResource(CResource *pRes); };