//
// GJWriteMessagePopup::closeMessagePopup from 0x1002dce34 to 0x1002dcfa8 (372 bytes)
//
// 4 xrefs:
// > GJWriteMessagePopup::onClose @ 0x1002dc9b0
// > GJWriteMessagePopup::keyBackClicked @ 0x1002dcfe0
// > sub_1002DCFE4 @ 0x1002dcfec
// > GJWriteMessagePopup::onClosePopup @ 0x1002dd5f4
//
// 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)
{
GJUserMessage *v4; // x20
GameLevelManager *v5; // x0
GameLevelManager *v6; // x0
GJUserMessage *StoredUserMessage; // x0
GJMessagePopup *v8; // x0
std::string __p; // [xsp+0h] [xbp-50h] BYREF
std::string __str; // [xsp+20h] [xbp-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;
if ( (a1->m_messageText.m_data.m_short.shortStorage.__elems_[22] & 0x8000000000000000LL) != 0 )
{
if ( !a1->m_messageText.m_data.m_long.size )
goto LABEL_18;
LABEL_7:
v4 = GJUserMessage::create_1();
if ( a1->m_messageText.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(&__str, (void *)a1->m_messageText.m_data.m_long.capacitym1, a1->m_messageText.m_data.m_long.size);
else
__str = (std::string)a1->m_messageText;
std::string::operator=((std::string *)&v4->m_content, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( a1->m_subjectText.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(&__p, (void *)a1->m_subjectText.m_data.m_long.capacitym1, a1->m_subjectText.m_data.m_long.size);
else
__p = a1->m_subjectText;
std::string::operator=((std::string *)&v4->m_title, (const std::string *)&__p);
if ( __p.m_data.m_short.shortStorage.__elems_[22] < 0 )
operator delete((void *)__p.m_data.m_long.capacitym1);
v5 = GameLevelManager::sharedState();
GameLevelManager::storeUserMessageReply(v5, a1->m_accountID, v4);
goto LABEL_18;
}
if ( a1->m_messageText.m_data.m_short.shortStorage.__elems_[22] )
goto LABEL_7;
LABEL_18:
v6 = GameLevelManager::sharedState();
StoredUserMessage = GameLevelManager::getStoredUserMessage(v6, a1->m_accountID);
if ( StoredUserMessage )
{
v8 = GJMessagePopup::create(StoredUserMessage);
v8->m_noElasticity = 1;
((void (__fastcall *)(GJMessagePopup *))v8->show)(v8);
}
LABEL_20:
((void (__fastcall *)(GJWriteMessagePopup *, _QWORD))a1->setKeypadEnabled)(a1, 0);
((void (__fastcall *)(GJWriteMessagePopup *, __int64))a1->removeFromParentAndCleanup)(a1, 1);
}