2026-02-13 14:34:15 +08:00
# include "GameFrameBase.h"
//#include "ArmFun.h"
# include "SimpleAudioEngine.h"
# include "UserInfo.h"
# include "GlobalJosn.h"
# include "Utility.h"
# include "MainScene.h"
# include "JniFun.h"
# include "LoadingScene.h"
# include "PopScene.h"
# include "SelectShareScene.h"
# define ANIM_DELAY_TIME 0.3f
# define RECORD_PLAY_TIME 1.6f
const BYTE cbFaceCount [ ] = { 5 , 9 , 3 , 10 , 4 , 4 , 6 , 6 , 4 , 4 , 4 , 8 } ;
GameFrameBase : : GameFrameBase ( )
: m_pSelfPlayer ( NULL )
//,m_bEnterGetUserInfo(true)
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϷTAG
this - > setTag ( SCENE_TAG_GAME ) ;
m_bPrivateEnd = false ;
m_pChatLayer = nullptr ;
m_kGameMission . SetClientKernelSink ( this ) ;
auto dispatcher = Director : : getInstance ( ) - > getEventDispatcher ( ) ;
dispatcher - > addCustomEventListener ( CONTINUE_GAME , CC_CALLBACK_1 ( GameFrameBase : : onEventContinueGame , this ) ) ;
dispatcher - > addCustomEventListener ( SEND_USER_CHAT_TEXT , CC_CALLBACK_1 ( GameFrameBase : : onEventUserChat , this ) ) ;
dispatcher - > addCustomEventListener ( SEND_USER_CHAT_FACE , CC_CALLBACK_1 ( GameFrameBase : : onEventUserFace , this ) ) ;
dispatcher - > addCustomEventListener ( LEAVE_GAME , CC_CALLBACK_1 ( GameFrameBase : : EventLeaveGame , this ) ) ;
dispatcher - > addCustomEventListener ( DISMISS_ROOM_EVENT , CC_CALLBACK_1 ( GameFrameBase : : onEventDismissRoom , this ) ) ;
dispatcher - > addCustomEventListener ( WEIXIN_SHOW , CC_CALLBACK_1 ( GameFrameBase : : onButtonWeiXinImagic , this ) ) ;
dispatcher - > addCustomEventListener ( AUTO_USER_READY_EVENT , CC_CALLBACK_1 ( GameFrameBase : : onEventAutoUserReady , this ) ) ;
2026-03-02 17:32:23 +08:00
// <20> <> ¼<EFBFBD> <C2BC> Ϣ;
2026-02-13 14:34:15 +08:00
m_GameRecord = tagGameRecord ( ) ; // <20> <> Ϸ<EFBFBD> <CFB7> ¼
m_iActRecordIdex = 0 ;
m_RecordTime = 0.f ;
m_wRecordSelfChairID = INVALID_CHAIR ;
2026-03-02 17:32:23 +08:00
m_wMainGameID = 0 ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> GAMEID
2026-02-13 14:34:15 +08:00
m_IsGameRecord = false ;
m_voicechairid . clear ( ) ;
m_VoiceList . clear ( ) ;
m_fLocationTimer = 0.f ;
m_fMusicVolume = 0.f ;
m_txtNetWorkTime = nullptr ;
m_SystemInfo = nullptr ;
m_PlatformNotic = nullptr ;
}
GameFrameBase : : ~ GameFrameBase ( )
{
this - > stopAllActions ( ) ;
auto dispatcher = Director : : getInstance ( ) - > getEventDispatcher ( ) ;
dispatcher - > removeCustomEventListeners ( CONTINUE_GAME ) ;
dispatcher - > removeCustomEventListeners ( SEND_USER_CHAT_TEXT ) ;
dispatcher - > removeCustomEventListeners ( SEND_USER_CHAT_FACE ) ;
dispatcher - > removeCustomEventListeners ( LEAVE_GAME ) ;
dispatcher - > removeCustomEventListeners ( DISMISS_ROOM_EVENT ) ;
dispatcher - > removeCustomEventListeners ( WEIXIN_SHOW ) ;
dispatcher - > removeCustomEventListeners ( AUTO_USER_READY_EVENT ) ;
m_kGameMission . SetClientKernelSink ( nullptr ) ;
m_kGameMission . stop ( ) ;
m_voicechairid . clear ( ) ;
m_VoiceList . clear ( ) ;
}
bool GameFrameBase : : init ( )
{
if ( ! Scene : : init ( ) )
{
return false ;
}
return true ;
}
void GameFrameBase : : onEnterTransitionDidFinish ( )
{
Scene : : onEnterTransitionDidFinish ( ) ;
LoadingScene : : Instance ( ) . show ( this ) ;
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ;
YvVoiceManager : : GetInstance ( ) - > setUploadListern ( this ) ;
YvVoiceManager : : GetInstance ( ) - > setPlayFinishFunc ( CC_CALLBACK_0 ( GameFrameBase : : onPlayFinish , this ) ) ;
}
void GameFrameBase : : onExit ( )
{
Scene : : onExit ( ) ;
CocosDenshion : : SimpleAudioEngine : : getInstance ( ) - > stopBackgroundMusic ( ) ;
unschedule ( schedule_selector ( GameFrameBase : : onGetNetWorkTime ) ) ;
}
void GameFrameBase : : onClickExitGameButton ( cocos2d : : Ref * )
{
if ( m_kGameMission . isAlive ( ) )
{
m_kGameMission . PerformStandUpAction ( ) ;
}
else
{
ExitGame ( ) ;
}
}
void GameFrameBase : : clearInfo ( )
{
while ( m_kPlayers . size ( ) )
{
GamePlayer * pTempPlayer = m_kPlayers [ 0 ] ;
removeGamePlayerToList ( pTempPlayer ) ;
DeletePlayer ( pTempPlayer ) ;
}
}
void GameFrameBase : : ExitGame ( )
{
clearInfo ( ) ;
m_kGameMission . stop ( ) ;
//ScenceManagerBase::Instance().GameBackScence();
//UserInfo::Instance().reqAccountInfo();
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϸ<EFBFBD> ¼<EFBFBD>
void GameFrameBase : : onEventContinueGame ( EventCustom * event )
{
SendUserReady ( ) ;
}
void GameFrameBase : : onEventUserFace ( EventCustom * event )
{
CMD_GF_C_UserExpression * pkSendNet = static_cast < CMD_GF_C_UserExpression * > ( event - > getUserData ( ) ) ;
m_kGameMission . SendSocketData ( MDM_GF_FRAME , SUB_GF_USER_EXPRESSION , pkSendNet , sizeof ( CMD_GF_C_UserExpression ) ) ;
}
void GameFrameBase : : onEventUserChat ( EventCustom * event )
{
CMD_GF_C_UserChat * pkSendNet = static_cast < CMD_GF_C_UserChat * > ( event - > getUserData ( ) ) ;
WORD wDataSize = sizeof ( CMD_GF_C_UserChat ) - sizeof ( pkSendNet - > szChatString ) + pkSendNet - > wChatLength * sizeof ( pkSendNet - > szChatString [ 0 ] ) ;
m_kGameMission . SendSocketData ( MDM_GF_FRAME , SUB_GF_USER_CHAT , pkSendNet , wDataSize ) ;
}
bool GameFrameBase : : RevTalkFile ( void * data , int dataSize )
{
DataStream kDataStream ( data , dataSize ) ;
tagCloudVoice cloudVoice ;
cloudVoice . StreamValue ( kDataStream , false ) ;
//if (cloudVoice.dwUserID != getSelfGamePlayer()->GetUserID())
{
m_voicechairid [ cloudVoice . strFileID ] = cloudVoice . dwUserID ;
m_VoiceList . push_back ( cloudVoice . strFileID ) ;
cocos2d : : log ( " ADD voice file = %s " , cloudVoice . strFileID . c_str ( ) ) ;
//m_fMusicVolume = CocosDenshion::SimpleAudioEngine::getInstance()->getBackgroundMusicVolume();
//if (m_fMusicVolume>0.3f)
//{
// CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(0.3f);
//}
bool bMusicPlaying = CocosDenshion : : SimpleAudioEngine : : getInstance ( ) - > isBackgroundMusicPlaying ( ) ;
if ( bMusicPlaying )
{
CocosDenshion : : SimpleAudioEngine : : getInstance ( ) - > pauseBackgroundMusic ( ) ;
}
showVoiceTip ( ) ;
}
return true ;
}
2026-03-02 17:32:23 +08:00
bool GameFrameBase : : OnSocketSubUserChat ( void * data , int dataSize ) //<2F> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
2026-02-13 14:34:15 +08:00
{
CMD_GF_S_UserChat * pUserChat = ( CMD_GF_S_UserChat * ) data ;
//Ч<> <D0A7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ASSERT ( dataSize < = sizeof ( CMD_GF_S_UserChat ) ) ;
ASSERT ( dataSize > = ( sizeof ( CMD_GF_S_UserChat ) - sizeof ( pUserChat - > szChatString ) ) ) ;
ASSERT ( dataSize = = ( sizeof ( CMD_GF_S_UserChat ) - sizeof ( pUserChat - > szChatString ) + pUserChat - > wChatLength * sizeof ( pUserChat - > szChatString [ 0 ] ) ) ) ;
//Ч<> <D0A7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( dataSize > sizeof ( CMD_GF_S_UserChat ) ) return false ;
if ( dataSize < ( sizeof ( CMD_GF_S_UserChat ) - sizeof ( pUserChat - > szChatString ) ) ) return false ;
if ( dataSize ! = ( sizeof ( CMD_GF_S_UserChat ) - sizeof ( pUserChat - > szChatString ) + pUserChat - > wChatLength * sizeof ( pUserChat - > szChatString [ 0 ] ) ) ) return false ;
GamePlayer * pGamePlayer = getPlayerByUserID ( pUserChat - > dwSendUserID ) ;
if ( pGamePlayer = = nullptr ) return true ;
std : : string strChat = utility : : a_u8 ( pUserChat - > szChatString ) ;
pGamePlayer - > showChatInfo ( strChat ) ;
//WORD wViewChairID = SwitchViewChairID(pGamePlayer->GetChairID());
//std::string strChat = utility::a_u8(pUserChat->szChatString);
//showUserChatMsg(wViewChairID, (char*)strChat.c_str(), pos);
return true ;
}
bool GameFrameBase : : OnSocketSubUserFace ( void * data , int dataSize ) //<2F> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
{
ASSERT ( dataSize = = sizeof ( CMD_GF_S_UserExpression ) ) ;
if ( dataSize ! = sizeof ( CMD_GF_S_UserExpression ) ) return false ;
CMD_GF_S_UserExpression * pUserFace = ( CMD_GF_S_UserExpression * ) data ;
Vec2 pos = GetPlayerPosByUserID ( pUserFace - > dwSendUserID ) ;
GamePlayer * pGamePlayer = getPlayerByUserID ( pUserFace - > dwSendUserID ) ;
if ( pGamePlayer = = nullptr ) return true ;
WORD wViewChairID = SwitchViewChairID ( pGamePlayer - > GetChairID ( ) ) ;
// <20> <> <EFBFBD> <EFBFBD> ;
if ( pUserFace - > isExpression )
{
ShowUserFace ( pUserFace ) ;
}
else
{
2026-03-02 17:32:23 +08:00
// <20> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> ;
2026-02-13 14:34:15 +08:00
std : : string strSoundPath = getShortChatSoundPath ( pGamePlayer - > GetUserInfo ( ) - > cbGender , pUserFace - > wItemIndex ) ;
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ;
2026-02-13 14:34:15 +08:00
std : : string strChatInfo = getShortChatInfoByIndex ( pUserFace - > wItemIndex ) ;
pGamePlayer - > showChatInfo ( strChatInfo ) ;
if ( ! strSoundPath . empty ( ) )
{
YSAudioEngine : : Instance ( ) . playEffect ( strSoundPath . c_str ( ) ) ;
}
}
return true ;
}
bool GameFrameBase : : ShowUserFace ( CMD_GF_S_UserExpression * pUserFace ) //<2F> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
{
if ( pUserFace = = nullptr ) return false ;
Vec2 pos = GetPlayerPosByUserID ( pUserFace - > dwSendUserID ) ;
2026-03-02 17:32:23 +08:00
//<2F> <> <EFBFBD> <EFBFBD>
2026-02-13 14:34:15 +08:00
Animation * pAnimate = LoadFaceAnimations ( pUserFace - > wItemIndex ) ;
ASSERT ( pAnimate ! = nullptr ) ;
if ( pAnimate )
{
auto animate = Animate : : create ( pAnimate ) ;
auto reani = Repeat : : create ( animate , 2 ) ;
auto spritAni = Sprite : : create ( ) ;
spritAni - > setAnchorPoint ( Point ( 0.5 , 0.5 ) ) ;
spritAni - > setPosition ( pos ) ;
this - > addChild ( spritAni , Max_Zorder ) ;
spritAni - > runAction ( Sequence : : create ( reani , DelayTime : : create ( 0.2f ) , RemoveSelf : : create ( ) , nullptr ) ) ;
}
return true ;
}
Animation * GameFrameBase : : LoadFaceAnimations ( uint16 wItemIndex )
{
Animation * pAnimate = nullptr ;
AnimationCache * pAnimationCache = AnimationCache : : getInstance ( ) ;
SpriteFrameCache * spriteCache = SpriteFrameCache : : getInstance ( ) ;
std : : string strAnimation = StringUtils : : format ( " Platform_Chat_%d " , wItemIndex ) ;
pAnimate = pAnimationCache - > getAnimation ( strAnimation ) ;
if ( pAnimate = = nullptr )
{
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> ÿһ <C3BF> <D2BB> ͼƬ
2026-02-13 14:34:15 +08:00
Vector < SpriteFrame * > sfme ;
std : : string strImg ;
for ( int i = 1 ; i < = cbFaceCount [ wItemIndex ] ; + + i )
{
2026-03-02 17:32:23 +08:00
// <20> <> ȡͼƬ<CDBC> <C6AC> <EFBFBD> ƣ<EFBFBD> <C6A3> <EFBFBD> <EFBFBD> 뵽<EFBFBD> <EBB5BD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2026-02-13 14:34:15 +08:00
strImg = __String : : createWithFormat ( " Platform/Talk/%d/%d.png " , wItemIndex + 1 , i ) - > getCString ( ) ;
Texture2D * pTexture = Director : : getInstance ( ) - > getTextureCache ( ) - > addImage ( strImg ) ;
if ( nullptr = = pTexture ) continue ;
Rect rect ( 0 , 0 , pTexture - > getContentSize ( ) . width , pTexture - > getContentSize ( ) . height ) ;
SpriteFrame * fname = SpriteFrame : : createWithTexture ( pTexture , rect ) ; //spriteCache->getSpriteFrameByName(strImg);
if ( fname )
{
sfme . pushBack ( fname ) ;
}
}
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD> <EFBFBD> ٶ<EFBFBD>
2026-02-13 14:34:15 +08:00
pAnimate = Animation : : createWithSpriteFrames ( sfme , ANIM_DELAY_TIME ) ;
pAnimationCache - > addAnimation ( pAnimate , strAnimation ) ;
}
return pAnimate ;
}
void GameFrameBase : : showVoiceTip ( )
{
if ( m_VoiceList . empty ( ) )
{
2026-03-02 17:32:23 +08:00
//// <20> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ;
2026-02-13 14:34:15 +08:00
//CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(m_fMusicVolume);
CocosDenshion : : SimpleAudioEngine : : getInstance ( ) - > resumeBackgroundMusic ( ) ;
return ;
}
std : : string strfile = m_VoiceList . front ( ) ;
std : : map < std : : string , WORD > : : iterator it = m_voicechairid . find ( strfile ) ;
if ( it ! = m_voicechairid . end ( ) )
{
uint32 dwUserID = it - > second ;
GamePlayer * pPlayer = getPlayerByUserID ( dwUserID ) ;
if ( pPlayer = = nullptr ) return ;
pPlayer - > showVoiceBubble ( ) ;
YvVoiceManager : : GetInstance ( ) - > PlayRecord ( strfile ) ;
}
}
void GameFrameBase : : hideVoiceTip ( const char * filePath )
{
cocos2d : : log ( " hideVoiceTip file = %s " , filePath ) ;
m_VoiceList . remove ( filePath ) ;
std : : map < std : : string , WORD > : : iterator it = m_voicechairid . find ( filePath ) ;
if ( it ! = m_voicechairid . end ( ) )
{
uint32 dwUserID = it - > second ;
GamePlayer * pPlayer = getPlayerByUserID ( dwUserID ) ;
if ( pPlayer = = nullptr ) return ;
pPlayer - > hideVoiceBubble ( ) ;
cocos2d : : log ( " del voice file = %s " , filePath ) ;
}
else
{
# if (CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM)
cocos2d : : log ( " not find voice file = %s " , filePath ) ;
ASSERT ( false ) ;
# endif
hideAllPlayerVoiceBubble ( ) ;
}
showVoiceTip ( ) ;
}
//<2F> <> <EFBFBD> ù<EFBFBD> <C3B9> <EFBFBD> <EFBFBD> ؼ<EFBFBD>
void GameFrameBase : : SetSystemNode ( ImageView * img )
{
if ( img = = nullptr ) return ;
// <20> <> <EFBFBD> <EFBFBD> ;
m_SystemInfo = img ;
CC_ASSERT ( m_SystemInfo ) ;
m_SystemInfo - > setVisible ( false ) ;
m_PlatformNotic = SystemNotice : : createSystemNotice ( " common/Img/Msg_BG.png " ) ;
ASSERT ( m_PlatformNotic ! = nullptr ) ;
if ( m_PlatformNotic )
{
m_PlatformNotic - > setPosition ( Vec2 ( m_SystemInfo - > getContentSize ( ) . width / 2 , m_SystemInfo - > getContentSize ( ) . height / 2 ) ) ;
m_PlatformNotic - > setCascadeOpacityEnabled ( true ) ;
m_PlatformNotic - > setCallBack ( [ this ] ( ) {
m_SystemInfo - > setVisible ( false ) ;
} ) ;
m_SystemInfo - > addChild ( m_PlatformNotic ) ;
}
}
//ϵͳ<CFB5> <CDB3> Ϣ
bool GameFrameBase : : OnSocketSubGameSystemMessage ( void * data , int dataSize )
{
CMD_CM_SystemMessage * pSystemMessage = ( CMD_CM_SystemMessage * ) data ;
uint16 wHeadSize = sizeof ( CMD_CM_SystemMessage ) - sizeof ( pSystemMessage - > szString ) ;
//Ч<> <D0A7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ASSERT ( ( dataSize > wHeadSize ) & & ( dataSize = = ( wHeadSize + pSystemMessage - > wLength * sizeof ( char ) ) ) ) ;
if ( ( dataSize < = wHeadSize ) | | ( dataSize ! = ( wHeadSize + pSystemMessage - > wLength * sizeof ( char ) ) ) ) return false ;
uint16 wType = pSystemMessage - > wType ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
if ( wType & SMT_EJECT )
{
PopScene : : Instance ( ) . show ( utility : : a_u8 ( pSystemMessage - > szString ) ) ;
}
//ϵͳ<CFB5> <CDB3> Ϣ
if ( wType & SMT_TABLE_ROLL )
{
ShowRollMessage ( pSystemMessage - > szString , 0 , true ) ;
}
//<2F> ر<EFBFBD> <D8B1> <EFBFBD> Ϸ
if ( ( ( wType & ( SMT_EJECT | SMT_TABLE_ROLL ) ) = = 0 ) & & ( wType & ( SMT_CLOSE_ROOM | SMT_CLOSE_GAME | SMT_CLOSE_LINK ) ) ! = 0 )
{
EventLeaveGame ( nullptr ) ;
}
return true ;
}
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ;
2026-02-13 14:34:15 +08:00
void GameFrameBase : : ShowRollMessage ( const std : : string & message , int repeat /*= 0*/ , bool bForever /*= false*/ )
{
if ( m_PlatformNotic )
{
m_PlatformNotic - > postMessage ( utility : : a_u8 ( message ) , repeat , bForever ) ;
m_SystemInfo - > setVisible ( true ) ;
}
}
//<2F> Թ<EFBFBD> <D4B9> <EFBFBD> Ϣ
bool GameFrameBase : : OnEventLookonMode ( void * data , int dataSize )
{
return true ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
bool GameFrameBase : : OnEventSceneMessage ( uint8 cbGameStatus , bool bLookonUser , void * data , int dataSize )
{
return true ;
}
2026-03-02 17:32:23 +08:00
//<2F> <> Ϸ<EFBFBD> <CFB7> Ϣ
2026-02-13 14:34:15 +08:00
bool GameFrameBase : : OnEventGameMessage ( int sub , void * data , int dataSize )
{
std : : vector < NET_CBInfo * > kCallFun ;
NET_CBInfoList : : iterator itor1 = m_kCBInfoList . begin ( ) ;
while ( itor1 ! = m_kCBInfoList . end ( ) )
{
if ( itor1 - > iIdex = = sub )
{
kCallFun . push_back ( & ( * itor1 ) ) ;
}
itor1 + + ;
}
std : : vector < NET_CBInfo * > : : iterator itor2 = kCallFun . begin ( ) ;
while ( itor2 ! = kCallFun . end ( ) )
{
utility : : mlog ( ( * itor2 ) - > kCallFunName . c_str ( ) ) ;
( ( * itor2 ) - > pCallBack ) ( data , dataSize ) ;
itor2 + + ;
}
return true ;
}
//<2F> <> <EFBFBD> ͺ <EFBFBD> <CDBA> <EFBFBD>
bool GameFrameBase : : SendSocketData ( uint16 wSubCmdID )
{
utility : : mlog ( " GameFrameBase::SendSocketData " , ( int ) wSubCmdID ) ;
return m_kGameMission . SendSocketData ( MDM_GF_GAME , wSubCmdID ) ;
}
//<2F> <> <EFBFBD> ͺ <EFBFBD> <CDBA> <EFBFBD>
bool GameFrameBase : : SendSocketData ( uint16 wSubCmdID , void * data , uint16 dataSize )
{
return m_kGameMission . SendSocketData ( MDM_GF_GAME , wSubCmdID , data , dataSize ) ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <D7BC>
bool GameFrameBase : : SendUserReady ( )
{
ResetAllData ( ) ;
return m_kGameMission . SendSocketData ( MDM_GF_FRAME , SUB_GF_USER_READY , 0 , 0 ) ;
}
void GameFrameBase : : addNetCB ( int iIdex , cocos2d : : Ref * pScence , std : : function < void ( void * , int ) > pCallBack , std : : string kCallName )
{
NET_CBInfo kInfo ;
kInfo . iIdex = iIdex ;
kInfo . pCallBack = pCallBack ;
kInfo . pSrc1 = pScence ;
kInfo . kCallFunName = kCallName ;
m_kCBInfoList . push_back ( kInfo ) ;
}
//<2F> ر<EFBFBD> <D8B1> <EFBFBD> Ϸ
void GameFrameBase : : CloseGameClient ( )
{
ExitGame ( ) ;
return ;
}
//<2F> <> Ϸ<EFBFBD> <CFB7> <EFBFBD> <EFBFBD>
void GameFrameBase : : ReconnectServer ( )
{
if ( ! m_bPrivateEnd & & ! m_IsGameRecord )
{
LoadingScene : : Instance ( ) . show ( this ) ;
this - > stopAllActions ( ) ;
m_kGameMission . stop ( ) ;
ResetTable ( ) ;
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ;
2026-02-13 14:34:15 +08:00
m_voicechairid . clear ( ) ;
m_VoiceList . clear ( ) ;
m_kGameMission . start ( ) ;
}
}
2026-03-02 17:32:23 +08:00
//<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> ·<EFBFBD> <C2B7> ;
2026-02-13 14:34:15 +08:00
const std : : string GameFrameBase : : getShortChatSoundPath ( uint8 cbGender , int nIndex )
{
2026-03-02 17:32:23 +08:00
// ƴ<> <C6B4> ;
2026-02-13 14:34:15 +08:00
std : : string strFilePath = " common/sound/chat/ " ;
if ( cbGender = = enMan )
{
strFilePath + = StringUtils : : format ( " man_chat%d.mp3 " , nIndex + 1 ) ;
}
else
{
strFilePath + = StringUtils : : format ( " woman_chat%d.mp3 " , nIndex + 1 ) ;
}
return strFilePath ;
}
GamePlayer * GameFrameBase : : getPoolPlayer ( IClientUserItem * pIClientUserItem )
{
GamePlayer * pPlayer = NULL ;
if ( m_kPoolPlayer . size ( ) )
{
pPlayer = m_kPoolPlayer . back ( ) ;
m_kPoolPlayer . pop_back ( ) ;
pPlayer - > setUserItem ( pIClientUserItem ) ;
}
return pPlayer ;
}
GamePlayer * GameFrameBase : : CreatePlayer ( IClientUserItem * pIClientUserItem )
{
GamePlayer * pPlayer = getPoolPlayer ( pIClientUserItem ) ;
if ( pPlayer )
{
return pPlayer ;
}
return new GamePlayer ( pIClientUserItem ) ;
}
void GameFrameBase : : DeletePlayer ( GamePlayer * pPlayer )
{
if ( utility : : haveInVector ( m_kPoolPlayer , pPlayer ) )
{
return ;
}
m_kPoolPlayer . push_back ( pPlayer ) ;
}
GamePlayer * GameFrameBase : : getGamePlayerByUserItem ( IClientUserItem * pIClientUserItem )
{
std : : vector < GamePlayer * > : : iterator itor = m_kPlayers . begin ( ) ;
for ( ; itor ! = m_kPlayers . end ( ) ; itor + + )
{
if ( ( * itor ) - > getUserItem ( ) = = pIClientUserItem )
{
return ( * itor ) ;
}
}
return NULL ;
}
GamePlayer * GameFrameBase : : getPlayerByChairID ( uint16 wChairID )
{
std : : vector < GamePlayer * > : : iterator itor = m_kPlayers . begin ( ) ;
for ( ; itor ! = m_kPlayers . end ( ) ; itor + + )
{
if ( ( * itor ) - > GetChairID ( ) = = wChairID )
{
return ( * itor ) ;
}
}
cocos2d : : log ( " getPlayerByChairID(%d) is null " , wChairID ) ;
return NULL ;
}
GamePlayer * GameFrameBase : : getPlayerByUserID ( uint32 wUserID )
{
std : : vector < GamePlayer * > : : iterator itor = m_kPlayers . begin ( ) ;
for ( ; itor ! = m_kPlayers . end ( ) ; itor + + )
{
if ( ( * itor ) - > GetUserID ( ) = = wUserID )
{
return ( * itor ) ;
}
}
return NULL ;
}
void GameFrameBase : : addGamePlayerToList ( GamePlayer * pPlayer )
{
CCAssert ( pPlayer - > getUserItem ( ) , " " ) ;
if ( ! utility : : haveInVector ( m_kPlayers , pPlayer ) )
{
m_kPlayers . push_back ( pPlayer ) ;
}
pPlayer - > PlayerEnter ( ) ;
pPlayer - > upPlayerInfo ( ) ;
pPlayer - > upPlayerState ( ) ;
// <20> <> <EFBFBD> ҽ <EFBFBD> <D2BD> <EFBFBD> ;
OnEventUserEnter ( pPlayer ) ;
}
void GameFrameBase : : removeGamePlayerToList ( GamePlayer * pPlayer )
{
if ( m_pSelfPlayer = = pPlayer )
{
m_pSelfPlayer = NULL ;
}
utility : : removeInVector ( m_kPlayers , pPlayer ) ;
pPlayer - > PlayerLeave ( ) ;
pPlayer - > setUserItem ( NULL ) ;
}
GamePlayer * GameFrameBase : : getSelfGamePlayer ( )
{
return m_pSelfPlayer ;
}
uint16 GameFrameBase : : getSelfChairID ( )
{
if ( m_pSelfPlayer = = NULL )
{
return 0 ;
}
return m_pSelfPlayer - > GetChairID ( ) ;
}
void GameFrameBase : : hideAllPlayerVoiceBubble ( )
{
std : : vector < GamePlayer * > : : iterator itor = m_kPlayers . begin ( ) ;
for ( ; itor ! = m_kPlayers . end ( ) ; itor + + )
{
GamePlayer * pPlayer = ( * itor ) ;
if ( pPlayer ! = nullptr )
{
pPlayer - > hideVoiceBubble ( ) ;
}
}
}
//<2F> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD> ;
void GameFrameBase : : OnEventUserEnter ( IClientUserItem * pIClientUserItem , bool bLookonUser )
{
GamePlayer * pPlayer = getGamePlayerByUserItem ( pIClientUserItem ) ;
if ( pPlayer )
{
pPlayer - > upPlayerInfo ( ) ;
return ;
}
IClientUserItem * pMeItem = GetMeUserItem ( ) ;
if ( ! pMeItem )
{
return ;
}
if ( pMeItem - > GetTableID ( ) ! = pIClientUserItem - > GetTableID ( ) )
{
return ;
}
if ( pIClientUserItem - > GetUserStatus ( ) = = US_LOOKON )
{
return ;
}
if ( GetMeUserItem ( ) = = pIClientUserItem )
{
CCAssert ( m_pSelfPlayer = = NULL , " " ) ;
m_pSelfPlayer = CreatePlayer ( pIClientUserItem ) ;
if ( m_pSelfPlayer = = NULL )
{
return ;
}
//m_pSelfPlayer->SetHeadHttp(UserInfo::Instance().getHeadHttp());
addGamePlayerToList ( m_pSelfPlayer ) ;
upSelfPlayerInfo ( ) ;
2026-03-02 17:32:23 +08:00
// ͬ<> <CDAC> <EFBFBD> û<EFBFBD> λ<EFBFBD> <CEBB> ;
2026-02-13 14:34:15 +08:00
tagUserAddr * pUserAddr = CGlobalUserInfo : : GetInstance ( ) - > GetUserAddr ( ) ;
m_pSelfPlayer - > SetLocation ( pUserAddr ) ;
int iIdex = 0 ;
while ( true )
{
IClientUserItem * pTempUserItem = GetTableUserItem ( iIdex ) ;
iIdex + + ;
if ( ! pTempUserItem )
{
break ;
}
if ( pTempUserItem - > GetTableID ( ) ! = pMeItem - > GetTableID ( ) )
{
continue ;
}
if ( pTempUserItem - > GetUserStatus ( ) = = US_LOOKON )
{
continue ;
}
//if (m_bEnterGetUserInfo)
//{
// m_kIndividualMission.query(pIClientUserItem->GetUserID(), false);
//}
if ( pTempUserItem = = pIClientUserItem )
{
continue ;
}
GamePlayer * pTempPlayer = CreatePlayer ( pTempUserItem ) ;
addGamePlayerToList ( pTempPlayer ) ;
}
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ӳٶ<D3B3> ʱ<EFBFBD> <CAB1> ȡ
2026-02-13 14:34:15 +08:00
if ( ! m_IsGameRecord )
{
m_PingTime . dwPingCount = 0 ;
schedule ( schedule_selector ( GameFrameBase : : onGetNetWorkTime ) , 5.f ) ;
}
}
else
{
if ( m_pSelfPlayer )
{
GamePlayer * pTempPlayer = CreatePlayer ( pIClientUserItem ) ;
addGamePlayerToList ( pTempPlayer ) ;
}
}
}
//<2F> û<EFBFBD> <C3BB> 뿪
void GameFrameBase : : OnEventUserLeave ( IClientUserItem * pIClientUserItem , bool bLookonUser )
{
GamePlayer * pPlayer = getGamePlayerByUserItem ( pIClientUserItem ) ;
if ( pPlayer )
{
OnEventUserLeave ( pPlayer ) ;
removeGamePlayerToList ( pPlayer ) ;
DeletePlayer ( pPlayer ) ;
}
}
//<2F> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
void GameFrameBase : : OnEventUserScore ( IClientUserItem * pIClientUserItem , bool bLookonUser )
{
GamePlayer * pPlayer = getGamePlayerByUserItem ( pIClientUserItem ) ;
if ( pPlayer )
{
pPlayer - > upPlayerInfo ( ) ;
OnUserScore ( pPlayer ) ;
}
//if (pPlayer == m_pSelfPlayer)
//{
// upSelfPlayerInfo();
//}
}
//<2F> û<EFBFBD> ״̬
void GameFrameBase : : OnEventUserStatus ( IClientUserItem * pIClientUserItem , bool bLookonUser )
{
GamePlayer * pPlayer = getGamePlayerByUserItem ( pIClientUserItem ) ;
if ( pPlayer )
{
pPlayer - > upPlayerState ( ) ;
OnEventUserStatus ( pPlayer ) ;
}
}
//<2F> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
void GameFrameBase : : OnEventUserAttrib ( IClientUserItem * pIClientUserItem , bool bLookonUser )
{
GamePlayer * pPlayer = getGamePlayerByUserItem ( pIClientUserItem ) ;
if ( pPlayer )
{
pPlayer - > upPlayerInfo ( ) ;
}
if ( pPlayer = = m_pSelfPlayer )
{
upSelfPlayerInfo ( ) ;
}
}
//<2F> û<EFBFBD> ͷ<EFBFBD> <CDB7>
void GameFrameBase : : OnEventCustomFace ( IClientUserItem * pIClientUserItem , bool bLookonUser )
{
GamePlayer * pPlayer = getGamePlayerByUserItem ( pIClientUserItem ) ;
if ( pPlayer )
{
pPlayer - > upPlayerInfo ( ) ;
}
}
void GameFrameBase : : onGPAccountInfoHttpIP ( uint32 dwUserID , std : : string strIP , std : : string strHttp )
{
GamePlayer * pPlayer = getPlayerByUserID ( dwUserID ) ;
if ( ! pPlayer )
{
return ;
}
IClientUserItem * pIClientUserItem = pPlayer - > getUserItem ( false ) ;
if ( ! pIClientUserItem )
{
return ;
}
//<2F> <> ȡ<EFBFBD> û<EFBFBD>
tagUserInfo * pUserInfo = pIClientUserItem - > GetUserInfo ( ) ;
strncpy ( pUserInfo - > szLogonIP , strIP . c_str ( ) , countarray ( pUserInfo - > szLogonIP ) ) ;
strncpy ( pUserInfo - > szHeadHttp , strHttp . c_str ( ) , countarray ( pUserInfo - > szHeadHttp ) ) ;
pPlayer - > upPlayerInfo ( ) ;
}
//<2F> û<EFBFBD> λ<EFBFBD> <CEBB>
void GameFrameBase : : onEventUserLocation ( IClientUserItem * pIClientUserItem , CMD_GF_S_UserLocation * pLocation )
{
GamePlayer * pPlayer = getGamePlayerByUserItem ( pIClientUserItem ) ;
if ( pPlayer )
{
pPlayer - > SetLocation ( pLocation ) ;
}
}
IClientUserItem * GameFrameBase : : GetMeUserItem ( )
{
return m_kGameMission . GetMeUserItem ( ) ;
}
IClientUserItem * GameFrameBase : : GetTableUserItem ( uint16 wChariID )
{
return m_kGameMission . GetTableUserItem ( wChariID ) ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӷ<EFBFBD> <D3B7> <EFBFBD> <EFBFBD> <EFBFBD>
void GameFrameBase : : SetServerItem ( CGameServerItem * pServerItem )
{
return m_kGameMission . SetServerItem ( pServerItem ) ;
}
2026-03-02 17:32:23 +08:00
//<2F> <> <EFBFBD> ض<EFBFBD> <D8B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ;
2026-02-13 14:34:15 +08:00
void GameFrameBase : : loadShortChat ( const std : : string & strFilePath )
{
std : : vector < std : : string > ( ) . swap ( m_vecShortChatList ) ;
auto str = cocos2d : : FileUtils : : getInstance ( ) - > getStringFromFile ( strFilePath ) ;
rapidjson : : Document doc ;
doc . Parse < 0 > ( str . c_str ( ) ) ;
if ( doc . HasParseError ( ) | | ! doc . IsArray ( ) )
{
return ;
}
if ( ! doc . HasParseError ( ) & & doc . IsArray ( ) )
{
for ( rapidjson : : SizeType i = 0 ; i < doc . Size ( ) ; + + i )
{
const rapidjson : : Value & v = doc [ i ] ;
std : : string strChatInfo = v . GetString ( ) ;
m_vecShortChatList . push_back ( strChatInfo ) ;
}
}
}
2026-03-02 17:32:23 +08:00
//<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> б <EFBFBD> ;
2026-02-13 14:34:15 +08:00
const std : : vector < std : : string > & GameFrameBase : : getShortChatList ( )
{
return m_vecShortChatList ;
}
2026-03-02 17:32:23 +08:00
//<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ;
2026-02-13 14:34:15 +08:00
std : : string GameFrameBase : : getShortChatInfoByIndex ( int nIndex )
{
if ( ( int ) m_vecShortChatList . size ( ) < = nIndex )
{
return " " ;
}
return m_vecShortChatList [ nIndex ] ;
}
2026-03-02 17:32:23 +08:00
/**************************************************** <20> <> Ϸ<EFBFBD> <CFB7> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> BEGIN ****************************************************/
2026-02-13 14:34:15 +08:00
// <20> 뿪<EFBFBD> <EBBFAA> Ϸ<EFBFBD> ¼<EFBFBD>
void GameFrameBase : : EventLeaveGame ( cocos2d : : EventCustom * event )
{
Director : : getInstance ( ) - > popScene ( ) ;
}
void GameFrameBase : : onEventDismissRoom ( cocos2d : : EventCustom * event )
{
__Bool * pBool = ( __Bool * ) event - > getUserData ( ) ;
onEventAgreeDismissRoom ( pBool - > getValue ( ) ) ;
}
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ<EFBFBD> <EFBFBD> <D7BC>
2026-02-13 14:34:15 +08:00
void GameFrameBase : : onEventAutoUserReady ( cocos2d : : EventCustom * event )
{
__Bool * pBool = ( __Bool * ) event - > getUserData ( ) ;
bool bAgree = pBool - > getValue ( ) ;
m_kGameMission . SendSocketData ( MDM_GF_FRAME , SUB_GF_USER_START_READY , & bAgree , sizeof ( bAgree ) ) ;
//if (bAgree)
//{
// ResetAllData();
// m_kGameMission.SendSocketData(MDM_GF_FRAME, SUB_GF_USER_START_READY, 0, 0);
//}
//else
//{
// ResetAllData();
// m_kGameMission.SendSocketData(MDM_GF_FRAME, SUB_GF_USER_NO_READY, 0, 0);
//}
}
2026-03-02 17:32:23 +08:00
// ˽<> ˳<EFBFBD> <CBB3> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> Ϸ<EFBFBD> ﲻ<EFBFBD> <EFB2BB> <EFBFBD> <EFBFBD> <EFBFBD> رճ<D8B1> <D5B3> <EFBFBD> );
2026-02-13 14:34:15 +08:00
void GameFrameBase : : PrivateRoomEnd ( )
{
std : : vector < GamePlayer * > : : iterator itor = m_kPlayers . begin ( ) ;
for ( ; itor ! = m_kPlayers . end ( ) ; itor + + )
{
GamePlayer * player = ( * itor ) ;
player - > setAllowLeave ( false ) ;
}
m_kGameMission . stop ( ) ;
}
// ͬ<> <CDAC> <EFBFBD> <EFBFBD> ɢ<EFBFBD> <C9A2> <EFBFBD> <EFBFBD>
void GameFrameBase : : onEventAgreeDismissRoom ( bool bAgree /* = true*/ )
{
CMD_GR_Dismiss_Private kNetInfo ;
kNetInfo . bDismiss = bAgree ? 1 : 0 ;
m_kGameMission . SendSocketData ( MDM_GR_PRIVATE , SUB_GR_PRIVATE_DISMISS , & kNetInfo , sizeof ( kNetInfo ) ) ;
}
// <20> <> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD>
void GameFrameBase : : onButtonWeiXinImagic ( Ref * )
{
std : : function < void ( bool , const std : : string & ) > afterCaptured = [ this ] ( bool bSucceed , std : : string name )
{
if ( bSucceed )
{
MissionWeiXin : : Instance ( ) . shareScreenWeiXin ( name ) ;
# if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
// ɾ<> <C9BE> <EFBFBD> ļ<EFBFBD> ;
FileUtils : : getInstance ( ) - > removeFile ( name ) ;
# endif
}
} ;
2026-03-02 17:32:23 +08:00
cocos2d : : utils : : captureScreen ( afterCaptured , " screenshot.png " ) ;
2026-02-13 14:34:15 +08:00
//SelectShareScene::Instance().shareImage();
}
/**/
void GameFrameBase : : OnSocketSubPrivateScoreInfo ( CMD_GF_Private_Score_Info * pNetInfo )
{
m_PrivateScoreInfo = * pNetInfo ;
}
2026-03-02 17:32:23 +08:00
/**************************************************** <20> <> Ϸ<EFBFBD> <CFB7> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> END ****************************************************/
2026-02-13 14:34:15 +08:00
//////////////////////////////// <20> <> Ϸ¼<CFB7> <C2BC> //////////////////////////////////////////
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϸ¼<CFB7> <C2BC> <EFBFBD> <EFBFBD> Դ
bool GameFrameBase : : SetGameRecord ( DataStream & kDataStream )
{
return m_GameRecord . StreamValue ( kDataStream , false ) ;
}
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Լ<EFBFBD> <D4BC> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2026-02-13 14:34:15 +08:00
void GameFrameBase : : SetMainGameID ( DWORD dwGameID , bool isGameRecord )
{
m_wMainGameID = dwGameID ;
m_IsGameRecord = isGameRecord ;
2026-03-02 17:32:23 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ˵<EFBFBD>
2026-02-13 14:34:15 +08:00
m_pMeunNOde = static_cast < Node * > ( CSLoader : : createNode ( " Games/GameRecord/GameRecordNode.csb " ) ) ;
this - > addChild ( m_pMeunNOde , 999 ) ;
this - > uiMenuInit ( ) ;
}
// <20> ˵<EFBFBD> <CBB5> <EFBFBD> ʼ <EFBFBD> <CABC>
void GameFrameBase : : uiMenuInit ( )
{
if ( m_pMeunNOde = = nullptr ) return ;
m_sprRepBg = ( Sprite * ) m_pMeunNOde - > getChildByName ( " rep_btnbackui " ) ;
CC_ASSERT ( m_sprRepBg ! = nullptr ) ;
m_btnExit = ( Button * ) m_pMeunNOde - > getChildByName ( " btnExit " ) ;
ASSERT ( m_btnExit ) ;
m_btnExit - > addClickEventListener ( [ = ] ( Ref * pSender ) {
YSAudioEngine : : Instance ( ) . playBtnClickEffect ( ) ;
Director : : getInstance ( ) - > popScene ( ) ;
} ) ;
m_btnBackWard = ( Button * ) m_sprRepBg - > getChildByName ( " btnBackWard " ) ;
ASSERT ( m_btnBackWard ) ;
m_btnBackWard - > addClickEventListener ( CC_CALLBACK_1 ( GameFrameBase : : LeftRecordAction , this ) ) ;
m_btnForward = ( Button * ) m_sprRepBg - > getChildByName ( " btnForward " ) ;
ASSERT ( m_btnForward ) ;
m_btnForward - > addClickEventListener ( CC_CALLBACK_1 ( GameFrameBase : : RightRecordAction , this ) ) ;
m_btnPlay = ( Button * ) m_sprRepBg - > getChildByName ( " btnPlay " ) ;
ASSERT ( m_btnPlay ) ;
m_btnPlay - > setVisible ( false ) ;
m_btnPlay - > addClickEventListener ( [ = ] ( Ref * pSender ) {
YSAudioEngine : : Instance ( ) . playBtnClickEffect ( ) ;
if ( m_iActRecordIdex > = ( int ) m_GameRecord . actionVec . size ( ) )
{
m_btnPlay - > setVisible ( true ) ;
m_btnPause - > setVisible ( false ) ;
return ;
}
m_btnPlay - > setVisible ( false ) ;
m_btnPause - > setVisible ( true ) ;
schedule ( schedule_selector ( GameFrameBase : : NextRecordAction ) , m_RecordTime ) ;
} ) ;
m_btnPause = ( Button * ) m_sprRepBg - > getChildByName ( " btnPause " ) ;
ASSERT ( m_btnPause ) ;
m_btnPause - > addClickEventListener ( [ = ] ( Ref * pSender ) {
YSAudioEngine : : Instance ( ) . playBtnClickEffect ( ) ;
m_btnPlay - > setVisible ( true ) ;
m_btnPause - > setVisible ( false ) ;
unschedule ( schedule_selector ( GameFrameBase : : NextRecordAction ) ) ;
} ) ;
m_txtRecordPercent = ( Text * ) m_pMeunNOde - > getChildByName ( " txtRecordPercent " ) ;
ASSERT ( m_txtRecordPercent ) ;
m_txtRecordPercent - > setString ( " 0% " ) ;
}
// <20> <> ʼ ¼<CABC> <EFBFBD>
bool GameFrameBase : : StartRecord ( WORD wGamePlayer )
{
LoadingScene : : Instance ( ) . hide ( ) ;
if ( m_GameRecord . playersVec . size ( ) > wGamePlayer )
{
return false ;
}
m_RecordTime = RECORD_PLAY_TIME ;
m_wRecordSelfChairID = 0 ;
// <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ;
OnSocketSubPrivateRoomInfo ( & m_GameRecord . roomInfo ) ;
int nRealUserCount = m_GameRecord . playersVec . size ( ) ;
2026-03-02 17:32:23 +08:00
// <20> <> ȡ<EFBFBD> Լ<EFBFBD> <D4BC> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB>
2026-02-13 14:34:15 +08:00
for ( int i = 0 ; i < nRealUserCount ; i + + )
{
tagGameRecordPlayer & kRecordPlayer = m_GameRecord . playersVec [ i ] ;
if ( kRecordPlayer . dwGameID = = m_wMainGameID )
{
m_wRecordSelfChairID = kRecordPlayer . wChairID ;
break ;
}
}
2026-03-02 17:32:23 +08:00
// <20> <> ʾ <EFBFBD> <CABE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> Լ<EFBFBD> <D4BC> <EFBFBD> ʼ );
2026-02-13 14:34:15 +08:00
tagGameRecordPlayer & kSelfRecordPlayer = m_GameRecord . playersVec [ m_wRecordSelfChairID ] ;
m_kGameMission . InitRecordGamePlayer ( m_wRecordSelfChairID , kSelfRecordPlayer ) ;
for ( WORD i = 0 ; i < nRealUserCount ; i + + )
{
if ( i = = m_wRecordSelfChairID ) continue ;
//WORD wNext = (m_wRecordSelfChairID + i) % wGamePlayer;
tagGameRecordPlayer & kRecordPlayer = m_GameRecord . playersVec [ i ] ;
m_kGameMission . InitRecordGamePlayer ( kRecordPlayer . wChairID , kRecordPlayer ) ;
}
m_iActRecordIdex = 0 ;
m_txtRecordPercent - > setString ( utility : : toString ( m_iActRecordIdex * 100 / m_GameRecord . actionVec . size ( ) , " % " ) ) ;
StartGameRecord ( ) ;
return true ;
}
void GameFrameBase : : LeftRecordAction ( Ref * ref )
{
YSAudioEngine : : Instance ( ) . playBtnClickEffect ( ) ;
if ( m_iActRecordIdex < ( int ) m_GameRecord . actionVec . size ( ) )
{
unschedule ( schedule_selector ( GameFrameBase : : NextRecordAction ) ) ;
m_RecordTime + = 0.5f ;
schedule ( schedule_selector ( GameFrameBase : : NextRecordAction ) , m_RecordTime ) ;
}
}
void GameFrameBase : : RightRecordAction ( Ref * ref )
{
YSAudioEngine : : Instance ( ) . playBtnClickEffect ( ) ;
if ( m_iActRecordIdex < ( int ) m_GameRecord . actionVec . size ( ) )
{
unschedule ( schedule_selector ( GameFrameBase : : NextRecordAction ) ) ;
m_RecordTime - = 0.5f ;
if ( m_RecordTime < 0.2f )
{
m_RecordTime = 0.5f ;
}
schedule ( schedule_selector ( GameFrameBase : : NextRecordAction ) , m_RecordTime ) ;
}
}
void GameFrameBase : : onUpLoadFileListern ( YVSDK : : UpLoadFileRespond * resp )
{
GamePlayer * pGamePlayer = getSelfGamePlayer ( ) ;
if ( pGamePlayer ! = nullptr )
{
std : : string url = resp - > fileurl ;
tagCloudVoice cloudVoice ;
cloudVoice . dwUserID = pGamePlayer - > GetUserID ( ) ;
cloudVoice . strFileID = url ;
DataStream kDataStream ;
cloudVoice . StreamValue ( kDataStream , true ) ;
m_kGameMission . SendSocketData ( MDM_GF_FRAME , SUB_GR_TABLE_TALK , & kDataStream [ 0 ] , kDataStream . size ( ) ) ;
}
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ;
void GameFrameBase : : onPlayFinish ( )
{
if ( m_VoiceList . size ( ) > 0 )
{
std : : string strfile = m_VoiceList . front ( ) ;
hideVoiceTip ( strfile . c_str ( ) ) ;
}
else
{
hideAllPlayerVoiceBubble ( ) ;
}
}
// <20> <> ʱ<EFBFBD> <CAB1> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> ӳ<EFBFBD>
void GameFrameBase : : onGetNetWorkTime ( float delta )
{
if ( m_kGameMission . isAlive ( ) )
{
m_PingTime . dwPingCount + + ;
m_llNetWorkTime = JniFun : : getCurrTime ( ) ;
m_kGameMission . SendSocketData ( MDM_GF_FRAME , SUB_GF_PING_TIME , & m_PingTime , sizeof ( m_PingTime ) ) ;
m_fLocationTimer + = delta ;
if ( m_fLocationTimer > 180.f )
{
2026-03-02 17:32:23 +08:00
//<2F> <> <EFBFBD> ͵<EFBFBD> <CDB5> <EFBFBD> λ<EFBFBD> <CEBB> ;
2026-02-13 14:34:15 +08:00
tagUserAddr * pUserAddr = CGlobalUserInfo : : GetInstance ( ) - > GetUserAddr ( ) ;
if ( pUserAddr & & pUserAddr - > isInit )
{
CMD_GF_C_UserLocation _location ;
zeromemory ( & _location , sizeof ( _location ) ) ;
_location . lLatitude = pUserAddr - > latitude * DOUBLE_TO_SCORE ;
_location . lLongitude = pUserAddr - > longitude * DOUBLE_TO_SCORE ;
_location . lAccuracy = pUserAddr - > accuracy * DOUBLE_TO_SCORE ;
strncpy ( _location . szAddress , pUserAddr - > strAddress . c_str ( ) , countarray ( _location . szAddress ) ) ;
m_kGameMission . SendSocketData ( MDM_GF_FRAME , SUB_GF_USER_LOCATION , & _location , sizeof ( _location ) ) ;
m_fLocationTimer = 0.f ;
}
}
}
}
bool GameFrameBase : : OnSocketSubNetWorkTime ( void * data , int dataSize )
{
ASSERT ( sizeof ( CMD_GF_S_PingTime ) = = dataSize ) ;
if ( sizeof ( CMD_GF_S_PingTime ) ! = dataSize ) return false ;
CMD_GF_S_PingTime * pingtime = ( CMD_GF_S_PingTime * ) data ;
if ( m_PingTime . dwPingCount ! = pingtime - > dwPingCount ) return false ;
long long llNetTime = JniFun : : getCurrTime ( ) - m_llNetWorkTime ;
if ( ( llNetTime > = 0 ) & & m_txtNetWorkTime )
{
m_txtNetWorkTime - > setString ( StringUtils : : format ( " %lldms " , llNetTime ) ) ;
if ( llNetTime > 500 )
{
m_txtNetWorkTime - > setTextColor ( Color4B ( 255 , 0 , 0 , 255 ) ) ;
}
else if ( llNetTime > 300 )
{
m_txtNetWorkTime - > setTextColor ( Color4B ( 255 , 255 , 0 , 255 ) ) ;
}
else
{
m_txtNetWorkTime - > setTextColor ( Color4B ( 0 , 255 , 0 , 255 ) ) ;
}
}
return true ;
}