mirror of https://github.com/AxioDL/metaforce.git
STRG cooking bug fixes
This commit is contained in:
parent
bcc524e084
commit
3a3298d48e
|
@ -95,7 +95,12 @@ static std::u16string::const_iterator CookTextureList(std::u16string& ret,
|
||||||
{
|
{
|
||||||
auto end = str.find(u',', it - str.begin());
|
auto end = str.find(u',', it - str.begin());
|
||||||
if (end == std::u16string::npos)
|
if (end == std::u16string::npos)
|
||||||
Log.report(logvisor::Fatal, "Missing comma token while pasing font tag");
|
{
|
||||||
|
end = str.find(u';', it - str.begin());
|
||||||
|
if (end == std::u16string::npos)
|
||||||
|
Log.report(logvisor::Fatal,
|
||||||
|
"Missing comma/semicolon token while pasing font tag");
|
||||||
|
}
|
||||||
auto endIt = str.begin() + end + 1;
|
auto endIt = str.begin() + end + 1;
|
||||||
hecl::ProjectPath path =
|
hecl::ProjectPath path =
|
||||||
UniqueIDBridge::MakePathFromString<UniqueID32>(
|
UniqueIDBridge::MakePathFromString<UniqueID32>(
|
||||||
|
@ -234,20 +239,15 @@ static std::u16string CookString(const std::u16string& str)
|
||||||
{
|
{
|
||||||
ret.append(u"font=");
|
ret.append(u"font=");
|
||||||
it += 5;
|
it += 5;
|
||||||
auto end = str.find(u',', it - str.begin());
|
|
||||||
if (end == std::u16string::npos)
|
|
||||||
Log.report(logvisor::Fatal, "Missing comma token while pasing font tag");
|
|
||||||
hecl::ProjectPath path =
|
|
||||||
UniqueIDBridge::MakePathFromString<UniqueID32>(
|
|
||||||
hecl::Char16ToUTF8(std::u16string(it, str.begin() + end + 1)));
|
|
||||||
ret.append(hecl::UTF8ToChar16(UniqueID32(path).toString()));
|
|
||||||
|
|
||||||
ret.push_back(u';');
|
|
||||||
auto scpos = str.find(u';', it - str.begin());
|
auto scpos = str.find(u';', it - str.begin());
|
||||||
if (scpos == std::u16string::npos)
|
if (scpos == std::u16string::npos)
|
||||||
it = str.end();
|
Log.report(logvisor::Fatal, "Missing semicolon token while pasing font tag");
|
||||||
else
|
hecl::ProjectPath path =
|
||||||
it = str.begin() + scpos + 1;
|
UniqueIDBridge::MakePathFromString<UniqueID32>(
|
||||||
|
hecl::Char16ToUTF8(std::u16string(it, str.begin() + scpos)));
|
||||||
|
ret.append(hecl::UTF8ToChar16(UniqueID32(path).toString()));
|
||||||
|
ret.push_back(u';');
|
||||||
|
it = str.begin() + scpos + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -336,6 +336,9 @@ void STRG::write(athena::io::IStreamWriter& writer) const
|
||||||
atUint32 strCount = STRG::count();
|
atUint32 strCount = STRG::count();
|
||||||
writer.writeUint32Big(strCount);
|
writer.writeUint32Big(strCount);
|
||||||
|
|
||||||
|
std::vector<std::u16string> strings;
|
||||||
|
strings.reserve(strCount * langs.size());
|
||||||
|
|
||||||
atUint32 offset = 0;
|
atUint32 offset = 0;
|
||||||
for (const std::pair<FourCC, std::vector<std::u16string>>& lang : langs)
|
for (const std::pair<FourCC, std::vector<std::u16string>>& lang : langs)
|
||||||
{
|
{
|
||||||
|
@ -345,44 +348,52 @@ void STRG::write(athena::io::IStreamWriter& writer) const
|
||||||
atUint32 langStrCount = lang.second.size();
|
atUint32 langStrCount = lang.second.size();
|
||||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||||
{
|
{
|
||||||
atUint32 chCount = lang.second[s].size();
|
std::u16string str = CookString(lang.second[s]);
|
||||||
|
atUint32 chCount = str.size();
|
||||||
if (s < langStrCount)
|
if (s < langStrCount)
|
||||||
offset += (chCount + 1) * 2;
|
offset += (chCount + 1) * 2;
|
||||||
else
|
else
|
||||||
offset += 1;
|
offset += 1;
|
||||||
|
strings.push_back(std::move(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto langIt = strings.cbegin();
|
||||||
for (const std::pair<FourCC, std::vector<std::u16string>>& lang : langs)
|
for (const std::pair<FourCC, std::vector<std::u16string>>& lang : langs)
|
||||||
{
|
{
|
||||||
atUint32 langStrCount = lang.second.size();
|
atUint32 langStrCount = lang.second.size();
|
||||||
atUint32 tableSz = strCount * 4;
|
atUint32 tableSz = strCount * 4;
|
||||||
|
auto strIt = langIt;
|
||||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||||
{
|
{
|
||||||
if (s < langStrCount)
|
if (s < langStrCount)
|
||||||
tableSz += (lang.second[s].size() + 1) * 2;
|
tableSz += ((strIt++)->size() + 1) * 2;
|
||||||
else
|
else
|
||||||
tableSz += 1;
|
tableSz += 1;
|
||||||
}
|
}
|
||||||
writer.writeUint32Big(tableSz);
|
writer.writeUint32Big(tableSz);
|
||||||
|
|
||||||
offset = strCount * 4;
|
offset = strCount * 4;
|
||||||
|
strIt = langIt;
|
||||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||||
{
|
{
|
||||||
writer.writeUint32Big(offset);
|
writer.writeUint32Big(offset);
|
||||||
if (s < langStrCount)
|
if (s < langStrCount)
|
||||||
offset += (lang.second[s].size() + 1) * 2;
|
offset += ((strIt++)->size() + 1) * 2;
|
||||||
else
|
else
|
||||||
offset += 1;
|
offset += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strIt = langIt;
|
||||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||||
{
|
{
|
||||||
if (s < langStrCount)
|
if (s < langStrCount)
|
||||||
writer.writeU16StringBig(CookString(lang.second[s]));
|
writer.writeU16StringBig(*strIt++);
|
||||||
else
|
else
|
||||||
writer.writeUByte(0);
|
writer.writeUByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
langIt = strIt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +410,7 @@ size_t STRG::binarySize(size_t __isz) const
|
||||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||||
{
|
{
|
||||||
if (s < langStrCount)
|
if (s < langStrCount)
|
||||||
__isz += (lang.second[s].size() + 1) * 2;
|
__isz += (CookString(lang.second[s]).size() + 1) * 2;
|
||||||
else
|
else
|
||||||
__isz += 1;
|
__isz += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct STRG : ISTRG
|
||||||
{
|
{
|
||||||
STRG strg;
|
STRG strg;
|
||||||
strg.read(rs);
|
strg.read(rs);
|
||||||
athena::io::FileWriter writer(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
|
||||||
strg.toYAMLStream(writer);
|
strg.toYAMLStream(writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -72,14 +72,14 @@ struct STRG : ISTRG
|
||||||
STRG strg;
|
STRG strg;
|
||||||
athena::io::FileReader reader(inPath.getAbsolutePath());
|
athena::io::FileReader reader(inPath.getAbsolutePath());
|
||||||
strg.fromYAMLStream(reader);
|
strg.fromYAMLStream(reader);
|
||||||
athena::io::FileWriter ws(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
||||||
strg.write(ws);
|
strg.write(ws);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Cook(const STRG& strg, const hecl::ProjectPath& outPath)
|
static bool Cook(const STRG& strg, const hecl::ProjectPath& outPath)
|
||||||
{
|
{
|
||||||
athena::io::FileWriter ws(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
||||||
strg.write(ws);
|
strg.write(ws);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct STRG : ISTRG
|
||||||
{
|
{
|
||||||
STRG strg;
|
STRG strg;
|
||||||
strg.read(rs);
|
strg.read(rs);
|
||||||
athena::io::FileWriter writer(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
|
||||||
strg.toYAMLStream(writer);
|
strg.toYAMLStream(writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ struct STRG : ISTRG
|
||||||
STRG strg;
|
STRG strg;
|
||||||
athena::io::FileReader reader(inPath.getAbsolutePath());
|
athena::io::FileReader reader(inPath.getAbsolutePath());
|
||||||
strg.fromYAMLStream(reader);
|
strg.fromYAMLStream(reader);
|
||||||
athena::io::FileWriter ws(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
||||||
strg.write(ws);
|
strg.write(ws);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct STRG : ISTRG
|
||||||
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
||||||
{
|
{
|
||||||
std::unique_ptr<ISTRG> strg = LoadSTRG(rs);
|
std::unique_ptr<ISTRG> strg = LoadSTRG(rs);
|
||||||
athena::io::FileWriter writer(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
|
||||||
strg->toYAMLStream(writer);
|
strg->toYAMLStream(writer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ struct STRG : ISTRG
|
||||||
STRG strg;
|
STRG strg;
|
||||||
athena::io::FileReader reader(inPath.getAbsolutePath());
|
athena::io::FileReader reader(inPath.getAbsolutePath());
|
||||||
strg.fromYAMLStream(reader);
|
strg.fromYAMLStream(reader);
|
||||||
athena::io::FileWriter ws(outPath.getAbsolutePath());
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
||||||
strg.write(ws);
|
strg.write(ws);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -785,6 +785,12 @@ struct SpecMP1 : SpecBase
|
||||||
gui.read(reader);
|
gui.read(reader);
|
||||||
WriteTweak(gui, out);
|
WriteTweak(gui, out);
|
||||||
}
|
}
|
||||||
|
else if (!classStr.compare(DNAMP1::CTweakPlayerControl::DNAType()))
|
||||||
|
{
|
||||||
|
DNAMP1::CTweakPlayerControl pc;
|
||||||
|
pc.read(reader);
|
||||||
|
WriteTweak(pc, out);
|
||||||
|
}
|
||||||
else if (!classStr.compare(DNAMP1::CTweakBall::DNAType()))
|
else if (!classStr.compare(DNAMP1::CTweakBall::DNAType()))
|
||||||
{
|
{
|
||||||
DNAMP1::CTweakBall ball;
|
DNAMP1::CTweakBall ball;
|
||||||
|
|
|
@ -15,7 +15,7 @@ CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
|
||||||
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
|
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
|
||||||
const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store)
|
const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store)
|
||||||
: x14_props(props), x24_fontColor(fontCol), x28_outlineColor(outlineCol),
|
: x14_props(props), x24_fontColor(fontCol), x28_outlineColor(outlineCol),
|
||||||
x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY)
|
x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY), x5c_fontId(fontId)
|
||||||
{
|
{
|
||||||
x2cc_font = store->GetObj({SBIG('FONT'), fontId});
|
x2cc_font = store->GetObj({SBIG('FONT'), fontId});
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class CGuiTextSupport
|
||||||
bool x50_typeEnable = false;
|
bool x50_typeEnable = false;
|
||||||
float x54_chFadeTime = 0.1f;
|
float x54_chFadeTime = 0.1f;
|
||||||
float x58_chRate = 10.0f;
|
float x58_chRate = 10.0f;
|
||||||
ResId x5c_fontId;
|
ResId x5c_fontId = -1;
|
||||||
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
|
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
|
||||||
std::vector<CToken> x2bc_assets;
|
std::vector<CToken> x2bc_assets;
|
||||||
TLockedToken<CRasterFont> x2cc_font;
|
TLockedToken<CRasterFont> x2cc_font;
|
||||||
|
|
|
@ -299,7 +299,7 @@ ResId CTextParser::GetAssetIdFromString(const char16_t* str)
|
||||||
u8 g = GetColorValue(str + 2);
|
u8 g = GetColorValue(str + 2);
|
||||||
u8 b = GetColorValue(str + 4);
|
u8 b = GetColorValue(str + 4);
|
||||||
u8 a = GetColorValue(str + 6);
|
u8 a = GetColorValue(str + 6);
|
||||||
return (r << 24) | (g << 16) | (b << 8) | a;
|
return ((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
TToken<CRasterFont> CTextParser::GetFont(const char16_t* str, int len)
|
TToken<CRasterFont> CTextParser::GetFont(const char16_t* str, int len)
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
using FourCC = hecl::FourCC;
|
using FourCC = hecl::FourCC;
|
||||||
using ResId = s64;
|
using ResId = u64;
|
||||||
|
|
||||||
struct SObjectTag
|
struct SObjectTag
|
||||||
{
|
{
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 1a079c247e07d1b3c4ebc384db27274f56a5e1a2
|
Subproject commit b41ad1084bc649fada23b9bad61a02a943455552
|
Loading…
Reference in New Issue