//
// GJWriteMessagePopup::closeMessagePopup from 0x1002aa170 to 0x1002aa313 (419 bytes)
//
// 3 xrefs:
// > GJWriteMessagePopup::onClose @ 0x1002a9c37
// > GJWriteMessagePopup::keyBackClicked @ 0x1002aa347
// > sub_1002AA350 @ 0x1002aa35e
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall GJWriteMessagePopup::closeMessagePopup(GJWriteMessagePopup *a1, bool a2)
{
__int128 v2; // xmm0
unsigned int sizex2; // eax
std::string *p_m_messageText; // r15
GJUserMessage *v5; // r14
GameLevelManager *v6; // rax
GameLevelManager *v7; // rax
GJUserMessage *StoredUserMessage; // rax
GJMessagePopup *v9; // rax
std::string __str; // [rsp+0h] [rbp-50h] BYREF
std::string m_subjectText; // [rsp+20h] [rbp-30h] BYREF
((void (__fastcall *)(CCTextInputNode *, _QWORD))a1->m_messageInput->onClickTrackNode)(a1->m_messageInput, 0);
((void (__fastcall *)(CCTextInputNode *, _QWORD))a1->m_subjectInput->onClickTrackNode)(a1->m_subjectInput, 0);
if ( a2 || !a1->m_accountID )
goto LABEL_20;
sizex2 = a1->m_messageText.m_data.m_short.sizex2;
if ( (sizex2 & 1) != 0 )
{
if ( !a1->m_messageText.m_data.m_long.size )
goto LABEL_18;
LABEL_7:
p_m_messageText = &a1->m_messageText;
v5 = GJUserMessage::create_1();
if ( (a1->m_messageText.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&__str,
a1->m_messageText.m_data.m_long.longStorage,
a1->m_messageText.m_data.m_long.size,
*(double *)&v2);
}
else
{
__str.__r_.__value_.__r.__words[2] = (std::string::size_type)a1->m_messageText.m_data.m_long.longStorage;
v2 = *(_OWORD *)&p_m_messageText->m_data.m_short.sizex2;
*(_OWORD *)&__str.__r_.__value_.__l.0 = *(_OWORD *)&p_m_messageText->m_data.m_short.sizex2;
}
std::string::operator=((std::string *)&v5->m_content, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( (a1->m_subjectText.m_data.m_short.sizex2 & 1) != 0 )
sub_100006B70(
&m_subjectText,
a1->m_subjectText.m_data.m_long.longStorage,
a1->m_subjectText.m_data.m_long.size,
*(double *)&v2);
else
m_subjectText = (std::string)a1->m_subjectText;
std::string::operator=((std::string *)&v5->m_title, &m_subjectText);
if ( (*(_BYTE *)&m_subjectText.__r_.__value_.__s.0 & 1) != 0 )
operator delete(m_subjectText.__r_.__value_.__l.__data_);
v6 = GameLevelManager::sharedState();
GameLevelManager::storeUserMessageReply(v6, a1->m_accountID, v5);
goto LABEL_18;
}
if ( sizex2 >> 1 )
goto LABEL_7;
LABEL_18:
v7 = GameLevelManager::sharedState();
StoredUserMessage = GameLevelManager::getStoredUserMessage(v7, a1->m_accountID);
if ( StoredUserMessage )
{
v9 = GJMessagePopup::create(StoredUserMessage);
v9->m_noElasticity = 1;
((void (__fastcall *)(GJMessagePopup *))v9->show)(v9);
}
LABEL_20:
((void (__fastcall *)(GJWriteMessagePopup *, _QWORD))a1->setKeypadEnabled)(a1, 0);
((void (__fastcall *)(GJWriteMessagePopup *, __int64))a1->removeFromParentAndCleanup)(a1, 1);
}