diff --git a/DataSpec/AssetNameMap.cpp b/DataSpec/AssetNameMap.cpp index 4d4685b99..350feb0ae 100644 --- a/DataSpec/AssetNameMap.cpp +++ b/DataSpec/AssetNameMap.cpp @@ -36,7 +36,7 @@ void LoadAssetMap(athena::io::MemoryReader& ar) { if (magic != FOURCC('AIDM')) Log.report( logvisor::Warning, - FMT_STRING(_SYS_STR("Unable to load asset map; Assets will not have proper filenames for most files."))); + FMT_STRING("Unable to load asset map; Assets will not have proper filenames for most files.")); else { uint32_t assetCount = ar.readUint32Big(); g_AssetNameMap.reserve(assetCount); @@ -67,7 +67,7 @@ void InitAssetNameMap() { } else { Log.report( logvisor::Warning, - FMT_STRING(_SYS_STR("AssetNameMap32 unavailable; Assets will not have proper filenames for most files."))); + FMT_STRING("AssetNameMap32 unavailable; Assets will not have proper filenames for most files.")); } /* Now load the 64bit map for MP3 */ if (ASSET_NAME_MP64_DECOMPRESSED_SZ != 0u) { @@ -80,7 +80,7 @@ void InitAssetNameMap() { } else { Log.report( logvisor::Warning, - FMT_STRING(_SYS_STR("AssetNameMap64 unavailable; Assets will not have proper filenames for most files."))); + FMT_STRING("AssetNameMap64 unavailable; Assets will not have proper filenames for most files.")); } g_AssetNameMapInit = true; } diff --git a/DataSpec/CMakeLists.txt b/DataSpec/CMakeLists.txt index ca7a85d63..6308b330e 100644 --- a/DataSpec/CMakeLists.txt +++ b/DataSpec/CMakeLists.txt @@ -73,7 +73,7 @@ add_library(AssetNameMapNull AssetNameMapNull.cpp) get_target_property(HECL_INCLUDES hecl-full INCLUDE_DIRECTORIES) -target_include_directories(RetroDataSpec PUBLIC ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} +target_include_directories(RetroDataSpec PUBLIC ${PNG_INCLUDE_DIR} ${HECL_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}) target_link_libraries(RetroDataSpec PUBLIC amuse zeus nod squish ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} lzokay logvisor) if (COMMAND add_sanitizers) diff --git a/DataSpec/DNACommon/ANCS.cpp b/DataSpec/DNACommon/ANCS.cpp index 24e469501..13e5f67f3 100644 --- a/DataSpec/DNACommon/ANCS.cpp +++ b/DataSpec/DNACommon/ANCS.cpp @@ -17,7 +17,7 @@ namespace DataSpec::DNAANCS { template bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, const SpecBase& dataspec, - std::function fileChanged, bool force) { + std::function fileChanged, bool force) { auto& conn = btok.getBlenderConnection(); /* Extract character CMDL/CSKR/CINF first */ std::vector> chResInfo; @@ -32,8 +32,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he return false; std::string bestName = pakRouter.getBestEntryName(*cmdlE); - hecl::SystemStringConv bestNameView(bestName); - fileChanged(bestNameView.c_str()); + fileChanged(bestName.c_str()); typename ANCSDNA::CSKRType cskr; pakRouter.lookupAndReadDNA(info.cskr, cskr); @@ -75,8 +74,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he } std::string bestName = pakRouter.getBestEntryName(*cmdlE); - hecl::SystemStringConv bestNameView(bestName); - fileChanged(bestNameView.c_str()); + fileChanged(bestName.c_str()); const auto* rp = pakRouter.lookupCMDLRigPair(cmdlid); typename ANCSDNA::CSKRType cskr; @@ -106,8 +104,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he } std::string bestName = pakRouter.getBestEntryName(entry); - hecl::SystemStringConv bestNameView(bestName); - fileChanged(bestNameView.c_str()); + fileChanged(bestName.c_str()); /* Establish ANCS blend */ if (!conn.createBlend(outPath, hecl::blender::BlendType::Actor)) @@ -142,7 +139,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he if (cinfsDone.find(info.cinf) == cinfsDone.end()) { if (const typename PAKRouter::EntryType* cinfE = pakRouter.lookupEntry(info.cinf, nullptr, true, false)) { hecl::ProjectPath cinfPath = pakRouter.getWorking(cinfE); - os.linkArmature(cinfPath.getAbsolutePathUTF8(), fmt::format(FMT_STRING("CINF_{}"), info.cinf)); + os.linkArmature(cinfPath.getAbsolutePath(), fmt::format(FMT_STRING("CINF_{}"), info.cinf)); os << "if obj.name not in bpy.context.scene.objects:\n" " bpy.context.scene.collection.objects.link(obj)\n"; } @@ -158,7 +155,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he /* Link CMDL */ if (const typename PAKRouter::EntryType* cmdlE = pakRouter.lookupEntry(info.cmdl, nullptr, true, false)) { hecl::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE); - os.linkMesh(cmdlPath.getAbsolutePathUTF8(), pakRouter.getBestEntryName(*cmdlE)); + os.linkMesh(cmdlPath.getAbsolutePath(), pakRouter.getBestEntryName(*cmdlE)); /* Attach CMDL to CINF */ os << "if obj.name not in bpy.context.scene.objects:\n" @@ -177,7 +174,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he if (const typename PAKRouter::EntryType* cmdlE = pakRouter.lookupEntry(overlay.second.first, nullptr, true, false)) { hecl::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE); - os.linkMesh(cmdlPath.getAbsolutePathUTF8(), pakRouter.getBestEntryName(*cmdlE)); + os.linkMesh(cmdlPath.getAbsolutePath(), pakRouter.getBestEntryName(*cmdlE)); /* Attach CMDL to CINF */ os << "if obj.name not in bpy.context.scene.objects:\n" @@ -202,7 +199,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he if (cinfsDone.find(cinfid) == cinfsDone.end()) { if (const typename PAKRouter::EntryType* cinfE = pakRouter.lookupEntry(cinfid, nullptr, true, false)) { hecl::ProjectPath cinfPath = pakRouter.getWorking(cinfE); - os.linkArmature(cinfPath.getAbsolutePathUTF8(), fmt::format(FMT_STRING("CINF_{}"), cinfid)); + os.linkArmature(cinfPath.getAbsolutePath(), fmt::format(FMT_STRING("CINF_{}"), cinfid)); os << "if obj.name not in bpy.context.scene.objects:\n" " bpy.context.scene.collection.objects.link(obj)\n"; } @@ -219,7 +216,7 @@ bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const he /* Link CMDL */ if (const typename PAKRouter::EntryType* cmdlE = pakRouter.lookupEntry(cmdlid, nullptr, true, false)) { hecl::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE); - os.linkMesh(cmdlPath.getAbsolutePathUTF8(), pakRouter.getBestEntryName(*cmdlE)); + os.linkMesh(cmdlPath.getAbsolutePath(), pakRouter.getBestEntryName(*cmdlE)); /* Attach CMDL to CINF */ os << "if obj.name not in bpy.context.scene.objects:\n" @@ -270,16 +267,16 @@ template bool ReadANCSToBlender, DNAMP1::ANCS, DNAMP1::MaterialSet, DNACMDL::SurfaceHeader_1, 2>( hecl::blender::Token& btok, const DNAMP1::ANCS& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, - const SpecBase& dataspec, std::function fileChanged, bool force); + const SpecBase& dataspec, std::function fileChanged, bool force); template bool ReadANCSToBlender, DNAMP2::ANCS, DNAMP2::MaterialSet, DNACMDL::SurfaceHeader_2, 4>( hecl::blender::Token& btok, const DNAMP2::ANCS& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, - const SpecBase& dataspec, std::function fileChanged, bool force); + const SpecBase& dataspec, std::function fileChanged, bool force); template bool ReadANCSToBlender, DNAMP3::CHAR, DNAMP3::MaterialSet, DNACMDL::SurfaceHeader_3, 4>( hecl::blender::Token& btok, const DNAMP3::CHAR& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, - const SpecBase& dataspec, std::function fileChanged, bool force); + const SpecBase& dataspec, std::function fileChanged, bool force); } // namespace DataSpec::DNAANCS diff --git a/DataSpec/DNACommon/ANCS.hpp b/DataSpec/DNACommon/ANCS.hpp index 2cf7ef811..48e89b69f 100644 --- a/DataSpec/DNACommon/ANCS.hpp +++ b/DataSpec/DNACommon/ANCS.hpp @@ -7,7 +7,6 @@ #include "athena/Types.hpp" #include "hecl/Blender/Connection.hpp" -#include "hecl/SystemChar.hpp" namespace DataSpec { struct SpecBase; @@ -43,6 +42,6 @@ struct AnimationResInfo { template bool ReadANCSToBlender(hecl::blender::Token& btok, const ANCSDNA& ancs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, const SpecBase& dataspec, - std::function fileChanged, bool force = false); + std::function fileChanged, bool force = false); } // namespace DataSpec::DNAANCS diff --git a/DataSpec/DNACommon/CMDL.cpp b/DataSpec/DNACommon/CMDL.cpp index 0134ea70a..a09122128 100644 --- a/DataSpec/DNACommon/CMDL.cpp +++ b/DataSpec/DNACommon/CMDL.cpp @@ -82,8 +82,7 @@ void ReadMaterialSetToBlender_1_2(hecl::blender::PyOutStream& os, const Material PAKEntryReadStream rs = texEntry->beginReadStream(*node); TXTR::Extract(rs, txtrPath); } - hecl::SystemString resPath = pakRouter.getResourceRelativePath(entry, tex); - hecl::SystemUTF8Conv resPathView(resPath); + std::string resPath = pakRouter.getResourceRelativePath(entry, tex); os.format(FMT_STRING("if '{}' in bpy.data.images:\n" " image = bpy.data.images['{}']\n" "else:\n" @@ -91,7 +90,7 @@ void ReadMaterialSetToBlender_1_2(hecl::blender::PyOutStream& os, const Material " image.name = '{}'\n" "texmap_list.append(image)\n" "\n"), - texName, texName, resPathView, texName); + texName, texName, resPath, texName); } unsigned m = 0; @@ -468,7 +467,7 @@ void InitGeomBlenderContext(hecl::blender::PyOutStream& os, const hecl::ProjectP "with bpy.data.libraries.load('{}', link=True, relative=True) as (data_from, data_to):\n" " data_to.node_groups = data_from.node_groups\n" "\n"), - masterShaderPath.getAbsolutePathUTF8()); + masterShaderPath.getAbsolutePath()); } void FinishBlenderMesh(hecl::blender::PyOutStream& os, unsigned matSetCount, int meshIdx) { @@ -1195,7 +1194,7 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath size_t endOff = 0; for (const Material& mat : mset) { - std::string diagName = fmt::format(FMT_STRING("{}:{}"), inPath.getLastComponentUTF8(), mat.name); + std::string diagName = fmt::format(FMT_STRING("{}:{}"), inPath.getLastComponent(), mat.name); hecl::Frontend::IR matIR = FE.compileSource(mat.source, diagName); setBackends.emplace_back(); hecl::Backend::GX& matGX = setBackends.back(); diff --git a/DataSpec/DNACommon/DNACommon.cpp b/DataSpec/DNACommon/DNACommon.cpp index 603079fe3..1ef8ba3f0 100644 --- a/DataSpec/DNACommon/DNACommon.cpp +++ b/DataSpec/DNACommon/DNACommon.cpp @@ -83,7 +83,7 @@ void UniqueID32::Enumerate(typename WriteYaml::StreamT& write hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(*this); if (!path) return; - writer.writeString(path.getEncodableStringUTF8()); + writer.writeString(path.getEncodableString()); } template <> void UniqueID32::Enumerate(typename BinarySize::StreamT& s) { @@ -133,7 +133,7 @@ void UniqueID64::Enumerate(typename WriteYaml::StreamT& write hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(*this); if (!path) return; - writer.writeString(path.getEncodableStringUTF8()); + writer.writeString(path.getEncodableString()); } template <> void UniqueID64::Enumerate(typename BinarySize::StreamT& s) { @@ -164,7 +164,7 @@ void UniqueID128::Enumerate(typename WriteYaml::StreamT& writ hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(*this); if (!path) return; - writer.writeString(path.getEncodableStringUTF8()); + writer.writeString(path.getEncodableString()); } template <> void UniqueID128::Enumerate(typename BinarySize::StreamT& s) { @@ -189,7 +189,7 @@ void WordBitmap::write(athena::io::IStreamWriter& writer) const { void WordBitmap::binarySize(size_t& __isz) const { __isz += m_words.size() * 4; } hecl::ProjectPath GetPathBeginsWith(const hecl::DirectoryEnumerator& dEnum, const hecl::ProjectPath& parentPath, - hecl::SystemStringView test) { + std::string_view test) { for (const auto& ent : dEnum) if (hecl::StringUtils::BeginsWith(ent.m_name, test)) return hecl::ProjectPath(parentPath, ent.m_name); diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index bf469e3f7..ed9e856bb 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -144,12 +144,6 @@ public: copy[8] = '\0'; assign(strtoul(copy, nullptr, 16)); } - UniqueID32(const wchar_t* hexStr) noexcept { - wchar_t copy[9]; - wcsncpy(copy, hexStr, 8); - copy[8] = L'\0'; - assign(wcstoul(copy, nullptr, 16)); - } static constexpr size_t BinarySize() noexcept { return 4; } }; @@ -194,12 +188,6 @@ public: copy[16] = '\0'; assign(std::strtoull(copy, nullptr, 16)); } - UniqueID64(const wchar_t* hexStr) noexcept { - wchar_t copy[17]; - std::wcsncpy(copy, hexStr, 16); - copy[16] = L'\0'; - assign(std::wcstoull(copy, nullptr, 16)); - } static constexpr size_t BinarySize() noexcept { return 8; } }; @@ -370,8 +358,8 @@ struct CharacterAssociations { }; hecl::ProjectPath GetPathBeginsWith(const hecl::DirectoryEnumerator& dEnum, const hecl::ProjectPath& parentPath, - hecl::SystemStringView test); -inline hecl::ProjectPath GetPathBeginsWith(const hecl::ProjectPath& parentPath, hecl::SystemStringView test) { + std::string_view test); +inline hecl::ProjectPath GetPathBeginsWith(const hecl::ProjectPath& parentPath, std::string_view test) { return GetPathBeginsWith(hecl::DirectoryEnumerator(parentPath.getAbsolutePath()), parentPath, test); } diff --git a/DataSpec/DNACommon/MAPA.cpp b/DataSpec/DNACommon/MAPA.cpp index b668d6b6b..8a14db344 100644 --- a/DataSpec/DNACommon/MAPA.cpp +++ b/DataSpec/DNACommon/MAPA.cpp @@ -287,10 +287,9 @@ bool ReadMAPAToBlender(hecl::blender::Connection& conn, const MAPA& mapa, const /* World background */ hecl::ProjectPath worldDir = outPath.getParentPath().getParentPath(); for (const auto& ent : hecl::DirectoryEnumerator(worldDir.getAbsolutePath())) { - if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world")) && - hecl::StringUtils::EndsWith(ent.m_name, _SYS_STR(".blend"))) { - hecl::SystemUTF8Conv conv(ent.m_name); - os.linkBackground(fmt::format(FMT_STRING("//../{}"), conv), "World"sv); + if (hecl::StringUtils::BeginsWith(ent.m_name, "!world") && + hecl::StringUtils::EndsWith(ent.m_name, ".blend")) { + os.linkBackground(fmt::format(FMT_STRING("//../{}"), ent.m_name), "World"sv); break; } } @@ -322,7 +321,7 @@ template bool ReadMAPAToBlender>(hecl::blender::Con template bool Cook(const hecl::blender::MapArea& mapaIn, const hecl::ProjectPath& out) { if (mapaIn.verts.size() >= 256) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("MAPA {} vertex range exceeded [{}/{}]")), out.getRelativePath(), + Log.report(logvisor::Error, FMT_STRING("MAPA {} vertex range exceeded [{}/{}]"), out.getRelativePath(), mapaIn.verts.size(), 255); return false; } diff --git a/DataSpec/DNACommon/MAPU.cpp b/DataSpec/DNACommon/MAPU.cpp index 21684decc..04e4c029a 100644 --- a/DataSpec/DNACommon/MAPU.cpp +++ b/DataSpec/DNACommon/MAPU.cpp @@ -33,7 +33,7 @@ bool ReadMAPUToBlender(hecl::blender::Connection& conn, const MAPU& mapu, const "\n"; hecl::ProjectPath hexPath = pakRouter.getWorking(mapu.hexMapa); - os.linkMesh(hexPath.getAbsolutePathUTF8(), "MAP"); + os.linkMesh(hexPath.getAbsolutePath(), "MAP"); os << "hexMesh = bpy.data.objects['MAP'].data\n"; for (const MAPU::World& wld : mapu.worlds) { @@ -55,7 +55,7 @@ bool ReadMAPUToBlender(hecl::blender::Connection& conn, const MAPU& mapu, const "bpy.context.scene.collection.objects.link(wldObj)\n"), wld.name, wldXfF[0][0], wldXfF[0][1], wldXfF[0][2], wldXfF[0][3], wldXfF[1][0], wldXfF[1][1], wldXfF[1][2], wldXfF[1][3], wldXfF[2][0], wldXfF[2][1], wldXfF[2][2], wldXfF[2][3], hexColorF[0], - hexColorF[1], hexColorF[2], hexColorF[3], path.getParentPath().getRelativePathUTF8()); + hexColorF[1], hexColorF[2], hexColorF[3], path.getParentPath().getRelativePath()); int idx = 0; for (const MAPU::Transform& hexXf : wld.hexTransforms) { zeus::simd_floats hexXfF[3]; @@ -113,8 +113,8 @@ bool MAPU::Cook(const hecl::blender::MapUniverse& mapuIn, const hecl::ProjectPat MAPU::World& wldOut = mapu.worlds.back(); wldOut.name = wld.name; for (const auto& ent : wld.worldPath.enumerateDir()) { - if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world")) && - hecl::StringUtils::EndsWith(ent.m_name, _SYS_STR(".blend"))) { + if (hecl::StringUtils::BeginsWith(ent.m_name, "!world") && + hecl::StringUtils::EndsWith(ent.m_name, ".blend")) { wldOut.mlvl = hecl::ProjectPath(wld.worldPath, ent.m_name); break; } diff --git a/DataSpec/DNACommon/MLVL.cpp b/DataSpec/DNACommon/MLVL.cpp index c90330ed7..24c081147 100644 --- a/DataSpec/DNACommon/MLVL.cpp +++ b/DataSpec/DNACommon/MLVL.cpp @@ -12,8 +12,8 @@ namespace DataSpec::DNAMLVL { template bool ReadMLVLToBlender(hecl::blender::Connection& conn, const MLVL& mlvl, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, bool force, - std::function fileChanged) { - hecl::ProjectPath blendPath = outPath.getWithExtension(_SYS_STR(".blend"), true); + std::function fileChanged) { + hecl::ProjectPath blendPath = outPath.getWithExtension(".blend", true); if (!force && blendPath.isFile()) return true; @@ -35,7 +35,6 @@ bool ReadMLVLToBlender(hecl::blender::Connection& conn, const MLVL& mlvl, const int areaIdx = 0; for (const auto& area : mlvl.areas) { const typename PAKRouter::EntryType* mreaEntry = pakRouter.lookupEntry(area.areaMREAId); - hecl::SystemUTF8Conv areaDirName(*mreaEntry->unique.m_areaName); os.AABBToBMesh(area.aabb[0], area.aabb[1]); zeus::simd_floats xfMtxF[3]; @@ -52,7 +51,7 @@ bool ReadMLVLToBlender(hecl::blender::Connection& conn, const MLVL& mlvl, const "box.location = mtxd[0]\n" "box.rotation_quaternion = mtxd[1]\n" "box.scale = mtxd[2]\n"), - areaDirName, xfMtxF[0][0], xfMtxF[0][1], xfMtxF[0][2], xfMtxF[0][3], xfMtxF[1][0], xfMtxF[1][1], + *mreaEntry->unique.m_areaName, xfMtxF[0][0], xfMtxF[0][1], xfMtxF[0][2], xfMtxF[0][3], xfMtxF[1][0], xfMtxF[1][1], xfMtxF[1][2], xfMtxF[1][3], xfMtxF[2][0], xfMtxF[2][1], xfMtxF[2][2], xfMtxF[2][3]); /* Insert dock planes */ @@ -95,16 +94,16 @@ bool ReadMLVLToBlender(hecl::blender::Connection& conn, const MLVL& mlvl, const template bool ReadMLVLToBlender, DNAMP1::MLVL>( hecl::blender::Connection& conn, const DNAMP1::MLVL& mlvl, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAKRouter::EntryType& entry, bool force, - std::function fileChanged); + std::function fileChanged); template bool ReadMLVLToBlender, DNAMP2::MLVL>( hecl::blender::Connection& conn, const DNAMP2::MLVL& mlvl, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAKRouter::EntryType& entry, bool force, - std::function fileChanged); + std::function fileChanged); template bool ReadMLVLToBlender, DNAMP3::MLVL>( hecl::blender::Connection& conn, const DNAMP3::MLVL& mlvl, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAKRouter::EntryType& entry, bool force, - std::function fileChanged); + std::function fileChanged); } // namespace DataSpec::DNAMLVL diff --git a/DataSpec/DNACommon/MLVL.hpp b/DataSpec/DNACommon/MLVL.hpp index e598662c0..452d421d1 100644 --- a/DataSpec/DNACommon/MLVL.hpp +++ b/DataSpec/DNACommon/MLVL.hpp @@ -4,8 +4,6 @@ #include "DataSpec/DNACommon/DNACommon.hpp" -#include - namespace hecl { class ProjectPath; } @@ -19,6 +17,6 @@ namespace DataSpec::DNAMLVL { template bool ReadMLVLToBlender(hecl::blender::Connection& conn, const MLVL& mlvl, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKRouter::EntryType& entry, bool force, - std::function fileChanged); + std::function fileChanged); } diff --git a/DataSpec/DNACommon/PAK.cpp b/DataSpec/DNACommon/PAK.cpp index 46b8ffde9..c8e626fed 100644 --- a/DataSpec/DNACommon/PAK.cpp +++ b/DataSpec/DNACommon/PAK.cpp @@ -10,7 +10,7 @@ template void UniqueResult::checkEntry(const PAKBRIDGE& pakBridge, const typename PAKBRIDGE::PAKType::Entry& entry) { UniqueResult::Type resultType = UniqueResult::Type::NotFound; bool foundOneLayer = false; - const hecl::SystemString* levelName = nullptr; + const std::string* levelName = nullptr; typename PAKBRIDGE::PAKType::IDType useLevelId; typename PAKBRIDGE::PAKType::IDType useAreaId; unsigned layerIdx = 0; @@ -123,10 +123,9 @@ void PAKRouter::build(std::vector& bridges, std::functio size_t bridgeIdx = 0; for (BRIDGETYPE& bridge : bridges) { const auto& name = bridge.getName(); - hecl::SystemStringConv sysName(name); - hecl::SystemStringView::const_iterator extit = sysName.sys_str().end() - 4; - hecl::SystemString baseName(sysName.sys_str().begin(), extit); + std::string_view::const_iterator extit = name.end() - 4; + std::string baseName(name.begin(), extit); m_bridgePaths.emplace_back( std::make_pair(hecl::ProjectPath(m_gameWorking, baseName), hecl::ProjectPath(m_gameCooked, baseName))); @@ -173,13 +172,13 @@ void PAKRouter::build(std::vector& bridges, std::functio continue; /* Problematic corner case */ if (auto rec = catalogWriter.enterSubRecord(namedEntry.name)) { hecl::ProjectPath working = getWorking(namedEntry.id); - if (working.getAuxInfoUTF8().size()) { + if (working.getAuxInfo().size()) { if (auto v = catalogWriter.enterSubVector()) { - catalogWriter.writeString(working.getRelativePathUTF8()); - catalogWriter.writeString(working.getAuxInfoUTF8()); + catalogWriter.writeString(working.getRelativePath()); + catalogWriter.writeString(working.getAuxInfo()); } } else - catalogWriter.writeString(working.getRelativePathUTF8()); + catalogWriter.writeString(working.getRelativePath()); } } @@ -217,8 +216,8 @@ hecl::ProjectPath PAKRouter::getCharacterWorking(const EntryType* en if (characterSearch != m_charAssoc.m_cskrToCharacter.cend()) { hecl::ProjectPath characterPath = getWorking(characterSearch->second.first); if (entry->type == FOURCC('EVNT')) { - hecl::SystemStringConv wideStr(characterSearch->second.second); - return characterPath.getWithExtension((hecl::SystemString(_SYS_STR(".")) + wideStr.c_str()).c_str(), true); + std::string extension(characterSearch->second.second); + return characterPath.getWithExtension((std::string(".") + extension.c_str()).c_str(), true); } return characterPath.ensureAuxInfo(characterSearch->second.second); } @@ -241,12 +240,12 @@ hecl::ProjectPath PAKRouter::getWorking(const EntryType* entry, const EntryType* singleSearch = pak->lookupEntry(entry->id); if (singleSearch) { const hecl::ProjectPath& pakPath = m_bridgePaths[curBridgeIdx].first; - hecl::SystemString entName = hecl::UTF8StringToSysString(getBestEntryName(*entry)); - hecl::SystemString auxInfo; + std::string entName = getBestEntryName(*entry); + std::string auxInfo; if (extractor.fileExts[0] && !extractor.fileExts[1]) entName += extractor.fileExts[0]; else if (extractor.fileExts[0]) - entName += _SYS_STR(".*"); + entName += ".*"; else if (hecl::ProjectPath chWork = getCharacterWorking(entry)) return chWork; return hecl::ProjectPath(pakPath, entName).ensureAuxInfo(auxInfo); @@ -257,12 +256,12 @@ hecl::ProjectPath PAKRouter::getWorking(const EntryType* entry, if (uniqueSearch != m_uniqueEntries.end()) { const BRIDGETYPE& bridge = m_bridges->at(uniqueSearch->second.first); const hecl::ProjectPath& pakPath = m_bridgePaths[uniqueSearch->second.first].first; - hecl::SystemString entName = hecl::UTF8StringToSysString(getBestEntryName(*entry)); - hecl::SystemString auxInfo; + std::string entName = getBestEntryName(*entry); + std::string auxInfo; if (extractor.fileExts[0] && !extractor.fileExts[1]) entName += extractor.fileExts[0]; else if (extractor.fileExts[0]) - entName += _SYS_STR(".*"); + entName += ".*"; else if (hecl::ProjectPath chWork = getCharacterWorking(entry)) return chWork; if (bridge.getPAK().m_noShare) { @@ -275,13 +274,13 @@ hecl::ProjectPath PAKRouter::getWorking(const EntryType* entry, auto sharedSearch = m_sharedEntries.find(entry->id); if (sharedSearch != m_sharedEntries.end()) { - hecl::SystemString entBase = hecl::UTF8StringToSysString(getBestEntryName(*entry)); - hecl::SystemString auxInfo; - hecl::SystemString entName = entBase; + std::string entBase = getBestEntryName(*entry); + std::string auxInfo; + std::string entName = entBase; if (extractor.fileExts[0] && !extractor.fileExts[1]) entName += extractor.fileExts[0]; else if (extractor.fileExts[0]) - entName += _SYS_STR(".*"); + entName += ".*"; else if (hecl::ProjectPath chWork = getCharacterWorking(entry)) return chWork; hecl::ProjectPath sharedPath(m_sharedWorking, entName); @@ -349,7 +348,7 @@ hecl::ProjectPath PAKRouter::getCooked(const IDType& id, bool silenc } template -hecl::SystemString PAKRouter::getResourceRelativePath(const EntryType& a, const IDType& b) const { +std::string PAKRouter::getResourceRelativePath(const EntryType& a, const IDType& b) const { const nod::Node* node = m_node.get(); const PAKType* pak = m_pak.get(); if (!pak) @@ -358,11 +357,11 @@ hecl::SystemString PAKRouter::getResourceRelativePath(const EntryTyp FMT_STRING("PAKRouter::enterPAKBridge() must be called before PAKRouter::getResourceRelativePath()")); const typename BRIDGETYPE::PAKType::Entry* be = lookupEntry(b); if (!be) - return hecl::SystemString(); + return std::string(); hecl::ProjectPath aPath = getWorking(&a, BRIDGETYPE::LookupExtractor(*node, *pak, a)); - hecl::SystemString ret; + std::string ret; for (size_t i = 0; i < aPath.levelCount(); ++i) - ret += _SYS_STR("../"); + ret += "../"; hecl::ProjectPath bPath = getWorking(be, BRIDGETYPE::LookupExtractor(*node, *pak, *be)); ret += bPath.getRelativePath(); return ret; @@ -434,7 +433,7 @@ std::string PAKRouter::getBestEntryName(const IDType& entry, bool st template bool PAKRouter::extractResources(const BRIDGETYPE& pakBridge, bool force, hecl::blender::Token& btok, - std::function progress) { + std::function progress) { enterPAKBridge(pakBridge); size_t count = 0; size_t sz = m_pak->m_entries.size(); @@ -447,9 +446,8 @@ bool PAKRouter::extractResources(const BRIDGETYPE& pakBridge, bool f continue; std::string bestName = getBestEntryName(*entryPtr, false); - hecl::SystemStringConv bestNameView(bestName); float thisFac = ++count / fsz; - progress(bestNameView.c_str(), thisFac); + progress(bestName.c_str(), thisFac); const nod::Node* node = m_node.get(); @@ -464,7 +462,7 @@ bool PAKRouter::extractResources(const BRIDGETYPE& pakBridge, bool f if (force || cooked.isNone()) { cooked.makeDirChain(false); PAKEntryReadStream s = entryPtr->beginReadStream(*node); - const auto fout = hecl::FopenUnique(cooked.getAbsolutePath().data(), _SYS_STR("wb")); + const auto fout = hecl::FopenUnique(cooked.getAbsolutePath().data(), "wb"); std::fwrite(s.data(), 1, s.length(), fout.get()); } @@ -479,7 +477,7 @@ bool PAKRouter::extractResources(const BRIDGETYPE& pakBridge, bool f if (force || !extractor.IsFullyExtracted(working)) { PAKEntryReadStream s = entryPtr->beginReadStream(*node); extractor.func_b(m_dataSpec, s, working, *this, *entryPtr, force, btok, - [&progress, thisFac](const hecl::SystemChar* update) { progress(update, thisFac); }); + [&progress, thisFac](const char* update) { progress(update, thisFac); }); } } } diff --git a/DataSpec/DNACommon/PAK.hpp b/DataSpec/DNACommon/PAK.hpp index 35ca2802e..56e956436 100644 --- a/DataSpec/DNACommon/PAK.hpp +++ b/DataSpec/DNACommon/PAK.hpp @@ -60,9 +60,9 @@ public: struct UniqueResult { enum class Type { NotFound, Pak, Level, Area, Layer } m_type = Type::NotFound; - const hecl::SystemString* m_levelName = nullptr; - const hecl::SystemString* m_areaName = nullptr; - const hecl::SystemString* m_layerName = nullptr; + const std::string* m_levelName = nullptr; + const std::string* m_areaName = nullptr; + const std::string* m_layerName = nullptr; UniqueResult() = default; UniqueResult(Type tp) : m_type(tp) {} @@ -81,9 +81,9 @@ struct ResExtractor { std::function func_a; std::function&, const typename PAKBRIDGE::PAKType::Entry&, bool, hecl::blender::Token&, - std::function)> + std::function)> func_b; - std::array fileExts = {}; + std::array fileExts = {}; unsigned weight = 0; std::function&, typename PAKBRIDGE::PAKType::Entry&)> func_name; @@ -91,7 +91,7 @@ struct ResExtractor { ResExtractor() = default; ResExtractor(std::function func, - std::array&& fileExtsIn, unsigned weightin = 0, + std::array&& fileExtsIn, unsigned weightin = 0, std::function&, typename PAKBRIDGE::PAKType::Entry&)> nfunc = {}) @@ -99,9 +99,9 @@ struct ResExtractor { ResExtractor(std::function&, const typename PAKBRIDGE::PAKType::Entry&, bool, hecl::blender::Token&, - std::function)> + std::function)> func, - std::array&& fileExtsIn, unsigned weightin = 0, + std::array&& fileExtsIn, unsigned weightin = 0, std::function&, typename PAKBRIDGE::PAKType::Entry&)> nfunc = {}) @@ -127,11 +127,11 @@ struct ResExtractor { /** Level hierarchy representation */ template struct Level { - hecl::SystemString name; + std::string name; struct Area { - hecl::SystemString name; + std::string name; struct Layer { - hecl::SystemString name; + std::string name; bool active; std::unordered_set resources; }; @@ -188,13 +188,13 @@ public: hecl::ProjectPath getCooked(const EntryType* entry) const; hecl::ProjectPath getCooked(const IDType& id, bool silenceWarnings = false) const; - hecl::SystemString getResourceRelativePath(const EntryType& a, const IDType& b) const; + std::string getResourceRelativePath(const EntryType& a, const IDType& b) const; std::string getBestEntryName(const EntryType& entry, bool stdOverride = true) const; std::string getBestEntryName(const IDType& entry, bool stdOverride = true) const; bool extractResources(const BRIDGETYPE& pakBridge, bool force, hecl::blender::Token& btok, - std::function progress); + std::function progress); const typename BRIDGETYPE::PAKType::Entry* lookupEntry(const IDType& entry, const nod::Node** nodeOut = nullptr, bool silenceWarnings = false, bool currentPAK = false) const; diff --git a/DataSpec/DNACommon/PATH.cpp b/DataSpec/DNACommon/PATH.cpp index eeaa8cfd6..a5e330427 100644 --- a/DataSpec/DNACommon/PATH.cpp +++ b/DataSpec/DNACommon/PATH.cpp @@ -180,7 +180,7 @@ template bool PATH::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKBridge::PAKType::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { PATH path; path.read(rs); hecl::blender::Connection& conn = btok.getBlenderConnection(); @@ -189,8 +189,8 @@ bool PATH::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, std::string areaPath; for (const auto& ent : hecl::DirectoryEnumerator(outPath.getParentPath().getAbsolutePath())) { - if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!area_"))) { - areaPath = hecl::SystemUTF8Conv(ent.m_name).str(); + if (hecl::StringUtils::BeginsWith(ent.m_name, "!area_")) { + areaPath = ent.m_name; break; } } @@ -223,7 +223,7 @@ bool PATH::Cook(const hecl::ProjectPath& outPath, const hecl::Project #if DUMP_OCTREE { hecl::blender::Connection& conn = btok.getBlenderConnection(); - if (!conn.createBlend(inPath.getWithExtension(_SYS_STR(".octree.blend"), true), hecl::blender::BlendType::PathMesh)) + if (!conn.createBlend(inPath.getWithExtension(".octree.blend", true), hecl::blender::BlendType::PathMesh)) return false; zeus::CMatrix4f xf; diff --git a/DataSpec/DNACommon/PATH.hpp b/DataSpec/DNACommon/PATH.hpp index 2a3f8d793..8058f9c5f 100644 --- a/DataSpec/DNACommon/PATH.hpp +++ b/DataSpec/DNACommon/PATH.hpp @@ -104,7 +104,7 @@ struct AT_SPECIALIZE_PARMS(DataSpec::DNAMP1::PAKBridge, DataSpec::DNAMP2::PAKBri static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKBridge::PAKType::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged); + hecl::blender::Token& btok, std::function fileChanged); static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const PathMesh& mesh, hecl::blender::Token& btok); diff --git a/DataSpec/DNACommon/STRG.cpp b/DataSpec/DNACommon/STRG.cpp index fd8fa07e5..f6d0e6aed 100644 --- a/DataSpec/DNACommon/STRG.cpp +++ b/DataSpec/DNACommon/STRG.cpp @@ -15,29 +15,29 @@ std::unique_ptr LoadSTRG(athena::io::IStreamReader& reader) { uint32_t magic = reader.readUint32Big(); if (magic != 0x87654321) { LogDNACommon.report(logvisor::Error, FMT_STRING("invalid STRG magic")); - return std::unique_ptr(); + return {}; } uint32_t version = reader.readUint32Big(); switch (version) { case 0: { - DNAMP1::STRG* newStrg = new DNAMP1::STRG; + auto* newStrg = new DNAMP1::STRG; newStrg->_read(reader); return std::unique_ptr(newStrg); } case 1: { - DNAMP2::STRG* newStrg = new DNAMP2::STRG; + auto* newStrg = new DNAMP2::STRG; newStrg->_read(reader); return std::unique_ptr(newStrg); } case 3: { - DNAMP3::STRG* newStrg = new DNAMP3::STRG; + auto* newStrg = new DNAMP3::STRG; newStrg->_read(reader); return std::unique_ptr(newStrg); } default: break; } - return std::unique_ptr(); + return {}; } } // namespace DataSpec diff --git a/DataSpec/DNACommon/STRG.hpp b/DataSpec/DNACommon/STRG.hpp index 179e28979..04fddba87 100644 --- a/DataSpec/DNACommon/STRG.hpp +++ b/DataSpec/DNACommon/STRG.hpp @@ -21,7 +21,6 @@ struct ISTRG : BigDNAVYaml { virtual size_t count() const = 0; virtual std::string getUTF8(const FourCC& lang, size_t idx) const = 0; virtual std::u16string getUTF16(const FourCC& lang, size_t idx) const = 0; - virtual hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const = 0; virtual int32_t lookupIdx(std::string_view name) const = 0; virtual void gatherDependencies(std::vector& pathsOut) const; diff --git a/DataSpec/DNACommon/TXTR.cpp b/DataSpec/DNACommon/TXTR.cpp index 657b0e5c2..12376b47a 100644 --- a/DataSpec/DNACommon/TXTR.cpp +++ b/DataSpec/DNACommon/TXTR.cpp @@ -836,9 +836,9 @@ bool TXTR::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { const uint16_t height = rs.readUint16Big(); const uint32_t numMips = rs.readUint32Big(); - auto fp = hecl::FopenUnique(outPath.getAbsolutePath().data(), _SYS_STR("wb")); + auto fp = hecl::FopenUnique(outPath.getAbsolutePath().data(), "wb"); if (fp == nullptr) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to open '{}' for writing")), outPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("Unable to open '{}' for writing"), outPath.getAbsolutePath()); return false; } png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, PNGErr, PNGWarn); @@ -1039,9 +1039,9 @@ static int GetNumPaletteEntriesForGCN(png_structp png, png_infop info) { } bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) { - auto inf = hecl::FopenUnique(inPath.getAbsolutePath().data(), _SYS_STR("rb")); + auto inf = hecl::FopenUnique(inPath.getAbsolutePath().data(), "rb"); if (inf == nullptr) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to open '{}' for reading")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("Unable to open '{}' for reading"), inPath.getAbsolutePath()); return false; } @@ -1049,7 +1049,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat char header[8]; std::fread(header, 1, sizeof(header), inf.get()); if (png_sig_cmp((png_const_bytep)header, 0, 8)) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("invalid PNG signature in '{}'")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("invalid PNG signature in '{}'"), inPath.getAbsolutePath()); return false; } @@ -1067,7 +1067,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat } if (setjmp(png_jmpbuf(pngRead))) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("unable to initialize libpng I/O for '{}'")), + Log.report(logvisor::Error, FMT_STRING("unable to initialize libpng I/O for '{}'"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; @@ -1113,7 +1113,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat } if (bitDepth != 8) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("'{}' is not 8 bits-per-channel")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("'{}' is not 8 bits-per-channel"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; } @@ -1144,7 +1144,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat nComps = 1; break; default: - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("unsupported color type in '{}'")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("unsupported color type in '{}'"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; } @@ -1164,7 +1164,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat bufOut.reset(new uint8_t[bufLen]); if (setjmp(png_jmpbuf(pngRead))) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to read image in '{}'")), inPath.getAbsolutePath()); + Log.report(logvisor::Fatal, FMT_STRING("unable to read image in '{}'"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; } @@ -1345,7 +1345,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat /* Do write out */ athena::io::FileWriter outf(outPath.getAbsolutePath(), true, false); if (outf.hasError()) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to open '{}' for writing")), outPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("Unable to open '{}' for writing"), outPath.getAbsolutePath()); return false; } @@ -1359,9 +1359,9 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat } bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) { - auto inf = hecl::FopenUnique(inPath.getAbsolutePath().data(), _SYS_STR("rb")); + auto inf = hecl::FopenUnique(inPath.getAbsolutePath().data(), "rb"); if (inf == nullptr) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to open '{}' for reading")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("Unable to open '{}' for reading"), inPath.getAbsolutePath()); return false; } @@ -1369,7 +1369,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP char header[8]; std::fread(header, 1, sizeof(header), inf.get()); if (png_sig_cmp((png_const_bytep)header, 0, 8)) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("invalid PNG signature in '{}'")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("invalid PNG signature in '{}'"), inPath.getAbsolutePath()); return false; } @@ -1387,7 +1387,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP } if (setjmp(png_jmpbuf(pngRead))) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("unable to initialize libpng I/O for '{}'")), + Log.report(logvisor::Error, FMT_STRING("unable to initialize libpng I/O for '{}'"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; @@ -1427,7 +1427,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP } if (bitDepth != 8) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("'{}' is not 8 bits-per-channel")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("'{}' is not 8 bits-per-channel"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; } @@ -1456,7 +1456,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP paletteBuf = ReadPalette(pngRead, info, paletteSize); break; default: - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("unsupported color type in '{}'")), inPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("unsupported color type in '{}'"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; } @@ -1474,7 +1474,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP bufOut.reset(new uint8_t[bufLen]); if (setjmp(png_jmpbuf(pngRead))) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to read image in '{}'")), inPath.getAbsolutePath()); + Log.report(logvisor::Fatal, FMT_STRING("unable to read image in '{}'"), inPath.getAbsolutePath()); png_destroy_read_struct(&pngRead, &info, nullptr); return false; } @@ -1595,7 +1595,7 @@ bool TXTR::CookPC(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outP /* Do write out */ athena::io::FileWriter outf(outPath.getAbsolutePath(), true, false); if (outf.hasError()) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to open '{}' for writing")), outPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("Unable to open '{}' for writing"), outPath.getAbsolutePath()); return false; } diff --git a/DataSpec/DNAMP1/AGSC.cpp b/DataSpec/DNAMP1/AGSC.cpp index f136e5cb9..4591eae23 100644 --- a/DataSpec/DNAMP1/AGSC.cpp +++ b/DataSpec/DNAMP1/AGSC.cpp @@ -181,7 +181,7 @@ bool AGSC::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& dir) { group.getSdir().extractAllCompressed(dir.getAbsolutePath(), data.getSamp()); /* Import C headers */ - auto lastComp = dir.getLastComponentUTF8(); + auto lastComp = dir.getLastComponent(); auto search = std::lower_bound(std::cbegin(Headers), std::cend(Headers), lastComp, [](const auto& a, const auto& b) { return a.first < b; }); if (search != std::cend(Headers) && search->first == lastComp) @@ -190,7 +190,7 @@ bool AGSC::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& dir) { /* Write out project/pool */ { auto projd = group.getProj().toYAML(); - athena::io::FileWriter fo(hecl::ProjectPath(dir, _SYS_STR("!project.yaml")).getAbsolutePath()); + athena::io::FileWriter fo(hecl::ProjectPath(dir, "!project.yaml").getAbsolutePath()); if (fo.hasError()) return false; fo.writeUBytes(projd.data(), projd.size()); @@ -198,7 +198,7 @@ bool AGSC::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& dir) { { auto poold = group.getPool().toYAML(); - athena::io::FileWriter fo(hecl::ProjectPath(dir, _SYS_STR("!pool.yaml")).getAbsolutePath()); + athena::io::FileWriter fo(hecl::ProjectPath(dir, "!pool.yaml").getAbsolutePath()); if (fo.hasError()) return false; fo.writeUBytes(poold.data(), poold.size()); @@ -232,7 +232,7 @@ bool AGSC::Cook(const hecl::ProjectPath& dir, const hecl::ProjectPath& refOutPat Header head; head.audioDir = "Audio/"sv; - head.groupName = path.getLastComponentUTF8(); + head.groupName = path.getLastComponent(); head.write(w); amuse::AudioGroupDatabase group(path.getAbsolutePath()); diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index dc3053674..3de05dd7d 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -957,10 +957,10 @@ std::string_view ANCS::AnimationSet::DNAType() { return "DNAMP1::ANCS::Animation bool ANCS::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { - hecl::ProjectPath yamlPath = outPath.getWithExtension(_SYS_STR(".yaml"), true); + std::function fileChanged) { + hecl::ProjectPath yamlPath = outPath.getWithExtension(".yaml", true); hecl::ProjectPath::Type yamlType = yamlPath.getPathType(); - hecl::ProjectPath blendPath = outPath.getWithExtension(_SYS_STR(".blend"), true); + hecl::ProjectPath blendPath = outPath.getWithExtension(".blend", true); hecl::ProjectPath::Type blendType = blendPath.getPathType(); ANCS ancs; @@ -983,21 +983,21 @@ bool ANCS::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: bool ANCS::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const DNAANCS::Actor& actor) { /* Search for yaml */ - hecl::ProjectPath yamlPath = inPath.getWithExtension(_SYS_STR(".yaml"), true); + hecl::ProjectPath yamlPath = inPath.getWithExtension(".yaml", true); if (!yamlPath.isFile()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("'{}' not found as file")), yamlPath.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("'{}' not found as file"), yamlPath.getRelativePath()); athena::io::FileReader reader(yamlPath.getAbsolutePath()); if (!reader.isOpen()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("can't open '{}' for reading")), yamlPath.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("can't open '{}' for reading"), yamlPath.getRelativePath()); if (!athena::io::ValidateFromYAMLStream(reader)) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("'{}' is not DNAMP1::ANCS type")), yamlPath.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("'{}' is not DNAMP1::ANCS type"), yamlPath.getRelativePath()); } athena::io::YAMLDocReader yamlReader; if (!yamlReader.parse(&reader)) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to parse '{}'")), yamlPath.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("unable to parse '{}'"), yamlPath.getRelativePath()); } ANCS ancs; ancs.read(yamlReader); @@ -1014,12 +1014,10 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat ch.animAABBs.clear(); for (const DNAANCS::Actor::Subtype& sub : actor.subtypes) { if (sub.name == ch.name) { - hecl::SystemStringConv chSysName(ch.name); if (!sub.cskrId.empty()) { - hecl::SystemStringConv cskrSysName(sub.cskrId); - ch.cskr = inPath.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.CSKR")), chSysName, cskrSysName)); + ch.cskr = inPath.ensureAuxInfo(fmt::format(FMT_STRING("{}_{}.CSKR"), ch.name, sub.cskrId)); } else { - ch.cskr = inPath.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.CSKR")), chSysName)); + ch.cskr = inPath.ensureAuxInfo(fmt::format(FMT_STRING("{}.CSKR"), ch.name)); } /* Add subtype AABBs */ @@ -1040,14 +1038,12 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat auto search = std::find_if(sub.overlayMeshes.cbegin(), sub.overlayMeshes.cend(), [](const auto& p) { return p.name == "ICE"; }); if (search != sub.overlayMeshes.cend()) { - hecl::SystemStringConv overlaySys(search->name); ch.cmdlIce = search->mesh; if (!search->cskrId.empty()) { - hecl::SystemStringConv cskrSys(search->cskrId); ch.cskrIce = inPath.ensureAuxInfo( - fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), chSysName, overlaySys, cskrSys)); + fmt::format(FMT_STRING("{}.{}_{}.CSKR"), ch.name, search->name, search->cskrId)); } else { - ch.cskrIce = inPath.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}.CSKR")), chSysName, overlaySys)); + ch.cskrIce = inPath.ensureAuxInfo(fmt::format(FMT_STRING("{}.{}.CSKR"), ch.name, search->name)); } } } @@ -1064,15 +1060,13 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat /* Set Animation Resource IDs */ ancs.enumeratePrimitives([&](AnimationSet::MetaAnimPrimitive& prim) { - hecl::SystemStringConv sysStr(prim.animName); for (const DNAANCS::Action& act : actor.actions) { if (act.name == prim.animName) { hecl::ProjectPath pathOut; if (!act.animId.empty()) { - hecl::SystemStringConv idSys(act.animId); - pathOut = inPath.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.ANIM")), sysStr, idSys)); + pathOut = inPath.ensureAuxInfo(fmt::format(FMT_STRING("{}_{}.ANIM"), prim.animName, act.animId)); } else { - inPath.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.ANIM")), sysStr)); + inPath.ensureAuxInfo(fmt::format(FMT_STRING("{}.ANIM"), prim.animName)); } prim.animId = pathOut; break; @@ -1085,31 +1079,29 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat hecl::DirectoryEnumerator dEnum(inPath.getParentPath().getAbsolutePath()); ancs.animationSet.animResources.reserve(actor.actions.size()); for (const DNAANCS::Action& act : actor.actions) { - hecl::SystemStringConv sysStr(act.name); hecl::ProjectPath pathOut; if (!act.animId.empty()) { - hecl::SystemStringConv animIdSys(act.animId); - pathOut = inPath.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.ANIM")), sysStr, animIdSys)); + pathOut = inPath.ensureAuxInfo(fmt::format(FMT_STRING("{}_{}.ANIM"), act.name, act.animId)); } else { - pathOut = inPath.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.ANIM")), sysStr)); + pathOut = inPath.ensureAuxInfo(fmt::format(FMT_STRING("{}.ANIM"), act.name)); } ancs.animationSet.animResources.emplace_back(); ancs.animationSet.animResources.back().animId = pathOut; /* Check for associated EVNT YAML */ - hecl::SystemString testPrefix( - inPath.getWithExtension(fmt::format(FMT_STRING(_SYS_STR(".{}_")), sysStr).c_str(), true).getLastComponent()); + std::string testPrefix( + inPath.getWithExtension(fmt::format(FMT_STRING(".{}_"), act.name).c_str(), true).getLastComponent()); hecl::ProjectPath evntYamlPath; for (const auto& ent : dEnum) { if (hecl::StringUtils::BeginsWith(ent.m_name, testPrefix.c_str()) && - hecl::StringUtils::EndsWith(ent.m_name, _SYS_STR(".evnt.yaml"))) { + hecl::StringUtils::EndsWith(ent.m_name, ".evnt.yaml")) { evntYamlPath = hecl::ProjectPath(inPath.getParentPath(), ent.m_name); break; } } if (evntYamlPath.isFile()) { - evntYamlPath = evntYamlPath.ensureAuxInfo(_SYS_STR("")); + evntYamlPath = evntYamlPath.ensureAuxInfo(""); ancs.animationSet.animResources.back().evntId = evntYamlPath; } } @@ -1121,27 +1113,25 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat return true; } -static const hecl::SystemRegex regCskrNameId(_SYS_STR(R"((.*)_[0-9a-fA-F]{8}\.CSKR)"), +static const std::regex regCskrNameId(R"((.*)_[0-9a-fA-F]{8}\.CSKR)", std::regex::ECMAScript | std::regex::optimize); -static const hecl::SystemRegex regCskrName(_SYS_STR(R"((.*)\.CSKR)"), std::regex::ECMAScript | std::regex::optimize); +static const std::regex regCskrName(R"((.*)\.CSKR)", std::regex::ECMAScript | std::regex::optimize); bool ANCS::CookCSKR(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const DNAANCS::Actor& actor, const std::function& modelCookFunc) { auto auxInfo = inPath.getAuxInfo(); - hecl::SystemViewRegexMatch match; + std::match_results match; if (!std::regex_search(auxInfo.begin(), auxInfo.end(), match, regCskrNameId) && !std::regex_search(auxInfo.begin(), auxInfo.end(), match, regCskrName)) return false; - hecl::SystemString subName = match[1].str(); - hecl::SystemString overName; - auto dotPos = subName.rfind(_SYS_STR('.')); - if (dotPos != hecl::SystemString::npos) { - overName = hecl::SystemString(subName.begin() + dotPos + 1, subName.end()); - subName = hecl::SystemString(subName.begin(), subName.begin() + dotPos); + std::string subName = match[1].str(); + std::string overName; + auto dotPos = subName.rfind('.'); + if (dotPos != std::string::npos) { + overName = std::string(subName.begin() + dotPos + 1, subName.end()); + subName = std::string(subName.begin(), subName.begin() + dotPos); } - hecl::SystemUTF8Conv subNameView(subName); - hecl::SystemUTF8Conv overNameView(overName); /* Build bone ID map */ std::unordered_map boneIdMap; @@ -1150,48 +1140,48 @@ bool ANCS::CookCSKR(const hecl::ProjectPath& outPath, const hecl::ProjectPath& i } const DNAANCS::Actor::Subtype* subtype = nullptr; - if (subName != _SYS_STR("ATTACH")) { + if (subName != "ATTACH") { for (const DNAANCS::Actor::Subtype& sub : actor.subtypes) { - if (sub.name == subNameView.str()) { + if (sub.name == subName) { subtype = ⊂ break; } } if (!subtype) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find subtype '{}'")), subName); + Log.report(logvisor::Fatal, FMT_STRING("unable to find subtype '{}'"), subName); } const hecl::ProjectPath* modelPath = nullptr; - if (subName == _SYS_STR("ATTACH")) { + if (subName == "ATTACH") { const DNAANCS::Actor::Attachment* attachment = nullptr; for (const DNAANCS::Actor::Attachment& att : actor.attachments) { - if (att.name == overNameView.str()) { + if (att.name == overName) { attachment = &att; break; } } if (!attachment) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find attachment '{}'")), overName); + Log.report(logvisor::Fatal, FMT_STRING("unable to find attachment '{}'"), overName); modelPath = &attachment->mesh; } else if (overName.empty()) { modelPath = &subtype->mesh; } else { for (const auto& overlay : subtype->overlayMeshes) - if (overlay.name == overNameView.str()) { + if (overlay.name == overName) { modelPath = &overlay.mesh; break; } } if (!modelPath) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to resolve model path of {}:{}")), subName, overName); + Log.report(logvisor::Fatal, FMT_STRING("unable to resolve model path of {}:{}"), subName, overName); if (!modelPath->isFile()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to resolve '{}'")), modelPath->getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("unable to resolve '{}'"), modelPath->getRelativePath()); - hecl::ProjectPath skinIntPath = modelPath->getCookedPath(SpecEntMP1).getWithExtension(_SYS_STR(".skinint")); + hecl::ProjectPath skinIntPath = modelPath->getCookedPath(SpecEntMP1).getWithExtension(".skinint"); if (!skinIntPath.isFileOrGlob() || skinIntPath.getModtime() < modelPath->getModtime()) if (!modelCookFunc(*modelPath)) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to cook '{}'")), modelPath->getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("unable to cook '{}'"), modelPath->getRelativePath()); std::vector>, uint32_t>> skins; uint32_t posCount = 0; @@ -1216,7 +1206,7 @@ bool ANCS::CookCSKR(const hecl::ProjectPath& outPath, const hecl::ProjectPath& i const std::string& name = boneNames[bIdx]; auto search = boneIdMap.find(name); if (search == boneIdMap.cend()) - Log.report(logvisor::Fatal, FMT_STRING("unable to find bone '{}' in {}"), name, inPath.getRelativePathUTF8()); + Log.report(logvisor::Fatal, FMT_STRING("unable to find bone '{}' in {}"), name, inPath.getRelativePath()); virtualBone.first.emplace_back(search->second, weight); } virtualBone.second = skinIO.readUint32Big(); @@ -1251,20 +1241,18 @@ bool ANCS::CookCSKR(const hecl::ProjectPath& outPath, const hecl::ProjectPath& i bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const DNAANCS::Actor& actor, const std::function& modelCookFunc) { auto auxInfo = inPath.getAuxInfo(); - hecl::SystemViewRegexMatch match; + std::match_results match; if (!std::regex_search(auxInfo.begin(), auxInfo.end(), match, regCskrNameId) && !std::regex_search(auxInfo.begin(), auxInfo.end(), match, regCskrName)) return false; - hecl::SystemString subName = match[1].str(); - hecl::SystemString overName; - auto dotPos = subName.rfind(_SYS_STR('.')); - if (dotPos != hecl::SystemString::npos) { - overName = hecl::SystemString(subName.begin() + dotPos + 1, subName.end()); - subName = hecl::SystemString(subName.begin(), subName.begin() + dotPos); + std::string subName = match[1].str(); + std::string overName; + auto dotPos = subName.rfind('.'); + if (dotPos != std::string::npos) { + overName = std::string(subName.begin() + dotPos + 1, subName.end()); + subName = std::string(subName.begin(), subName.begin() + dotPos); } - hecl::SystemUTF8Conv subNameView(subName); - hecl::SystemUTF8Conv overNameView(overName); /* Build bone ID map */ std::unordered_map boneIdMap; @@ -1273,48 +1261,48 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath, const hecl::ProjectPath& } const DNAANCS::Actor::Subtype* subtype = nullptr; - if (subName != _SYS_STR("ATTACH")) { + if (subName != "ATTACH") { for (const DNAANCS::Actor::Subtype& sub : actor.subtypes) { - if (sub.name == subNameView.str()) { + if (sub.name == subName) { subtype = ⊂ break; } } if (!subtype) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find subtype '{}'")), subName); + Log.report(logvisor::Fatal, FMT_STRING("unable to find subtype '{}'"), subName); } const hecl::ProjectPath* modelPath = nullptr; - if (subName == _SYS_STR("ATTACH")) { + if (subName == "ATTACH") { const DNAANCS::Actor::Attachment* attachment = nullptr; for (const DNAANCS::Actor::Attachment& att : actor.attachments) { - if (att.name == overNameView.str()) { + if (att.name == overName) { attachment = &att; break; } } if (!attachment) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find attachment '{}'")), overName); + Log.report(logvisor::Fatal, FMT_STRING("unable to find attachment '{}'"), overName); modelPath = &attachment->mesh; } else if (overName.empty()) { modelPath = &subtype->mesh; } else { for (const auto& overlay : subtype->overlayMeshes) - if (overlay.name == overNameView.str()) { + if (overlay.name == overName) { modelPath = &overlay.mesh; break; } } if (!modelPath) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to resolve model path of {}:{}")), subName, overName); + Log.report(logvisor::Fatal, FMT_STRING("unable to resolve model path of {}:{}"), subName, overName); if (!modelPath->isFile()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to resolve '{}'")), modelPath->getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("unable to resolve '{}'"), modelPath->getRelativePath()); - hecl::ProjectPath skinIntPath = modelPath->getCookedPath(SpecEntMP1PC).getWithExtension(_SYS_STR(".skinint")); + hecl::ProjectPath skinIntPath = modelPath->getCookedPath(SpecEntMP1PC).getWithExtension(".skinint"); if (!skinIntPath.isFileOrGlob() || skinIntPath.getModtime() < modelPath->getModtime()) if (!modelCookFunc(*modelPath)) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to cook '{}'")), modelPath->getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("unable to cook '{}'"), modelPath->getRelativePath()); uint32_t bankCount = 0; std::vector> skinBanks; @@ -1354,7 +1342,7 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath, const hecl::ProjectPath& const std::string& name = boneNames[bIdx]; auto search = boneIdMap.find(name); if (search == boneIdMap.cend()) - Log.report(logvisor::Fatal, FMT_STRING("unable to find bone '{}' in {}"), name, inPath.getRelativePathUTF8()); + Log.report(logvisor::Fatal, FMT_STRING("unable to find bone '{}' in {}"), name, inPath.getRelativePath()); virtualBone.emplace_back(search->second, weight); } } @@ -1374,7 +1362,7 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath, const hecl::ProjectPath& const std::string& name = boneNames[bIdx]; auto search = boneIdMap.find(name); if (search == boneIdMap.cend()) - Log.report(logvisor::Fatal, FMT_STRING("unable to find bone '{}' in {}"), name, inPath.getRelativePathUTF8()); + Log.report(logvisor::Fatal, FMT_STRING("unable to find bone '{}' in {}"), name, inPath.getRelativePath()); skinOut.writeUint32Big(search->second); } } @@ -1394,24 +1382,23 @@ bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath, const hecl::ProjectPath& return true; } -static const hecl::SystemRegex regAnimNameId(_SYS_STR(R"((.*)_[0-9a-fA-F]{8}\.ANIM)"), +static const std::regex regAnimNameId(R"((.*)_[0-9a-fA-F]{8}\.ANIM)", std::regex::ECMAScript | std::regex::optimize); -static const hecl::SystemRegex regAnimName(_SYS_STR(R"((.*)\.ANIM)"), std::regex::ECMAScript | std::regex::optimize); +static const std::regex regAnimName(R"((.*)\.ANIM)", std::regex::ECMAScript | std::regex::optimize); bool ANCS::CookANIM(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const DNAANCS::Actor& actor, hecl::blender::DataStream& ds, bool pc) { auto auxInfo = inPath.getAuxInfo(); - hecl::SystemViewRegexMatch match; + std::match_results match; if (!std::regex_search(auxInfo.begin(), auxInfo.end(), match, regAnimNameId) && !std::regex_search(auxInfo.begin(), auxInfo.end(), match, regAnimName)) return false; - hecl::SystemString actName = match[1].str(); - hecl::SystemUTF8Conv actNameView(actName); - DNAANCS::Action action = ds.compileActionChannelsOnly(actNameView.str()); + std::string actName = match[1].str(); + DNAANCS::Action action = ds.compileActionChannelsOnly(actName); if (!actor.armatures.size()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("0 armatures in {}")), inPath.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("0 armatures in {}"), inPath.getRelativePath()); /* Build bone ID map */ std::unordered_map boneIdMap; @@ -1430,18 +1417,18 @@ bool ANCS::CookANIM(const hecl::ProjectPath& outPath, const hecl::ProjectPath& i ANIM anim(action, boneIdMap, *rigInv, pc); /* Check for associated EVNT YAML */ - hecl::SystemString testPrefix( - inPath.getWithExtension(fmt::format(FMT_STRING(_SYS_STR(".{}_")), actName).c_str(), true).getLastComponent()); + std::string testPrefix( + inPath.getWithExtension(fmt::format(FMT_STRING(".{}_"), actName).c_str(), true).getLastComponent()); hecl::ProjectPath evntYamlPath; for (const auto& ent : hecl::DirectoryEnumerator(inPath.getParentPath().getAbsolutePath())) { if (hecl::StringUtils::BeginsWith(ent.m_name, testPrefix.c_str()) && - hecl::StringUtils::EndsWith(ent.m_name, _SYS_STR(".evnt.yaml"))) { + hecl::StringUtils::EndsWith(ent.m_name, ".evnt.yaml")) { evntYamlPath = hecl::ProjectPath(inPath.getParentPath(), ent.m_name); break; } } if (evntYamlPath.isFile()) { - evntYamlPath = evntYamlPath.ensureAuxInfo(_SYS_STR("")); + evntYamlPath = evntYamlPath.ensureAuxInfo(""); anim.m_anim->evnt = evntYamlPath; } diff --git a/DataSpec/DNAMP1/ANCS.hpp b/DataSpec/DNAMP1/ANCS.hpp index cb9c4fa1f..9e00da1e4 100644 --- a/DataSpec/DNAMP1/ANCS.hpp +++ b/DataSpec/DNAMP1/ANCS.hpp @@ -404,7 +404,7 @@ struct ANCS : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged); + std::function fileChanged); static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const DNAANCS::Actor& actor); diff --git a/DataSpec/DNAMP1/ANIM.hpp b/DataSpec/DNAMP1/ANIM.hpp index e1dda6619..e1983ebe5 100644 --- a/DataSpec/DNAMP1/ANIM.hpp +++ b/DataSpec/DNAMP1/ANIM.hpp @@ -190,9 +190,8 @@ struct ANIM : BigDNA { void extractEVNT(const DNAANCS::AnimationResInfo& animInfo, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, bool force) const { if (m_anim->evnt.isValid()) { - hecl::SystemStringConv sysStr(animInfo.name); hecl::ProjectPath evntYamlPath = outPath.getWithExtension( - fmt::format(FMT_STRING(_SYS_STR(".{}_{}.evnt.yaml")), sysStr, m_anim->evnt).c_str(), true); + fmt::format(FMT_STRING(".{}_{}.evnt.yaml"), animInfo.name, m_anim->evnt).c_str(), true); hecl::ProjectPath::Type evntYamlType = evntYamlPath.getPathType(); if (force || evntYamlType == hecl::ProjectPath::Type::None) { diff --git a/DataSpec/DNAMP1/CINF.cpp b/DataSpec/DNAMP1/CINF.cpp index 27bbeed83..4a4773147 100644 --- a/DataSpec/DNAMP1/CINF.cpp +++ b/DataSpec/DNAMP1/CINF.cpp @@ -156,7 +156,7 @@ CINF::CINF(const Armature& armature, std::unordered_map& i bool CINF::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { if (!force && outPath.isFile()) return true; diff --git a/DataSpec/DNAMP1/CINF.hpp b/DataSpec/DNAMP1/CINF.hpp index 7a240ee9c..877b401c2 100644 --- a/DataSpec/DNAMP1/CINF.hpp +++ b/DataSpec/DNAMP1/CINF.hpp @@ -48,7 +48,7 @@ struct CINF : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged); + std::function fileChanged); static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const hecl::blender::Armature& armature); diff --git a/DataSpec/DNAMP1/CMDL.cpp b/DataSpec/DNAMP1/CMDL.cpp index 4733b847b..caae1808f 100644 --- a/DataSpec/DNAMP1/CMDL.cpp +++ b/DataSpec/DNAMP1/CMDL.cpp @@ -5,7 +5,7 @@ namespace DataSpec::DNAMP1 { bool CMDL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { /* Check for RigPair */ CINF cinf; CSKR cskr; @@ -28,14 +28,14 @@ bool CMDL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: #if 0 /* Cook and re-extract test */ - hecl::ProjectPath tempOut = outPath.getWithExtension(_SYS_STR(".recook"), true); + hecl::ProjectPath tempOut = outPath.getWithExtension(".recook", true); hecl::blender::Connection::DataStream ds = conn.beginData(); DNACMDL::Mesh mesh = ds.compileMesh(hecl::TopologyTriStrips, -1); ds.close(); DNACMDL::WriteCMDL(tempOut, outPath, mesh); athena::io::FileReader reader(tempOut.getAbsolutePath()); - hecl::ProjectPath tempBlend = outPath.getWithExtension(_SYS_STR(".recook.blend"), true); + hecl::ProjectPath tempBlend = outPath.getWithExtension(".recook.blend", true); if (!conn.createBlend(tempBlend, hecl::blender::Connection::TypeMesh)) return false; DNACMDL::ReadCMDLToBlender, MaterialSet, std::pair, DNACMDL::SurfaceHeader_1_2, 2> @@ -43,7 +43,7 @@ bool CMDL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: return conn.saveBlend(); #elif 0 /* HMDL cook test */ - hecl::ProjectPath tempOut = outPath.getWithExtension(_SYS_STR(".recook"), true); + hecl::ProjectPath tempOut = outPath.getWithExtension(".recook", true); hecl::blender::Connection::DataStream ds = conn.beginData(); DNACMDL::Mesh mesh = ds.compileMesh(hecl::HMDLTopology::TriStrips, 16); ds.close(); @@ -61,7 +61,7 @@ bool CMDL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat /* Output skinning intermediate */ auto vertCountIt = skinMesh.contiguousSkinVertCounts.cbegin(); - athena::io::FileWriter writer(outPath.getWithExtension(_SYS_STR(".skinint")).getAbsolutePath()); + athena::io::FileWriter writer(outPath.getWithExtension(".skinint").getAbsolutePath()); writer.writeUint32Big(skinMesh.boneNames.size()); for (const std::string& boneName : skinMesh.boneNames) writer.writeString(boneName); @@ -90,7 +90,7 @@ bool CMDL::HMDLCook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& i return false; /* Output skinning intermediate */ - athena::io::FileWriter writer(outPath.getWithExtension(_SYS_STR(".skinint")).getAbsolutePath()); + athena::io::FileWriter writer(outPath.getWithExtension(".skinint").getAbsolutePath()); writer.writeUint32Big(mesh.skinBanks.banks.size()); for (const DNACMDL::Mesh::SkinBanks::Bank& sb : mesh.skinBanks.banks) { writer.writeUint32Big(sb.m_boneIdxs.size()); diff --git a/DataSpec/DNAMP1/CMDL.hpp b/DataSpec/DNAMP1/CMDL.hpp index 5a18bbadd..a176b2d6d 100644 --- a/DataSpec/DNAMP1/CMDL.hpp +++ b/DataSpec/DNAMP1/CMDL.hpp @@ -14,7 +14,7 @@ namespace DataSpec::DNAMP1 { struct CMDL { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged); + std::function fileChanged); static void Name(const SpecBase& dataSpec, PAKEntryReadStream& rs, PAKRouter& pakRouter, PAK::Entry& entry) { diff --git a/DataSpec/DNAMP1/CSNG.cpp b/DataSpec/DNAMP1/CSNG.cpp index c4e8bbf7f..949003df0 100644 --- a/DataSpec/DNAMP1/CSNG.cpp +++ b/DataSpec/DNAMP1/CSNG.cpp @@ -4,8 +4,8 @@ namespace DataSpec::DNAMP1 { bool CSNG::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - hecl::ProjectPath midPath = outPath.getWithExtension(_SYS_STR(".mid"), true); - hecl::ProjectPath yamlPath = outPath.getWithExtension(_SYS_STR(".yaml"), true); + hecl::ProjectPath midPath = outPath.getWithExtension(".mid", true); + hecl::ProjectPath yamlPath = outPath.getWithExtension(".yaml", true); Header head; head.read(rs); @@ -36,16 +36,16 @@ bool CSNG::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { } /* Update !songs.yaml for Amuse editor */ - hecl::ProjectPath audGrp(outPath.getParentPath().getParentPath(), _SYS_STR("AudioGrp")); + hecl::ProjectPath audGrp(outPath.getParentPath().getParentPath(), "AudioGrp"); audGrp.makeDirChain(true); - hecl::ProjectPath songsPath(audGrp, _SYS_STR("!songs.yaml")); + hecl::ProjectPath songsPath(audGrp, "!songs.yaml"); std::optional r; if (songsPath.isFile()) r.emplace(songsPath.getAbsolutePath()); athena::io::YAMLDocWriter ydw("amuse::Songs", r ? &*r : nullptr); r = std::nullopt; ydw.writeString(fmt::format(FMT_STRING("{:04X}"), head.midiSetupId), - fmt::format(FMT_STRING("../MidiData/{}"), midPath.getLastComponentUTF8())); + fmt::format(FMT_STRING("../MidiData/{}"), midPath.getLastComponent())); athena::io::FileWriter w(songsPath.getAbsolutePath()); ydw.finish(&w); @@ -53,8 +53,8 @@ bool CSNG::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { } bool CSNG::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) { - hecl::ProjectPath midPath = inPath.getWithExtension(_SYS_STR(".mid"), true); - hecl::ProjectPath yamlPath = inPath.getWithExtension(_SYS_STR(".yaml"), true); + hecl::ProjectPath midPath = inPath.getWithExtension(".mid", true); + hecl::ProjectPath yamlPath = inPath.getWithExtension(".yaml", true); std::vector sngData; { diff --git a/DataSpec/DNAMP1/DCLN.cpp b/DataSpec/DNAMP1/DCLN.cpp index fbbb9cd34..330ec144d 100644 --- a/DataSpec/DNAMP1/DCLN.cpp +++ b/DataSpec/DNAMP1/DCLN.cpp @@ -54,7 +54,7 @@ void DCLN::sendToBlender(hecl::blender::Connection& conn, std::string_view entry bool DCLN::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { DCLN dcln; dcln.read(rs); hecl::blender::Connection& conn = btok.getBlenderConnection(); @@ -78,7 +78,7 @@ bool DCLN::Cook(const hecl::ProjectPath& outPath, const std::vector& meshe #if DCLN_DUMP_OBB hecl::blender::Connection& conn = hecl::blender::SharedBlenderToken.getBlenderConnection(); - conn.createBlend(outPath.getWithExtension(_SYS_STR(".blend")), hecl::blender::BlendType::ColMesh); + conn.createBlend(outPath.getWithExtension(".blend"), hecl::blender::BlendType::ColMesh); dcln.sendToBlender(conn, "BLAH"); conn.saveBlend(); #endif diff --git a/DataSpec/DNAMP1/DCLN.hpp b/DataSpec/DNAMP1/DCLN.hpp index 2136e029d..380de3e44 100644 --- a/DataSpec/DNAMP1/DCLN.hpp +++ b/DataSpec/DNAMP1/DCLN.hpp @@ -86,7 +86,7 @@ struct DCLN : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged); + std::function fileChanged); static bool Cook(const hecl::ProjectPath& outPath, const std::vector& meshes); }; diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index b0dd457e2..b071c99da 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -78,18 +78,18 @@ PAKBridge::PAKBridge(const nod::Node& node, bool doExtract) STRG mlvlName; mlvlName.read(rs); if (m_levelString.size()) - m_levelString += _SYS_STR(", "); - m_levelString += mlvlName.getSystemString(FOURCC('ENGL'), 0); + m_levelString += ", "; + m_levelString += mlvlName.getUTF8(FOURCC('ENGL'), 0); } } } } -static hecl::SystemString LayerName(std::string_view name) { - hecl::SystemString ret(hecl::SystemStringConv(name).sys_str()); +static std::string LayerName(std::string_view name) { + std::string ret(name); for (auto& ch : ret) - if (ch == _SYS_STR('/') || ch == _SYS_STR('\\')) - ch = _SYS_STR('-'); + if (ch == '/' || ch == '\\') + ch = '-'; return ret; } @@ -106,7 +106,7 @@ void PAKBridge::build() { } std::string catalogueName; std::string bestName = m_pak.bestEntryName(m_node, entry, catalogueName); - level.name = hecl::SystemStringConv(bestName).sys_str(); + level.name = bestName; level.areas.reserve(mlvl.areaCount); unsigned layerIdx = 0; @@ -148,17 +148,17 @@ void PAKBridge::build() { PAKEntryReadStream rs = areaNameEnt->beginReadStream(m_node); areaName.read(rs); } - areaDeps.name = areaName.getSystemString(FOURCC('ENGL'), 0); + areaDeps.name = areaName.getUTF8(FOURCC('ENGL'), 0); areaDeps.name = hecl::StringUtils::TrimWhitespace(areaDeps.name); } if (areaDeps.name.empty()) { std::string idStr = area.areaMREAId.toString(); - areaDeps.name = hecl::SystemString(_SYS_STR("MREA_")) + hecl::SystemStringConv(idStr).c_str(); + areaDeps.name = std::string("MREA_") + idStr; } - hecl::SystemString num = fmt::format(FMT_STRING(_SYS_STR("{:02d} ")), ai); + std::string num = fmt::format(FMT_STRING("{:02d} "), ai); areaDeps.name = num + areaDeps.name; - std::string lowerName(hecl::SystemUTF8Conv(areaDeps.name).str()); + std::string lowerName(areaDeps.name); for (char& ch : lowerName) { ch = tolower(ch); if (ch == ' ') @@ -179,7 +179,7 @@ void PAKBridge::build() { layer.active = layerFlags.flags >> (l - 1) & 0x1; layer.name = hecl::StringUtils::TrimWhitespace(layer.name); - num = fmt::format(FMT_STRING(_SYS_STR("{:02d} ")), l - 1); + num = fmt::format(FMT_STRING("{:02d} "), l - 1); layer.name = num + layer.name; layer.resources.reserve(area.depLayers[l] - r); @@ -277,7 +277,7 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, if (mlvl.worldNameId.isValid()) pathOverrides[mlvl.worldNameId] = - hecl::ProjectPath(mlvlDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId)); + hecl::ProjectPath(mlvlDirPath, fmt::format(FMT_STRING("!name_{}.yaml"), mlvl.worldNameId)); for (const MLVL::Area& area : mlvl.areas) { { @@ -294,7 +294,7 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath(); if (area.areaNameId.isValid()) pathOverrides[area.areaNameId] = - hecl::ProjectPath(areaDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), area.areaNameId)); + hecl::ProjectPath(areaDirPath, fmt::format(FMT_STRING("!name_{}.yaml"), area.areaNameId)); } if (mlvl.worldMap.isValid()) { @@ -324,61 +324,61 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, ResExtractor PAKBridge::LookupExtractor(const nod::Node& pakNode, const PAK& pak, const PAK::Entry& entry) { switch (entry.type.toUint32()) { case SBIG('STRG'): - return {STRG::Extract, {_SYS_STR(".yaml")}}; + return {STRG::Extract, {".yaml"}}; case SBIG('SCAN'): - return {SCAN::Extract, {_SYS_STR(".yaml")}, 0, SCAN::Name}; + return {SCAN::Extract, {".yaml"}, 0, SCAN::Name}; case SBIG('HINT'): - return {HINT::Extract, {_SYS_STR(".yaml")}}; + return {HINT::Extract, {".yaml"}}; case SBIG('TXTR'): - return {TXTR::Extract, {_SYS_STR(".png")}}; + return {TXTR::Extract, {".png"}}; case SBIG('AFSM'): - return {AFSM::Extract, {_SYS_STR(".yaml")}}; + return {AFSM::Extract, {".yaml"}}; case SBIG('FRME'): - return {FRME::Extract, {_SYS_STR(".blend")}, 2}; + return {FRME::Extract, {".blend"}, 2}; case SBIG('CINF'): - return {CINF::Extract, {_SYS_STR(".blend")}, 1}; + return {CINF::Extract, {".blend"}, 1}; case SBIG('CMDL'): - return {CMDL::Extract, {_SYS_STR(".blend")}, 1, CMDL::Name}; + return {CMDL::Extract, {".blend"}, 1, CMDL::Name}; case SBIG('DCLN'): - return {DCLN::Extract, {_SYS_STR(".blend")}}; + return {DCLN::Extract, {".blend"}}; case SBIG('ANCS'): - return {ANCS::Extract, {_SYS_STR(".yaml"), _SYS_STR(".blend")}, 2}; + return {ANCS::Extract, {".yaml", ".blend"}, 2}; case SBIG('MLVL'): - return {MLVL::Extract, {_SYS_STR(".yaml"), _SYS_STR(".blend")}, 3}; + return {MLVL::Extract, {".yaml", ".blend"}, 3}; case SBIG('SAVW'): - return {MLVL::ExtractSAVW, {_SYS_STR(".yaml")}, 3}; + return {MLVL::ExtractSAVW, {".yaml"}, 3}; case SBIG('MREA'): - return {MREA::Extract, {_SYS_STR(".blend")}, 4, MREA::Name}; + return {MREA::Extract, {".blend"}, 4, MREA::Name}; case SBIG('MAPA'): - return {MAPA::Extract, {_SYS_STR(".blend")}, 4}; + return {MAPA::Extract, {".blend"}, 4}; case SBIG('MAPW'): - return {MLVL::ExtractMAPW, {_SYS_STR(".yaml")}, 4}; + return {MLVL::ExtractMAPW, {".yaml"}, 4}; case SBIG('MAPU'): - return {MAPU::Extract, {_SYS_STR(".blend")}, 5}; + return {MAPU::Extract, {".blend"}, 5}; case SBIG('PATH'): - return {PATH::Extract, {_SYS_STR(".blend")}, 5}; + return {PATH::Extract, {".blend"}, 5}; case SBIG('PART'): - return {DNAParticle::ExtractGPSM, {_SYS_STR(".gpsm.yaml")}}; + return {DNAParticle::ExtractGPSM, {".gpsm.yaml"}}; case SBIG('ELSC'): - return {DNAParticle::ExtractELSM, {_SYS_STR(".elsm.yaml")}}; + return {DNAParticle::ExtractELSM, {".elsm.yaml"}}; case SBIG('SWHC'): - return {DNAParticle::ExtractSWSH, {_SYS_STR(".swsh.yaml")}}; + return {DNAParticle::ExtractSWSH, {".swsh.yaml"}}; case SBIG('CRSC'): - return {DNAParticle::ExtractCRSM, {_SYS_STR(".crsm.yaml")}}; + return {DNAParticle::ExtractCRSM, {".crsm.yaml"}}; case SBIG('WPSC'): - return {DNAParticle::ExtractWPSM, {_SYS_STR(".wpsm.yaml")}}; + return {DNAParticle::ExtractWPSM, {".wpsm.yaml"}}; case SBIG('DPSC'): - return {DNAParticle::ExtractDPSM, {_SYS_STR(".dpsm.yaml")}}; + return {DNAParticle::ExtractDPSM, {".dpsm.yaml"}}; case SBIG('FONT'): - return {DNAFont::ExtractFONT, {_SYS_STR(".yaml")}}; + return {DNAFont::ExtractFONT, {".yaml"}}; case SBIG('DGRP'): - return {DNADGRP::ExtractDGRP, {_SYS_STR(".yaml")}}; + return {DNADGRP::ExtractDGRP, {".yaml"}}; case SBIG('AGSC'): return {AGSC::Extract, {}}; case SBIG('CSNG'): - return {CSNG::Extract, {_SYS_STR(".mid"), _SYS_STR(".yaml")}}; + return {CSNG::Extract, {".mid", ".yaml"}}; case SBIG('ATBL'): - return {DNAAudio::ATBL::Extract, {_SYS_STR(".yaml")}}; + return {DNAAudio::ATBL::Extract, {".yaml"}}; case SBIG('CTWK'): case SBIG('DUMB'): { std::string catalogueName; @@ -387,47 +387,47 @@ ResExtractor PAKBridge::LookupExtractor(const nod::Node& pakNode, con if (catalogueName == "PlayerRes"sv) { if (isCurrentSpecWii() || getCurrentRegion() == ERegion::PAL || getCurrentRegion() == ERegion::NTSC_J) { /* We need to use the new rep for these tweaks */ - return {ExtractTweak>, {_SYS_STR(".yaml")}}; + return {ExtractTweak>, {".yaml"}}; } /* We need to use the old rep for these tweaks */ - return {ExtractTweak>, {_SYS_STR(".yaml")}}; + return {ExtractTweak>, {".yaml"}}; } if (catalogueName == "GunRes"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "Player"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "CameraBob"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "SlideShow"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "Game"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "Targeting"sv) { if (isCurrentSpecWii() || getCurrentRegion() == ERegion::PAL || getCurrentRegion() == ERegion::NTSC_J) { /* We need to use the new rep for these tweaks */ - return {ExtractTweak>, {_SYS_STR(".yaml")}}; + return {ExtractTweak>, {".yaml"}}; } /* We need to use the old rep for these tweaks */ - return {ExtractTweak>, {_SYS_STR(".yaml")}}; + return {ExtractTweak>, {".yaml"}}; } if (catalogueName == "Gui"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "AutoMapper"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "PlayerControls"sv || catalogueName == "PlayerControls2"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "Ball"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "Particle"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "GuiColors"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "PlayerGun"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "DUMB_MazeSeeds"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; if (catalogueName == "DUMB_SnowForces"sv) - return {ExtractTweak, {_SYS_STR(".yaml")}}; + return {ExtractTweak, {".yaml"}}; } break; } diff --git a/DataSpec/DNAMP1/DNAMP1.hpp b/DataSpec/DNAMP1/DNAMP1.hpp index 8e4b72929..ebc9db828 100644 --- a/DataSpec/DNAMP1/DNAMP1.hpp +++ b/DataSpec/DNAMP1/DNAMP1.hpp @@ -18,14 +18,14 @@ public: using Level = DataSpec::Level; std::unordered_map m_levelDeps; UniqueID32 m_levelId; - hecl::SystemString m_levelString; + std::string m_levelString; PAKBridge(const nod::Node& node, bool doExtract = true); void build(); static ResExtractor LookupExtractor(const nod::Node& pakNode, const PAK& pak, const PAK::Entry& entry); std::string_view getName() const { return m_node.getName(); } UniqueID32 getLevelId() const { return m_levelId; } - hecl::SystemStringView getLevelString() const { return m_levelString; } + std::string_view getLevelString() const { return m_levelString; } using PAKType = PAK; const PAKType& getPAK() const { return m_pak; } const nod::Node& getNode() const { return m_node; } diff --git a/DataSpec/DNAMP1/FRME.cpp b/DataSpec/DNAMP1/FRME.cpp index 9b2743947..8e58f08bf 100644 --- a/DataSpec/DNAMP1/FRME.cpp +++ b/DataSpec/DNAMP1/FRME.cpp @@ -93,7 +93,7 @@ void FRME::Widget::Enumerate(athena::io::IStreamReader& __dna_read widgetInfo = std::make_unique(); break; default: - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unsupported FRME widget type {}")), type); + Log.report(logvisor::Fatal, FMT_STRING("Unsupported FRME widget type {}"), type); } /* widgetInfo */ @@ -174,7 +174,7 @@ void FRME::Widget::CAMRInfo::Enumerate(athena::io::IStreamReader& } else if (projectionType == ProjectionType::Orthographic) { projection = std::make_unique(); } else { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Invalid CAMR projection mode! {}")), int(projectionType)); + Log.report(logvisor::Fatal, FMT_STRING("Invalid CAMR projection mode! {}"), int(projectionType)); } projection->read(__dna_reader); @@ -183,9 +183,9 @@ void FRME::Widget::CAMRInfo::Enumerate(athena::io::IStreamReader& template <> void FRME::Widget::CAMRInfo::Enumerate(athena::io::IStreamWriter& __dna_writer) { if (!projection) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Invalid CAMR projection object!"))); + Log.report(logvisor::Fatal, FMT_STRING("Invalid CAMR projection object!")); if (projection->type != projectionType) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("CAMR projection type does not match actual projection type!"))); + Log.report(logvisor::Fatal, FMT_STRING("CAMR projection type does not match actual projection type!")); __dna_writer.writeUint32Big(atUint32(projectionType)); projection->write(__dna_writer); @@ -274,7 +274,7 @@ AT_SPECIALIZE_DNA(FRME::Widget::TXPNInfo) bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { if (!force && outPath.isFile()) return true; @@ -390,7 +390,7 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: using IMGPInfo = Widget::IMGPInfo; if (IMGPInfo* info = static_cast(w.widgetInfo.get())) { std::string texName; - hecl::SystemString resPath; + std::string resPath; if (info->texture.isValid()) { texName = pakRouter.getBestEntryName(info->texture); const nod::Node* node; @@ -405,13 +405,12 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: } if (resPath.size()) { - hecl::SystemUTF8Conv resPathView(resPath); os.format(FMT_STRING("if '{}' in bpy.data.images:\n" " image = bpy.data.images['{}']\n" "else:\n" " image = bpy.data.images.load('''//{}''')\n" " image.name = '{}'\n"), - texName, texName, resPathView, texName); + texName, texName, resPath, texName); } else { os << "image = None\n"; } @@ -489,7 +488,7 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: hecl::ProjectPath modelPath = pakRouter.getWorking(info->model); const PAKRouter::EntryType* cmdlE = pakRouter.lookupEntry(info->model, nullptr, true, true); - os.linkMesh(modelPath.getAbsolutePathUTF8(), pakRouter.getBestEntryName(*cmdlE)); + os.linkMesh(modelPath.getAbsolutePath(), pakRouter.getBestEntryName(*cmdlE)); os.format(FMT_STRING("frme_obj.retro_model_light_mask = {}\n"), info->lightMask); os << "print(obj.name)\n" @@ -536,10 +535,10 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: "bpy.types.Object.retro_textpane_hjustification[1]['items'][{}][0]\n" "frme_obj.retro_textpane_vjustification = " "bpy.types.Object.retro_textpane_vjustification[1]['items'][{}][0]\n"), - info->xDim, info->zDim, scaleF[0], scaleF[1], scaleF[2], fontPath.getRelativePathUTF8(), + info->xDim, info->zDim, scaleF[0], scaleF[1], scaleF[2], fontPath.getRelativePath(), info->wordWrap ? "True" : "False", info->horizontal ? "True" : "False", fillF[0], fillF[1], fillF[2], fillF[3], outlineF[0], outlineF[1], outlineF[2], outlineF[3], extentF[0], extentF[1], - jpFontPath.getRelativePathUTF8(), info->jpnPointScale[0], info->jpnPointScale[1], + jpFontPath.getRelativePath(), info->jpnPointScale[0], info->jpnPointScale[1], int(info->justification), int(info->verticalJustification)); } } else if (w.type == SBIG('TBGP')) { @@ -569,7 +568,7 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: if (ENRGInfo* info = static_cast(w.widgetInfo.get())) { hecl::ProjectPath txtrPath = pakRouter.getWorking(info->texture); if (txtrPath) - os.format(FMT_STRING("frme_obj.retro_energybar_texture_path = '{}'\n"), txtrPath.getRelativePathUTF8()); + os.format(FMT_STRING("frme_obj.retro_energybar_texture_path = '{}'\n"), txtrPath.getRelativePath()); } } else if (w.type == SBIG('METR')) { using METRInfo = Widget::METRInfo; diff --git a/DataSpec/DNAMP1/FRME.hpp b/DataSpec/DNAMP1/FRME.hpp index 8a2f5f9ea..5e24d7c9c 100644 --- a/DataSpec/DNAMP1/FRME.hpp +++ b/DataSpec/DNAMP1/FRME.hpp @@ -268,7 +268,7 @@ struct FRME : BigDNA { Vector widgets; static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged); + std::function fileChanged); }; } // namespace DataSpec::DNAMP1 diff --git a/DataSpec/DNAMP1/MAPA.hpp b/DataSpec/DNAMP1/MAPA.hpp index c8d6674c6..49a0daaf7 100644 --- a/DataSpec/DNAMP1/MAPA.hpp +++ b/DataSpec/DNAMP1/MAPA.hpp @@ -11,7 +11,7 @@ namespace DataSpec::DNAMP1 { struct MAPA : DNAMAPA::MAPA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { MAPA mapa; mapa.read(rs); hecl::blender::Connection& conn = btok.getBlenderConnection(); diff --git a/DataSpec/DNAMP1/MAPU.hpp b/DataSpec/DNAMP1/MAPU.hpp index bbd42b696..a29254dc0 100644 --- a/DataSpec/DNAMP1/MAPU.hpp +++ b/DataSpec/DNAMP1/MAPU.hpp @@ -11,7 +11,7 @@ namespace DataSpec::DNAMP1 { struct MAPU : DNAMAPU::MAPU { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { MAPU mapu; mapu.read(rs); hecl::blender::Connection& conn = btok.getBlenderConnection(); diff --git a/DataSpec/DNAMP1/MLVL.cpp b/DataSpec/DNAMP1/MLVL.cpp index b0b88e319..fe7c3de90 100644 --- a/DataSpec/DNAMP1/MLVL.cpp +++ b/DataSpec/DNAMP1/MLVL.cpp @@ -16,7 +16,7 @@ namespace DNAMP1 { bool MLVL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { MLVL mlvl; mlvl.read(rs); const nod::Node* node; @@ -31,13 +31,13 @@ bool MLVL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: for (const MLVL::Area& area : mlvl.areas) { hecl::ProjectPath areaDir = pakRouter.getWorking(area.areaMREAId).getParentPath(); { - athena::io::FileWriter fw(hecl::ProjectPath(areaDir, _SYS_STR("!memoryid.yaml")).getAbsolutePath()); + athena::io::FileWriter fw(hecl::ProjectPath(areaDir, "!memoryid.yaml").getAbsolutePath()); athena::io::YAMLDocWriter w; w.writeUint32("memoryid", area.areaId); w.finish(&fw); } { - athena::io::FileWriter fw(hecl::ProjectPath(areaDir, _SYS_STR("!memoryrelays.yaml")).getAbsolutePath()); + athena::io::FileWriter fw(hecl::ProjectPath(areaDir, "!memoryrelays.yaml").getAbsolutePath()); athena::io::YAMLDocWriter w; std::vector relayIds; @@ -51,12 +51,12 @@ bool MLVL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: w.finish(&fw); } if (pakRouter.mreaHasDupeResources(area.areaMREAId)) - athena::io::FileWriter(hecl::ProjectPath(areaDir, _SYS_STR("!duperes")).getAbsolutePath()); + athena::io::FileWriter(hecl::ProjectPath(areaDir, "!duperes").getAbsolutePath()); areaIdx++; } - athena::io::FileWriter writer(outPath.getWithExtension(_SYS_STR(".yaml"), true).getAbsolutePath()); + athena::io::FileWriter writer(outPath.getWithExtension(".yaml", true).getAbsolutePath()); athena::io::ToYAMLStream(mlvl, writer, &MLVL::writeMeta); hecl::blender::Connection& conn = btok.getBlenderConnection(); return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter, entry, force, fileChanged); @@ -104,7 +104,7 @@ struct LayerResources { bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const World& wld, hecl::blender::Token& btok) { MLVL mlvl = {}; - athena::io::FileReader reader(inPath.getWithExtension(_SYS_STR(".yaml"), true).getAbsolutePath()); + athena::io::FileReader reader(inPath.getWithExtension(".yaml", true).getAbsolutePath()); athena::io::FromYAMLStream(mlvl, reader, &MLVL::readMeta); const hecl::ProjectPath parentPath = inPath.getParentPath(); @@ -112,15 +112,15 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat mlvl.magic = 0xDEAFBABE; mlvl.version = 0x11; - hecl::ProjectPath namePath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!name")); + hecl::ProjectPath namePath = GetPathBeginsWith(dEnum, parentPath, "!name"); if (namePath.isFile()) mlvl.worldNameId = namePath; - hecl::ProjectPath savwPath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!savw")); + hecl::ProjectPath savwPath = GetPathBeginsWith(dEnum, parentPath, "!savw"); if (savwPath.isFile()) { CookSAVW(savwPath.getCookedPath(SpecEntMP1), wld); mlvl.saveWorldId = savwPath; } - hecl::ProjectPath mapwPath = GetPathBeginsWith(dEnum, parentPath, _SYS_STR("!mapw")); + hecl::ProjectPath mapwPath = GetPathBeginsWith(dEnum, parentPath, "!mapw"); if (mapwPath.isFile()) { CookMAPW(mapwPath.getCookedPath(SpecEntMP1), wld); mlvl.worldMap = mapwPath; @@ -133,13 +133,13 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat continue; const hecl::DirectoryEnumerator areaDEnum(area.path.getAbsolutePath()); - const hecl::ProjectPath areaPath = GetPathBeginsWith(areaDEnum, area.path, _SYS_STR("!area")); + const hecl::ProjectPath areaPath = GetPathBeginsWith(areaDEnum, area.path, "!area"); if (!areaPath.isFile()) continue; - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Visiting {}")), area.path.getRelativePath()); + Log.report(logvisor::Info, FMT_STRING("Visiting {}"), area.path.getRelativePath()); - hecl::ProjectPath memRelayPath(area.path, _SYS_STR("!memoryrelays.yaml")); + hecl::ProjectPath memRelayPath(area.path, "!memoryrelays.yaml"); std::vector memRelays; @@ -159,15 +159,15 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat LayerResources layerResources; for (const hecl::DirectoryEnumerator::Entry& e : hecl::DirectoryEnumerator(area.path.getAbsolutePath(), hecl::DirectoryEnumerator::Mode::DirsSorted)) { - hecl::SystemString layerName; - hecl::SystemChar* endCh = nullptr; + std::string layerName; + char* endCh = nullptr; hecl::StrToUl(e.m_name.c_str(), &endCh, 10); if (!endCh) layerName = hecl::StringUtils::TrimWhitespace(e.m_name); else - layerName = hecl::StringUtils::TrimWhitespace(hecl::SystemString(endCh)); + layerName = hecl::StringUtils::TrimWhitespace(std::string(endCh)); - hecl::ProjectPath objectsPath(area.path, e.m_name + _SYS_STR("/!objects.yaml")); + hecl::ProjectPath objectsPath(area.path, e.m_name + "/!objects.yaml"); if (objectsPath.isNone()) continue; @@ -189,7 +189,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat layerResources.beginLayer(); /* Set active flag state */ - hecl::ProjectPath defActivePath(area.path, e.m_name + _SYS_STR("/!defaultactive")); + hecl::ProjectPath defActivePath(area.path, e.m_name + "/!defaultactive"); bool active = defActivePath.isNone() ? false : true; if (!areaInit) { @@ -200,7 +200,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat mlvl.areas.emplace_back(); MLVL::Area& areaOut = mlvl.areas.back(); - namePath = GetPathBeginsWith(areaDEnum, area.path, _SYS_STR("!name")); + namePath = GetPathBeginsWith(areaDEnum, area.path, "!name"); if (namePath.isFile()) areaOut.areaNameId = namePath; @@ -212,7 +212,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat areaOut.areaMREAId = areaPath; areaOut.areaId = 0xffffffff; - hecl::ProjectPath memIdPath(area.path, _SYS_STR("!memoryid.yaml")); + hecl::ProjectPath memIdPath(area.path, "!memoryid.yaml"); if (memIdPath.isFile()) { athena::io::FileReader fr(memIdPath.getAbsolutePath()); athena::io::YAMLDocReader r; @@ -298,8 +298,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat layerResources.addPath(path, true); } - hecl::SystemUTF8Conv layerU8(layerName); - mlvl.layerNames.emplace_back(layerU8.str()); + mlvl.layerNames.emplace_back(layerName); ++nameStartIdx; MLVL::LayerFlags& thisLayFlags = mlvl.layerFlags.back(); @@ -311,7 +310,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat } if (!areaInit) - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("No layer directories for area {}")), area.path.getRelativePath()); + Log.report(logvisor::Info, FMT_STRING("No layer directories for area {}"), area.path.getRelativePath()); /* Build deplist */ MLVL::Area& areaOut = mlvl.areas.back(); @@ -358,7 +357,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat } } - hecl::ProjectPath pathPath = GetPathBeginsWith(areaDEnum, area.path, _SYS_STR("!path")); + hecl::ProjectPath pathPath = GetPathBeginsWith(areaDEnum, area.path, "!path"); metaforce::SObjectTag pathTag = g_curSpec->buildTagFromPath(pathPath); if (pathTag.id.IsValid()) { areaOut.deps.emplace_back(pathTag.id.Value(), pathTag.type); @@ -400,7 +399,7 @@ bool MLVL::CookMAPW(const hecl::ProjectPath& outPath, const World& wld) { continue; /* Area map */ - hecl::ProjectPath mapPath = GetPathBeginsWith(area.path, _SYS_STR("!map")); + hecl::ProjectPath mapPath = GetPathBeginsWith(area.path, "!map"); if (mapPath.isFile()) mapaTags.push_back(g_curSpec->buildTagFromPath(mapPath)); } @@ -432,11 +431,11 @@ bool MLVL::CookSAVW(const hecl::ProjectPath& outPath, const World& wld) { if (area.path.getPathType() != hecl::ProjectPath::Type::Directory) continue; - hecl::ProjectPath areaPath = GetPathBeginsWith(area.path, _SYS_STR("!area")); + hecl::ProjectPath areaPath = GetPathBeginsWith(area.path, "!area"); if (!areaPath.isFile()) continue; - hecl::ProjectPath memRelayPath(area.path, _SYS_STR("/!memoryrelays.yaml")); + hecl::ProjectPath memRelayPath(area.path, "/!memoryrelays.yaml"); std::vector memRelays; if (memRelayPath.isFile()) { athena::io::FileReader fr(memRelayPath.getAbsolutePath()); @@ -448,7 +447,7 @@ bool MLVL::CookSAVW(const hecl::ProjectPath& outPath, const World& wld) { for (const hecl::DirectoryEnumerator::Entry& e : hecl::DirectoryEnumerator(area.path.getAbsolutePath(), hecl::DirectoryEnumerator::Mode::DirsSorted)) { - hecl::ProjectPath objectsPath(area.path, e.m_name + _SYS_STR("/!objects.yaml")); + hecl::ProjectPath objectsPath(area.path, e.m_name + "/!objects.yaml"); if (objectsPath.isNone()) continue; diff --git a/DataSpec/DNAMP1/MLVL.hpp b/DataSpec/DNAMP1/MLVL.hpp index 76e51025e..98dc25587 100644 --- a/DataSpec/DNAMP1/MLVL.hpp +++ b/DataSpec/DNAMP1/MLVL.hpp @@ -129,7 +129,7 @@ struct MLVL : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged); + std::function fileChanged); static bool ExtractMAPW(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath); diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index 7c6ae49a4..b191831b0 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -13,7 +13,7 @@ #define DUMP_OCTREE 0 -extern hecl::SystemString ExeDir; +extern std::string ExeDir; namespace DataSpec::DNAMP1 { @@ -179,7 +179,7 @@ static void OutputOctreeNode(hecl::blender::PyOutStream& os, athena::io::IStream bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function) { + std::function) { using RigPair = std::pair, std::pair>; RigPair dummy = {}; @@ -285,7 +285,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: { rs.seek(secStart, athena::SeekOrigin::Begin); auto visiData = rs.readUBytes(head.secSizes[curSec]); - athena::io::FileWriter visiOut(outPath.getWithExtension(_SYS_STR(".visi"), true).getAbsolutePath()); + athena::io::FileWriter visiOut(outPath.getWithExtension(".visi", true).getAbsolutePath()); visiOut.writeUBytes(visiData.get(), head.secSizes[curSec]); rs.seek(secStart + 4, athena::SeekOrigin::Begin); } @@ -300,7 +300,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: visiWriter.writeUint32(entityId); } } - hecl::ProjectPath visiMetadataPath(outPath.getParentPath(), _SYS_STR("!visi.yaml")); + hecl::ProjectPath visiMetadataPath(outPath.getParentPath(), "!visi.yaml"); athena::io::FileWriter visiMetadata(visiMetadataPath.getAbsolutePath()); visiWriter.finish(&visiMetadata); } @@ -386,7 +386,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat hecl::DirectoryEnumerator dEnum(inPath.getParentPath().getAbsolutePath(), hecl::DirectoryEnumerator::Mode::DirsSorted, false, false, true); for (const hecl::DirectoryEnumerator::Entry& ent : dEnum) { - hecl::ProjectPath layerScriptPath(areaDirPath, ent.m_name + _SYS_STR("/!objects.yaml")); + hecl::ProjectPath layerScriptPath(areaDirPath, ent.m_name + "/!objects.yaml"); if (layerScriptPath.isFile()) layerScriptPaths.push_back(std::move(layerScriptPath)); } @@ -464,7 +464,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat #if DUMP_OCTREE hecl::blender::Connection& conn = btok.getBlenderConnection(); - if (!conn.createBlend(inPath.getWithExtension(_SYS_STR(".octree.blend"), true), hecl::blender::BlendType::Area)) + if (!conn.createBlend(inPath.getWithExtension(".octree.blend", true), hecl::blender::BlendType::Area)) return false; /* Open Py Stream and read sections */ @@ -475,7 +475,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat "from mathutils import Vector\n" "\n" "bpy.context.scene.name = '%s'\n", - inPath.getLastComponentUTF8().data()); + inPath.getLastComponent().data()); athena::io::MemoryReader reader(secs.back().data(), secs.back().size()); reader.readUint32Big(); @@ -534,7 +534,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat #if DUMP_OCTREE hecl::blender::Connection& conn = btok.getBlenderConnection(); - if (!conn.createBlend(inPath.getWithExtension(_SYS_STR(".coctree.blend"), true), hecl::blender::BlendType::Area)) + if (!conn.createBlend(inPath.getWithExtension(".coctree.blend", true), hecl::blender::BlendType::Area)) return false; /* Open Py Stream and read sections */ @@ -545,7 +545,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat "from mathutils import Vector\n" "\n" "bpy.context.scene.name = '%s'\n", - inPath.getLastComponentUTF8().data()); + inPath.getLastComponent().data()); athena::io::MemoryReader reader(collision.bspTree.get(), collision.bspSize); zeus::CAABox colAABB(collision.aabb[0], collision.aabb[1]); @@ -603,7 +603,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat } /* VISI */ - hecl::ProjectPath visiMetadataPath(areaDirPath, _SYS_STR("!visi.yaml")); + hecl::ProjectPath visiMetadataPath(areaDirPath, "!visi.yaml"); bool visiGood = false; if (visiMetadataPath.isFile()) { athena::io::FileReader visiReader(visiMetadataPath.getAbsolutePath()); @@ -628,7 +628,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat } // Check if pre-generated visi exists, recycle if able - hecl::ProjectPath preVisiPath = inPath.getWithExtension(_SYS_STR(".visi"), true); + hecl::ProjectPath preVisiPath = inPath.getWithExtension(".visi", true); if (preVisiPath.getPathType() == hecl::ProjectPath::Type::File) { athena::io::FileReader preVisiReader(preVisiPath.getAbsolutePath()); atUint64 preVisiLen = preVisiReader.length(); @@ -657,7 +657,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat #if !WINDOWS_STORE if (!visiGood) { - hecl::ProjectPath visiIntOut = outPath.getWithExtension(_SYS_STR(".visiint")); + hecl::ProjectPath visiIntOut = outPath.getWithExtension(".visiint"); athena::io::FileWriter w(visiIntOut.getAbsolutePath()); w.writeUint32Big(meshes.size()); for (const DNACMDL::Mesh& mesh : meshes) { @@ -695,18 +695,18 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat w.close(); - hecl::SystemString VisiGenPath = ExeDir + _SYS_STR("/visigen"); + std::string VisiGenPath = ExeDir + "/visigen"; #if _WIN32 - VisiGenPath += _SYS_STR(".exe"); + VisiGenPath += ".exe"; #endif - hecl::SystemString thrIdx = fmt::format(FMT_STRING(_SYS_STR("{}")), hecl::ClientProcess::GetThreadWorkerIdx()); - hecl::SystemString parPid; + std::string thrIdx = fmt::format(FMT_STRING("{}"), hecl::ClientProcess::GetThreadWorkerIdx()); + std::string parPid; #if _WIN32 - parPid = fmt::format(FMT_STRING(_SYS_STR("{}")), reinterpret_cast(GetCurrentProcess())); + parPid = fmt::format(FMT_STRING("{}"), reinterpret_cast(GetCurrentProcess())); #else - parPid = fmt::format(FMT_STRING(_SYS_STR("{}")), (unsigned long long)getpid()); + parPid = fmt::format(FMT_STRING("{}"), (unsigned long long)getpid()); #endif - const hecl::SystemChar* args[] = {VisiGenPath.c_str(), + const char* args[] = {VisiGenPath.c_str(), visiIntOut.getAbsolutePath().data(), preVisiPath.getAbsolutePath().data(), thrIdx.c_str(), @@ -719,7 +719,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat r.readBytesToBuf(secs.back().data(), length); visiGood = true; } else { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to launch {}")), VisiGenPath); + Log.report(logvisor::Fatal, FMT_STRING("Unable to launch {}"), VisiGenPath); } } #endif @@ -730,7 +730,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat /* PATH */ { - const hecl::ProjectPath pathPath = GetPathBeginsWith(inPath.getParentPath(), _SYS_STR("!path")); + const hecl::ProjectPath pathPath = GetPathBeginsWith(inPath.getParentPath(), "!path"); UniqueID32 pathId; if (pathPath.isFile()) pathId = pathPath; diff --git a/DataSpec/DNAMP1/MREA.hpp b/DataSpec/DNAMP1/MREA.hpp index d02722e4d..d0c0b46e5 100644 --- a/DataSpec/DNAMP1/MREA.hpp +++ b/DataSpec/DNAMP1/MREA.hpp @@ -97,7 +97,7 @@ struct MREA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool, hecl::blender::Token& btok, - std::function); + std::function); static void Name(const SpecBase& dataSpec, PAKEntryReadStream& rs, PAKRouter& pakRouter, PAK::Entry& entry); diff --git a/DataSpec/DNAMP1/SCLY.cpp b/DataSpec/DNAMP1/SCLY.cpp index 81e6f3438..e99d97bf4 100644 --- a/DataSpec/DNAMP1/SCLY.cpp +++ b/DataSpec/DNAMP1/SCLY.cpp @@ -43,10 +43,10 @@ void SCLY::exportToLayerDirectories(const PAK::Entry& entry, PAKRouter(athena::io::IStreamReader& rs) { objects.push_back(std::move(obj)); size_t actualLen = rs.position() - start; if (actualLen != len) - Log.report( - logvisor::Fatal, - FMT_STRING(_SYS_STR("Error while reading object of type 0x{:02X}, did not read the expected amount of " - "data, read 0x{:x}, expected 0x{:x}")), - (atUint32)type, actualLen, len); + Log.report(logvisor::Fatal, + FMT_STRING("Error while reading object of type 0x{:02X}, did not read the expected amount of " + "data, read 0x{:x}, expected 0x{:x}"), + (atUint32)type, actualLen, len); rs.seek(start + len, athena::SeekOrigin::Begin); } else { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to find type 0x{:X} in object database")), + Log.report(logvisor::Fatal, FMT_STRING("Unable to find type 0x{:X} in object database"), (atUint32)type); } } @@ -147,7 +146,7 @@ void SCLY::ScriptLayer::Enumerate(athena::io::YAMLDocReader& r obj->type = type; objects.push_back(std::move(obj)); } else - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to find type 0x{:X} in object database")), + Log.report(logvisor::Fatal, FMT_STRING("Unable to find type 0x{:X} in object database"), (atUint32)type); } } diff --git a/DataSpec/DNAMP1/STRG.cpp b/DataSpec/DNAMP1/STRG.cpp index 42e484437..e866b1a67 100644 --- a/DataSpec/DNAMP1/STRG.cpp +++ b/DataSpec/DNAMP1/STRG.cpp @@ -37,7 +37,7 @@ static std::u16string_view::const_iterator UncookTextureList(std::u16string& ret while (true) { UniqueID32 id = ParseTag(&*it); hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id); - ret.append(hecl::UTF8ToChar16(path ? path.getRelativePathUTF8() : id.toString())); + ret.append(hecl::UTF8ToChar16(path ? path.getRelativePath() : id.toString())); it += 8; if (*it == u';') { ret.push_back(u';'); @@ -144,7 +144,7 @@ static std::u16string UncookString(std::u16string_view str) { it += 5; UniqueID32 id = ParseTag(&*it); hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id, true); - ret.append(hecl::UTF8ToChar16(path ? path.getRelativePathUTF8() : id.toString())); + ret.append(hecl::UTF8ToChar16(path ? path.getRelativePath() : id.toString())); ret.push_back(u';'); auto scpos = str.find(u';', it - str.begin()); diff --git a/DataSpec/DNAMP1/STRG.hpp b/DataSpec/DNAMP1/STRG.hpp index b3aad7702..9cc4f2285 100644 --- a/DataSpec/DNAMP1/STRG.hpp +++ b/DataSpec/DNAMP1/STRG.hpp @@ -36,16 +36,6 @@ struct STRG : ISTRG { return search->second->at(idx); return std::u16string(); } - hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const override { - auto search = langMap.find(lang); - if (search != langMap.end()) -#if HECL_UCS2 - return hecl::Char16ToWide(search->second->at(idx)); -#else - return hecl::Char16ToUTF8(search->second->at(idx)); -#endif - return hecl::SystemString(); - } static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { STRG strg; diff --git a/DataSpec/DNAMP1/ScriptObjects/Actor.cpp b/DataSpec/DNAMP1/ScriptObjects/Actor.cpp index e09386a54..da056382e 100644 --- a/DataSpec/DNAMP1/ScriptObjects/Actor.cpp +++ b/DataSpec/DNAMP1/ScriptObjects/Actor.cpp @@ -15,7 +15,7 @@ zeus::CAABox Actor::getVISIAABB(hecl::blender::Token& btok) const { aabbOut = zeus::CAABox(aabb.first, aabb.second); } else if (animationParameters.animationCharacterSet.isValid()) { hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(animationParameters.animationCharacterSet); - conn.openBlend(path.getWithExtension(_SYS_STR(".blend"), true)); + conn.openBlend(path.getWithExtension(".blend", true)); hecl::blender::DataStream ds = conn.beginData(); auto aabb = ds.getMeshAABB(); aabbOut = zeus::CAABox(aabb.first, aabb.second); diff --git a/DataSpec/DNAMP1/ScriptObjects/DoorArea.cpp b/DataSpec/DNAMP1/ScriptObjects/DoorArea.cpp index 6397c342c..766ff4dff 100644 --- a/DataSpec/DNAMP1/ScriptObjects/DoorArea.cpp +++ b/DataSpec/DNAMP1/ScriptObjects/DoorArea.cpp @@ -9,7 +9,7 @@ zeus::CAABox DoorArea::getVISIAABB(hecl::blender::Token& btok) const { if (animationParameters.animationCharacterSet.isValid()) { hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(animationParameters.animationCharacterSet); - conn.openBlend(path.getWithExtension(_SYS_STR(".blend"), true)); + conn.openBlend(path.getWithExtension(".blend", true)); hecl::blender::DataStream ds = conn.beginData(); auto aabb = ds.getMeshAABB(); aabbOut = zeus::CAABox(aabb.first, aabb.second); diff --git a/DataSpec/DNAMP1/ScriptObjects/Platform.cpp b/DataSpec/DNAMP1/ScriptObjects/Platform.cpp index dce842368..a468a110b 100644 --- a/DataSpec/DNAMP1/ScriptObjects/Platform.cpp +++ b/DataSpec/DNAMP1/ScriptObjects/Platform.cpp @@ -15,7 +15,7 @@ zeus::CAABox Platform::getVISIAABB(hecl::blender::Token& btok) const { aabbOut = zeus::CAABox(aabb.first, aabb.second); } else if (animationParameters.animationCharacterSet.isValid()) { hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(animationParameters.animationCharacterSet); - conn.openBlend(path.getWithExtension(_SYS_STR(".blend"), true)); + conn.openBlend(path.getWithExtension(".blend", true)); hecl::blender::DataStream ds = conn.beginData(); auto aabb = ds.getMeshAABB(); aabbOut = zeus::CAABox(aabb.first, aabb.second); diff --git a/DataSpec/DNAMP2/AGSC.cpp b/DataSpec/DNAMP2/AGSC.cpp index 9dd18ad58..a0c6496b6 100644 --- a/DataSpec/DNAMP2/AGSC.cpp +++ b/DataSpec/DNAMP2/AGSC.cpp @@ -30,7 +30,7 @@ bool AGSC::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& dir) { /* Write out project/pool */ { auto projd = group.getProj().toYAML(); - athena::io::FileWriter fo(hecl::ProjectPath(dir, _SYS_STR("!project.yaml")).getAbsolutePath()); + athena::io::FileWriter fo(hecl::ProjectPath(dir, "!project.yaml").getAbsolutePath()); if (fo.hasError()) return false; fo.writeUBytes(projd.data(), projd.size()); @@ -38,7 +38,7 @@ bool AGSC::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& dir) { { auto poold = group.getPool().toYAML(); - athena::io::FileWriter fo(hecl::ProjectPath(dir, _SYS_STR("!pool.yaml")).getAbsolutePath()); + athena::io::FileWriter fo(hecl::ProjectPath(dir, "!pool.yaml").getAbsolutePath()); if (fo.hasError()) return false; fo.writeUBytes(poold.data(), poold.size()); @@ -61,7 +61,7 @@ bool AGSC::Cook(const hecl::ProjectPath& dir, const hecl::ProjectPath& outPath) auto sdirSamp = group.getSdir().toGCNData(group); Header head; - head.groupName = dir.getLastComponentUTF8(); + head.groupName = dir.getLastComponent(); for (const auto& p : group.getProj().sfxGroups()) head.groupId = p.first.id; head.poolSz = pool.size(); diff --git a/DataSpec/DNAMP2/ANCS.hpp b/DataSpec/DNAMP2/ANCS.hpp index 7a2e48ef1..35c15309f 100644 --- a/DataSpec/DNAMP2/ANCS.hpp +++ b/DataSpec/DNAMP2/ANCS.hpp @@ -199,10 +199,10 @@ struct ANCS : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged) { - hecl::ProjectPath yamlPath = outPath.getWithExtension(_SYS_STR(".yaml"), true); + hecl::blender::Token& btok, std::function fileChanged) { + hecl::ProjectPath yamlPath = outPath.getWithExtension(".yaml", true); hecl::ProjectPath::Type yamlType = yamlPath.getPathType(); - hecl::ProjectPath blendPath = outPath.getWithExtension(_SYS_STR(".blend"), true); + hecl::ProjectPath blendPath = outPath.getWithExtension(".blend", true); hecl::ProjectPath::Type blendType = blendPath.getPathType(); if (force || yamlType == hecl::ProjectPath::Type::None || blendType == hecl::ProjectPath::Type::None) { diff --git a/DataSpec/DNAMP2/CINF.cpp b/DataSpec/DNAMP2/CINF.cpp index 6136d5d91..da6af3935 100644 --- a/DataSpec/DNAMP2/CINF.cpp +++ b/DataSpec/DNAMP2/CINF.cpp @@ -176,7 +176,7 @@ CINF::CINF(const Armature& armature, std::unordered_map& i template bool CINF::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKBridge::PAKType::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged) { + hecl::blender::Token& btok, std::function fileChanged) { if (!force && outPath.isFile()) return true; @@ -207,11 +207,11 @@ bool CINF::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: template bool CINF::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKBridge::PAKType::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged); + std::function fileChanged); template bool CINF::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename DNAMP3::PAKBridge::PAKType::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged); + hecl::blender::Token& btok, std::function fileChanged); bool CINF::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const hecl::blender::Armature& armature) { diff --git a/DataSpec/DNAMP2/CINF.hpp b/DataSpec/DNAMP2/CINF.hpp index 85831eb66..6ef77a0f9 100644 --- a/DataSpec/DNAMP2/CINF.hpp +++ b/DataSpec/DNAMP2/CINF.hpp @@ -53,7 +53,7 @@ struct CINF : BigDNA { template static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const typename PAKBridge::PAKType::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged); + hecl::blender::Token& btok, std::function fileChanged); static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const hecl::blender::Armature& armature); diff --git a/DataSpec/DNAMP2/CMDL.cpp b/DataSpec/DNAMP2/CMDL.cpp index 36a6bb596..4243b67ea 100644 --- a/DataSpec/DNAMP2/CMDL.cpp +++ b/DataSpec/DNAMP2/CMDL.cpp @@ -5,7 +5,7 @@ namespace DataSpec::DNAMP2 { bool CMDL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool, hecl::blender::Token& btok, - std::function) { + std::function) { /* Check for RigPair */ CINF cinf; CSKR cskr; diff --git a/DataSpec/DNAMP2/CMDL.hpp b/DataSpec/DNAMP2/CMDL.hpp index bf4ec2b08..a2a0e14fc 100644 --- a/DataSpec/DNAMP2/CMDL.hpp +++ b/DataSpec/DNAMP2/CMDL.hpp @@ -12,7 +12,7 @@ namespace DataSpec::DNAMP2 { struct CMDL { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool, - hecl::blender::Token& btok, std::function); + hecl::blender::Token& btok, std::function); }; } // namespace DataSpec::DNAMP2 diff --git a/DataSpec/DNAMP2/DNAMP2.cpp b/DataSpec/DNAMP2/DNAMP2.cpp index 95167ead1..d58c5057b 100644 --- a/DataSpec/DNAMP2/DNAMP2.cpp +++ b/DataSpec/DNAMP2/DNAMP2.cpp @@ -52,18 +52,18 @@ PAKBridge::PAKBridge(const nod::Node& node, bool doExtract) STRG mlvlName; mlvlName.read(rs); if (m_levelString.size()) - m_levelString += _SYS_STR(", "); - m_levelString += mlvlName.getSystemString(FOURCC('ENGL'), 0); + m_levelString += ", "; + m_levelString += mlvlName.getUTF8(FOURCC('ENGL'), 0); } } } } -static hecl::SystemString LayerName(std::string_view name) { - hecl::SystemString ret(hecl::SystemStringConv(name).sys_str()); +static std::string LayerName(std::string_view name) { + std::string ret(name); for (auto& ch : ret) - if (ch == _SYS_STR('/') || ch == _SYS_STR('\\')) - ch = _SYS_STR('-'); + if (ch == '/' || ch == '\\') + ch = '-'; return ret; } @@ -80,8 +80,7 @@ void PAKBridge::build() { mlvl.read(rs); } std::string catalogueName; - std::string bestName = m_pak.bestEntryName(m_node, e, catalogueName); - level.name = hecl::SystemStringConv(bestName).sys_str(); + level.name = m_pak.bestEntryName(m_node, e, catalogueName); level.areas.reserve(mlvl.areaCount); unsigned layerIdx = 0; @@ -109,17 +108,16 @@ void PAKBridge::build() { PAKEntryReadStream rs = areaNameEnt->beginReadStream(m_node); areaName.read(rs); } - areaDeps.name = areaName.getSystemString(FOURCC('ENGL'), 0); + areaDeps.name = areaName.getUTF8(FOURCC('ENGL'), 0); areaDeps.name = hecl::StringUtils::TrimWhitespace(areaDeps.name); } if (areaDeps.name.empty()) { - areaDeps.name = hecl::SystemStringConv(area.internalAreaName).sys_str(); + areaDeps.name = area.internalAreaName; if (areaDeps.name.empty()) { - std::string idStr = area.areaMREAId.toString(); - areaDeps.name = hecl::SystemString(_SYS_STR("MREA_")) + hecl::SystemStringConv(idStr).c_str(); + areaDeps.name = "MREA_" + area.areaMREAId.toString(); } } - hecl::SystemString num = fmt::format(FMT_STRING(_SYS_STR("{:02d} ")), ai); + std::string num = fmt::format(FMT_STRING("{:02d} "), ai); areaDeps.name = num + areaDeps.name; areaDeps.layers.reserve(area.depLayerCount - 1); @@ -130,7 +128,7 @@ void PAKBridge::build() { layer.name = LayerName(mlvl.layerNames[layerIdx++]); layer.active = layerFlags.flags >> (l - 1) & 0x1; layer.name = hecl::StringUtils::TrimWhitespace(layer.name); - num = fmt::format(FMT_STRING(_SYS_STR("{:02d} ")), l - 1); + num = fmt::format(FMT_STRING("{:02d} "), l - 1); layer.name = num + layer.name; layer.resources.reserve(area.depLayers[l] - r); @@ -202,7 +200,7 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, if (mlvl.worldNameId.isValid()) pathOverrides[mlvl.worldNameId] = - hecl::ProjectPath(mlvlDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId)); + hecl::ProjectPath(mlvlDirPath, fmt::format(FMT_STRING("!name_{}.yaml"), mlvl.worldNameId)); for (const MLVL::Area& area : mlvl.areas) { { @@ -218,7 +216,7 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath(); if (area.areaNameId.isValid()) pathOverrides[area.areaNameId] = - hecl::ProjectPath(areaDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), area.areaNameId)); + hecl::ProjectPath(areaDirPath, fmt::format(FMT_STRING("!name_{}.yaml"), area.areaNameId)); } if (mlvl.worldMap.isValid()) { @@ -249,43 +247,43 @@ ResExtractor PAKBridge::LookupExtractor(const nod::Node& pakNode, con const DNAMP2::PAK::Entry& entry) { switch (entry.type.toUint32()) { case SBIG('HINT'): - return {DNAMP1::HINT::Extract, {_SYS_STR(".yaml")}}; + return {DNAMP1::HINT::Extract, {".yaml"}}; case SBIG('STRG'): - return {STRG::Extract, {_SYS_STR(".yaml")}}; + return {STRG::Extract, {".yaml"}}; case SBIG('TXTR'): - return {TXTR::Extract, {_SYS_STR(".png")}}; + return {TXTR::Extract, {".png"}}; case SBIG('AFSM'): - return {AFSM::Extract, {_SYS_STR(".yaml")}}; + return {AFSM::Extract, {".yaml"}}; case SBIG('SAVW'): - return {SAVWCommon::ExtractSAVW, {_SYS_STR(".yaml")}}; + return {SAVWCommon::ExtractSAVW, {".yaml"}}; case SBIG('CMDL'): - return {CMDL::Extract, {_SYS_STR(".blend")}, 1}; + return {CMDL::Extract, {".blend"}, 1}; case SBIG('CINF'): - return {CINF::Extract, {_SYS_STR(".blend")}, 1}; + return {CINF::Extract, {".blend"}, 1}; case SBIG('ANCS'): - return {ANCS::Extract, {_SYS_STR(".yaml"), _SYS_STR(".blend")}, 2}; + return {ANCS::Extract, {".yaml", ".blend"}, 2}; case SBIG('MLVL'): - return {MLVL::Extract, {_SYS_STR(".yaml"), _SYS_STR(".blend")}, 3}; + return {MLVL::Extract, {".yaml", ".blend"}, 3}; case SBIG('MREA'): - return {MREA::Extract, {_SYS_STR(".blend")}, 4}; + return {MREA::Extract, {".blend"}, 4}; case SBIG('MAPA'): - return {MAPA::Extract, {_SYS_STR(".blend")}, 4}; + return {MAPA::Extract, {".blend"}, 4}; case SBIG('MAPU'): - return {MAPU::Extract, {_SYS_STR(".blend")}, 5}; + return {MAPU::Extract, {".blend"}, 5}; case SBIG('PATH'): - return {PATH::Extract, {_SYS_STR(".blend")}, 5}; + return {PATH::Extract, {".blend"}, 5}; case SBIG('FSM2'): - return {DNAFSM2::ExtractFSM2, {_SYS_STR(".yaml")}}; + return {DNAFSM2::ExtractFSM2, {".yaml"}}; case SBIG('FONT'): - return {DNAFont::ExtractFONT, {_SYS_STR(".yaml")}}; + return {DNAFont::ExtractFONT, {".yaml"}}; case SBIG('DGRP'): - return {DNADGRP::ExtractDGRP, {_SYS_STR(".yaml")}}; + return {DNADGRP::ExtractDGRP, {".yaml"}}; case SBIG('AGSC'): return {AGSC::Extract, {}}; case SBIG('CSNG'): - return {DNAMP1::CSNG::Extract, {_SYS_STR(".mid"), _SYS_STR(".yaml")}}; + return {DNAMP1::CSNG::Extract, {".mid", ".yaml"}}; case SBIG('ATBL'): - return {DNAAudio::ATBL::Extract, {_SYS_STR(".yaml")}}; + return {DNAAudio::ATBL::Extract, {".yaml"}}; } return {}; } diff --git a/DataSpec/DNAMP2/DNAMP2.hpp b/DataSpec/DNAMP2/DNAMP2.hpp index 654073fd0..8958ac5c8 100644 --- a/DataSpec/DNAMP2/DNAMP2.hpp +++ b/DataSpec/DNAMP2/DNAMP2.hpp @@ -16,14 +16,14 @@ public: bool m_doExtract; using Level = DataSpec::Level; std::unordered_map m_levelDeps; - hecl::SystemString m_levelString; + std::string m_levelString; PAKBridge(const nod::Node& node, bool doExtract = true); void build(); static ResExtractor LookupExtractor(const nod::Node& pakNode, const DNAMP2::PAK& pak, const DNAMP2::PAK::Entry& entry); std::string_view getName() const { return m_node.getName(); } - hecl::SystemStringView getLevelString() const { return m_levelString; } + std::string_view getLevelString() const { return m_levelString; } using PAKType = DNAMP2::PAK; const PAKType& getPAK() const { return m_pak; } diff --git a/DataSpec/DNAMP2/MAPA.hpp b/DataSpec/DNAMP2/MAPA.hpp index 122aab86b..2805e89b5 100644 --- a/DataSpec/DNAMP2/MAPA.hpp +++ b/DataSpec/DNAMP2/MAPA.hpp @@ -8,7 +8,7 @@ namespace DataSpec::DNAMP2 { struct MAPA : DNAMAPA::MAPA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged) { + hecl::blender::Token& btok, std::function fileChanged) { MAPA mapa; mapa.read(rs); hecl::blender::Connection& conn = btok.getBlenderConnection(); diff --git a/DataSpec/DNAMP2/MAPU.hpp b/DataSpec/DNAMP2/MAPU.hpp index 3d030d808..a68b500ad 100644 --- a/DataSpec/DNAMP2/MAPU.hpp +++ b/DataSpec/DNAMP2/MAPU.hpp @@ -11,7 +11,7 @@ namespace DataSpec::DNAMP2 { struct MAPU : DNAMAPU::MAPU { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged) { + hecl::blender::Token& btok, std::function fileChanged) { MAPU mapu; mapu.read(rs); hecl::blender::Connection& conn = btok.getBlenderConnection(); diff --git a/DataSpec/DNAMP2/MLVL.hpp b/DataSpec/DNAMP2/MLVL.hpp index 18e558acf..273a5fc84 100644 --- a/DataSpec/DNAMP2/MLVL.hpp +++ b/DataSpec/DNAMP2/MLVL.hpp @@ -85,10 +85,10 @@ struct MLVL : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool force, - hecl::blender::Token& btok, std::function fileChanged) { + hecl::blender::Token& btok, std::function fileChanged) { MLVL mlvl; mlvl.read(rs); - athena::io::FileWriter writer(outPath.getWithExtension(_SYS_STR(".yaml"), true).getAbsolutePath()); + athena::io::FileWriter writer(outPath.getWithExtension(".yaml", true).getAbsolutePath()); athena::io::ToYAMLStream(mlvl, writer); hecl::blender::Connection& conn = btok.getBlenderConnection(); return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter, entry, force, fileChanged); diff --git a/DataSpec/DNAMP2/MREA.cpp b/DataSpec/DNAMP2/MREA.cpp index fa763b6d8..7996f6a4a 100644 --- a/DataSpec/DNAMP2/MREA.cpp +++ b/DataSpec/DNAMP2/MREA.cpp @@ -179,7 +179,7 @@ void MREA::StreamReader::writeDecompInfos(athena::io::IStreamWriter& writer) con bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool force, - hecl::blender::Token& btok, std::function) { + hecl::blender::Token& btok, std::function) { using RigPair = std::pair, std::pair>; RigPair dummy = {}; @@ -193,7 +193,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: /* MREA decompression stream */ StreamReader drs(rs, head.compressedBlockCount); - hecl::ProjectPath decompPath = outPath.getCookedPath(SpecEntMP2ORIG).getWithExtension(_SYS_STR(".decomp")); + hecl::ProjectPath decompPath = outPath.getCookedPath(SpecEntMP2ORIG).getWithExtension(".decomp"); decompPath.makeDirChain(false); athena::io::FileWriter mreaDecompOut(decompPath.getAbsolutePath()); head.write(mreaDecompOut); diff --git a/DataSpec/DNAMP2/MREA.hpp b/DataSpec/DNAMP2/MREA.hpp index 65950865b..088f47c0e 100644 --- a/DataSpec/DNAMP2/MREA.hpp +++ b/DataSpec/DNAMP2/MREA.hpp @@ -123,7 +123,7 @@ struct MREA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const DNAMP2::PAK::Entry& entry, bool, - hecl::blender::Token& btok, std::function); + hecl::blender::Token& btok, std::function); }; } // namespace DataSpec::DNAMP2 diff --git a/DataSpec/DNAMP2/STRG.hpp b/DataSpec/DNAMP2/STRG.hpp index 5ec8fd5e1..d740423fe 100644 --- a/DataSpec/DNAMP2/STRG.hpp +++ b/DataSpec/DNAMP2/STRG.hpp @@ -42,16 +42,6 @@ struct STRG : ISTRG { return search->second->at(idx); return std::u16string(); } - hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const override { - auto search = langMap.find(lang); - if (search != langMap.end()) -#if HECL_UCS2 - return hecl::Char16ToWide(search->second->at(idx)); -#else - return hecl::Char16ToUTF8(search->second->at(idx)); -#endif - return hecl::SystemString(); - } static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { STRG strg; diff --git a/DataSpec/DNAMP3/CHAR.hpp b/DataSpec/DNAMP3/CHAR.hpp index af6e71b75..a07b4f53a 100644 --- a/DataSpec/DNAMP3/CHAR.hpp +++ b/DataSpec/DNAMP3/CHAR.hpp @@ -267,10 +267,10 @@ struct CHAR : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { - hecl::ProjectPath yamlPath = outPath.getWithExtension(_SYS_STR(".yaml"), true); + std::function fileChanged) { + hecl::ProjectPath yamlPath = outPath.getWithExtension(".yaml", true); hecl::ProjectPath::Type yamlType = yamlPath.getPathType(); - hecl::ProjectPath blendPath = outPath.getWithExtension(_SYS_STR(".blend"), true); + hecl::ProjectPath blendPath = outPath.getWithExtension(".blend", true); hecl::ProjectPath::Type blendType = blendPath.getPathType(); if (force || yamlType == hecl::ProjectPath::Type::None || blendType == hecl::ProjectPath::Type::None) { diff --git a/DataSpec/DNAMP3/CMDL.cpp b/DataSpec/DNAMP3/CMDL.cpp index 2b4daa46e..989bfa5f6 100644 --- a/DataSpec/DNAMP3/CMDL.cpp +++ b/DataSpec/DNAMP3/CMDL.cpp @@ -5,7 +5,7 @@ namespace DataSpec::DNAMP3 { bool CMDL::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool, hecl::blender::Token& btok, - std::function) { + std::function) { /* Check for RigPair */ CINF cinf; CSKR cskr; diff --git a/DataSpec/DNAMP3/CMDL.hpp b/DataSpec/DNAMP3/CMDL.hpp index 63df8cdc9..1650c9ccb 100644 --- a/DataSpec/DNAMP3/CMDL.hpp +++ b/DataSpec/DNAMP3/CMDL.hpp @@ -12,7 +12,7 @@ namespace DataSpec::DNAMP3 { struct CMDL { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool, hecl::blender::Token& btok, - std::function); + std::function); }; } // namespace DataSpec::DNAMP3 diff --git a/DataSpec/DNAMP3/CMDLMaterials.cpp b/DataSpec/DNAMP3/CMDLMaterials.cpp index 91a0d143c..c675f06f6 100644 --- a/DataSpec/DNAMP3/CMDLMaterials.cpp +++ b/DataSpec/DNAMP3/CMDLMaterials.cpp @@ -63,15 +63,14 @@ static void LoadTexture(Stream& out, const UniqueID64& tex, const PAKRouterbeginReadStream(*node); TXTR::Extract(rs, txtrPath); } - hecl::SystemString resPath = pakRouter.getResourceRelativePath(entry, tex); - hecl::SystemUTF8Conv resPathView(resPath); + std::string resPath = pakRouter.getResourceRelativePath(entry, tex); out.format(FMT_STRING("if '{}' in bpy.data.images:\n" " image = bpy.data.images['{}']\n" "else:\n" " image = bpy.data.images.load('''//{}''')\n" " image.name = '{}'\n" "\n"), - texName, texName, resPathView, texName); + texName, texName, resPath, texName); } void MaterialSet::ConstructMaterial(Stream& out, const PAKRouter& pakRouter, const PAK::Entry& entry, diff --git a/DataSpec/DNAMP3/DNAMP3.cpp b/DataSpec/DNAMP3/DNAMP3.cpp index a38ffefc0..dc98b26e6 100644 --- a/DataSpec/DNAMP3/DNAMP3.cpp +++ b/DataSpec/DNAMP3/DNAMP3.cpp @@ -35,7 +35,7 @@ PAKBridge::PAKBridge(const nod::Node& node, bool doExtract) m_pak.read(rs); /* Append Level String */ - std::set uniq; + std::set uniq; for (auto& ent : m_pak.m_entries) { PAK::Entry& entry = ent.second; if (entry.type == FOURCC('MLVL')) { @@ -47,24 +47,24 @@ PAKBridge::PAKBridge(const nod::Node& node, bool doExtract) PAKEntryReadStream rs = nameEnt->beginReadStream(m_node); STRG mlvlName; mlvlName.read(rs); - uniq.insert(mlvlName.getSystemString(FOURCC('ENGL'), 0)); + uniq.insert(mlvlName.getUTF8(FOURCC('ENGL'), 0)); } } } bool comma = false; - for (const hecl::SystemString& str : uniq) { + for (const std::string& str : uniq) { if (comma) - m_levelString += _SYS_STR(", "); + m_levelString += ", "; comma = true; m_levelString += str; } } -static hecl::SystemString LayerName(std::string_view name) { - hecl::SystemString ret(hecl::SystemStringConv(name).sys_str()); +static std::string LayerName(std::string_view name) { + std::string ret(name); for (auto& ch : ret) - if (ch == _SYS_STR('/') || ch == _SYS_STR('\\')) - ch = _SYS_STR('-'); + if (ch == '/' || ch == '\\') + ch = '-'; return ret; } @@ -82,7 +82,7 @@ void PAKBridge::build() { } std::string catalogueName; std::string bestName = m_pak.bestEntryName(m_node, entry, catalogueName); - level.name = hecl::SystemStringConv(bestName).sys_str(); + level.name = bestName; level.areas.reserve(mlvl.areaCount); unsigned layerIdx = 0; @@ -110,17 +110,16 @@ void PAKBridge::build() { PAKEntryReadStream rs = areaNameEnt->beginReadStream(m_node); areaName.read(rs); } - areaDeps.name = areaName.getSystemString(FOURCC('ENGL'), 0); + areaDeps.name = areaName.getUTF8(FOURCC('ENGL'), 0); areaDeps.name = hecl::StringUtils::TrimWhitespace(areaDeps.name); } if (areaDeps.name.empty()) { - areaDeps.name = hecl::SystemStringConv(area.internalAreaName).sys_str(); + areaDeps.name = area.internalAreaName; if (areaDeps.name.empty()) { - std::string idStr = area.areaMREAId.toString(); - areaDeps.name = hecl::SystemString(_SYS_STR("MREA_")) + hecl::SystemStringConv(idStr).c_str(); + areaDeps.name = "MREA_" + area.areaMREAId.toString(); } } - hecl::SystemString num = fmt::format(FMT_STRING(_SYS_STR("{:02d} ")), ai); + std::string num = fmt::format(FMT_STRING("{:02d} "), ai); areaDeps.name = num + areaDeps.name; const MLVL::LayerFlags& layerFlags = *layerFlagsIt++; @@ -132,7 +131,7 @@ void PAKBridge::build() { layer.name = LayerName(mlvl.layerNames[layerIdx++]); layer.active = layerFlags.flags >> (l - 1) & 0x1; layer.name = hecl::StringUtils::TrimWhitespace(layer.name); - num = fmt::format(FMT_STRING(_SYS_STR("{:02d} ")), l - 1); + num = fmt::format(FMT_STRING("{:02d} "), l - 1); layer.name = num + layer.name; } } @@ -192,7 +191,7 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, if (mlvl.worldNameId.isValid()) pathOverrides[mlvl.worldNameId] = - hecl::ProjectPath(mlvlDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId)); + hecl::ProjectPath(mlvlDirPath, fmt::format(FMT_STRING("!name_{}.yaml"), mlvl.worldNameId)); for (const MLVL::Area& area : mlvl.areas) { { @@ -208,7 +207,7 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath(); if (area.areaNameId.isValid()) pathOverrides[area.areaNameId] = - hecl::ProjectPath(areaDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), area.areaNameId)); + hecl::ProjectPath(areaDirPath, fmt::format(FMT_STRING("!name_{}.yaml"), area.areaNameId)); } if (mlvl.worldMap.isValid()) { @@ -238,35 +237,35 @@ void PAKBridge::addMAPATransforms(PAKRouter& pakRouter, ResExtractor PAKBridge::LookupExtractor(const nod::Node& pakNode, const PAK& pak, const PAK::Entry& entry) { switch (entry.type.toUint32()) { case SBIG('CAUD'): - return {CAUD::Extract, {_SYS_STR(".yaml")}}; + return {CAUD::Extract, {".yaml"}}; case SBIG('STRG'): - return {STRG::Extract, {_SYS_STR(".yaml")}}; + return {STRG::Extract, {".yaml"}}; case SBIG('TXTR'): - return {TXTR::Extract, {_SYS_STR(".png")}}; + return {TXTR::Extract, {".png"}}; case SBIG('SAVW'): - return {SAVWCommon::ExtractSAVW, {_SYS_STR(".yaml")}}; + return {SAVWCommon::ExtractSAVW, {".yaml"}}; case SBIG('HINT'): - return {HINT::Extract, {_SYS_STR(".yaml")}}; + return {HINT::Extract, {".yaml"}}; case SBIG('CMDL'): - return {CMDL::Extract, {_SYS_STR(".blend")}, 1}; + return {CMDL::Extract, {".blend"}, 1}; case SBIG('CINF'): - return {CINF::Extract, {_SYS_STR(".blend")}, 1}; + return {CINF::Extract, {".blend"}, 1}; case SBIG('CHAR'): - return {CHAR::Extract, {_SYS_STR(".yaml"), _SYS_STR(".blend")}, 2}; + return {CHAR::Extract, {".yaml", ".blend"}, 2}; case SBIG('MLVL'): - return {MLVL::Extract, {_SYS_STR(".yaml"), _SYS_STR(".blend")}, 3}; + return {MLVL::Extract, {".yaml", ".blend"}, 3}; case SBIG('MREA'): - return {MREA::Extract, {_SYS_STR(".blend")}, 4}; + return {MREA::Extract, {".blend"}, 4}; case SBIG('MAPA'): - return {MAPA::Extract, {_SYS_STR(".blend")}, 4}; + return {MAPA::Extract, {".blend"}, 4}; case SBIG('PATH'): - return {PATH::Extract, {_SYS_STR(".blend")}, 5}; + return {PATH::Extract, {".blend"}, 5}; case SBIG('FSM2'): - return {DNAFSM2::ExtractFSM2, {_SYS_STR(".yaml")}}; + return {DNAFSM2::ExtractFSM2, {".yaml"}}; case SBIG('FONT'): - return {DNAFont::ExtractFONT, {_SYS_STR(".yaml")}}; + return {DNAFont::ExtractFONT, {".yaml"}}; case SBIG('DGRP'): - return {DNADGRP::ExtractDGRP, {_SYS_STR(".yaml")}}; + return {DNADGRP::ExtractDGRP, {".yaml"}}; } return {}; } diff --git a/DataSpec/DNAMP3/DNAMP3.hpp b/DataSpec/DNAMP3/DNAMP3.hpp index 3e7d05c6f..4c399d33f 100644 --- a/DataSpec/DNAMP3/DNAMP3.hpp +++ b/DataSpec/DNAMP3/DNAMP3.hpp @@ -16,13 +16,13 @@ public: bool m_doExtract; using Level = DataSpec::Level; std::unordered_map m_levelDeps; - hecl::SystemString m_levelString; + std::string m_levelString; PAKBridge(const nod::Node& node, bool doExtract = true); void build(); static ResExtractor LookupExtractor(const nod::Node& pakNode, const PAK& pak, const PAK::Entry& entry); std::string_view getName() const { return m_node.getName(); } - hecl::SystemStringView getLevelString() const { return m_levelString; } + std::string_view getLevelString() const { return m_levelString; } using PAKType = PAK; const PAKType& getPAK() const { return m_pak; } diff --git a/DataSpec/DNAMP3/MAPA.hpp b/DataSpec/DNAMP3/MAPA.hpp index b0794b42e..5a7ab9b48 100644 --- a/DataSpec/DNAMP3/MAPA.hpp +++ b/DataSpec/DNAMP3/MAPA.hpp @@ -8,7 +8,7 @@ namespace DataSpec::DNAMP3 { struct MAPA : DNAMAPA::MAPA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { MAPA mapa; mapa.read(rs); hecl::blender::Connection& conn = btok.getBlenderConnection(); diff --git a/DataSpec/DNAMP3/MLVL.hpp b/DataSpec/DNAMP3/MLVL.hpp index c48cca2d1..ba3f56aee 100644 --- a/DataSpec/DNAMP3/MLVL.hpp +++ b/DataSpec/DNAMP3/MLVL.hpp @@ -74,10 +74,10 @@ struct MLVL : BigDNA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function fileChanged) { + std::function fileChanged) { MLVL mlvl; mlvl.read(rs); - athena::io::FileWriter writer(outPath.getWithExtension(_SYS_STR(".yaml"), true).getAbsolutePath()); + athena::io::FileWriter writer(outPath.getWithExtension(".yaml", true).getAbsolutePath()); athena::io::ToYAMLStream(mlvl, writer); hecl::blender::Connection& conn = btok.getBlenderConnection(); return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter, entry, force, fileChanged); diff --git a/DataSpec/DNAMP3/MREA.cpp b/DataSpec/DNAMP3/MREA.cpp index c0089f228..45f5de33a 100644 --- a/DataSpec/DNAMP3/MREA.cpp +++ b/DataSpec/DNAMP3/MREA.cpp @@ -65,7 +65,7 @@ void MREA::ReadBabeDeadToBlender_3(hecl::blender::PyOutStream& os, athena::io::I bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok, - std::function) { + std::function) { using RigPair = std::pair, std::pair>; RigPair dummy = {}; @@ -79,7 +79,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl: /* MREA decompression stream */ StreamReader drs(rs, head.compressedBlockCount, head.secIndexCount); - hecl::ProjectPath decompPath = outPath.getCookedPath(SpecEntMP3ORIG).getWithExtension(_SYS_STR(".decomp")); + hecl::ProjectPath decompPath = outPath.getCookedPath(SpecEntMP3ORIG).getWithExtension(".decomp"); decompPath.makeDirChain(false); athena::io::FileWriter mreaDecompOut(decompPath.getAbsolutePath()); head.write(mreaDecompOut); diff --git a/DataSpec/DNAMP3/MREA.hpp b/DataSpec/DNAMP3/MREA.hpp index 5747b4393..2fb0ebf9b 100644 --- a/DataSpec/DNAMP3/MREA.hpp +++ b/DataSpec/DNAMP3/MREA.hpp @@ -89,7 +89,7 @@ struct MREA { static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, PAKRouter& pakRouter, const PAK::Entry& entry, bool, hecl::blender::Token& btok, - std::function); + std::function); static bool ExtractLayerDeps(PAKEntryReadStream& rs, PAKBridge::Level::Area& areaOut); }; diff --git a/DataSpec/DNAMP3/STRG.hpp b/DataSpec/DNAMP3/STRG.hpp index 8f8d44f50..211dc52c3 100644 --- a/DataSpec/DNAMP3/STRG.hpp +++ b/DataSpec/DNAMP3/STRG.hpp @@ -42,16 +42,6 @@ struct STRG : ISTRG { return hecl::UTF8ToChar16(search->second->at(idx)); return std::u16string(); } - hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const override { - auto search = langMap.find(lang); - if (search != langMap.end()) -#if HECL_UCS2 - return hecl::UTF8ToWide(search->second->at(idx)); -#else - return search->second->at(idx); -#endif - return hecl::SystemString(); - } static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { std::unique_ptr strg = LoadSTRG(rs); diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 6fd2cf9c3..13e3e9317 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -24,18 +24,18 @@ namespace DataSpec { static logvisor::Module Log("DataSpec::SpecBase"); -static const hecl::SystemChar* MomErr[] = {_SYS_STR("Your metroid is in another castle"), - _SYS_STR("HECL is experiencing a PTSD attack"), - _SYS_STR("Unable to freeze metroids"), - _SYS_STR("Ridley ate your homework"), - _SYS_STR("Expected 0 maternal symbolisms, found 2147483647"), - _SYS_STR("Contradictive narratives unsupported"), - _SYS_STR("Wiimote profile \"NES + Zapper\" not recognized"), - _SYS_STR("Unable to find Waldo"), - _SYS_STR("Expected Ridley, found furby"), - _SYS_STR("Adam has not authorized this, please do not bug the developers"), - _SYS_STR("Lady returned objection"), - _SYS_STR("Unterminated plot thread 'Deleter' detected")}; +static const char* MomErr[] = {"Your metroid is in another castle", + "HECL is experiencing a PTSD attack", + "Unable to freeze metroids", + "Ridley ate your homework", + "Expected 0 maternal symbolisms, found 2147483647", + "Contradictive narratives unsupported", + "Wiimote profile \"NES + Zapper\" not recognized", + "Unable to find Waldo", + "Expected Ridley, found furby", + "Adam has not authorized this, please do not bug the developers", + "Lady returned objection", + "Unterminated plot thread 'Deleter' detected"}; constexpr uint32_t MomErrCount = std::extent::value; @@ -58,10 +58,10 @@ SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Databas SpecBase::~SpecBase() { cancelBackgroundIndex(); } -static const hecl::SystemString regNONE = _SYS_STR(""); -static const hecl::SystemString regE = _SYS_STR("NTSC"); -static const hecl::SystemString regJ = _SYS_STR("NTSC-J"); -static const hecl::SystemString regP = _SYS_STR("PAL"); +static const std::string regNONE = ""; +static const std::string regE = "NTSC"; +static const std::string regJ = "NTSC-J"; +static const std::string regP = "PAL"; void SpecBase::setThreadProject() { UniqueIDBridge::SetThreadProject(m_project); } @@ -74,7 +74,7 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vectorgetHeader().m_gameID[3]); - const hecl::SystemString* regstr = ®NONE; + const std::string* regstr = ®NONE; switch (m_region) { case ERegion::NTSC_U: regstr = ®E; @@ -116,18 +116,18 @@ void SpecBase::doExtract(const ExtractPassInfo& info, const hecl::MultiProgressP Log.report(logvisor::Fatal, FMT_STRING("Unable to build master shader blend")); if (m_isWii) { /* Extract root files for repacking later */ - hecl::ProjectPath outDir(m_project.getProjectWorkingPath(), _SYS_STR("out")); + hecl::ProjectPath outDir(m_project.getProjectWorkingPath(), "out"); outDir.makeDirChain(true); nod::ExtractionContext ctx = {info.force, nullptr}; if (!m_standalone) { - progress.print(_SYS_STR("Trilogy Files"), _SYS_STR(""), 0.0); + progress.print("Trilogy Files", "", 0.0); nod::IPartition* data = m_disc->getDataPartition(); const nod::Node& root = data->getFSTRoot(); for (const nod::Node& child : root) if (child.getKind() == nod::Node::Kind::File) child.extractToDirectory(outDir.getAbsolutePath(), ctx); - progress.print(_SYS_STR("Trilogy Files"), _SYS_STR(""), 1.0); + progress.print("Trilogy Files", "", 1.0); } } extractFromDisc(*m_disc, info.force, progress); @@ -135,15 +135,15 @@ void SpecBase::doExtract(const ExtractPassInfo& info, const hecl::MultiProgressP bool IsPathAudioGroup(const hecl::ProjectPath& path) { return (path.getPathType() == hecl::ProjectPath::Type::Directory && - hecl::ProjectPath(path, _SYS_STR("!project.yaml")).isFile() && - hecl::ProjectPath(path, _SYS_STR("!pool.yaml")).isFile()); + hecl::ProjectPath(path, "!project.yaml").isFile() && + hecl::ProjectPath(path, "!pool.yaml").isFile()); } static bool IsPathSong(const hecl::ProjectPath& path) { - if (path.getPathType() != hecl::ProjectPath::Type::Glob || !path.getWithExtension(_SYS_STR(".mid"), true).isFile() || - !path.getWithExtension(_SYS_STR(".yaml"), true).isFile()) { - return path.isFile() && path.getLastComponentExt() == _SYS_STR("mid") && - path.getWithExtension(_SYS_STR(".yaml"), true).isFile(); + if (path.getPathType() != hecl::ProjectPath::Type::Glob || !path.getWithExtension(".mid", true).isFile() || + !path.getWithExtension(".yaml", true).isFile()) { + return path.isFile() && path.getLastComponentExt() == "mid" && + path.getWithExtension(".yaml", true).isFile(); } return true; } @@ -154,7 +154,7 @@ bool SpecBase::canCook(const hecl::ProjectPath& path, hecl::blender::Token& btok hecl::ProjectPath asBlend; if (path.getPathType() == hecl::ProjectPath::Type::Glob) - asBlend = path.getWithExtension(_SYS_STR(".blend"), true); + asBlend = path.getWithExtension(".blend", true); else asBlend = path; @@ -184,18 +184,18 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj hecl::ProjectPath asBlend; if (path.getPathType() == hecl::ProjectPath::Type::Glob) - asBlend = path.getWithExtension(_SYS_STR(".blend"), true); + asBlend = path.getWithExtension(".blend", true); else asBlend = path; if (hecl::IsPathBlend(asBlend)) { - if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".CSKR")) || - hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".ANIM"))) + if (hecl::StringUtils::EndsWith(path.getAuxInfo(), ".CSKR") || + hecl::StringUtils::EndsWith(path.getAuxInfo(), ".ANIM")) return oldEntry; hecl::blender::BlendType type = hecl::blender::GetBlendType(asBlend.getAbsolutePath()); if (type == hecl::blender::BlendType::None) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("unable to cook '{}'")), path.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("unable to cook '{}'"), path.getAbsolutePath()); return nullptr; } if (type == hecl::blender::BlendType::Mesh || type == hecl::blender::BlendType::Area) @@ -213,7 +213,7 @@ void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& co hecl::ProjectPath asBlend; if (path.getPathType() == hecl::ProjectPath::Type::Glob) - asBlend = path.getWithExtension(_SYS_STR(".blend"), true); + asBlend = path.getWithExtension(".blend", true); else asBlend = path; @@ -304,7 +304,7 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector break; } case hecl::blender::BlendType::Actor: { - hecl::ProjectPath asGlob = in.getWithExtension(_SYS_STR(".*"), true); + hecl::ProjectPath asGlob = in.getWithExtension(".*", true); hecl::ProjectPath parentPath = asGlob.getParentPath(); hecl::DirectoryEnumerator dEnum(parentPath.getAbsolutePath()); hecl::blender::DataStream ds = conn.beginData(); @@ -319,13 +319,11 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector pathsOut.push_back(sub.mesh); } - hecl::SystemStringConv chSysName(sub.name); if (!sub.cskrId.empty()) { - hecl::SystemStringConv cskrSysName(sub.cskrId); pathsOut.push_back( - asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.CSKR")), chSysName, cskrSysName))); + asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}_{}.CSKR"), sub.name, sub.cskrId))); } else { - pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.CSKR")), chSysName))); + pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}.CSKR"), sub.name))); } const auto& arm = actor.armatures[sub.armature]; @@ -333,14 +331,12 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector pathsOut.push_back(arm.path); for (const auto& overlay : sub.overlayMeshes) { - hecl::SystemStringConv overlaySys(overlay.name); - hecl::SystemStringConv overlayCskrId(overlay.cskrId); if (hecl::IsPathBlend(overlay.mesh)) { flattenDependenciesBlend(overlay.mesh, pathsOut, btok); pathsOut.push_back(overlay.mesh); } pathsOut.push_back(asGlob.ensureAuxInfo( - fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), chSysName, overlaySys, overlayCskrId))); + fmt::format(FMT_STRING("{}.{}_{}.CSKR"), sub.name, overlay.name, overlay.cskrId))); } } }; @@ -356,10 +352,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector pathsOut.push_back(att.mesh); } - hecl::SystemStringConv chSysName(att.name); - hecl::SystemStringConv sysCskrId(att.cskrId); pathsOut.push_back( - asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), chSysName, sysCskrId))); + asGlob.ensureAuxInfo(fmt::format(FMT_STRING("ATTACH.{}_{}.CSKR"), att.name, att.cskrId))); if (att.armature >= 0) { const auto& arm = actor.armatures[att.armature]; @@ -369,16 +363,14 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector } for (const auto& act : actNames) { - hecl::SystemStringConv actSysName(act.first); - hecl::SystemStringConv actAnimId(act.second); - pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.ANIM")), actSysName, actAnimId))); - hecl::SystemString searchPrefix( - asGlob.getWithExtension(fmt::format(FMT_STRING(_SYS_STR(".{}_")), actSysName).c_str(), true) + pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}_{}.ANIM"), act.first, act.second))); + std::string searchPrefix( + asGlob.getWithExtension(fmt::format(FMT_STRING(".{}_"), act.first).c_str(), true) .getLastComponent()); hecl::ProjectPath evntPath; for (const auto& ent : dEnum) { if (hecl::StringUtils::BeginsWith(ent.m_name, searchPrefix.c_str()) && - hecl::StringUtils::EndsWith(ent.m_name, _SYS_STR(".evnt.yaml"))) { + hecl::StringUtils::EndsWith(ent.m_name, ".evnt.yaml")) { evntPath = hecl::ProjectPath(parentPath, ent.m_name); break; } @@ -387,7 +379,7 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector pathsOut.push_back(evntPath); } - hecl::ProjectPath yamlPath = asGlob.getWithExtension(_SYS_STR(".yaml"), true); + hecl::ProjectPath yamlPath = asGlob.getWithExtension(".yaml", true); if (yamlPath.isFile()) { athena::io::FileReader reader(yamlPath.getAbsolutePath()); flattenDependenciesANCSYAML(reader, pathsOut, charIdx); @@ -408,7 +400,7 @@ void SpecBase::flattenDependencies(const hecl::ProjectPath& path, std::vector& li for (const auto& ent : dEnum) { hecl::ProjectPath childPath(path, ent.m_name); if (ent.m_isDir) { - if (hecl::ProjectPath(childPath, _SYS_STR("!project.yaml")).isFile() && - hecl::ProjectPath(childPath, _SYS_STR("!pool.yaml")).isFile()) { + if (hecl::ProjectPath(childPath, "!project.yaml").isFile() && + hecl::ProjectPath(childPath, "!pool.yaml").isFile()) { /* Handle AudioGroup case */ if (metaforce::SObjectTag tag = tagFromPath(childPath)) { if (addedTags.find(tag) != addedTags.end()) @@ -485,7 +477,7 @@ void SpecBase::copyBuildListData(std::vector>& fileIndex.reserve(buildList.size()); int loadIdx = 0; for (const auto& tag : buildList) { - hecl::SystemString str = fmt::format(FMT_STRING(_SYS_STR("Copying {}")), tag); + std::string str = fmt::format(FMT_STRING("Copying {}"), tag); progress.print(str, std::nullopt, ++loadIdx / float(buildList.size())); auto& [positionOut, sizeOut, compressedOut] = fileIndex.emplace_back(); @@ -493,7 +485,7 @@ void SpecBase::copyBuildListData(std::vector>& if (tag.type == FOURCC('MLVL')) { auto search = mlvlData.find(tag.id); if (search == mlvlData.end()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to find MLVL {}")), tag.id); + Log.report(logvisor::Fatal, FMT_STRING("Unable to find MLVL {}"), tag.id); positionOut = pakOut.position(); sizeOut = ROUND_UP_32(search->second.size()); @@ -509,7 +501,7 @@ void SpecBase::copyBuildListData(std::vector>& hecl::ProjectPath cooked = getCookedPath(path, true); athena::io::FileReader r(cooked.getAbsolutePath()); if (r.hasError()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to open resource {}")), cooked.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("Unable to open resource {}"), cooked.getRelativePath()); atUint64 size = r.length(); auto data = r.readUBytes(size); auto compData = compressPakData(tag, data.get(), size); @@ -536,8 +528,8 @@ void SpecBase::copyBuildListData(std::vector>& static bool IsWorldBlend(const hecl::ProjectPath& path) { if (path.isFile()) { auto lastComp = path.getLastComponent(); - return hecl::StringUtils::BeginsWith(lastComp, _SYS_STR("!world")) && - hecl::StringUtils::EndsWith(lastComp, _SYS_STR(".blend")); + return hecl::StringUtils::BeginsWith(lastComp, "!world") && + hecl::StringUtils::EndsWith(lastComp, ".blend"); } return false; } @@ -551,15 +543,15 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da waitForIndexComplete(); /* Name pak based on root-relative components */ - auto components = path.getWithExtension(_SYS_STR(""), true).getPathComponents(); + auto components = path.getWithExtension("", true).getPathComponents(); if (components.size() <= 1) return; hecl::ProjectPath outPath; - if (hecl::ProjectPath(m_project.getProjectWorkingPath(), _SYS_STR("out/files/") + components[0]).isDirectory()) + if (hecl::ProjectPath(m_project.getProjectWorkingPath(), "out/files/" + components[0]).isDirectory()) outPath.assign(m_project.getProjectWorkingPath(), - _SYS_STR("out/files/") + components[0] + _SYS_STR("/") + components[1] + entry->m_pakExt.data()); + "out/files/" + components[0] + "/" + components[1] + entry->m_pakExt.data()); else - outPath.assign(m_project.getProjectWorkingPath(), _SYS_STR("out/files/") + components[1] + entry->m_pakExt.data()); + outPath.assign(m_project.getProjectWorkingPath(), "out/files/" + components[1] + entry->m_pakExt.data()); outPath.makeDirChain(false); /* Output file */ @@ -633,7 +625,7 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da /* Async cook resource list if using ClientProcess */ if (cp) { - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Validating resources"))); + Log.report(logvisor::Info, FMT_STRING("Validating resources")); progress.setMainIndeterminate(true); std::vector cookTags; cookTags.reserve(buildList.size()); @@ -656,7 +648,7 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da for (auto& tag : cookTags) { hecl::ProjectPath depPath = pathFromTag(tag); if (!depPath) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to resolve {}")), tag); + Log.report(logvisor::Fatal, FMT_STRING("Unable to resolve {}"), tag); m_project.cookPath(depPath, progress, false, false, fast, entry, cp); } progress.setMainIndeterminate(false); @@ -666,7 +658,7 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da /* Write resource data and build file index */ std::vector> fileIndex; - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Copying data into {}")), outPath.getRelativePath()); + Log.report(logvisor::Info, FMT_STRING("Copying data into {}"), outPath.getRelativePath()); copyBuildListData(fileIndex, buildList, entry, fast, progress, pakOut, mlvlData); /* Write file index */ @@ -680,8 +672,8 @@ std::optional SpecBase::compileWorldFromDir(const hecl::Pr hecl::blender::Token& btok) const { hecl::ProjectPath asBlend; for (const auto& ent : hecl::DirectoryEnumerator(dir.getAbsolutePath())) { - if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!world"))) { - asBlend = hecl::ProjectPath(dir, ent.m_name).getWithExtension(_SYS_STR(".blend"), true); + if (hecl::StringUtils::BeginsWith(ent.m_name, "!world")) { + asBlend = hecl::ProjectPath(dir, ent.m_name).getWithExtension(".blend", true); break; } } @@ -714,17 +706,17 @@ constexpr uint8_t Convert4To8(uint8_t v) { } void SpecBase::extractRandomStaticEntropy(const uint8_t* buf, const hecl::ProjectPath& pakPath) { - hecl::ProjectPath entropyPath(pakPath, _SYS_STR("RandomStaticEntropy.png")); - hecl::ProjectPath catalogPath(pakPath, _SYS_STR("!catalog.yaml")); + hecl::ProjectPath entropyPath(pakPath, "RandomStaticEntropy.png"); + hecl::ProjectPath catalogPath(pakPath, "!catalog.yaml"); entropyPath.makeDirChain(false); - if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), _SYS_STR("a"))) { - fmt::print(fp.get(), FMT_STRING("RandomStaticEntropy: {}\n"), entropyPath.getRelativePathUTF8()); + if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), "a")) { + fmt::print(fp.get(), FMT_STRING("RandomStaticEntropy: {}\n"), entropyPath.getRelativePath()); } - auto fp = hecl::FopenUnique(entropyPath.getAbsolutePath().data(), _SYS_STR("wb")); + auto fp = hecl::FopenUnique(entropyPath.getAbsolutePath().data(), "wb"); if (fp == nullptr) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to open '{}' for writing")), entropyPath.getAbsolutePath()); + Log.report(logvisor::Error, FMT_STRING("Unable to open '{}' for writing"), entropyPath.getAbsolutePath()); return; } png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, PNGErr, PNGWarn); @@ -870,10 +862,10 @@ static void WriteTag(athena::io::YAMLDocWriter& cacheWriter, const metaforce::SO const hecl::ProjectPath& path) { auto key = fmt::format(FMT_STRING("{}"), pathTag.id); if (auto* existing = cacheWriter.getCurNode()->findMapChild(key)) { - existing->m_seqChildren.emplace_back(athena::io::ValToNode(path.getEncodableStringUTF8())); + existing->m_seqChildren.emplace_back(athena::io::ValToNode(path.getEncodableString())); } else if (auto v = cacheWriter.enterSubVector(key)) { cacheWriter.writeString(pathTag.type.toString()); - cacheWriter.writeString(path.getEncodableStringUTF8()); + cacheWriter.writeString(path.getEncodableString()); } } @@ -944,7 +936,7 @@ void SpecBase::backgroundIndexRecursiveCatalogs(const hecl::ProjectPath& dir, at continue; /* Read catalog.yaml for .pak directory if exists */ - if (level == 1 && ent.m_name == _SYS_STR("!catalog.yaml")) { + if (level == 1 && ent.m_name == "!catalog.yaml") { readCatalog(path, nameWriter); continue; } @@ -964,7 +956,7 @@ void SpecBase::insertPathTag(athena::io::YAMLDocWriter& cacheWriter, const metaf if (search != m_tagToPath.end() && search->second != path && tag.type != FOURCC('CINF') && tag.type != FOURCC('CSKR') && tag.type != FOURCC('ANIM') && tag.type != FOURCC('EVNT')) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("'{}|{}' already exists for tag {} as '{}|{}'")), + Log.report(logvisor::Fatal, FMT_STRING("'{}|{}' already exists for tag {} as '{}|{}'"), path.getRelativePath(), path.getAuxInfo(), tag, search->second.getRelativePath(), search->second.getAuxInfo()); } @@ -974,7 +966,7 @@ void SpecBase::insertPathTag(athena::io::YAMLDocWriter& cacheWriter, const metaf WriteTag(cacheWriter, tag, path); #if DUMP_CACHE_FILL if (dump) - fmt::print(stderr, FMT_STRING("{} {}\n"), tag, path.getRelativePathUTF8()); + fmt::print(stderr, FMT_STRING("{} {}\n"), tag, path.getRelativePath()); #endif } @@ -984,7 +976,7 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc return true; /* Try as glob */ - hecl::ProjectPath asGlob = path.getWithExtension(_SYS_STR(".*"), true); + hecl::ProjectPath asGlob = path.getWithExtension(".*", true); if (m_pathToTag.find(asGlob.hash()) != m_pathToTag.cend()) return true; @@ -1009,25 +1001,21 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc std::vector> actionNames = ds.getActionNames(); for (const auto& sub : subtypeNames) { - hecl::SystemStringConv subName(sub.first); hecl::ProjectPath subPath; if (!sub.second.empty()) { - hecl::SystemStringConv cskrId(sub.second); - subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.CSKR")), subName, cskrId)); + subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}_{}.CSKR"), sub.first, sub.second)); } else { - subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.CSKR")), subName)); + subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}.CSKR"), sub.first)); } insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath); std::vector> overlayNames = ds.getSubtypeOverlayNames(sub.first); for (const auto& overlay : overlayNames) { - hecl::SystemStringConv overlaySys(overlay.first); - hecl::SystemStringConv overlayCskrId(overlay.second); if (!overlay.second.empty()) { subPath = asGlob.ensureAuxInfo( - fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), subName, overlaySys, overlayCskrId)); + fmt::format(FMT_STRING("{}.{}_{}.CSKR"), sub.first, overlay.first, overlay.second)); } else { - subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}.CSKR")), subName, overlaySys)); + subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}.{}.CSKR"), sub.first, overlay.first)); } insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath); } @@ -1035,26 +1023,22 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc std::vector> attachmentNames = ds.getAttachmentNames(); for (const auto& attachment : attachmentNames) { - hecl::SystemStringConv attachmentSys(attachment.first); - hecl::SystemStringConv attachmentCskrId(attachment.second); hecl::ProjectPath subPath; if (!attachment.second.empty()) { subPath = asGlob.ensureAuxInfo( - fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), attachmentSys, attachmentCskrId)); + fmt::format(FMT_STRING("ATTACH.{}_{}.CSKR"), attachment.first, attachment.second)); } else { - subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}.CSKR")), attachmentSys)); + subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING("ATTACH.{}.CSKR"), attachment.first)); } insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath); } for (const auto& act : actionNames) { - hecl::SystemStringConv sysStr(act.first); - hecl::SystemStringConv animId(act.second); hecl::ProjectPath subPath; if (!act.second.empty()) { - subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.ANIM")), sysStr, animId)); + subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}_{}.ANIM"), act.first, act.second)); } else { - subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.ANIM")), sysStr)); + subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING("{}.ANIM"), act.first)); } insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath); } @@ -1096,7 +1080,7 @@ void SpecBase::backgroundIndexRecursiveProc(const hecl::ProjectPath& dir, athena continue; /* Read catalog.yaml for .pak directory if exists */ - if (level == 1 && ent.m_name == _SYS_STR("!catalog.yaml")) { + if (level == 1 && ent.m_name == "!catalog.yaml") { readCatalog(path, nameWriter); continue; } @@ -1110,8 +1094,8 @@ void SpecBase::backgroundIndexRecursiveProc(const hecl::ProjectPath& dir, athena void SpecBase::backgroundIndexProc() { logvisor::RegisterThreadName("Resource Index"); - hecl::ProjectPath tagCachePath(m_project.getProjectCookedPath(getOriginalSpec()), _SYS_STR("tag_cache.yaml")); - hecl::ProjectPath nameCachePath(m_project.getProjectCookedPath(getOriginalSpec()), _SYS_STR("name_cache.yaml")); + hecl::ProjectPath tagCachePath(m_project.getProjectCookedPath(getOriginalSpec()), "tag_cache.yaml"); + hecl::ProjectPath nameCachePath(m_project.getProjectCookedPath(getOriginalSpec()), "name_cache.yaml"); hecl::ProjectPath specRoot(m_project.getProjectWorkingPath(), getOriginalSpec().m_name); /* Cache will be overwritten with validated entries afterwards */ @@ -1122,7 +1106,7 @@ void SpecBase::backgroundIndexProc() { if (tagCachePath.isFile()) { athena::io::FileReader reader(tagCachePath.getAbsolutePath()); if (reader.isOpen()) { - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Cache index of '{}' loading")), getOriginalSpec().m_name); + Log.report(logvisor::Info, FMT_STRING("Cache index of '{}' loading"), getOriginalSpec().m_name); athena::io::YAMLDocReader cacheReader; if (cacheReader.parse(&reader)) { std::unique_lock lk(m_backgroundIndexMutex); @@ -1152,12 +1136,12 @@ void SpecBase::backgroundIndexProc() { } fmt::print(stderr, FMT_STRING("\r {} / {}\n"), loadIdx, tagCount); } - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Cache index of '{}' loaded; {} tags")), getOriginalSpec().m_name, + Log.report(logvisor::Info, FMT_STRING("Cache index of '{}' loaded; {} tags"), getOriginalSpec().m_name, m_tagToPath.size()); if (nameCachePath.isFile()) { /* Read in name cache */ - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Name index of '{}' loading")), getOriginalSpec().m_name); + Log.report(logvisor::Info, FMT_STRING("Name index of '{}' loading"), getOriginalSpec().m_name); athena::io::FileReader nreader(nameCachePath.getAbsolutePath()); athena::io::YAMLDocReader nameReader; if (nameReader.parse(&nreader)) { @@ -1176,13 +1160,13 @@ void SpecBase::backgroundIndexProc() { } } } - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Name index of '{}' loaded; {} names")), + Log.report(logvisor::Info, FMT_STRING("Name index of '{}' loaded; {} names"), getOriginalSpec().m_name, m_catalogNameToTag.size()); } } } - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Background index of '{}' started")), getOriginalSpec().m_name); + Log.report(logvisor::Info, FMT_STRING("Background index of '{}' started"), getOriginalSpec().m_name); backgroundIndexRecursiveProc(specRoot, cacheWriter, nameWriter, 0); tagCachePath.makeDirChain(false); @@ -1193,7 +1177,7 @@ void SpecBase::backgroundIndexProc() { nameWriter.finish(&nwriter); m_backgroundBlender.shutdown(); - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Background index of '{}' complete; {} tags, {} names")), + Log.report(logvisor::Info, FMT_STRING("Background index of '{}' complete; {} tags, {} names"), getOriginalSpec().m_name, m_tagToPath.size(), m_catalogNameToTag.size()); m_backgroundRunning = false; } @@ -1221,7 +1205,7 @@ void SpecBase::waitForIndexComplete() const { } void SpecBase::WriteVersionInfo(hecl::Database::Project& project, const hecl::ProjectPath& pakPath) { - hecl::ProjectPath versionPath(pakPath, _SYS_STR("version.yaml")); + hecl::ProjectPath versionPath(pakPath, "version.yaml"); versionPath.makeDirChain(false); MetaforceVersionInfo info; diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index 487562af9..f7a02763d 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -49,11 +49,11 @@ struct SpecBase : hecl::Database::IDataSpec { /* Extract handlers */ virtual bool checkStandaloneID(const char* id) const = 0; - virtual bool checkFromStandaloneDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, + virtual bool checkFromStandaloneDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) = 0; - virtual bool checkFromTrilogyDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, std::vector& reps) = 0; + virtual bool checkFromTrilogyDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) = 0; virtual bool extractFromDisc(nod::DiscBase& disc, bool force, const hecl::MultiProgressPrinter& progress) = 0; /* Convert path to object tag */ diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 2180359d9..e60408956 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -65,12 +65,12 @@ extern hecl::Database::DataSpecEntry SpecEntMP1ORIG; struct TextureCache { static void Generate(PAKRouter& pakRouter, hecl::Database::Project& project, const hecl::ProjectPath& pakPath) { - hecl::ProjectPath texturePath(pakPath, _SYS_STR("texture_cache.yaml")); - hecl::ProjectPath catalogPath(pakPath, _SYS_STR("!catalog.yaml")); + hecl::ProjectPath texturePath(pakPath, "texture_cache.yaml"); + hecl::ProjectPath catalogPath(pakPath, "!catalog.yaml"); texturePath.makeDirChain(false); - if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), _SYS_STR("a"))) { - fmt::print(fp.get(), FMT_STRING("TextureCache: {}\n"), texturePath.getRelativePathUTF8()); + if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), "a")) { + fmt::print(fp.get(), FMT_STRING("TextureCache: {}\n"), texturePath.getRelativePath()); } Log.report(logvisor::Level::Info, FMT_STRING("Gathering Texture metadata (this can take up to 10 seconds)...")); @@ -87,7 +87,7 @@ struct TextureCache { athena::io::YAMLDocWriter yamlW("MP1TextureCache"); for (const auto& pair : metaMap) { hecl::ProjectPath path = pakRouter.getWorking(pair.first); - auto rec = yamlW.enterSubRecord(path.getRelativePathUTF8()); + auto rec = yamlW.enterSubRecord(path.getRelativePath()); pair.second.write(yamlW); } @@ -142,21 +142,21 @@ struct SpecMP1 : SpecBase { SpecMP1(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) : SpecBase(specEntry, project, pc) - , m_workPath(project.getProjectWorkingPath(), _SYS_STR("MP1")) - , m_cookPath(project.getProjectCookedPath(SpecEntMP1), _SYS_STR("MP1")) + , m_workPath(project.getProjectWorkingPath(), "MP1") + , m_cookPath(project.getProjectCookedPath(SpecEntMP1), "MP1") , m_pakRouter(*this, m_workPath, m_cookPath) { m_game = EGame::MetroidPrime1; SpecBase::setThreadProject(); } - void buildPaks(nod::Node& root, const std::vector& args, ExtractReport& rep) { + void buildPaks(nod::Node& root, const std::vector& args, ExtractReport& rep) { m_nonPaks.clear(); m_paks.clear(); for (const nod::Node& child : root) { bool isPak = false; auto name = child.getName(); std::string lowerName(name); - std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); + hecl::ToLower(lowerName); if (name.size() > 4) { std::string::iterator extit = lowerName.end() - 4; if (std::string(extit, lowerName.end()) == ".pak") { @@ -169,8 +169,8 @@ struct SpecMP1 : SpecBase { if (args.size()) { good = false; if (!lowerName.compare(0, 7, "metroid")) { - hecl::SystemChar idxChar = lowerName[7]; - for (const hecl::SystemString& arg : args) { + char idxChar = lowerName[7]; + for (const std::string& arg : args) { if (arg.size() == 1 && iswdigit(arg[0])) if (arg[0] == idxChar) good = true; @@ -179,9 +179,9 @@ struct SpecMP1 : SpecBase { good = true; if (!good) { - for (const hecl::SystemString& arg : args) { - std::string lowerArg(hecl::SystemUTF8Conv(arg).str()); - std::transform(lowerArg.begin(), lowerArg.end(), lowerArg.begin(), tolower); + for (const std::string& arg : args) { + std::string lowerArg(arg); + hecl::ToLower(lowerArg); if (!lowerArg.compare(0, lowerBase.size(), lowerBase)) good = true; } @@ -210,14 +210,13 @@ struct SpecMP1 : SpecBase { } ExtractReport& childRep = rep.childOpts.emplace_back(); - hecl::SystemStringConv nameView(item.first); - childRep.name = nameView.sys_str(); + childRep.name = item.first; childRep.desc = item.second->getLevelString(); } } - bool checkFromStandaloneDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, std::vector& reps) override { + bool checkFromStandaloneDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) override { nod::IPartition* partition = disc.getDataPartition(); m_dolBuf = partition->getDOLBuf(); const char* buildInfo = @@ -229,11 +228,10 @@ struct SpecMP1 : SpecBase { m_version = std::string(buildInfo); /* Root Report */ ExtractReport& rep = reps.emplace_back(); - rep.name = _SYS_STR("MP1"); - rep.desc = _SYS_STR("Metroid Prime ") + regstr; + rep.name = "MP1"; + rep.desc = "Metroid Prime " + regstr; if (buildInfo) { - hecl::SystemStringConv buildView(m_version); - rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")"); + rep.desc += " (" + m_version + ")"; } /* Iterate PAKs and build level options */ @@ -243,23 +241,23 @@ struct SpecMP1 : SpecBase { return true; } - bool checkFromTrilogyDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, std::vector& reps) override { - std::vector mp1args; + bool checkFromTrilogyDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) override { + std::vector mp1args; bool doExtract = false; if (args.size()) { /* Needs filter */ - for (const hecl::SystemString& arg : args) { - hecl::SystemString lowerArg = arg; + for (const std::string& arg : args) { + std::string lowerArg = arg; hecl::ToLower(lowerArg); - if (!lowerArg.compare(0, 3, _SYS_STR("mp1"))) { + if (!lowerArg.compare(0, 3, "mp1")) { doExtract = true; mp1args.reserve(args.size()); - size_t slashPos = arg.find(_SYS_STR('/')); - if (slashPos == hecl::SystemString::npos) - slashPos = arg.find(_SYS_STR('\\')); - if (slashPos != hecl::SystemString::npos) - mp1args.emplace_back(hecl::SystemString(arg.begin() + slashPos + 1, arg.end())); + size_t slashPos = arg.find('/'); + if (slashPos == std::string::npos) + slashPos = arg.find('\\'); + if (slashPos != std::string::npos) + mp1args.emplace_back(std::string(arg.begin() + slashPos + 1, arg.end())); } } } else @@ -282,12 +280,11 @@ struct SpecMP1 : SpecBase { /* Root Report */ ExtractReport& rep = reps.emplace_back(); - rep.name = _SYS_STR("MP1"); - rep.desc = _SYS_STR("Metroid Prime ") + regstr; + rep.name = "MP1"; + rep.desc = "Metroid Prime " + regstr; if (buildInfo != nullptr) { m_version = std::string(buildInfo); - hecl::SystemStringConv buildView(m_version); - rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")"); + rep.desc += " (" + m_version + ")"; } /* Iterate PAKs and build level options */ @@ -303,36 +300,36 @@ struct SpecMP1 : SpecBase { } bool extractFromDisc(nod::DiscBase& disc, bool force, const hecl::MultiProgressPrinter& progress) override { - m_project.enableDataSpecs({_SYS_STR("MP1-PC")}); + m_project.enableDataSpecs({"MP1-PC"}); nod::ExtractionContext ctx = {force, nullptr}; m_workPath.makeDir(); progress.startNewLine(); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 0.0); + progress.print("Indexing PAKs", "", 0.0); m_pakRouter.build(m_paks, - [&progress](float factor) { progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), factor); }); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 1.0); + [&progress](float factor) { progress.print("Indexing PAKs", "", factor); }); + progress.print("Indexing PAKs", "", 1.0); - hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), _SYS_STR("out")); + hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), "out"); outPath.makeDir(); disc.getDataPartition()->extractSysFiles(outPath.getAbsolutePath(), ctx); - hecl::ProjectPath mp1OutPath(outPath, _SYS_STR("files/MP1")); + hecl::ProjectPath mp1OutPath(outPath, "files/MP1"); mp1OutPath.makeDirChain(true); /* Extract non-pak files */ progress.startNewLine(); - progress.print(_SYS_STR("MP1 Root"), _SYS_STR(""), 0.0); + progress.print("MP1 Root", "", 0.0); int prog = 0; - ctx.progressCB = [&](nod::SystemStringView name, float) { - progress.print(_SYS_STR("MP1 Root"), name, prog / (float)m_nonPaks.size()); + ctx.progressCB = [&](std::string_view name, float) { + progress.print("MP1 Root", name, prog / (float)m_nonPaks.size()); }; for (const nod::Node* node : m_nonPaks) { node->extractToDirectory(mp1OutPath.getAbsolutePath(), ctx); prog++; } - progress.print(_SYS_STR("MP1 Root"), _SYS_STR(""), 1.0); + progress.print("MP1 Root", "", 1.0); /* Extract unique resources */ hecl::ClientProcess process; @@ -358,14 +355,11 @@ struct SpecMP1 : SpecBase { if (!pak.m_doExtract) continue; - auto name = pak.getName(); - hecl::SystemStringConv sysName(name); - - auto pakName = hecl::SystemString(sysName.sys_str()); + auto pakName = std::string(pak.getName()); process.addLambdaTransaction([this, &progress, &pak, pakName, force](hecl::blender::Token& btok) { int threadIdx = hecl::ClientProcess::GetThreadWorkerIdx(); m_pakRouter.extractResources(pak, force, btok, - [&progress, &pakName, threadIdx](const hecl::SystemChar* substr, float factor) { + [&progress, &pakName, threadIdx](const char* substr, float factor) { progress.print(pakName, substr, factor, threadIdx); }); }); @@ -374,14 +368,14 @@ struct SpecMP1 : SpecBase { process.waitUntilComplete(); /* Extract part of .dol for RandomStatic entropy */ - hecl::ProjectPath noAramPath(m_project.getProjectWorkingPath(), _SYS_STR("MP1/URDE")); + hecl::ProjectPath noAramPath(m_project.getProjectWorkingPath(), "MP1/URDE"); extractRandomStaticEntropy(m_dolBuf.get() + 0x4f60, noAramPath); /* Generate Texture Cache containing meta data for every texture file */ TextureCache::Generate(m_pakRouter, m_project, noAramPath); /* Write version data */ - hecl::ProjectPath versionPath = hecl::ProjectPath(m_project.getProjectWorkingPath(), _SYS_STR("out/files/MP1")); + hecl::ProjectPath versionPath = hecl::ProjectPath(m_project.getProjectWorkingPath(), "out/files/MP1"); WriteVersionInfo(m_project, versionPath); return true; } @@ -393,7 +387,7 @@ struct SpecMP1 : SpecBase { hecl::ProjectPath getWorking(class UniqueID32& id) override { return m_pakRouter.getWorking(id); } bool checkPathPrefix(const hecl::ProjectPath& path) const override { - return path.getRelativePath().compare(0, 4, _SYS_STR("MP1/")) == 0; + return path.getRelativePath().compare(0, 4, "MP1/") == 0; } bool validateYAMLDNAType(athena::io::IStreamReader& fp) const override { @@ -473,29 +467,29 @@ struct SpecMP1 : SpecBase { } metaforce::SObjectTag buildTagFromPath(const hecl::ProjectPath& path) const override { - if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".CSKR"))) + if (hecl::StringUtils::EndsWith(path.getAuxInfo(), ".CSKR")) return {SBIG('CSKR'), path.parsedHash32()}; - else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".ANIM"))) + else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), ".ANIM")) return {SBIG('ANIM'), path.parsedHash32()}; - else if (const hecl::SystemChar* ext = path.getLastComponentExt().data()) { - if (ext[0] == _SYS_STR('*') || !hecl::StrCmp(ext, _SYS_STR("mid"))) { - if (path.getWithExtension(_SYS_STR(".mid"), true).isFile() && - path.getWithExtension(_SYS_STR(".yaml"), true).isFile()) { - hecl::ProjectPath glob = path.getWithExtension(_SYS_STR(".*"), true); + else if (const char* ext = path.getLastComponentExt().data()) { + if (ext[0] == '*' || !hecl::StrCmp(ext, "mid")) { + if (path.getWithExtension(".mid", true).isFile() && + path.getWithExtension(".yaml", true).isFile()) { + hecl::ProjectPath glob = path.getWithExtension(".*", true); return {SBIG('CSNG'), glob.parsedHash32()}; } } } if (path.getPathType() == hecl::ProjectPath::Type::Directory) { - if (hecl::ProjectPath(path, _SYS_STR("!project.yaml")).isFile() && - hecl::ProjectPath(path, _SYS_STR("!pool.yaml")).isFile()) + if (hecl::ProjectPath(path, "!project.yaml").isFile() && + hecl::ProjectPath(path, "!pool.yaml").isFile()) return {SBIG('AGSC'), path.parsedHash32()}; } hecl::ProjectPath asBlend; if (path.getPathType() == hecl::ProjectPath::Type::Glob) - asBlend = path.getWithExtension(_SYS_STR(".blend"), true); + asBlend = path.getWithExtension(".blend", true); else asBlend = path; @@ -511,16 +505,16 @@ struct SpecMP1 : SpecBase { return {SBIG('PATH'), path.parsedHash32()}; case hecl::blender::BlendType::Actor: if (path.getAuxInfo().size()) { - if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".CSKR"))) - return {SBIG('CSKR'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()}; - else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".ANIM"))) - return {SBIG('ANIM'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()}; + if (hecl::StringUtils::EndsWith(path.getAuxInfo(), ".CSKR")) + return {SBIG('CSKR'), path.getWithExtension(".*", true).parsedHash32()}; + else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), ".ANIM")) + return {SBIG('ANIM'), path.getWithExtension(".*", true).parsedHash32()}; } - return {SBIG('ANCS'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()}; + return {SBIG('ANCS'), path.getWithExtension(".*", true).parsedHash32()}; case hecl::blender::BlendType::Area: return {SBIG('MREA'), path.parsedHash32()}; case hecl::blender::BlendType::World: - return {SBIG('MLVL'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()}; + return {SBIG('MLVL'), path.getWithExtension(".*", true).parsedHash32()}; case hecl::blender::BlendType::MapArea: return {SBIG('MAPA'), path.parsedHash32()}; case hecl::blender::BlendType::MapUniverse: @@ -533,7 +527,7 @@ struct SpecMP1 : SpecBase { } else if (hecl::IsPathPNG(path)) { return {SBIG('TXTR'), path.parsedHash32()}; } else if (hecl::IsPathYAML(path)) { - auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), _SYS_STR("r")); + auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), "r"); if (fp == nullptr) { return {}; } @@ -640,7 +634,7 @@ struct SpecMP1 : SpecBase { std::unique_lock lk(m_backgroundIndexMutex); for (const auto& tag : m_tagToPath) - if (!tag.second.getRelativePathUTF8().compare(0, pathPrefix.size(), pathPrefix)) + if (!tag.second.getRelativePath().compare(0, pathPrefix.size(), pathPrefix)) out.push_back(tag.first); } @@ -677,7 +671,7 @@ struct SpecMP1 : SpecBase { void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast, hecl::blender::Token& btok, FCookProgress progress) override { - if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _SYS_STR(".CSKR"))) { + if (hecl::StringUtils::EndsWith(in.getAuxInfo(), ".CSKR")) { Actor actor = ds.compileActorCharacterOnly(); ds.close(); if (m_pc) { @@ -693,7 +687,7 @@ struct SpecMP1 : SpecBase { return true; }); } - } else if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _SYS_STR(".ANIM"))) { + } else if (hecl::StringUtils::EndsWith(in.getAuxInfo(), ".ANIM")) { Actor actor = ds.compileActorCharacterOnly(); DNAMP1::ANCS::CookANIM(out, in, actor, ds, m_pc); } else { @@ -711,8 +705,8 @@ struct SpecMP1 : SpecBase { if (ent2.m_isDir) { hecl::ProjectPath wldDir(pakPath, ent2.m_name); for (const auto& ent3 : wldDir.enumerateDir()) { - if (hecl::StringUtils::BeginsWith(ent3.m_name, _SYS_STR("!world")) && - hecl::StringUtils::EndsWith(ent3.m_name, _SYS_STR(".blend"))) { + if (hecl::StringUtils::BeginsWith(ent3.m_name, "!world") && + hecl::StringUtils::EndsWith(ent3.m_name, ".blend")) { hecl::ProjectPath wldPath(wldDir, ent3.m_name); if (wldPath.isFile()) { if (!conn.openBlend(wldPath)) @@ -740,10 +734,9 @@ struct SpecMP1 : SpecBase { std::optional colMesh; for (const std::string& mesh : meshes) { - hecl::SystemStringConv meshSys(mesh); if (mesh == "CMESH") { colMesh = ds.compileColMesh(mesh); - progress(_SYS_STR("Collision Mesh")); + progress("Collision Mesh"); continue; } meshCompiles.push_back( @@ -751,7 +744,7 @@ struct SpecMP1 : SpecBase { } if (!colMesh) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find mesh named 'CMESH' in {}")), + Log.report(logvisor::Fatal, FMT_STRING("unable to find mesh named 'CMESH' in {}"), in.getAbsolutePath()); std::vector lights = ds.compileLights(); @@ -922,7 +915,7 @@ struct SpecMP1 : SpecBase { TextureCache::Cook(in, out); } } - progress(_SYS_STR("Done")); + progress("Done"); } void flattenDependenciesYAML(athena::io::IStreamReader& fin, std::vector& pathsOut) override { @@ -998,7 +991,7 @@ struct SpecMP1 : SpecBase { { athena::io::FileReader r(worldPathCooked.getAbsolutePath()); if (r.hasError()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to open world {}")), worldPathCooked.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("Unable to open world {}"), worldPathCooked.getRelativePath()); mlvl.read(r); } @@ -1015,7 +1008,7 @@ struct SpecMP1 : SpecBase { } listOut.reserve(count); - metaforce::SObjectTag worldTag = tagFromPath(worldPath.getWithExtension(_SYS_STR(".*"), true)); + metaforce::SObjectTag worldTag = tagFromPath(worldPath.getWithExtension(".*", true)); w.writeUint32Big(m_pc ? 0x80030005 : 0x00030005); w.writeUint32Big(0); @@ -1026,7 +1019,7 @@ struct SpecMP1 : SpecBase { nameEnt.type = worldTag.type; nameEnt.id = worldTag.id.Value(); nameEnt.nameLen = atUint32(parentDir.getLastComponent().size()); - nameEnt.name = parentDir.getLastComponentUTF8(); + nameEnt.name = parentDir.getLastComponent(); nameEnt.write(w); std::unordered_set addedTags; @@ -1035,7 +1028,7 @@ struct SpecMP1 : SpecBase { bool dupeRes = false; if (hecl::ProjectPath areaDir = pathFromTag(areaTag).getParentPath()) - dupeRes = hecl::ProjectPath(areaDir, _SYS_STR("!duperes")).isFile(); + dupeRes = hecl::ProjectPath(areaDir, "!duperes").isFile(); metaforce::SObjectTag nameTag(FOURCC('STRG'), area.areaNameId.toUint64()); if (nameTag) @@ -1094,10 +1087,10 @@ struct SpecMP1 : SpecBase { if (hecl::ProjectPath mapCookedPath = getCookedPath(mapPath, true)) { athena::io::FileReader r(mapCookedPath.getAbsolutePath()); if (r.hasError()) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to open {}")), mapCookedPath.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("Unable to open {}"), mapCookedPath.getRelativePath()); if (r.readUint32Big() != 0xDEADF00D) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Corrupt MAPW {}")), mapCookedPath.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("Corrupt MAPW {}"), mapCookedPath.getRelativePath()); r.readUint32Big(); atUint32 mapaCount = r.readUint32Big(); for (atUint32 i = 0; i < mapaCount; ++i) { @@ -1120,7 +1113,7 @@ struct SpecMP1 : SpecBase { for (const auto& tex : textures) { metaforce::SObjectTag texTag = tagFromPath(tex); if (!texTag) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to resolve {}")), tex.getRelativePath()); + Log.report(logvisor::Fatal, FMT_STRING("Unable to resolve {}"), tex.getRelativePath()); listOut.push_back(texTag); } } @@ -1233,12 +1226,12 @@ struct SpecMP1 : SpecBase { void cookAudioGroup(const hecl::ProjectPath& out, const hecl::ProjectPath& in, FCookProgress progress) override { DNAMP1::AGSC::Cook(in, out); - progress(_SYS_STR("Done")); + progress("Done"); } void cookSong(const hecl::ProjectPath& out, const hecl::ProjectPath& in, FCookProgress progress) override { DNAMP1::CSNG::Cook(in, out); - progress(_SYS_STR("Done")); + progress("Done"); } void cookMapArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, @@ -1246,7 +1239,7 @@ struct SpecMP1 : SpecBase { hecl::blender::MapArea mapa = ds.compileMapArea(); ds.close(); DNAMP1::MAPA::Cook(mapa, out); - progress(_SYS_STR("Done")); + progress("Done"); } void cookMapUniverse(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, @@ -1254,18 +1247,18 @@ struct SpecMP1 : SpecBase { hecl::blender::MapUniverse mapu = ds.compileMapUniverse(); ds.close(); DNAMAPU::MAPU::Cook(mapu, out); - progress(_SYS_STR("Done")); + progress("Done"); } }; hecl::Database::DataSpecEntry SpecEntMP1 = { - _SYS_STR("MP1"sv), _SYS_STR("Data specification for original Metroid Prime engine"sv), _SYS_STR(".pak"sv), + "MP1"sv, "Data specification for original Metroid Prime engine"sv, ".pak"sv, [](hecl::Database::Project& project, hecl::Database::DataSpecTool) -> std::unique_ptr { return std::make_unique(&SpecEntMP1, project, false); }}; hecl::Database::DataSpecEntry SpecEntMP1PC = { - _SYS_STR("MP1-PC"sv), _SYS_STR("Data specification for PC-optimized Metroid Prime engine"sv), _SYS_STR(".upak"sv), + "MP1-PC"sv, "Data specification for PC-optimized Metroid Prime engine"sv, ".upak"sv, [](hecl::Database::Project& project, hecl::Database::DataSpecTool tool) -> std::unique_ptr { if (tool != hecl::Database::DataSpecTool::Extract) @@ -1274,5 +1267,5 @@ hecl::Database::DataSpecEntry SpecEntMP1PC = { }}; hecl::Database::DataSpecEntry SpecEntMP1ORIG = { - _SYS_STR("MP1-ORIG"sv), _SYS_STR("Data specification for unmodified Metroid Prime resources"sv), {}, {}}; + "MP1-ORIG"sv, "Data specification for unmodified Metroid Prime resources"sv, {}, {}}; } // namespace DataSpec diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index 8bda301a6..94438362c 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -32,12 +32,12 @@ extern hecl::Database::DataSpecEntry SpecEntMP2ORIG; struct TextureCache { static void Generate(PAKRouter& pakRouter, hecl::Database::Project& project, const hecl::ProjectPath& pakPath) { - hecl::ProjectPath texturePath(pakPath, _SYS_STR("texture_cache.yaml")); - hecl::ProjectPath catalogPath(pakPath, _SYS_STR("!catalog.yaml")); + hecl::ProjectPath texturePath(pakPath, "texture_cache.yaml"); + hecl::ProjectPath catalogPath(pakPath, "!catalog.yaml"); texturePath.makeDirChain(false); - if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), _SYS_STR("a"))) { - fmt::print(fp.get(), FMT_STRING("TextureCache: {}\n"), texturePath.getRelativePathUTF8()); + if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), "a")) { + fmt::print(fp.get(), FMT_STRING("TextureCache: {}\n"), texturePath.getRelativePath()); } Log.report(logvisor::Level::Info, FMT_STRING("Gathering Texture metadata (this can take up to 10 seconds)...")); @@ -54,7 +54,7 @@ struct TextureCache { athena::io::YAMLDocWriter yamlW("MP2TextureCache"); for (const auto& pair : metaMap) { hecl::ProjectPath path = pakRouter.getWorking(pair.first); - auto rec = yamlW.enterSubRecord(path.getRelativePathUTF8()); + auto rec = yamlW.enterSubRecord(path.getRelativePath()); pair.second.write(yamlW); } @@ -109,21 +109,21 @@ struct SpecMP2 : SpecBase { SpecMP2(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) : SpecBase(specEntry, project, pc) - , m_workPath(project.getProjectWorkingPath(), _SYS_STR("MP2")) - , m_cookPath(project.getProjectCookedPath(SpecEntMP2), _SYS_STR("MP2")) + , m_workPath(project.getProjectWorkingPath(), "MP2") + , m_cookPath(project.getProjectCookedPath(SpecEntMP2), "MP2") , m_pakRouter(*this, m_workPath, m_cookPath) { m_game = EGame::MetroidPrime2; SpecBase::setThreadProject(); } - void buildPaks(nod::Node& root, const std::vector& args, ExtractReport& rep) { + void buildPaks(nod::Node& root, const std::vector& args, ExtractReport& rep) { m_nonPaks.clear(); m_paks.clear(); for (const nod::Node& child : root) { bool isPak = false; auto name = child.getName(); std::string lowerName(name); - std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); + hecl::ToLower(lowerName); if (name.size() > 4) { std::string::iterator extit = lowerName.end() - 4; if (std::string(extit, lowerName.end()) == ".pak") { @@ -136,8 +136,8 @@ struct SpecMP2 : SpecBase { if (args.size()) { good = false; if (!lowerName.compare(0, 7, "metroid")) { - hecl::SystemChar idxChar = lowerName[7]; - for (const hecl::SystemString& arg : args) { + char idxChar = lowerName[7]; + for (const std::string& arg : args) { if (arg.size() == 1 && iswdigit(arg[0])) if (arg[0] == idxChar) good = true; @@ -146,9 +146,9 @@ struct SpecMP2 : SpecBase { good = true; if (!good) { - for (const hecl::SystemString& arg : args) { - std::string lowerArg(hecl::SystemUTF8Conv(arg).str()); - std::transform(lowerArg.begin(), lowerArg.end(), lowerArg.begin(), tolower); + for (const std::string& arg : args) { + std::string lowerArg(arg); + hecl::ToLower(lowerArg); if (!lowerArg.compare(0, lowerBase.size(), lowerBase)) good = true; } @@ -175,14 +175,13 @@ struct SpecMP2 : SpecBase { } ExtractReport& childRep = rep.childOpts.emplace_back(); - hecl::SystemStringConv nameView(item.first); - childRep.name = hecl::SystemString(nameView.sys_str()); + childRep.name = item.first; childRep.desc = item.second->getLevelString(); } } - bool checkFromStandaloneDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, std::vector& reps) override { + bool checkFromStandaloneDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) override { nod::IPartition* partition = disc.getDataPartition(); std::unique_ptr dolBuf = partition->getDOLBuf(); const char* buildInfo = @@ -194,10 +193,9 @@ struct SpecMP2 : SpecBase { m_version = std::string(buildInfo); /* Root Report */ ExtractReport& rep = reps.emplace_back(); - rep.name = _SYS_STR("MP2"); - rep.desc = _SYS_STR("Metroid Prime 2 ") + regstr; - hecl::SystemStringConv buildView(m_version); - rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")"); + rep.name = "MP2"; + rep.desc = "Metroid Prime 2 " + regstr; + rep.desc += " (" + m_version + ")"; /* Iterate PAKs and build level options */ nod::Node& root = partition->getFSTRoot(); @@ -206,23 +204,23 @@ struct SpecMP2 : SpecBase { return true; } - bool checkFromTrilogyDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, std::vector& reps) override { - std::vector mp2args; + bool checkFromTrilogyDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) override { + std::vector mp2args; bool doExtract = false; if (!args.empty()) { /* Needs filter */ - for (const hecl::SystemString& arg : args) { - hecl::SystemString lowerArg = arg; + for (const std::string& arg : args) { + std::string lowerArg = arg; hecl::ToLower(lowerArg); - if (!lowerArg.compare(0, 3, _SYS_STR("mp2"))) { + if (!lowerArg.compare(0, 3, "mp2")) { doExtract = true; mp2args.reserve(args.size()); - size_t slashPos = arg.find(_SYS_STR('/')); - if (slashPos == hecl::SystemString::npos) - slashPos = arg.find(_SYS_STR('\\')); - if (slashPos != hecl::SystemString::npos) - mp2args.emplace_back(hecl::SystemString(arg.begin() + slashPos + 1, arg.end())); + size_t slashPos = arg.find('/'); + if (slashPos == std::string::npos) + slashPos = arg.find('\\'); + if (slashPos != std::string::npos) + mp2args.emplace_back(std::string(arg.begin() + slashPos + 1, arg.end())); } } } else @@ -245,12 +243,11 @@ struct SpecMP2 : SpecBase { /* Root Report */ ExtractReport& rep = reps.emplace_back(); - rep.name = _SYS_STR("MP2"); - rep.desc = _SYS_STR("Metroid Prime 2 ") + regstr; + rep.name = "MP2"; + rep.desc = "Metroid Prime 2 " + regstr; if (buildInfo != nullptr) { m_version = std::string(buildInfo); - hecl::SystemStringConv buildView(m_version); - rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")"); + rep.desc += " (" + m_version + ")"; } /* Iterate PAKs and build level options */ @@ -271,28 +268,28 @@ struct SpecMP2 : SpecBase { m_workPath.makeDir(); progress.startNewLine(); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 0.0); + progress.print("Indexing PAKs", "", 0.0); m_pakRouter.build(m_paks, - [&progress](float factor) { progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), factor); }); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 1.0); + [&progress](float factor) { progress.print("Indexing PAKs", "", factor); }); + progress.print("Indexing PAKs", "", 1.0); - hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), _SYS_STR("out")); + hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), "out"); outPath.makeDir(); disc.getDataPartition()->extractSysFiles(outPath.getAbsolutePath(), ctx); - hecl::ProjectPath mp2OutPath(outPath, _SYS_STR("files/MP2")); + hecl::ProjectPath mp2OutPath(outPath, "files/MP2"); mp2OutPath.makeDirChain(true); progress.startNewLine(); - progress.print(_SYS_STR("MP2 Root"), _SYS_STR(""), 0.0); + progress.print("MP2 Root", "", 0.0); int prog = 0; - ctx.progressCB = [&prog, &progress](nod::SystemStringView name, float) { - progress.print(_SYS_STR("MP2 Root"), name, prog); + ctx.progressCB = [&prog, &progress](std::string_view name, float) { + progress.print("MP2 Root", name, prog); }; for (const nod::Node* node : m_nonPaks) { node->extractToDirectory(mp2OutPath.getAbsolutePath(), ctx); prog++; } - progress.print(_SYS_STR("MP2 Root"), _SYS_STR(""), 1.0); + progress.print("MP2 Root", "", 1.0); hecl::ClientProcess process; progress.startNewLine(); @@ -301,14 +298,11 @@ struct SpecMP2 : SpecBase { if (!pak.m_doExtract) continue; - auto name = pak.getName(); - hecl::SystemStringConv sysName(name); - - auto pakName = hecl::SystemString(sysName.sys_str()); + auto pakName = std::string(pak.getName()); process.addLambdaTransaction([this, &progress, &pak, pakName, force](hecl::blender::Token& btok) { int threadIdx = hecl::ClientProcess::GetThreadWorkerIdx(); m_pakRouter.extractResources(pak, force, btok, - [&progress, &pakName, threadIdx](const hecl::SystemChar* substr, float factor) { + [&progress, &pakName, threadIdx](const char* substr, float factor) { progress.print(pakName, substr, factor, threadIdx); }); }); @@ -317,11 +311,11 @@ struct SpecMP2 : SpecBase { process.waitUntilComplete(); /* Generate Texture Cache containing meta data for every texture file */ - hecl::ProjectPath noAramPath(m_project.getProjectWorkingPath(), _SYS_STR("MP2/URDE")); + hecl::ProjectPath noAramPath(m_project.getProjectWorkingPath(), "MP2/URDE"); TextureCache::Generate(m_pakRouter, m_project, noAramPath); /* Write version data */ - hecl::ProjectPath versionPath = hecl::ProjectPath(m_project.getProjectWorkingPath(), _SYS_STR("out/files/MP2")); + hecl::ProjectPath versionPath = hecl::ProjectPath(m_project.getProjectWorkingPath(), "out/files/MP2"); WriteVersionInfo(m_project, versionPath); return true; } @@ -333,7 +327,7 @@ struct SpecMP2 : SpecBase { hecl::ProjectPath getWorking(class UniqueID32& id) override { return m_pakRouter.getWorking(id); } bool checkPathPrefix(const hecl::ProjectPath& path) const override { - return path.getRelativePath().compare(0, 4, _SYS_STR("MP2/")) == 0; + return path.getRelativePath().compare(0, 4, "MP2/") == 0; } bool validateYAMLDNAType(athena::io::IStreamReader& fp) const override { @@ -390,12 +384,12 @@ struct SpecMP2 : SpecBase { void cookAudioGroup(const hecl::ProjectPath& out, const hecl::ProjectPath& in, FCookProgress progress) override { DNAMP2::AGSC::Cook(in, out); - progress(_SYS_STR("Done")); + progress("Done"); } void cookSong(const hecl::ProjectPath& out, const hecl::ProjectPath& in, FCookProgress progress) override { DNAMP1::CSNG::Cook(in, out); - progress(_SYS_STR("Done")); + progress("Done"); } void cookMapArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, @@ -403,7 +397,7 @@ struct SpecMP2 : SpecBase { hecl::blender::MapArea mapa = ds.compileMapArea(); ds.close(); DNAMP2::MAPA::Cook(mapa, out); - progress(_SYS_STR("Done")); + progress("Done"); } void cookMapUniverse(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, @@ -411,18 +405,18 @@ struct SpecMP2 : SpecBase { hecl::blender::MapUniverse mapu = ds.compileMapUniverse(); ds.close(); DNAMAPU::MAPU::Cook(mapu, out); - progress(_SYS_STR("Done")); + progress("Done"); } }; hecl::Database::DataSpecEntry SpecEntMP2( - _SYS_STR("MP2"sv), _SYS_STR("Data specification for original Metroid Prime 2 engine"sv), _SYS_STR(".pak"sv), + "MP2"sv, "Data specification for original Metroid Prime 2 engine"sv, ".pak"sv, [](hecl::Database::Project& project, hecl::Database::DataSpecTool) -> std::unique_ptr { return std::make_unique(&SpecEntMP2, project, false); }); hecl::Database::DataSpecEntry SpecEntMP2PC = { - _SYS_STR("MP2-PC"sv), _SYS_STR("Data specification for PC-optimized Metroid Prime 2 engine"sv), _SYS_STR(".upak"sv), + "MP2-PC"sv, "Data specification for PC-optimized Metroid Prime 2 engine"sv, ".upak"sv, [](hecl::Database::Project& project, hecl::Database::DataSpecTool tool) -> std::unique_ptr { if (tool != hecl::Database::DataSpecTool::Extract) @@ -431,6 +425,6 @@ hecl::Database::DataSpecEntry SpecEntMP2PC = { }}; hecl::Database::DataSpecEntry SpecEntMP2ORIG = { - _SYS_STR("MP2-ORIG"sv), _SYS_STR("Data specification for unmodified Metroid Prime 2 resources"sv), {}, {}}; + "MP2-ORIG"sv, "Data specification for unmodified Metroid Prime 2 resources"sv, {}, {}}; } // namespace DataSpec diff --git a/DataSpec/SpecMP3.cpp b/DataSpec/SpecMP3.cpp index 2256cddc6..8b44dc857 100644 --- a/DataSpec/SpecMP3.cpp +++ b/DataSpec/SpecMP3.cpp @@ -29,12 +29,12 @@ extern hecl::Database::DataSpecEntry SpecEntMP3ORIG; struct TextureCache { static void Generate(PAKRouter& pakRouter, hecl::Database::Project& project, const hecl::ProjectPath& pakPath) { - hecl::ProjectPath texturePath(pakPath, _SYS_STR("texture_cache.yaml")); - hecl::ProjectPath catalogPath(pakPath, _SYS_STR("!catalog.yaml")); + hecl::ProjectPath texturePath(pakPath, "texture_cache.yaml"); + hecl::ProjectPath catalogPath(pakPath, "!catalog.yaml"); texturePath.makeDirChain(false); - if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), _SYS_STR("a"))) { - fmt::print(fp.get(), FMT_STRING("TextureCache: {}\n"), texturePath.getRelativePathUTF8()); + if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), "a")) { + fmt::print(fp.get(), FMT_STRING("TextureCache: {}\n"), texturePath.getRelativePath()); } Log.report(logvisor::Level::Info, FMT_STRING("Gathering Texture metadata (this can take up to 10 seconds)...")); @@ -51,7 +51,7 @@ struct TextureCache { athena::io::YAMLDocWriter yamlW("MP3TextureCache"); for (const auto& pair : metaMap) { hecl::ProjectPath path = pakRouter.getWorking(pair.first); - auto rec = yamlW.enterSubRecord(path.getRelativePathUTF8()); + auto rec = yamlW.enterSubRecord(path.getRelativePath()); pair.second.write(yamlW); } @@ -115,17 +115,17 @@ struct SpecMP3 : SpecBase { SpecMP3(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) : SpecBase(specEntry, project, pc) - , m_workPath(project.getProjectWorkingPath(), _SYS_STR("MP3")) - , m_cookPath(project.getProjectCookedPath(SpecEntMP3), _SYS_STR("MP3")) + , m_workPath(project.getProjectWorkingPath(), "MP3") + , m_cookPath(project.getProjectCookedPath(SpecEntMP3), "MP3") , m_pakRouter(*this, m_workPath, m_cookPath) - , m_feWorkPath(project.getProjectWorkingPath(), _SYS_STR("fe")) - , m_feCookPath(project.getProjectCookedPath(SpecEntMP3), _SYS_STR("fe")) + , m_feWorkPath(project.getProjectWorkingPath(), "fe") + , m_feCookPath(project.getProjectCookedPath(SpecEntMP3), "fe") , m_fePakRouter(*this, m_feWorkPath, m_feCookPath) { m_game = EGame::MetroidPrime3; SpecBase::setThreadProject(); } - void buildPaks(nod::Node& root, const std::vector& args, ExtractReport& rep, bool fe) { + void buildPaks(nod::Node& root, const std::vector& args, ExtractReport& rep, bool fe) { if (fe) { m_feNonPaks.clear(); m_fePaks.clear(); @@ -137,7 +137,7 @@ struct SpecMP3 : SpecBase { bool isPak = false; auto name = child.getName(); std::string lowerName(name); - std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower); + hecl::ToLower(lowerName); if (name.size() > 4) { std::string::iterator extit = lowerName.end() - 4; if (std::string(extit, lowerName.end()) == ".pak") { @@ -150,8 +150,8 @@ struct SpecMP3 : SpecBase { if (args.size()) { good = false; if (!lowerName.compare(0, 7, "metroid")) { - hecl::SystemChar idxChar = lowerName[7]; - for (const hecl::SystemString& arg : args) { + char idxChar = lowerName[7]; + for (const std::string& arg : args) { if (arg.size() == 1 && iswdigit(arg[0])) if (arg[0] == idxChar) good = true; @@ -160,9 +160,9 @@ struct SpecMP3 : SpecBase { good = true; if (!good) { - for (const hecl::SystemString& arg : args) { - std::string lowerArg(hecl::SystemUTF8Conv(arg).str()); - std::transform(lowerArg.begin(), lowerArg.end(), lowerArg.begin(), tolower); + for (const std::string& arg : args) { + std::string lowerArg(arg); + hecl::ToLower(lowerArg); if (!lowerArg.compare(0, lowerBase.size(), lowerBase)) good = true; } @@ -201,25 +201,24 @@ struct SpecMP3 : SpecBase { continue; ExtractReport& childRep = rep.childOpts.emplace_back(); - hecl::SystemStringConv nameView(item.first); - childRep.name = hecl::SystemString(nameView.sys_str()); + childRep.name = item.first; if (item.first == "Worlds.pak") continue; else if (item.first == "Metroid6.pak") { /* Phaaze doesn't have a world name D: */ - childRep.desc = _SYS_STR("Phaaze"); + childRep.desc = "Phaaze"; continue; } else if (item.first == "Metroid8.pak") { /* Space world is misnamed */ - childRep.desc = _SYS_STR("Space"); + childRep.desc = "Space"; continue; } childRep.desc = item.second->getLevelString(); } } - bool checkFromStandaloneDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, std::vector& reps) override { + bool checkFromStandaloneDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) override { doMP3 = true; nod::IPartition* partition = disc.getDataPartition(); std::unique_ptr dolBuf = partition->getDOLBuf(); @@ -237,10 +236,9 @@ struct SpecMP3 : SpecBase { m_version = std::string(buildInfo); /* Root Report */ ExtractReport& rep = reps.emplace_back(); - rep.name = _SYS_STR("MP3"); - rep.desc = _SYS_STR("Metroid Prime 3 ") + regstr; - hecl::SystemStringConv buildView(m_version); - rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")"); + rep.name = "MP3"; + rep.desc = "Metroid Prime 3 " + regstr; + rep.desc += " (" + m_version + ")"; /* Iterate PAKs and build level options */ nod::Node& root = partition->getFSTRoot(); @@ -249,37 +247,37 @@ struct SpecMP3 : SpecBase { return true; } - bool checkFromTrilogyDisc(nod::DiscBase& disc, const hecl::SystemString& regstr, - const std::vector& args, std::vector& reps) override { - std::vector mp3args; - std::vector feargs; + bool checkFromTrilogyDisc(nod::DiscBase& disc, const std::string& regstr, + const std::vector& args, std::vector& reps) override { + std::vector mp3args; + std::vector feargs; if (args.size()) { /* Needs filter */ - for (const hecl::SystemString& arg : args) { - hecl::SystemString lowerArg = arg; + for (const std::string& arg : args) { + std::string lowerArg = arg; hecl::ToLower(lowerArg); - if (!lowerArg.compare(0, 3, _SYS_STR("mp3"))) { + if (!lowerArg.compare(0, 3, "mp3")) { doMP3 = true; mp3args.reserve(args.size()); - size_t slashPos = arg.find(_SYS_STR('/')); - if (slashPos == hecl::SystemString::npos) - slashPos = arg.find(_SYS_STR('\\')); - if (slashPos != hecl::SystemString::npos) - mp3args.emplace_back(hecl::SystemString(arg.begin() + slashPos + 1, arg.end())); + size_t slashPos = arg.find('/'); + if (slashPos == std::string::npos) + slashPos = arg.find('\\'); + if (slashPos != std::string::npos) + mp3args.emplace_back(std::string(arg.begin() + slashPos + 1, arg.end())); } } - for (const hecl::SystemString& arg : args) { - hecl::SystemString lowerArg = arg; + for (const std::string& arg : args) { + std::string lowerArg = arg; hecl::ToLower(lowerArg); - if (!lowerArg.compare(0, 2, _SYS_STR("fe"))) { + if (!lowerArg.compare(0, 2, "fe")) { doMPTFE = true; feargs.reserve(args.size()); - size_t slashPos = arg.find(_SYS_STR('/')); - if (slashPos == hecl::SystemString::npos) - slashPos = arg.find(_SYS_STR('\\')); - if (slashPos != hecl::SystemString::npos) - feargs.emplace_back(hecl::SystemString(arg.begin() + slashPos + 1, arg.end())); + size_t slashPos = arg.find('/'); + if (slashPos == std::string::npos) + slashPos = arg.find('\\'); + if (slashPos != std::string::npos) + feargs.emplace_back(std::string(arg.begin() + slashPos + 1, arg.end())); } } } else { @@ -317,12 +315,11 @@ struct SpecMP3 : SpecBase { /* Root Report */ ExtractReport& rep = reps.emplace_back(); - rep.name = _SYS_STR("MP3"); - rep.desc = _SYS_STR("Metroid Prime 3 ") + regstr; + rep.name = "MP3"; + rep.desc = "Metroid Prime 3 " + regstr; m_version = std::string(buildInfo); - hecl::SystemStringConv buildView(m_version); - rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")"); + rep.desc += " (" + m_version + ")"; /* Iterate PAKs and build level options */ nod::Node::DirectoryIterator mp3It = root.find("MP3"); @@ -347,12 +344,11 @@ struct SpecMP3 : SpecBase { /* Root Report */ ExtractReport& rep = reps.emplace_back(); - rep.name = _SYS_STR("fe"); - rep.desc = _SYS_STR("Metroid Prime Trilogy Frontend ") + regstr; + rep.name = "fe"; + rep.desc = "Metroid Prime Trilogy Frontend " + regstr; if (buildInfo) { std::string buildStr(buildInfo); - hecl::SystemStringConv buildView(buildStr); - rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")"); + rep.desc += " (" + buildStr + ")"; } /* Iterate PAKs and build level options */ @@ -369,30 +365,30 @@ struct SpecMP3 : SpecBase { } bool extractFromDisc(nod::DiscBase& disc, bool force, const hecl::MultiProgressPrinter& progress) override { - hecl::SystemString currentTarget; + std::string currentTarget; size_t nodeCount = 0; int prog = 0; - nod::ExtractionContext ctx = {force, [&](nod::SystemStringView name, float) { + nod::ExtractionContext ctx = {force, [&](std::string_view name, float) { progress.print(currentTarget, name, prog / (float)nodeCount); }}; if (doMP3) { m_workPath.makeDir(); progress.startNewLine(); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 0.0); + progress.print("Indexing PAKs", "", 0.0); m_pakRouter.build(m_paks, - [&progress](float factor) { progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), factor); }); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 1.0); + [&progress](float factor) { progress.print("Indexing PAKs", "", factor); }); + progress.print("Indexing PAKs", "", 1.0); progress.startNewLine(); - hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), _SYS_STR("out")); + hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), "out"); outPath.makeDir(); disc.getDataPartition()->extractSysFiles(outPath.getAbsolutePath(), ctx); - m_outPath = {outPath, _SYS_STR("files/MP3")}; + m_outPath = {outPath, "files/MP3"}; m_outPath.makeDirChain(true); - currentTarget = _SYS_STR("MP3 Root"); - progress.print(currentTarget.c_str(), _SYS_STR(""), 0.0); + currentTarget = "MP3 Root"; + progress.print(currentTarget.c_str(), "", 0.0); prog = 0; nodeCount = m_nonPaks.size(); @@ -403,7 +399,7 @@ struct SpecMP3 : SpecBase { } ctx.progressCB = nullptr; - progress.print(currentTarget.c_str(), _SYS_STR(""), 1.0); + progress.print(currentTarget.c_str(), "", 1.0); progress.startNewLine(); hecl::ClientProcess process; @@ -412,13 +408,10 @@ struct SpecMP3 : SpecBase { if (!pak.m_doExtract) continue; - auto name = pak.getName(); - hecl::SystemStringConv sysName(name); - - auto pakName = hecl::SystemString(sysName.sys_str()); + auto pakName = std::string(pak.getName()); process.addLambdaTransaction([this, &progress, &pak, pakName, force](hecl::blender::Token& btok) { m_pakRouter.extractResources(pak, force, btok, - [&progress, &pakName](const hecl::SystemChar* substr, float factor) { + [&progress, &pakName](const char* substr, float factor) { progress.print(pakName, substr, factor); }); }); @@ -431,20 +424,20 @@ struct SpecMP3 : SpecBase { m_feWorkPath.makeDir(); progress.startNewLine(); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 0.0); + progress.print("Indexing PAKs", "", 0.0); m_fePakRouter.build( - m_fePaks, [&progress](float factor) { progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), factor); }); - progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 1.0); + m_fePaks, [&progress](float factor) { progress.print("Indexing PAKs", "", factor); }); + progress.print("Indexing PAKs", "", 1.0); progress.startNewLine(); - hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), _SYS_STR("out")); + hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), "out"); outPath.makeDir(); disc.getDataPartition()->extractSysFiles(outPath.getAbsolutePath(), ctx); - m_feOutPath = {outPath, _SYS_STR("files/fe")}; + m_feOutPath = {outPath, "files/fe"}; m_feOutPath.makeDirChain(true); - currentTarget = _SYS_STR("fe Root"); - progress.print(currentTarget.c_str(), _SYS_STR(""), 0.0); + currentTarget = "fe Root"; + progress.print(currentTarget.c_str(), "", 0.0); prog = 0; nodeCount = m_feNonPaks.size(); @@ -453,7 +446,7 @@ struct SpecMP3 : SpecBase { node->extractToDirectory(m_feOutPath.getAbsolutePath(), ctx); prog++; } - progress.print(currentTarget.c_str(), _SYS_STR(""), 1.0); + progress.print(currentTarget.c_str(), "", 1.0); progress.startNewLine(); hecl::ClientProcess process; @@ -462,13 +455,10 @@ struct SpecMP3 : SpecBase { if (!pak.m_doExtract) continue; - auto name = pak.getName(); - hecl::SystemStringConv sysName(name); - - hecl::SystemString pakName(sysName.sys_str()); + std::string pakName(pak.getName()); process.addLambdaTransaction([this, &progress, &pak, pakName, force](hecl::blender::Token& btok) { m_fePakRouter.extractResources(pak, force, btok, - [&progress, &pakName](const hecl::SystemChar* substr, float factor) { + [&progress, &pakName](const char* substr, float factor) { progress.print(pakName, substr, factor); }); }); @@ -479,11 +469,11 @@ struct SpecMP3 : SpecBase { /* Generate Texture Cache containing meta data for every texture file */ if (doMP3) { - hecl::ProjectPath noAramPath(m_workPath, _SYS_STR("URDE")); + hecl::ProjectPath noAramPath(m_workPath, "URDE"); TextureCache::Generate(m_pakRouter, m_project, noAramPath); } if (doMPTFE) { - hecl::ProjectPath noAramPath(m_feWorkPath, _SYS_STR("URDE")); + hecl::ProjectPath noAramPath(m_feWorkPath, "URDE"); TextureCache::Generate(m_fePakRouter, m_project, noAramPath); } /* Write version data */ @@ -503,7 +493,7 @@ struct SpecMP3 : SpecBase { hecl::ProjectPath getWorking(class UniqueID64& id) override { return m_pakRouter.getWorking(id); } bool checkPathPrefix(const hecl::ProjectPath& path) const override { - return path.getRelativePath().compare(0, 4, _SYS_STR("MP3/")) == 0; + return path.getRelativePath().compare(0, 4, "MP3/") == 0; } bool validateYAMLDNAType(athena::io::IStreamReader& fp) const override { @@ -559,7 +549,7 @@ struct SpecMP3 : SpecBase { hecl::blender::MapArea mapa = ds.compileMapArea(); ds.close(); DNAMP3::MAPA::Cook(mapa, out); - progress(_SYS_STR("Done")); + progress("Done"); } void cookMapUniverse(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, @@ -567,13 +557,13 @@ struct SpecMP3 : SpecBase { }; hecl::Database::DataSpecEntry SpecEntMP3( - _SYS_STR("MP3"sv), _SYS_STR("Data specification for original Metroid Prime 3 engine"sv), _SYS_STR(".pak"sv), + "MP3"sv, "Data specification for original Metroid Prime 3 engine"sv, ".pak"sv, [](hecl::Database::Project& project, hecl::Database::DataSpecTool) -> std::unique_ptr { return std::make_unique(&SpecEntMP3, project, false); }); hecl::Database::DataSpecEntry SpecEntMP3PC = { - _SYS_STR("MP3-PC"sv), _SYS_STR("Data specification for PC-optimized Metroid Prime 3 engine"sv), _SYS_STR(".upak"sv), + "MP3-PC"sv, "Data specification for PC-optimized Metroid Prime 3 engine"sv, ".upak"sv, [](hecl::Database::Project& project, hecl::Database::DataSpecTool tool) -> std::unique_ptr { if (tool != hecl::Database::DataSpecTool::Extract) @@ -582,6 +572,6 @@ hecl::Database::DataSpecEntry SpecEntMP3PC = { }}; hecl::Database::DataSpecEntry SpecEntMP3ORIG = { - _SYS_STR("MP3-ORIG"sv), _SYS_STR("Data specification for unmodified Metroid Prime 3 resources"sv), {}, {}}; + "MP3-ORIG"sv, "Data specification for unmodified Metroid Prime 3 resources"sv, {}, {}}; } // namespace DataSpec diff --git a/Runtime/AutoMapper/CAutoMapper.cpp b/Runtime/AutoMapper/CAutoMapper.cpp index 8d506b9d9..f863f1806 100644 --- a/Runtime/AutoMapper/CAutoMapper.cpp +++ b/Runtime/AutoMapper/CAutoMapper.cpp @@ -14,6 +14,7 @@ #include "Runtime/Particle/CGenDescription.hpp" #include "Runtime/World/CPlayer.hpp" +#include #include namespace metaforce { diff --git a/Runtime/CDvdFile.cpp b/Runtime/CDvdFile.cpp index 34b9ca6fe..e874686b6 100644 --- a/Runtime/CDvdFile.cpp +++ b/Runtime/CDvdFile.cpp @@ -123,9 +123,9 @@ void CDvdFile::RecursiveBuildCaseInsensitiveMap(const hecl::ProjectPath& path, s RecursiveBuildCaseInsensitiveMap(hecl::ProjectPath(path, p.m_name), prefixLen); } else { hecl::ProjectPath ch(path, p.m_name); - std::string chStr(ch.getAbsolutePathUTF8().begin() + prefixLen, ch.getAbsolutePathUTF8().end()); + std::string chStr(ch.getAbsolutePath().begin() + prefixLen, ch.getAbsolutePath().end()); std::string lowerChStr(chStr); - std::transform(lowerChStr.begin(), lowerChStr.end(), lowerChStr.begin(), ::tolower); + hecl::ToLower(lowerChStr); m_caseInsensitiveMap[lowerChStr] = chStr; } } @@ -133,7 +133,7 @@ void CDvdFile::RecursiveBuildCaseInsensitiveMap(const hecl::ProjectPath& path, s void CDvdFile::Initialize(const hecl::ProjectPath& path) { m_DvdRoot = path; - RecursiveBuildCaseInsensitiveMap(path, path.getAbsolutePathUTF8().length() + 1); + RecursiveBuildCaseInsensitiveMap(path, path.getAbsolutePath().length() + 1); if (m_WorkerRun.load()) { return; } diff --git a/Runtime/CGameAllocator.cpp b/Runtime/CGameAllocator.cpp index ce786ff48..87f062408 100644 --- a/Runtime/CGameAllocator.cpp +++ b/Runtime/CGameAllocator.cpp @@ -44,7 +44,7 @@ u8* CGameAllocator::Alloc(size_t len) { void CGameAllocator::Free(u8* ptr) { SChunkDescription* info = reinterpret_cast(ptr - sizeof(SChunkDescription)); if (info->magic != 0xE8E8E8E8 || info->sentinal != 0xEFEFEFEF) { - AllocLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Invalid chunk description, memory corruption!"))); + AllocLog.report(logvisor::Fatal, FMT_STRING("Invalid chunk description, memory corruption!")); return; } diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index be6bd36bf..196ba619b 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -101,41 +101,41 @@ private: #endif }; -extern hecl::SystemString ExeDir; +extern std::string ExeDir; namespace metaforce { static logvisor::Module Log{"Metaforce"}; std::optional g_mainMP1; -static hecl::SystemString CPUFeatureString(const zeus::CPUInfo& cpuInf) { - hecl::SystemString features; +static std::string CPUFeatureString(const zeus::CPUInfo& cpuInf) { + std::string features; #if defined(__x86_64__) || defined(_M_X64) - auto AddFeature = [&features](const hecl::SystemChar* str) { + auto AddFeature = [&features](const char* str) { if (!features.empty()) - features += _SYS_STR(", "); + features += ", "; features += str; }; if (cpuInf.AESNI) - AddFeature(_SYS_STR("AES-NI")); + AddFeature("AES-NI"); if (cpuInf.SSE1) - AddFeature(_SYS_STR("SSE")); + AddFeature("SSE"); if (cpuInf.SSE2) - AddFeature(_SYS_STR("SSE2")); + AddFeature("SSE2"); if (cpuInf.SSE3) - AddFeature(_SYS_STR("SSE3")); + AddFeature("SSE3"); if (cpuInf.SSSE3) - AddFeature(_SYS_STR("SSSE3")); + AddFeature("SSSE3"); if (cpuInf.SSE4a) - AddFeature(_SYS_STR("SSE4a")); + AddFeature("SSE4a"); if (cpuInf.SSE41) - AddFeature(_SYS_STR("SSE4.1")); + AddFeature("SSE4.1"); if (cpuInf.SSE42) - AddFeature(_SYS_STR("SSE4.2")); + AddFeature("SSE4.2"); if (cpuInf.AVX) - AddFeature(_SYS_STR("AVX")); + AddFeature("AVX"); if (cpuInf.AVX2) - AddFeature(_SYS_STR("AVX2")); + AddFeature("AVX2"); #endif return features; } @@ -253,7 +253,7 @@ private: std::string m_errorString; boo::ObjToken m_renderTex; - hecl::SystemString m_deferredProject; + std::string m_deferredProject; std::unique_ptr m_proj; std::optional m_amuseAllocWrapper; std::unique_ptr m_voiceEngine; @@ -275,7 +275,7 @@ public: int appMain(boo::IApplication* app) override { initialize(app); - m_window = app->newWindow(_SYS_STR("Metaforce"sv)); + m_window = app->newWindow("Metaforce"sv); if (!m_window) { return 1; } @@ -283,8 +283,7 @@ public: m_window->showWindow(); boo::IGraphicsDataFactory* gfxF = m_window->getMainContextDataFactory(); - m_window->setTitle( - fmt::format(FMT_STRING(_SYS_STR("Metaforce {} [{}]")), METAFORCE_WC_DESCRIBE_SYS, gfxF->platformName())); + m_window->setTitle(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, gfxF->platformName())); boo::SWindowRect rect = m_window->getWindowFrame(); m_windowCallback.m_lastRect = rect; @@ -303,26 +302,25 @@ public: hecl::ProjectPath projectPath; for (const auto& arg : app->getArgs()) { hecl::Sstat theStat; - if (!hecl::Stat((arg + _SYS_STR("/out")).c_str(), &theStat) && S_ISDIR(theStat.st_mode)) { + if (!hecl::Stat((arg + "/out").c_str(), &theStat) && S_ISDIR(theStat.st_mode)) { hecl::ProjectRootPath rootPath(arg); hecl::Database::Project tmp(rootPath); // Force project creation } if (m_deferredProject.empty() && hecl::SearchForProject(arg)) m_deferredProject = arg; - if (arg == _SYS_STR("--no-shader-warmup")) + if (arg == "--no-shader-warmup") m_noShaderWarmup = true; - else if (arg == _SYS_STR("--no-sound")) + else if (arg == "--no-sound") m_voiceEngine->setVolume(0.f); } if (m_deferredProject.empty()) { /* Default behavior - search upwards for packaged project containing the program */ if (hecl::ProjectRootPath projRoot = hecl::SearchForProject(ExeDir)) { - hecl::SystemString rootPath(projRoot.getAbsolutePath()); + std::string rootPath(projRoot.getAbsolutePath()); hecl::Sstat theStat; - if (hecl::Stat((rootPath + _SYS_STR("/out/files/MP1/Metroid1.upak")).c_str(), &theStat) == 0 && - S_ISREG(theStat.st_mode)) - m_deferredProject = rootPath + _SYS_STR("/out"); + if (hecl::Stat((rootPath + "/out/files/MP1/Metroid1.upak").c_str(), &theStat) == 0 && S_ISREG(theStat.st_mode)) + m_deferredProject = rootPath + "/out"; } } @@ -353,10 +351,9 @@ public: void initialize(boo::IApplication* app) { zeus::detectCPU(); - for (const boo::SystemString& arg : app->getArgs()) { - if (arg.find(_SYS_STR("--verbosity=")) == 0 || arg.find(_SYS_STR("-v=")) == 0) { - hecl::SystemUTF8Conv utf8Arg(arg.substr(arg.find_last_of('=') + 1)); - hecl::VerbosityLevel = atoi(utf8Arg.c_str()); + for (const auto& arg : app->getArgs()) { + if (arg.find("--verbosity=") == 0 || arg.find("-v=") == 0) { + hecl::VerbosityLevel = atoi(arg.substr(arg.find_last_of('=') + 1).c_str()); hecl::LogModule.report(logvisor::Info, FMT_STRING("Set verbosity level to {}"), hecl::VerbosityLevel); } } @@ -364,22 +361,21 @@ public: const zeus::CPUInfo& cpuInf = zeus::cpuFeatures(); Log.report(logvisor::Info, FMT_STRING("CPU Name: {}"), cpuInf.cpuBrand); Log.report(logvisor::Info, FMT_STRING("CPU Vendor: {}"), cpuInf.cpuVendor); - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("CPU Features: {}")), CPUFeatureString(cpuInf)); + Log.report(logvisor::Info, FMT_STRING("CPU Features: {}"), CPUFeatureString(cpuInf)); } void onAppIdle() noexcept { if (!m_deferredProject.empty()) { - hecl::SystemString subPath; + std::string subPath; hecl::ProjectRootPath projPath = hecl::SearchForProject(m_deferredProject, subPath); if (projPath) { m_proj = std::make_unique(projPath); m_deferredProject.clear(); - hecl::ProjectPath projectPath{m_proj->getProjectWorkingPath(), _SYS_STR("out/files/MP1")}; + hecl::ProjectPath projectPath{m_proj->getProjectWorkingPath(), "out/files/MP1"}; CDvdFile::Initialize(projectPath); } else { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Project doesn't exist at '{}'")), m_deferredProject); - hecl::SystemUTF8Conv conv{m_deferredProject}; - m_errorString = fmt::format(FMT_STRING("Project not found at '{}'"), conv.str()); + Log.report(logvisor::Error, FMT_STRING("Project doesn't exist at '{}'"), m_deferredProject); + m_errorString = fmt::format(FMT_STRING("Project not found at '{}'"), m_deferredProject); m_deferredProject.clear(); } } @@ -433,8 +429,7 @@ public: } } if (!m_imGuiInitialized) { - hecl::SystemUTF8Conv configDir{m_fileMgr.getStoreRoot()}; - ImGuiEngine::Initialize(gfxF, m_window.get(), scale, configDir.str()); + ImGuiEngine::Initialize(gfxF, m_window.get(), scale, m_fileMgr.getStoreRoot()); m_imGuiInitialized = true; } @@ -534,17 +529,17 @@ public: } // namespace metaforce -static hecl::SystemChar CwdBuf[1024]; -hecl::SystemString ExeDir; +static char CwdBuf[1024]; +std::string ExeDir; static void SetupBasics(bool logging) { auto result = zeus::validateCPU(); if (!result.first) { #if _WIN32 && !WINDOWS_STORE - std::wstring msg = - fmt::format(FMT_STRING(L"ERROR: This build of Metaforce requires the following CPU features:\n{}\n"), + std::string msg = + fmt::format(FMT_STRING("ERROR: This build of Metaforce requires the following CPU features:\n{}\n"), metaforce::CPUFeatureString(result.second)); - MessageBoxW(nullptr, msg.c_str(), L"CPU error", MB_OK | MB_ICONERROR); + MessageBoxW(nullptr, nowide::widen(msg).c_str(), L"CPU error", MB_OK | MB_ICONERROR); #else fmt::print(stderr, FMT_STRING("ERROR: This build of Metaforce requires the following CPU features:\n{}\n"), metaforce::CPUFeatureString(result.second)); @@ -558,58 +553,52 @@ static void SetupBasics(bool logging) { atSetExceptionHandler(AthenaExc); #if SENTRY_ENABLED - hecl::Runtime::FileStoreManager fileMgr{_SYS_STR("sentry-native-metaforce")}; - hecl::SystemUTF8Conv cacheDir{fileMgr.getStoreRoot()}; + hecl::Runtime::FileStoreManager fileMgr{"sentry-native-metaforce"}; + std::string cacheDir{fileMgr.getStoreRoot()}; logvisor::RegisterSentry("metaforce", METAFORCE_WC_DESCRIBE, cacheDir.c_str()); #endif } -static bool IsClientLoggingEnabled(int argc, const boo::SystemChar** argv) { +static bool IsClientLoggingEnabled(int argc, char** argv) { for (int i = 1; i < argc; ++i) - if (!hecl::StrNCmp(argv[i], _SYS_STR("-l"), 2)) + if (!hecl::StrNCmp(argv[i], "-l", 2)) return true; return false; } #if !WINDOWS_STORE -#if _WIN32 -int wmain(int argc, const boo::SystemChar** argv) -#else -int main(int argc, const boo::SystemChar** argv) -#endif -{ - if (argc > 1 && !hecl::StrCmp(argv[1], _SYS_STR("--dlpackage"))) { +int main(int argc, char** argv) { + if (argc > 1 && !hecl::StrCmp(argv[1], "--dlpackage")) { fmt::print(FMT_STRING("{}\n"), METAFORCE_DLPACKAGE); return 100; } SetupBasics(IsClientLoggingEnabled(argc, argv)); - hecl::Runtime::FileStoreManager fileMgr{_SYS_STR("metaforce")}; + hecl::Runtime::FileStoreManager fileMgr{"metaforce"}; hecl::CVarManager cvarMgr{fileMgr}; hecl::CVarCommons cvarCmns{cvarMgr}; - std::vector args; + std::vector args; for (int i = 1; i < argc; ++i) - args.push_back(argv[i]); + args.emplace_back(argv[i]); cvarMgr.parseCommandLine(args); - hecl::SystemString logFile{hecl::SystemStringConv(cvarCmns.getLogFile()).c_str()}; - hecl::SystemString logFilePath; + std::string logFile = cvarCmns.getLogFile(); + std::string logFilePath; if (!logFile.empty()) { std::time_t time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); char buf[100]; std::strftime(buf, 100, "%Y-%m-%d_%H-%M-%S", std::localtime(&time)); - hecl::SystemString timeStr = hecl::SystemStringConv(buf).c_str(); - logFilePath = fmt::format(FMT_STRING(_SYS_STR("{}/{}-{}")), fileMgr.getStoreRoot(), timeStr, logFile); + logFilePath = fmt::format(FMT_STRING("{}/{}-{}"), fileMgr.getStoreRoot(), buf, logFile); logvisor::RegisterFileLogger(logFilePath.c_str()); } - if (hecl::SystemChar* cwd = hecl::Getcwd(CwdBuf, 1024)) { + if (char* cwd = hecl::Getcwd(CwdBuf, 1024)) { if (hecl::PathRelative(argv[0])) - ExeDir = hecl::SystemString(cwd) + _SYS_STR('/'); - hecl::SystemString Argv0(argv[0]); - hecl::SystemString::size_type lastIdx = Argv0.find_last_of(_SYS_STR("/\\")); - if (lastIdx != hecl::SystemString::npos) + ExeDir = std::string(cwd) + '/'; + std::string Argv0(argv[0]); + std::string::size_type lastIdx = Argv0.find_last_of("/\\"); + if (lastIdx != std::string::npos) ExeDir.insert(ExeDir.end(), Argv0.begin(), Argv0.begin() + lastIdx); } @@ -617,9 +606,9 @@ int main(int argc, const boo::SystemChar** argv) hecl::SetCpuCountOverride(argc, argv); metaforce::Application appCb(fileMgr, cvarMgr, cvarCmns); - int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, appCb, _SYS_STR("metaforce"), - _SYS_STR("Metaforce"), argc, argv, appCb.getGraphicsApi(), appCb.getSamples(), - appCb.getAnisotropy(), appCb.getDeepColor(), false); + int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, appCb, "metaforce", "Metaforce", argv[0], args, + appCb.getGraphicsApi(), appCb.getSamples(), appCb.getAnisotropy(), appCb.getDeepColor(), + false); return ret; } #endif @@ -631,30 +620,22 @@ using namespace Windows::ApplicationModel::Core; [Platform::MTAThread] int WINAPIV main(Platform::Array ^ params) { SetupBasics(false); metaforce::Application appCb; - auto viewProvider = ref new boo::ViewProvider(appCb, _SYS_STR("metaforce"), _SYS_STR("Metaforce"), - _SYS_STR("metaforce"), params, false); + auto viewProvider = ref new boo::ViewProvider(appCb, "metaforce", "Metaforce", "metaforce", params, false); CoreApplication::Run(viewProvider); return 0; } #elif _WIN32 #include +#include -int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) { +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int) { int argc = 0; - const boo::SystemChar** argv; - if (lpCmdLine[0]) - argv = (const wchar_t**)(CommandLineToArgvW(lpCmdLine, &argc)); - static boo::SystemChar selfPath[1024]; - GetModuleFileNameW(nullptr, selfPath, 1024); - static const boo::SystemChar* booArgv[32] = {}; - booArgv[0] = selfPath; - for (int i = 0; i < argc; ++i) - booArgv[i + 1] = argv[i]; - + char** argv = nullptr; + nowide::args _(argc, argv); const DWORD outType = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); - if (IsClientLoggingEnabled(argc + 1, booArgv) && outType == FILE_TYPE_UNKNOWN) + if (IsClientLoggingEnabled(argc, argv) && outType == FILE_TYPE_UNKNOWN) logvisor::CreateWin32Console(); - return wmain(argc + 1, booArgv); + return main(argc, argv); } #endif diff --git a/Runtime/CMemoryCardSys.cpp b/Runtime/CMemoryCardSys.cpp index b50ef6e6b..9ae7656d1 100644 --- a/Runtime/CMemoryCardSys.cpp +++ b/Runtime/CMemoryCardSys.cpp @@ -13,7 +13,7 @@ namespace metaforce { namespace { using ECardResult = kabufuda::ECardResult; -static kabufuda::SystemString g_CardImagePaths[2] = {}; +static std::string g_CardImagePaths[2] = {}; static kabufuda::Card g_CardStates[2] = {kabufuda::Card{"GM8E", "01"}, kabufuda::Card{"GM8E", "01"}}; // static kabufuda::ECardResult g_OpResults[2] = {}; hecl::CVar* mc_dolphinAPath = nullptr; @@ -336,24 +336,16 @@ ECardResult CMemoryCardSys::CCardFileInfo::WriteFile() { } ECardResult CMemoryCardSys::CCardFileInfo::CloseFile() { return CMemoryCardSys::CloseFile(m_handle); } -kabufuda::SystemString CMemoryCardSys::_GetDolphinCardPath(kabufuda::ECardSlot slot) { +std::string CMemoryCardSys::_GetDolphinCardPath(kabufuda::ECardSlot slot) { return g_CardImagePaths[static_cast(slot)]; } void CMemoryCardSys::_ResolveDolphinCardPath(const hecl::CVar* cv, kabufuda::ECardSlot slot) { -#if CARD_UCS2 - if (cv != nullptr && cv->toWideLiteral().empty()) { - g_CardImagePaths[int(slot)] = ResolveDolphinCardPath(slot); - } else if (cv != nullptr) { - g_CardImagePaths[int(slot)] = cv->toWideLiteral(); - } -#else if (cv != nullptr && cv->toLiteral().empty()) { g_CardImagePaths[int(slot)] = ResolveDolphinCardPath(slot); } else if (cv != nullptr) { g_CardImagePaths[int(slot)] = cv->toLiteral(); } -#endif } kabufuda::ProbeResults CMemoryCardSys::CardProbe(kabufuda::ECardSlot port) { @@ -563,7 +555,7 @@ void CMemoryCardSys::CommitToDisk(kabufuda::ECardSlot port) { } bool CMemoryCardSys::CreateDolphinCard(kabufuda::ECardSlot slot) { - kabufuda::SystemString path = + std::string path = _CreateDolphinCard(slot, slot == kabufuda::ECardSlot::SlotA ? mc_dolphinAPath->hasDefaultValue() : mc_dolphinBPath->hasDefaultValue()); if (CardProbe(slot).x0_error != ECardResult::READY) { diff --git a/Runtime/CMemoryCardSys.hpp b/Runtime/CMemoryCardSys.hpp index beba822b7..6c99bf540 100644 --- a/Runtime/CMemoryCardSys.hpp +++ b/Runtime/CMemoryCardSys.hpp @@ -69,10 +69,10 @@ class CMemoryCardSys { public: static void _ResetCVar(kabufuda::ECardSlot slot); static void _ResolveDolphinCardPath(const hecl::CVar* cv, kabufuda::ECardSlot slot); - static kabufuda::SystemString ResolveDolphinCardPath(kabufuda::ECardSlot slot); + static std::string ResolveDolphinCardPath(kabufuda::ECardSlot slot); static bool CreateDolphinCard(kabufuda::ECardSlot slot); - static kabufuda::SystemString _GetDolphinCardPath(kabufuda::ECardSlot slot); - static kabufuda::SystemString _CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin); + static std::string _GetDolphinCardPath(kabufuda::ECardSlot slot); + static std::string _CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin); using ECardResult = kabufuda::ECardResult; struct CardResult { diff --git a/Runtime/CMemoryCardSysNix.cpp b/Runtime/CMemoryCardSysNix.cpp index 8354496e9..c7ff75db6 100644 --- a/Runtime/CMemoryCardSysNix.cpp +++ b/Runtime/CMemoryCardSysNix.cpp @@ -4,7 +4,7 @@ namespace metaforce { -kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) { +std::string CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) { if (g_Main->IsUSA() && !g_Main->IsTrilogy()) { const char* home = getenv("HOME"); if (!home || home[0] != '/') @@ -12,8 +12,8 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo const char* dataHome = getenv("XDG_DATA_HOME"); /* XDG-selected data path */ - kabufuda::SystemString path = - ((dataHome && dataHome[0] == '/') ? dataHome : hecl::SystemString(home)) + "/.local/share/dolphin-emu"; + std::string path = + ((dataHome && dataHome[0] == '/') ? dataHome : std::string(home)) + "/.local/share/dolphin-emu"; path += fmt::format(FMT_STRING("/GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); hecl::Sstat theStat; @@ -31,7 +31,7 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo return {}; } -kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin) { +std::string CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin) { if (g_Main->IsUSA() && !g_Main->IsTrilogy()) { if (dolphin) { const char* home = getenv("HOME"); @@ -40,8 +40,8 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl const char* dataHome = getenv("XDG_DATA_HOME"); /* XDG-selected data path */ - kabufuda::SystemString path = - ((dataHome && dataHome[0] == '/') ? dataHome : hecl::SystemString(home)) + "/.local/share/dolphin-emu/GC"; + std::string path = + ((dataHome && dataHome[0] == '/') ? dataHome : std::string(home)) + "/.local/share/dolphin-emu/GC"; if (hecl::RecursiveMakeDir(path.c_str()) < 0) return {}; @@ -52,12 +52,12 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl return path; } } else { - kabufuda::SystemString path = _GetDolphinCardPath(slot); + std::string path = _GetDolphinCardPath(slot); hecl::SanitizePath(path); - if (path.find('/') == kabufuda::SystemString::npos) { - path = hecl::GetcwdStr() + _SYS_STR("/") + _GetDolphinCardPath(slot); + if (path.find('/') == std::string::npos) { + path = hecl::GetcwdStr() + "/" + _GetDolphinCardPath(slot); } - hecl::SystemString tmpPath = path.substr(0, path.find_last_of(_SYS_STR("/"))); + std::string tmpPath = path.substr(0, path.find_last_of("/")); hecl::RecursiveMakeDir(tmpPath.c_str()); const auto fp = hecl::FopenUnique(path.c_str(), "wb"); if (fp) { diff --git a/Runtime/CMemoryCardSysOSX.cpp b/Runtime/CMemoryCardSysOSX.cpp index 7f8813c4d..2922308fe 100644 --- a/Runtime/CMemoryCardSysOSX.cpp +++ b/Runtime/CMemoryCardSysOSX.cpp @@ -3,13 +3,13 @@ #include "Runtime/IMain.hpp" namespace metaforce { -kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) { +std::string CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) { if (g_Main->IsUSA() && !g_Main->IsTrilogy()) { const char* home = getenv("HOME"); if (!home) return {}; - kabufuda::SystemString path = home; + std::string path = home; path += fmt::format(FMT_STRING("/Library/Application Support/Dolphin/GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); @@ -22,14 +22,14 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo return {}; } -kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin) { +std::string CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin) { if (g_Main->IsUSA() && !g_Main->IsTrilogy()) { if (dolphin) { const char* home = getenv("HOME"); if (!home) return {}; - kabufuda::SystemString path = home; + std::string path = home; path += "/Library/Application Support/Dolphin/GC"; if (hecl::RecursiveMakeDir(path.c_str()) < 0) return {}; @@ -42,12 +42,12 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl return path; } else { - kabufuda::SystemString path = _GetDolphinCardPath(slot); + std::string path = _GetDolphinCardPath(slot); hecl::SanitizePath(path); - if (path.find('/') == kabufuda::SystemString::npos) { - path = hecl::GetcwdStr() + _SYS_STR("/") + _GetDolphinCardPath(slot); + if (path.find('/') == std::string::npos) { + path = hecl::GetcwdStr() + "/" + _GetDolphinCardPath(slot); } - hecl::SystemString tmpPath = path.substr(0, path.find_last_of(_SYS_STR("/"))); + std::string tmpPath = path.substr(0, path.find_last_of("/")); hecl::RecursiveMakeDir(tmpPath.c_str()); const auto fp = hecl::FopenUnique(path.c_str(), "wb"); if (fp) { diff --git a/Runtime/CMemoryCardSysWin.cpp b/Runtime/CMemoryCardSysWin.cpp index 6152fb069..3fba93526 100644 --- a/Runtime/CMemoryCardSysWin.cpp +++ b/Runtime/CMemoryCardSysWin.cpp @@ -14,7 +14,7 @@ using namespace Windows::Storage; /* Partial path-selection logic from * https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/UICommon/UICommon.cpp * Modified to not use dolphin-binary-relative paths. */ -kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) { +std::string CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) { if (g_Main->IsUSA() && !g_Main->IsTrilogy()) { #if !WINDOWS_STORE /* Detect where the User directory is. There are two different cases @@ -26,35 +26,32 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo /* Check our registry keys */ HKEY hkey; - kabufuda::SystemChar configPath[MAX_PATH] = {0}; - if (RegOpenKeyEx(HKEY_CURRENT_USER, _SYS_STR("Software\\Dolphin Emulator"), 0, KEY_QUERY_VALUE, &hkey) == - ERROR_SUCCESS) { + wchar_t configPath[MAX_PATH] = {0}; + if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Dolphin Emulator", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) { DWORD size = MAX_PATH; - if (RegQueryValueEx(hkey, _SYS_STR("UserConfigPath"), nullptr, nullptr, (LPBYTE)configPath, &size) != - ERROR_SUCCESS) + if (RegQueryValueEx(hkey, L"UserConfigPath", nullptr, nullptr, (LPBYTE)configPath, &size) != ERROR_SUCCESS) configPath[0] = 0; RegCloseKey(hkey); } /* Get My Documents path in case we need it. */ - kabufuda::SystemChar my_documents[MAX_PATH]; + wchar_t my_documents[MAX_PATH]; bool my_documents_found = SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents)); - kabufuda::SystemString path; + std::string path; if (configPath[0]) /* Case 1 */ - path = configPath; + path = nowide::narrow(configPath); else if (my_documents_found) /* Case 2 */ - path = kabufuda::SystemString(my_documents) + _SYS_STR("/Dolphin Emulator"); + path = nowide::narrow(my_documents) + "/Dolphin Emulator"; else /* Unable to find */ return {}; #else StorageFolder ^ localFolder = ApplicationData::Current->LocalFolder; - kabufuda::SystemString path(localFolder->Path->Data()); + std::string path(localFolder->Path->Data()); #endif - path += fmt::format(FMT_STRING(_SYS_STR("/GC/MemoryCard{}.USA.raw")), - slot == kabufuda::ECardSlot::SlotA ? _SYS_STR('A') : _SYS_STR('B')); + path += fmt::format(FMT_STRING("/GC/MemoryCard{}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); hecl::Sstat theStat; if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode)) @@ -65,7 +62,7 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo return {}; } -kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin) { +std::string CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin) { if (g_Main->IsUSA() && !g_Main->IsTrilogy()) { if (dolphin) { #if !WINDOWS_STORE @@ -78,54 +75,51 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl /* Check our registry keys */ HKEY hkey; - kabufuda::SystemChar configPath[MAX_PATH] = {0}; - if (RegOpenKeyEx(HKEY_CURRENT_USER, _SYS_STR("Software\\Dolphin Emulator"), 0, KEY_QUERY_VALUE, &hkey) == - ERROR_SUCCESS) { + wchar_t configPath[MAX_PATH] = {0}; + if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Dolphin Emulator", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) { DWORD size = MAX_PATH; - if (RegQueryValueEx(hkey, _SYS_STR("UserConfigPath"), nullptr, nullptr, (LPBYTE)configPath, &size) != - ERROR_SUCCESS) + if (RegQueryValueEx(hkey, L"UserConfigPath", nullptr, nullptr, (LPBYTE)configPath, &size) != ERROR_SUCCESS) configPath[0] = 0; RegCloseKey(hkey); } /* Get My Documents path in case we need it. */ - kabufuda::SystemChar my_documents[MAX_PATH]; + wchar_t my_documents[MAX_PATH]; bool my_documents_found = SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents)); - kabufuda::SystemString path; + std::string path; if (configPath[0]) /* Case 1 */ - path = configPath; + path = nowide::narrow(configPath); else if (my_documents_found) /* Case 2 */ - path = kabufuda::SystemString(my_documents) + _SYS_STR("/Dolphin Emulator"); + path = nowide::narrow(my_documents) + "/Dolphin Emulator"; else /* Unable to find */ return {}; #else StorageFolder ^ localFolder = ApplicationData::Current->LocalFolder; - kabufuda::SystemString path(localFolder->Path->Data()); + std::string path(localFolder->Path->Data()); #endif - path += _SYS_STR("/GC"); + path += "/GC"; if (hecl::RecursiveMakeDir(path.c_str()) < 0) return {}; - path += fmt::format(FMT_STRING(_SYS_STR("/MemoryCard{}.USA.raw")), - slot == kabufuda::ECardSlot::SlotA ? _SYS_STR('A') : _SYS_STR('B')); - const auto fp = hecl::FopenUnique(path.c_str(), _SYS_STR("wb")); + path += fmt::format(FMT_STRING("/MemoryCard{}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); + const auto fp = hecl::FopenUnique(path.c_str(), "wb"); if (fp == nullptr) { return {}; } return path; } else { - kabufuda::SystemString path = _GetDolphinCardPath(slot); + std::string path = _GetDolphinCardPath(slot); hecl::SanitizePath(path); - if (path.find('/') == kabufuda::SystemString::npos) { - path = hecl::GetcwdStr() + _SYS_STR("/") + _GetDolphinCardPath(slot); + if (path.find('/') == std::string::npos) { + path = hecl::GetcwdStr() + "/" + _GetDolphinCardPath(slot); } - hecl::SystemString tmpPath = path.substr(0, path.find_last_of(_SYS_STR("/"))); + std::string tmpPath = path.substr(0, path.find_last_of("/")); hecl::RecursiveMakeDir(tmpPath.c_str()); - const auto fp = hecl::FopenUnique(path.c_str(), _SYS_STR("wb")); + const auto fp = hecl::FopenUnique(path.c_str(), "wb"); if (fp) { return path; } diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index 36ed24dfa..592a5577a 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -466,7 +466,7 @@ boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDat boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr; boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr; boo::ObjToken CGraphics::g_SpareTexture; -const boo::SystemChar* CGraphics::g_BooPlatformName = nullptr; +const char* CGraphics::g_BooPlatformName = nullptr; const CTevCombiners::CTevPass CGraphics::sTevPass805a564c({GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC}, diff --git a/Runtime/Graphics/CGraphics.hpp b/Runtime/Graphics/CGraphics.hpp index 6f018da9d..2329d8f2d 100644 --- a/Runtime/Graphics/CGraphics.hpp +++ b/Runtime/Graphics/CGraphics.hpp @@ -322,7 +322,7 @@ public: static void UpdateFPSCounter(); static boo::IGraphicsDataFactory::Platform g_BooPlatform; - static const boo::SystemChar* g_BooPlatformName; + static const char* g_BooPlatformName; static boo::IGraphicsDataFactory* g_BooFactory; static boo::IGraphicsCommandQueue* g_BooMainCommandQueue; static boo::ObjToken g_SpareTexture; @@ -344,7 +344,7 @@ public: g_SpareTexture.reset(); } - static const boo::SystemChar* PlatformName() { return g_BooPlatformName; } + static const char* PlatformName() { return g_BooPlatformName; } static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs) { g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse); diff --git a/Runtime/Graphics/CLineRenderer.cpp b/Runtime/Graphics/CLineRenderer.cpp index eafe3a7cc..036ce7b63 100644 --- a/Runtime/Graphics/CLineRenderer.cpp +++ b/Runtime/Graphics/CLineRenderer.cpp @@ -25,7 +25,7 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, EPrimitive : m_mode(mode), m_maxVerts(maxVerts) { OPTICK_EVENT(); if (maxVerts < 2) { - LineRendererLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("maxVerts < 2, maxVerts = {}")), maxVerts); + LineRendererLog.report(logvisor::Fatal, FMT_STRING("maxVerts < 2, maxVerts = {}"), maxVerts); return; } m_textured = bool(texture); @@ -57,7 +57,7 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjTo : m_mode(mode), m_maxVerts(maxVerts) { OPTICK_EVENT(); if (maxVerts < 2) { - LineRendererLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("maxVerts < 2, maxVerts = {}")), maxVerts); + LineRendererLog.report(logvisor::Fatal, FMT_STRING("maxVerts < 2, maxVerts = {}"), maxVerts); return; } m_textured = bool(texture); diff --git a/Runtime/GuiSys/CErrorOutputWindow.hpp b/Runtime/GuiSys/CErrorOutputWindow.hpp index dd85bd38a..1c14ffc77 100644 --- a/Runtime/GuiSys/CErrorOutputWindow.hpp +++ b/Runtime/GuiSys/CErrorOutputWindow.hpp @@ -16,7 +16,7 @@ private: bool x18_26_; bool x18_27_; bool x18_28_; - const wchar_t* x1c_msg; + const char16_t* x1c_msg; public: explicit CErrorOutputWindow(bool); diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index a34ceea0f..e72cc7a93 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -1,5 +1,7 @@ #include "Runtime/GuiSys/CGuiTextSupport.hpp" +#include + #include "Runtime/CSimplePool.hpp" #include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphicsPalette.hpp" diff --git a/Runtime/GuiSys/CTextParser.cpp b/Runtime/GuiSys/CTextParser.cpp index cfe8527e0..39d0e034b 100644 --- a/Runtime/GuiSys/CTextParser.cpp +++ b/Runtime/GuiSys/CTextParser.cpp @@ -52,7 +52,7 @@ s32 CTextParser::ParseInt(const char16_t* str, int len, bool signVal) { int val = 0; while (len > procCur) { val *= 10; - wchar_t ch = str[procCur]; + char16_t ch = str[procCur]; val += ch - u'0'; ++procCur; } diff --git a/Runtime/GuiSys/CTextRenderBuffer.hpp b/Runtime/GuiSys/CTextRenderBuffer.hpp index c5cbdd43f..c73290dab 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.hpp +++ b/Runtime/GuiSys/CTextRenderBuffer.hpp @@ -40,7 +40,7 @@ public: Command x4_command; u16 x8_xPos; u16 xa_zPos; - wchar_t xc_glyph; + char16_t xc_glyph; u8 xe_imageIndex; }; #endif diff --git a/Runtime/GuiSys/CWordBreakTables.cpp b/Runtime/GuiSys/CWordBreakTables.cpp index 69a94610a..79c615a14 100644 --- a/Runtime/GuiSys/CWordBreakTables.cpp +++ b/Runtime/GuiSys/CWordBreakTables.cpp @@ -8,13 +8,13 @@ namespace metaforce { namespace { struct CCharacterIdentifier { - wchar_t chr; + char16_t chr; u32 rank; }; constexpr std::array sCantBeginChars{{ - {L'!', 1}, {L')', 1}, {L',', 1}, {L'-', 1}, {L'.', 1}, {L':', 1}, {L';', 1}, {L'?', 1}, {L']', 1}, - {L'}', 1}, {0x92, 1}, {0x94, 1}, {0xBB, 1}, {0x3001, 1}, {0x3002, 1}, {0x3005, 1}, {0x300D, 1}, {0x300F, 1}, + {u'!', 1}, {u')', 1}, {u',', 1}, {u'-', 1}, {u'.', 1}, {u':', 1}, {u';', 1}, {u'?', 1}, {u']', 1}, + {u'}', 1}, {0x92, 1}, {0x94, 1}, {0xBB, 1}, {0x3001, 1}, {0x3002, 1}, {0x3005, 1}, {0x300D, 1}, {0x300F, 1}, {0x3011, 1}, {0x3015, 1}, {0x3017, 1}, {0x3019, 1}, {0x301B, 1}, {0x301C, 3}, {0x301E, 1}, {0x302B, 3}, {0x3041, 2}, {0x3043, 2}, {0x3045, 2}, {0x3047, 2}, {0x3049, 2}, {0x3063, 2}, {0x3083, 2}, {0x3085, 2}, {0x3087, 2}, {0x308E, 2}, {0x309D, 3}, {0x309E, 3}, {0x30A1, 2}, {0x30A3, 2}, {0x30A5, 2}, {0x30A7, 2}, {0x30A9, 2}, {0x30C3, 2}, {0x30E3, 2}, @@ -23,12 +23,12 @@ constexpr std::array sCantBeginChars{{ }}; constexpr std::array sCantEndChars{{ - {L'#', 2}, {L'$', 2}, {L'(', 1}, {L'@', 2}, {L'B', 4}, {L'C', 4}, {L'D', 4}, {L'E', 4}, {L'F', 4}, - {L'G', 4}, {L'J', 4}, {L'K', 4}, {L'L', 4}, {L'M', 4}, {L'N', 4}, {L'P', 4}, {L'Q', 4}, {L'R', 4}, - {L'S', 4}, {L'T', 4}, {L'V', 4}, {L'W', 4}, {L'X', 4}, {L'Y', 4}, {L'Z', 4}, {L'b', 4}, {L'c', 4}, - {L'd', 4}, {L'f', 4}, {L'g', 4}, {L'h', 4}, {L'j', 4}, {L'k', 4}, {L'l', 4}, {L'm', 4}, {L'n', 4}, - {L'p', 4}, {L'q', 4}, {L'r', 4}, {L's', 4}, {L't', 4}, {L'v', 4}, {L'w', 4}, {L'x', 4}, {L'y', 4}, - {L'z', 4}, {0xD1, 4}, {0xF1, 4}, {L'[', 1}, {L'{', 1}, {0x91, 1}, {0x93, 1}, {0xA2, 2}, {0xA3, 2}, + {u'#', 2}, {u'$', 2}, {u'(', 1}, {u'@', 2}, {u'B', 4}, {u'C', 4}, {u'D', 4}, {u'E', 4}, {u'F', 4}, + {u'G', 4}, {u'J', 4}, {u'K', 4}, {u'L', 4}, {u'M', 4}, {u'N', 4}, {u'P', 4}, {u'Q', 4}, {u'R', 4}, + {u'S', 4}, {u'T', 4}, {u'V', 4}, {u'W', 4}, {u'X', 4}, {u'Y', 4}, {u'Z', 4}, {u'b', 4}, {u'c', 4}, + {u'd', 4}, {u'f', 4}, {u'g', 4}, {u'h', 4}, {u'j', 4}, {u'k', 4}, {u'l', 4}, {u'm', 4}, {u'n', 4}, + {u'p', 4}, {u'q', 4}, {u'r', 4}, {u's', 4}, {u't', 4}, {u'v', 4}, {u'w', 4}, {u'x', 4}, {u'y', 4}, + {u'z', 4}, {0xD1, 4}, {0xF1, 4}, {u'[', 1}, {u'{', 1}, {0x91, 1}, {0x93, 1}, {0xA2, 2}, {0xA3, 2}, {0xA5, 2}, {0xA7, 2}, {0xA9, 2}, {0xAB, 1}, {0x20A0, 2}, {0x20A1, 2}, {0x20A2, 2}, {0x20A3, 2}, {0x20A4, 2}, {0x20A5, 2}, {0x20A6, 2}, {0x20A7, 2}, {0x20A8, 2}, {0x20A9, 2}, {0x20AA, 2}, {0x20AB, 2}, {0x20AC, 2}, {0x300C, 1}, {0x300E, 1}, {0x3010, 1}, {0x3012, 2}, {0x3014, 1}, {0x3016, 1}, {0x3018, 1}, {0x301A, 1}, {0xFF03, 2}, {0xFF04, 2}, @@ -36,7 +36,7 @@ constexpr std::array sCantEndChars{{ }}; } // Anonymous namespace -int CWordBreakTables::GetBeginRank(wchar_t ch) { +int CWordBreakTables::GetBeginRank(char16_t ch) { const auto search = rstl::binary_find(sCantBeginChars.cbegin(), sCantBeginChars.cend(), ch, [](const CCharacterIdentifier& item) { return item.chr; }); if (search == sCantBeginChars.cend()) { @@ -45,7 +45,7 @@ int CWordBreakTables::GetBeginRank(wchar_t ch) { return search->rank; } -int CWordBreakTables::GetEndRank(wchar_t ch) { +int CWordBreakTables::GetEndRank(char16_t ch) { const auto search = rstl::binary_find(sCantEndChars.cbegin(), sCantEndChars.cend(), ch, [](const CCharacterIdentifier& item) { return item.chr; }); if (search == sCantEndChars.cend()) { diff --git a/Runtime/GuiSys/CWordBreakTables.hpp b/Runtime/GuiSys/CWordBreakTables.hpp index 274f58911..0957eefe2 100644 --- a/Runtime/GuiSys/CWordBreakTables.hpp +++ b/Runtime/GuiSys/CWordBreakTables.hpp @@ -4,8 +4,8 @@ namespace metaforce { class CWordBreakTables { public: - static int GetBeginRank(wchar_t ch); - static int GetEndRank(wchar_t ch); + static int GetBeginRank(char16_t ch); + static int GetEndRank(char16_t ch); }; } // namespace metaforce diff --git a/Runtime/Input/CKeyboardMouseController.hpp b/Runtime/Input/CKeyboardMouseController.hpp index 67e053694..611e99a53 100644 --- a/Runtime/Input/CKeyboardMouseController.hpp +++ b/Runtime/Input/CKeyboardMouseController.hpp @@ -7,7 +7,7 @@ namespace metaforce { struct CKeyboardMouseControllerData { std::array m_charKeys{}; - std::array m_specialKeys{}; + std::array(boo::ESpecialKey::MAX)> m_specialKeys{}; std::array m_mouseButtons{}; boo::EModifierKey m_modMask = boo::EModifierKey::None; boo::SWindowCoord m_mouseCoord; diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index a78598f65..24cea6b06 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "NESEmulator/CNESEmulator.hpp" diff --git a/Runtime/MP1/CPauseScreenBase.cpp b/Runtime/MP1/CPauseScreenBase.cpp index e95565320..0115c5c6d 100644 --- a/Runtime/MP1/CPauseScreenBase.cpp +++ b/Runtime/MP1/CPauseScreenBase.cpp @@ -1,6 +1,7 @@ #include "Runtime/MP1/CPauseScreenBase.hpp" #include +#include #include "Runtime/CGameState.hpp" #include "Runtime/GameGlobalObjects.hpp" diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 8351c1563..5a3734dba 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -799,22 +799,19 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana MainLog.report(logvisor::Level::Fatal, FMT_STRING("Attempted to initialize URDE in MP1 mode with non-MP1 data!!!!")); } - hecl::SystemStringConv conv(GetVersionString()); - boo::SystemStringView versionView(conv.sys_str()); - MainLog.report(logvisor::Level::Info, - FMT_STRING(_SYS_STR("Loading data from Metroid Prime version {} from region {}{}")), versionView, - boo::SystemChar(GetRegion()), IsTrilogy() ? _SYS_STR(" from trilogy") : _SYS_STR("")); + MainLog.report(logvisor::Level::Info, FMT_STRING("Loading data from Metroid Prime version {} from region {}{}"), + GetVersionString(), GetRegion(), IsTrilogy() ? " from trilogy" : ""); } else { MainLog.report(logvisor::Level::Fatal, FMT_STRING("Unable to load version info")); } const auto& args = boo::APP->getArgs(); for (auto it = args.begin(); it != args.end(); ++it) { - if (*it == _SYS_STR("--warp") && args.end() - it >= 3) { - const hecl::SystemChar* worldIdxStr = (*(it + 1)).c_str(); - const hecl::SystemChar* areaIdxStr = (*(it + 2)).c_str(); + if (*it == "--warp" && args.end() - it >= 3) { + const char* worldIdxStr = (*(it + 1)).c_str(); + const char* areaIdxStr = (*(it + 2)).c_str(); - hecl::SystemChar* endptr = nullptr; + char* endptr = nullptr; m_warpWorldIdx = TAreaId(hecl::StrToUl(worldIdxStr, &endptr, 0)); if (endptr == worldIdxStr) { m_warpWorldIdx = 0; @@ -838,13 +835,13 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarMana } while (args.end() - it >= 4) { - const hecl::SystemChar* layerStr = (*(it + 3)).c_str(); - if (!(layerStr[0] == _SYS_STR('0') && layerStr[1] == _SYS_STR('x')) && - (layerStr[0] == _SYS_STR('0') || layerStr[0] == _SYS_STR('1'))) { - for (const auto* cur = layerStr; *cur != _SYS_STR('\0'); ++cur) - if (*cur == _SYS_STR('1')) + const char* layerStr = (*(it + 3)).c_str(); + if (!(layerStr[0] == '0' && layerStr[1] == 'x') && + (layerStr[0] == '0' || layerStr[0] == '1')) { + for (const auto* cur = layerStr; *cur != '\0'; ++cur) + if (*cur == '1') m_warpLayerBits |= u64(1) << (cur - layerStr); - } else if (layerStr[0] == _SYS_STR('0') && layerStr[1] == _SYS_STR('x')) { + } else if (layerStr[0] == '0' && layerStr[1] == 'x') { m_warpMemoryRelays.emplace_back(TAreaId(hecl::StrToUl(layerStr + 2, nullptr, 16))); } ++it; @@ -1014,7 +1011,7 @@ void CMain::Shutdown() { boo::IWindow* CMain::GetMainWindow() const { return m_mainWindow; } #if 0 -int CMain::RsMain(int argc, boo::SystemChar** argv, boo::IAudioVoiceEngine* voiceEngine, +int CMain::RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) { // PPCSetFpIEEEMode(); // uVar21 = OSGetTime(); @@ -1048,7 +1045,7 @@ int CMain::RsMain(int argc, boo::SystemChar** argv, boo::IAudioVoiceEngine* voic int CMain::appMain(boo::IApplication* app) { zeus::detectCPU(); - mainWindow = app->newWindow(_SYS_STR("Metroid Prime 1 Reimplementation vZygote"), 1); + mainWindow = app->newWindow("Metroid Prime 1 Reimplementation vZygote", 1); mainWindow->showWindow(); TOneStatic globalObjs; InitializeSubsystems(); diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index f055d3b56..4af468c75 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -280,7 +280,7 @@ public: static void UpdateDiscordPresence(CAssetId worldSTRG = {}); - // int RsMain(int argc, boo::SystemChar** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& + // int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& // backend); void Init(const hecl::Runtime::FileStoreManager& storeMgr, hecl::CVarManager* cvarManager, boo::IWindow* window, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) override; diff --git a/Runtime/platforms/freedesktop/CMakeLists.txt b/Runtime/platforms/freedesktop/CMakeLists.txt index 6e21e9066..d458df5a1 100644 --- a/Runtime/platforms/freedesktop/CMakeLists.txt +++ b/Runtime/platforms/freedesktop/CMakeLists.txt @@ -1,6 +1,5 @@ add_executable(mkwmicon mkwmicon.c) target_link_libraries(mkwmicon ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) -target_include_directories(mkwmicon PRIVATE ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) macro(declare_wmicon_target) add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/Runtime/platforms/freedesktop/mainicon_netwm.bin diff --git a/assetnameparser/main.cpp b/assetnameparser/main.cpp index 3b178cf9c..3d9bd5f06 100644 --- a/assetnameparser/main.cpp +++ b/assetnameparser/main.cpp @@ -25,12 +25,9 @@ #define NOMINMAX #endif #include -#include +#include #define strncasecmp _strnicmp #define strcasecmp _stricmp -#if UNICODE -#define IS_UCS2 1 -#endif #endif namespace { @@ -182,20 +179,10 @@ struct SAsset { enum class FileLockType { None = 0, Read, Write }; -#if IS_UCS2 -using SystemChar = wchar_t; -using SystemString = std::wstring; -#ifndef _SYS_STR -#define _SYS_STR(val) L##val -#endif -using Sstat = struct _stat; +#if _WIN32 +using Sstat = struct ::_stat64; #else -using SystemChar = char; -using SystemString = std::string; -#ifndef _SYS_STR -#define _SYS_STR(val) val -#endif -using Sstat = struct stat; +using SStat = struct stat; #endif struct FILEDeleter { @@ -203,9 +190,11 @@ struct FILEDeleter { }; using FILEPtr = std::unique_ptr; -FILEPtr Fopen(const SystemChar* path, const SystemChar* mode, FileLockType lock = FileLockType::None) { -#if IS_UCS2 - FILEPtr fp{_wfopen(path, mode)}; +FILEPtr Fopen(const char* path, const char* mode, FileLockType lock = FileLockType::None) { +#if _WIN32 + const nowide::wstackstring wpath(path); + const nowide::wshort_stackstring wmode(mode); + FILEPtr fp{_wfopen(wpath.get(), wmode.get())}; if (!fp) { return nullptr; } @@ -269,35 +258,34 @@ std::string getValidExtension(const std::string& type) { return type; } +int main(int argc, char* argv[]) { #if _WIN32 -int wmain(int argc, const wchar_t* argv[]) -#else -int main(int argc, const char* argv[]) + nowide::args _(argc, argv); #endif -{ + logvisor::RegisterStandardExceptions(); logvisor::RegisterConsoleLogger(); if (argc < 3) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Usage: {} ")), argv[0]); + Log.report(logvisor::Error, FMT_STRING("Usage: {} "), argv[0]); return 1; } - SystemString inPath = argv[1]; - SystemString outPath = argv[2]; + std::string inPath = argv[1]; + std::string outPath = argv[2]; tinyxml2::XMLDocument doc; std::vector assets; - FILEPtr docF = Fopen(inPath.c_str(), _SYS_STR("rb")); + FILEPtr docF = Fopen(inPath.c_str(), "rb"); if (doc.LoadFile(docF.get()) == tinyxml2::XML_SUCCESS) { const tinyxml2::XMLElement* elm = doc.RootElement(); if (strcmp(elm->Name(), "AssetNameMap") != 0) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Invalid database supplied"))); + Log.report(logvisor::Fatal, FMT_STRING("Invalid database supplied")); return 1; } elm = elm->FirstChildElement("AssetNameMap"); if (elm == nullptr) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Malformed AssetName database"))); + Log.report(logvisor::Fatal, FMT_STRING("Malformed AssetName database")); return 1; } @@ -308,7 +296,7 @@ int main(int argc, const char* argv[]) const tinyxml2::XMLElement* valueElm = elm->FirstChildElement("Value"); if (keyElm == nullptr || valueElm == nullptr) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Malformed Asset entry, [Key,Value] required"))); + Log.report(logvisor::Fatal, FMT_STRING("Malformed Asset entry, [Key,Value] required")); return 0; } @@ -319,7 +307,7 @@ int main(int argc, const char* argv[]) const tinyxml2::XMLElement* autoGenDirElm = valueElm->FirstChildElement("AutoGenDir"); if (nameElm == nullptr || dirElm == nullptr || typeElm == nullptr) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Malformed Value entry, [Name,Directory,Type] required"))); + Log.report(logvisor::Fatal, FMT_STRING("Malformed Value entry, [Name,Directory,Type] required")); return 0; } bool autoGen = strncasecmp(autoGenNameElm->GetText(), "true", 4) == 0 && strncasecmp(autoGenDirElm->GetText(), "true", 4) == 0; @@ -340,9 +328,9 @@ int main(int argc, const char* argv[]) elm = elm->NextSiblingElement("Asset"); } - FILEPtr f = Fopen(outPath.c_str(), _SYS_STR("wb")); + FILEPtr f = Fopen(outPath.c_str(), "wb"); if (f == nullptr) { - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to open destination"))); + Log.report(logvisor::Fatal, FMT_STRING("Unable to open destination")); return 0; } @@ -365,6 +353,6 @@ int main(int argc, const char* argv[]) return 0; } - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("failed to load"))); + Log.report(logvisor::Fatal, FMT_STRING("failed to load")); return 1; } diff --git a/extern/amuse b/extern/amuse index 6e896fa1d..603e066ee 160000 --- a/extern/amuse +++ b/extern/amuse @@ -1 +1 @@ -Subproject commit 6e896fa1d399927ba0558e6af3e084ea79ec6b88 +Subproject commit 603e066eed46388506e0a1f63925030e56070626 diff --git a/extern/athena b/extern/athena index 2aa5b7673..2aa9a573a 160000 --- a/extern/athena +++ b/extern/athena @@ -1 +1 @@ -Subproject commit 2aa5b76732e27e33441f292ab39fbaf4d3b0a4d0 +Subproject commit 2aa9a573a0dbe6ff694e3bf8f3e20c96a56ba087 diff --git a/extern/boo b/extern/boo index 542191fd7..1eb2a46a4 160000 --- a/extern/boo +++ b/extern/boo @@ -1 +1 @@ -Subproject commit 542191fd70e8835576f2d1320859291518972e8a +Subproject commit 1eb2a46a4194fc50ded0e97ac5027a9e4f7b9382 diff --git a/extern/kabufuda b/extern/kabufuda index 1111fb483..4cf61b7d5 160000 --- a/extern/kabufuda +++ b/extern/kabufuda @@ -1 +1 @@ -Subproject commit 1111fb48397534f86c61db3b681cbcfef583f019 +Subproject commit 4cf61b7d5edd2f4ccab5ada1f7c987307f1cf1d9 diff --git a/extern/libpng/CMakeLists.txt b/extern/libpng/CMakeLists.txt index 82ae188e5..f3857c437 100644 --- a/extern/libpng/CMakeLists.txt +++ b/extern/libpng/CMakeLists.txt @@ -55,7 +55,6 @@ if (WIN32 OR NX OR NOT PNG_LIBRARIES) target_compile_options(png PRIVATE -Wno-implicit-fallthrough) endif () target_link_libraries(png PUBLIC ${ZLIB_LIBRARIES}) - target_include_directories(png PUBLIC ${ZLIB_INCLUDE_DIR}) set(PNG_LIBRARIES png CACHE PATH "PNG libraries" FORCE) set(PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "PNG include path" FORCE) endif () diff --git a/extern/nod b/extern/nod index a525f6077..c1635245b 160000 --- a/extern/nod +++ b/extern/nod @@ -1 +1 @@ -Subproject commit a525f607752b87d719c142ef88589e1e5bbfa9b5 +Subproject commit c1635245b881ed0004ff5e616896579ce1b19164 diff --git a/hecl/bintoc/CMakeLists.txt b/hecl/bintoc/CMakeLists.txt index c2d5d3f3d..003393286 100644 --- a/hecl/bintoc/CMakeLists.txt +++ b/hecl/bintoc/CMakeLists.txt @@ -5,6 +5,5 @@ project(bintoc LANGUAGES C) add_executable(bintoc bintoc.c) add_subdirectory(../../extern/athena/extern/zlib zlib EXCLUDE_FROM_ALL) target_link_libraries(bintoc PRIVATE ${ZLIB_LIBRARIES}) -target_include_directories(bintoc PRIVATE ${ZLIB_INCLUDE_DIR}) install(TARGETS bintoc DESTINATION bin) diff --git a/hecl/driver/ToolBase.hpp b/hecl/driver/ToolBase.hpp index dc028ee0a..d5a5b438f 100644 --- a/hecl/driver/ToolBase.hpp +++ b/hecl/driver/ToolBase.hpp @@ -19,11 +19,11 @@ extern logvisor::Module LogModule; struct ToolPassInfo { - hecl::SystemString pname; - hecl::SystemString cwd; - std::vector args; - std::vector flags; - hecl::SystemString output; + std::string pname; + std::string cwd; + std::vector args; + std::vector flags; + std::string output; hecl::Database::Project* project = nullptr; unsigned verbosityLevel = 0; bool force = false; @@ -55,9 +55,9 @@ protected: bool continuePrompt() { if (!m_info.yes) { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) "))); + fmt::print(FMT_STRING("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) ")); else - fmt::print(FMT_STRING(_SYS_STR("\nContinue? (Y/n) "))); + fmt::print(FMT_STRING("\nContinue? (Y/n) ")); fflush(stdout); int ch; @@ -73,7 +73,7 @@ protected: #endif { if (ch == 'n' || ch == 'N') { - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); return false; } if (ch == 'y' || ch == 'Y' || ch == '\r' || ch == '\n') @@ -83,7 +83,7 @@ protected: tcsetattr(0, TCSANOW, &tioOld); #endif } - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); return true; } @@ -93,7 +93,7 @@ public: hecl::GuiMode = info.gui; } virtual ~ToolBase() = default; - virtual hecl::SystemStringView toolName() const = 0; + virtual std::string_view toolName() const = 0; virtual int run() = 0; virtual void cancel() {} explicit operator bool() const { return m_good; } @@ -107,11 +107,11 @@ private: FILE* m_sout = nullptr; HelpFunc m_helpFunc; int m_lineWidth; - hecl::SystemString m_wrapBuffer; + std::string m_wrapBuffer; - void _wrapBuf(hecl::SystemString& string) { + void _wrapBuf(std::string& string) { int counter; - hecl::SystemString::iterator it = string.begin(); + std::string::iterator it = string.begin(); while (it != string.end()) { std::ptrdiff_t v = it - string.begin(); @@ -120,33 +120,33 @@ private: for (counter = WRAP_INDENT; counter < m_lineWidth; ++counter) { if (it >= string.end()) return; - if (*it == _SYS_STR('\n')) { + if (*it == '\n') { counter = WRAP_INDENT; ++it; } if (counter == WRAP_INDENT) { for (int i = 0; i < WRAP_INDENT; ++i) - it = string.insert(it, _SYS_STR(' ')) + 1; + it = string.insert(it, ' ') + 1; } if (it >= string.end()) return; - if (*it != _SYS_STR('\n')) + if (*it != '\n') ++it; } /* check for whitespace */ if (isspace(*it)) { - *it = _SYS_STR('\n'); + *it = '\n'; counter = WRAP_INDENT; ++it; } else { /* check for nearest whitespace back in string */ - for (hecl::SystemString::iterator k = it; k != string.begin(); --k) { + for (std::string::iterator k = it; k != string.begin(); --k) { if (isspace(*k)) { counter = WRAP_INDENT; if (k - string.begin() < v) - k = string.insert(it, _SYS_STR('\n')); + k = string.insert(it, '\n'); else - *k = _SYS_STR('\n'); + *k = '\n'; it = k + 1; break; } @@ -175,61 +175,61 @@ public: #endif } - void print(const hecl::SystemChar* str) { fmt::print(m_sout, FMT_STRING(_SYS_STR("{}")), str); } + void print(const char* str) { fmt::print(m_sout, FMT_STRING("{}"), str); } - void printBold(const hecl::SystemChar* str) { + void printBold(const char* str) { if (XTERM_COLOR) - fmt::print(m_sout, FMT_STRING(_SYS_STR("" BOLD "{}" NORMAL "")), str); + fmt::print(m_sout, FMT_STRING("" BOLD "{}" NORMAL ""), str); else - fmt::print(m_sout, FMT_STRING(_SYS_STR("{}")), str); + fmt::print(m_sout, FMT_STRING("{}"), str); } - void secHead(const hecl::SystemChar* headName) { + void secHead(const char* headName) { if (XTERM_COLOR) - fmt::print(m_sout, FMT_STRING(_SYS_STR("" BOLD "{}" NORMAL "\n")), headName); + fmt::print(m_sout, FMT_STRING("" BOLD "{}" NORMAL "\n"), headName); else - fmt::print(m_sout, FMT_STRING(_SYS_STR("{}\n")), headName); + fmt::print(m_sout, FMT_STRING("{}\n"), headName); } - void optionHead(const hecl::SystemChar* flag, const hecl::SystemChar* synopsis) { + void optionHead(const char* flag, const char* synopsis) { if (XTERM_COLOR) - fmt::print(m_sout, FMT_STRING(_SYS_STR("" BOLD "{}" NORMAL " ({})\n")), flag, synopsis); + fmt::print(m_sout, FMT_STRING("" BOLD "{}" NORMAL " ({})\n"), flag, synopsis); else - fmt::print(m_sout, FMT_STRING(_SYS_STR("{} ({})\n")), flag, synopsis); + fmt::print(m_sout, FMT_STRING("{} ({})\n"), flag, synopsis); } void beginWrap() { m_wrapBuffer.clear(); } - void wrap(const hecl::SystemChar* str) { m_wrapBuffer += str; } + void wrap(const char* str) { m_wrapBuffer += str; } - void wrapBold(const hecl::SystemChar* str) { + void wrapBold(const char* str) { if (XTERM_COLOR) - m_wrapBuffer += _SYS_STR("" BOLD ""); + m_wrapBuffer += "" BOLD ""; m_wrapBuffer += str; if (XTERM_COLOR) - m_wrapBuffer += _SYS_STR("" NORMAL ""); + m_wrapBuffer += "" NORMAL ""; } void endWrap() { _wrapBuf(m_wrapBuffer); - m_wrapBuffer += _SYS_STR('\n'); - fmt::print(m_sout, FMT_STRING(_SYS_STR("{}")), m_wrapBuffer); + m_wrapBuffer += '\n'; + fmt::print(m_sout, FMT_STRING("{}"), m_wrapBuffer); m_wrapBuffer.clear(); } }; -static hecl::SystemString MakePathArgAbsolute(const hecl::SystemString& arg, const hecl::SystemString& cwd) { +static std::string MakePathArgAbsolute(const std::string& arg, const std::string& cwd) { #if _WIN32 - if (arg.size() >= 2 && iswalpha(arg[0]) && arg[1] == _SYS_STR(':')) + if (arg.size() >= 2 && iswalpha(arg[0]) && arg[1] == ':') return arg; - if (arg[0] == _SYS_STR('\\') || arg[0] == _SYS_STR('/')) + if (arg[0] == '\\' || arg[0] == '/') return arg; - return cwd + _SYS_STR('\\') + arg; + return cwd + '\\' + arg; #else - if (arg[0] == _SYS_STR('/') || arg[0] == _SYS_STR('\\')) + if (arg[0] == '/' || arg[0] == '\\') return arg; - if (cwd.back() == _SYS_STR('/') || cwd.back() == _SYS_STR('\\')) + if (cwd.back() == '/' || cwd.back() == '\\') return cwd + arg; - return cwd + _SYS_STR('/') + arg; + return cwd + '/' + arg; #endif } diff --git a/hecl/driver/ToolCook.hpp b/hecl/driver/ToolCook.hpp index 3bedd07e8..94a216f76 100644 --- a/hecl/driver/ToolCook.hpp +++ b/hecl/driver/ToolCook.hpp @@ -15,22 +15,22 @@ class ToolCook final : public ToolBase { public: explicit ToolCook(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) { /* Check for recursive flag */ - for (hecl::SystemChar arg : info.flags) - if (arg == _SYS_STR('r')) + for (char arg : info.flags) + if (arg == 'r') m_recursive = true; /* Scan args */ if (info.args.size()) { /* See if project path is supplied via args and use that over the getcwd one */ m_selectedItems.reserve(info.args.size()); - for (const hecl::SystemString& arg : info.args) { + for (const std::string& arg : info.args) { if (arg.empty()) continue; - else if (arg == _SYS_STR("--fast")) { + else if (arg == "--fast") { m_fast = true; continue; - } else if (arg.size() >= 8 && !arg.compare(0, 7, _SYS_STR("--spec="))) { - hecl::SystemString specName(arg.begin() + 7, arg.end()); + } else if (arg.size() >= 8 && !arg.compare(0, 7, "--spec=")) { + std::string specName(arg.begin() + 7, arg.end()); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (!hecl::StrCaseCmp(spec->m_name.data(), specName.c_str())) { m_spec = spec; @@ -38,12 +38,12 @@ public: } } if (!m_spec) - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find data spec '{}'")), specName); + LogModule.report(logvisor::Fatal, FMT_STRING("unable to find data spec '{}'"), specName); continue; - } else if (arg.size() >= 2 && arg[0] == _SYS_STR('-') && arg[1] == _SYS_STR('-')) + } else if (arg.size() >= 2 && arg[0] == '-' && arg[1] == '-') continue; - hecl::SystemString subPath; + std::string subPath; hecl::ProjectRootPath root = hecl::SearchForProject(MakePathArgAbsolute(arg, info.cwd), subPath); if (root) { if (!m_fallbackProj) { @@ -51,8 +51,8 @@ public: m_useProj = m_fallbackProj.get(); } else if (m_fallbackProj->getProjectRootPath() != root) LogModule.report(logvisor::Fatal, - FMT_STRING(_SYS_STR("hecl cook can only process multiple items in the same project; ") - _SYS_STR("'{}' and '{}' are different projects")), + FMT_STRING("hecl cook can only process multiple items in the same project; " + "'{}' and '{}' are different projects"), m_fallbackProj->getProjectRootPath().getAbsolutePath(), root.getAbsolutePath()); m_selectedItems.emplace_back(*m_useProj, subPath); @@ -67,85 +67,91 @@ public: /* Default case: recursive at root */ if (m_selectedItems.empty()) { m_selectedItems.reserve(1); - m_selectedItems.push_back({hecl::ProjectPath(*m_useProj, _SYS_STR(""))}); + m_selectedItems.push_back({hecl::ProjectPath(*m_useProj, "")}); m_recursive = true; } } static void Help(HelpOutput& help) { - help.secHead(_SYS_STR("NAME")); + help.secHead("NAME"); help.beginWrap(); - help.wrap(_SYS_STR("hecl-cook - Cook objects within the project database\n")); + help.wrap("hecl-cook - Cook objects within the project database\n"); help.endWrap(); - help.secHead(_SYS_STR("SYNOPSIS")); + help.secHead("SYNOPSIS"); help.beginWrap(); - help.wrap(_SYS_STR("hecl cook [-rf] [--fast] [--spec=] [...]\n")); + help.wrap("hecl cook [-rf] [--fast] [--spec=] [...]\n"); help.endWrap(); - help.secHead(_SYS_STR("DESCRIPTION")); + help.secHead("DESCRIPTION"); help.beginWrap(); - help.wrap(_SYS_STR("This command initiates a cooking pass on the project database. Cooking ") - _SYS_STR("is analogous to compiling in software development. The resulting object buffers ") - _SYS_STR("are cached within the project database. HECL performs the following ") - _SYS_STR("tasks for each object during the cook process:\n\n")); - help.wrapBold(_SYS_STR("- Object Gather: ")); - help.wrap(_SYS_STR("Files added with ")); - help.wrapBold(_SYS_STR("hecl add")); - help.wrap(_SYS_STR(" are queried for their dependent files (e.g. ")); - help.wrapBold(_SYS_STR(".blend")); - help.wrap(_SYS_STR(" files return any linked ")); - help.wrapBold(_SYS_STR(".png")); - help.wrap(_SYS_STR(" images). If the dependent files are unable to be found, the cook process aborts.\n\n")); - help.wrapBold(_SYS_STR("- Modtime Comparison: ")); - help.wrap(_SYS_STR("Files that have previously finished a cook pass are inspected for their time of ") - _SYS_STR("last modification. If the file hasn't changed since its previous cook-pass, the ") _SYS_STR( - "process is skipped. If the file has been moved or deleted, the object is automatically ") - _SYS_STR("removed from the project database.\n\n")); - help.wrapBold(_SYS_STR("- Cook: ")); - help.wrap(_SYS_STR("A type-specific procedure compiles the file's contents into an efficient format ") - _SYS_STR("for use by the runtime. A data-buffer is provided to HECL.\n\n")); - help.wrapBold(_SYS_STR("- Hash and Compress: ")); - help.wrap(_SYS_STR("The data-buffer is hashed and compressed before being cached in the object database.\n\n")); + help.wrap( + "This command initiates a cooking pass on the project database. Cooking " + "is analogous to compiling in software development. The resulting object buffers " + "are cached within the project database. HECL performs the following " + "tasks for each object during the cook process:\n\n"); + help.wrapBold("- Object Gather: "); + help.wrap("Files added with "); + help.wrapBold("hecl add"); + help.wrap(" are queried for their dependent files (e.g. "); + help.wrapBold(".blend"); + help.wrap(" files return any linked "); + help.wrapBold(".png"); + help.wrap(" images). If the dependent files are unable to be found, the cook process aborts.\n\n"); + help.wrapBold("- Modtime Comparison: "); + help.wrap( + "Files that have previously finished a cook pass are inspected for their time of " + "last modification. If the file hasn't changed since its previous cook-pass, the " + "process is skipped. If the file has been moved or deleted, the object is automatically " + "removed from the project database.\n\n"); + help.wrapBold("- Cook: "); + help.wrap( + "A type-specific procedure compiles the file's contents into an efficient format " + "for use by the runtime. A data-buffer is provided to HECL.\n\n"); + help.wrapBold("- Hash and Compress: "); + help.wrap("The data-buffer is hashed and compressed before being cached in the object database.\n\n"); help.endWrap(); - help.secHead(_SYS_STR("OPTIONS")); - help.optionHead(_SYS_STR("..."), _SYS_STR("input file(s)")); + help.secHead("OPTIONS"); + help.optionHead("...", "input file(s)"); help.beginWrap(); - help.wrap(_SYS_STR("Specifies working file(s) containing production data to be cooked by HECL. ") - _SYS_STR("Glob-strings may be specified (e.g. ")); - help.wrapBold(_SYS_STR("*.blend")); - help.wrap(_SYS_STR(") to automatically cook all matching current-directory files in the project database. ") - _SYS_STR("If no path specified, all files in the project database are cooked.\n")); + help.wrap( + "Specifies working file(s) containing production data to be cooked by HECL. " + "Glob-strings may be specified (e.g. "); + help.wrapBold("*.blend"); + help.wrap( + ") to automatically cook all matching current-directory files in the project database. " + "If no path specified, all files in the project database are cooked.\n"); help.endWrap(); - help.optionHead(_SYS_STR("-r"), _SYS_STR("recursion")); + help.optionHead("-r", "recursion"); help.beginWrap(); - help.wrap(_SYS_STR("Enables recursive file-matching for cooking entire directories of working files.\n")); + help.wrap("Enables recursive file-matching for cooking entire directories of working files.\n"); help.endWrap(); - help.optionHead(_SYS_STR("-f"), _SYS_STR("force")); + help.optionHead("-f", "force"); help.beginWrap(); - help.wrap(_SYS_STR("Forces cooking of all matched files, ignoring timestamp differences.\n")); + help.wrap("Forces cooking of all matched files, ignoring timestamp differences.\n"); help.endWrap(); - help.optionHead(_SYS_STR("--fast"), _SYS_STR("fast cook")); + help.optionHead("--fast", "fast cook"); help.beginWrap(); - help.wrap(_SYS_STR("Performs draft-optimization cooking for supported data types.\n")); + help.wrap("Performs draft-optimization cooking for supported data types.\n"); help.endWrap(); - help.optionHead(_SYS_STR("--spec="), _SYS_STR("data specification")); + help.optionHead("--spec=", "data specification"); help.beginWrap(); - help.wrap(_SYS_STR("Specifies a DataSpec to use when cooking. ") - _SYS_STR("This build of hecl supports the following values of :\n")); + help.wrap( + "Specifies a DataSpec to use when cooking. " + "This build of hecl supports the following values of :\n"); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (!spec->m_factory) continue; - help.wrap(_SYS_STR(" ")); + help.wrap(" "); help.wrapBold(spec->m_name.data()); - help.wrap(_SYS_STR("\n")); + help.wrap("\n"); } } - hecl::SystemStringView toolName() const override { return _SYS_STR("cook"sv); } + std::string_view toolName() const override { return "cook"sv; } int run() override { hecl::MultiProgressPrinter printer(true); diff --git a/hecl/driver/ToolExtract.hpp b/hecl/driver/ToolExtract.hpp index 4b62ff3e5..df8016908 100644 --- a/hecl/driver/ToolExtract.hpp +++ b/hecl/driver/ToolExtract.hpp @@ -32,18 +32,18 @@ public: LogModule.report(logvisor::Fatal, FMT_STRING("hecl extract needs a source path as its first argument")); if (!info.project) { - hecl::SystemString rootDir; + std::string rootDir; if (info.output.empty()) { /* Get name from input file and init project there */ - hecl::SystemString baseFile = info.args.front(); - size_t slashPos = baseFile.rfind(_SYS_STR('/')); - if (slashPos == hecl::SystemString::npos) - slashPos = baseFile.rfind(_SYS_STR('\\')); - if (slashPos != hecl::SystemString::npos) + std::string baseFile = info.args.front(); + size_t slashPos = baseFile.rfind('/'); + if (slashPos == std::string::npos) + slashPos = baseFile.rfind('\\'); + if (slashPos != std::string::npos) baseFile.assign(baseFile.begin() + slashPos + 1, baseFile.end()); - size_t dotPos = baseFile.rfind(_SYS_STR('.')); - if (dotPos != hecl::SystemString::npos) + size_t dotPos = baseFile.rfind('.'); + if (dotPos != std::string::npos) baseFile.assign(baseFile.begin(), baseFile.begin() + dotPos); if (baseFile.empty()) @@ -62,8 +62,8 @@ public: newProjRoot.makeDir(); m_fallbackProj.reset(new hecl::Database::Project(newProjRoot)); if (logvisor::ErrorCount > ErrorRef) - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to init project at '{}'")), rootDir); - LogModule.report(logvisor::Info, FMT_STRING(_SYS_STR("initialized project at '{}/.hecl'")), rootDir); + LogModule.report(logvisor::Fatal, FMT_STRING("unable to init project at '{}'"), rootDir); + LogModule.report(logvisor::Info, FMT_STRING("initialized project at '{}/.hecl'"), rootDir); m_useProj = m_fallbackProj.get(); } else m_useProj = info.project; @@ -87,44 +87,44 @@ public: } static void Help(HelpOutput& help) { - help.secHead(_SYS_STR("NAME")); + help.secHead("NAME"); help.beginWrap(); - help.wrap(_SYS_STR("hecl-extract - Extract objects from supported package/image formats\n")); + help.wrap("hecl-extract - Extract objects from supported package/image formats\n"); help.endWrap(); - help.secHead(_SYS_STR("SYNOPSIS")); + help.secHead("SYNOPSIS"); help.beginWrap(); - help.wrap(_SYS_STR("hecl extract [...]\n")); + help.wrap("hecl extract [...]\n"); help.endWrap(); - help.secHead(_SYS_STR("DESCRIPTION")); + help.secHead("DESCRIPTION"); help.beginWrap(); - help.wrap(_SYS_STR("This command recursively extracts all or part of a dataspec-supported ") - _SYS_STR("package format. Each object is decoded to a working format and added to the project.\n\n")); + help.wrap("This command recursively extracts all or part of a dataspec-supported " + "package format. Each object is decoded to a working format and added to the project.\n\n"); help.endWrap(); - help.secHead(_SYS_STR("OPTIONS")); - help.optionHead(_SYS_STR("[/...]"), _SYS_STR("input file")); + help.secHead("OPTIONS"); + help.optionHead("[/...]", "input file"); help.beginWrap(); - help.wrap(_SYS_STR("Specifies the package file or disc image to source data from. ") - _SYS_STR("An optional subnode specifies a named hierarchical-node specific ") - _SYS_STR("to the game architecture (levels/areas).")); + help.wrap("Specifies the package file or disc image to source data from. " + "An optional subnode specifies a named hierarchical-node specific " + "to the game architecture (levels/areas)."); help.endWrap(); } - hecl::SystemStringView toolName() const override { return _SYS_STR("extract"sv); } + std::string_view toolName() const override { return "extract"sv; } static void _recursivePrint(int level, hecl::Database::IDataSpec::ExtractReport& rep) { for (int l = 0; l < level; ++l) - fmt::print(FMT_STRING(_SYS_STR(" "))); + fmt::print(FMT_STRING(" ")); if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" BOLD "{}" NORMAL "")), rep.name); + fmt::print(FMT_STRING("" BOLD "{}" NORMAL ""), rep.name); else - fmt::print(FMT_STRING(_SYS_STR("{}")), rep.name); + fmt::print(FMT_STRING("{}"), rep.name); if (rep.desc.size()) - fmt::print(FMT_STRING(_SYS_STR(" [{}]")), rep.desc); - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING(" [{}]"), rep.desc); + fmt::print(FMT_STRING("\n")); for (hecl::Database::IDataSpec::ExtractReport& child : rep.childOpts) _recursivePrint(level + 1, child); } @@ -132,32 +132,32 @@ public: int run() override { if (m_specPasses.empty()) { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" RED BOLD "NOTHING TO EXTRACT" NORMAL "\n"))); + fmt::print(FMT_STRING("" RED BOLD "NOTHING TO EXTRACT" NORMAL "\n")); else - fmt::print(FMT_STRING(_SYS_STR("NOTHING TO EXTRACT\n"))); + fmt::print(FMT_STRING("NOTHING TO EXTRACT\n")); return 1; } if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" GREEN BOLD "ABOUT TO EXTRACT:" NORMAL "\n"))); + fmt::print(FMT_STRING("" GREEN BOLD "ABOUT TO EXTRACT:" NORMAL "\n")); else - fmt::print(FMT_STRING(_SYS_STR("ABOUT TO EXTRACT:\n"))); + fmt::print(FMT_STRING("ABOUT TO EXTRACT:\n")); for (hecl::Database::IDataSpec::ExtractReport& rep : m_reps) { _recursivePrint(0, rep); - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); } fflush(stdout); if (continuePrompt()) { for (SpecExtractPass& ds : m_specPasses) { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" MAGENTA BOLD "Using DataSpec {}:" NORMAL "\n")), ds.m_entry->m_name); + fmt::print(FMT_STRING("" MAGENTA BOLD "Using DataSpec {}:" NORMAL "\n"), ds.m_entry->m_name); else - fmt::print(FMT_STRING(_SYS_STR("Using DataSpec {}:\n")), ds.m_entry->m_name); + fmt::print(FMT_STRING("Using DataSpec {}:\n"), ds.m_entry->m_name); ds.m_instance->doExtract(m_einfo, {true}); - fmt::print(FMT_STRING(_SYS_STR("\n\n"))); + fmt::print(FMT_STRING("\n\n")); } } diff --git a/hecl/driver/ToolHelp.hpp b/hecl/driver/ToolHelp.hpp index 04a558a27..6baa64d84 100644 --- a/hecl/driver/ToolHelp.hpp +++ b/hecl/driver/ToolHelp.hpp @@ -20,50 +20,50 @@ public: static void Help(HelpOutput& help) { /* clang-format off */ help.printBold( - _SYS_STR(" ___________ \n") - _SYS_STR(" ,.-'\"...........``~., \n") - _SYS_STR(" ,.-\".......................\"-., \n") - _SYS_STR(" ,/..................................\":, \n") - _SYS_STR(" .,?........................................, \n") - _SYS_STR(" /...........................................,}\n") - _SYS_STR(" ./........................................,:`^`..}\n") - _SYS_STR(" ./.......................................,:\"...../\n") - _SYS_STR(" ?.....__..................................:`...../\n") - _SYS_STR(" /__.(...\"~-,_...........................,:`....../\n") - _SYS_STR(" /(_....\"~,_....\"~,_.....................,:`...._/ \n") - _SYS_STR(" {.._$;_....\"=,_.....\"-,_......,.-~-,},.~\";/....} \n") - _SYS_STR(" ((...*~_......\"=-._...\";,,./`........../\"..../ \n") - _SYS_STR(" ,,,___.`~,......\"~.,....................`......}....../ \n") - _SYS_STR("............(....`=-,,...`.........................(...;_,,-\" \n") - _SYS_STR("............/.`~,......`-.................................../ \n") - _SYS_STR(".............`~.*-,.....................................|,./...,__ \n") - _SYS_STR(",,_..........}.>-._...................................|.......`=~-, \n") - _SYS_STR(".....`=~-,__......`,................................. \n") - _SYS_STR("...................`=~-,,.,........................... \n") - _SYS_STR(".........................`:,,..........................`\n") - _SYS_STR("...........................`=-,...............,%%`>--==`` \n") - _SYS_STR(".................................._.........._,-%%...` \n") - _SYS_STR("...................................,\n")); + " ___________ \n" + " ,.-'\"...........``~., \n" + " ,.-\".......................\"-., \n" + " ,/..................................\":, \n" + " .,?........................................, \n" + " /...........................................,}\n" + " ./........................................,:`^`..}\n" + " ./.......................................,:\"...../\n" + " ?.....__..................................:`...../\n" + " /__.(...\"~-,_...........................,:`....../\n" + " /(_....\"~,_....\"~,_.....................,:`...._/ \n" + " {.._$;_....\"=,_.....\"-,_......,.-~-,},.~\";/....} \n" + " ((...*~_......\"=-._...\";,,./`........../\"..../ \n" + " ,,,___.`~,......\"~.,....................`......}....../ \n" + "............(....`=-,,...`.........................(...;_,,-\" \n" + "............/.`~,......`-.................................../ \n" + ".............`~.*-,.....................................|,./...,__ \n" + ",,_..........}.>-._...................................|.......`=~-, \n" + ".....`=~-,__......`,................................. \n" + "...................`=~-,,.,........................... \n" + ".........................`:,,..........................`\n" + "...........................`=-,...............,%%`>--==`` \n" + ".................................._.........._,-%%...` \n" + "...................................,\n"); /* clang-format on */ } - static void ShowHelp(const hecl::SystemString& toolName) { + static void ShowHelp(const std::string& toolName) { /* Select tool's help-text streamer */ HelpOutput::HelpFunc helpFunc = nullptr; - if (toolName == _SYS_STR("init")) + if (toolName == "init") helpFunc = ToolInit::Help; - else if (toolName == _SYS_STR("spec")) + else if (toolName == "spec") helpFunc = ToolSpec::Help; - else if (toolName == _SYS_STR("extract")) + else if (toolName == "extract") helpFunc = ToolExtract::Help; - else if (toolName == _SYS_STR("cook")) + else if (toolName == "cook") helpFunc = ToolCook::Help; - else if (toolName == _SYS_STR("package") || toolName == _SYS_STR("pack")) + else if (toolName == "package" || toolName == "pack") helpFunc = ToolPackage::Help; - else if (toolName == _SYS_STR("help")) + else if (toolName == "help") helpFunc = ToolHelp::Help; else { - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("unrecognized tool '{}' - can't help")), toolName); + LogModule.report(logvisor::Error, FMT_STRING("unrecognized tool '{}' - can't help"), toolName); return; } @@ -71,7 +71,7 @@ public: ho.go(); } - hecl::SystemStringView toolName() const override { return _SYS_STR("help"sv); } + std::string_view toolName() const override { return "help"sv; } int run() override { ShowHelp(m_info.args.front()); diff --git a/hecl/driver/ToolImage.hpp b/hecl/driver/ToolImage.hpp index 7dc2d01e8..9e60feacd 100644 --- a/hecl/driver/ToolImage.hpp +++ b/hecl/driver/ToolImage.hpp @@ -22,11 +22,11 @@ public: /* Scan args */ if (info.args.size()) { /* See if project path is supplied via args and use that over the getcwd one */ - for (const hecl::SystemString& arg : info.args) { + for (const std::string& arg : info.args) { if (arg.empty()) continue; - hecl::SystemString subPath; + std::string subPath; hecl::ProjectRootPath root = hecl::SearchForProject(MakePathArgAbsolute(arg, info.cwd), subPath); if (root) { @@ -47,83 +47,82 @@ public: ~ToolImage() override = default; static void Help(HelpOutput& help) { - help.secHead(_SYS_STR("NAME")); + help.secHead("NAME"); help.beginWrap(); - help.wrap(_SYS_STR("hecl-image - Generate GameCube/Wii disc image from packaged files\n")); + help.wrap("hecl-image - Generate GameCube/Wii disc image from packaged files\n"); help.endWrap(); - help.secHead(_SYS_STR("SYNOPSIS")); + help.secHead("SYNOPSIS"); help.beginWrap(); - help.wrap(_SYS_STR("hecl image []\n")); + help.wrap("hecl image []\n"); help.endWrap(); - help.secHead(_SYS_STR("DESCRIPTION")); + help.secHead("DESCRIPTION"); help.beginWrap(); - help.wrap(_SYS_STR("This command uses the current contents of `out` to generate a GameCube or ") - _SYS_STR("Wii disc image. `hecl package` must have been run previously to be effective.\n")); + help.wrap("This command uses the current contents of `out` to generate a GameCube or " + "Wii disc image. `hecl package` must have been run previously to be effective.\n"); help.endWrap(); - help.secHead(_SYS_STR("OPTIONS")); - help.optionHead(_SYS_STR(""), _SYS_STR("input directory")); + help.secHead("OPTIONS"); + help.optionHead("", "input directory"); help.beginWrap(); - help.wrap(_SYS_STR("Specifies a project subdirectory to root the resulting image from. ") - _SYS_STR("Project must contain an out/sys and out/files directory to succeed.\n")); + help.wrap("Specifies a project subdirectory to root the resulting image from. " + "Project must contain an out/sys and out/files directory to succeed.\n"); help.endWrap(); } - hecl::SystemStringView toolName() const override { return _SYS_STR("image"sv); } + std::string_view toolName() const override { return "image"sv; } int run() override { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" GREEN BOLD "ABOUT TO IMAGE:" NORMAL "\n"))); + fmt::print(FMT_STRING("" GREEN BOLD "ABOUT TO IMAGE:" NORMAL "\n")); else - fmt::print(FMT_STRING(_SYS_STR("ABOUT TO IMAGE:\n"))); + fmt::print(FMT_STRING("ABOUT TO IMAGE:\n")); - fmt::print(FMT_STRING(_SYS_STR(" {}\n")), m_useProj->getProjectRootPath().getAbsolutePath()); + fmt::print(FMT_STRING(" {}\n"), m_useProj->getProjectRootPath().getAbsolutePath()); fflush(stdout); if (continuePrompt()) { - hecl::ProjectPath outPath(m_useProj->getProjectWorkingPath(), _SYS_STR("out")); + hecl::ProjectPath outPath(m_useProj->getProjectWorkingPath(), "out"); if (!outPath.isDirectory()) { - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("{} is not a directory")), outPath.getAbsolutePath()); + LogModule.report(logvisor::Error, FMT_STRING("{} is not a directory"), outPath.getAbsolutePath()); return 1; } - hecl::ProjectPath bootBinPath(outPath, _SYS_STR("sys/boot.bin")); + hecl::ProjectPath bootBinPath(outPath, "sys/boot.bin"); if (!bootBinPath.isFile()) { - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("{} is not a file")), bootBinPath.getAbsolutePath()); + LogModule.report(logvisor::Error, FMT_STRING("{} is not a file"), bootBinPath.getAbsolutePath()); return 1; } athena::io::FileReader r(bootBinPath.getAbsolutePath()); if (r.hasError()) { - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("unable to open {}")), bootBinPath.getAbsolutePath()); + LogModule.report(logvisor::Error, FMT_STRING("unable to open {}"), bootBinPath.getAbsolutePath()); return 1; } std::string id = r.readString(6); r.close(); - hecl::SystemStringConv idView(id); - hecl::SystemString fileOut = hecl::SystemString(outPath.getAbsolutePath()) + _SYS_STR('/') + idView.c_str(); + std::string fileOut = std::string(outPath.getAbsolutePath()) + '/' + id; hecl::MultiProgressPrinter printer(true); - auto progFunc = [&printer](float totalProg, nod::SystemStringView fileName, size_t fileBytesXfered) { + auto progFunc = [&printer](float totalProg, std::string_view fileName, size_t fileBytesXfered) { printer.print(fileName, std::nullopt, totalProg); }; if (id[0] == 'G') { - fileOut += _SYS_STR(".gcm"); + fileOut += ".gcm"; if (nod::DiscBuilderGCN::CalculateTotalSizeRequired(outPath.getAbsolutePath()) == UINT64_MAX) return 1; - LogModule.report(logvisor::Info, FMT_STRING(_SYS_STR("Generating {} as GameCube image")), fileOut); + LogModule.report(logvisor::Info, FMT_STRING("Generating {} as GameCube image"), fileOut); nod::DiscBuilderGCN db(fileOut, progFunc); if (db.buildFromDirectory(outPath.getAbsolutePath()) != nod::EBuildResult::Success) return 1; } else { - fileOut += _SYS_STR(".iso"); + fileOut += ".iso"; bool dualLayer; if (nod::DiscBuilderWii::CalculateTotalSizeRequired(outPath.getAbsolutePath(), dualLayer) == UINT64_MAX) return 1; - LogModule.report(logvisor::Info, FMT_STRING(_SYS_STR("Generating {} as {}-layer Wii image")), fileOut, - dualLayer ? _SYS_STR("dual") : _SYS_STR("single")); + LogModule.report(logvisor::Info, FMT_STRING("Generating {} as {}-layer Wii image"), fileOut, + dualLayer ? "dual" : "single"); nod::DiscBuilderWii db(fileOut, dualLayer, progFunc); if (db.buildFromDirectory(outPath.getAbsolutePath()) != nod::EBuildResult::Success) return 1; diff --git a/hecl/driver/ToolInit.hpp b/hecl/driver/ToolInit.hpp index ed2758f26..6288adca6 100644 --- a/hecl/driver/ToolInit.hpp +++ b/hecl/driver/ToolInit.hpp @@ -4,12 +4,12 @@ #include class ToolInit final : public ToolBase { - const hecl::SystemString* m_dir = nullptr; + const std::string* m_dir = nullptr; public: explicit ToolInit(const ToolPassInfo& info) : ToolBase(info) { hecl::Sstat theStat; - const hecl::SystemString* dir; + const std::string* dir; if (info.args.size()) dir = &info.args.front(); else @@ -18,18 +18,18 @@ public: if (hecl::Stat(dir->c_str(), &theStat)) { hecl::MakeDir(dir->c_str()); if (hecl::Stat(dir->c_str(), &theStat)) { - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to stat '{}'")), *dir); + LogModule.report(logvisor::Fatal, FMT_STRING("unable to stat '{}'"), *dir); return; } } if (!S_ISDIR(theStat.st_mode)) { - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("'{}' is not a directory")), *dir); + LogModule.report(logvisor::Fatal, FMT_STRING("'{}' is not a directory"), *dir); return; } - hecl::SystemString testPath = *dir + _SYS_STR("/.hecl/beacon"); + std::string testPath = *dir + "/.hecl/beacon"; if (!hecl::Stat(testPath.c_str(), &theStat)) { - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("project already exists at '{}'")), *dir); + LogModule.report(logvisor::Fatal, FMT_STRING("project already exists at '{}'"), *dir); return; } @@ -43,35 +43,35 @@ public: hecl::Database::Project proj((hecl::ProjectRootPath(*m_dir))); if (logvisor::ErrorCount > ErrorRef) return 1; - LogModule.report(logvisor::Info, FMT_STRING(_SYS_STR("initialized project at '{}/.hecl'")), *m_dir); + LogModule.report(logvisor::Info, FMT_STRING("initialized project at '{}/.hecl'"), *m_dir); return 0; } static void Help(HelpOutput& help) { - help.secHead(_SYS_STR("NAME")); + help.secHead("NAME"); help.beginWrap(); - help.wrap(_SYS_STR("hecl-init - Initialize a brand-new project database\n")); + help.wrap("hecl-init - Initialize a brand-new project database\n"); help.endWrap(); - help.secHead(_SYS_STR("SYNOPSIS")); + help.secHead("SYNOPSIS"); help.beginWrap(); - help.wrap(_SYS_STR("hecl init []\n")); + help.wrap("hecl init []\n"); help.endWrap(); - help.secHead(_SYS_STR("DESCRIPTION")); + help.secHead("DESCRIPTION"); help.beginWrap(); - help.wrap(_SYS_STR("Creates a ")); - help.wrapBold(_SYS_STR(".hecl")); - help.wrap(_SYS_STR(" directory within the selected directory with an initialized database index. ") - _SYS_STR("This constitutes an empty HECL project, ready for making stuff!!\n")); + help.wrap("Creates a "); + help.wrapBold(".hecl"); + help.wrap(" directory within the selected directory with an initialized database index. " + "This constitutes an empty HECL project, ready for making stuff!!\n"); help.endWrap(); - help.secHead(_SYS_STR("OPTIONS")); - help.optionHead(_SYS_STR(""), _SYS_STR("group directory path")); + help.secHead("OPTIONS"); + help.optionHead("", "group directory path"); help.beginWrap(); - help.wrap(_SYS_STR("Directory to create new project database in. If not specified, current directory is used.\n")); + help.wrap("Directory to create new project database in. If not specified, current directory is used.\n"); help.endWrap(); } - hecl::SystemStringView toolName() const override { return _SYS_STR("init"sv); } + std::string_view toolName() const override { return "init"sv; } }; diff --git a/hecl/driver/ToolInstallAddon.hpp b/hecl/driver/ToolInstallAddon.hpp index 3b5721db1..f224d96dd 100644 --- a/hecl/driver/ToolInstallAddon.hpp +++ b/hecl/driver/ToolInstallAddon.hpp @@ -13,22 +13,22 @@ public: } static void Help(HelpOutput& help) { - help.secHead(_SYS_STR("NAME")); + help.secHead("NAME"); help.beginWrap(); - help.wrap(_SYS_STR("hecl-installaddon - Installs embedded Blender addon into local Blender\n")); + help.wrap("hecl-installaddon - Installs embedded Blender addon into local Blender\n"); help.endWrap(); - help.secHead(_SYS_STR("SYNOPSIS")); + help.secHead("SYNOPSIS"); help.beginWrap(); - help.wrap(_SYS_STR("hecl installaddon\n")); + help.wrap("hecl installaddon\n"); help.endWrap(); - help.secHead(_SYS_STR("DESCRIPTION")); + help.secHead("DESCRIPTION"); help.beginWrap(); - help.wrap(_SYS_STR("Installs the hecl Blender addon into Blender. The path to the blender executable ") - _SYS_STR("can be overridden by setting the BLENDER_BIN environment variable.")); + help.wrap("Installs the hecl Blender addon into Blender. The path to the blender executable " + "can be overridden by setting the BLENDER_BIN environment variable."); help.endWrap(); } - hecl::SystemStringView toolName() const override { return _SYS_STR("installaddon"sv); } + std::string_view toolName() const override { return "installaddon"sv; } }; diff --git a/hecl/driver/ToolPackage.hpp b/hecl/driver/ToolPackage.hpp index b30597674..262731e5e 100644 --- a/hecl/driver/ToolPackage.hpp +++ b/hecl/driver/ToolPackage.hpp @@ -21,8 +21,8 @@ class ToolPackage final : public ToolBase { void CheckFile(const hecl::ProjectPath& path) { auto lastComp = path.getLastComponent(); - if (hecl::StringUtils::BeginsWith(lastComp, _SYS_STR("!world")) && - hecl::StringUtils::EndsWith(lastComp, _SYS_STR(".blend"))) + if (hecl::StringUtils::BeginsWith(lastComp, "!world") && + hecl::StringUtils::EndsWith(lastComp, ".blend")) AddSelectedItem(path); } @@ -47,8 +47,8 @@ class ToolPackage final : public ToolBase { * and no nested !world.blend files == General PAK */ if (checkGeneral && origSize == m_selectedItems.size()) { auto pathComps = path.getPathComponents(); - if (pathComps.size() == 2 && pathComps[0] != _SYS_STR("out") && pathComps[1] != _SYS_STR("Shared") && - pathComps[0].find(_SYS_STR(".app")) == hecl::SystemString::npos) + if (pathComps.size() == 2 && pathComps[0] != "out" && pathComps[1] != "Shared" && + pathComps[0].find(".app") == std::string::npos) AddSelectedItem(path); } } @@ -62,14 +62,14 @@ public: if (info.args.size()) { /* See if project path is supplied via args and use that over the getcwd one */ m_selectedItems.reserve(info.args.size()); - for (const hecl::SystemString& arg : info.args) { + for (const std::string& arg : info.args) { if (arg.empty()) continue; - else if (arg == _SYS_STR("--fast")) { + else if (arg == "--fast") { m_fast = true; continue; - } else if (arg.size() >= 8 && !arg.compare(0, 7, _SYS_STR("--spec="))) { - hecl::SystemString specName(arg.begin() + 7, arg.end()); + } else if (arg.size() >= 8 && !arg.compare(0, 7, "--spec=")) { + std::string specName(arg.begin() + 7, arg.end()); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (!hecl::StrCaseCmp(spec->m_name.data(), specName.c_str())) { m_spec = spec; @@ -77,12 +77,12 @@ public: } } if (!m_spec) - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find data spec '{}'")), specName); + LogModule.report(logvisor::Fatal, FMT_STRING("unable to find data spec '{}'"), specName); continue; - } else if (arg.size() >= 2 && arg[0] == _SYS_STR('-') && arg[1] == _SYS_STR('-')) + } else if (arg.size() >= 2 && arg[0] == '-' && arg[1] == '-') continue; - hecl::SystemString subPath; + std::string subPath; hecl::ProjectRootPath root = hecl::SearchForProject(MakePathArgAbsolute(arg, info.cwd), subPath); if (root) { @@ -91,8 +91,8 @@ public: m_useProj = m_fallbackProj.get(); } else if (m_fallbackProj->getProjectRootPath() != root) LogModule.report(logvisor::Fatal, - FMT_STRING(_SYS_STR("hecl package can only process multiple items in the same project; ") - _SYS_STR("'{}' and '{}' are different projects")), + FMT_STRING("hecl package can only process multiple items in the same project; " + "'{}' and '{}' are different projects"), m_fallbackProj->getProjectRootPath().getAbsolutePath(), root.getAbsolutePath()); @@ -107,60 +107,65 @@ public: /* Default case: recursive at root */ if (m_selectedItems.empty()) - FindSelectedItems({*m_useProj, _SYS_STR("")}, true); + FindSelectedItems({*m_useProj, ""}, true); } static void Help(HelpOutput& help) { - help.secHead(_SYS_STR("NAME")); + help.secHead("NAME"); help.beginWrap(); - help.wrap(_SYS_STR("hecl-pack\n") _SYS_STR("hecl-package - Package objects within the project database\n")); + help.wrap( + "hecl-pack\n" + "hecl-package - Package objects within the project database\n"); help.endWrap(); - help.secHead(_SYS_STR("SYNOPSIS")); + help.secHead("SYNOPSIS"); help.beginWrap(); - help.wrap(_SYS_STR("hecl package [--spec=] []\n")); + help.wrap("hecl package [--spec=] []\n"); help.endWrap(); - help.secHead(_SYS_STR("DESCRIPTION")); + help.secHead("DESCRIPTION"); help.beginWrap(); - help.wrap(_SYS_STR("This command initiates a packaging pass on the project database. Packaging ") - _SYS_STR("is analogous to linking in software development. All objects necessary to ") _SYS_STR( - "generate a complete package are gathered, grouped, and indexed within a .upak file.\n")); + help.wrap( + "This command initiates a packaging pass on the project database. Packaging " + "is analogous to linking in software development. All objects necessary to " + "generate a complete package are gathered, grouped, and indexed within a .upak file.\n"); help.endWrap(); - help.secHead(_SYS_STR("OPTIONS")); - help.optionHead(_SYS_STR("--spec="), _SYS_STR("data specification")); + help.secHead("OPTIONS"); + help.optionHead("--spec=", "data specification"); help.beginWrap(); - help.wrap(_SYS_STR("Specifies a DataSpec to use when cooking and generating the package. ") - _SYS_STR("This build of hecl supports the following values of :\n")); + help.wrap( + "Specifies a DataSpec to use when cooking and generating the package. " + "This build of hecl supports the following values of :\n"); for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (!spec->m_factory) continue; - help.wrap(_SYS_STR(" ")); + help.wrap(" "); help.wrapBold(spec->m_name.data()); - help.wrap(_SYS_STR("\n")); + help.wrap("\n"); } help.endWrap(); - help.secHead(_SYS_STR("OPTIONS")); - help.optionHead(_SYS_STR(""), _SYS_STR("input directory")); + help.secHead("OPTIONS"); + help.optionHead("", "input directory"); help.beginWrap(); - help.wrap(_SYS_STR("Specifies a project subdirectory to root the resulting package from. ") - _SYS_STR("If any dependent files fall outside this subdirectory, they will be implicitly ") - _SYS_STR("gathered and packaged.\n")); + help.wrap( + "Specifies a project subdirectory to root the resulting package from. " + "If any dependent files fall outside this subdirectory, they will be implicitly " + "gathered and packaged.\n"); help.endWrap(); } - hecl::SystemStringView toolName() const override { return _SYS_STR("package"sv); } + std::string_view toolName() const override { return "package"sv; } int run() override { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" GREEN BOLD "ABOUT TO PACKAGE:" NORMAL "\n"))); + fmt::print(FMT_STRING("" GREEN BOLD "ABOUT TO PACKAGE:" NORMAL "\n")); else - fmt::print(FMT_STRING(_SYS_STR("ABOUT TO PACKAGE:\n"))); + fmt::print(FMT_STRING("ABOUT TO PACKAGE:\n")); for (auto& item : m_selectedItems) - fmt::print(FMT_STRING(_SYS_STR(" {}\n")), item.getRelativePath()); + fmt::print(FMT_STRING(" {}\n"), item.getRelativePath()); fflush(stdout); if (continuePrompt()) { @@ -168,7 +173,7 @@ public: hecl::ClientProcess cp(&printer); for (const hecl::ProjectPath& path : m_selectedItems) { if (!m_useProj->packagePath(path, printer, m_fast, m_spec, &cp)) - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to package {}")), path.getAbsolutePath()); + LogModule.report(logvisor::Error, FMT_STRING("Unable to package {}"), path.getAbsolutePath()); } cp.waitUntilComplete(); } diff --git a/hecl/driver/ToolSpec.hpp b/hecl/driver/ToolSpec.hpp index 35b1b63d5..8e07cfc77 100644 --- a/hecl/driver/ToolSpec.hpp +++ b/hecl/driver/ToolSpec.hpp @@ -16,12 +16,12 @@ public: LogModule.report(logvisor::Fatal, FMT_STRING("hecl spec must be ran within a project directory")); const auto& specs = info.project->getDataSpecs(); - hecl::SystemString firstArg = info.args.front(); + std::string firstArg = info.args.front(); hecl::ToLower(firstArg); - if (firstArg == _SYS_STR("enable")) + if (firstArg == "enable") mode = MENABLE; - else if (firstArg == _SYS_STR("disable")) + else if (firstArg == "disable") mode = MDISABLE; else return; @@ -41,46 +41,46 @@ public: } } if (!found) - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("'{}' is not found in the dataspec registry")), *it); + LogModule.report(logvisor::Fatal, FMT_STRING("'{}' is not found in the dataspec registry"), *it); } } static void Help(HelpOutput& help) { - help.secHead(_SYS_STR("NAME")); + help.secHead("NAME"); help.beginWrap(); - help.wrap(_SYS_STR("hecl-spec - Configure target data options\n")); + help.wrap("hecl-spec - Configure target data options\n"); help.endWrap(); - help.secHead(_SYS_STR("SYNOPSIS")); + help.secHead("SYNOPSIS"); help.beginWrap(); - help.wrap(_SYS_STR("hecl spec [enable|disable] [...]\n")); + help.wrap("hecl spec [enable|disable] [...]\n"); help.endWrap(); - help.secHead(_SYS_STR("DESCRIPTION")); + help.secHead("DESCRIPTION"); help.beginWrap(); help.wrap( - _SYS_STR("This command configures the HECL project with the user's preferred target DataSpecs.\n\n") - _SYS_STR("Providing enable/disable argument will bulk-set the enable status of the provided spec(s)") - _SYS_STR("list. If enable/disable is not provided, a list of supported DataSpecs is printed.\n\n")); + "This command configures the HECL project with the user's preferred target DataSpecs.\n\n" + "Providing enable/disable argument will bulk-set the enable status of the provided spec(s)" + "list. If enable/disable is not provided, a list of supported DataSpecs is printed.\n\n"); help.endWrap(); - help.secHead(_SYS_STR("OPTIONS")); - help.optionHead(_SYS_STR("..."), _SYS_STR("DataSpec name(s)")); + help.secHead("OPTIONS"); + help.optionHead("...", "DataSpec name(s)"); help.beginWrap(); - help.wrap(_SYS_STR("Specifies platform-names to enable/disable")); + help.wrap("Specifies platform-names to enable/disable"); help.endWrap(); } - hecl::SystemStringView toolName() const override { return _SYS_STR("spec"sv); } + std::string_view toolName() const override { return "spec"sv; } int run() override { if (!m_info.project) { for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" BOLD CYAN "{}" NORMAL "\n")), spec->m_name); + fmt::print(FMT_STRING("" BOLD CYAN "{}" NORMAL "\n"), spec->m_name); else - fmt::print(FMT_STRING(_SYS_STR("{}\n")), spec->m_name); - fmt::print(FMT_STRING(_SYS_STR(" {}\n")), spec->m_desc); + fmt::print(FMT_STRING("{}\n"), spec->m_name); + fmt::print(FMT_STRING(" {}\n"), spec->m_desc); } return 0; } @@ -89,28 +89,28 @@ public: if (mode == MLIST) { for (auto& spec : specs) { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" BOLD CYAN "{}" NORMAL "")), spec.spec.m_name); + fmt::print(FMT_STRING("" BOLD CYAN "{}" NORMAL ""), spec.spec.m_name); else - fmt::print(FMT_STRING(_SYS_STR("{}")), spec.spec.m_name); + fmt::print(FMT_STRING("{}"), spec.spec.m_name); if (spec.active) { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR(" " BOLD GREEN "[ENABLED]" NORMAL ""))); + fmt::print(FMT_STRING(" " BOLD GREEN "[ENABLED]" NORMAL "")); else - fmt::print(FMT_STRING(_SYS_STR(" [ENABLED]"))); + fmt::print(FMT_STRING(" [ENABLED]")); } - fmt::print(FMT_STRING(_SYS_STR("\n {}\n")), spec.spec.m_desc); + fmt::print(FMT_STRING("\n {}\n"), spec.spec.m_desc); } return 0; } - std::vector opSpecs; + std::vector opSpecs; auto it = m_info.args.begin(); ++it; for (; it != m_info.args.end(); ++it) { - hecl::SystemString itName = *it; + std::string itName = *it; hecl::ToLower(itName); for (auto& spec : specs) { - hecl::SystemString compName(spec.spec.m_name); + std::string compName(spec.spec.m_name); hecl::ToLower(compName); if (itName == compName) { opSpecs.emplace_back(spec.spec.m_name); diff --git a/hecl/driver/main.cpp b/hecl/driver/main.cpp index 54b5763c3..623a8bdf6 100644 --- a/hecl/driver/main.cpp +++ b/hecl/driver/main.cpp @@ -46,27 +46,27 @@ bool XTERM_COLOR = false; */ /* Main usage message */ -static void printHelp(const hecl::SystemChar* pname) { +static void printHelp(const char* pname) { if (XTERM_COLOR) - fmt::print(FMT_STRING(_SYS_STR("" BOLD "HECL" NORMAL ""))); + fmt::print(FMT_STRING("" BOLD "HECL" NORMAL "")); else - fmt::print(FMT_STRING(_SYS_STR("HECL"))); + fmt::print(FMT_STRING("HECL")); #if HECL_HAS_NOD #define TOOL_LIST "extract|init|cook|package|image|installaddon|help" #else #define TOOL_LIST "extract|init|cook|package|installaddon|help" #endif #if HECL_GIT - fmt::print(FMT_STRING(_SYS_STR(" Commit " HECL_GIT_S " " HECL_BRANCH_S "\nUsage: {} " TOOL_LIST "\n")), pname); + fmt::print(FMT_STRING(" Commit " HECL_GIT_S " " HECL_BRANCH_S "\nUsage: {} " TOOL_LIST "\n"), pname); #elif HECL_VER - fmt::print(FMT_STRING(_SYS_STR(" Version " HECL_VER_S "\nUsage: {} " TOOL_LIST "\n")), pname); + fmt::print(FMT_STRING(" Version " HECL_VER_S "\nUsage: {} " TOOL_LIST "\n"), pname); #else - fmt::print(FMT_STRING(_SYS_STR("\nUsage: {} " TOOL_LIST "\n")), pname); + fmt::print(FMT_STRING("\nUsage: {} " TOOL_LIST "\n"), pname); #endif } /* Regex patterns */ -static const hecl::SystemRegex regOPEN(_SYS_STR("-o([^\"]*|\\S*)"), std::regex::ECMAScript | std::regex::optimize); +static const std::regex regOPEN("-o([^\"]*|\\S*)", std::regex::ECMAScript | std::regex::optimize); static ToolBase* ToolPtr = nullptr; @@ -85,40 +85,36 @@ static void AthenaExc(athena::error::Level level, const char* file, const char*, AthenaLog.vreport(logvisor::Level(level), fmt, args); } -hecl::SystemString ExeDir; +std::string ExeDir; -#if _WIN32 -static ToolPassInfo CreateInfo(int argc, const wchar_t** argv) { -#else -static ToolPassInfo CreateInfo(int argc, const char** argv) { -#endif - hecl::SystemChar cwdbuf[1024]; +static ToolPassInfo CreateInfo(int argc, char** argv) { + char cwdbuf[1024]; ToolPassInfo info; info.pname = argv[0]; if (hecl::Getcwd(cwdbuf, static_cast(std::size(cwdbuf)))) { info.cwd = cwdbuf; - if (info.cwd.size() && info.cwd.back() != _SYS_STR('/') && info.cwd.back() != _SYS_STR('\\')) { + if (info.cwd.size() && info.cwd.back() != '/' && info.cwd.back() != '\\') { #if _WIN32 - info.cwd += _SYS_STR('\\'); + info.cwd += '\\'; #else - info.cwd += _SYS_STR('/'); + info.cwd += '/'; #endif } if (hecl::PathRelative(argv[0])) { - ExeDir = hecl::SystemString(cwdbuf) + _SYS_STR('/'); + ExeDir = std::string(cwdbuf) + '/'; } - hecl::SystemString Argv0(argv[0]); - hecl::SystemString::size_type lastIdx = Argv0.find_last_of(_SYS_STR("/\\")); - if (lastIdx != hecl::SystemString::npos) { + std::string Argv0(argv[0]); + std::string::size_type lastIdx = Argv0.find_last_of("/\\"); + if (lastIdx != std::string::npos) { ExeDir.insert(ExeDir.end(), Argv0.begin(), Argv0.begin() + lastIdx); } } /* Concatenate args */ - std::vector args; + std::vector args; args.reserve(argc - 2); for (int i = 2; i < argc; ++i) { args.emplace_back(argv[i]); @@ -127,11 +123,11 @@ static ToolPassInfo CreateInfo(int argc, const char** argv) { if (!args.empty()) { /* Extract output argument */ for (auto it = args.cbegin(); it != args.cend();) { - const hecl::SystemString& arg = *it; - hecl::SystemRegexMatch oMatch; + const std::string& arg = *it; + std::smatch oMatch; if (std::regex_search(arg, oMatch, regOPEN)) { - const hecl::SystemString& token = oMatch[1].str(); + const std::string& token = oMatch[1].str(); if (token.size()) { if (info.output.empty()) { @@ -162,28 +158,28 @@ static ToolPassInfo CreateInfo(int argc, const char** argv) { /* Iterate flags */ bool threadArg = false; for (auto it = args.cbegin(); it != args.cend();) { - const hecl::SystemString& arg = *it; + const std::string& arg = *it; if (threadArg) { threadArg = false; hecl::CpuCountOverride = int(hecl::StrToUl(arg.c_str(), nullptr, 0)); it = args.erase(it); continue; } - if (arg.size() < 2 || arg[0] != _SYS_STR('-') || arg[1] == _SYS_STR('-')) { + if (arg.size() < 2 || arg[0] != '-' || arg[1] == '-') { ++it; continue; } for (auto chit = arg.cbegin() + 1; chit != arg.cend(); ++chit) { - if (*chit == _SYS_STR('v')) + if (*chit == 'v') ++info.verbosityLevel; - else if (*chit == _SYS_STR('f')) + else if (*chit == 'f') info.force = true; - else if (*chit == _SYS_STR('y')) + else if (*chit == 'y') info.yes = true; - else if (*chit == _SYS_STR('g')) + else if (*chit == 'g') info.gui = true; - else if (*chit == _SYS_STR('j')) { + else if (*chit == 'j') { ++chit; if (*chit) hecl::CpuCountOverride = int(hecl::StrToUl(&*chit, nullptr, 0)); @@ -199,14 +195,14 @@ static ToolPassInfo CreateInfo(int argc, const char** argv) { /* Gather remaining args */ info.args.reserve(args.size()); - for (const hecl::SystemString& arg : args) + for (const std::string& arg : args) info.args.push_back(arg); } return info; } -static std::unique_ptr FindProject(hecl::SystemStringView cwd) { +static std::unique_ptr FindProject(std::string_view cwd) { const hecl::ProjectRootPath rootPath = hecl::SearchForProject(cwd); if (!rootPath) { return nullptr; @@ -224,47 +220,47 @@ static std::unique_ptr FindProject(hecl::SystemStringVi return newProj; } -static std::unique_ptr MakeSelectedTool(hecl::SystemString toolName, ToolPassInfo& info) { - hecl::SystemString toolNameLower = toolName; +static std::unique_ptr MakeSelectedTool(std::string toolName, ToolPassInfo& info) { + std::string toolNameLower = toolName; hecl::ToLower(toolNameLower); - if (toolNameLower == _SYS_STR("init")) { + if (toolNameLower == "init") { return std::make_unique(info); } - if (toolNameLower == _SYS_STR("spec")) { + if (toolNameLower == "spec") { return std::make_unique(info); } - if (toolNameLower == _SYS_STR("extract")) { + if (toolNameLower == "extract") { return std::make_unique(info); } - if (toolNameLower == _SYS_STR("cook")) { + if (toolNameLower == "cook") { return std::make_unique(info); } - if (toolNameLower == _SYS_STR("package") || toolNameLower == _SYS_STR("pack")) { + if (toolNameLower == "package" || toolNameLower == "pack") { return std::make_unique(info); } #if HECL_HAS_NOD - if (toolNameLower == _SYS_STR("image")) { + if (toolNameLower == "image") { return std::make_unique(info); } #endif - if (toolNameLower == _SYS_STR("installaddon")) { + if (toolNameLower == "installaddon") { return std::make_unique(info); } - if (toolNameLower == _SYS_STR("help")) { + if (toolNameLower == "help") { return std::make_unique(info); } - auto fp = hecl::FopenUnique(toolName.c_str(), _SYS_STR("rb")); + auto fp = hecl::FopenUnique(toolName.c_str(), "rb"); if (fp == nullptr) { - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("unrecognized tool '{}'")), toolNameLower); + LogModule.report(logvisor::Error, FMT_STRING("unrecognized tool '{}'"), toolNameLower); return nullptr; } fp.reset(); @@ -275,14 +271,16 @@ static std::unique_ptr MakeSelectedTool(hecl::SystemString toolName, T } #if _WIN32 -int wmain(int argc, const wchar_t** argv) +#include #else /* SIGWINCH should do nothing */ static void SIGWINCHHandler(int sig) {} -int main(int argc, const char** argv) #endif -{ - if (argc > 1 && !hecl::StrCmp(argv[1], _SYS_STR("--dlpackage"))) { +int main(int argc, char** argv) { +#if _WIN32 + nowide::args _(argc, argv); +#endif + if (argc > 1 && !hecl::StrCmp(argv[1], "--dlpackage")) { fmt::print(FMT_STRING("{}\n"), METAFORCE_DLPACKAGE); return 100; } @@ -295,9 +293,10 @@ int main(int argc, const char** argv) /* Xterm check */ #if _WIN32 - const char* conemuANSI = getenv("ConEmuANSI"); - if (conemuANSI && !strcmp(conemuANSI, "ON")) + const auto conemuANSI = hecl::GetEnv("ConEmuANSI"); + if (conemuANSI && conemuANSI == "ON") { XTERM_COLOR = true; + } #else const char* term = getenv("TERM"); if (term && !strncmp(term, "xterm", 5)) @@ -311,8 +310,8 @@ int main(int argc, const char** argv) atSetExceptionHandler(AthenaExc); #if SENTRY_ENABLED - hecl::Runtime::FileStoreManager fileMgr{_SYS_STR("sentry-native-hecl")}; - hecl::SystemUTF8Conv cacheDir{fileMgr.getStoreRoot()}; + hecl::Runtime::FileStoreManager fileMgr{"sentry-native-hecl"}; + std::string cacheDir{fileMgr.getStoreRoot()}; logvisor::RegisterSentry("hecl", METAFORCE_WC_DESCRIBE, cacheDir.c_str()); #endif @@ -323,8 +322,9 @@ int main(int argc, const char** argv) system("PAUSE"); #endif return 0; - } else if (argc == 0) { - printHelp(_SYS_STR("hecl")); + } + if (argc == 0) { + printHelp("hecl"); #if WIN_PAUSE system("PAUSE"); #endif @@ -353,7 +353,7 @@ int main(int argc, const char** argv) return 1; } if (info.verbosityLevel) { - LogModule.report(logvisor::Info, FMT_STRING(_SYS_STR("Constructed tool '{}' {}\n")), tool->toolName(), + LogModule.report(logvisor::Info, FMT_STRING("Constructed tool '{}' {}\n"), tool->toolName(), info.verbosityLevel); } diff --git a/hecl/include/hecl/Blender/Connection.hpp b/hecl/include/hecl/Blender/Connection.hpp index f207816f4..725860a77 100644 --- a/hecl/include/hecl/Blender/Connection.hpp +++ b/hecl/include/hecl/Blender/Connection.hpp @@ -731,7 +731,7 @@ class Connection { BlendType m_loadedType = BlendType::None; bool m_loadedRigged = false; ProjectPath m_loadedBlend; - hecl::SystemString m_errPath; + std::string m_errPath; uint32_t _readStr(char* buf, uint32_t bufSz); uint32_t _writeStr(const char* str, uint32_t len, int wpipe); uint32_t _writeStr(const char* str, uint32_t len) { return _writeStr(str, len, m_writepipe[1]); } @@ -805,7 +805,7 @@ class Connection { char readBuf[16]; _readStr(readBuf, 16); if (status != readBuf) - BlenderLog.report(logvisor::Fatal, FMT_STRING("{}: {}: {}"), m_loadedBlend.getRelativePathUTF8(), action, readBuf); + BlenderLog.report(logvisor::Fatal, FMT_STRING("{}: {}: {}"), m_loadedBlend.getRelativePath(), action, readBuf); } void _checkReady(std::string_view action) { _checkStatus(action, "READY"sv); } void _checkDone(std::string_view action) { _checkStatus(action, "DONE"sv); } diff --git a/metaforce-gui/FindBlender.hpp b/hecl/include/hecl/Blender/FindBlender.hpp similarity index 73% rename from metaforce-gui/FindBlender.hpp rename to hecl/include/hecl/Blender/FindBlender.hpp index 7a09faeee..ac4748d05 100644 --- a/metaforce-gui/FindBlender.hpp +++ b/hecl/include/hecl/Blender/FindBlender.hpp @@ -8,6 +8,6 @@ constexpr uint32_t MaxBlenderMajorSearch = 2; constexpr uint32_t MinBlenderMinorSearch = 83; constexpr uint32_t MaxBlenderMinorSearch = 92; -hecl::SystemString FindBlender(int& major, int& minor); +std::optional FindBlender(int& major, int& minor); -} +} // namespace hecl::blender diff --git a/hecl/include/hecl/Blender/SDNARead.hpp b/hecl/include/hecl/Blender/SDNARead.hpp index c853dc9a5..50471df0b 100644 --- a/hecl/include/hecl/Blender/SDNARead.hpp +++ b/hecl/include/hecl/Blender/SDNARead.hpp @@ -4,7 +4,6 @@ #include #include "hecl/FourCC.hpp" -#include "hecl/SystemChar.hpp" #include @@ -65,12 +64,12 @@ class SDNARead { SDNABlock m_sdnaBlock; public: - explicit SDNARead(SystemStringView path); + explicit SDNARead(std::string_view path); explicit operator bool() const { return !m_data.empty(); } const SDNABlock& sdnaBlock() const { return m_sdnaBlock; } void enumerate(const std::function& func) const; }; -BlendType GetBlendType(SystemStringView path); +BlendType GetBlendType(std::string_view path); } // namespace hecl::blender diff --git a/hecl/include/hecl/CVar.hpp b/hecl/include/hecl/CVar.hpp index 67fc742c5..8e1d1012a 100644 --- a/hecl/include/hecl/CVar.hpp +++ b/hecl/include/hecl/CVar.hpp @@ -88,7 +88,6 @@ public: bool toBoolean(bool* isValid = nullptr) const; int32_t toSigned(bool* isValid = nullptr) const; uint32_t toUnsigned(bool* isValid = nullptr) const; - std::wstring toWideLiteral(bool* isValid = nullptr) const; std::string toLiteral(bool* isValid = nullptr) const; template @@ -106,9 +105,7 @@ public: bool fromInteger(int32_t val); bool fromInteger(uint32_t val); bool fromLiteral(std::string_view val); - bool fromLiteral(std::wstring_view val); bool fromLiteralToType(std::string_view val); - bool fromLiteralToType(std::wstring_view val); bool isVec2f() const { return m_type == EType::Vec2f; } bool isVec2d() const { return m_type == EType::Vec2d; } @@ -153,7 +150,6 @@ public: void addListener(ListenerFunc func) { m_listeners.push_back(std::move(func)); } bool isValidInput(std::string_view input) const; - bool isValidInput(std::wstring_view input) const; private: CVar(std::string_view name, std::string_view help, EType type) : m_help(help), m_type(type) { m_name = name; } @@ -239,12 +235,6 @@ inline bool CVar::toValue(uint32_t& value) const { return isValid; } template <> -inline bool CVar::toValue(std::wstring& value) const { - bool isValid = false; - value = toWideLiteral(&isValid); - return isValid; -} -template <> inline bool CVar::toValue(std::string& value) const { bool isValid = false; value = toLiteral(&isValid); @@ -299,10 +289,6 @@ template <> inline bool CVar::fromValue(std::string_view val) { return fromLiteral(val); } -template <> -inline bool CVar::fromValue(std::wstring_view val) { - return fromLiteral(val); -} class CVarUnlocker { CVar* m_cvar; diff --git a/hecl/include/hecl/CVarManager.hpp b/hecl/include/hecl/CVarManager.hpp index 64b333841..1576ce327 100644 --- a/hecl/include/hecl/CVarManager.hpp +++ b/hecl/include/hecl/CVarManager.hpp @@ -6,7 +6,6 @@ #include #include "hecl/CVar.hpp" -#include "hecl/SystemChar.hpp" namespace hecl { namespace Runtime { @@ -107,7 +106,7 @@ public: void setCheatsEnabled(bool v, bool setDeserialized = false); bool restartRequired() const; - void parseCommandLine(const std::vector& args); + void parseCommandLine(const std::vector& args); private: bool suppressDeveloper(); diff --git a/hecl/include/hecl/ClientProcess.hpp b/hecl/include/hecl/ClientProcess.hpp index e557c422b..bafb555ac 100644 --- a/hecl/include/hecl/ClientProcess.hpp +++ b/hecl/include/hecl/ClientProcess.hpp @@ -10,7 +10,6 @@ #include "hecl/Blender/Token.hpp" #include "hecl/hecl.hpp" -#include "hecl/SystemChar.hpp" #include @@ -22,7 +21,7 @@ namespace hecl { class MultiProgressPrinter; extern int CpuCountOverride; -void SetCpuCountOverride(int argc, const SystemChar** argv); +void SetCpuCountOverride(int argc, char** argv); class ClientProcess { std::mutex m_mutex; diff --git a/hecl/include/hecl/Console.hpp b/hecl/include/hecl/Console.hpp index a0aee7fab..a5a6532a7 100644 --- a/hecl/include/hecl/Console.hpp +++ b/hecl/include/hecl/Console.hpp @@ -38,12 +38,8 @@ class Console { ~LogVisorAdapter() override = default; void report(const char* modName, logvisor::Level severity, fmt::string_view format, fmt::format_args args) override; - void report(const char* modName, logvisor::Level severity, fmt::wstring_view format, - fmt::wformat_args args) override; void reportSource(const char* modName, logvisor::Level severity, const char* file, unsigned linenum, fmt::string_view format, fmt::format_args args) override; - void reportSource(const char* modName, logvisor::Level severity, const char* file, unsigned linenum, - fmt::wstring_view format, fmt::wformat_args args) override; }; public: diff --git a/hecl/include/hecl/Database.hpp b/hecl/include/hecl/Database.hpp index 1b6c426fe..d528a4623 100644 --- a/hecl/include/hecl/Database.hpp +++ b/hecl/include/hecl/Database.hpp @@ -55,7 +55,7 @@ class IDataSpec { public: IDataSpec(const DataSpecEntry* specEntry) : m_specEntry(specEntry) {} virtual ~IDataSpec() = default; - using FCookProgress = std::function; + using FCookProgress = std::function; /** * @brief Extract Pass Info @@ -64,8 +64,8 @@ public: * reverses the cooking process by emitting editable resources */ struct ExtractPassInfo { - SystemString srcpath; - std::vector extractArgs; + std::string srcpath; + std::vector extractArgs; bool force; }; @@ -76,8 +76,8 @@ public: * to be extracted */ struct ExtractReport { - SystemString name; - SystemString desc; + std::string name; + std::string desc; std::vector childOpts; }; @@ -129,12 +129,12 @@ extern std::vector DATA_SPEC_REGISTRY; * Auto-registers with data spec registry */ struct DataSpecEntry { - SystemStringView m_name; - SystemStringView m_desc; - SystemStringView m_pakExt; + std::string_view m_name; + std::string_view m_desc; + std::string_view m_pakExt; std::function(Project&, DataSpecTool)> m_factory; - DataSpecEntry(SystemStringView name, SystemStringView desc, SystemStringView pakExt, + DataSpecEntry(std::string_view name, std::string_view desc, std::string_view pakExt, std::function(Project& project, DataSpecTool)>&& factory) : m_name(name), m_desc(desc), m_pakExt(pakExt), m_factory(std::move(factory)) {} }; @@ -150,7 +150,7 @@ struct DataSpecEntry { */ class ObjectBase { friend class Project; - SystemString m_path; + std::string m_path; protected: /** @@ -209,9 +209,9 @@ protected: virtual FourCC getType() const { return FourCC("NULL"); } public: - ObjectBase(SystemStringView path) : m_path(path) {} + ObjectBase(std::string_view path) : m_path(path) {} - SystemStringView getPath() const { return m_path; } + std::string_view getPath() const { return m_path; } }; /** @@ -251,12 +251,12 @@ public: * opening a locked handle for read/write transactions */ class ConfigFile { - SystemString m_filepath; + std::string m_filepath; std::vector m_lines; UniqueFilePtr m_lockedFile; public: - ConfigFile(const Project& project, SystemStringView name, SystemStringView subdir = _SYS_STR("/.hecl/")); + ConfigFile(const Project& project, std::string_view name, std::string_view subdir = "/.hecl/"); std::vector& lockAndRead(); void addLine(std::string_view line); void removeLine(std::string_view refLine); @@ -360,14 +360,14 @@ public: * @param specs String(s) representing unique spec(s) from getDataSpecs * @return true on success */ - bool enableDataSpecs(const std::vector& specs); + bool enableDataSpecs(const std::vector& specs); /** * @brief Disable persistent user preference for particular spec string(s) * @param specs String(s) representing unique spec(s) from getDataSpecs * @return true on success */ - bool disableDataSpecs(const std::vector& specs); + bool disableDataSpecs(const std::vector& specs); /** * @brief Begin cook process for specified directory diff --git a/hecl/include/hecl/MultiProgressPrinter.hpp b/hecl/include/hecl/MultiProgressPrinter.hpp index 78292acdd..16c6aac38 100644 --- a/hecl/include/hecl/MultiProgressPrinter.hpp +++ b/hecl/include/hecl/MultiProgressPrinter.hpp @@ -6,8 +6,6 @@ #include #include -#include "hecl/SystemChar.hpp" - #if _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN @@ -32,7 +30,7 @@ class MultiProgressPrinter { } m_termInfo; struct ThreadStat { - hecl::SystemString m_message, m_submessage; + std::string m_message, m_submessage; float m_factor = 0.f; bool m_active = false; void print(const TermInfo& tinfo) const; @@ -56,7 +54,8 @@ class MultiProgressPrinter { public: MultiProgressPrinter(bool activate = false); ~MultiProgressPrinter(); - void print(std::optional message, std::optional submessage, + void print(std::optional message, + std::optional submessage, float factor = -1.f, int threadIdx = 0) const; void setMainFactor(float factor) const; diff --git a/hecl/include/hecl/Pipeline.hpp b/hecl/include/hecl/Pipeline.hpp index 39e9e8dd4..4b61b37e8 100644 --- a/hecl/include/hecl/Pipeline.hpp +++ b/hecl/include/hecl/Pipeline.hpp @@ -408,7 +408,7 @@ class PipelineConverter : public PipelineConverterBase { public: PipelineConverter(boo::IGraphicsDataFactory* gfxF) : PipelineConverterBase(gfxF, P::Enum) {} #if HECL_RUNTIME - bool loadFromFile(FactoryCtx& ctx, const hecl::SystemChar* path); + bool loadFromFile(FactoryCtx& ctx, const char* path); #endif template diff --git a/hecl/include/hecl/Runtime.hpp b/hecl/include/hecl/Runtime.hpp index 54b7469c2..0d0e0780d 100644 --- a/hecl/include/hecl/Runtime.hpp +++ b/hecl/include/hecl/Runtime.hpp @@ -3,8 +3,6 @@ #include #include -#include "hecl/SystemChar.hpp" - #include #include @@ -17,17 +15,17 @@ namespace Runtime { * @brief Per-platform file store resolution */ class FileStoreManager { - SystemString m_domain; - SystemString m_storeRoot; + std::string m_domain; + std::string m_storeRoot; public: - FileStoreManager(SystemStringView domain); - SystemStringView getDomain() const { return m_domain; } + FileStoreManager(std::string_view domain); + std::string_view getDomain() const { return m_domain; } /** * @brief Returns the full path to the file store, including domain * @return Full path to store e.g /home/foo/.hecl/bar */ - SystemStringView getStoreRoot() const { return m_storeRoot; } + std::string_view getStoreRoot() const { return m_storeRoot; } }; /** diff --git a/hecl/include/hecl/SteamFinder.hpp b/hecl/include/hecl/SteamFinder.hpp index 501ec3781..19ce6fa5b 100644 --- a/hecl/include/hecl/SteamFinder.hpp +++ b/hecl/include/hecl/SteamFinder.hpp @@ -1,9 +1,9 @@ #pragma once -#include "hecl/SystemChar.hpp" +#include namespace hecl { -hecl::SystemString FindCommonSteamApp(const hecl::SystemChar* name); +std::string FindCommonSteamApp(const char* name); -} +} // namespace hecl diff --git a/hecl/include/hecl/SystemChar.hpp b/hecl/include/hecl/SystemChar.hpp index 124c28332..ccde87455 100644 --- a/hecl/include/hecl/SystemChar.hpp +++ b/hecl/include/hecl/SystemChar.hpp @@ -11,7 +11,6 @@ #ifndef NOMINMAX #define NOMINMAX #endif -#include #endif #include #include @@ -20,38 +19,4 @@ namespace hecl { -#if _WIN32 && UNICODE -#define HECL_UCS2 1 -#endif - -#if HECL_UCS2 -typedef wchar_t SystemChar; -typedef std::wstring SystemString; -typedef std::wstring_view SystemStringView; -static inline void ToLower(SystemString& str) { std::transform(str.begin(), str.end(), str.begin(), towlower); } -static inline void ToUpper(SystemString& str) { std::transform(str.begin(), str.end(), str.begin(), towupper); } -#ifndef _SYS_STR -#define _SYS_STR(val) L##val -#endif -typedef struct _stat Sstat; -#else -typedef char SystemChar; -typedef std::string SystemString; -typedef std::string_view SystemStringView; -static inline void ToLower(SystemString& str) { - std::transform(str.begin(), str.end(), str.begin(), - [](SystemChar c) { return std::tolower(static_cast(c)); }); -} -static inline void ToUpper(SystemString& str) { - std::transform(str.begin(), str.end(), str.begin(), - [](SystemChar c) { return std::toupper(static_cast(c)); }); -} -#ifndef _SYS_STR -#define _SYS_STR(val) val -#endif -typedef struct stat Sstat; -#endif - -constexpr size_t StrLen(const SystemChar* str) { return std::char_traits::length(str); } - } // namespace hecl diff --git a/hecl/include/hecl/hecl.hpp b/hecl/include/hecl/hecl.hpp index be6d8812a..74ba3b2dc 100644 --- a/hecl/include/hecl/hecl.hpp +++ b/hecl/include/hecl/hecl.hpp @@ -25,6 +25,7 @@ extern "C" int rep_closefrom(int lower); #include #include #include "winsupport.hpp" +#include #endif #include @@ -41,7 +42,6 @@ extern "C" int rep_closefrom(int lower); #include "logvisor/logvisor.hpp" #include "athena/Global.hpp" #include "xxhash/xxhash.h" -#include "SystemChar.hpp" #include "FourCC.hpp" #if defined(__has_feature) @@ -92,10 +92,7 @@ extern unsigned VerbosityLevel; extern bool GuiMode; extern logvisor::Module LogModule; -std::string WideToUTF8(std::wstring_view src); std::string Char16ToUTF8(std::u16string_view src); -std::wstring Char16ToWide(std::u16string_view src); -std::wstring UTF8ToWide(std::string_view src); std::u16string UTF8ToChar16(std::string_view src); /* humanize_number port from FreeBSD's libutil */ @@ -107,84 +104,29 @@ ENABLE_BITWISE_ENUM(HNScale) std::string HumanizeNumber(int64_t quotient, size_t len, const char* suffix, int scale, HNFlags flags); -#if HECL_UCS2 -class SystemUTF8Conv { - std::string m_utf8; +static inline void ToLower(std::string& str) { + std::transform(str.begin(), str.end(), str.begin(), + [](char c) { return std::tolower(static_cast(c)); }); +} +static inline void ToUpper(std::string& str) { + std::transform(str.begin(), str.end(), str.begin(), + [](char c) { return std::toupper(static_cast(c)); }); +} -public: - explicit SystemUTF8Conv(SystemStringView str) : m_utf8(WideToUTF8(str)) {} - - std::string_view str() const { return m_utf8; } - const char* c_str() const { return m_utf8.c_str(); } - - friend std::string operator+(const SystemUTF8Conv& lhs, std::string_view rhs) { return lhs.m_utf8 + rhs.data(); } - friend std::string operator+(std::string_view lhs, const SystemUTF8Conv& rhs) { - return std::string(lhs).append(rhs.m_utf8); - } -}; - -class SystemStringConv { - std::wstring m_sys; - -public: - explicit SystemStringConv(std::string_view str) : m_sys(UTF8ToWide(str)) {} - - SystemStringView sys_str() const { return m_sys; } - const SystemChar* c_str() const { return m_sys.c_str(); } - - friend std::wstring operator+(const SystemStringConv& lhs, const std::wstring_view rhs) { - return lhs.m_sys + rhs.data(); - } - friend std::wstring operator+(std::wstring_view lhs, const SystemStringConv& rhs) { - return std::wstring(lhs).append(rhs.m_sys); - } -}; - -inline hecl::SystemString UTF8StringToSysString(std::string_view src) { return UTF8ToWide(src); } +#if _WIN32 +using Sstat = struct ::_stat64; #else -class SystemUTF8Conv { - std::string_view m_utf8; - -public: - explicit SystemUTF8Conv(SystemStringView str) : m_utf8(str) {} - - std::string_view str() const { return m_utf8; } - const char* c_str() const { return m_utf8.data(); } - - friend std::string operator+(const SystemUTF8Conv& lhs, std::string_view rhs) { - return std::string(lhs.m_utf8).append(rhs); - } - friend std::string operator+(std::string_view lhs, const SystemUTF8Conv& rhs) { - return std::string(lhs).append(rhs.m_utf8); - } -}; - -class SystemStringConv { - std::string_view m_sys; - -public: - explicit SystemStringConv(std::string_view str) : m_sys(str) {} - - SystemStringView sys_str() const { return m_sys; } - const SystemChar* c_str() const { return m_sys.data(); } - - friend std::string operator+(const SystemStringConv& lhs, std::string_view rhs) { - return std::string(lhs.m_sys).append(rhs); - } - friend std::string operator+(std::string_view lhs, const SystemStringConv& rhs) { - return std::string(lhs).append(rhs.m_sys); - } -}; - -inline hecl::SystemString UTF8StringToSysString(std::string src) { return src; } +using SStat = struct stat; #endif -void SanitizePath(std::string& path); -void SanitizePath(std::wstring& path); +constexpr size_t StrLen(const char* str) { return std::char_traits::length(str); } -inline void Unlink(const SystemChar* file) { +void SanitizePath(std::string& path); + +inline void Unlink(const char* file) { #if _WIN32 - _wunlink(file); + const nowide::wstackstring wfile(file); + _wunlink(wfile.get()); #else unlink(file); #endif @@ -193,7 +135,8 @@ inline void Unlink(const SystemChar* file) { inline void MakeDir(const char* dir) { #if _WIN32 HRESULT err; - if (!CreateDirectoryA(dir, NULL)) + const nowide::wstackstring wdir(dir); + if (!CreateDirectoryW(wdir.get(), NULL)) if ((err = GetLastError()) != ERROR_ALREADY_EXISTS) LogModule.report(logvisor::Fatal, FMT_STRING("MakeDir({})"), dir); #else @@ -203,62 +146,68 @@ inline void MakeDir(const char* dir) { #endif } -#if _WIN32 -inline void MakeDir(const wchar_t* dir) { - HRESULT err; - if (!CreateDirectoryW(dir, NULL)) - if ((err = GetLastError()) != ERROR_ALREADY_EXISTS) - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("MakeDir({})")), dir); -} -#endif +int RecursiveMakeDir(const char* dir); -int RecursiveMakeDir(const SystemChar* dir); - -inline const SystemChar* GetEnv(const SystemChar* name) { +inline std::optional GetEnv(const char* name) { #if WINDOWS_STORE return nullptr; #else -#if HECL_UCS2 - return _wgetenv(name); +#if _WIN32 + size_t sz = 0; + const nowide::wshort_stackstring wname(name); + _wgetenv_s(&sz, nullptr, 0, wname.get()); + if (sz == 0) { + return {}; + } + auto wbuf = std::make_unique(sz); + _wgetenv_s(&sz, wbuf.get(), sz, wname.get()); + return nowide::narrow(wbuf.get(), sz); #else return getenv(name); #endif #endif } -inline SystemChar* Getcwd(SystemChar* buf, int maxlen) { -#if HECL_UCS2 - return _wgetcwd(buf, maxlen); +inline char* Getcwd(char* buf, int maxlen) { +#if _WIN32 + auto wbuf = std::make_unique(maxlen); + wchar_t* result = _wgetcwd(wbuf.get(), maxlen); + if (result == nullptr) { + return nullptr; + } + return nowide::narrow(buf, maxlen, wbuf.get()); #else return getcwd(buf, maxlen); #endif } -SystemString GetcwdStr(); +std::string GetcwdStr(); -inline bool IsAbsolute(SystemStringView path) { +inline bool IsAbsolute(std::string_view path) { #if _WIN32 - if (path.size() && (path[0] == _SYS_STR('\\') || path[0] == _SYS_STR('/'))) + if (path.size() && (path[0] == '\\' || path[0] == '/')) return true; - if (path.size() >= 2 && iswalpha(path[0]) && path[1] == _SYS_STR(':')) + if (path.size() >= 2 && iswalpha(path[0]) && path[1] == ':') return true; #else - if (path.size() && path[0] == _SYS_STR('/')) + if (path.size() && path[0] == '/') return true; #endif return false; } -const SystemChar* GetTmpDir(); +std::string GetTmpDir(); #if !WINDOWS_STORE -int RunProcess(const SystemChar* path, const SystemChar* const args[]); +int RunProcess(const char* path, const char* const args[]); #endif enum class FileLockType { None = 0, Read, Write }; -inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLockType lock = FileLockType::None) { -#if HECL_UCS2 - FILE* fp = _wfopen(path, mode); +inline FILE* Fopen(const char* path, const char* mode, FileLockType lock = FileLockType::None) { +#if _WIN32 + const nowide::wstackstring wpath(path); + const nowide::wshort_stackstring wmode(mode); + FILE* fp = _wfopen(wpath.get(), wmode.get()); if (!fp) return nullptr; #else @@ -286,7 +235,7 @@ struct UniqueFileDeleter { }; using UniqueFilePtr = std::unique_ptr; -inline UniqueFilePtr FopenUnique(const SystemChar* path, const SystemChar* mode, +inline UniqueFilePtr FopenUnique(const char* path, const char* mode, FileLockType lock = FileLockType::None) { return UniqueFilePtr{Fopen(path, mode, lock)}; } @@ -311,76 +260,72 @@ inline int64_t FTell(FILE* fp) { #endif } -inline int Rename(const SystemChar* oldpath, const SystemChar* newpath) { -#if HECL_UCS2 - // return _wrename(oldpath, newpath); - return MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) == 0; +inline int Rename(const char* oldpath, const char* newpath) { +#if _WIN32 + const nowide::wstackstring woldpath(oldpath); + const nowide::wstackstring wnewpath(newpath); + return MoveFileExW(woldpath.get(), wnewpath.get(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) == 0; #else return rename(oldpath, newpath); #endif } -inline int Stat(const SystemChar* path, Sstat* statOut) { -#if HECL_UCS2 +inline int Stat(const char* path, Sstat* statOut) { +#if _WIN32 size_t pos; - for (pos = 0; pos < 3 && path[pos] != L'\0'; ++pos) {} - if (pos == 2 && path[1] == L':') { - SystemChar fixPath[4] = {path[0], L':', L'/', L'\0'}; - return _wstat(fixPath, statOut); + const nowide::wstackstring wpath(path); + const wchar_t* wpathP = wpath.get(); + for (pos = 0; pos < 3 && wpathP[pos] != L'\0'; ++pos) {} + if (pos == 2 && wpathP[1] == L':') { + wchar_t fixPath[4] = {wpathP[0], L':', L'/', L'\0'}; + return _wstat64(fixPath, statOut); } - return _wstat(path, statOut); + return _wstat64(wpath.get(), statOut); #else return stat(path, statOut); #endif } -inline int StrCmp(const SystemChar* str1, const SystemChar* str2) { +inline int StrCmp(const char* str1, const char* str2) { if (!str1 || !str2) return str1 != str2; -#if HECL_UCS2 - return wcscmp(str1, str2); -#else return strcmp(str1, str2); -#endif } -inline int StrNCmp(const SystemChar* str1, const SystemChar* str2, size_t count) { +inline int StrNCmp(const char* str1, const char* str2, size_t count) { if (!str1 || !str2) return str1 != str2; - return std::char_traits::compare(str1, str2, count); + return std::char_traits::compare(str1, str2, count); } -inline int StrCaseCmp(const SystemChar* str1, const SystemChar* str2) { +inline int StrCaseCmp(const char* str1, const char* str2) { if (!str1 || !str2) return str1 != str2; -#if HECL_UCS2 - return _wcsicmp(str1, str2); +#if _WIN32 + return _stricmp(str1, str2); #else return strcasecmp(str1, str2); #endif } -inline unsigned long StrToUl(const SystemChar* str, SystemChar** endPtr, int base) { -#if HECL_UCS2 - return wcstoul(str, endPtr, base); -#else +inline unsigned long StrToUl(const char* str, char** endPtr, int base) { return strtoul(str, endPtr, base); -#endif } -inline bool CheckFreeSpace(const SystemChar* path, size_t reqSz) { +inline bool CheckFreeSpace(const char* path, size_t reqSz) { #if _WIN32 ULARGE_INTEGER freeBytes; wchar_t buf[1024]; wchar_t* end; - DWORD ret = GetFullPathNameW(path, 1024, buf, &end); + const nowide::wstackstring wpath(path); + DWORD ret = GetFullPathNameW(wpath.get(), 1024, buf, &end); if (!ret || ret > 1024) - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("GetFullPathNameW {}")), path); + LogModule.report(logvisor::Fatal, FMT_STRING("GetFullPathNameW {}"), path); if (end) end[0] = L'\0'; if (!GetDiskFreeSpaceExW(buf, &freeBytes, nullptr, nullptr)) - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("GetDiskFreeSpaceExW {}: {}")), path, GetLastError()); + LogModule.report(logvisor::Fatal, FMT_STRING("GetDiskFreeSpaceExW {}: {}"), path, GetLastError()); return reqSz < freeBytes.QuadPart; #else struct statvfs svfs; @@ -390,11 +335,12 @@ inline bool CheckFreeSpace(const SystemChar* path, size_t reqSz) { #endif } -inline bool PathRelative(const SystemChar* path) { +inline bool PathRelative(const char* path) { if (!path || !path[0]) return false; #if _WIN32 && !WINDOWS_STORE - return PathIsRelative(path); + const nowide::wstackstring wpath(path); + return PathIsRelativeW(wpath.get()); #else return path[0] != '/'; #endif @@ -428,12 +374,6 @@ inline int ConsoleWidth(bool* ok = nullptr) { class MultiProgressPrinter; class ProjectRootPath; -using SystemRegex = std::basic_regex; -using SystemRegexIterator = std::regex_iterator; -using SystemRegexMatch = std::match_results; -using SystemViewRegexMatch = std::match_results; -using SystemRegexTokenIterator = std::regex_token_iterator; - /** * @brief Hash representation used for all storable and comparable objects * @@ -451,7 +391,6 @@ public: constexpr Hash(uint64_t hashin) noexcept : hash(hashin) {} explicit Hash(const void* buf, size_t len) noexcept : hash(XXH64(buf, len, 0)) {} explicit Hash(std::string_view str) noexcept : hash(XXH64(str.data(), str.size(), 0)) {} - explicit Hash(std::wstring_view str) noexcept : hash(XXH64(str.data(), str.size() * 2, 0)) {} constexpr uint32_t val32() const noexcept { return uint32_t(hash) ^ uint32_t(hash >> 32); } constexpr uint64_t val64() const noexcept { return uint64_t(hash); } @@ -505,7 +444,7 @@ public: * @brief Case-insensitive comparator for std::map sorting */ struct CaseInsensitiveCompare { - // Allow heterogenous lookup with maps that use this comparator. + // Allow heterogeneous lookup with maps that use this comparator. using is_transparent = void; bool operator()(std::string_view lhs, std::string_view rhs) const { @@ -513,12 +452,6 @@ struct CaseInsensitiveCompare { return std::tolower(static_cast(lhs)) < std::tolower(static_cast(rhs)); }); } - - bool operator()(std::wstring_view lhs, std::wstring_view rhs) const { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), [](wchar_t lhs, wchar_t rhs) { - return std::towlower(lhs) < std::towlower(rhs); - }); - } }; /** @@ -528,33 +461,28 @@ class DirectoryEnumerator { public: enum class Mode { Native, DirsSorted, FilesSorted, DirsThenFilesSorted }; struct Entry { - hecl::SystemString m_path; - hecl::SystemString m_name; + std::string m_path; + std::string m_name; size_t m_fileSz; bool m_isDir; - Entry(hecl::SystemString path, const hecl::SystemChar* name, size_t sz, bool isDir) - : m_path(std::move(path)), m_name(name), m_fileSz(sz), m_isDir(isDir) {} + Entry(std::string path, std::string name, size_t sz, bool isDir) + : m_path(std::move(path)), m_name(std::move(name)), m_fileSz(sz), m_isDir(isDir) {} }; private: std::vector m_entries; public: - DirectoryEnumerator(SystemStringView path, Mode mode = Mode::DirsThenFilesSorted, bool sizeSort = false, + DirectoryEnumerator(std::string_view path, Mode mode = Mode::DirsThenFilesSorted, bool sizeSort = false, bool reverse = false, bool noHidden = false); - explicit operator bool() const { return m_entries.size() != 0; } - size_t size() const { return m_entries.size(); } - std::vector::const_iterator begin() const { return m_entries.cbegin(); } - std::vector::const_iterator end() const { return m_entries.cend(); } + explicit operator bool() const { return !m_entries.empty(); } + [[nodiscard]] size_t size() const { return m_entries.size(); } + [[nodiscard]] std::vector::const_iterator begin() const { return m_entries.cbegin(); } + [[nodiscard]] std::vector::const_iterator end() const { return m_entries.cend(); } }; -/** - * @brief Build list of common OS-specific directories - */ -std::vector> GetSystemLocations(); - /** * @brief Special ProjectRootPath class for opening Database::Project instances * @@ -562,7 +490,7 @@ std::vector> GetSystemLocations(); * resolve canonicalized relative paths. */ class ProjectRootPath { - SystemString m_projRoot; + std::string m_projRoot; Hash m_hash = 0; public: @@ -582,7 +510,7 @@ public: * @brief Construct a representation of a project root path * @param path valid filesystem-path (relative or absolute) to project root */ - ProjectRootPath(SystemStringView path) : m_projRoot(path) { + ProjectRootPath(std::string_view path) : m_projRoot(path) { SanitizePath(m_projRoot); m_hash = Hash(m_projRoot); } @@ -591,29 +519,29 @@ public: * @brief Access fully-canonicalized absolute path * @return Absolute path reference */ - SystemStringView getAbsolutePath() const { return m_projRoot; } + std::string_view getAbsolutePath() const { return m_projRoot; } /** * @brief Make absolute path project relative * @param absPath Absolute path - * @return SystemString of path relative to project root + * @return std::string of path relative to project root */ - SystemString getProjectRelativeFromAbsolute(SystemStringView absPath) const { + std::string getProjectRelativeFromAbsolute(std::string_view absPath) const { if (absPath.size() > m_projRoot.size()) { - SystemString absPathForward(absPath); - for (SystemChar& ch : absPathForward) - if (ch == _SYS_STR('\\')) - ch = _SYS_STR('/'); + std::string absPathForward(absPath); + for (char& ch : absPathForward) + if (ch == '\\') + ch = '/'; if (!absPathForward.compare(0, m_projRoot.size(), m_projRoot)) { auto beginIt = absPathForward.cbegin() + m_projRoot.size(); - while (*beginIt == _SYS_STR('/')) + while (*beginIt == '/') ++beginIt; - return SystemString(beginIt, absPathForward.cend()); + return std::string(beginIt, absPathForward.cend()); } } - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to resolve '{}' as project relative '{}'")), absPath, + LogModule.report(logvisor::Fatal, FMT_STRING("unable to resolve '{}' as project relative '{}'"), absPath, m_projRoot); - return SystemString(); + return std::string(); } /** @@ -636,9 +564,9 @@ public: * @brief Obtain c-string of final path component * @return Final component c-string (may be empty) */ - SystemStringView getLastComponent() const { - size_t pos = m_projRoot.rfind(_SYS_STR('/')); - if (pos == SystemString::npos) + std::string_view getLastComponent() const { + size_t pos = m_projRoot.rfind('/'); + if (pos == std::string::npos) return {}; return {m_projRoot.c_str() + pos + 1, size_t(m_projRoot.size() - pos - 1)}; } @@ -659,30 +587,15 @@ public: */ class ProjectPath { Database::Project* m_proj = nullptr; - SystemString m_absPath; - SystemString m_relPath; - SystemString m_auxInfo; + std::string m_absPath; + std::string m_relPath; + std::string m_auxInfo; Hash m_hash = 0; -#if HECL_UCS2 - std::string m_utf8AbsPath; - std::string m_utf8RelPath; - std::string m_utf8AuxInfo; -#endif void ComputeHash() { -#if HECL_UCS2 - m_utf8AbsPath = WideToUTF8(m_absPath); - m_utf8RelPath = WideToUTF8(m_relPath); - m_utf8AuxInfo = WideToUTF8(m_auxInfo); - if (m_utf8AuxInfo.size()) - m_hash = Hash(m_utf8RelPath + '|' + m_utf8AuxInfo); - else - m_hash = Hash(m_utf8RelPath); -#else if (m_auxInfo.size()) m_hash = Hash(m_relPath + '|' + m_auxInfo); else m_hash = Hash(m_relPath); -#endif } public: @@ -706,10 +619,6 @@ public: m_absPath.clear(); m_relPath.clear(); m_hash = 0; -#if HECL_UCS2 - m_utf8AbsPath.clear(); - m_utf8RelPath.clear(); -#endif } /** @@ -717,26 +626,16 @@ public: * @param project previously constructed Project to use root path of * @param path valid filesystem-path (relative or absolute) to subpath */ - ProjectPath(Database::Project& project, SystemStringView path) { assign(project, path); } - void assign(Database::Project& project, SystemStringView path); - -#if HECL_UCS2 ProjectPath(Database::Project& project, std::string_view path) { assign(project, path); } void assign(Database::Project& project, std::string_view path); -#endif /** * @brief Construct a project subpath representation within another subpath * @param parentPath previously constructed ProjectPath which ultimately connects to a ProjectRootPath * @param path valid filesystem-path (relative or absolute) to subpath */ - ProjectPath(const ProjectPath& parentPath, SystemStringView path) { assign(parentPath, path); } - void assign(const ProjectPath& parentPath, SystemStringView path); - -#if HECL_UCS2 ProjectPath(const ProjectPath& parentPath, std::string_view path) { assign(parentPath, path); } void assign(const ProjectPath& parentPath, std::string_view path); -#endif /** * @brief Determine if ProjectPath represents project root directory @@ -750,22 +649,22 @@ public: * @param replace remove existing extension (if any) before appending new extension * @return new path with extension */ - ProjectPath getWithExtension(const SystemChar* ext, bool replace = false) const; + ProjectPath getWithExtension(const char* ext, bool replace = false) const; /** * @brief Access fully-canonicalized absolute path * @return Absolute path reference */ - SystemStringView getAbsolutePath() const { return m_absPath; } + std::string_view getAbsolutePath() const { return m_absPath; } /** * @brief Access fully-canonicalized project-relative path * @return Relative pointer to within absolute-path or "." for project root-directory (use isRoot to detect) */ - SystemStringView getRelativePath() const { + std::string_view getRelativePath() const { if (m_relPath.size()) return m_relPath; - static const SystemString dot = _SYS_STR("."); + static const std::string dot = "."; return dot; } @@ -783,47 +682,35 @@ public: * This will not resolve outside the project root (error in that case) */ ProjectPath getParentPath() const { - if (m_relPath == _SYS_STR(".")) + if (m_relPath == ".") LogModule.report(logvisor::Fatal, FMT_STRING("attempted to resolve parent of root project path")); - size_t pos = m_relPath.rfind(_SYS_STR('/')); - if (pos == SystemString::npos) - return ProjectPath(*m_proj, _SYS_STR("")); - return ProjectPath(*m_proj, SystemString(m_relPath.begin(), m_relPath.begin() + pos)); + size_t pos = m_relPath.rfind('/'); + if (pos == std::string::npos) + return ProjectPath(*m_proj, ""); + return ProjectPath(*m_proj, std::string(m_relPath.begin(), m_relPath.begin() + pos)); } /** * @brief Obtain c-string of final path component (stored within relative path) * @return Final component c-string (may be empty) */ - SystemStringView getLastComponent() const { - size_t pos = m_relPath.rfind(_SYS_STR('/')); - if (pos == SystemString::npos) + std::string_view getLastComponent() const { + size_t pos = m_relPath.rfind('/'); + if (pos == std::string::npos) return m_relPath; return {m_relPath.c_str() + pos + 1, m_relPath.size() - pos - 1}; } - std::string_view getLastComponentUTF8() const { - size_t pos = m_relPath.rfind(_SYS_STR('/')); -#if HECL_UCS2 - if (pos == SystemString::npos) - return m_utf8RelPath; - return {m_utf8RelPath.c_str() + pos + 1, size_t(m_utf8RelPath.size() - pos - 1)}; -#else - if (pos == SystemString::npos) - return m_relPath; - return {m_relPath.c_str() + pos + 1, size_t(m_relPath.size() - pos - 1)}; -#endif - } /** * @brief Obtain c-string of extension of final path component (stored within relative path) * @return Final component extension c-string (may be empty) */ - SystemStringView getLastComponentExt() const { - SystemStringView lastCompOrig = getLastComponent().data(); - const SystemChar* end = lastCompOrig.data() + lastCompOrig.size(); - const SystemChar* lastComp = end; + std::string_view getLastComponentExt() const { + std::string_view lastCompOrig = getLastComponent().data(); + const char* end = lastCompOrig.data() + lastCompOrig.size(); + const char* lastComp = end; while (lastComp != lastCompOrig.data()) { - if (*lastComp == _SYS_STR('.')) + if (*lastComp == '.') return {lastComp + 1, size_t(end - lastComp - 1)}; --lastComp; } @@ -834,51 +721,17 @@ public: * @brief Build vector of project-relative directory/file components * @return Vector of path components */ - std::vector getPathComponents() const { - std::vector ret; + std::vector getPathComponents() const { + std::vector ret; if (m_relPath.empty()) return ret; auto it = m_relPath.cbegin(); - if (*it == _SYS_STR('/')) { - ret.push_back(_SYS_STR("/")); - ++it; - } - hecl::SystemString comp; - for (; it != m_relPath.cend(); ++it) { - if (*it == _SYS_STR('/')) { - if (comp.empty()) - continue; - ret.push_back(std::move(comp)); - comp.clear(); - continue; - } - comp += *it; - } - if (comp.size()) - ret.push_back(std::move(comp)); - return ret; - } - - /** - * @brief Build vector of project-relative directory/file components - * @return Vector of path components encoded as UTF8 - */ - std::vector getPathComponentsUTF8() const { -#if HECL_UCS2 - const std::string& relPath = m_utf8RelPath; -#else - const std::string& relPath = m_relPath; -#endif - std::vector ret; - if (relPath.empty()) - return ret; - auto it = relPath.cbegin(); if (*it == '/') { ret.push_back("/"); ++it; } std::string comp; - for (; it != relPath.cend(); ++it) { + for (; it != m_relPath.cend(); ++it) { if (*it == '/') { if (comp.empty()) continue; @@ -893,53 +746,19 @@ public: return ret; } - /** - * @brief Access fully-canonicalized absolute path in UTF-8 - * @return Absolute path reference - */ - std::string_view getAbsolutePathUTF8() const { -#if HECL_UCS2 - return m_utf8AbsPath; -#else - return m_absPath; -#endif - } - - std::string_view getRelativePathUTF8() const { -#if HECL_UCS2 - return m_utf8RelPath; -#else - return m_relPath; -#endif - } - - SystemStringView getAuxInfo() const { return m_auxInfo; } - - std::string_view getAuxInfoUTF8() const { -#if HECL_UCS2 - return m_utf8AuxInfo; -#else - return m_auxInfo; -#endif - } + std::string_view getAuxInfo() const { return m_auxInfo; } /** * @brief Construct a path with the aux info overwritten with specified string * @param auxStr string to replace existing auxInfo with */ - ProjectPath ensureAuxInfo(SystemStringView auxStr) const { + ProjectPath ensureAuxInfo(std::string_view auxStr) const { if (auxStr.empty()) return ProjectPath(getProject(), getRelativePath()); else - return ProjectPath(getProject(), SystemString(getRelativePath()) + _SYS_STR('|') + auxStr.data()); + return ProjectPath(getProject(), std::string(getRelativePath()) + '|' + auxStr.data()); } -#if HECL_UCS2 - ProjectPath ensureAuxInfo(std::string_view auxStr) const { - return ProjectPath(getProject(), SystemString(getRelativePath()) + _SYS_STR('|') + UTF8ToWide(auxStr)); - } -#endif - template class EncodableString { friend class ProjectPath; @@ -956,20 +775,13 @@ public: operator EncStringView() const { return m_stringView; } }; - EncodableString getEncodableString() const { + EncodableString getEncodableString() const { if (!getAuxInfo().empty()) - return {SystemString(getRelativePath()) + _SYS_STR('|') + getAuxInfo().data()}; + return {std::string(getRelativePath()) + '|' + getAuxInfo().data()}; else return {getRelativePath()}; } - EncodableString getEncodableStringUTF8() const { - if (!getAuxInfo().empty()) - return {std::string(getRelativePathUTF8()) + '|' + getAuxInfoUTF8().data()}; - else - return {getRelativePathUTF8()}; - } - /** * @brief Type of path */ @@ -1027,7 +839,7 @@ public: * @brief Insert directory children into list * @param outPaths list to append children to */ - void getDirChildren(std::map& outPaths) const; + void getDirChildren(std::map& outPaths) const; /** * @brief Construct DirectoryEnumerator set to project path @@ -1046,8 +858,8 @@ public: */ size_t levelCount() const { size_t count = 0; - for (SystemChar ch : m_relPath) - if (ch == _SYS_STR('/') || ch == _SYS_STR('\\')) + for (char ch : m_relPath) + if (ch == '/' || ch == '\\') ++count; return count; } @@ -1066,11 +878,11 @@ public: * directory, creating the final component */ void makeDirChain(bool includeLastComp) const { - std::vector comps = getPathComponents(); + std::vector comps = getPathComponents(); auto end = comps.cend(); if (end != comps.cbegin() && !includeLastComp) --end; - ProjectPath compPath(*m_proj, _SYS_STR(".")); + ProjectPath compPath(*m_proj, "."); for (auto it = comps.cbegin(); it != end; ++it) { compPath = ProjectPath(compPath, *it); compPath.makeDir(); @@ -1103,29 +915,6 @@ public: */ class StringUtils { public: - static bool BeginsWith(SystemStringView str, SystemStringView test) { - if (test.size() > str.size()) - return false; - return str.compare(0, test.size(), test) == 0; - } - - static bool EndsWith(SystemStringView str, SystemStringView test) { - if (test.size() > str.size()) - return false; - return str.compare(str.size() - test.size(), SystemStringView::npos, test) == 0; - } - - static std::string TrimWhitespace(std::string_view str) { - auto bit = str.begin(); - while (bit != str.cend() && std::isspace(static_cast(*bit))) - ++bit; - auto eit = str.end(); - while (eit != str.cbegin() && std::isspace(static_cast(*(eit - 1)))) - --eit; - return {bit, eit}; - } - -#if HECL_UCS2 static bool BeginsWith(std::string_view str, std::string_view test) { if (test.size() > str.size()) return false; @@ -1138,16 +927,15 @@ public: return str.compare(str.size() - test.size(), std::string_view::npos, test) == 0; } - static SystemString TrimWhitespace(SystemStringView str) { + static std::string TrimWhitespace(std::string_view str) { auto bit = str.begin(); - while (bit != str.cend() && std::iswspace(*bit)) + while (bit != str.cend() && std::isspace(static_cast(*bit))) ++bit; auto eit = str.end(); - while (eit != str.cbegin() && std::iswspace(*(eit - 1))) + while (eit != str.cbegin() && std::isspace(static_cast(*(eit - 1)))) --eit; return {bit, eit}; } -#endif }; /** @@ -1180,7 +968,7 @@ public: * @param path absolute or relative file path to search from * @return Newly-constructed root path (bool-evaluating to false if not found) */ -ProjectRootPath SearchForProject(SystemStringView path); +ProjectRootPath SearchForProject(std::string_view path); /** * @brief Search from within provided directory for the project root @@ -1188,7 +976,7 @@ ProjectRootPath SearchForProject(SystemStringView path); * @param subpathOut remainder of provided path assigned to this ProjectPath * @return Newly-constructed root path (bool-evaluating to false if not found) */ -ProjectRootPath SearchForProject(SystemStringView path, SystemString& subpathOut); +ProjectRootPath SearchForProject(std::string_view path, std::string& subpathOut); /** * @brief Test if given path is a PNG (based on file header) @@ -1391,6 +1179,3 @@ struct hash { size_t operator()(const hecl::Hash& val) const noexcept { return val.valSizeT(); } }; } // namespace std - -FMT_CUSTOM_FORMATTER(hecl::SystemUTF8Conv, "{}", obj.str()) -FMT_CUSTOM_FORMATTER(hecl::SystemStringConv, "{}", obj.sys_str()) diff --git a/hecl/lib/Blender/CMakeLists.txt b/hecl/lib/Blender/CMakeLists.txt index f757890ba..2eee92a63 100644 --- a/hecl/lib/Blender/CMakeLists.txt +++ b/hecl/lib/Blender/CMakeLists.txt @@ -1,8 +1,13 @@ set(BLENDER_SOURCES - Connection.cpp - MeshOptimizer.hpp - MeshOptimizer.cpp - SDNARead.cpp - HMDL.cpp) + Connection.cpp + MeshOptimizer.hpp + MeshOptimizer.cpp + SDNARead.cpp + HMDL.cpp) hecl_add_list(Blender BLENDER_SOURCES) + +set(FIND_BLENDER_SOURCES + FindBlender.cpp) + +hecl_add_list(Blender FIND_BLENDER_SOURCES) \ No newline at end of file diff --git a/hecl/lib/Blender/Connection.cpp b/hecl/lib/Blender/Connection.cpp index 109d1eaaf..42c6eb517 100644 --- a/hecl/lib/Blender/Connection.cpp +++ b/hecl/lib/Blender/Connection.cpp @@ -14,6 +14,7 @@ #include #include "hecl/Blender/Connection.hpp" +#include "hecl/Blender/FindBlender.hpp" #include "hecl/Blender/Token.hpp" #include "hecl/Database.hpp" #include "hecl/hecl.hpp" @@ -48,20 +49,9 @@ using namespace std::literals; namespace hecl::blender { -static const uint32_t MinBlenderMajorSearch = 2; -static const uint32_t MaxBlenderMajorSearch = 2; -static const uint32_t MinBlenderMinorSearch = 83; -static const uint32_t MaxBlenderMinorSearch = 92; - logvisor::Module BlenderLog("hecl::blender::Connection"); Token SharedBlenderToken; -#ifdef __APPLE__ -#define DEFAULT_BLENDER_BIN "/Applications/Blender.app/Contents/MacOS/blender" -#else -#define DEFAULT_BLENDER_BIN "blender" -#endif - extern "C" uint8_t HECL_BLENDERSHELL[]; extern "C" size_t HECL_BLENDERSHELL_SZ; @@ -71,21 +61,21 @@ extern "C" size_t HECL_ADDON_SZ; extern "C" uint8_t HECL_STARTUP[]; extern "C" size_t HECL_STARTUP_SZ; -static void InstallBlendershell(const SystemChar* path) { - auto fp = hecl::FopenUnique(path, _SYS_STR("w")); +static void InstallBlendershell(const char* path) { + auto fp = hecl::FopenUnique(path, "w"); if (fp == nullptr) { - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to open {} for writing")), path); + BlenderLog.report(logvisor::Fatal, FMT_STRING("unable to open {} for writing"), path); } std::fwrite(HECL_BLENDERSHELL, 1, HECL_BLENDERSHELL_SZ, fp.get()); } -static void InstallAddon(const SystemChar* path) { - auto fp = hecl::FopenUnique(path, _SYS_STR("wb")); +static void InstallAddon(const char* path) { + auto fp = hecl::FopenUnique(path, "wb"); if (fp == nullptr) { - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to install blender addon at '{}'")), path); + BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to install blender addon at '{}'"), path); } std::fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp.get()); @@ -239,9 +229,8 @@ std::size_t Connection::_writeBuf(const void* buf, std::size_t len) { ProjectPath Connection::_readPath() { std::string path = _readStdString(); if (!path.empty()) { - SystemStringConv pathAbs(path); - SystemString meshPathRel = - getBlendPath().getProject().getProjectRootPath().getProjectRelativeFromAbsolute(pathAbs.sys_str()); + std::string meshPathRel = + getBlendPath().getProject().getProjectRootPath().getProjectRelativeFromAbsolute(path); return ProjectPath(getBlendPath().getProject().getProjectWorkingPath(), meshPathRel); } return {}; @@ -261,7 +250,7 @@ void Connection::_closePipe() { void Connection::_blenderDied() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); - auto errFp = hecl::FopenUnique(m_errPath.c_str(), _SYS_STR("r")); + auto errFp = hecl::FopenUnique(m_errPath.c_str(), "r"); if (errFp != nullptr) { std::fseek(errFp.get(), 0, SEEK_END); @@ -281,7 +270,7 @@ void Connection::_blenderDied() { static std::atomic_bool BlenderFirstInit(false); #if _WIN32 -static bool RegFileExists(const hecl::SystemChar* path) { +static bool RegFileExists(const char* path) { if (!path) return false; hecl::Sstat theStat; @@ -295,16 +284,16 @@ Connection::Connection(int verbosityLevel) { BlenderLog.report(logvisor::Info, FMT_STRING("Establishing BlenderConnection...")); /* Put hecl_blendershell.py in temp dir */ - const SystemChar* TMPDIR = GetTmpDir(); + const std::string TMPDIR = GetTmpDir(); #ifndef _WIN32 signal(SIGPIPE, SIG_IGN); #endif - hecl::SystemString blenderShellPath(TMPDIR); - blenderShellPath += _SYS_STR("/hecl_blendershell.py"); + std::string blenderShellPath(TMPDIR); + blenderShellPath += "/hecl_blendershell.py"; - hecl::SystemString blenderAddonPath(TMPDIR); - blenderAddonPath += _SYS_STR("/hecl_blenderaddon.zip"); + std::string blenderAddonPath(TMPDIR); + blenderAddonPath += "/hecl_blenderaddon.zip"; bool FalseCmp = false; if (BlenderFirstInit.compare_exchange_strong(FalseCmp, true)) { @@ -345,54 +334,16 @@ Connection::Connection(int verbosityLevel) { pipe(m_writepipe.data()); #endif - /* User-specified blender path */ -#if _WIN32 - wchar_t BLENDER_BIN_BUF[2048]; - std::wstring blenderBinBuf; - const wchar_t* blenderBin = _wgetenv(L"BLENDER_BIN"); -#else - const char* blenderBin = getenv("BLENDER_BIN"); -#endif - - /* Steam blender */ - hecl::SystemString steamBlender; - - /* Child process of blender */ -#if _WIN32 - if (!blenderBin || !RegFileExists(blenderBin)) { - /* Environment not set; try steam */ - steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender")); - if (steamBlender.size()) { - steamBlender += _SYS_STR("\\blender.exe"); - blenderBin = steamBlender.c_str(); - } - - if (!RegFileExists(blenderBin)) { - /* No steam; try default */ - wchar_t progFiles[256]; - if (GetEnvironmentVariableW(L"ProgramFiles", progFiles, 256)) { - for (size_t major = MaxBlenderMajorSearch; major >= MinBlenderMajorSearch; --major) { - bool found = false; - for (size_t minor = MaxBlenderMinorSearch; minor >= MinBlenderMinorSearch; --minor) { - _snwprintf(BLENDER_BIN_BUF, 2048, L"%s\\Blender Foundation\\Blender %i.%i\\blender.exe", progFiles, major, - minor); - if (RegFileExists(BLENDER_BIN_BUF)) { - blenderBin = BLENDER_BIN_BUF; - found = true; - break; - } - } - - if (found) { - break; - } - } - } - } + int blenderMajor = 0; + int blenderMinor = 0; + auto blenderBin = blender::FindBlender(blenderMajor, blenderMinor); + if (!blenderBin) { + BlenderLog.report(logvisor::Fatal, FMT_STRING("Failed to locate Blender installation")); } - std::wstring cmdLine = fmt::format(FMT_STRING(L" --background -P \"{}\" -- {} {} {} \"{}\""), blenderShellPath, - uintptr_t(writehandle), uintptr_t(readhandle), verbosityLevel, blenderAddonPath); +#if _WIN32 + std::string cmdLine = fmt::format(FMT_STRING(" --background -P \"{}\" -- {} {} {} \"{}\""), blenderShellPath, + uintptr_t(writehandle), uintptr_t(readhandle), verbosityLevel, blenderAddonPath); STARTUPINFO sinfo = {sizeof(STARTUPINFO)}; HANDLE nulHandle = CreateFileW(L"nul", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sattrs, OPEN_EXISTING, @@ -407,14 +358,16 @@ Connection::Connection(int verbosityLevel) { sinfo.hStdOutput = consoleOutWrite; } - if (!CreateProcessW(blenderBin, cmdLine.data(), nullptr, nullptr, TRUE, NORMAL_PRIORITY_CLASS, nullptr, nullptr, - &sinfo, &m_pinfo)) { + const nowide::wstackstring wblenderBin(blenderBin.value()); + nowide::wstackstring wcmdLine(cmdLine); + if (!CreateProcessW(wblenderBin.get(), wcmdLine.get(), nullptr, nullptr, TRUE, NORMAL_PRIORITY_CLASS, nullptr, + nullptr, &sinfo, &m_pinfo)) { LPWSTR messageBuffer = nullptr; FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr); - BlenderLog.report(logvisor::Fatal, FMT_STRING(L"unable to launch blender from {}: {}"), blenderBin, - messageBuffer); + BlenderLog.report(logvisor::Fatal, FMT_STRING("unable to launch blender from {}: {}"), blenderBin.value(), + nowide::narrow(messageBuffer)); } close(m_writepipe[0]); @@ -475,8 +428,8 @@ Connection::Connection(int verbosityLevel) { /* Try user-specified blender first */ if (blenderBin) { - execlp(blenderBin, blenderBin, "--background", "-P", blenderShellPath.c_str(), "--", readfds.c_str(), - writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), nullptr); + execlp(blenderBin->c_str(), blenderBin->c_str(), "--background", "-P", blenderShellPath.c_str(), "--", + readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), nullptr); if (errno != ENOENT) { errbuf = fmt::format(FMT_STRING("NOLAUNCH {}"), strerror(errno)); _writeStr(errbuf.c_str(), errbuf.size(), m_readpipe[1]); @@ -485,16 +438,15 @@ Connection::Connection(int verbosityLevel) { } /* Try steam */ - steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender")); + steamBlender = hecl::FindCommonSteamApp("Blender"); if (steamBlender.size()) { #ifdef __APPLE__ steamBlender += "/blender.app/Contents/MacOS/blender"; #else steamBlender += "/blender"; #endif - blenderBin = steamBlender.c_str(); - execlp(blenderBin, blenderBin, "--background", "-P", blenderShellPath.c_str(), "--", readfds.c_str(), - writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), nullptr); + execlp(steamBlender.c_str(), steamBlender.c_str(), "--background", "-P", blenderShellPath.c_str(), "--", + readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), nullptr); if (errno != ENOENT) { errbuf = fmt::format(FMT_STRING("NOLAUNCH {}"), strerror(errno)); _writeStr(errbuf.c_str(), errbuf.size(), m_readpipe[1]); @@ -522,11 +474,11 @@ Connection::Connection(int verbosityLevel) { /* Stash error path and unlink existing file */ #if _WIN32 - m_errPath = hecl::SystemString(TMPDIR) + - fmt::format(FMT_STRING(_SYS_STR("/hecl_{:016X}.derp")), (unsigned long long)m_pinfo.dwProcessId); + m_errPath = std::string(TMPDIR) + + fmt::format(FMT_STRING("/hecl_{:016X}.derp"), (unsigned long long)m_pinfo.dwProcessId); #else - m_errPath = hecl::SystemString(TMPDIR) + - fmt::format(FMT_STRING(_SYS_STR("/hecl_{:016X}.derp")), (unsigned long long)m_blenderProc); + m_errPath = std::string(TMPDIR) + + fmt::format(FMT_STRING("/hecl_{:016X}.derp"), (unsigned long long)m_blenderProc); #endif hecl::Unlink(m_errPath.c_str()); @@ -539,25 +491,25 @@ Connection::Connection(int verbosityLevel) { } else if (!lineStr.compare(0, 9, "NOBLENDER")) { _closePipe(); #if _WIN32 - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to find blender at '{}'")), blenderBin); + BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to find blender at '{}'"), blenderBin.value()); #else if (blenderBin) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to find blender at '{}' or '{}'")), blenderBin, + BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to find blender at '{}' or '{}'"), blenderBin, DEFAULT_BLENDER_BIN); else - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to find blender at '{}'")), DEFAULT_BLENDER_BIN); + BlenderLog.report(logvisor::Fatal, FMT_STRING("Unable to find blender at '{}'"), DEFAULT_BLENDER_BIN); #endif } else if (lineStr == "INVALIDBLENDERVER") { _closePipe(); - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Installed blender version must be >= {}.{}")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("Installed blender version must be >= {}.{}"), MinBlenderMajorSearch, MinBlenderMinorSearch); } else if (lineStr == "NOADDON") { _closePipe(); - if (blenderAddonPath != _SYS_STR("SKIPINSTALL")) + if (blenderAddonPath != "SKIPINSTALL") InstallAddon(blenderAddonPath.c_str()); ++installAttempt; if (installAttempt >= 2) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to install blender addon using '{}'")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("unable to install blender addon using '{}'"), blenderAddonPath.c_str()); #ifndef _WIN32 waitpid(pid, nullptr, 0); @@ -565,7 +517,7 @@ Connection::Connection(int verbosityLevel) { continue; } else if (lineStr == "ADDONINSTALLED") { _closePipe(); - blenderAddonPath = _SYS_STR("SKIPINSTALL"); + blenderAddonPath = "SKIPINSTALL"; #ifndef _WIN32 waitpid(pid, nullptr, 0); #endif @@ -654,7 +606,7 @@ bool Connection::createBlend(const ProjectPath& path, BlendType type) { FMT_STRING("BlenderConnection::createBlend() musn't be called with stream active")); return false; } - _writeStr(fmt::format(FMT_STRING("CREATE \"{}\" {}"), path.getAbsolutePathUTF8(), BlendTypeStrs[int(type)])); + _writeStr(fmt::format(FMT_STRING("CREATE \"{}\" {}"), path.getAbsolutePath(), BlendTypeStrs[int(type)])); if (_isFinished()) { /* Delete immediately in case save doesn't occur */ hecl::Unlink(path.getAbsolutePath().data()); @@ -673,7 +625,7 @@ bool Connection::openBlend(const ProjectPath& path, bool force) { } if (!force && path == m_loadedBlend) return true; - _writeStr(fmt::format(FMT_STRING("OPEN \"{}\""), path.getAbsolutePathUTF8())); + _writeStr(fmt::format(FMT_STRING("OPEN \"{}\""), path.getAbsolutePath())); if (_isFinished()) { m_loadedBlend = path; _writeStr("GETTYPE"); @@ -711,7 +663,7 @@ bool Connection::saveBlend() { void Connection::deleteBlend() { if (m_loadedBlend) { hecl::Unlink(m_loadedBlend.getAbsolutePath().data()); - BlenderLog.report(logvisor::Info, FMT_STRING(_SYS_STR("Deleted '{}'")), m_loadedBlend.getAbsolutePath()); + BlenderLog.report(logvisor::Info, FMT_STRING("Deleted '{}'"), m_loadedBlend.getAbsolutePath()); m_loadedBlend = ProjectPath(); } } @@ -1203,8 +1155,7 @@ MapUniverse::World::World(Connection& conn) { color.read(conn); std::string path = conn._readStdString(); if (!path.empty()) { - hecl::SystemStringConv sysPath(path); - worldPath.assign(conn.getBlendPath().getProject().getProjectWorkingPath(), sysPath.sys_str()); + worldPath.assign(conn.getBlendPath().getProject().getProjectWorkingPath(), path); } } @@ -1350,7 +1301,7 @@ std::vector DataStream::getLightList() { std::pair DataStream::getMeshAABB() { if (m_parent->m_loadedType != BlendType::Mesh && m_parent->m_loadedType != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not a MESH or ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not a MESH or ACTOR blend"), m_parent->m_loadedBlend.getAbsolutePath()); m_parent->_writeStr("MESHAABB"); @@ -1368,7 +1319,7 @@ const char* DataStream::MeshOutputModeString(HMDLTopology topology) { Mesh DataStream::compileMesh(HMDLTopology topology, int skinSlotCount) { if (m_parent->getBlendType() != BlendType::Mesh) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not a MESH blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not a MESH blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("MESHCOMPILE"); @@ -1379,7 +1330,7 @@ Mesh DataStream::compileMesh(HMDLTopology topology, int skinSlotCount) { Mesh DataStream::compileMesh(std::string_view name, HMDLTopology topology, int skinSlotCount, bool useLuv) { if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an AREA blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr(fmt::format(FMT_STRING("MESHCOMPILENAME {} {}"), name, int(useLuv))); @@ -1390,7 +1341,7 @@ Mesh DataStream::compileMesh(std::string_view name, HMDLTopology topology, int s ColMesh DataStream::compileColMesh(std::string_view name) { if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an AREA blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr(fmt::format(FMT_STRING("MESHCOMPILENAMECOLLISION {}"), name)); @@ -1401,7 +1352,7 @@ ColMesh DataStream::compileColMesh(std::string_view name) { std::vector DataStream::compileColMeshes() { if (m_parent->getBlendType() != BlendType::ColMesh) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not a CMESH blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not a CMESH blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("MESHCOMPILECOLLISIONALL"); @@ -1414,7 +1365,7 @@ std::vector DataStream::compileColMeshes() { std::vector DataStream::compileLights() { if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an AREA blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("LIGHTCOMPILEALL"); @@ -1427,7 +1378,7 @@ std::vector DataStream::compileLights() { PathMesh DataStream::compilePathMesh() { if (m_parent->getBlendType() != BlendType::PathMesh) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not a PATH blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not a PATH blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("MESHCOMPILEPATH"); @@ -1438,7 +1389,7 @@ PathMesh DataStream::compilePathMesh() { std::vector DataStream::compileGuiFrame(int version) { if (m_parent->getBlendType() != BlendType::Frame) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not a FRAME blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not a FRAME blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr(fmt::format(FMT_STRING("FRAMECOMPILE {}"), version)); @@ -1449,13 +1400,12 @@ std::vector DataStream::compileGuiFrame(int version) { if (readStr == "FRAMEDONE") break; - SystemStringConv absolute(readStr); auto& proj = m_parent->getBlendPath().getProject(); - SystemString relative; - if (PathRelative(absolute.c_str())) - relative = absolute.sys_str(); + std::string relative; + if (PathRelative(readStr.c_str())) + relative = readStr; else - relative = proj.getProjectRootPath().getProjectRelativeFromAbsolute(absolute.sys_str()); + relative = proj.getProjectRootPath().getProjectRelativeFromAbsolute(readStr); hecl::ProjectPath path(proj.getProjectWorkingPath(), relative); m_parent->_writeStr(fmt::format(FMT_STRING("{:08X}"), path.parsedHash32())); @@ -1478,7 +1428,7 @@ std::vector DataStream::getTextures() { Actor DataStream::compileActor() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("ACTORCOMPILE"); @@ -1489,7 +1439,7 @@ Actor DataStream::compileActor() { Actor DataStream::compileActorCharacterOnly() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("ACTORCOMPILECHARACTERONLY"); @@ -1500,7 +1450,7 @@ Actor DataStream::compileActorCharacterOnly() { Armature DataStream::compileArmature() { if (m_parent->getBlendType() != BlendType::Armature) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ARMATURE blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ARMATURE blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("ARMATURECOMPILE"); @@ -1511,7 +1461,7 @@ Armature DataStream::compileArmature() { Action DataStream::compileActionChannelsOnly(std::string_view name) { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr(fmt::format(FMT_STRING("ACTIONCOMPILECHANNELSONLY {}"), name)); @@ -1522,7 +1472,7 @@ Action DataStream::compileActionChannelsOnly(std::string_view name) { World DataStream::compileWorld() { if (m_parent->getBlendType() != BlendType::World) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an WORLD blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an WORLD blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("WORLDCOMPILE"); @@ -1533,7 +1483,7 @@ World DataStream::compileWorld() { std::vector> DataStream::getSubtypeNames() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("GETSUBTYPENAMES"); @@ -1551,7 +1501,7 @@ std::vector> DataStream::getSubtypeNames() { std::vector> DataStream::getActionNames() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("GETACTIONNAMES"); @@ -1569,7 +1519,7 @@ std::vector> DataStream::getActionNames() { std::vector> DataStream::getSubtypeOverlayNames(std::string_view name) { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr(fmt::format(FMT_STRING("GETSUBTYPEOVERLAYNAMES {}"), name)); @@ -1587,7 +1537,7 @@ std::vector> DataStream::getSubtypeOverlayNa std::vector> DataStream::getAttachmentNames() { if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("GETATTACHMENTNAMES"); @@ -1608,7 +1558,7 @@ std::unordered_map DataStream::getBoneMatrices(std::strin return {}; if (m_parent->getBlendType() != BlendType::Actor) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an ACTOR blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an ACTOR blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr(fmt::format(FMT_STRING("GETBONEMATRICES {}"), name)); @@ -1643,7 +1593,7 @@ bool DataStream::renderPvs(std::string_view path, const atVec3f& location) { return false; if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an AREA blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath()); athena::simd_floats f(location.simd); @@ -1658,7 +1608,7 @@ bool DataStream::renderPvsLight(std::string_view path, std::string_view lightNam return false; if (m_parent->getBlendType() != BlendType::Area) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not an AREA blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not an AREA blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr(fmt::format(FMT_STRING("RENDERPVSLIGHT {} {}"), path, lightName)); @@ -1669,7 +1619,7 @@ bool DataStream::renderPvsLight(std::string_view path, std::string_view lightNam MapArea DataStream::compileMapArea() { if (m_parent->getBlendType() != BlendType::MapArea) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not a MAPAREA blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not a MAPAREA blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("MAPAREACOMPILE"); @@ -1680,7 +1630,7 @@ MapArea DataStream::compileMapArea() { MapUniverse DataStream::compileMapUniverse() { if (m_parent->getBlendType() != BlendType::MapUniverse) - BlenderLog.report(logvisor::Fatal, FMT_STRING(_SYS_STR("{} is not a MAPUNIVERSE blend")), + BlenderLog.report(logvisor::Fatal, FMT_STRING("{} is not a MAPUNIVERSE blend"), m_parent->getBlendPath().getAbsolutePath()); m_parent->_writeStr("MAPUNIVERSECOMPILE"); diff --git a/metaforce-gui/FindBlender.cpp b/hecl/lib/Blender/FindBlender.cpp similarity index 65% rename from metaforce-gui/FindBlender.cpp rename to hecl/lib/Blender/FindBlender.cpp index 16d250587..941577263 100644 --- a/metaforce-gui/FindBlender.cpp +++ b/hecl/lib/Blender/FindBlender.cpp @@ -1,4 +1,4 @@ -#include "FindBlender.hpp" +#include "hecl/Blender/FindBlender.hpp" #include "hecl/SteamFinder.hpp" #include "hecl/hecl.hpp" @@ -6,8 +6,6 @@ namespace hecl::blender { #ifdef __APPLE__ #define DEFAULT_BLENDER_BIN "/Applications/Blender.app/Contents/MacOS/blender" -#elif __linux__ -#define DEFAULT_BLENDER_BIN "/usr/bin/blender" #else #define DEFAULT_BLENDER_BIN "blender" #endif @@ -15,53 +13,58 @@ namespace hecl::blender { static const std::regex regBlenderVersion(R"(Blender (\d+)\.(\d+)(?:\.(\d+))?)", std::regex::ECMAScript | std::regex::optimize); -static bool RegFileExists(const hecl::SystemChar* path) { +static bool RegFileExists(const char* path) { if (!path) return false; hecl::Sstat theStat; return !hecl::Stat(path, &theStat) && S_ISREG(theStat.st_mode); } -hecl::SystemString FindBlender(int& major, int& minor) { +std::optional FindBlender(int& major, int& minor) { major = 0; minor = 0; /* User-specified blender path */ #if _WIN32 - wchar_t BLENDER_BIN_BUF[2048]; - const wchar_t* blenderBin = _wgetenv(L"BLENDER_BIN"); + auto blenderBin = GetEnv("BLENDER_BIN"); #else - const char* blenderBin = getenv("BLENDER_BIN"); + const char* cblenderBin = getenv("BLENDER_BIN"); + std::optional blenderBin{}; + if (cblenderBin != nullptr) { + blenderBin = cblenderBin; + } #endif /* Steam blender */ - hecl::SystemString steamBlender; + std::string steamBlender; /* Child process of blender */ #if _WIN32 - if (!blenderBin || !RegFileExists(blenderBin)) { + if (!blenderBin || !RegFileExists(blenderBin->c_str())) { /* Environment not set; try steam */ - steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender")); + steamBlender = hecl::FindCommonSteamApp("Blender"); if (steamBlender.size()) { - steamBlender += _SYS_STR("\\blender.exe"); + steamBlender += "\\blender.exe"; blenderBin = steamBlender.c_str(); } - if (!RegFileExists(blenderBin)) { + if (!RegFileExists(blenderBin->c_str())) { /* No steam; try default */ - wchar_t progFiles[256]; - if (GetEnvironmentVariableW(L"ProgramFiles", progFiles, 256)) { + wchar_t wProgFiles[256]; + if (GetEnvironmentVariableW(L"ProgramFiles", wProgFiles, 256)) { + auto progFiles = nowide::narrow(wProgFiles); for (size_t major = MaxBlenderMajorSearch; major >= MinBlenderMajorSearch; --major) { bool found = false; - for (size_t minor = MaxBlenderMinorSearch; minor > MinBlenderMinorSearch; --minor) { - _snwprintf(BLENDER_BIN_BUF, 2048, L"%s\\Blender Foundation\\Blender %i.%i\\blender.exe", progFiles, major, - minor); - if (RegFileExists(BLENDER_BIN_BUF)) { - blenderBin = BLENDER_BIN_BUF; + for (size_t minor = MaxBlenderMinorSearch; minor >= MinBlenderMinorSearch; --minor) { + std::string blenderBinBuf = fmt::format(FMT_STRING("{}\\Blender Foundation\\Blender {}.{}\\blender.exe"), + progFiles, major, minor); + if (RegFileExists(blenderBinBuf.c_str())) { + blenderBin = std::move(blenderBinBuf); found = true; break; } } + if (found) { break; } @@ -73,7 +76,7 @@ hecl::SystemString FindBlender(int& major, int& minor) { #else if (!RegFileExists(blenderBin)) { /* Try steam */ - steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender")); + steamBlender = hecl::FindCommonSteamApp("Blender"); if (steamBlender.size()) { #ifdef __APPLE__ steamBlender += "/blender.app/Contents/MacOS/blender"; @@ -100,12 +103,13 @@ hecl::SystemString FindBlender(int& major, int& minor) { return {}; #if _WIN32 + const nowide::wstackstring wblenderBin(blenderBin.value()); DWORD handle = 0; - DWORD infoSize = GetFileVersionInfoSizeW(blenderBin, &handle); + DWORD infoSize = GetFileVersionInfoSizeW(wblenderBin.get(), &handle); if (infoSize != NULL) { auto* infoData = new char[infoSize]; - if (GetFileVersionInfoW(blenderBin, handle, infoSize, infoData)) { + if (GetFileVersionInfoW(wblenderBin.get(), handle, infoSize, infoData)) { UINT size = 0; LPVOID lpBuffer = nullptr; if (VerQueryValueW(infoData, L"\\", &lpBuffer, &size) && size != 0u) { @@ -120,7 +124,7 @@ hecl::SystemString FindBlender(int& major, int& minor) { delete[] infoData; } #else - hecl::SystemString command = hecl::SystemString(_SYS_STR("\"")) + blenderBin + _SYS_STR("\" --version"); + std::string command = std::string("\"") + blenderBin + "\" --version"; FILE* fp = popen(command.c_str(), "r"); char versionBuf[256]; size_t rdSize = fread(versionBuf, 1, 255, fp); diff --git a/hecl/lib/Blender/SDNARead.cpp b/hecl/lib/Blender/SDNARead.cpp index da769eeab..723d2986e 100644 --- a/hecl/lib/Blender/SDNARead.cpp +++ b/hecl/lib/Blender/SDNARead.cpp @@ -69,7 +69,7 @@ void SDNARead::enumerate(const std::functiontoBoolean())) { - if (isValid != nullptr) - *isValid = false; - } else if (isValid != nullptr) { - *isValid = true; - } - - // Even if it's not a literal, it's still safe to return - return hecl::UTF8ToWide(m_value); -} - bool CVar::fromVec2f(const atVec2f& val) { if (!safeToModify(EType::Vec2f)) return false; @@ -398,15 +386,6 @@ bool CVar::fromLiteral(std::string_view val) { return true; } -bool CVar::fromLiteral(std::wstring_view val) { - if (!safeToModify(EType::Literal)) - return false; - - m_value.assign(hecl::WideToUTF8(val)); - setModified(); - return true; -} - bool CVar::fromLiteralToType(std::string_view val) { if (!safeToModify(m_type) || !isValidInput(val)) return false; @@ -415,8 +394,6 @@ bool CVar::fromLiteralToType(std::string_view val) { return true; } -bool CVar::fromLiteralToType(std::wstring_view val) { return fromLiteralToType(hecl::WideToUTF8(val)); } - bool CVar::isModified() const { return True(m_flags & EFlags::Modified); } bool CVar::modificationRequiresRestart() const { return True(m_flags & EFlags::ModifyRestart); } @@ -523,8 +500,6 @@ bool CVar::isValidInput(std::string_view input) const { return false; } -bool CVar::isValidInput(std::wstring_view input) const { return isValidInput(hecl::WideToUTF8(input)); } - bool CVar::safeToModify(EType type) const { // Are we NoDevelper? if (isNoDeveloper()) diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index 4dbd8aac1..2f45acc82 100644 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -111,18 +111,13 @@ void CVarManager::deserialize(CVar* cvar) { } /* We were either unable to find a deferred value or got an invalid value */ -#if _WIN32 - hecl::SystemString filename = - hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toWideLiteral(); -#else - hecl::SystemString filename = - hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toLiteral(); -#endif + std::string filename = + std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral(); hecl::Sstat st; if (m_useBinary) { CVarContainer container; - filename += _SYS_STR(".bin"); + filename += ".bin"; if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) return; athena::io::FileReader reader(filename); @@ -144,7 +139,7 @@ void CVarManager::deserialize(CVar* cvar) { } } } else { - filename += _SYS_STR(".yaml"); + filename += ".yaml"; if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) return; athena::io::FileReader reader(filename); @@ -170,13 +165,8 @@ void CVarManager::deserialize(CVar* cvar) { } void CVarManager::serialize() { -#if _WIN32 - hecl::SystemString filename = - hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toWideLiteral(); -#else - hecl::SystemString filename = - hecl::SystemString(m_store.getStoreRoot()) + _SYS_STR('/') + com_configfile->toLiteral(); -#endif + std::string filename = + std::string(m_store.getStoreRoot()) + '/' + com_configfile->toLiteral(); if (m_useBinary) { CVarContainer container; @@ -189,12 +179,12 @@ void CVarManager::serialize() { } container.cvarCount = atUint32(container.cvars.size()); - filename += _SYS_STR(".bin"); + filename += ".bin"; athena::io::FileWriter writer(filename); if (writer.isOpen()) container.write(writer); } else { - filename += _SYS_STR(".yaml"); + filename += ".yaml"; athena::io::FileReader r(filename); athena::io::YAMLDocWriter docWriter(r.isOpen() ? &r : nullptr); @@ -297,21 +287,20 @@ bool CVarManager::restartRequired() const { }); } -void CVarManager::parseCommandLine(const std::vector& args) { +void CVarManager::parseCommandLine(const std::vector& args) { bool oldDeveloper = suppressDeveloper(); std::string developerName(com_developer->name()); athena::utility::tolower(developerName); - for (const SystemString& arg : args) { - if (arg[0] != _SYS_STR('+')) { + for (const std::string& arg : args) { + if (arg[0] != '+') { continue; } - const std::string tmp(SystemUTF8Conv(arg).str()); std::smatch matches; std::string cvarName; std::string cvarValue; - if (std::regex_match(tmp, matches, cmdLineRegex)) { + if (std::regex_match(arg, matches, cmdLineRegex)) { std::vector realMatches; for (auto match : matches) { if (match.matched) { diff --git a/hecl/lib/ClientProcess.cpp b/hecl/lib/ClientProcess.cpp index d8b0aae77..be5bb6817 100644 --- a/hecl/lib/ClientProcess.cpp +++ b/hecl/lib/ClientProcess.cpp @@ -26,7 +26,7 @@ ThreadLocalPtr ClientProcess::ThreadWorker; int CpuCountOverride = 0; -void SetCpuCountOverride(int argc, const SystemChar** argv) { +void SetCpuCountOverride(int argc, char** argv) { bool threadArg = false; for (int i = 1; i < argc; ++i) { if (threadArg) { @@ -35,7 +35,7 @@ void SetCpuCountOverride(int argc, const SystemChar** argv) { return; } } - if (!hecl::StrNCmp(argv[i], _SYS_STR("-j"), 2)) { + if (!hecl::StrNCmp(argv[i], "-j", 2)) { if (int count = int(hecl::StrToUl(argv[i] + 2, nullptr, 0))) { CpuCountOverride = count; return; @@ -65,7 +65,7 @@ static int GetCPUCount() { void ClientProcess::BufferTransaction::run(blender::Token& btok) { athena::io::FileReader r(m_path.getAbsolutePath(), 32 * 1024, false); if (r.hasError()) { - CP_Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to background-buffer '{}'")), m_path.getAbsolutePath()); + CP_Log.report(logvisor::Fatal, FMT_STRING("unable to background-buffer '{}'"), m_path.getAbsolutePath()); return; } if (m_offset) @@ -175,30 +175,30 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec* if (specEnt) { hecl::ProjectPath cooked = path.getCookedPath(*specEnt); if (fast) - cooked = cooked.getWithExtension(_SYS_STR(".fast")); + cooked = cooked.getWithExtension(".fast"); cooked.makeDirChain(false); if (force || cooked.getPathType() == ProjectPath::Type::None || path.getModtime() > cooked.getModtime()) { if (m_progPrinter) { - hecl::SystemString str; + std::string str; if (path.getAuxInfo().empty()) - str = fmt::format(FMT_STRING(_SYS_STR("Cooking {}")), path.getRelativePath()); + str = fmt::format(FMT_STRING("Cooking {}"), path.getRelativePath()); else - str = fmt::format(FMT_STRING(_SYS_STR("Cooking {}|{}")), path.getRelativePath(), path.getAuxInfo()); + str = fmt::format(FMT_STRING("Cooking {}|{}"), path.getRelativePath(), path.getAuxInfo()); m_progPrinter->print(str, std::nullopt, -1.f, hecl::ClientProcess::GetThreadWorkerIdx()); m_progPrinter->flush(); } else { if (path.getAuxInfo().empty()) - LogModule.report(logvisor::Info, FMT_STRING(_SYS_STR("Cooking {}")), path.getRelativePath()); + LogModule.report(logvisor::Info, FMT_STRING("Cooking {}"), path.getRelativePath()); else - LogModule.report(logvisor::Info, FMT_STRING(_SYS_STR("Cooking {}|{}")), path.getRelativePath(), path.getAuxInfo()); + LogModule.report(logvisor::Info, FMT_STRING("Cooking {}|{}"), path.getRelativePath(), path.getAuxInfo()); } - spec->doCook(path, cooked, false, btok, [](const SystemChar*) {}); + spec->doCook(path, cooked, false, btok, [](const char*) {}); if (m_progPrinter) { - hecl::SystemString str; + std::string str; if (path.getAuxInfo().empty()) - str = fmt::format(FMT_STRING(_SYS_STR("Cooked {}")), path.getRelativePath()); + str = fmt::format(FMT_STRING("Cooked {}"), path.getRelativePath()); else - str = fmt::format(FMT_STRING(_SYS_STR("Cooked {}|{}")), path.getRelativePath(), path.getAuxInfo()); + str = fmt::format(FMT_STRING("Cooked {}|{}"), path.getRelativePath(), path.getAuxInfo()); m_progPrinter->print(str, std::nullopt, -1.f, hecl::ClientProcess::GetThreadWorkerIdx()); m_progPrinter->flush(); } diff --git a/hecl/lib/Console.cpp b/hecl/lib/Console.cpp index 1ebdc31f4..0d1bbd7cf 100644 --- a/hecl/lib/Console.cpp +++ b/hecl/lib/Console.cpp @@ -378,16 +378,6 @@ void Console::LogVisorAdapter::report(const char* modName, logvisor::Level sever } } -void Console::LogVisorAdapter::report(const char* modName, logvisor::Level severity, - fmt::wstring_view format, fmt::wformat_args args) { - auto tmp = fmt::vformat(format, args); - std::vector lines = athena::utility::split(athena::utility::wideToUtf8(tmp), '\n'); - for (const std::string& line : lines) { - auto v = fmt::format(FMT_STRING("[{}] {}"), modName, line); - m_con->m_log.emplace_back(std::move(v), Console::Level(severity)); - } -} - void Console::LogVisorAdapter::reportSource(const char* modName, logvisor::Level severity, const char* file, unsigned linenum, fmt::string_view format, fmt::format_args args) { auto tmp = fmt::vformat(format, args); @@ -395,16 +385,6 @@ void Console::LogVisorAdapter::reportSource(const char* modName, logvisor::Level m_con->m_log.emplace_back(std::move(v), Console::Level(severity)); } -void Console::LogVisorAdapter::reportSource(const char* modName, logvisor::Level severity, const char* file, - unsigned linenum, fmt::wstring_view format, fmt::wformat_args args) { - auto tmp = fmt::vformat(format, args); - std::vector lines = athena::utility::split(athena::utility::wideToUtf8(tmp), '\n'); - for (const std::string& line : lines) { - auto v = fmt::format(FMT_STRING("[{}] {} {}:{}"), modName, line, file, linenum); - m_con->m_log.emplace_back(std::move(v), Console::Level(severity)); - } -} - void Console::dumpLog() { for (const auto& l : m_log) { switch (l.second) { diff --git a/hecl/lib/MultiProgressPrinter.cpp b/hecl/lib/MultiProgressPrinter.cpp index 8a0aff17a..5ae3b6bc5 100644 --- a/hecl/lib/MultiProgressPrinter.cpp +++ b/hecl/lib/MultiProgressPrinter.cpp @@ -38,20 +38,20 @@ void MultiProgressPrinter::ThreadStat::print(const TermInfo& tinfo) const { if (submessageLen) { if (messageLen > half - submessageLen - 1) - fmt::print(FMT_STRING(_SYS_STR(" {:.{}}... {} ")), m_message, half - submessageLen - 4, m_submessage); + fmt::print(FMT_STRING(" {:.{}}... {} "), m_message, half - submessageLen - 4, m_submessage); else { - fmt::print(FMT_STRING(_SYS_STR(" {}")), m_message); + fmt::print(FMT_STRING(" {}"), m_message); for (int i = half - messageLen - submessageLen - 1; i >= 0; --i) - fmt::print(FMT_STRING(_SYS_STR(" "))); - fmt::print(FMT_STRING(_SYS_STR("{} ")), m_submessage); + fmt::print(FMT_STRING(" ")); + fmt::print(FMT_STRING("{} "), m_submessage); } } else { if (messageLen > half) - fmt::print(FMT_STRING(_SYS_STR(" {:.{}}... ")), m_message, half - 3); + fmt::print(FMT_STRING(" {:.{}}... "), m_message, half - 3); else { - fmt::print(FMT_STRING(_SYS_STR(" {}")), m_message); + fmt::print(FMT_STRING(" {}"), m_message); for (int i = half - messageLen; i >= 0; --i) - fmt::print(FMT_STRING(_SYS_STR(" "))); + fmt::print(FMT_STRING(" ")); } } @@ -62,22 +62,22 @@ void MultiProgressPrinter::ThreadStat::print(const TermInfo& tinfo) const { int rem = nblocks - filled; if (tinfo.xtermColor) { - fmt::print(FMT_STRING(_SYS_STR("" BOLD "{:3d}% [")), iFactor); + fmt::print(FMT_STRING("" BOLD "{:3d}% ["), iFactor); for (int b = 0; b < filled; ++b) - fmt::print(FMT_STRING(_SYS_STR("#"))); + fmt::print(FMT_STRING("#")); for (int b = 0; b < rem; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("]" NORMAL ""))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("]" NORMAL "")); } else { #if _WIN32 SetConsoleTextAttribute(tinfo.console, FOREGROUND_INTENSITY | FOREGROUND_WHITE); #endif - fmt::print(FMT_STRING(_SYS_STR("{:3d}% [")), iFactor); + fmt::print(FMT_STRING("{:3d}% ["), iFactor); for (int b = 0; b < filled; ++b) - fmt::print(FMT_STRING(_SYS_STR("#"))); + fmt::print(FMT_STRING("#")); for (int b = 0; b < rem; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("]"))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("]")); #if _WIN32 SetConsoleTextAttribute(tinfo.console, FOREGROUND_WHITE); #endif @@ -100,24 +100,24 @@ void MultiProgressPrinter::DrawIndeterminateBar() { int rem = blocks - pre - 1; if (m_termInfo.xtermColor) { - fmt::print(FMT_STRING(_SYS_STR("" BOLD " ["))); + fmt::print(FMT_STRING("" BOLD " [")); for (int b = 0; b < pre; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("#"))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("#")); for (int b = 0; b < rem; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("]" NORMAL ""))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("]" NORMAL "")); } else { #if _WIN32 SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_INTENSITY | FOREGROUND_WHITE); #endif - fmt::print(FMT_STRING(_SYS_STR(" ["))); + fmt::print(FMT_STRING(" [")); for (int b = 0; b < pre; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("#"))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("#")); for (int b = 0; b < rem; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("]"))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("]")); #if _WIN32 SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_WHITE); #endif @@ -127,7 +127,7 @@ void MultiProgressPrinter::DrawIndeterminateBar() { void MultiProgressPrinter::MoveCursorUp(int n) { if (n) { if (m_termInfo.xtermColor) { - fmt::print(FMT_STRING(_SYS_STR("" PREV_LINE "")), n); + fmt::print(FMT_STRING("" PREV_LINE ""), n); } #if _WIN32 else { @@ -139,7 +139,7 @@ void MultiProgressPrinter::MoveCursorUp(int n) { } #endif } else { - fmt::print(FMT_STRING(_SYS_STR("\r"))); + fmt::print(FMT_STRING("\r")); } } @@ -157,7 +157,7 @@ void MultiProgressPrinter::DoPrint() { SetConsoleCursorInfo(m_termInfo.console, &cursorInfo); #endif if (m_termInfo.xtermColor) - fmt::print(FMT_STRING(_SYS_STR("" HIDE_CURSOR ""))); + fmt::print(FMT_STRING("" HIDE_CURSOR "")); if (m_dirty) { m_termInfo.width = (hecl::GuiMode ? 120 : std::max(80, hecl::ConsoleWidth(&m_termInfo.truncate))); @@ -168,7 +168,7 @@ void MultiProgressPrinter::DoPrint() { for (const ThreadStat& stat : m_threadStats) { if (stat.m_active) { stat.print(m_termInfo); - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); ++m_curThreadLines; } } @@ -179,7 +179,7 @@ void MultiProgressPrinter::DoPrint() { #endif ) { DrawIndeterminateBar(); - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); ++m_curProgLines; } else if (m_mainFactor >= 0.f) { float factor = std::max(0.0f, std::min(1.0f, m_mainFactor)); @@ -191,34 +191,34 @@ void MultiProgressPrinter::DoPrint() { int rem = blocks - filled; if (m_termInfo.xtermColor) { - fmt::print(FMT_STRING(_SYS_STR("" BOLD " {:3d}% [")), iFactor); + fmt::print(FMT_STRING("" BOLD " {:3d}% ["), iFactor); for (int b = 0; b < filled; ++b) - fmt::print(FMT_STRING(_SYS_STR("#"))); + fmt::print(FMT_STRING("#")); for (int b = 0; b < rem; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("]" NORMAL ""))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("]" NORMAL "")); } else { #if _WIN32 SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_INTENSITY | FOREGROUND_WHITE); #endif - fmt::print(FMT_STRING(_SYS_STR(" {:3d}% [")), iFactor); + fmt::print(FMT_STRING(" {:3d}% ["), iFactor); for (int b = 0; b < filled; ++b) - fmt::print(FMT_STRING(_SYS_STR("#"))); + fmt::print(FMT_STRING("#")); for (int b = 0; b < rem; ++b) - fmt::print(FMT_STRING(_SYS_STR("-"))); - fmt::print(FMT_STRING(_SYS_STR("]"))); + fmt::print(FMT_STRING("-")); + fmt::print(FMT_STRING("]")); #if _WIN32 SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_WHITE); #endif } - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); ++m_curProgLines; } } else if (m_latestThread != -1) { const ThreadStat& stat = m_threadStats[m_latestThread]; stat.print(m_termInfo); - fmt::print(FMT_STRING(_SYS_STR("\r"))); + fmt::print(FMT_STRING("\r")); } m_dirty = false; } else if (m_mainIndeterminate @@ -230,12 +230,12 @@ void MultiProgressPrinter::DoPrint() { MoveCursorUp(m_curProgLines); m_curProgLines = 0; DrawIndeterminateBar(); - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); ++m_curProgLines; } if (m_termInfo.xtermColor) - fmt::print(FMT_STRING(_SYS_STR("" SHOW_CURSOR ""))); + fmt::print(FMT_STRING("" SHOW_CURSOR "")); fflush(stdout); #if _WIN32 @@ -286,8 +286,8 @@ MultiProgressPrinter::~MultiProgressPrinter() { m_logThread.join(); } -void MultiProgressPrinter::print(std::optional message, - std::optional submessage, +void MultiProgressPrinter::print(std::optional message, + std::optional submessage, float factor, int threadIdx) const { if (!m_running) { @@ -356,7 +356,7 @@ void MultiProgressPrinter::startNewLine() const { m_curThreadLines = 0; m_mainFactor = -1.f; auto logLk = logvisor::LockLog(); - fmt::print(FMT_STRING(_SYS_STR("\n"))); + fmt::print(FMT_STRING("\n")); } void MultiProgressPrinter::flush() const { diff --git a/hecl/lib/Pipeline.cpp b/hecl/lib/Pipeline.cpp index 05eef00cd..0de6a0538 100644 --- a/hecl/lib/Pipeline.cpp +++ b/hecl/lib/Pipeline.cpp @@ -15,7 +15,7 @@ class ShaderCacheZipStream : public athena::io::IStreamReader { z_stream m_zstrm = {}; public: - explicit ShaderCacheZipStream(const hecl::SystemChar* path) : m_reader(path) { + explicit ShaderCacheZipStream(const char* path) : m_reader(path) { if (m_reader.hasError()) return; if (m_reader.readUint32Big() != SBIG('SHAD')) @@ -91,7 +91,7 @@ static std::vector ReadVertexFormat(ShaderCacheZip } template -bool PipelineConverter

::loadFromFile(FactoryCtx& ctx, const hecl::SystemChar* path) { +bool PipelineConverter

::loadFromFile(FactoryCtx& ctx, const char* path) { ShaderCacheZipStream r(path); if (!r) return false; diff --git a/hecl/lib/Project.cpp b/hecl/lib/Project.cpp index 3c9a946d7..7f0ffe961 100644 --- a/hecl/lib/Project.cpp +++ b/hecl/lib/Project.cpp @@ -43,8 +43,8 @@ static bool CheckNewLineAdvance(std::string::const_iterator& it) { return false; } -Project::ConfigFile::ConfigFile(const Project& project, SystemStringView name, SystemStringView subdir) { - m_filepath = SystemString(project.m_rootPath.getAbsolutePath()) + subdir.data() + name.data(); +Project::ConfigFile::ConfigFile(const Project& project, std::string_view name, std::string_view subdir) { + m_filepath = std::string(project.m_rootPath.getAbsolutePath()) + subdir.data() + name.data(); } std::vector& Project::ConfigFile::lockAndRead() { @@ -52,7 +52,7 @@ std::vector& Project::ConfigFile::lockAndRead() { return m_lines; } - m_lockedFile = hecl::FopenUnique(m_filepath.c_str(), _SYS_STR("a+"), FileLockType::Write); + m_lockedFile = hecl::FopenUnique(m_filepath.c_str(), "a+", FileLockType::Write); hecl::FSeek(m_lockedFile.get(), 0, SEEK_SET); std::string mainString; @@ -132,8 +132,8 @@ bool Project::ConfigFile::unlockAndCommit() { return false; } - const SystemString newPath = m_filepath + _SYS_STR(".part"); - auto newFile = hecl::FopenUnique(newPath.c_str(), _SYS_STR("w"), FileLockType::Write); + const std::string newPath = m_filepath + ".part"; + auto newFile = hecl::FopenUnique(newPath.c_str(), "w", FileLockType::Write); bool fail = false; for (const std::string& line : m_lines) { if (std::fwrite(line.c_str(), 1, line.size(), newFile.get()) != line.size()) { @@ -149,19 +149,10 @@ bool Project::ConfigFile::unlockAndCommit() { newFile.reset(); m_lockedFile.reset(); if (fail) { -#if HECL_UCS2 - _wunlink(newPath.c_str()); -#else - unlink(newPath.c_str()); -#endif + Unlink(newPath.c_str()); return false; } else { -#if HECL_UCS2 - //_wrename(newPath.c_str(), m_filepath.c_str()); - MoveFileExW(newPath.c_str(), m_filepath.c_str(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); -#else - rename(newPath.c_str(), m_filepath.c_str()); -#endif + Rename(newPath.c_str(), m_filepath.c_str()); return true; } } @@ -172,21 +163,21 @@ bool Project::ConfigFile::unlockAndCommit() { Project::Project(const ProjectRootPath& rootPath) : m_rootPath(rootPath) -, m_workRoot(*this, _SYS_STR("")) -, m_dotPath(m_workRoot, _SYS_STR(".hecl")) -, m_cookedRoot(m_dotPath, _SYS_STR("cooked")) -, m_specs(*this, _SYS_STR("specs")) -, m_paths(*this, _SYS_STR("paths")) -, m_groups(*this, _SYS_STR("groups")) { +, m_workRoot(*this, "") +, m_dotPath(m_workRoot, ".hecl") +, m_cookedRoot(m_dotPath, "cooked") +, m_specs(*this, "specs") +, m_paths(*this, "paths") +, m_groups(*this, "groups") { /* Stat for existing project directory (must already exist) */ Sstat myStat; if (hecl::Stat(m_rootPath.getAbsolutePath().data(), &myStat)) { - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("unable to stat {}")), m_rootPath.getAbsolutePath()); + LogModule.report(logvisor::Error, FMT_STRING("unable to stat {}"), m_rootPath.getAbsolutePath()); return; } if (!S_ISDIR(myStat.st_mode)) { - LogModule.report(logvisor::Error, FMT_STRING(_SYS_STR("provided path must be a directory; '{}' isn't")), + LogModule.report(logvisor::Error, FMT_STRING("provided path must be a directory; '{}' isn't"), m_rootPath.getAbsolutePath()); return; } @@ -196,8 +187,8 @@ Project::Project(const ProjectRootPath& rootPath) m_cookedRoot.makeDir(); /* Ensure beacon is valid or created */ - const ProjectPath beaconPath(m_dotPath, _SYS_STR("beacon")); - auto bf = hecl::FopenUnique(beaconPath.getAbsolutePath().data(), _SYS_STR("a+b")); + const ProjectPath beaconPath(m_dotPath, "beacon"); + auto bf = hecl::FopenUnique(beaconPath.getAbsolutePath().data(), "a+b"); struct BeaconStruct { hecl::FourCC magic; uint32_t version; @@ -225,14 +216,14 @@ const ProjectPath& Project::getProjectCookedPath(const DataSpecEntry& spec) cons for (const ProjectDataSpec& sp : m_compiledSpecs) if (&sp.spec == &spec) return sp.cookedPath; - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to find spec '{}'")), spec.m_name); + LogModule.report(logvisor::Fatal, FMT_STRING("Unable to find spec '{}'"), spec.m_name); return m_cookedRoot; } bool Project::addPaths(const std::vector& paths) { m_paths.lockAndRead(); for (const ProjectPath& path : paths) - m_paths.addLine(path.getRelativePathUTF8()); + m_paths.addLine(path.getRelativePath()); return m_paths.unlockAndCommit(); } @@ -240,7 +231,7 @@ bool Project::removePaths(const std::vector& paths, bool recursive) std::vector& existingPaths = m_paths.lockAndRead(); if (recursive) { for (const ProjectPath& path : paths) { - auto recursiveBase = path.getRelativePathUTF8(); + auto recursiveBase = path.getRelativePath(); for (auto it = existingPaths.begin(); it != existingPaths.end();) { if (!(*it).compare(0, recursiveBase.size(), recursiveBase)) { it = existingPaths.erase(it); @@ -251,19 +242,19 @@ bool Project::removePaths(const std::vector& paths, bool recursive) } } else for (const ProjectPath& path : paths) - m_paths.removeLine(path.getRelativePathUTF8()); + m_paths.removeLine(path.getRelativePath()); return m_paths.unlockAndCommit(); } bool Project::addGroup(const hecl::ProjectPath& path) { m_groups.lockAndRead(); - m_groups.addLine(path.getRelativePathUTF8()); + m_groups.addLine(path.getRelativePath()); return m_groups.unlockAndCommit(); } bool Project::removeGroup(const ProjectPath& path) { m_groups.lockAndRead(); - m_groups.removeLine(path.getRelativePathUTF8()); + m_groups.removeLine(path.getRelativePath()); return m_groups.unlockAndCommit(); } @@ -271,30 +262,26 @@ void Project::rescanDataSpecs() { m_compiledSpecs.clear(); m_specs.lockAndRead(); for (const DataSpecEntry* spec : DATA_SPEC_REGISTRY) { - hecl::SystemString specStr(spec->m_name); - SystemUTF8Conv specUTF8(specStr); - m_compiledSpecs.push_back({*spec, ProjectPath(m_cookedRoot, hecl::SystemString(spec->m_name) + _SYS_STR(".spec")), - m_specs.checkForLine(specUTF8.str())}); + m_compiledSpecs.push_back({*spec, ProjectPath(m_cookedRoot, std::string(spec->m_name) + ".spec"), + m_specs.checkForLine(spec->m_name)}); } m_specs.unlockAndDiscard(); } -bool Project::enableDataSpecs(const std::vector& specs) { +bool Project::enableDataSpecs(const std::vector& specs) { m_specs.lockAndRead(); - for (const SystemString& spec : specs) { - SystemUTF8Conv specView(spec); - m_specs.addLine(specView.str()); + for (const std::string& spec : specs) { + m_specs.addLine(spec); } bool result = m_specs.unlockAndCommit(); rescanDataSpecs(); return result; } -bool Project::disableDataSpecs(const std::vector& specs) { +bool Project::disableDataSpecs(const std::vector& specs) { m_specs.lockAndRead(); - for (const SystemString& spec : specs) { - SystemUTF8Conv specView(spec); - m_specs.removeLine(specView.str()); + for (const std::string& spec : specs) { + m_specs.removeLine(spec); } bool result = m_specs.unlockAndCommit(); rescanDataSpecs(); @@ -303,34 +290,34 @@ bool Project::disableDataSpecs(const std::vector& specs) { class CookProgress { const hecl::MultiProgressPrinter& m_progPrinter; - const SystemChar* m_dir = nullptr; - const SystemChar* m_file = nullptr; + const char* m_dir = nullptr; + const char* m_file = nullptr; float m_prog = 0.f; public: CookProgress(const hecl::MultiProgressPrinter& progPrinter) : m_progPrinter(progPrinter) {} - void changeDir(const SystemChar* dir) { + void changeDir(const char* dir) { m_dir = dir; m_progPrinter.startNewLine(); } - void changeFile(const SystemChar* file, float prog) { + void changeFile(const char* file, float prog) { m_file = file; m_prog = prog; } void reportFile(const DataSpecEntry* specEnt) { - SystemString submsg(m_file); - submsg += _SYS_STR(" ("); + std::string submsg(m_file); + submsg += " ("; submsg += specEnt->m_name.data(); - submsg += _SYS_STR(')'); + submsg += ')'; m_progPrinter.print(m_dir, submsg, m_prog); } - void reportFile(const DataSpecEntry* specEnt, const SystemChar* extra) { - SystemString submsg(m_file); - submsg += _SYS_STR(" ("); + void reportFile(const DataSpecEntry* specEnt, const char* extra) { + std::string submsg(m_file); + submsg += " ("; submsg += specEnt->m_name.data(); - submsg += _SYS_STR(", "); + submsg += ", "; submsg += extra; - submsg += _SYS_STR(')'); + submsg += ')'; m_progPrinter.print(m_dir, submsg, m_prog); } void reportDirComplete() { m_progPrinter.print(m_dir, std::nullopt, 1.f); } @@ -348,11 +335,11 @@ static void VisitFile(const ProjectPath& path, bool force, bool fast, continue; ProjectPath cooked = path.getCookedPath(*override); if (fast) - cooked = cooked.getWithExtension(_SYS_STR(".fast")); + cooked = cooked.getWithExtension(".fast"); if (force || cooked.getPathType() == ProjectPath::Type::None || path.getModtime() > cooked.getModtime()) { progress.reportFile(override); spec->doCook(path, cooked, fast, hecl::blender::SharedBlenderToken, - [&](const SystemChar* extra) { progress.reportFile(override, extra); }); + [&](const char* extra) { progress.reportFile(override, extra); }); } } } @@ -362,17 +349,17 @@ static void VisitFile(const ProjectPath& path, bool force, bool fast, static void VisitDirectory(const ProjectPath& dir, bool recursive, bool force, bool fast, std::vector>& specInsts, CookProgress& progress, ClientProcess* cp) { - if (dir.getLastComponent().size() > 1 && dir.getLastComponent()[0] == _SYS_STR('.')) + if (dir.getLastComponent().size() > 1 && dir.getLastComponent()[0] == '.') return; - if (hecl::ProjectPath(dir, _SYS_STR("!project.yaml")).isFile() && - hecl::ProjectPath(dir, _SYS_STR("!pool.yaml")).isFile()) { + if (hecl::ProjectPath(dir, "!project.yaml").isFile() && + hecl::ProjectPath(dir, "!pool.yaml").isFile()) { /* Handle AudioGroup case */ VisitFile(dir, force, fast, specInsts, progress, cp); return; } - std::map children; + std::map children; dir.getDirChildren(children); /* Pass 1: child file count */ @@ -458,7 +445,7 @@ bool Project::packagePath(const ProjectPath& path, const hecl::MultiProgressPrin bool foundPC = false; for (const ProjectDataSpec& projectSpec : m_compiledSpecs) { if (projectSpec.active && projectSpec.spec.m_factory) { - if (hecl::StringUtils::EndsWith(projectSpec.spec.m_name, _SYS_STR("-PC"))) { + if (hecl::StringUtils::EndsWith(projectSpec.spec.m_name, "-PC")) { foundPC = true; specEntry = &projectSpec.spec; } else if (!foundPC) { diff --git a/hecl/lib/ProjectPath.cpp b/hecl/lib/ProjectPath.cpp index 08f3e656f..5dabb1890 100644 --- a/hecl/lib/ProjectPath.cpp +++ b/hecl/lib/ProjectPath.cpp @@ -6,23 +6,23 @@ #include "hecl/FourCC.hpp" namespace hecl { -static const SystemRegex regPATHCOMP(_SYS_STR("[/\\\\]*([^/\\\\]+)"), SystemRegex::ECMAScript | SystemRegex::optimize); +static const std::regex regPATHCOMP("[/\\\\]*([^/\\\\]+)", std::regex::ECMAScript | std::regex::optimize); -static SystemString CanonRelPath(SystemStringView path) { +static std::string CanonRelPath(std::string_view path) { /* Tokenize Path */ - std::vector comps; - hecl::SystemRegexMatch matches; - SystemString in(path); + std::vector comps; + std::smatch matches; + std::string in(path); SanitizePath(in); for (; std::regex_search(in, matches, regPATHCOMP); in = matches.suffix().str()) { - hecl::SystemRegexMatch::const_reference match = matches[1]; - if (match == _SYS_STR(".")) + std::smatch::const_reference match = matches[1]; + if (match == ".") continue; - else if (match == _SYS_STR("..")) { + else if (match == "..") { if (comps.empty()) { /* Unable to resolve outside project */ - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to resolve outside project root in {}")), path); - return _SYS_STR("."); + LogModule.report(logvisor::Fatal, FMT_STRING("Unable to resolve outside project root in {}"), path); + return "."; } comps.pop_back(); continue; @@ -33,78 +33,64 @@ static SystemString CanonRelPath(SystemStringView path) { /* Emit relative path */ if (comps.size()) { auto it = comps.begin(); - SystemString retval = *it; + std::string retval = *it; for (++it; it != comps.end(); ++it) { if ((*it).size()) { - retval += _SYS_STR('/'); + retval += '/'; retval += *it; } } return retval; } - return _SYS_STR("."); + return "."; } -static SystemString CanonRelPath(SystemStringView path, const ProjectRootPath& projectRoot) { +static std::string CanonRelPath(std::string_view path, const ProjectRootPath& projectRoot) { /* Absolute paths not allowed; attempt to make project-relative */ if (IsAbsolute(path)) return CanonRelPath(projectRoot.getProjectRelativeFromAbsolute(path)); return CanonRelPath(path); } -void ProjectPath::assign(Database::Project& project, SystemStringView path) { +void ProjectPath::assign(Database::Project& project, std::string_view path) { m_proj = &project; - SystemString usePath; - size_t pipeFind = path.rfind(_SYS_STR('|')); - if (pipeFind != SystemString::npos) { + std::string usePath; + size_t pipeFind = path.rfind('|'); + if (pipeFind != std::string::npos) { m_auxInfo.assign(path.cbegin() + pipeFind + 1, path.cend()); usePath.assign(path.cbegin(), path.cbegin() + pipeFind); } else usePath = path; m_relPath = CanonRelPath(usePath, project.getProjectRootPath()); - m_absPath = SystemString(project.getProjectRootPath().getAbsolutePath()) + _SYS_STR('/') + m_relPath; + m_absPath = std::string(project.getProjectRootPath().getAbsolutePath()) + '/' + m_relPath; SanitizePath(m_relPath); SanitizePath(m_absPath); ComputeHash(); } -#if HECL_UCS2 -void ProjectPath::assign(Database::Project& project, std::string_view path) { - std::wstring wpath = UTF8ToWide(path); - assign(project, wpath); -} -#endif - -void ProjectPath::assign(const ProjectPath& parentPath, SystemStringView path) { +void ProjectPath::assign(const ProjectPath& parentPath, std::string_view path) { m_proj = parentPath.m_proj; - SystemString usePath; - size_t pipeFind = path.rfind(_SYS_STR('|')); - if (pipeFind != SystemString::npos) { + std::string usePath; + size_t pipeFind = path.rfind('|'); + if (pipeFind != std::string::npos) { m_auxInfo.assign(path.cbegin() + pipeFind + 1, path.cend()); usePath.assign(path.cbegin(), path.cbegin() + pipeFind); } else usePath = path; - m_relPath = CanonRelPath(parentPath.m_relPath + _SYS_STR('/') + usePath); - m_absPath = SystemString(m_proj->getProjectRootPath().getAbsolutePath()) + _SYS_STR('/') + m_relPath; + m_relPath = CanonRelPath(parentPath.m_relPath + '/' + usePath); + m_absPath = std::string(m_proj->getProjectRootPath().getAbsolutePath()) + '/' + m_relPath; SanitizePath(m_relPath); SanitizePath(m_absPath); ComputeHash(); } -#if HECL_UCS2 -void ProjectPath::assign(const ProjectPath& parentPath, std::string_view path) { - std::wstring wpath = UTF8ToWide(path); - assign(parentPath, wpath); -} -#endif - -ProjectPath ProjectPath::getWithExtension(const SystemChar* ext, bool replace) const { +ProjectPath ProjectPath::getWithExtension(const char* ext, bool replace) const { ProjectPath pp(*this); if (replace) { auto relIt = pp.m_relPath.end(); @@ -113,11 +99,11 @@ ProjectPath ProjectPath::getWithExtension(const SystemChar* ext, bool replace) c auto absIt = pp.m_absPath.end(); if (absIt != pp.m_absPath.begin()) --absIt; - while (relIt != pp.m_relPath.begin() && *relIt != _SYS_STR('.') && *relIt != _SYS_STR('/')) { + while (relIt != pp.m_relPath.begin() && *relIt != '.' && *relIt != '/') { --relIt; --absIt; } - if (*relIt == _SYS_STR('.') && relIt != pp.m_relPath.begin()) { + if (*relIt == '.' && relIt != pp.m_relPath.begin()) { pp.m_relPath.resize(relIt - pp.m_relPath.begin()); pp.m_absPath.resize(absIt - pp.m_absPath.begin()); } @@ -136,7 +122,7 @@ ProjectPath ProjectPath::getCookedPath(const Database::DataSpecEntry& spec) cons ProjectPath ret(m_proj->getProjectCookedPath(spec), woExt.getRelativePath()); if (getAuxInfo().size()) - return ret.getWithExtension((SystemString(_SYS_STR(".")) + getAuxInfo().data()).c_str()); + return ret.getWithExtension((std::string(".") + getAuxInfo().data()).c_str()); else return ret; } @@ -144,7 +130,7 @@ ProjectPath ProjectPath::getCookedPath(const Database::DataSpecEntry& spec) cons ProjectPath::Type ProjectPath::getPathType() const { if (m_absPath.empty()) return Type::None; - if (m_absPath.find(_SYS_STR('*')) != SystemString::npos) + if (m_absPath.find('*') != std::string::npos) return Type::Glob; Sstat theStat; if (hecl::Stat(m_absPath.c_str(), &theStat)) @@ -159,7 +145,7 @@ ProjectPath::Type ProjectPath::getPathType() const { Time ProjectPath::getModtime() const { Sstat theStat; time_t latestTime = 0; - if (m_absPath.find(_SYS_STR('*')) != SystemString::npos) { + if (m_absPath.find('*') != std::string::npos) { std::vector globResults; getGlobResults(globResults); for (ProjectPath& path : globResults) { @@ -184,21 +170,21 @@ Time ProjectPath::getModtime() const { return Time(latestTime); } } - LogModule.report(logvisor::Fatal, FMT_STRING(_SYS_STR("invalid path type for computing modtime in '{}'")), m_absPath); + LogModule.report(logvisor::Fatal, FMT_STRING("invalid path type for computing modtime in '{}'"), m_absPath); return Time(); } -static void _recursiveGlob(Database::Project& proj, std::vector& outPaths, const SystemString& remPath, - const SystemString& itStr, bool needSlash) { - SystemRegexMatch matches; +static void _recursiveGlob(Database::Project& proj, std::vector& outPaths, const std::string& remPath, + const std::string& itStr, bool needSlash) { + std::smatch matches; if (!std::regex_search(remPath, matches, regPATHCOMP)) return; - const SystemString& comp = matches[1]; - if (comp.find(_SYS_STR('*')) == SystemString::npos) { - SystemString nextItStr = itStr; + const std::string& comp = matches[1]; + if (comp.find('*') == std::string::npos) { + std::string nextItStr = itStr; if (needSlash) - nextItStr += _SYS_STR('/'); + nextItStr += '/'; nextItStr += comp; hecl::Sstat theStat; @@ -213,12 +199,12 @@ static void _recursiveGlob(Database::Project& proj, std::vector& ou } /* Compile component into regex */ - SystemRegex regComp(comp, SystemRegex::ECMAScript); + std::regex regComp(comp, std::regex::ECMAScript); hecl::DirectoryEnumerator de(itStr, hecl::DirectoryEnumerator::Mode::DirsThenFilesSorted, false, false, true); for (const hecl::DirectoryEnumerator::Entry& ent : de) { if (std::regex_match(ent.m_name, regComp)) { - SystemString nextItStr = itStr; + std::string nextItStr = itStr; if (needSlash) nextItStr += '/'; nextItStr += ent.m_name; @@ -235,7 +221,7 @@ static void _recursiveGlob(Database::Project& proj, std::vector& ou } } -void ProjectPath::getDirChildren(std::map& outPaths) const { +void ProjectPath::getDirChildren(std::map& outPaths) const { hecl::DirectoryEnumerator de(m_absPath, hecl::DirectoryEnumerator::Mode::DirsThenFilesSorted, false, false, true); for (const hecl::DirectoryEnumerator::Entry& ent : de) outPaths[ent.m_name] = ProjectPath(*this, ent.m_name); @@ -247,7 +233,7 @@ hecl::DirectoryEnumerator ProjectPath::enumerateDir() const { void ProjectPath::getGlobResults(std::vector& outPaths) const { auto rootPath = m_proj->getProjectRootPath().getAbsolutePath(); - _recursiveGlob(*m_proj, outPaths, m_relPath, rootPath.data(), rootPath.back() != _SYS_STR('/')); + _recursiveGlob(*m_proj, outPaths, m_relPath, rootPath.data(), rootPath.back() != '/'); } template @@ -265,18 +251,18 @@ static bool RegexSearchLast(const T& str, std::match_results match; if (RegexSearchLast(getLastComponent(), match, regParsedHash32)) { auto hexStr = match[1].str(); if (auto val = hecl::StrToUl(hexStr.c_str(), nullptr, 16)) @@ -286,17 +272,17 @@ uint32_t ProjectPath::parsedHash32() const { return hash().val32(); } -ProjectRootPath SearchForProject(SystemStringView path) { +ProjectRootPath SearchForProject(std::string_view path) { ProjectRootPath testRoot(path); auto begin = testRoot.getAbsolutePath().begin(); auto end = testRoot.getAbsolutePath().end(); while (begin != end) { - SystemString testPath(begin, end); - SystemString testIndexPath = testPath + _SYS_STR("/.hecl/beacon"); + std::string testPath(begin, end); + std::string testIndexPath = testPath + "/.hecl/beacon"; Sstat theStat; if (!hecl::Stat(testIndexPath.c_str(), &theStat)) { if (S_ISREG(theStat.st_mode)) { - const auto fp = hecl::FopenUnique(testIndexPath.c_str(), _SYS_STR("rb")); + const auto fp = hecl::FopenUnique(testIndexPath.c_str(), "rb"); if (fp == nullptr) { continue; } @@ -316,7 +302,7 @@ ProjectRootPath SearchForProject(SystemStringView path) { } } - while (begin != end && *(end - 1) != _SYS_STR('/') && *(end - 1) != _SYS_STR('\\')) + while (begin != end && *(end - 1) != '/' && *(end - 1) != '\\') --end; if (begin != end) --end; @@ -324,19 +310,19 @@ ProjectRootPath SearchForProject(SystemStringView path) { return ProjectRootPath(); } -ProjectRootPath SearchForProject(SystemStringView path, SystemString& subpathOut) { +ProjectRootPath SearchForProject(std::string_view path, std::string& subpathOut) { const ProjectRootPath testRoot(path); auto begin = testRoot.getAbsolutePath().begin(); auto end = testRoot.getAbsolutePath().end(); while (begin != end) { - SystemString testPath(begin, end); - SystemString testIndexPath = testPath + _SYS_STR("/.hecl/beacon"); + std::string testPath(begin, end); + std::string testIndexPath = testPath + "/.hecl/beacon"; Sstat theStat; if (!hecl::Stat(testIndexPath.c_str(), &theStat)) { if (S_ISREG(theStat.st_mode)) { - const auto fp = hecl::FopenUnique(testIndexPath.c_str(), _SYS_STR("rb")); + const auto fp = hecl::FopenUnique(testIndexPath.c_str(), "rb"); if (fp == nullptr) { continue; } @@ -352,10 +338,10 @@ ProjectRootPath SearchForProject(SystemStringView path, SystemString& subpathOut const ProjectRootPath newRootPath = ProjectRootPath(testPath); const auto origEnd = testRoot.getAbsolutePath().end(); - while (end != origEnd && *end != _SYS_STR('/') && *end != _SYS_STR('\\')) { + while (end != origEnd && *end != '/' && *end != '\\') { ++end; } - if (end != origEnd && (*end == _SYS_STR('/') || *end == _SYS_STR('\\'))) { + if (end != origEnd && (*end == '/' || *end == '\\')) { ++end; } @@ -364,7 +350,7 @@ ProjectRootPath SearchForProject(SystemStringView path, SystemString& subpathOut } } - while (begin != end && *(end - 1) != _SYS_STR('/') && *(end - 1) != _SYS_STR('\\')) { + while (begin != end && *(end - 1) != '/' && *(end - 1) != '\\') { --end; } if (begin != end) { diff --git a/hecl/lib/Runtime/FileStoreManager.cpp b/hecl/lib/Runtime/FileStoreManager.cpp index 1dfe59a59..91c585e0d 100644 --- a/hecl/lib/Runtime/FileStoreManager.cpp +++ b/hecl/lib/Runtime/FileStoreManager.cpp @@ -15,22 +15,22 @@ using namespace Windows::Storage; namespace hecl::Runtime { static logvisor::Module Log("FileStoreManager"); -FileStoreManager::FileStoreManager(SystemStringView domain) : m_domain(domain) { +FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) { #if _WIN32 #if !WINDOWS_STORE WCHAR home[MAX_PATH]; if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home))) - Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to locate profile for file store"))); + Log.report(logvisor::Fatal, FMT_STRING("unable to locate profile for file store")); - SystemString path(home); + std::string path = nowide::narrow(home); #else StorageFolder ^ cacheFolder = ApplicationData::Current->LocalCacheFolder; - SystemString path(cacheFolder->Path->Data()); + std::string path(cacheFolder->Path->Data()); #endif - path += _SYS_STR("/.heclrun"); + path += "/.heclrun"; hecl::MakeDir(path.c_str()); - path += _SYS_STR('/'); + path += '/'; path += domain.data(); hecl::MakeDir(path.c_str()); diff --git a/hecl/lib/SteamFinder.cpp b/hecl/lib/SteamFinder.cpp index a930e5d5f..6f4073058 100644 --- a/hecl/lib/SteamFinder.cpp +++ b/hecl/lib/SteamFinder.cpp @@ -2,7 +2,7 @@ #include "hecl/hecl.hpp" #ifdef WIN32 #include -#define PATH_SEP L'\\' +#define PATH_SEP '\\' #else #define PATH_SEP '/' #endif @@ -12,25 +12,25 @@ namespace hecl { /* Used to extract alternate steam install directories from libraryfolders.vdf */ static const std::regex regSteamPath(R"(^\s+\"[0-9]+\"\s+\"(.*)\")", std::regex::ECMAScript | std::regex::optimize); -hecl::SystemString FindCommonSteamApp(const hecl::SystemChar* name) { - hecl::SystemString steamInstallDir; +std::string FindCommonSteamApp(const char* name) { + std::string steamInstallDir; hecl::Sstat theStat; #ifdef WIN32 #if !WINDOWS_STORE HKEY hkey; - hecl::SystemChar _steamInstallDir[MAX_PATH] = {0}; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _SYS_STR("Software\\Valve\\Steam"), 0, KEY_QUERY_VALUE, &hkey) != + wchar_t _steamInstallDir[MAX_PATH] = {0}; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) { - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _SYS_STR("Software\\Valve\\Steam"), 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Valve\\Steam", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &hkey) != ERROR_SUCCESS) return {}; } DWORD size = MAX_PATH; - if (RegQueryValueEx(hkey, _SYS_STR("InstallPath"), nullptr, nullptr, (LPBYTE)_steamInstallDir, &size) == + if (RegQueryValueEx(hkey, L"InstallPath", nullptr, nullptr, (LPBYTE)_steamInstallDir, &size) == ERROR_SUCCESS) - steamInstallDir = _steamInstallDir; + steamInstallDir = nowide::narrow(_steamInstallDir); RegCloseKey(hkey); if (steamInstallDir.empty()) @@ -57,18 +57,18 @@ hecl::SystemString FindCommonSteamApp(const hecl::SystemChar* name) { #endif - const hecl::SystemString appPath = hecl::SystemString(_SYS_STR("common")) + PATH_SEP + name; + const std::string appPath = std::string("common") + PATH_SEP + name; /* Try main steam install directory first */ - const hecl::SystemString steamAppsMain = steamInstallDir + PATH_SEP + _SYS_STR("steamapps"); - const hecl::SystemString mainAppPath = steamAppsMain + PATH_SEP + appPath; + const std::string steamAppsMain = steamInstallDir + PATH_SEP + "steamapps"; + const std::string mainAppPath = steamAppsMain + PATH_SEP + appPath; if (!hecl::Stat(mainAppPath.c_str(), &theStat) && S_ISDIR(theStat.st_mode)) { return mainAppPath; } /* Iterate alternate steam install dirs */ - const hecl::SystemString libraryFoldersVdfPath = steamAppsMain + PATH_SEP + _SYS_STR("libraryfolders.vdf"); - auto fp = hecl::FopenUnique(libraryFoldersVdfPath.c_str(), _SYS_STR("r")); + const std::string libraryFoldersVdfPath = steamAppsMain + PATH_SEP + "libraryfolders.vdf"; + auto fp = hecl::FopenUnique(libraryFoldersVdfPath.c_str(), "r"); if (fp == nullptr) { return {}; } @@ -88,9 +88,8 @@ hecl::SystemString FindCommonSteamApp(const hecl::SystemChar* name) { const auto end = fileBuf.cend(); while (std::regex_search(begin, end, dirMatch, regSteamPath)) { const std::string match = dirMatch[1].str(); - const hecl::SystemStringConv otherInstallDir(match); const auto otherAppPath = - hecl::SystemString(otherInstallDir.sys_str()) + PATH_SEP + _SYS_STR("steamapps") + PATH_SEP + appPath; + std::string(match.c_str()) + PATH_SEP + "steamapps" + PATH_SEP + appPath; if (!hecl::Stat(otherAppPath.c_str(), &theStat) && S_ISDIR(theStat.st_mode)) { return otherAppPath; diff --git a/hecl/lib/WideStringConvert.cpp b/hecl/lib/WideStringConvert.cpp index 036e3d385..da496d659 100644 --- a/hecl/lib/WideStringConvert.cpp +++ b/hecl/lib/WideStringConvert.cpp @@ -4,21 +4,6 @@ namespace hecl { static logvisor::Module Log("hecl-wsconv"); -std::string WideToUTF8(std::wstring_view src) { - std::string retval; - retval.reserve(src.length()); - for (wchar_t ch : src) { - utf8proc_uint8_t mb[4]; - utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb); - if (c < 0) { - Log.report(logvisor::Warning, FMT_STRING("invalid UTF-8 character while encoding")); - return retval; - } - retval.append(reinterpret_cast(mb), c); - } - return retval; -} - std::string Char16ToUTF8(std::u16string_view src) { std::string retval; retval.reserve(src.length()); @@ -34,23 +19,6 @@ std::string Char16ToUTF8(std::u16string_view src) { return retval; } -std::wstring UTF8ToWide(std::string_view src) { - std::wstring retval; - retval.reserve(src.length()); - const utf8proc_uint8_t* buf = reinterpret_cast(src.data()); - while (*buf) { - utf8proc_int32_t wc; - utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); - if (len < 0) { - Log.report(logvisor::Warning, FMT_STRING("invalid UTF-8 character while decoding")); - return retval; - } - buf += len; - retval += wchar_t(wc); - } - return retval; -} - std::u16string UTF8ToChar16(std::string_view src) { std::u16string retval; retval.reserve(src.length()); diff --git a/hecl/lib/hecl.cpp b/hecl/lib/hecl.cpp index 5bf82af00..59d5d38df 100644 --- a/hecl/lib/hecl.cpp +++ b/hecl/lib/hecl.cpp @@ -28,6 +28,7 @@ #include #endif +#include #include using namespace std::literals; @@ -66,44 +67,14 @@ void SanitizePath(std::string& path) { path.pop_back(); } -constexpr std::wstring_view WIllegals = L"<>?\""sv; - -void SanitizePath(std::wstring& path) { - if (path.empty()) - return; - path.erase(std::remove(path.begin(), path.end(), L'\n'), path.end()); - path.erase(std::remove(path.begin(), path.end(), L'\r'), path.end()); - std::wstring::iterator p1 = path.begin(); - bool ic = false; - std::transform(path.begin(), path.end(), path.begin(), [&](const wchar_t a) -> wchar_t { - ++p1; - if (WIllegals.find_first_of(a) != std::wstring::npos) { - ic = false; - return L'_'; - } - - if (ic) { - ic = false; - return a; - } - if (a == L'\\' && (p1 == path.end() || *p1 != L'\\')) { - ic = true; - return L'/'; - } - return a; - }); - while (path.back() == L'/') - path.pop_back(); -} - -SystemString GetcwdStr() { +std::string GetcwdStr() { /* http://stackoverflow.com/a/2869667 */ // const size_t ChunkSize=255; // const int MaxChunks=10240; // 2550 KiBs of current path are more than enough - SystemChar stackBuffer[255]; // Stack buffer for the "normal" case + char stackBuffer[255]; // Stack buffer for the "normal" case if (Getcwd(stackBuffer, int(std::size(stackBuffer))) != nullptr) { - return SystemString(stackBuffer); + return std::string(stackBuffer); } if (errno != ERANGE) { // It's not ERANGE, so we don't know how to handle it @@ -115,9 +86,9 @@ SystemString GetcwdStr() { // With boost use scoped_ptr; in C++0x, use unique_ptr // If you want to be less C++ but more efficient you may want to use realloc const int bufSize = 255 * chunks; - std::unique_ptr cwd(new SystemChar[bufSize]); + std::unique_ptr cwd(new char[bufSize]); if (Getcwd(cwd.get(), bufSize) != nullptr) { - return SystemString(cwd.get()); + return std::string(cwd.get()); } if (errno != ERANGE) { // It's not ERANGE, so we don't know how to handle it @@ -125,8 +96,9 @@ SystemString GetcwdStr() { // Of course you may choose a different error reporting method } } - LogModule.report(logvisor::Fatal, FMT_STRING("Cannot determine the current path; the path is apparently unreasonably long")); - return SystemString(); + LogModule.report(logvisor::Fatal, + FMT_STRING("Cannot determine the current path; the path is apparently unreasonably long")); + return std::string(); } static std::mutex PathsMutex; @@ -160,7 +132,7 @@ void ResourceLock::ClearThreadRes() { } bool IsPathPNG(const hecl::ProjectPath& path) { - const auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), _SYS_STR("rb")); + const auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), "rb"); if (fp == nullptr) { return false; } @@ -176,10 +148,10 @@ bool IsPathPNG(const hecl::ProjectPath& path) { bool IsPathBlend(const hecl::ProjectPath& path) { const auto lastCompExt = path.getLastComponentExt(); - if (lastCompExt.empty() || lastCompExt != _SYS_STR("blend")) + if (lastCompExt.empty() || lastCompExt != "blend") return false; - const auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), _SYS_STR("rb")); + const auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), "rb"); if (fp == nullptr) { return false; } @@ -195,132 +167,162 @@ bool IsPathBlend(const hecl::ProjectPath& path) { bool IsPathYAML(const hecl::ProjectPath& path) { auto lastComp = path.getLastComponent(); - if (lastComp == _SYS_STR("!catalog.yaml") || - lastComp == _SYS_STR("!memoryid.yaml") || - lastComp == _SYS_STR("!memoryrelays.yaml")) + if (lastComp == "!catalog.yaml" || lastComp == "!memoryid.yaml" || lastComp == "!memoryrelays.yaml") return false; /* !catalog.yaml, !memoryid.yaml, !memoryrelays.yaml are exempt from general use */ auto lastCompExt = path.getLastComponentExt(); if (lastCompExt.empty()) return false; - return lastCompExt == _SYS_STR("yaml") || lastCompExt == _SYS_STR("yml"); + return lastCompExt == "yaml" || lastCompExt == "yml"; } -hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, bool sizeSort, bool reverse, +hecl::DirectoryEnumerator::DirectoryEnumerator(std::string_view path, Mode mode, bool sizeSort, bool reverse, bool noHidden) { - hecl::Sstat theStat; - if (hecl::Stat(path.data(), &theStat) || !S_ISDIR(theStat.st_mode)) + Sstat theStat; + if (Stat(path.data(), &theStat) || !S_ISDIR(theStat.st_mode)) { return; + } #if _WIN32 - hecl::SystemString wc(path); - wc += _SYS_STR("/*"); + std::wstring wc = nowide::widen(path); + wc += L"/*"; WIN32_FIND_DATAW d; HANDLE dir = FindFirstFileW(wc.c_str(), &d); - if (dir == INVALID_HANDLE_VALUE) + if (dir == INVALID_HANDLE_VALUE) { return; + } switch (mode) { case Mode::Native: do { - if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) + if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) { continue; - if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) + } + if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) { continue; - hecl::SystemString fp(path); - fp += _SYS_STR('/'); - fp += d.cFileName; - hecl::Sstat st; - if (hecl::Stat(fp.c_str(), &st)) + } + std::string fileName = nowide::narrow(d.cFileName); + std::string fp(path); + fp += '/'; + fp += fileName; + Sstat st; + if (Stat(fp.c_str(), &st)) continue; size_t sz = 0; bool isDir = false; - if (S_ISDIR(st.st_mode)) + if (S_ISDIR(st.st_mode)) { isDir = true; - else if (S_ISREG(st.st_mode)) + } else if (S_ISREG(st.st_mode)) { sz = st.st_size; - else + } else { continue; + } - m_entries.emplace_back(fp, d.cFileName, sz, isDir); + m_entries.emplace_back(fp, fileName, sz, isDir); } while (FindNextFileW(dir, &d)); break; case Mode::DirsThenFilesSorted: case Mode::DirsSorted: { - std::map sort; + std::map sort; do { - if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) + if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) { continue; - if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) + } + if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) { continue; - hecl::SystemString fp(path); - fp += _SYS_STR('/'); - fp += d.cFileName; - hecl::Sstat st; - if (hecl::Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode)) + } + std::string fileName = nowide::narrow(d.cFileName); + std::string fp(path); + fp += '/'; + fp += fileName; + Sstat st; + if (Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode)) { continue; - sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, 0, true))); + } + sort.emplace(fileName, Entry{fp, fileName, 0, true}); } while (FindNextFileW(dir, &d)); - if (reverse) - for (auto it = sort.crbegin(); it != sort.crend(); ++it) - m_entries.push_back(std::move(it->second)); - else - for (auto& e : sort) - m_entries.push_back(std::move(e.second)); + m_entries.reserve(sort.size()); + if (reverse) { + for (auto& it : std::ranges::reverse_view(sort)) { + m_entries.emplace_back(std::move(it.second)); + } + } else { + for (auto& e : sort) { + m_entries.emplace_back(std::move(e.second)); + } + } - if (mode == Mode::DirsSorted) + if (mode == Mode::DirsSorted) { break; + } FindClose(dir); dir = FindFirstFileW(wc.c_str(), &d); } case Mode::FilesSorted: { - if (mode == Mode::FilesSorted) + if (mode == Mode::FilesSorted) { m_entries.clear(); + } if (sizeSort) { std::multimap sort; do { - if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) + if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) { continue; - if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) + } + if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) { continue; - hecl::SystemString fp(path); - fp += _SYS_STR('/'); - fp += d.cFileName; - hecl::Sstat st; - if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) + } + std::string fileName = nowide::narrow(d.cFileName); + std::string fp(path); + fp += '/'; + fp += fileName; + Sstat st; + if (Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) { continue; - sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d.cFileName, st.st_size, false))); + } + sort.emplace(st.st_size, Entry{fp, fileName, static_cast(st.st_size), false}); } while (FindNextFileW(dir, &d)); - if (reverse) - for (auto it = sort.crbegin(); it != sort.crend(); ++it) - m_entries.push_back(std::move(it->second)); - else - for (auto& e : sort) - m_entries.push_back(std::move(e.second)); + m_entries.reserve(m_entries.size() + sort.size()); + if (reverse) { + for (auto& it : std::ranges::reverse_view(sort)) { + m_entries.emplace_back(std::move(it.second)); + } + } else { + for (auto& e : sort) { + m_entries.emplace_back(std::move(e.second)); + } + } } else { - std::map sort; + std::map sort; do { - if (!wcscmp(d.cFileName, _SYS_STR(".")) || !wcscmp(d.cFileName, _SYS_STR(".."))) + if (!wcscmp(d.cFileName, L".") || !wcscmp(d.cFileName, L"..")) { continue; - if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) + } + if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) { continue; - hecl::SystemString fp(path); - fp += _SYS_STR('/'); - fp += d.cFileName; - hecl::Sstat st; - if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) + } + std::string fileName = nowide::narrow(d.cFileName); + std::string fp(path); + fp += '/'; + fp += fileName; + Sstat st; + if (Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) { continue; - sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, st.st_size, false))); + } + sort.emplace(fileName, Entry{fp, fileName, static_cast(st.st_size), false}); } while (FindNextFileW(dir, &d)); - if (reverse) - for (auto it = sort.crbegin(); it != sort.crend(); ++it) - m_entries.push_back(std::move(it->second)); - else - for (auto& e : sort) - m_entries.push_back(std::move(e.second)); + m_entries.reserve(m_entries.size() + sort.size()); + if (reverse) { + for (auto& e : std::ranges::reverse_view(sort)) { + m_entries.emplace_back(std::move(e.second)); + } + } else { + for (auto& e : sort) { + m_entries.emplace_back(std::move(e.second)); + } + } } break; @@ -341,7 +343,7 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, continue; if (noHidden && d->d_name[0] == '.') continue; - hecl::SystemString fp(path); + std::string fp(path); fp += '/'; fp += d->d_name; hecl::Sstat st; @@ -362,13 +364,13 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, break; case Mode::DirsThenFilesSorted: case Mode::DirsSorted: { - std::map sort; + std::map sort; while ((d = readdir(dir))) { if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) continue; if (noHidden && d->d_name[0] == '.') continue; - hecl::SystemString fp(path); + std::string fp(path); fp += '/'; fp += d->d_name; hecl::Sstat st; @@ -400,7 +402,7 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, continue; if (noHidden && d->d_name[0] == '.') continue; - hecl::SystemString fp(path); + std::string fp(path); fp += '/'; fp += d->d_name; hecl::Sstat st; @@ -416,13 +418,13 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, for (auto& e : sort) m_entries.push_back(std::move(e.second)); } else { - std::map sort; + std::map sort; while ((d = readdir(dir))) { if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) continue; if (noHidden && d->d_name[0] == '.') continue; - hecl::SystemString fp(path); + std::string fp(path); fp += '/'; fp += d->d_name; hecl::Sstat st; @@ -447,159 +449,24 @@ hecl::DirectoryEnumerator::DirectoryEnumerator(SystemStringView path, Mode mode, #endif } -static std::pair NameFromPath(hecl::SystemStringView path) { - hecl::SystemUTF8Conv utf8(path); - if (utf8.str().size() == 1 && utf8.str()[0] == '/') - return {hecl::SystemString(path), "/"}; - size_t lastSlash = utf8.str().rfind('/'); +static std::pair NameFromPath(std::string_view path) { + if (path.size() == 1 && path[0] == '/') + return {std::string(path), "/"}; + size_t lastSlash = path.rfind('/'); if (lastSlash != std::string::npos) - return {hecl::SystemString(path), std::string(utf8.str().cbegin() + lastSlash + 1, utf8.str().cend())}; + return {std::string(path), std::string(path.cbegin() + lastSlash + 1, path.cend())}; else - return {hecl::SystemString(path), std::string(utf8.str())}; + return {std::string(path), std::string(path)}; } -std::vector> GetSystemLocations() { - std::vector> ret; -#ifdef WIN32 -#if !WINDOWS_STORE - /* Add the drive names to the listing (as queried by blender) */ - { - constexpr uint32_t FILE_MAXDIR = 768; - wchar_t wline[FILE_MAXDIR]; - const uint32_t tmp = GetLogicalDrives(); - - for (uint32_t i = 0; i < 26; i++) { - if ((tmp >> i) & 1) { - wline[0] = L'A' + i; - wline[1] = L':'; - wline[2] = L'/'; - wline[3] = L'\0'; - wchar_t* name = nullptr; - - /* Flee from horrible win querying hover floppy drives! */ - if (i > 1) { - /* Try to get volume label as well... */ - if (GetVolumeInformationW(wline, wline + 4, FILE_MAXDIR - 4, nullptr, nullptr, nullptr, nullptr, 0)) { - const size_t labelLen = std::wcslen(wline + 4); - _snwprintf(wline + 4 + labelLen, FILE_MAXDIR - 4 - labelLen, L" (%.2s)", wline); - name = wline + 4; - } - } - - wline[2] = L'\0'; - if (name == nullptr) { - ret.push_back(NameFromPath(wline)); - } else { - ret.emplace_back(wline, hecl::WideToUTF8(name)); - } - } - } - - /* Adding Desktop and My Documents */ - SystemString wpath; - SHGetSpecialFolderPathW(nullptr, wline, CSIDL_PERSONAL, 0); - wpath.assign(wline); - SanitizePath(wpath); - ret.push_back(NameFromPath(wpath)); - SHGetSpecialFolderPathW(nullptr, wline, CSIDL_DESKTOPDIRECTORY, 0); - wpath.assign(wline); - SanitizePath(wpath); - ret.push_back(NameFromPath(wpath)); - } -#endif -#else -#ifdef __APPLE__ - { - hecl::Sstat theStat; - const char* home = getenv("HOME"); - - if (home) { - ret.push_back(NameFromPath(home)); - std::string desktop(home); - desktop += "/Desktop"; - if (!hecl::Stat(desktop.c_str(), &theStat)) - ret.push_back(NameFromPath(desktop)); - } - - /* Get mounted volumes better method OSX 10.6 and higher, see: */ - /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ - /* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */ - - CFURLRef cfURL = nullptr; - CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; - CFURLEnumeratorRef volEnum = - CFURLEnumeratorCreateForMountedVolumes(nullptr, kCFURLEnumeratorSkipInvisibles, nullptr); - - while (result != kCFURLEnumeratorEnd) { - char defPath[1024]; - - result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, nullptr); - if (result != kCFURLEnumeratorSuccess) { - continue; - } - - CFURLGetFileSystemRepresentation(cfURL, false, reinterpret_cast(defPath), std::size(defPath)); - ret.push_back(NameFromPath(defPath)); - } - - CFRelease(volEnum); - } -#else - /* unix */ - { - hecl::Sstat theStat; - const char* home = getenv("HOME"); - - if (home) { - ret.push_back(NameFromPath(home)); - std::string desktop(home); - desktop += "/Desktop"; - if (!hecl::Stat(desktop.c_str(), &theStat)) - ret.push_back(NameFromPath(desktop)); - } - - { - bool found = false; -#ifdef __linux__ - /* Loop over mount points */ - struct mntent* mnt; - - FILE* fp = setmntent(MOUNTED, "r"); - if (fp) { - while ((mnt = getmntent(fp))) { - if (strlen(mnt->mnt_fsname) < 4 || strncmp(mnt->mnt_fsname, "/dev", 4)) - continue; - - std::string mntStr(mnt->mnt_dir); - if (mntStr.size() > 1 && mntStr.back() == '/') - mntStr.pop_back(); - ret.push_back(NameFromPath(mntStr)); - - found = true; - } - endmntent(fp); - } -#endif - /* Fallback */ - if (!found) - ret.push_back(NameFromPath("/")); - } - } -#endif -#endif - return ret; -} - -std::wstring Char16ToWide(std::u16string_view src) { return std::wstring(src.begin(), src.end()); } - /* recursive mkdir */ #if _WIN32 -int RecursiveMakeDir(const SystemChar* dir) { - SystemChar tmp[1024]; +int RecursiveMakeDir(const char* dir) { + char tmp[1024]; /* copy path */ - std::wcsncpy(tmp, dir, std::size(tmp)); - const size_t len = std::wcslen(tmp); + std::strncpy(tmp, dir, std::size(tmp)); + const size_t len = std::strlen(tmp); if (len >= std::size(tmp)) { return -1; } @@ -610,7 +477,7 @@ int RecursiveMakeDir(const SystemChar* dir) { } /* recursive mkdir */ - SystemChar* p = nullptr; + char* p = nullptr; Sstat sb; for (p = tmp + 1; *p; p++) { if (*p == '/' || *p == '\\') { @@ -618,7 +485,8 @@ int RecursiveMakeDir(const SystemChar* dir) { /* test path */ if (Stat(tmp, &sb) != 0) { /* path does not exist - create directory */ - if (!CreateDirectoryW(tmp, nullptr)) { + const nowide::wstackstring wtmp(tmp); + if (!CreateDirectoryW(wtmp.get(), nullptr)) { return -1; } } else if (!S_ISDIR(sb.st_mode)) { @@ -631,7 +499,8 @@ int RecursiveMakeDir(const SystemChar* dir) { /* test path */ if (Stat(tmp, &sb) != 0) { /* path does not exist - create directory */ - if (!CreateDirectoryW(tmp, nullptr)) { + const nowide::wstackstring wtmp(tmp); + if (!CreateDirectoryW(wtmp.get(), nullptr)) { return -1; } } else if (!S_ISDIR(sb.st_mode)) { @@ -641,8 +510,8 @@ int RecursiveMakeDir(const SystemChar* dir) { return 0; } #else -int RecursiveMakeDir(const SystemChar* dir) { - SystemChar tmp[1024]; +int RecursiveMakeDir(const char* dir) { + char tmp[1024]; /* copy path */ std::memset(tmp, 0, std::size(tmp)); @@ -658,7 +527,7 @@ int RecursiveMakeDir(const SystemChar* dir) { } /* recursive mkdir */ - SystemChar* p = nullptr; + char* p = nullptr; Sstat sb; for (p = tmp + 1; *p; p++) { if (*p == '/') { @@ -690,25 +559,27 @@ int RecursiveMakeDir(const SystemChar* dir) { } #endif -const SystemChar* GetTmpDir() { +std::string GetTmpDir() { #ifdef _WIN32 #if WINDOWS_STORE const wchar_t* TMPDIR = nullptr; #else - const wchar_t* TMPDIR = _wgetenv(L"TEMP"); - if (!TMPDIR) - TMPDIR = L"\\Temp"; + auto TMPDIR = GetEnv("TEMP"); + if (!TMPDIR) { + return "\\Temp"; + } + return std::move(TMPDIR.value()); #endif #else const char* TMPDIR = getenv("TMPDIR"); if (!TMPDIR) TMPDIR = "/tmp"; -#endif return TMPDIR; +#endif } #if !WINDOWS_STORE -int RunProcess(const SystemChar* path, const SystemChar* const args[]) { +int RunProcess(const char* path, const char* const args[]) { #ifdef _WIN32 SECURITY_ATTRIBUTES sattrs = {sizeof(SECURITY_ATTRIBUTES), nullptr, TRUE}; HANDLE consoleOutReadTmp = INVALID_HANDLE_VALUE; @@ -741,12 +612,12 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) { CloseHandle(consoleOutReadTmp); - hecl::SystemString cmdLine; - const SystemChar* const* arg = &args[1]; + std::wstring cmdLine; + const char* const* arg = &args[1]; while (*arg) { - cmdLine += _SYS_STR(" \""); - cmdLine += *arg++; - cmdLine += _SYS_STR('"'); + cmdLine += L" \""; + cmdLine += nowide::widen(*arg++); + cmdLine += L'"'; } STARTUPINFO sinfo = {sizeof(STARTUPINFO)}; @@ -758,12 +629,14 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) { sinfo.hStdOutput = consoleOutWrite; PROCESS_INFORMATION pinfo = {}; - if (!CreateProcessW(path, cmdLine.data(), nullptr, nullptr, TRUE, NORMAL_PRIORITY_CLASS, nullptr, nullptr, &sinfo, - &pinfo)) { + const nowide::wstackstring wpath(path); + if (!CreateProcessW(wpath.get(), cmdLine.data(), nullptr, nullptr, TRUE, NORMAL_PRIORITY_CLASS, nullptr, nullptr, + &sinfo, &pinfo)) { LPWSTR messageBuffer = nullptr; FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr); - LogModule.report(logvisor::Error, FMT_STRING(L"unable to launch process from {}: {}"), path, messageBuffer); + LogModule.report(logvisor::Error, FMT_STRING("unable to launch process from {}: {}"), path, + nowide::narrow(messageBuffer)); LocalFree(messageBuffer); CloseHandle(nulHandle); diff --git a/hecl/shaderc/main.cpp b/hecl/shaderc/main.cpp index e8d44eac6..9cb4f5509 100644 --- a/hecl/shaderc/main.cpp +++ b/hecl/shaderc/main.cpp @@ -4,6 +4,7 @@ #include "glslang/Public/ShaderLang.h" #include "hecl/hecl.hpp" #include +#include static logvisor::Module Log("shaderc"); @@ -32,12 +33,12 @@ static bool FindBestD3DCompile() { } return false; } - -int wmain(int argc, const hecl::SystemChar** argv) -#else -int main(int argc, const hecl::SystemChar** argv) #endif -{ + +int main(int argc, char** argv) { +#if _WIN32 + nowide::args _(argc, argv); +#endif logvisor::RegisterConsoleLogger(); logvisor::RegisterStandardExceptions(); @@ -53,7 +54,7 @@ int main(int argc, const hecl::SystemChar** argv) return 0; } - hecl::SystemString outPath; + std::string outPath; hecl::shaderc::Compiler c; for (int i = 1; i < argc; ++i) { if (argv[i][0] == '-') { @@ -68,7 +69,7 @@ int main(int argc, const hecl::SystemChar** argv) return 1; } } else if (argv[i][1] == 'D') { - const hecl::SystemChar* define; + const char* define; if (argv[i][2]) { define = &argv[i][2]; } else if (i + 1 < argc) { @@ -78,14 +79,12 @@ int main(int argc, const hecl::SystemChar** argv) Log.report(logvisor::Error, FMT_STRING("Invalid -D argument")); return 1; } - hecl::SystemUTF8Conv conv(define); - const char* defineU8 = conv.c_str(); - if (const char* equals = strchr(defineU8, '=')) - c.addDefine(std::string(defineU8, equals - defineU8), equals + 1); + if (const char* equals = strchr(define, '=')) + c.addDefine(std::string(define, equals - define), equals + 1); else - c.addDefine(defineU8, ""); + c.addDefine(define, ""); } else { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unrecognized flag option '{:c}'")), argv[i][1]); + Log.report(logvisor::Error, FMT_STRING("Unrecognized flag option '{:c}'"), argv[i][1]); return 1; } } else { @@ -98,9 +97,9 @@ int main(int argc, const hecl::SystemChar** argv) return 1; } - hecl::SystemStringView baseName; - auto slashPos = outPath.find_last_of(_SYS_STR("/\\")); - if (slashPos != hecl::SystemString::npos) + std::string_view baseName; + auto slashPos = outPath.find_last_of("/\\"); + if (slashPos != std::string::npos) baseName = outPath.data() + slashPos + 1; else baseName = outPath; @@ -110,16 +109,15 @@ int main(int argc, const hecl::SystemChar** argv) return 1; } - hecl::SystemUTF8Conv conv(baseName); std::pair ret; - if (!c.compile(conv.str(), ret)) + if (!c.compile(baseName, ret)) return 1; { - hecl::SystemString headerPath = outPath + _SYS_STR(".hpp"); + std::string headerPath = outPath + ".hpp"; athena::io::FileWriter w(headerPath); if (w.hasError()) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Error opening '{}' for writing")), headerPath); + Log.report(logvisor::Error, FMT_STRING("Error opening '{}' for writing"), headerPath); return 1; } std::string header = ret.first.str(); @@ -127,10 +125,10 @@ int main(int argc, const hecl::SystemChar** argv) } { - hecl::SystemString impPath = outPath + _SYS_STR(".cpp"); + std::string impPath = outPath + ".cpp"; athena::io::FileWriter w(impPath); if (w.hasError()) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Error opening '{}' for writing")), impPath); + Log.report(logvisor::Error, FMT_STRING("Error opening '{}' for writing"), impPath); return 1; } std::string source = ret.second.str(); diff --git a/hecl/shaderc/shaderc.cpp b/hecl/shaderc/shaderc.cpp index ca4cfb181..defc6cd4c 100644 --- a/hecl/shaderc/shaderc.cpp +++ b/hecl/shaderc/shaderc.cpp @@ -28,7 +28,7 @@ static const char* StageNames[] = { "hecl::PipelineStage::Evaluation" }; -const std::string* Compiler::getFileContents(SystemStringView path) { +const std::string* Compiler::getFileContents(std::string_view path) { // TODO: Heterogeneous lookup when C++20 available auto search = m_fileContents.find(path.data()); if (search == m_fileContents.end()) { @@ -42,7 +42,7 @@ const std::string* Compiler::getFileContents(SystemStringView path) { return &search->second; } -void Compiler::addInputFile(SystemStringView file) { +void Compiler::addInputFile(std::string_view file) { if (std::find(m_inputFiles.begin(), m_inputFiles.end(), file) == m_inputFiles.end()) m_inputFiles.emplace_back(file); } @@ -207,25 +207,25 @@ static const std::regex regGeometry(R"(#\s*geometry\s+(.*))", RegexFlags); static const std::regex regControl(R"(#\s*control\s+(.*))", RegexFlags); static const std::regex regEvaluation(R"(#\s*evaluation\s+(.*))", RegexFlags); -bool Compiler::includeFile(SystemStringView file, std::string& out, int depth) { +bool Compiler::includeFile(std::string_view file, std::string& out, int depth) { if (depth > 32) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Too many levels of includes (>32) at '{}'")), file); + Log.report(logvisor::Error, FMT_STRING("Too many levels of includes (>32) at '{}'"), file); return false; } const std::string* data = getFileContents(file); if (!data) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Unable to access '{}'")), file); + Log.report(logvisor::Error, FMT_STRING("Unable to access '{}'"), file); return false; } const std::string& sdata = *data; - SystemString directory; - auto slashPos = file.find_last_of(_SYS_STR("/\\")); - if (slashPos != SystemString::npos) - directory = SystemString(file.data(), slashPos); + std::string directory; + auto slashPos = file.find_last_of("/\\"); + if (slashPos != std::string::npos) + directory = std::string(file.data(), slashPos); else - directory = _SYS_STR("."); + directory = "."; auto begin = sdata.cbegin(); auto end = sdata.cend(); @@ -241,14 +241,13 @@ bool Compiler::includeFile(SystemStringView file, std::string& out, int depth) { if (std::regex_search(begin, nextBegin, subMatch, regInclude)) { std::string path = subMatch[1].str(); if (path.empty()) { - Log.report(logvisor::Error, FMT_STRING(_SYS_STR("Empty path provided to include in '{}'")), file); + Log.report(logvisor::Error, FMT_STRING("Empty path provided to include in '{}'"), file); return false; } - hecl::SystemString pathStr(hecl::SystemStringConv(path).sys_str()); - if (!hecl::IsAbsolute(pathStr)) - pathStr = directory + _SYS_STR('/') + pathStr; - if (!includeFile(pathStr, out, depth + 1)) + if (!hecl::IsAbsolute(path)) + path = directory + '/' + path; + if (!includeFile(path, out, depth + 1)) return false; } else { out.insert(out.end(), begin, nextBegin); @@ -442,7 +441,7 @@ constexpr void SemanticOut(std::stringstream& out, attr.second); } -bool Compiler::compileFile(SystemStringView file, std::string_view baseName, +bool Compiler::compileFile(std::string_view file, std::string_view baseName, std::pair& out) { std::string includesPass; if (!includeFile(file, includesPass)) diff --git a/hecl/shaderc/shaderc.hpp b/hecl/shaderc/shaderc.hpp index 06a343512..152da404a 100644 --- a/hecl/shaderc/shaderc.hpp +++ b/hecl/shaderc/shaderc.hpp @@ -1,5 +1,4 @@ #pragma once -#include "hecl/SystemChar.hpp" #include #include #include @@ -9,9 +8,9 @@ namespace hecl::shaderc { class Compiler { enum class StageType { Vertex, Fragment, Geometry, Control, Evaluation }; - std::vector m_inputFiles; - std::unordered_map m_fileContents; - const std::string* getFileContents(SystemStringView path); + std::vector m_inputFiles; + std::unordered_map m_fileContents; + const std::string* getFileContents(std::string_view path); std::unordered_map m_defines; template static bool StageAction(StageType type, const std::string& name, const std::string& basename, @@ -19,12 +18,12 @@ class Compiler { template static bool StageAction(const std::string& platforms, StageType type, const std::string& name, const std::string& basename, const std::string& stage, std::stringstream& implOut); - bool includeFile(SystemStringView file, std::string& out, int depth = 0); - bool compileFile(SystemStringView file, std::string_view baseName, + bool includeFile(std::string_view file, std::string& out, int depth = 0); + bool compileFile(std::string_view file, std::string_view baseName, std::pair& out); public: - void addInputFile(SystemStringView file); + void addInputFile(std::string_view file); void addDefine(std::string_view var, std::string_view val); bool compile(std::string_view baseName, std::pair& out); }; diff --git a/imgui/ImGuiEngine.cpp b/imgui/ImGuiEngine.cpp index fde1bf3de..7b74a2fad 100644 --- a/imgui/ImGuiEngine.cpp +++ b/imgui/ImGuiEngine.cpp @@ -270,7 +270,7 @@ void ImGuiEngine::End() { bool rebind = false; if (drawData->TotalIdxCount > IndexBufferSize) { #if 0 - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Resizing index buffer ({} < {})")), IndexBufferSize, + Log.report(logvisor::Info, FMT_STRING("Resizing index buffer ({} < {})"), IndexBufferSize, drawData->TotalIdxCount); #endif IndexBufferSize = drawData->TotalIdxCount + 1000; @@ -279,7 +279,7 @@ void ImGuiEngine::End() { } if (drawData->TotalVtxCount > VertexBufferSize) { #if 0 - Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Resizing vertex buffer ({} < {})")), VertexBufferSize, + Log.report(logvisor::Info, FMT_STRING("Resizing vertex buffer ({} < {})"), VertexBufferSize, drawData->TotalVtxCount); #endif VertexBufferSize = drawData->TotalVtxCount + 1000; diff --git a/metaforce-gui/CMakeLists.txt b/metaforce-gui/CMakeLists.txt index e117cb68b..8bd6c19a8 100644 --- a/metaforce-gui/CMakeLists.txt +++ b/metaforce-gui/CMakeLists.txt @@ -43,8 +43,6 @@ add_executable(metaforce-gui WIN32 MACOSX_BUNDLE ExtractZip.cpp ExtractZip.hpp FileDirDialog.hpp - FindBlender.cpp - FindBlender.hpp MainWindow.cpp MainWindow.hpp MainWindow.ui @@ -134,8 +132,6 @@ if (WIN32) platforms/win/metaforce-gui.manifest platforms/win/metaforce-gui.rc ) - target_link_libraries(metaforce-gui PRIVATE - Version) elseif (APPLE) set_target_properties(metaforce-gui PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist" diff --git a/metaforce-gui/MainWindow.cpp b/metaforce-gui/MainWindow.cpp index 36fa272fc..7b3ef4649 100644 --- a/metaforce-gui/MainWindow.cpp +++ b/metaforce-gui/MainWindow.cpp @@ -65,7 +65,7 @@ const QStringList MainWindow::skUpdateTracks = {QStringLiteral("stable"), QStrin MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) , m_ui(std::make_unique()) -, m_fileMgr(_SYS_STR("metaforce")) +, m_fileMgr("metaforce") , m_cvarManager(m_fileMgr) , m_cvarCommons(m_cvarManager) , m_heclProc(this) diff --git a/metaforce-gui/SysReqTableView.cpp b/metaforce-gui/SysReqTableView.cpp index 0bb0ab625..11f43d85a 100644 --- a/metaforce-gui/SysReqTableView.cpp +++ b/metaforce-gui/SysReqTableView.cpp @@ -8,7 +8,7 @@ #include #include #include -#include "FindBlender.hpp" +#include "hecl/Blender/FindBlender.hpp" #include #if _WIN32 diff --git a/metaforce-gui/platforms/freedesktop/CMakeLists.txt b/metaforce-gui/platforms/freedesktop/CMakeLists.txt index 49359e607..01a6716b1 100644 --- a/metaforce-gui/platforms/freedesktop/CMakeLists.txt +++ b/metaforce-gui/platforms/freedesktop/CMakeLists.txt @@ -1,6 +1,5 @@ add_executable(mkqticon mkqticon.c) target_link_libraries(mkqticon ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) -target_include_directories(mkqticon PRIVATE ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) macro(declare_qticon_target) add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/metaforce-gui/platforms/freedesktop/mainicon_qt.bin diff --git a/version.h.in b/version.h.in index 828942549..0570f8a08 100644 --- a/version.h.in +++ b/version.h.in @@ -1,16 +1,7 @@ #ifndef VERSION_H #define VERSION_H -#ifndef _SYS_STR -#ifdef _WIN32 -#define _SYS_STR(val) L##val -#else -#define _SYS_STR(val) val -#endif -#endif - #define METAFORCE_WC_DESCRIBE "@METAFORCE_WC_DESCRIBE@" -#define METAFORCE_WC_DESCRIBE_SYS _SYS_STR("@METAFORCE_WC_DESCRIBE@") #define METAFORCE_VERSION_STRING "@METAFORCE_VERISON_STRING@" #define METAFORCE_WC_BRANCH "@METAFORCE_WC_BRANCH@" diff --git a/visigen/MainWin.cpp b/visigen/MainWin.cpp index 14f4a000c..05e75fff8 100644 --- a/visigen/MainWin.cpp +++ b/visigen/MainWin.cpp @@ -5,6 +5,8 @@ #include #include "athena/Global.hpp" #include "logvisor/logvisor.hpp" +#include +#include #include "../version.h" #include @@ -40,8 +42,9 @@ static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l return DefWindowProc(hwnd, uMsg, wParam, lParam); } -int wmain(int argc, const hecl::SystemChar** argv) { - if (argc > 1 && !wcscmp(argv[1], L"--dlpackage")) { +int main(int argc, char** argv) { + nowide::args _(argc, argv); + if (argc > 1 && !strcmp(argv[1], "--dlpackage")) { fmt::print(FMT_STRING("{}\n"), METAFORCE_DLPACKAGE); return 100; } @@ -54,7 +57,7 @@ int wmain(int argc, const hecl::SystemChar** argv) { int instIdx = -1; if (argc > 3) - instIdx = _wtoi(argv[3]); + instIdx = atoi(argv[3]); WNDCLASS wndClass = {CS_NOCLOSE, WindowProc, 0, 0, GetModuleHandle(nullptr), 0, 0, 0, 0, L"VISIGenWindow"}; RegisterClassW(&wndClass); @@ -126,8 +129,8 @@ int wmain(int argc, const hecl::SystemChar** argv) { continue; case WM_USER + 1: { /* Update window title from client thread */ - std::wstring title = fmt::format(FMT_STRING(L"VISIGen [{:g}%]"), s_Percent * 100.f); - SetWindowTextW(window, title.c_str()); + std::string title = fmt::format(FMT_STRING("VISIGen [{:g}%]"), s_Percent * 100.f); + SetWindowTextW(window, nowide::widen(title).c_str()); continue; } default: diff --git a/visigen/VISIRenderer.cpp b/visigen/VISIRenderer.cpp index a95463e27..47c8c0512 100644 --- a/visigen/VISIRenderer.cpp +++ b/visigen/VISIRenderer.cpp @@ -438,11 +438,7 @@ void VISIRenderer::Run(FPercent updatePercent) { ProcessType parentPid = 0; if (m_argc > 4) -#ifdef _WIN32 - parentPid = ProcessType(wcstoull(m_argv[4], nullptr, 10)); -#else parentPid = ProcessType(strtoull(m_argv[4], nullptr, 10)); -#endif uint32_t layer2LightCount = 0; { diff --git a/visigen/VISIRenderer.hpp b/visigen/VISIRenderer.hpp index 08d1bbd3f..337df57a5 100644 --- a/visigen/VISIRenderer.hpp +++ b/visigen/VISIRenderer.hpp @@ -1,7 +1,6 @@ #pragma once #include "boo/graphicsdev/glew.h" -#include "hecl/SystemChar.hpp" #include "zeus/CColor.hpp" #include "zeus/CMatrix4f.hpp" #include "zeus/CAABox.hpp" @@ -14,7 +13,7 @@ class VISIRenderer { friend struct VISIBuilder; int m_argc; - const hecl::SystemChar** m_argv; + char** m_argv; int m_return = 0; zeus::CAABox m_totalAABB; @@ -82,7 +81,7 @@ public: uint8_t a; }; - VISIRenderer(int argc, const hecl::SystemChar** argv) : m_argc(argc), m_argv(argv) {} + VISIRenderer(int argc, char** argv) : m_argc(argc), m_argv(argv) {} void Run(FPercent updatePercent); void Terminate(); void RenderPVSOpaque(RGBA8* bufOut, const zeus::CVector3f& pos, bool& needTransparent);