Various SCAN fixes + MP3 support
This commit is contained in:
parent
d13d221165
commit
836d1d404a
|
@ -18,6 +18,11 @@ EResType CScan::Type()
|
|||
return eScan;
|
||||
}
|
||||
|
||||
EGame CScan::Version()
|
||||
{
|
||||
return mVersion;
|
||||
}
|
||||
|
||||
CStringTable* CScan::ScanText()
|
||||
{
|
||||
return mpStringTable;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "CResource.h"
|
||||
#include "CStringTable.h"
|
||||
#include "EFormatVersion.h"
|
||||
#include <Core/CToken.h>
|
||||
|
||||
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();
|
||||
|
|
|
@ -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 ************
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<CScan*>(pRes);
|
||||
|
||||
|
@ -38,7 +44,12 @@ void WScanPreviewPanel::SetResource(CResource *pRes)
|
|||
if (pScan->IsImportant())
|
||||
ui->ScanTypeLabel->setText("<b><font color=\"red\">Important</font></b>");
|
||||
else
|
||||
ui->ScanTypeLabel->setText("<b><font color=\"orange\">Normal</font></b>");
|
||||
{
|
||||
if (pScan->Version() <= ePrime)
|
||||
ui->ScanTypeLabel->setText("<b><font color=\"#FF9030\">Normal</font></b>");
|
||||
else
|
||||
ui->ScanTypeLabel->setText("<b><font color=\"#A0A0FF\">Normal</font></b>");
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
|
@ -14,6 +14,7 @@ class WScanPreviewPanel : public IPreviewPanel
|
|||
public:
|
||||
explicit WScanPreviewPanel(QWidget *parent = 0);
|
||||
~WScanPreviewPanel();
|
||||
QSize sizeHint() const;
|
||||
EResType ResType();
|
||||
void SetResource(CResource *pRes);
|
||||
|
||||
|
|
|
@ -7,9 +7,15 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>114</height>
|
||||
<height>47</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
|
@ -27,7 +33,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<layout class="QHBoxLayout" name="ScanInfoLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
|
@ -41,7 +47,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="ScanTypeInfoLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="TypeInfoLabel">
|
||||
<property name="text">
|
||||
|
@ -59,7 +65,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="HorizSpacer1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -72,7 +78,38 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="ScanCategoryInfoLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="CategoryInfoLabel">
|
||||
<property name="text">
|
||||
<string>Logbook:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="ScanCategoryLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="HorizSpacer2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="ScanSpeedInfoLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="SpeedInfoLabel">
|
||||
<property name="text">
|
||||
|
@ -89,41 +126,10 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="LogbookInfoLabel">
|
||||
<property name="text">
|
||||
<string>Logbook:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="ScanCategoryLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<widget class="Line" name="Divider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -132,7 +138,7 @@
|
|||
<item>
|
||||
<widget class="WStringPreviewPanel" name="ScanTextWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
|
@ -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<CStringTable*>(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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue