From 7a60151d3e081fdce73fd654358d09b0e7d0db64 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 23 Jan 2017 21:41:33 -1000 Subject: [PATCH] Char16 refactor and GuiSys bug fixes --- DataSpec/DNACommon/STRG.hpp | 2 +- DataSpec/DNAMP1/MLVL.cpp | 7 +- DataSpec/DNAMP1/STRG.cpp | 22 ++-- DataSpec/DNAMP1/STRG.hpp | 12 +- DataSpec/DNAMP2/STRG.cpp | 24 ++-- DataSpec/DNAMP2/STRG.hpp | 12 +- DataSpec/DNAMP3/STRG.hpp | 6 +- Runtime/CGameOptions.cpp | 4 +- Runtime/CMemoryCardSys.cpp | 38 +++---- Runtime/CMemoryCardSys.hpp | 20 ++-- Runtime/GuiSys/CGuiTextPane.cpp | 2 +- Runtime/GuiSys/CGuiTextSupport.cpp | 10 +- Runtime/GuiSys/CGuiTextSupport.hpp | 6 +- Runtime/GuiSys/CInstruction.cpp | 2 +- Runtime/GuiSys/CInstruction.hpp | 4 +- Runtime/GuiSys/CRasterFont.cpp | 21 ++-- Runtime/GuiSys/CRasterFont.hpp | 22 ++-- Runtime/GuiSys/CStringTable.cpp | 6 +- Runtime/GuiSys/CStringTable.hpp | 2 +- Runtime/GuiSys/CTextExecuteBuffer.cpp | 18 +-- Runtime/GuiSys/CTextExecuteBuffer.hpp | 6 +- Runtime/GuiSys/CTextParser.cpp | 152 ++++++++++++++------------ Runtime/GuiSys/CTextParser.hpp | 22 ++-- Runtime/MP1/CFrontEndUI.cpp | 32 +++--- Runtime/MP1/CFrontEndUI.hpp | 6 +- Runtime/MP1/CMemoryCardDriver.cpp | 19 ++-- Runtime/MP1/CMemoryCardDriver.hpp | 3 +- Runtime/MP1/CSaveUI.cpp | 18 +-- Runtime/World/CWorldTransManager.cpp | 2 +- hecl | 2 +- kabufuda | 2 +- 31 files changed, 262 insertions(+), 242 deletions(-) diff --git a/DataSpec/DNACommon/STRG.hpp b/DataSpec/DNACommon/STRG.hpp index 10dc74075..4166f0e44 100644 --- a/DataSpec/DNACommon/STRG.hpp +++ b/DataSpec/DNACommon/STRG.hpp @@ -16,7 +16,7 @@ struct ISTRG : BigYAML virtual size_t count() const=0; virtual std::string getUTF8(const FourCC& lang, size_t idx) const=0; - virtual std::wstring getUTF16(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(const std::string& name) const=0; diff --git a/DataSpec/DNAMP1/MLVL.cpp b/DataSpec/DNAMP1/MLVL.cpp index 4f812c67a..8304ec187 100644 --- a/DataSpec/DNAMP1/MLVL.cpp +++ b/DataSpec/DNAMP1/MLVL.cpp @@ -6,6 +6,7 @@ #include "ScriptObjects/SpecialFunction.hpp" #include "ScriptObjects/DoorArea.hpp" #include "Runtime/RetroTypes.hpp" +#include "Runtime/World/ScriptObjectSupport.hpp" namespace DataSpec { @@ -207,7 +208,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat std::vector scans; for (std::unique_ptr& obj : layer.objects) { - if (obj->type == 0x13) + if (obj->type == int(urde::EScriptObjectType::MemoryRelay)) { MemoryRelay& memRelay = static_cast(*obj); for (IScriptObject::Connection& conn : memRelay.connections) @@ -221,7 +222,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat } savw.relays.push_back(memRelay.id); } - else if (obj->type == 0x3A) + else if (obj->type == int(urde::EScriptObjectType::SpecialFunction)) { SpecialFunction& specialFunc = static_cast(*obj); if (specialFunc.function == ESpecialFunctionType::CinematicSkip) @@ -234,7 +235,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat layer.layer = specialFunc.layerSwitch.layerIdx; } } - else if (obj->type == 0x3) + else if (obj->type == int(urde::EScriptObjectType::Door)) { DoorArea& doorArea = static_cast(*obj); savw.doors.push_back(doorArea.id); diff --git a/DataSpec/DNAMP1/STRG.cpp b/DataSpec/DNAMP1/STRG.cpp index b72bd37f6..0d6e3d010 100644 --- a/DataSpec/DNAMP1/STRG.cpp +++ b/DataSpec/DNAMP1/STRG.cpp @@ -38,7 +38,7 @@ void STRG::_read(athena::io::IStreamReader& reader) langs.reserve(skLanguages.size()); for (const std::pair& lang : readLangs) { - std::vector strs; + std::vector strs; reader.seek(tablesStart + lang.second, athena::SeekOrigin::Begin); reader.readUint32Big(); // table size atUint32 langStart = reader.position(); @@ -47,7 +47,7 @@ void STRG::_read(athena::io::IStreamReader& reader) atUint32 strOffset = reader.readUint32Big(); atUint32 tmpOffset = reader.position(); reader.seek(langStart + strOffset, athena::SeekOrigin::Begin); - strs.emplace_back(reader.readWStringBig()); + strs.emplace_back(reader.readU16StringBig()); reader.seek(tmpOffset, athena::SeekOrigin::Begin); } langs.emplace_back(lang.first, strs); @@ -55,7 +55,7 @@ void STRG::_read(athena::io::IStreamReader& reader) langMap.clear(); langMap.reserve(langCount); - for (std::pair>& item : langs) + for (std::pair>& item : langs) langMap.emplace(item.first, &item.second); } @@ -81,7 +81,7 @@ void STRG::write(athena::io::IStreamWriter& writer) const writer.writeUint32Big(strCount); atUint32 offset = 0; - for (const std::pair>& lang : langs) + for (const std::pair>& lang : langs) { DNAFourCC(lang.first).write(writer); writer.writeUint32Big(offset); @@ -97,7 +97,7 @@ void STRG::write(athena::io::IStreamWriter& writer) const } } - for (const std::pair>& lang : langs) + for (const std::pair>& lang : langs) { atUint32 langStrCount = lang.second.size(); atUint32 tableSz = strCount * 4; @@ -123,7 +123,7 @@ void STRG::write(athena::io::IStreamWriter& writer) const for (atUint32 s=0 ; s>& lang : langs) + for (const std::pair>& lang : langs) { atUint32 langStrCount = lang.second.size(); for (atUint32 s=0 ; s strs; + std::vector strs; for (const auto& str : lang.second->m_seqChildren) - strs.emplace_back(hecl::UTF8ToWide(str->m_scalarString)); + strs.emplace_back(hecl::UTF8ToChar16(str->m_scalarString)); langs.emplace_back(FourCC(lang.first.c_str()), strs); } @@ -214,8 +214,8 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const for (const auto& lang : langs) { writer.enterSubVector(lang.first.toString().c_str()); - for (const std::wstring& str : lang.second) - writer.writeWString(nullptr, str); + for (const std::u16string& str : lang.second) + writer.writeU16String(nullptr, str); writer.leaveSubVector(); } } diff --git a/DataSpec/DNAMP1/STRG.hpp b/DataSpec/DNAMP1/STRG.hpp index 092a64b06..1cbd09055 100644 --- a/DataSpec/DNAMP1/STRG.hpp +++ b/DataSpec/DNAMP1/STRG.hpp @@ -16,8 +16,8 @@ struct STRG : ISTRG DECL_YAML Delete expl; void _read(athena::io::IStreamReader& reader); - std::vector>> langs; - std::unordered_map*> langMap; + std::vector>> langs; + std::unordered_map*> langMap; inline int32_t lookupIdx(const std::string& name) const {return -1;} @@ -36,15 +36,15 @@ struct STRG : ISTRG { auto search = langMap.find(lang); if (search != langMap.end()) - return hecl::WideToUTF8(search->second->at(idx)); + return hecl::Char16ToUTF8(search->second->at(idx)); return std::string(); } - inline std::wstring getUTF16(const FourCC& lang, size_t idx) const + inline std::u16string getUTF16(const FourCC& lang, size_t idx) const { auto search = langMap.find(lang); if (search != langMap.end()) return search->second->at(idx); - return std::wstring(); + return std::u16string(); } inline hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const { @@ -53,7 +53,7 @@ struct STRG : ISTRG #if HECL_UCS2 return search->second->at(idx); #else - return hecl::WideToUTF8(search->second->at(idx)); + return hecl::Char16ToUTF8(search->second->at(idx)); #endif return hecl::SystemString(); } diff --git a/DataSpec/DNAMP2/STRG.cpp b/DataSpec/DNAMP2/STRG.cpp index b745914d7..f042043d1 100644 --- a/DataSpec/DNAMP2/STRG.cpp +++ b/DataSpec/DNAMP2/STRG.cpp @@ -40,16 +40,16 @@ void STRG::_read(athena::io::IStreamReader& reader) langs.reserve(langCount); for (FourCC& lang : readLangs) { - std::vector strs; + std::vector strs; reader.seek(strCount * 4); for (atUint32 s=0 ; s>& item : langs) + for (std::pair>& item : langs) langMap.emplace(item.first, &item.second); } @@ -75,7 +75,7 @@ void STRG::write(athena::io::IStreamWriter& writer) const writer.writeUint32Big(strCount); atUint32 offset = 0; - for (const std::pair>& lang : langs) + for (const std::pair>& lang : langs) { lang.first.write(writer); writer.writeUint32Big(offset); @@ -114,7 +114,7 @@ void STRG::write(athena::io::IStreamWriter& writer) const for (const std::pair& name : names) writer.writeString(name.first); - for (const std::pair>& lang : langs) + for (const std::pair>& lang : langs) { offset = strCount * 4; atUint32 langStrCount = lang.second.size(); @@ -130,7 +130,7 @@ void STRG::write(athena::io::IStreamWriter& writer) const for (atUint32 s=0 ; s>& lang : langs) + for (const std::pair>& lang : langs) { atUint32 langStrCount = lang.second.size(); __isz += strCount * 4; @@ -207,9 +207,9 @@ void STRG::read(athena::io::YAMLDocReader& reader) langs.clear(); for (const auto& lang : root->m_mapChildren) { - std::vector strs; + std::vector strs; for (const auto& str : lang.second->m_seqChildren) - strs.emplace_back(hecl::UTF8ToWide(str->m_scalarString)); + strs.emplace_back(hecl::UTF8ToChar16(str->m_scalarString)); langs.emplace_back(FourCC(lang.first.c_str()), strs); } @@ -221,7 +221,7 @@ void STRG::read(athena::io::YAMLDocReader& reader) langMap.clear(); langMap.reserve(langs.size()); - for (std::pair>& item : langs) + for (std::pair>& item : langs) langMap.emplace(item.first, &item.second); } @@ -230,8 +230,8 @@ void STRG::write(athena::io::YAMLDocWriter& writer) const for (const auto& lang : langs) { writer.enterSubVector(lang.first.toString().c_str()); - for (const std::wstring& str : lang.second) - writer.writeWString(nullptr, str); + for (const std::u16string& str : lang.second) + writer.writeU16String(nullptr, str); writer.leaveSubVector(); } if (names.size()) diff --git a/DataSpec/DNAMP2/STRG.hpp b/DataSpec/DNAMP2/STRG.hpp index de70664ab..8121806b3 100644 --- a/DataSpec/DNAMP2/STRG.hpp +++ b/DataSpec/DNAMP2/STRG.hpp @@ -15,8 +15,8 @@ struct STRG : ISTRG DECL_YAML Delete expl; void _read(athena::io::IStreamReader& reader); - std::vector>> langs; - std::unordered_map*> langMap; + std::vector>> langs; + std::unordered_map*> langMap; std::map names; inline int32_t lookupIdx(const std::string& name) const @@ -42,15 +42,15 @@ struct STRG : ISTRG { auto search = langMap.find(lang); if (search != langMap.end()) - return hecl::WideToUTF8(search->second->at(idx)); + return hecl::Char16ToUTF8(search->second->at(idx)); return std::string(); } - inline std::wstring getUTF16(const FourCC& lang, size_t idx) const + inline std::u16string getUTF16(const FourCC& lang, size_t idx) const { auto search = langMap.find(lang); if (search != langMap.end()) return search->second->at(idx); - return std::wstring(); + return std::u16string(); } inline hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const { @@ -59,7 +59,7 @@ struct STRG : ISTRG #if HECL_UCS2 return search->second->at(idx); #else - return hecl::WideToUTF8(search->second->at(idx)); + return hecl::Char16ToUTF8(search->second->at(idx)); #endif return hecl::SystemString(); } diff --git a/DataSpec/DNAMP3/STRG.hpp b/DataSpec/DNAMP3/STRG.hpp index 4cdc0ebc4..3bd4e1795 100644 --- a/DataSpec/DNAMP3/STRG.hpp +++ b/DataSpec/DNAMP3/STRG.hpp @@ -45,12 +45,12 @@ struct STRG : ISTRG return search->second->at(idx); return std::string(); } - inline std::wstring getUTF16(const FourCC& lang, size_t idx) const + inline std::u16string getUTF16(const FourCC& lang, size_t idx) const { auto search = langMap.find(lang); if (search != langMap.end()) - return hecl::UTF8ToWide(search->second->at(idx)); - return std::wstring(); + return hecl::UTF8ToChar16(search->second->at(idx)); + return std::u16string(); } inline hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const { diff --git a/Runtime/CGameOptions.cpp b/Runtime/CGameOptions.cpp index 726048c25..8edeead01 100644 --- a/Runtime/CGameOptions.cpp +++ b/Runtime/CGameOptions.cpp @@ -80,7 +80,7 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) for (const auto& world : memWorlds) { TLockedToken saveWorld = - g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); + g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()}); cinematicCount += saveWorld->GetCinematicCount(); } @@ -92,7 +92,7 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) for (const auto& world : memWorlds) { TLockedToken saveWorld = - g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); + g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()}); auto stateIt = cinematicStates.cbegin(); for (TEditorId cineId : saveWorld->GetCinematics()) diff --git a/Runtime/CMemoryCardSys.cpp b/Runtime/CMemoryCardSys.cpp index 690b913dc..b4a1839bf 100644 --- a/Runtime/CMemoryCardSys.cpp +++ b/Runtime/CMemoryCardSys.cpp @@ -278,7 +278,7 @@ ECardResult CMemoryCardSys::CCardFileInfo::PumpCardTransfer() result = GetStatus(stat); if (result != ECardResult::READY) return result; - result = CMemoryCardSys::SetStatus(m_handle, stat); + result = CMemoryCardSys::SetStatus(m_handle.slot, m_handle.getFileNo(), stat); if (result != ECardResult::READY) return result; return ECardResult::BUSY; @@ -294,7 +294,7 @@ ECardResult CMemoryCardSys::CCardFileInfo::PumpCardTransfer() ECardResult CMemoryCardSys::CCardFileInfo::GetStatus(kabufuda::CardStat& stat) const { - ECardResult result = CMemoryCardSys::GetStatus(m_handle, stat); + ECardResult result = CMemoryCardSys::GetStatus(m_handle.slot, m_handle.getFileNo(), stat); if (result != ECardResult::READY) return result; @@ -438,11 +438,11 @@ ECardResult CMemoryCardSys::CloseFile(CardFileHandle& info) g_OpResults[int(info.slot)] = err; return err; } - info.handle.reset(); + card.closeFile(info.handle); return ECardResult::READY; } -ECardResult CMemoryCardSys::ReadFile(const CardFileHandle& info, void* buf, s32 length, s32 offset) +ECardResult CMemoryCardSys::ReadFile(CardFileHandle& info, void* buf, s32 length, s32 offset) { kabufuda::Card& card = g_CardStates[int(info.slot)]; if (CardResult err = card.getError()) @@ -450,13 +450,13 @@ ECardResult CMemoryCardSys::ReadFile(const CardFileHandle& info, void* buf, s32 g_OpResults[int(info.slot)] = err; return err; } - card.seek(info, offset, kabufuda::SeekOrigin::Begin); - card.read(info, buf, length); + card.seek(info.handle, offset, kabufuda::SeekOrigin::Begin); + card.read(info.handle, buf, length); g_OpResults[int(info.slot)] = ECardResult::READY; return ECardResult::READY; } -ECardResult CMemoryCardSys::WriteFile(const CardFileHandle& info, const void* buf, s32 length, s32 offset) +ECardResult CMemoryCardSys::WriteFile(CardFileHandle& info, const void* buf, s32 length, s32 offset) { kabufuda::Card& card = g_CardStates[int(info.slot)]; if (CardResult err = card.getError()) @@ -464,8 +464,8 @@ ECardResult CMemoryCardSys::WriteFile(const CardFileHandle& info, const void* bu g_OpResults[int(info.slot)] = err; return err; } - card.seek(info, offset, kabufuda::SeekOrigin::Begin); - card.write(info, buf, length); + card.seek(info.handle, offset, kabufuda::SeekOrigin::Begin); + card.write(info.handle, buf, length); g_OpResults[int(info.slot)] = ECardResult::READY; return ECardResult::READY; } @@ -501,29 +501,29 @@ ECardResult CMemoryCardSys::GetResultCode(kabufuda::ECardSlot port) return g_OpResults[int(port)]; } -ECardResult CMemoryCardSys::GetStatus(const CardFileHandle& info, CardStat& statOut) +ECardResult CMemoryCardSys::GetStatus(kabufuda::ECardSlot port, int fileNo, CardStat& statOut) { - kabufuda::Card& card = g_CardStates[int(info.slot)]; + kabufuda::Card& card = g_CardStates[int(port)]; if (CardResult err = card.getError()) { - g_OpResults[int(info.slot)] = err; + g_OpResults[int(port)] = err; return err; } - ECardResult result = card.getStatus(info, statOut); - g_OpResults[int(info.slot)] = result; + ECardResult result = card.getStatus(fileNo, statOut); + g_OpResults[int(port)] = result; return result; } -ECardResult CMemoryCardSys::SetStatus(const CardFileHandle& info, const CardStat& stat) +ECardResult CMemoryCardSys::SetStatus(kabufuda::ECardSlot port, int fileNo, const CardStat& stat) { - kabufuda::Card& card = g_CardStates[int(info.slot)]; + kabufuda::Card& card = g_CardStates[int(port)]; if (CardResult err = card.getError()) { - g_OpResults[int(info.slot)] = err; + g_OpResults[int(port)] = err; return err; } - ECardResult result = card.setStatus(info, stat); - g_OpResults[int(info.slot)] = result; + ECardResult result = card.setStatus(fileNo, stat); + g_OpResults[int(port)] = result; return result; } diff --git a/Runtime/CMemoryCardSys.hpp b/Runtime/CMemoryCardSys.hpp index 08781443e..a4be19e0b 100644 --- a/Runtime/CMemoryCardSys.hpp +++ b/Runtime/CMemoryCardSys.hpp @@ -32,10 +32,10 @@ public: const TLockedToken& GetWorldName() const { return x2c_worldName; } const TLockedToken& GetSaveWorld() const { return x3c_saveWorld; } - const wchar_t* GetFrontEndName() const + const char16_t* GetFrontEndName() const { if (!x2c_worldName) - return L""; + return u""; return x2c_worldName->GetString(0); } }; @@ -79,11 +79,9 @@ public: struct CardFileHandle { kabufuda::ECardSlot slot; - std::unique_ptr handle; + kabufuda::FileHandle handle; CardFileHandle(kabufuda::ECardSlot slot) : slot(slot) {} - kabufuda::IFileHandle* operator->() const { return handle.get(); } - operator std::unique_ptr&() { return handle; } - operator const std::unique_ptr&() const { return handle; } + int getFileNo() const { return handle.getFileNo(); } }; using CardStat = kabufuda::CardStat; @@ -134,7 +132,7 @@ public: void LockIconToken(ResId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp); kabufuda::ECardSlot GetCardPort() const { return m_handle.slot; } - int GetFileNo() const { return m_handle->getFileNo(); } + int GetFileNo() const { return m_handle.getFileNo(); } u32 CalculateBannerDataSize() const; u32 CalculateTotalDataSize() const; void BuildCardBuffer(); @@ -162,13 +160,13 @@ public: static ECardResult OpenFile(kabufuda::ECardSlot port, const char* name, CardFileHandle& info); static ECardResult FastOpenFile(kabufuda::ECardSlot port, int fileNo, CardFileHandle& info); static ECardResult CloseFile(CardFileHandle& info); - static ECardResult ReadFile(const CardFileHandle& info, void* buf, s32 length, s32 offset); - static ECardResult WriteFile(const CardFileHandle& info, const void* buf, s32 length, s32 offset); + static ECardResult ReadFile(CardFileHandle& info, void* buf, s32 length, s32 offset); + static ECardResult WriteFile(CardFileHandle& info, const void* buf, s32 length, s32 offset); static ECardResult GetNumFreeBytes(kabufuda::ECardSlot port, s32& freeBytes, s32& freeFiles); static ECardResult GetSerialNo(kabufuda::ECardSlot port, u64& serialOut); static ECardResult GetResultCode(kabufuda::ECardSlot port); - static ECardResult GetStatus(const CardFileHandle& info, CardStat& statOut); - static ECardResult SetStatus(const CardFileHandle& info, const CardStat& stat); + static ECardResult GetStatus(kabufuda::ECardSlot port, int fileNo, CardStat& statOut); + static ECardResult SetStatus(kabufuda::ECardSlot port, int fileNo, const CardStat& stat); static ECardResult DeleteFile(kabufuda::ECardSlot port, const char* name); static ECardResult FastDeleteFile(kabufuda::ECardSlot port, int fileNo); static ECardResult Rename(kabufuda::ECardSlot port, const char* oldName, const char* newName); diff --git a/Runtime/GuiSys/CGuiTextPane.cpp b/Runtime/GuiSys/CGuiTextPane.cpp index 2dc868a4c..2cbbc01ba 100644 --- a/Runtime/GuiSys/CGuiTextPane.cpp +++ b/Runtime/GuiSys/CGuiTextPane.cpp @@ -119,7 +119,7 @@ std::shared_ptr CGuiTextPane::Create(CGuiFrame* frame, CInputStream& fontCol, outlineCol, extentX, extentY); ret->ParseBaseInfo(frame, in, parms); ret->InitializeBuffers(); - ret->TextSupport()->SetText(L"?\?(?\?)"); + ret->TextSupport()->SetText(u"?\?(?\?)"); return ret; } diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index d61c8bc4d..5f94ba357 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -145,9 +145,9 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer() g_TextExecuteBuf->AddColor(EColorType::Main, x24_fontColor); g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor); - std::wstring initStr; + std::u16string initStr; if ((x5c_fontId & 0xffff) != 0xffff) - initStr = hecl::WideFormat(L"&font=%08X;", u32(x5c_fontId)); + initStr = hecl::Char16Format(L"&font=%08X;", u32(x5c_fontId)); initStr += x0_string; g_TextParser->ParseText(*g_TextExecuteBuf, initStr.c_str(), initStr.size()); @@ -231,7 +231,7 @@ void CGuiTextSupport::SetFontColor(const zeus::CColor& col) } } -void CGuiTextSupport::AddText(const std::wstring& str) +void CGuiTextSupport::AddText(const std::u16string& str) { if (x60_renderBuf) { @@ -243,7 +243,7 @@ void CGuiTextSupport::AddText(const std::wstring& str) ClearRenderBuffer(); } -void CGuiTextSupport::SetText(const std::wstring& str, bool multipage) +void CGuiTextSupport::SetText(const std::u16string& str, bool multipage) { if (x0_string.compare(str)) { @@ -258,7 +258,7 @@ void CGuiTextSupport::SetText(const std::wstring& str, bool multipage) void CGuiTextSupport::SetText(const std::string& str, bool multipage) { - SetText(hecl::UTF8ToWide(str), multipage); + SetText(hecl::UTF8ToChar16(str), multipage); } bool CGuiTextSupport::_GetIsTextSupportFinishedLoading() const diff --git a/Runtime/GuiSys/CGuiTextSupport.hpp b/Runtime/GuiSys/CGuiTextSupport.hpp index 65f2e52da..0a4b23e2a 100644 --- a/Runtime/GuiSys/CGuiTextSupport.hpp +++ b/Runtime/GuiSys/CGuiTextSupport.hpp @@ -77,7 +77,7 @@ public: class CGuiTextSupport { friend class CGuiTextPane; - std::wstring x0_string; + std::u16string x0_string; float x10_curTimeMod900 = 0.f; CGuiTextProperties x14_props; zeus::CColor x24_fontColor; @@ -125,8 +125,8 @@ public: void SetGeometryColor(const zeus::CColor& col); void SetOutlineColor(const zeus::CColor& col); void SetFontColor(const zeus::CColor& col); - void AddText(const std::wstring& str); - void SetText(const std::wstring& str, bool multipage=false); + void AddText(const std::u16string& str); + void SetText(const std::u16string& str, bool multipage=false); void SetText(const std::string& str, bool multipage=false); bool GetIsTextSupportFinishedLoading() const; }; diff --git a/Runtime/GuiSys/CInstruction.cpp b/Runtime/GuiSys/CInstruction.cpp index 166f675d8..e8a1da59c 100644 --- a/Runtime/GuiSys/CInstruction.cpp +++ b/Runtime/GuiSys/CInstruction.cpp @@ -321,7 +321,7 @@ void CBlockInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* b void CWordInstruction::InvokeLTR(CFontRenderState& state) const { CRasterFont* font = state.x48_font.GetObj(); - wchar_t space = L' '; + char16_t space = u' '; int w, h; font->GetSize(state.x0_drawStrOpts, w, h, &space, 1); diff --git a/Runtime/GuiSys/CInstruction.hpp b/Runtime/GuiSys/CInstruction.hpp index 07c334e4a..e508e49c0 100644 --- a/Runtime/GuiSys/CInstruction.hpp +++ b/Runtime/GuiSys/CInstruction.hpp @@ -132,9 +132,9 @@ public: class CTextInstruction : public CInstruction { - std::wstring x4_str; /* used to be a placement-new sized allocation */ + std::u16string x4_str; /* used to be a placement-new sized allocation */ public: - CTextInstruction(const wchar_t* str, int len) : x4_str(str, len) {} + CTextInstruction(const char16_t* str, int len) : x4_str(str, len) {} void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const; }; diff --git a/Runtime/GuiSys/CRasterFont.cpp b/Runtime/GuiSys/CRasterFont.cpp index 933004446..ce0ee7d33 100644 --- a/Runtime/GuiSys/CRasterFont.cpp +++ b/Runtime/GuiSys/CRasterFont.cpp @@ -41,7 +41,7 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) for (u32 i = 0 ; i < glyphCount ; ++i) { - wchar_t chr = in.readUint16Big(); + char16_t chr = in.readUint16Big(); float startU = in.readFloatBig(); float startV = in.readFloatBig(); float endU = in.readFloatBig(); @@ -66,8 +66,8 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) for (u32 i = 0 ; i < kernCount ; ++i) { - wchar_t first = in.readUint16Big(); - wchar_t second = in.readUint16Big(); + char16_t first = in.readUint16Big(); + char16_t second = in.readUint16Big(); s32 howMuch = in.readUint32Big(); x1c_kerning.emplace_back(first, second, howMuch); } @@ -78,14 +78,14 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, int y, int& xout, int& yout, CTextRenderBuffer* renderBuf, - const wchar_t* str, s32 length) const + const char16_t* str, s32 length) const { if (!x0_initialized) return; - const wchar_t* chr = str; + const char16_t* chr = str; const CGlyph* prevGlyph = nullptr; - while (*chr != '\0') + while (*chr != u'\0') { const CGlyph* glyph = GetGlyph(*chr); if (glyph) @@ -130,7 +130,8 @@ void CRasterFont::DrawSpace(const CDrawStringOptions& opts, int x, int y, int& x yout = y; } -void CRasterFont::DrawString(const CDrawStringOptions& opts, int x, int y, int& xout, int& yout, CTextRenderBuffer* renderBuf, const wchar_t* str, int len) const +void CRasterFont::DrawString(const CDrawStringOptions& opts, int x, int y, int& xout, int& yout, + CTextRenderBuffer* renderBuf, const char16_t* str, int len) const { if (!x0_initialized) return; @@ -152,15 +153,15 @@ void CRasterFont::DrawString(const CDrawStringOptions& opts, int x, int y, int& SinglePassDrawString(opts, x, y, xout, yout, renderBuf, str, len); } -void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& height, const wchar_t* str, int len) const +void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& height, const char16_t* str, int len) const { width = 0; height = 0; - const wchar_t* chr = str; + const char16_t* chr = str; const CGlyph* prevGlyph = nullptr; int prevWidth = 0; - while (*chr != L'\0') + while (*chr != u'\0') { const CGlyph* glyph = GetGlyph(*chr); diff --git a/Runtime/GuiSys/CRasterFont.hpp b/Runtime/GuiSys/CRasterFont.hpp index f39836aa4..49754ff6b 100644 --- a/Runtime/GuiSys/CRasterFont.hpp +++ b/Runtime/GuiSys/CRasterFont.hpp @@ -55,18 +55,18 @@ public: class CKernPair { private: - wchar_t x0_first; - wchar_t x2_second; + char16_t x0_first; + char16_t x2_second; s32 x4_howMuch; public: CKernPair() = default; - CKernPair(wchar_t first, wchar_t second, s32 howMuch) + CKernPair(char16_t first, char16_t second, s32 howMuch) : x0_first(first), x2_second(second), x4_howMuch(howMuch) {} - wchar_t GetFirst() const { return x0_first; } - wchar_t GetSecond() const { return x2_second; } + char16_t GetFirst() const { return x0_first; } + char16_t GetSecond() const { return x2_second; } s32 GetHowMuch() const { return x4_howMuch; } }; @@ -92,7 +92,7 @@ class CRasterFont bool x0_initialized = false; s32 x4_monoWidth = 16; s32 x8_monoHeight = 16; - std::vector> xc_glyphs; + std::vector> xc_glyphs; std::vector x1c_kerning; EColorType x2c_mode = EColorType::Main; CFontInfo x30_fontInfo; @@ -100,7 +100,7 @@ class CRasterFont s32 x8c_baseline; s32 x90_lineMargin = 0; - const CGlyph* InternalGetGlyph(wchar_t chr) const + const CGlyph* InternalGetGlyph(char16_t chr) const { u32 i = 0; for (; i < xc_glyphs.size(); ++i) @@ -135,17 +135,17 @@ public: void SinglePassDrawString(const CDrawStringOptions&, int x, int y, int& xout, int& yout, CTextRenderBuffer* renderBuf, - const wchar_t* str, s32 len) const; + const char16_t* str, s32 len) const; void DrawSpace(const CDrawStringOptions& opts, int x, int y, int& xout, int& yout, int len) const; void DrawString(const CDrawStringOptions& opts, int x, int y, int& xout, int& yout, CTextRenderBuffer* renderBuf, - const wchar_t* str, int len) const; - const CGlyph* GetGlyph(wchar_t chr) const + const char16_t* str, int len) const; + const CGlyph* GetGlyph(char16_t chr) const { return InternalGetGlyph(chr); } void GetSize(const CDrawStringOptions& opts, int& width, int& height, - const wchar_t* str, int len) const; + const char16_t* str, int len) const; TToken& GetTexture() { return x80_texture; } }; diff --git a/Runtime/GuiSys/CStringTable.cpp b/Runtime/GuiSys/CStringTable.cpp index 7b5893d95..b0a2579ab 100644 --- a/Runtime/GuiSys/CStringTable.cpp +++ b/Runtime/GuiSys/CStringTable.cpp @@ -70,13 +70,13 @@ void CStringTable::LoadStringTable(CInputStream &in) } } -const wchar_t* CStringTable::GetString(s32 str) const +const char16_t* CStringTable::GetString(s32 str) const { if (str < 0 || u32(str) >= x0_stringCount) - return L"Invalid"; + return u"Invalid"; u32 off = *reinterpret_cast(x4_data.get() + str * 4); - return reinterpret_cast(x4_data.get() + off); + return reinterpret_cast(x4_data.get() + off); } void CStringTable::SetLanguage(s32 lang) diff --git a/Runtime/GuiSys/CStringTable.hpp b/Runtime/GuiSys/CStringTable.hpp index 6de7a4a69..753d0b742 100644 --- a/Runtime/GuiSys/CStringTable.hpp +++ b/Runtime/GuiSys/CStringTable.hpp @@ -17,7 +17,7 @@ public: CStringTable(CInputStream& in); void LoadStringTable(CInputStream& in); - const wchar_t* GetString(s32) const; + const char16_t* GetString(s32) const; static void SetLanguage(s32); }; diff --git a/Runtime/GuiSys/CTextExecuteBuffer.cpp b/Runtime/GuiSys/CTextExecuteBuffer.cpp index ea6e93a63..1765b55d3 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.cpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.cpp @@ -133,21 +133,21 @@ std::vector CTextExecuteBuffer::GetAssets() const return ret; } -void CTextExecuteBuffer::AddString(const wchar_t* str, int count) +void CTextExecuteBuffer::AddString(const char16_t* str, int count) { if (!xa4_curLine) StartNewLine(); - const wchar_t* charCur = str; - const wchar_t* wordCur = str; + const char16_t* charCur = str; + const char16_t* wordCur = str; for (int ac=0 ; *charCur && (ac < count || count == -1) ; ++charCur, ++ac) { - if (*charCur == L'\n' || *charCur == L' ') + if (*charCur == u'\n' || *charCur == u' ') { AddStringFragment(wordCur, charCur - wordCur); wordCur = charCur + 1; - if (*charCur == L'\n') + if (*charCur == u'\n') { StartNewLine(); } @@ -155,7 +155,7 @@ void CTextExecuteBuffer::AddString(const wchar_t* str, int count) { StartNewWord(); int w, h; - wchar_t space = L' '; + char16_t space = u' '; x18_textState.x48_font.GetObj()->GetSize(x18_textState.x0_drawStrOpts, w, h, &space, 1); if (xa0_curBlock->x14_direction == ETextDirection::Horizontal) @@ -176,14 +176,14 @@ void CTextExecuteBuffer::AddString(const wchar_t* str, int count) AddStringFragment(wordCur, charCur - wordCur); } -void CTextExecuteBuffer::AddStringFragment(const wchar_t* str, int len) +void CTextExecuteBuffer::AddStringFragment(const char16_t* str, int len) { if (xa0_curBlock->x14_direction == ETextDirection::Horizontal) for (int i=0 ; ix8_curX > xa0_curBlock->xc_blockExtentX && len > 1) { - const wchar_t* strEnd = str + len; + const char16_t* strEnd = str + len; int aRank = 5; do diff --git a/Runtime/GuiSys/CTextExecuteBuffer.hpp b/Runtime/GuiSys/CTextExecuteBuffer.hpp index 354ea72d4..22e2888a6 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.hpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.hpp @@ -46,9 +46,9 @@ public: InstList::const_iterator pgEnd) const; std::list BuildRenderBufferPages(const zeus::CVector2i& extent) const; std::vector GetAssets() const; - void AddString(const wchar_t* str, int len); - void AddStringFragment(const wchar_t* str, int len); - int WrapOneLTR(const wchar_t* str, int len); + void AddString(const char16_t* str, int len); + void AddStringFragment(const char16_t* str, int len); + int WrapOneLTR(const char16_t* str, int len); void MoveWordLTR(); void StartNewLine(); void StartNewWord(); diff --git a/Runtime/GuiSys/CTextParser.cpp b/Runtime/GuiSys/CTextParser.cpp index 500fc69a0..309afd61d 100644 --- a/Runtime/GuiSys/CTextParser.cpp +++ b/Runtime/GuiSys/CTextParser.cpp @@ -5,7 +5,17 @@ namespace urde { -CTextColor CTextParser::ParseColor(const wchar_t* str, int len) +static float u16stof(char16_t* str) +{ + wchar_t wstr[16]; + int i; + for (i=0 ; i<15 && str[i] != u'\0' ; ++i) + wstr[i] = str[i]; + wstr[i+1] = L'\0'; + return std::wcstof(wstr, nullptr); +} + +CTextColor CTextParser::ParseColor(const char16_t* str, int len) { u8 r = GetColorValue(str + 1); u8 g = GetColorValue(str + 3); @@ -16,30 +26,30 @@ CTextColor CTextParser::ParseColor(const wchar_t* str, int len) return CTextColor(r, g, b, a); } -u8 CTextParser::GetColorValue(const wchar_t* str) +u8 CTextParser::GetColorValue(const char16_t* str) { return (FromHex(str[0]) << 4) + FromHex(str[1]); } -u32 CTextParser::FromHex(wchar_t ch) +u32 CTextParser::FromHex(char16_t ch) { - if (ch >= L'0' && ch <= L'9') - return ch - L'0'; + if (ch >= u'0' && ch <= u'9') + return ch - u'0'; - if (ch >= L'A' && ch <= L'F') - return ch - L'A' + 10; + if (ch >= u'A' && ch <= u'F') + return ch - u'A' + 10; - if (ch >= L'a' && ch <= L'f') - return ch - L'a' + 10; + if (ch >= u'a' && ch <= u'f') + return ch - u'a' + 10; return 0; } -s32 CTextParser::ParseInt(const wchar_t* str, int len, bool signVal) +s32 CTextParser::ParseInt(const char16_t* str, int len, bool signVal) { bool neg = false; int procCur = 0; - if (signVal && len && *str == L'-') + if (signVal && len && *str == u'-') { neg = true; procCur = 1; @@ -50,14 +60,14 @@ s32 CTextParser::ParseInt(const wchar_t* str, int len, bool signVal) { val *= 10; wchar_t ch = str[procCur]; - val += ch - L'0'; + val += ch - u'0'; ++procCur; } return neg ? -val : val; } -bool CTextParser::Equals(const wchar_t* str, int len, const wchar_t* other) +bool CTextParser::Equals(const char16_t* str, int len, const char16_t* other) { int i=0; for (; *other && i= L'0' && str[7] <= L'9') + int val = str[6] - u'0'; + if (str[7] >= u'0' && str[7] <= u'9') { ++valCur; --len; val *= 10; - val += str[7] - L'0'; + val += str[7] - u'0'; } - if (Equals(valCur + 10, len - 10, L"no")) + if (Equals(valCur + 10, len - 10, u"no")) out.AddRemoveColorOverride(val); else { @@ -132,80 +142,80 @@ void CTextParser::ParseTag(CTextExecuteBuffer& out, const wchar_t* str, int len) out.AddColorOverride(val, color); } } - else if (BeginsWith(str, len, L"line-spacing=")) + else if (BeginsWith(str, len, u"line-spacing=")) { out.AddLineSpacing(ParseInt(str + 13, len - 13, true) / 100.0); } - else if (BeginsWith(str, len, L"line-extra-space=")) + else if (BeginsWith(str, len, u"line-extra-space=")) { out.AddLineSpacing(ParseInt(str + 17, len - 17, true)); } - else if (BeginsWith(str, len, L"just=")) + else if (BeginsWith(str, len, u"just=")) { - if (Equals(str + 5, len - 5, L"left")) + if (Equals(str + 5, len - 5, u"left")) out.AddJustification(EJustification::Left); - else if (Equals(str + 5, len - 5, L"center")) + else if (Equals(str + 5, len - 5, u"center")) out.AddJustification(EJustification::Center); - else if (Equals(str + 5, len - 5, L"right")) + else if (Equals(str + 5, len - 5, u"right")) out.AddJustification(EJustification::Right); - else if (Equals(str + 5, len - 5, L"full")) + else if (Equals(str + 5, len - 5, u"fulu")) out.AddJustification(EJustification::Full); - else if (Equals(str + 5, len - 5, L"nleft")) + else if (Equals(str + 5, len - 5, u"nleft")) out.AddJustification(EJustification::NLeft); - else if (Equals(str + 5, len - 5, L"ncenter")) + else if (Equals(str + 5, len - 5, u"ncenter")) out.AddJustification(EJustification::NCenter); - else if (Equals(str + 5, len - 5, L"nright")) + else if (Equals(str + 5, len - 5, u"nright")) out.AddJustification(EJustification::NRight); } - else if (BeginsWith(str, len, L"vjust=")) + else if (BeginsWith(str, len, u"vjust=")) { - if (Equals(str + 6, len - 6, L"top")) + if (Equals(str + 6, len - 6, u"top")) out.AddVerticalJustification(EVerticalJustification::Top); - else if (Equals(str + 6, len - 6, L"center")) + else if (Equals(str + 6, len - 6, u"center")) out.AddVerticalJustification(EVerticalJustification::Center); - else if (Equals(str + 6, len - 6, L"bottom")) + else if (Equals(str + 6, len - 6, u"bottom")) out.AddVerticalJustification(EVerticalJustification::Bottom); - else if (Equals(str + 6, len - 6, L"full")) + else if (Equals(str + 6, len - 6, u"fulu")) out.AddVerticalJustification(EVerticalJustification::Full); - else if (Equals(str + 6, len - 6, L"ntop")) + else if (Equals(str + 6, len - 6, u"ntop")) out.AddVerticalJustification(EVerticalJustification::NTop); - else if (Equals(str + 6, len - 6, L"ncenter")) + else if (Equals(str + 6, len - 6, u"ncenter")) out.AddVerticalJustification(EVerticalJustification::NCenter); - else if (Equals(str + 6, len - 6, L"nbottom")) + else if (Equals(str + 6, len - 6, u"nbottom")) out.AddVerticalJustification(EVerticalJustification::NBottom); } - else if (Equals(str, len, L"push")) + else if (Equals(str, len, u"push")) { out.AddPushState(); } - else if (Equals(str, len, L"pop")) + else if (Equals(str, len, u"pop")) { out.AddPopState(); } } -CFontImageDef CTextParser::GetImage(const wchar_t* str, int len) +CFontImageDef CTextParser::GetImage(const char16_t* str, int len) { int commaCount = 0; for (int i=0 ; i> texs; @@ -232,19 +242,19 @@ CFontImageDef CTextParser::GetImage(const wchar_t* str, int len) return CFontImageDef(std::move(texs), interval, zeus::CVector2f(1.f, 1.f)); } - else if (BeginsWith(str, len, L"SA")) + else if (BeginsWith(str, len, u"SA")) { /* Scaled and animated texture array */ AdvanceCommaPos(); - float interval = std::wcstof(&iterable[tokenPos], nullptr); + float interval = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); AdvanceCommaPos(); - float scaleX = std::wcstof(&iterable[tokenPos], nullptr); + float scaleX = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); AdvanceCommaPos(); - float scaleY = std::wcstof(&iterable[tokenPos], nullptr); + float scaleY = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); std::vector> texs; @@ -259,15 +269,15 @@ CFontImageDef CTextParser::GetImage(const wchar_t* str, int len) return CFontImageDef(std::move(texs), interval, zeus::CVector2f(scaleX, scaleY)); } - else if (BeginsWith(str, len, L"SI")) + else if (BeginsWith(str, len, u"SI")) { /* Scaled single texture */ AdvanceCommaPos(); - float scaleX = std::wcstof(&iterable[tokenPos], nullptr); + float scaleX = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); AdvanceCommaPos(); - float scaleY = std::wcstof(&iterable[tokenPos], nullptr); + float scaleY = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); AdvanceCommaPos(); @@ -283,7 +293,7 @@ CFontImageDef CTextParser::GetImage(const wchar_t* str, int len) return CFontImageDef(std::move(tex), zeus::CVector2f(1.f, 1.f)); } -ResId CTextParser::GetAssetIdFromString(const wchar_t* str) +ResId CTextParser::GetAssetIdFromString(const char16_t* str) { u8 r = GetColorValue(str); u8 g = GetColorValue(str + 2); @@ -292,27 +302,27 @@ ResId CTextParser::GetAssetIdFromString(const wchar_t* str) return (r << 24) | (g << 16) | (b << 8) | a; } -TToken CTextParser::GetFont(const wchar_t* str, int len) +TToken CTextParser::GetFont(const char16_t* str, int len) { return x0_store.GetObj({SBIG('FONT'), GetAssetIdFromString(str)}); } -void CTextParser::ParseText(CTextExecuteBuffer& out, const wchar_t* str, int len) +void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int len) { for (int b=0, e=0 ; str[e] && (len == -1 || e < len) ;) { - if (str[e] != L'&') + if (str[e] != u'&') { ++e; continue; } - if ((len == -1 || e+1 < len) && str[e+1] != L'&') + if ((len == -1 || e+1 < len) && str[e+1] != u'&') { out.AddString(str + b, e - b); ++e; b = e; - while (str[e] && (len == -1 || e < len) && str[e] != L';') + while (str[e] && (len == -1 || e < len) && str[e] != u';') ++e; ParseTag(out, str + e, e - b); diff --git a/Runtime/GuiSys/CTextParser.hpp b/Runtime/GuiSys/CTextParser.hpp index 067c36447..6495e8f27 100644 --- a/Runtime/GuiSys/CTextParser.hpp +++ b/Runtime/GuiSys/CTextParser.hpp @@ -12,20 +12,20 @@ class CTextParser { IObjectStore& x0_store; - static CTextColor ParseColor(const wchar_t* str, int len); - static u8 GetColorValue(const wchar_t* str); - static u32 FromHex(wchar_t ch); - static s32 ParseInt(const wchar_t* str, int len, bool signVal); - static ResId GetAssetIdFromString(const wchar_t* str); - static bool Equals(const wchar_t* str, int len, const wchar_t* other); - static bool BeginsWith(const wchar_t* str, int len, const wchar_t* other); - void ParseTag(CTextExecuteBuffer& out, const wchar_t* str, int len); - CFontImageDef GetImage(const wchar_t* str, int len); - TToken GetFont(const wchar_t* str, int len); + static CTextColor ParseColor(const char16_t* str, int len); + static u8 GetColorValue(const char16_t* str); + static u32 FromHex(char16_t ch); + static s32 ParseInt(const char16_t* str, int len, bool signVal); + static ResId GetAssetIdFromString(const char16_t* str); + static bool Equals(const char16_t* str, int len, const char16_t* other); + static bool BeginsWith(const char16_t* str, int len, const char16_t* other); + void ParseTag(CTextExecuteBuffer& out, const char16_t* str, int len); + CFontImageDef GetImage(const char16_t* str, int len); + TToken GetFont(const char16_t* str, int len); public: CTextParser(IObjectStore& store) : x0_store(store) {} - void ParseText(CTextExecuteBuffer& out, const wchar_t* str, int len); + void ParseText(CTextExecuteBuffer& out, const char16_t* str, int len); }; } diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index 97bfc43c8..7b030940b 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -286,7 +286,7 @@ void CFrontEndUI::SNewFileSelectFrame::DeactivateNewGamePopup() x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()]. x0_base->SetColor(zeus::CColor::skWhite); - x60_textpane_cancel->TextSupport()->SetText(L""); + x60_textpane_cancel->TextSupport()->SetText(u""); } void CFrontEndUI::SNewFileSelectFrame::ActivateNewGamePopup() @@ -339,7 +339,7 @@ void CFrontEndUI::SNewFileSelectFrame::ResetFrame() for (int i=2 ; i>=0 ; --i) x20_tablegroup_fileselect->GetWorkerWidget(i)->SetIsSelectable(true); - x60_textpane_cancel->TextSupport()->SetText(L""); + x60_textpane_cancel->TextSupport()->SetText(u""); } void CFrontEndUI::SNewFileSelectFrame::ActivateErase() @@ -383,7 +383,7 @@ void CFrontEndUI::SNewFileSelectFrame::ClearFrameContents() option.x2c_chRate = SFileMenuOption::ComputeRandom(); option.x28_curField = -1; for (int j=0 ; j<4 ; ++j) - option.x4_textpanes[j].SetPairText(L""); + option.x4_textpanes[j].SetPairText(u""); } StartTextAnimating(x28_textpane_erase.x0_panes[0], g_MainStringTable->GetString(38), 60.f); @@ -439,7 +439,7 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() { if (++option.x28_curField < 4) { - std::wstring str; + std::u16string str; SGuiTextPair& populatePair = option.x4_textpanes[option.x28_curField]; const CGameState::GameFileStateInfo* data = x4_saveUI->GetGameData(i); @@ -449,8 +449,8 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() // Completion percent if (data) { - std::wstring fileStr = g_MainStringTable->GetString(data->x20_hardMode ? 106 : 39); - str = fileStr + hecl::WideFormat(L" %02d%%", data->x18_itemPercent); + std::u16string fileStr = g_MainStringTable->GetString(data->x20_hardMode ? 106 : 39); + str = fileStr + hecl::Char16Format(L" %02d%%", data->x18_itemPercent); break; } str = g_MainStringTable->GetString(36); @@ -475,7 +475,7 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents() if (data) { auto pt = std::div(data->x0_playTime, 3600); - str = hecl::WideFormat(L"%02d:%02d", pt.quot, pt.rem / 60); + str = hecl::Char16Format(L"%02d:%02d", pt.quot, pt.rem / 60); } str = g_MainStringTable->GetString(52); break; @@ -614,7 +614,7 @@ CFrontEndUI::SFileMenuOption CFrontEndUI::SNewFileSelectFrame::FindFileSelectOpt return ret; } -void CFrontEndUI::SNewFileSelectFrame::StartTextAnimating(CGuiTextPane* text, const std::wstring& str, float chRate) +void CFrontEndUI::SNewFileSelectFrame::StartTextAnimating(CGuiTextPane* text, const std::u16string& str, float chRate) { text->TextSupport()->SetText(str); text->TextSupport()->SetTypeWriteEffectOptions(true, 0.1f, chRate); @@ -710,17 +710,17 @@ void CFrontEndUI::SFusionBonusFrame::SGBALinkFrame::SetUIText(EUIType tp) break; } - std::wstring instructionsStr; + std::u16string instructionsStr; if (instructions != -1) instructionsStr = g_MainStringTable->GetString(instructions); xc_textpane_instructions.SetPairText(instructionsStr); - std::wstring yesStr; + std::u16string yesStr; if (yes != -1) yesStr = g_MainStringTable->GetString(yes); x14_textpane_yes->TextSupport()->SetText(yesStr); - std::wstring noStr; + std::u16string noStr; if (no != -1) noStr = g_MainStringTable->GetString(no); x18_textpane_no->TextSupport()->SetText(noStr); @@ -947,7 +947,7 @@ void CFrontEndUI::SFusionBonusFrame::Update(float dt, CSaveUI* saveUI) x2c_tablegroup_fusionsuit->SetIsVisible(showFusionSuitProceed); x24_loadedFrame->FindWidget("textpane_proceed")->SetIsVisible(showFusionSuitProceed); - std::wstring instructionStr; + std::u16string instructionStr; if (x28_tablegroup_options->GetUserSelection() == 1) { /* Fusion Suit */ @@ -1022,7 +1022,7 @@ void CFrontEndUI::SFusionBonusFrame::DoCancel(CGuiTableGroup* caller) x8_action = EAction::GoBack; x28_tablegroup_options->SetUserSelection(0); x2c_tablegroup_fusionsuit->SetIsActive(false); - x30_textpane_instructions.SetPairText(L""); + x30_textpane_instructions.SetPairText(u""); SetTableColors(x28_tablegroup_options); } } @@ -1090,7 +1090,7 @@ void CFrontEndUI::SFusionBonusFrame::DoAdvance(CGuiTableGroup* caller) } } -void CFrontEndUI::SGuiTextPair::SetPairText(const std::wstring& str) +void CFrontEndUI::SGuiTextPair::SetPairText(const std::u16string& str) { x0_panes[0]->TextSupport()->SetText(str); x0_panes[1]->TextSupport()->SetText(str); @@ -1104,7 +1104,7 @@ CFrontEndUI::SGuiTextPair CFrontEndUI::FindTextPanePair(CGuiFrame* frame, const return ret; } -void CFrontEndUI::FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str) +void CFrontEndUI::FindAndSetPairText(CGuiFrame* frame, const char* name, const std::u16string& str) { CGuiTextPane* w1 = static_cast(frame->FindWidget(name)); w1->TextSupport()->SetText(str); @@ -1557,7 +1557,7 @@ void CFrontEndUI::SOptionsFrontEndFrame::SetRightUIText() } else { - FindTextPanePair(x1c_loadedFrame, name).SetPairText(L""); + FindTextPanePair(x1c_loadedFrame, name).SetPairText(u""); x28_tablegroup_rightmenu->GetWorkerWidget(i)->SetIsSelectable(false); } } diff --git a/Runtime/MP1/CFrontEndUI.hpp b/Runtime/MP1/CFrontEndUI.hpp index 1a8074970..aa456bbf1 100644 --- a/Runtime/MP1/CFrontEndUI.hpp +++ b/Runtime/MP1/CFrontEndUI.hpp @@ -78,10 +78,10 @@ public: struct SGuiTextPair { CGuiTextPane* x0_panes[2] = {}; - void SetPairText(const std::wstring& str); + void SetPairText(const std::u16string& str); }; static SGuiTextPair FindTextPanePair(CGuiFrame* frame, const char* name); - static void FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str); + static void FindAndSetPairText(CGuiFrame* frame, const char* name, const std::u16string& str); struct SFileMenuOption { @@ -168,7 +168,7 @@ public: void DoFileMenuAdvance(CGuiTableGroup* caller); static SFileMenuOption FindFileSelectOption(CGuiFrame* frame, int idx); - static void StartTextAnimating(CGuiTextPane* text, const std::wstring& str, float chRate); + static void StartTextAnimating(CGuiTextPane* text, const std::u16string& str, float chRate); }; struct SFusionBonusFrame diff --git a/Runtime/MP1/CMemoryCardDriver.cpp b/Runtime/MP1/CMemoryCardDriver.cpp index ce310956a..2e608b808 100644 --- a/Runtime/MP1/CMemoryCardDriver.cpp +++ b/Runtime/MP1/CMemoryCardDriver.cpp @@ -29,7 +29,7 @@ ECardResult CMemoryCardDriver::SFileInfo::Close() ECardResult CMemoryCardDriver::SFileInfo::StartRead() { CMemoryCardSys::CardStat stat = {}; - ECardResult result = CMemoryCardSys::GetStatus(x0_fileInfo, stat); + ECardResult result = CMemoryCardSys::GetStatus(x0_fileInfo.slot, x0_fileInfo.getFileNo(), stat); if (result != ECardResult::READY) return result; @@ -78,7 +78,7 @@ ECardResult CMemoryCardDriver::SFileInfo::FileRead() ECardResult CMemoryCardDriver::SFileInfo::GetSaveDataOffset(u32& offOut) { CMemoryCardSys::CardStat stat = {}; - ECardResult result = CMemoryCardSys::GetStatus(x0_fileInfo, stat); + ECardResult result = CMemoryCardSys::GetStatus(x0_fileInfo.slot, x0_fileInfo.getFileNo(), stat); if (result != ECardResult::READY) { offOut = -1; @@ -189,7 +189,8 @@ void CMemoryCardDriver::ReadFinished() { CMemoryCardSys::CardStat stat = {}; SFileInfo& fileInfo = x100_mcFileInfos[x194_fileIdx].second; - if (CMemoryCardSys::GetStatus(fileInfo.x0_fileInfo, stat) != ECardResult::READY) + if (CMemoryCardSys::GetStatus(fileInfo.x0_fileInfo.slot, + fileInfo.x0_fileInfo.getFileNo(), stat) != ECardResult::READY) { NoCardFound(); return; @@ -201,7 +202,8 @@ void CMemoryCardDriver::ReadFinished() r.readBytesToBuf(x30_systemData, 174); for (int i=0 ; i<3 ; ++i) - xe4_fileSlots[i] = LoadSaveFile(r); + if (header.x4_savePresent[i]) + xe4_fileSlots[i] = LoadSaveFile(r); if (x19d_inGame) ImportPersistentOptions(); @@ -245,7 +247,8 @@ void CMemoryCardDriver::IndexFiles() else if (result == ECardResult::READY) { CMemoryCardSys::CardStat stat = {}; - if (CMemoryCardSys::GetStatus(info.second.x0_fileInfo, stat) == + if (CMemoryCardSys::GetStatus(info.second.x0_fileInfo.slot, + info.second.x0_fileInfo.getFileNo(), stat) == ECardResult::READY) { u32 comment = stat.GetCommentAddr(); @@ -278,11 +281,13 @@ void CMemoryCardDriver::IndexFiles() if (x100_mcFileInfos[1].first == EFileState::File) { CMemoryCardSys::CardStat stat = {}; - if (CMemoryCardSys::GetStatus(x100_mcFileInfos[0].second.x0_fileInfo, stat) == + if (CMemoryCardSys::GetStatus(x100_mcFileInfos[0].second.x0_fileInfo.slot, + x100_mcFileInfos[0].second.x0_fileInfo.getFileNo(), stat) == ECardResult::READY) { u32 timeA = stat.GetTime(); - if (CMemoryCardSys::GetStatus(x100_mcFileInfos[1].second.x0_fileInfo, stat) == + if (CMemoryCardSys::GetStatus(x100_mcFileInfos[1].second.x0_fileInfo.slot, + x100_mcFileInfos[1].second.x0_fileInfo.getFileNo(), stat) == ECardResult::READY) { u32 timeB = stat.GetTime(); diff --git a/Runtime/MP1/CMemoryCardDriver.hpp b/Runtime/MP1/CMemoryCardDriver.hpp index e11c64404..fa70e8931 100644 --- a/Runtime/MP1/CMemoryCardDriver.hpp +++ b/Runtime/MP1/CMemoryCardDriver.hpp @@ -74,6 +74,7 @@ private: struct SFileInfo { CMemoryCardSys::CardFileHandle x0_fileInfo; + std::string x14_name; std::vector x24_saveFileData; std::vector x34_saveData; @@ -81,7 +82,7 @@ private: kabufuda::ECardResult Open(); kabufuda::ECardResult Close(); kabufuda::ECardSlot GetFileCardPort() const { return x0_fileInfo.slot; } - int GetFileNo() const { return x0_fileInfo->getFileNo(); } + int GetFileNo() const { return x0_fileInfo.getFileNo(); } kabufuda::ECardResult StartRead(); kabufuda::ECardResult TryFileRead(); kabufuda::ECardResult FileRead(); diff --git a/Runtime/MP1/CSaveUI.cpp b/Runtime/MP1/CSaveUI.cpp index 4d81d9868..fd5ac5e9a 100644 --- a/Runtime/MP1/CSaveUI.cpp +++ b/Runtime/MP1/CSaveUI.cpp @@ -30,7 +30,7 @@ void CSaveUI::ResetCardDriver() CIOWin::EMessageReturn CSaveUI::Update(float dt) { - if (PumpLoad()) + if (!PumpLoad()) return CIOWin::EMessageReturn::Normal; x50_loadedFrame->Update(dt); @@ -61,6 +61,10 @@ CIOWin::EMessageReturn CSaveUI::Update(float dt) x6c_cardDriver->IndexFiles(); } } + else + { + x6c_cardDriver->IndexFiles(); + } } else if (x6c_cardDriver->x10_state == EState::Ready) { @@ -304,30 +308,30 @@ void CSaveUI::SetUIText() default: break; } - std::wstring msgAStr; + std::u16string msgAStr; if (msgA != -1) msgAStr = x38_strgMemoryCard->GetString(msgA); - std::wstring msgBStr; + std::u16string msgBStr; if (msgB != -1) msgBStr = x38_strgMemoryCard->GetString(msgB); x54_textpane_message->TextSupport()->SetText(msgAStr + msgBStr); - std::wstring opt0Str; + std::u16string opt0Str; if (opt0 != -1) opt0Str = x38_strgMemoryCard->GetString(opt0); x5c_textpane_choice0->TextSupport()->SetText(opt0Str); - std::wstring opt1Str; + std::u16string opt1Str; if (opt1 != -1) opt1Str = x38_strgMemoryCard->GetString(opt1); x60_textpane_choice1->TextSupport()->SetText(opt1Str); - std::wstring opt2Str; + std::u16string opt2Str; if (opt2 != -1) opt2Str = x38_strgMemoryCard->GetString(opt2); x64_textpane_choice2->TextSupport()->SetText(opt2Str); - std::wstring opt3Str; + std::u16string opt3Str; x68_textpane_choice3->TextSupport()->SetText(opt3Str); x5c_textpane_choice0->SetIsSelectable(opt0 != -1); diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index 82fe2f5d7..844d22188 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -389,7 +389,7 @@ void CWorldTransManager::EnableTransition(ResId fontId, ResId stringId, bool b1, x8_textData->SetTypeWriteEffectOptions(true, chFadeTime, chFadeRate); xc_strTable = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), stringId}); - x8_textData->SetText(L""); + x8_textData->SetText(u""); } void CWorldTransManager::DisableTransition() diff --git a/hecl b/hecl index df935c31c..767d2a471 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit df935c31c1f5c21519ed432c128dd7b1541cd972 +Subproject commit 767d2a471138dfa7f68e3254fdb942151b02cb78 diff --git a/kabufuda b/kabufuda index 3121f67f4..408ac735b 160000 --- a/kabufuda +++ b/kabufuda @@ -1 +1 @@ -Subproject commit 3121f67f4da34f64bcef3aecab1d269fc5a4e035 +Subproject commit 408ac735b4741d2d4b27e1cf985c3f69098025be