mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 05:07:43 +00:00
ANCS fixes and cleanup
This commit is contained in:
@@ -174,73 +174,5 @@ void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
}
|
||||
}
|
||||
|
||||
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wconv;
|
||||
|
||||
/* Validate pass */
|
||||
for (AngelScript::asUINT i=0 ; i<in.GetGlobalVarCount() ; ++i)
|
||||
{
|
||||
const char* name;
|
||||
int typeId;
|
||||
if (in.GetGlobalVar(i, &name, 0, &typeId) < 0)
|
||||
continue;
|
||||
if (typeId == ASTYPE_STRGLanguage.getTypeID())
|
||||
{
|
||||
if (strlen(name) != 4)
|
||||
{
|
||||
Log.report(LogVisor::Error, "STRG language string '%s' from %s must be exactly 4 characters", name, in.GetName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Read pass */
|
||||
langs.clear();
|
||||
for (AngelScript::asUINT i=0 ; i<in.GetGlobalVarCount() ; ++i)
|
||||
{
|
||||
const char* name;
|
||||
int typeId;
|
||||
if (in.GetGlobalVar(i, &name, 0, &typeId) < 0)
|
||||
continue;
|
||||
if (typeId == ASTYPE_STRGLanguage.getTypeID())
|
||||
{
|
||||
const std::vector<std::string*>& strsin = ASTYPE_STRGLanguage.vectorCast(in.GetAddressOfGlobalVar(i));
|
||||
std::vector<std::wstring> strs;
|
||||
for (const std::string* str : strsin)
|
||||
strs.emplace_back(wconv.from_bytes(*str));
|
||||
langs.emplace_back(FourCC(name), strs);
|
||||
}
|
||||
}
|
||||
|
||||
langMap.clear();
|
||||
langMap.reserve(langs.size());
|
||||
for (std::pair<FourCC, std::vector<std::wstring>>& item : langs)
|
||||
langMap.emplace(item.first, &item.second);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void STRG::writeAngelScript(std::ofstream& out) const
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wconv;
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
out << "STRG::Language " << lang.first.toString() << "({";
|
||||
bool comma = false;
|
||||
unsigned idx = 0;
|
||||
for (const std::wstring& str : lang.second)
|
||||
{
|
||||
if (comma)
|
||||
out << ",";
|
||||
out << "\n/* " << idx++ << " */ \"";
|
||||
out << wconv.to_bytes(str);
|
||||
out << "\"";
|
||||
comma = true;
|
||||
}
|
||||
out << "\n});\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user