diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index a64c458e..17de0acf 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -11525,7 +11525,7 @@ fn_8029B66C = .text:0x8029B66C; // type:function size:0xB8 __ct__10CSlideShowFv = .text:0x8029B724; // type:function size:0x600 scope:global fn_8029BD24 = .text:0x8029BD24; // type:function size:0x268 fn_8029BF8C = .text:0x8029BF8C; // type:function size:0xAC -fn_8029C038 = .text:0x8029C038; // type:function size:0xC0 +lower_bound,Q24rstl55vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>,Ui,Q24rstl57pair_sorter_finder,Q24rstl8less>>__4rstlFQ24rstl136const_pointer_iterator,Q24rstl55vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl136const_pointer_iterator,Q24rstl55vector,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>RCUiQ24rstl57pair_sorter_finder,Q24rstl8less> = .text:0x8029C038; // type:function size:0xC0 fn_8029C0F8 = .text:0x8029C0F8; // type:function size:0xF0 fn_8029C1E8 = .text:0x8029C1E8; // type:function size:0xD4 fn_8029C2BC = .text:0x8029C2BC; // type:function size:0x4C @@ -13332,12 +13332,12 @@ FromHex__11CTextParserFw = .text:0x803043BC; // type:function size:0x5C scope:gl ParseInt__11CTextParserFPCwib = .text:0x80304418; // type:function size:0x110 scope:global Equals__11CTextParserFPCwiPCw = .text:0x80304528; // type:function size:0x54 scope:global BeginsWith__11CTextParserFPCwiPCw = .text:0x8030457C; // type:function size:0x54 scope:global -ParseTag__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x803045D0; // type:function size:0x6D4 scope:global +ParseTag__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x803045D0; // type:function size:0x6D4 scope:global HandleUserTag__11CTextParserFR18CTextExecuteBufferPCwi = .text:0x80304CA4; // type:function size:0x8 scope:global -GetImage__11CTextParserFPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x80304CAC; // type:function size:0x87C scope:global +GetImage__11CTextParserFPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x80304CAC; // type:function size:0x87C scope:global GetFont__11CTextParserFPCwi = .text:0x80305528; // type:function size:0xC4 scope:global -GetAssetIdFromString__11CTextParserFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x803055EC; // type:function size:0x160 scope:global -ParseText__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x8030574C; // type:function size:0x154 scope:global +GetAssetIdFromString__11CTextParserFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>PQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x803055EC; // type:function size:0x160 scope:global +ParseText__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x8030574C; // type:function size:0x154 scope:global __ct__11CTextParserFR12IObjectStore = .text:0x803058A0; // type:function size:0x8 scope:global reserve__Q24rstl54vector<17TToken<8CTexture>,Q24rstl17rmemory_allocator>Fi = .text:0x803058A8; // type:function size:0xF8 scope:global GetEndRank__16CWordBreakTablesFw = .text:0x803059A0; // type:function size:0x94 scope:global diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index d02f4156..1ae0ce78 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -13334,10 +13334,10 @@ Equals__11CTextParserFPCwiPCw = .text:0x80304608; // type:function size:0x54 sco BeginsWith__11CTextParserFPCwiPCw = .text:0x8030465C; // type:function size:0x54 scope:global ParseTag__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x803046B0; // type:function size:0x6D4 scope:global HandleUserTag__11CTextParserFR18CTextExecuteBufferPCwi = .text:0x80304D84; // type:function size:0x8 scope:global -GetImage__11CTextParserFPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x80304D8C; // type:function size:0x87C scope:global +GetImage__11CTextParserFPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x80304D8C; // type:function size:0x87C scope:global GetFont__11CTextParserFPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x80305608; // type:function size:0xC4 scope:global -GetAssetIdFromString__11CTextParserFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x803056CC; // type:function size:0x160 scope:global -ParseText__11CTextParserFR18CTextExecuteBufferPCwi = .text:0x8030582C; // type:function size:0x154 scope:global +GetAssetIdFromString__11CTextParserFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>PQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x803056CC; // type:function size:0x160 scope:global +ParseText__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x8030582C; // type:function size:0x154 scope:global __ct__11CTextParserFR12IObjectStore = .text:0x80305980; // type:function size:0x8 scope:global reserve__Q24rstl54vector<17TToken<8CTexture>,Q24rstl17rmemory_allocator>Fi = .text:0x80305988; // type:function size:0xF8 scope:global GetEndRank__16CWordBreakTablesFw = .text:0x80305A80; // type:function size:0x94 scope:global diff --git a/config/GM8E01_48/symbols.txt b/config/GM8E01_48/symbols.txt index fb0c90aa..dd344443 100644 --- a/config/GM8E01_48/symbols.txt +++ b/config/GM8E01_48/symbols.txt @@ -13332,12 +13332,12 @@ FromHex__11CTextParserFw = .text:0x8030452C; // type:function size:0x5C ParseInt__11CTextParserFPCwib = .text:0x80304588; // type:function size:0x110 Equals__11CTextParserFPCwiPCw = .text:0x80304698; // type:function size:0x54 BeginsWith__11CTextParserFPCwiPCw = .text:0x803046EC; // type:function size:0x54 -ParseTag__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x80304740; // type:function size:0x6D4 +ParseTag__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x80304740; // type:function size:0x6D4 HandleUserTag__11CTextParserFR18CTextExecuteBufferPCwi = .text:0x80304E14; // type:function size:0x8 -GetImage__11CTextParserFPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x80304E1C; // type:function size:0x87C +GetImage__11CTextParserFPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x80304E1C; // type:function size:0x87C GetFont__11CTextParserFPCwi = .text:0x80305698; // type:function size:0xC4 -GetAssetIdFromString__11CTextParserFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x8030575C; // type:function size:0x160 -ParseText__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl52vector,Q24rstl17rmemory_allocator> = .text:0x803058BC; // type:function size:0x154 +GetAssetIdFromString__11CTextParserFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>PQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x8030575C; // type:function size:0x160 +ParseText__11CTextParserFR18CTextExecuteBufferPCwiRQ24rstl55vector,Q24rstl17rmemory_allocator> = .text:0x803058BC; // type:function size:0x154 __ct__11CTextParserFR12IObjectStore = .text:0x80305A10; // type:function size:0x8 reserve__Q24rstl54vector<17TToken<8CTexture>,Q24rstl17rmemory_allocator>Fi = .text:0x80305A18; // type:function size:0xF8 GetEndRank__16CWordBreakTablesFw = .text:0x80305B10; // type:function size:0x94 diff --git a/include/Kyoto/Text/CTextExecuteBuffer.hpp b/include/Kyoto/Text/CTextExecuteBuffer.hpp index 01fb2e76..add2586c 100644 --- a/include/Kyoto/Text/CTextExecuteBuffer.hpp +++ b/include/Kyoto/Text/CTextExecuteBuffer.hpp @@ -29,7 +29,8 @@ public: void AddColor(EColorType type, const CTextColor& color); void AddRemoveColorOverride(int idx); void AddColorOverride(int idx, const CTextColor& color); - + void AddString(const wchar_t* str, const int len); + private: InstList x0_instructions; CSaveableState x18_; @@ -42,7 +43,7 @@ private: int xb8_curWordY; int xbc_spaceDistance; bool xc0_imageBaseline; - rstl::list xc4_stateStack; + rstl::list< CSaveableState > xc4_stateStack; }; #endif // _CTEXTEXECUTEBUFFER diff --git a/include/Kyoto/Text/CTextParser.hpp b/include/Kyoto/Text/CTextParser.hpp index 166223ce..8c8c06fb 100644 --- a/include/Kyoto/Text/CTextParser.hpp +++ b/include/Kyoto/Text/CTextParser.hpp @@ -4,9 +4,10 @@ #include #include -#include -#include +#include "Kyoto/SObjectTag.hpp" #include "Kyoto/Text/CFontImageDef.hpp" +#include +#include class IObjectStore; class CRasterFont; @@ -15,17 +16,22 @@ class CTextExecuteBuffer; class CTextParser { public: CTextParser(IObjectStore& store); - void ParseText(CTextExecuteBuffer&, const wchar_t* str, int len, rstl::vector >& vec); - uint GetAssetIdFromString(const rstl::string& str); + void ParseText(CTextExecuteBuffer&, const wchar_t* str, int len, + rstl::vector< rstl::pair< CAssetId, CAssetId > >& vec); + static const CAssetId + GetAssetIdFromString(const rstl::string& str, + rstl::vector< rstl::pair< CAssetId, CAssetId > >* txtrMap); TToken< CRasterFont > GetFont(const wchar_t* str, int len); - CFontImageDef GetImage(const wchar_t* str, int len, rstl::vector >& vec); + CFontImageDef GetImage(const wchar_t* str, int len, + rstl::vector< rstl::pair< CAssetId, CAssetId > >& vec); uint HandleUserTag(CTextExecuteBuffer& buffer, const wchar_t* str, int len); - void ParseTag(CTextExecuteBuffer&, const wchar_t* str, int len, rstl::vector >& vec); + void ParseTag(CTextExecuteBuffer&, const wchar_t* str, int len, + rstl::vector< rstl::pair< CAssetId, CAssetId > >& vec); static bool BeginsWith(const wchar_t* str1, int len, const wchar_t* str2); static bool Equals(const wchar_t* str1, int len, const wchar_t* str2); static int ParseInt(const wchar_t* str, int len, bool); static int FromHex(wchar_t c); - static int GetColorValue(const wchar_t* str); + static const int GetColorValue(const wchar_t* str); CTextColor ParseColor(const wchar_t* str, int len); private: diff --git a/src/Kyoto/Text/CTextParser.cpp b/src/Kyoto/Text/CTextParser.cpp index 43cd8020..63b28184 100644 --- a/src/Kyoto/Text/CTextParser.cpp +++ b/src/Kyoto/Text/CTextParser.cpp @@ -1,14 +1,61 @@ #include "Kyoto/Text/CTextParser.hpp" #include "Kyoto/Math/CVector2f.hpp" +#include "Kyoto/SObjectTag.hpp" #include "Kyoto/Text/CRasterFont.hpp" #include "Kyoto/Text/CTextExecuteBuffer.hpp" #include "Kyoto/Text/TextCommon.hpp" +#include +#include CTextParser::CTextParser(IObjectStore& store) : mObjectStore(store) {} -void CTextParser::ParseText(CTextExecuteBuffer& buffer, const wchar_t* str, int len, rstl::vector >& vec) {} +void CTextParser::ParseText(CTextExecuteBuffer& buffer, const wchar_t* str, int len, + rstl::vector< rstl::pair< CAssetId, CAssetId > >& txtrMap) { + int b = 0, e = 0; + for (b = 0, e = 0; str[e] && (len == -1 || e < len);) { + if (str[e] == L'&') { + if ((len == -1 || e + 1 < len) && str[e + 1] != L'&') { + if (e > b) { + buffer.AddString(str + b, e - b); + } + ++e; + b = e; -uint CTextParser::GetAssetIdFromString(const rstl::string& str) {} + while ((len == -1 || e < len) && str[e] && str[e] != L';') + ++e; + + ParseTag(buffer, str + b, e - b, txtrMap); + b = e + 1; + } else { + buffer.AddString(str + b, e + 1 - b); + e += 2; + b = e; + } + } else { + ++e; + } + } + + if (e > b) + buffer.AddString(str + b, e - b); +} + +const CAssetId +CTextParser::GetAssetIdFromString(const rstl::string& inStr, + rstl::vector< rstl::pair< CAssetId, CAssetId > >* txtrMap) { + rstl::wstring str = CStringExtras::ConvertToUNICODE(inStr); + int id = (GetColorValue(str.data()) << 24) | (GetColorValue(str.data() + 2) << 16) | + (GetColorValue(str.data() + 4) << 8) | GetColorValue(str.data() + 6); + if (txtrMap) { + rstl::vector< rstl::pair< CAssetId, CAssetId > >::const_iterator search = + rstl::find_by_key(*txtrMap, id); + if (search != txtrMap->end()) { + return search->second; + } + } + + return id; +} TToken< CRasterFont > CTextParser::GetFont(const wchar_t* str, int len) { uint id = (GetColorValue(str) << 24) | GetColorValue(str + 2) << 16 | @@ -17,7 +64,8 @@ TToken< CRasterFont > CTextParser::GetFont(const wchar_t* str, int len) { return mObjectStore.GetObj(SObjectTag('FONT', id)); } -CFontImageDef CTextParser::GetImage(const wchar_t* str, int len, rstl::vector >& vec) { +CFontImageDef CTextParser::GetImage(const wchar_t* str, int len, + rstl::vector< rstl::pair< CAssetId, CAssetId > >& vec) { return CFontImageDef(TToken< CTexture >(), CVector2f(0.f, 0.f)); } @@ -25,7 +73,8 @@ uint CTextParser::HandleUserTag(CTextExecuteBuffer& buffer, const wchar_t* strin return 0; } -void CTextParser::ParseTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len, rstl::vector >& vec) { +void CTextParser::ParseTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len, + rstl::vector< rstl::pair< CAssetId, CAssetId > >& vec) { if (BeginsWith(string, len, L"font=")) { TToken< CRasterFont > font = GetFont(string + 5, len - 5); buffer.AddFont(font); @@ -158,7 +207,7 @@ int CTextParser::FromHex(wchar_t ch) { return 0; } -int CTextParser::GetColorValue(const wchar_t* str) { +const int CTextParser::GetColorValue(const wchar_t* str) { return FromHex(str[1]) + (FromHex(str[0]) << 4); } diff --git a/src/MetroidPrime/Cameras/CCameraManager.cpp b/src/MetroidPrime/Cameras/CCameraManager.cpp index 05e897df..9cfb5886 100644 --- a/src/MetroidPrime/Cameras/CCameraManager.cpp +++ b/src/MetroidPrime/Cameras/CCameraManager.cpp @@ -562,8 +562,8 @@ void CCameraManager::UpdateCameraHints(float dt, CStateManager& mgr) { for (rstl::reserved_vector< TUniqueId, 64 >::iterator id = x2b0_inactiveCameraHints.begin(); id != x2b0_inactiveCameraHints.end(); ++id) { TUniqueId uid = *id; - if (const CScriptCameraHint* hint = - TCastToConstPtr< CScriptCameraHint >(mgr.GetObjectById(uid))) { + const CScriptCameraHint* hint = TCastToConstPtr< CScriptCameraHint >(mgr.GetObjectById(uid)); + if (hint) { if (hint->GetSenderCount() == 0 || hint->GetInactive()) { for (rstl::reserved_vector< rstl::pair< int, TUniqueId >, 64 >::iterator it = xac_cameraHints.begin(); @@ -589,10 +589,10 @@ void CCameraManager::UpdateCameraHints(float dt, CStateManager& mgr) { for (rstl::reserved_vector< TUniqueId, 64 >::iterator id = x334_activeCameraHints.begin(); id != x334_activeCameraHints.end(); ++id) { TUniqueId uid = *id; - if (const CScriptCameraHint* hint = - TCastToConstPtr< CScriptCameraHint >(mgr.GetObjectById(uid))) { + const CScriptCameraHint* hint = TCastToConstPtr< CScriptCameraHint >(mgr.GetObjectById(uid)); + if (hint) { bool activeHintPresent = false; - for (rstl::reserved_vector< rstl::pair< int, TUniqueId >, 64 >::iterator it = + for (rstl::reserved_vector< rstl::pair< int, TUniqueId >, 64 >::const_iterator it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) { if (it->second == uid) { @@ -611,9 +611,9 @@ void CCameraManager::UpdateCameraHints(float dt, CStateManager& mgr) { } if (inactiveHintRemoved || activeHintAdded || invalidHintRemoved) { - // rstl::less< int > less; - // rstl::pair_sorter_finder< rstl::pair< int, TUniqueId >, rstl::less< int > > sorter(less); - // rstl::sort(xac_cameraHints.begin(), xac_cameraHints.end(), sorter); + rstl::less< int > less; + rstl::pair_sorter_finder< rstl::pair< int, TUniqueId >, rstl::less< int > > sorter(less); + rstl::sort(xac_cameraHints.begin(), xac_cameraHints.end(), sorter); CTransform4f ballCamXf = x80_ballCamera->GetTransform(); if ((inactiveHintRemoved || invalidHintRemoved) && xac_cameraHints.empty()) { NoCameraHintsLeft(mgr);