Added support for loading dependencies of EVNT and STRG
This commit is contained in:
parent
7f2cac6216
commit
11a7b86120
|
@ -313,7 +313,7 @@ public:
|
||||||
{
|
{
|
||||||
CharType Chr = At(iChar);
|
CharType Chr = At(iChar);
|
||||||
|
|
||||||
if (Chr >= 'a' && Chr <= 'z')
|
if (Chr >= CHAR_LITERAL('a') && Chr <= CHAR_LITERAL('z'))
|
||||||
Out[iChar] = Chr - 0x20;
|
Out[iChar] = Chr - 0x20;
|
||||||
else
|
else
|
||||||
Out[iChar] = Chr;
|
Out[iChar] = Chr;
|
||||||
|
@ -553,10 +553,10 @@ public:
|
||||||
// Now we can finally check the actual string and make sure all the characters are valid hex characters.
|
// Now we can finally check the actual string and make sure all the characters are valid hex characters.
|
||||||
for (u32 iChr = 0; iChr < Width; iChr++)
|
for (u32 iChr = 0; iChr < Width; iChr++)
|
||||||
{
|
{
|
||||||
char Chr = Str[iChr];
|
CharType Chr = Str[iChr];
|
||||||
if (!((Chr >= '0') && (Chr <= '9')) &&
|
if (!((Chr >= CHAR_LITERAL('0')) && (Chr <= CHAR_LITERAL('9'))) &&
|
||||||
!((Chr >= 'a') && (Chr <= 'f')) &&
|
!((Chr >= CHAR_LITERAL('a')) && (Chr <= CHAR_LITERAL('f'))) &&
|
||||||
!((Chr >= 'A') && (Chr <= 'F')))
|
!((Chr >= CHAR_LITERAL('A')) && (Chr <= CHAR_LITERAL('F'))))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,23 +832,23 @@ public:
|
||||||
// Static
|
// Static
|
||||||
static TBasicString<CharType> FromInt32(s32 Value, int Width = 0, int Base = 16)
|
static TBasicString<CharType> FromInt32(s32 Value, int Width = 0, int Base = 16)
|
||||||
{
|
{
|
||||||
std::basic_stringstream<CharType> sstream;
|
std::basic_stringstream<CharType> SStream;
|
||||||
sstream << std::setbase(Base) << std::setw(Width) << std::setfill(CHAR_LITERAL('0')) << Value;
|
SStream << std::setbase(Base) << std::setw(Width) << std::setfill(CHAR_LITERAL('0')) << Value;
|
||||||
return sstream.str();
|
return SStream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static TBasicString<CharType> FromInt64(s64 Value, int Width = 0, int Base = 16)
|
static TBasicString<CharType> FromInt64(s64 Value, int Width = 0, int Base = 16)
|
||||||
{
|
{
|
||||||
std::basic_stringstream<CharType> sstream;
|
std::basic_stringstream<CharType> SStream;
|
||||||
sstream << std::setbase(Base) << std::setw(Width) << std::setfill(CHAR_LITERAL('0')) << Value;
|
SStream << std::setbase(Base) << std::setw(Width) << std::setfill(CHAR_LITERAL('0')) << Value;
|
||||||
return sstream.str();
|
return SStream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static TBasicString<CharType> FromFloat(float Value, int MinDecimals = 1)
|
static TBasicString<CharType> FromFloat(float Value, int MinDecimals = 1)
|
||||||
{
|
{
|
||||||
std::basic_stringstream<CharType> sstream;
|
std::basic_stringstream<CharType> SStream;
|
||||||
sstream << Value;
|
SStream << Value;
|
||||||
_TString Out = sstream.str();
|
_TString Out = SStream.str();
|
||||||
|
|
||||||
int NumZeroes = Out.Size() - (Out.IndexOf(LITERAL(".")) + 1);
|
int NumZeroes = Out.Size() - (Out.IndexOf(LITERAL(".")) + 1);
|
||||||
|
|
||||||
|
@ -906,13 +906,13 @@ public:
|
||||||
|
|
||||||
static TBasicString<CharType> HexString(unsigned long Num, int Width = 8, bool AddPrefix = true, bool Uppercase = true)
|
static TBasicString<CharType> HexString(unsigned long Num, int Width = 8, bool AddPrefix = true, bool Uppercase = true)
|
||||||
{
|
{
|
||||||
std::basic_stringstream<CharType> sstream;
|
std::basic_stringstream<CharType> SStream;
|
||||||
sstream << std::hex << std::setw(Width) << std::setfill('0') << Num;
|
SStream << std::hex << std::setw(Width) << std::setfill('0') << Num;
|
||||||
|
|
||||||
_TString str = sstream.str();
|
_TString Str = SStream.str();
|
||||||
if (Uppercase) str = str.ToUpper();
|
if (Uppercase) Str = Str.ToUpper();
|
||||||
if (AddPrefix) str.Prepend(LITERAL("0x"));
|
if (AddPrefix) Str.Prepend(LITERAL("0x"));
|
||||||
return str;
|
return Str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CompareCStrings(const CharType* pkA, const CharType* pkB)
|
static bool CompareCStrings(const CharType* pkA, const CharType* pkB)
|
||||||
|
@ -930,24 +930,24 @@ public:
|
||||||
static u32 CStringLength(const CharType* pkStr)
|
static u32 CStringLength(const CharType* pkStr)
|
||||||
{
|
{
|
||||||
// Replacement for strlen so we can measure any CharType
|
// Replacement for strlen so we can measure any CharType
|
||||||
u32 out = 0;
|
u32 Out = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (*pkStr == 0) return out;
|
if (*pkStr == 0) return Out;
|
||||||
out++;
|
Out++;
|
||||||
pkStr++;
|
pkStr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsWhitespace(CharType c)
|
static bool IsWhitespace(CharType Chr)
|
||||||
{
|
{
|
||||||
return ( (c == CHAR_LITERAL('\t')) ||
|
return ( (Chr == CHAR_LITERAL('\t')) ||
|
||||||
(c == CHAR_LITERAL('\n')) ||
|
(Chr == CHAR_LITERAL('\n')) ||
|
||||||
(c == CHAR_LITERAL('\v')) ||
|
(Chr == CHAR_LITERAL('\v')) ||
|
||||||
(c == CHAR_LITERAL('\f')) ||
|
(Chr == CHAR_LITERAL('\f')) ||
|
||||||
(c == CHAR_LITERAL('\r')) ||
|
(Chr == CHAR_LITERAL('\r')) ||
|
||||||
(c == CHAR_LITERAL(' ')) );
|
(Chr == CHAR_LITERAL(' ')) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,7 @@ CResource* CResourceEntry::Load(IInputStream& rInput)
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case eAnimation: mpResource = CAnimationLoader::LoadANIM(rInput, this); break;
|
case eAnimation: mpResource = CAnimationLoader::LoadANIM(rInput, this); break;
|
||||||
|
case eAnimEventData: mpResource = CUnsupportedFormatLoader::LoadEVNT(rInput, this); break;
|
||||||
case eAnimSet: mpResource = CAnimSetLoader::LoadANCSOrCHAR(rInput, this); break;
|
case eAnimSet: mpResource = CAnimSetLoader::LoadANCSOrCHAR(rInput, this); break;
|
||||||
case eArea: mpResource = CAreaLoader::LoadMREA(rInput, this); break;
|
case eArea: mpResource = CAreaLoader::LoadMREA(rInput, this); break;
|
||||||
case eDependencyGroup: mpResource = CDependencyGroupLoader::LoadDGRP(rInput, this); break;
|
case eDependencyGroup: mpResource = CDependencyGroupLoader::LoadDGRP(rInput, this); break;
|
||||||
|
|
|
@ -41,6 +41,33 @@ public:
|
||||||
|
|
||||||
return TWideString();
|
return TWideString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CDependencyTree* BuildDependencyTree() const
|
||||||
|
{
|
||||||
|
// The only dependencies STRGs have is they can reference FONTs with the &font=; formatting tag
|
||||||
|
CDependencyTree *pTree = new CDependencyTree(ID());
|
||||||
|
EIDLength IDLength = (Game() <= eEchoes ? e32Bit : e64Bit);
|
||||||
|
|
||||||
|
for (u32 iLang = 0; iLang < mLangTables.size(); iLang++)
|
||||||
|
{
|
||||||
|
const SLangTable& rkTable = mLangTables[iLang];
|
||||||
|
|
||||||
|
for (u32 iStr = 0; iStr < rkTable.Strings.size(); iStr++)
|
||||||
|
{
|
||||||
|
static const TWideString skTag = L"&font=";
|
||||||
|
const TWideString& rkStr = rkTable.Strings[iStr];
|
||||||
|
|
||||||
|
for (u32 FontIdx = rkStr.IndexOfPhrase(*skTag); FontIdx != -1; FontIdx = rkStr.IndexOfPhrase(*skTag, FontIdx + 1))
|
||||||
|
{
|
||||||
|
u32 IDStart = FontIdx + skTag.Size();
|
||||||
|
TWideString StrFontID = rkStr.SubString(IDStart, IDLength * 2);
|
||||||
|
pTree->AddDependency( CAssetID::FromString(StrFontID) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pTree;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CSTRINGTABLE_H
|
#endif // CSTRINGTABLE_H
|
||||||
|
|
|
@ -12,6 +12,50 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadCSNG(IInputStream& rCSNG, CResou
|
||||||
return pGroup;
|
return pGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CDependencyGroup* CUnsupportedFormatLoader::LoadEVNT(IInputStream& rEVNT, CResourceEntry *pEntry)
|
||||||
|
{
|
||||||
|
u32 Version = rEVNT.ReadLong();
|
||||||
|
ASSERT(Version == 1 || Version == 2);
|
||||||
|
|
||||||
|
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
|
||||||
|
|
||||||
|
// Loop Events
|
||||||
|
u32 NumLoopEvents = rEVNT.ReadLong();
|
||||||
|
|
||||||
|
for (u32 iLoop = 0; iLoop < NumLoopEvents; iLoop++)
|
||||||
|
{
|
||||||
|
rEVNT.Seek(0x2, SEEK_CUR);
|
||||||
|
rEVNT.ReadString();
|
||||||
|
rEVNT.Seek(0x1C, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// User Events
|
||||||
|
u32 NumUserEvents = rEVNT.ReadLong();
|
||||||
|
|
||||||
|
for (u32 iUser = 0; iUser < NumUserEvents; iUser++)
|
||||||
|
{
|
||||||
|
rEVNT.Seek(0x2, SEEK_CUR);
|
||||||
|
rEVNT.ReadString();
|
||||||
|
rEVNT.Seek(0x1F, SEEK_CUR);
|
||||||
|
rEVNT.ReadString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Effect Events
|
||||||
|
u32 NumEffectEvents = rEVNT.ReadLong();
|
||||||
|
|
||||||
|
for (u32 iFX = 0; iFX < NumEffectEvents; iFX++)
|
||||||
|
{
|
||||||
|
rEVNT.Seek(0x2, SEEK_CUR);
|
||||||
|
rEVNT.ReadString();
|
||||||
|
rEVNT.Seek(0x23, SEEK_CUR);
|
||||||
|
pGroup->AddDependency(rEVNT.ReadLong());
|
||||||
|
rEVNT.ReadString();
|
||||||
|
rEVNT.Seek(0x8, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pGroup;
|
||||||
|
}
|
||||||
|
|
||||||
CDependencyGroup* CUnsupportedFormatLoader::LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry)
|
CDependencyGroup* CUnsupportedFormatLoader::LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry)
|
||||||
{
|
{
|
||||||
u32 Magic = rHINT.ReadLong();
|
u32 Magic = rHINT.ReadLong();
|
||||||
|
|
|
@ -12,6 +12,7 @@ class CUnsupportedFormatLoader
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CDependencyGroup* LoadCSNG(IInputStream& rCSNG, CResourceEntry *pEntry);
|
static CDependencyGroup* LoadCSNG(IInputStream& rCSNG, CResourceEntry *pEntry);
|
||||||
|
static CDependencyGroup* LoadEVNT(IInputStream& rEVNT, CResourceEntry *pEntry);
|
||||||
static CDependencyGroup* LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry);
|
static CDependencyGroup* LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry);
|
||||||
static CDependencyGroup* LoadMAPW(IInputStream& rMAPW, CResourceEntry *pEntry);
|
static CDependencyGroup* LoadMAPW(IInputStream& rMAPW, CResourceEntry *pEntry);
|
||||||
static CDependencyGroup* LoadMAPU(IInputStream& rMAPU, CResourceEntry *pEntry);
|
static CDependencyGroup* LoadMAPU(IInputStream& rMAPU, CResourceEntry *pEntry);
|
||||||
|
|
Loading…
Reference in New Issue