650 lines
18 KiB
C++
650 lines
18 KiB
C++
|
|
#include "RecordScene.h"
|
|||
|
|
#include "MissionWeiXin.h"
|
|||
|
|
#include "SimpleAudioEngine.h"
|
|||
|
|
#include "UserInfo.h"
|
|||
|
|
#include "PopScene.h"
|
|||
|
|
#include "GameCreator.h"
|
|||
|
|
#include "WN_CMD_Sparrow.h"
|
|||
|
|
#include "NN_CMD.h"
|
|||
|
|
#include "13S_CMD.h"
|
|||
|
|
#include "ZJH_CMD.h"
|
|||
|
|
#include "editor-support/cocostudio/CCComExtensionData.h"
|
|||
|
|
|
|||
|
|
using namespace cocostudio;
|
|||
|
|
|
|||
|
|
#define MAX_PLAYER_COUNT 5 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
|
|||
|
|
RecordScene::RecordScene() :m_kGameRecordMission(GlobalJosn::getInstance()->m_strLogonIp.c_str(), GlobalJosn::getInstance()->m_iPort)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_kGameRecordMission.setUrl(GlobalJosn::getInstance()->m_strLogonIp.c_str(), GlobalJosn::getInstance()->m_iPort);
|
|||
|
|
m_kGameRecordMission.setMissionSink(this);
|
|||
|
|
|
|||
|
|
m_RecordType = RT_RANK;
|
|||
|
|
m_wKindID = WNMJ_SPACE::KIND_ID;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
RecordScene::~RecordScene()
|
|||
|
|
{
|
|||
|
|
m_kGameRecordMission.stop();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool RecordScene::init()
|
|||
|
|
{
|
|||
|
|
if (!Node::init())
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
auto rootPanel = CSLoader::createNode("Platform/RecordScene.csb");
|
|||
|
|
CC_ASSERT(rootPanel != nullptr);
|
|||
|
|
this->addChild(rootPanel);
|
|||
|
|
|
|||
|
|
/**************************** <20>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD> ********************************************/
|
|||
|
|
m_ImageView = (ImageView*)rootPanel->getChildByName("Imagebg");
|
|||
|
|
CC_ASSERT(m_ImageView != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
|
m_TotalItem = (Layout*)m_ImageView->getChildByName("TotalItem");
|
|||
|
|
CC_ASSERT(m_TotalItem != nullptr);
|
|||
|
|
for (int i = 0; i < MAX_PLAYER_COUNT -1; i++)
|
|||
|
|
{
|
|||
|
|
auto txtplayer = (Text*)m_TotalItem->getChildByName(StringUtils::format("txtplayer_%d", i));
|
|||
|
|
ASSERT(txtplayer);
|
|||
|
|
txtplayer->setString("");
|
|||
|
|
}
|
|||
|
|
m_TotalItem->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>¼
|
|||
|
|
m_ListItem = (Layout*)m_ImageView->getChildByName("ListItem");
|
|||
|
|
CC_ASSERT(m_ListItem != nullptr);
|
|||
|
|
for (int i = 0; i < MAX_PLAYER_COUNT; i++)
|
|||
|
|
{
|
|||
|
|
auto txtScore = (Text*)m_ListItem->getChildByName(StringUtils::format("txtScore_%d", i));
|
|||
|
|
ASSERT(txtScore);
|
|||
|
|
txtScore->setString("");
|
|||
|
|
}
|
|||
|
|
m_ListItem->setVisible(false);
|
|||
|
|
|
|||
|
|
m_PanelListHeader = (Layout*)m_ImageView->getChildByName("ListViewHeader");
|
|||
|
|
CC_ASSERT(m_PanelListHeader != nullptr);
|
|||
|
|
for (int i = 0; i < MAX_PLAYER_COUNT; i++)
|
|||
|
|
{
|
|||
|
|
auto txtUserName = (Text*)m_PanelListHeader->getChildByName(StringUtils::format("txtUserName_%d", i));
|
|||
|
|
ASSERT(txtUserName);
|
|||
|
|
txtUserName->setString("");
|
|||
|
|
}
|
|||
|
|
m_PanelListHeader->setVisible(false);
|
|||
|
|
|
|||
|
|
m_pListView = (ListView*)m_ImageView->getChildByName("ListViewInfo");
|
|||
|
|
CC_ASSERT(m_pListView != nullptr);
|
|||
|
|
|
|||
|
|
// <20><>Ϸ<EFBFBD>˵<EFBFBD>;
|
|||
|
|
for (int i = 0; i < MAX_GAME_COUNT; i++)
|
|||
|
|
{
|
|||
|
|
std::string strItemKey = __String::createWithFormat("chb_Item_%d", i)->getCString();
|
|||
|
|
CheckBox* GameItem = (CheckBox*)m_ImageView->getChildByName(strItemKey);
|
|||
|
|
ASSERT(GameItem != nullptr);
|
|||
|
|
if (GameItem == nullptr) continue;
|
|||
|
|
m_RadioGroupMenu.AddCheckBox(GameItem);
|
|||
|
|
|
|||
|
|
GameItem->addClickEventListener([this](Ref* ref){
|
|||
|
|
if (ref == nullptr) return;
|
|||
|
|
|
|||
|
|
CheckBox* chbSelect = (CheckBox*)ref;
|
|||
|
|
auto pData = (ComExtensionData*)chbSelect->getComponent("ComExtensionData");
|
|||
|
|
std::string strUserData = pData->getCustomProperty();
|
|||
|
|
m_wKindID = atoi(strUserData.c_str());
|
|||
|
|
|
|||
|
|
LoadingScene::Instance().show(this);
|
|||
|
|
m_kGameRecordMission.GetGameRecordList(UserInfo::Instance().getUserID(), m_wKindID); // <20><>ȡ¼<C8A1><C2BC><EFBFBD>б<EFBFBD>;
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_RadioGroupMenu.setDelauftSelect(0, true);
|
|||
|
|
|
|||
|
|
/**************************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ********************************************/
|
|||
|
|
m_ImageTop = (ImageView*)rootPanel->getChildByName("top");
|
|||
|
|
CC_ASSERT(m_ImageTop != nullptr);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>رհ<D8B1>ť
|
|||
|
|
auto btnClose = (Button*)m_ImageTop->getChildByName("btnClose");
|
|||
|
|
CC_ASSERT(btnClose != nullptr);
|
|||
|
|
|
|||
|
|
//ע<><D7A2><EFBFBD>رհ<D8B1>ť<EFBFBD>¼<EFBFBD>
|
|||
|
|
btnClose->addClickEventListener([this](Ref*){
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
|
|||
|
|
if (m_RecordType == RT_GAME)
|
|||
|
|
{
|
|||
|
|
onGPBackGameRecordList(nullptr);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->popScene();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//<2F>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD>˻ط<CBBB>
|
|||
|
|
m_btnOther = (Button*)m_ImageTop->getChildByName("btnOther");
|
|||
|
|
CC_ASSERT(m_btnOther != nullptr);
|
|||
|
|
m_btnOther->addClickEventListener([this](Ref*){
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
if (m_CheckRcord->isVisible() == false)
|
|||
|
|
{
|
|||
|
|
m_CheckRcord->setVisible(true);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ز鿴<D8B2><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һطŴ<D8B7><C5B4><EFBFBD>
|
|||
|
|
m_CheckRcord = (Node*)CSLoader::createNode("Platform/CheckRecordScene.csb");
|
|||
|
|
CC_ASSERT(m_CheckRcord != nullptr);
|
|||
|
|
m_CheckRcord->setVisible(false);
|
|||
|
|
this->addChild(m_CheckRcord);
|
|||
|
|
|
|||
|
|
auto m_btnCheckClose = (Button*)m_CheckRcord->getChildByName("btnClose");
|
|||
|
|
CC_ASSERT(m_btnCheckClose);
|
|||
|
|
m_btnCheckClose->addClickEventListener([this](Ref*){
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
if (m_CheckRcord->isVisible())
|
|||
|
|
{
|
|||
|
|
m_CheckRcord->setVisible(false);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
auto btnCheckOk = (Button*)m_CheckRcord->getChildByName("btnOk");
|
|||
|
|
CC_ASSERT(btnCheckOk != nullptr);
|
|||
|
|
btnCheckOk->addClickEventListener(CC_CALLBACK_1(RecordScene::onClickCheckRecord, this));
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::onEnter()
|
|||
|
|
{
|
|||
|
|
Node::onEnter();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::onEnterTransitionDidFinish()
|
|||
|
|
{
|
|||
|
|
Node::onEnterTransitionDidFinish();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::onExit()
|
|||
|
|
{
|
|||
|
|
Node::onExit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::string RecordScene::timeToString(systemtime kSystem)
|
|||
|
|
{
|
|||
|
|
std::string kStr;
|
|||
|
|
kStr = StringUtils::format("%04d-%02d-%02d %02d:%02d:%02d", kSystem.wYear, kSystem.wMonth, kSystem.wDay, kSystem.wHour, kSystem.wMinute, kSystem.wSecond);
|
|||
|
|
return kStr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::string RecordScene::scoreToString(SCORE lScore)
|
|||
|
|
{
|
|||
|
|
if (lScore > 0)
|
|||
|
|
{
|
|||
|
|
return StringUtils::format("+%d", lScore);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return StringUtils::format("%d", lScore);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|||
|
|
void RecordScene::onGPBackGameRecordList(tagPrivateRandTotalRecordList* pNetInfo)
|
|||
|
|
{
|
|||
|
|
LoadingScene::Instance().hide();
|
|||
|
|
|
|||
|
|
if (nullptr == m_pListView) return;
|
|||
|
|
m_pListView->removeAllChildren();
|
|||
|
|
m_PanelListHeader->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
if (pNetInfo != nullptr)
|
|||
|
|
{
|
|||
|
|
m_PrivateRandTotalRecordList = *pNetInfo;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = 0; i < (int)m_PrivateRandTotalRecordList.kList.size(); i++)
|
|||
|
|
{
|
|||
|
|
tagPrivateRandTotalRecord& kInfo = m_PrivateRandTotalRecordList.kList[i];
|
|||
|
|
Layout* layoutItem = (Layout*)m_TotalItem->clone();
|
|||
|
|
if (nullptr == layoutItem) continue;
|
|||
|
|
m_pListView->pushBackCustomItem(layoutItem);
|
|||
|
|
layoutItem->setVisible(true);
|
|||
|
|
|
|||
|
|
// <20><>ֵ
|
|||
|
|
auto txtRecordID = (Text*)layoutItem->getChildByName("txtRecordID");
|
|||
|
|
ASSERT(txtRecordID);
|
|||
|
|
txtRecordID->setString(utility::toString(i+1));
|
|||
|
|
|
|||
|
|
auto txtRoomID = (Text*)layoutItem->getChildByName("txtRoomID");
|
|||
|
|
ASSERT(txtRoomID);
|
|||
|
|
txtRoomID->setString(utility::toString(kInfo.iRoomNum));
|
|||
|
|
|
|||
|
|
auto txtTime = (Text*)layoutItem->getChildByName("txtTime");
|
|||
|
|
ASSERT(txtTime);
|
|||
|
|
txtTime->setString(timeToString(kInfo.kPlayTime));
|
|||
|
|
|
|||
|
|
// <20>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|||
|
|
BYTE __ind = 0;
|
|||
|
|
for (int m = 0; m < (int)kInfo.kNickName.size(); m++)
|
|||
|
|
{
|
|||
|
|
// <20>Լ<EFBFBD>;
|
|||
|
|
if (kInfo.kUserID[m] == UserInfo::Instance().getUserID())
|
|||
|
|
{
|
|||
|
|
auto txtScore = (Text*)layoutItem->getChildByName("txtScore");
|
|||
|
|
ASSERT(txtScore);
|
|||
|
|
txtScore->setString(utility::ScoreToString(kInfo.kScore[m]));
|
|||
|
|
|
|||
|
|
auto ImgResult = (ImageView*)layoutItem->getChildByName("ImgResult");
|
|||
|
|
ASSERT(ImgResult);
|
|||
|
|
|
|||
|
|
if (kInfo.kScore[m] > 0)
|
|||
|
|
{
|
|||
|
|
ImgResult->loadTexture("common/Img/win.png");
|
|||
|
|
}
|
|||
|
|
else if (kInfo.kScore[m] < 0)
|
|||
|
|
{
|
|||
|
|
ImgResult->loadTexture("common/Img/lose.png");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ImgResult->loadTexture("common/Img/ping.png");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
auto txtplayer = (Text*)layoutItem->getChildByName(StringUtils::format("txtplayer_%d", __ind++));
|
|||
|
|
if (txtplayer)
|
|||
|
|
{
|
|||
|
|
std::string strScore = scoreToString(kInfo.kScore[m]);
|
|||
|
|
std::string strNicName = utility::getShortName(kInfo.kNickName[m], 6);
|
|||
|
|
if (!strNicName.empty())
|
|||
|
|
{
|
|||
|
|
std::string strInfo = StringUtils::format("%s:%s", strNicName.c_str(), strScore.c_str());
|
|||
|
|
txtplayer->setString(utility::a_u8(strInfo));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//std::string strScore = scoreToString(kInfo.kScore[m]);
|
|||
|
|
//std::string strInfo = StringUtils::format("%s: %s", kInfo.kNickName[m].c_str(), strScore.c_str());
|
|||
|
|
//txtplayer->setString(utility::a_u8(strInfo));
|
|||
|
|
//txtplayer->setVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ע<><D7A2><EFBFBD>鿴<EFBFBD>¼<EFBFBD>;
|
|||
|
|
auto btncheck = (Button*)layoutItem->getChildByName("btncheck");
|
|||
|
|
if (btncheck)
|
|||
|
|
{
|
|||
|
|
btncheck->addClickEventListener([kInfo, this](Ref* ref){
|
|||
|
|
m_kGameRecordMission.GetPrivateRandTotalRecord(kInfo.iRecordID);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
m_RecordType = RT_ROOM;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>Ϸ<EFBFBD><CFB7>¼
|
|||
|
|
void RecordScene::onGPBackGameTotalRecord(tagPrivateRandTotalRecord* pNetInfo)
|
|||
|
|
{
|
|||
|
|
m_kPrivateRandTotalRecord = *pNetInfo;
|
|||
|
|
|
|||
|
|
if (nullptr == m_pListView) return;
|
|||
|
|
m_pListView->removeAllChildren();
|
|||
|
|
|
|||
|
|
if (pNetInfo->kRecordChild.size()>0)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < MAX_PLAYER_COUNT; i++)
|
|||
|
|
{
|
|||
|
|
auto txtUserName = (Text*)m_PanelListHeader->getChildByName(StringUtils::format("txtUserName_%d", i));
|
|||
|
|
if (txtUserName)
|
|||
|
|
{
|
|||
|
|
if (i < (int)pNetInfo->kNickName.size())
|
|||
|
|
{
|
|||
|
|
std::string strName = utility::a_u8(pNetInfo->kNickName[i]);
|
|||
|
|
txtUserName->setString(utility::getShortName(strName, 10));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtUserName->setString("");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//for (int i = 0; i < (int)pNetInfo->kNickName.size(); i++)
|
|||
|
|
//{
|
|||
|
|
// auto txtUserName = (Text*)m_PanelListHeader->getChildByName(StringUtils::format("txtUserName_%d", i));
|
|||
|
|
// if (txtUserName)
|
|||
|
|
// {
|
|||
|
|
// std::string strName = utility::a_u8(pNetInfo->kNickName[i]);
|
|||
|
|
// txtUserName->setString(utility::getShortName(strName, 10));
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
m_PanelListHeader->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ţţ<C5A3><C5A3><EFBFBD>ɻط<C9BB>;
|
|||
|
|
bool isReplayer = true;
|
|||
|
|
if ((pNetInfo->dwKindID == NN_KIND_ID) || (pNetInfo->dwKindID == ZJH_KIND_ID))
|
|||
|
|
{
|
|||
|
|
isReplayer = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = 0; i < (int)pNetInfo->kRecordChild.size(); i++)
|
|||
|
|
{
|
|||
|
|
tagPrivateRandRecordChild kInfo = pNetInfo->kRecordChild[i];
|
|||
|
|
Layout* layoutItem = (Layout*)m_ListItem->clone();
|
|||
|
|
if (nullptr == layoutItem) continue;
|
|||
|
|
m_pListView->pushBackCustomItem(layoutItem);
|
|||
|
|
layoutItem->setVisible(true);
|
|||
|
|
|
|||
|
|
auto txtIndex = (Text*)layoutItem->getChildByName("txtIndex");
|
|||
|
|
ASSERT(txtIndex);
|
|||
|
|
txtIndex->setString(utility::toString(i+1));
|
|||
|
|
|
|||
|
|
auto txtTime = (Text*)layoutItem->getChildByName("txtTime");
|
|||
|
|
ASSERT(txtTime);
|
|||
|
|
std::string strTime = StringUtils::format("%02d:%02d:%02d", kInfo.kPlayTime.wHour, kInfo.kPlayTime.wMinute, kInfo.kPlayTime.wSecond);
|
|||
|
|
txtTime->setString(strTime);
|
|||
|
|
|
|||
|
|
auto txtRecordChildID = (Text*)layoutItem->getChildByName("txtRecordChildID");
|
|||
|
|
ASSERT(txtRecordChildID);
|
|||
|
|
txtRecordChildID->setVisible(false);
|
|||
|
|
txtRecordChildID->setString(utility::toString(kInfo.iRecordChildID));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>;
|
|||
|
|
std::vector<std::string> userScores = utility::split(kInfo.kUserDefine, ",");
|
|||
|
|
|
|||
|
|
for (int m = 0; m < (int)userScores.size(); m++)
|
|||
|
|
{
|
|||
|
|
if (!pNetInfo->kNickName[m].empty())
|
|||
|
|
{
|
|||
|
|
auto txtScore = (Text*)layoutItem->getChildByName(StringUtils::format("txtScore_%d", m));
|
|||
|
|
if (txtScore)
|
|||
|
|
{
|
|||
|
|
txtScore->setString(userScores[m]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
auto btnPlay = (Button*)layoutItem->getChildByName("btnPlay"); // <20>طŰ<D8B7>ť
|
|||
|
|
auto btnShow = (Button*)layoutItem->getChildByName("btnShow"); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
|
|||
|
|
|
|||
|
|
if (btnShow && btnPlay)
|
|||
|
|
{
|
|||
|
|
if (isReplayer)
|
|||
|
|
{
|
|||
|
|
int iRecordChildID = kInfo.iRecordChildID;
|
|||
|
|
btnPlay->addClickEventListener([iRecordChildID, this](Ref* ref){
|
|||
|
|
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
if (ref == nullptr) return;
|
|||
|
|
|
|||
|
|
m_kGameRecordMission.GetPrivateRandRecordChild(iRecordChildID);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
btnShow->addClickEventListener([iRecordChildID, this](Ref* ref){
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ(Ҫ<>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>Ӻż<D3BA><C5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|||
|
|
std::string strMsg = StringUtils::format("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>ս<EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %d", iRecordChildID);
|
|||
|
|
std::string strUrl = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_WEIXIN_URL);
|
|||
|
|
std::string strTitle = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_WEIXIN_TITLE);
|
|||
|
|
MissionWeiXin::Instance().shareUrlWeiXin(strUrl, strTitle, utility::a_u8(strMsg));
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
btnShow->setVisible(isReplayer);
|
|||
|
|
btnPlay->setVisible(isReplayer);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
m_RecordType = RT_GAME;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::StartGame(tagPrivateRandRecordChild* kChild)
|
|||
|
|
{
|
|||
|
|
if (kChild == nullptr) return;
|
|||
|
|
|
|||
|
|
cocos2d::log("iRecordChildID = %d", kChild->iRecordChildID);
|
|||
|
|
|
|||
|
|
GameFrameBase* pGameFrame = CGameCreator::getInstance()->startGameClient(kChild->dwKindID);
|
|||
|
|
if (pGameFrame)
|
|||
|
|
{
|
|||
|
|
cocos2d::log("set Game Record...");
|
|||
|
|
if (pGameFrame->SetGameRecord(kChild->kRecordGame))
|
|||
|
|
{
|
|||
|
|
cocos2d::log("set Main GameID...");
|
|||
|
|
pGameFrame->SetMainGameID(UserInfo::getInstance()->getGameID(), true);
|
|||
|
|
|
|||
|
|
cocos2d::log("start Record client...");
|
|||
|
|
Director::getInstance()->pushScene(TransitionCrossFade::create(0.3f, pGameFrame));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
PopScene::Instance().show(utility::a_u8("<EFBFBD>ط<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
PopScene::Instance().show(utility::a_u8("δ<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>طţ<EFBFBD>"));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::onListViewClickEvent(Ref* ref, ListView::EventType eventType)
|
|||
|
|
{
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
|
|||
|
|
if (m_RecordType != RT_ROOM) return;
|
|||
|
|
|
|||
|
|
ListView* listView = dynamic_cast<ListView*>(ref);
|
|||
|
|
if (listView == nullptr || eventType != ListView::EventType::ON_SELECTED_ITEM_END)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ssize_t index = m_pListView->getCurSelectedIndex();
|
|||
|
|
auto selectItem = (Layout*)m_pListView->getItem(index);
|
|||
|
|
if (nullptr == selectItem) return;
|
|||
|
|
|
|||
|
|
auto txtRecordID = (Text*)selectItem->getChildByName("txtRecordID");
|
|||
|
|
ASSERT(txtRecordID);
|
|||
|
|
|
|||
|
|
std::string strRecordID = txtRecordID->getString();
|
|||
|
|
char* lpStrEnd = NULL;
|
|||
|
|
int iRecordID = (int)strtol(strRecordID.c_str(), &lpStrEnd, 10);
|
|||
|
|
|
|||
|
|
m_kGameRecordMission.GetPrivateRandTotalRecord(iRecordID);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::onClickCheckRecord(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
|
|||
|
|
if (m_CheckRcord->isVisible() == false) return;
|
|||
|
|
|
|||
|
|
TextField* txtRecordChildID = (TextField*)m_CheckRcord->getChildByName("txtRecordChildID");
|
|||
|
|
CC_ASSERT(txtRecordChildID);
|
|||
|
|
|
|||
|
|
if (txtRecordChildID->getStringLength() <= 0)
|
|||
|
|
{
|
|||
|
|
PopScene::Instance().show(utility::a_u8("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļط<EFBFBD><EFBFBD>벻<EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
char* lpStrEnd = NULL;
|
|||
|
|
int iChildRecordID = (int)strtol(txtRecordChildID->getString().c_str(), &lpStrEnd, 10);
|
|||
|
|
if (iChildRecordID <= 0)
|
|||
|
|
{
|
|||
|
|
PopScene::Instance().show(utility::a_u8("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļط<EFBFBD><EFBFBD>벻<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϣ<EFBFBD>"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_kGameRecordMission.GetPrivateRandRecordChild(iChildRecordID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::onGPBackGameRecordChild(tagPrivateRandRecordChild* pNetInfo)
|
|||
|
|
{
|
|||
|
|
if (nullptr == pNetInfo) return;
|
|||
|
|
|
|||
|
|
cocos2d::log("iRecordChildID = %d", pNetInfo->iRecordChildID);
|
|||
|
|
StartGame(pNetInfo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::pushScene()
|
|||
|
|
{
|
|||
|
|
float height = Director::getInstance()->getWinSize().height;
|
|||
|
|
|
|||
|
|
if (m_ImageTop)
|
|||
|
|
{
|
|||
|
|
float top_h = m_ImageTop->getContentSize().height;
|
|||
|
|
|
|||
|
|
m_ImageTop->setPositionY(height + top_h / 2);
|
|||
|
|
m_ImageTop->runAction(MoveBy::create(0.2f, Vec2(0, 0 - top_h)));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (m_ImageView)
|
|||
|
|
{
|
|||
|
|
float b_h = m_ImageView->getContentSize().height;
|
|||
|
|
|
|||
|
|
m_ImageView->setPositionY(0);
|
|||
|
|
m_ImageView->setOpacity(0);
|
|||
|
|
|
|||
|
|
auto act = MoveBy::create(0.2f, Vec2(0, b_h / 2));
|
|||
|
|
auto spawn = Spawn::create(FadeIn::create(0.2f), act, nullptr);
|
|||
|
|
|
|||
|
|
m_ImageView->runAction(Sequence::create(spawn, CallFunc::create([&]()
|
|||
|
|
{
|
|||
|
|
LoadingScene::Instance().show(this);
|
|||
|
|
m_kGameRecordMission.GetGameRecordList(UserInfo::Instance().getUserID(), m_wKindID); // <20><>ȡ¼<C8A1><C2BC><EFBFBD>б<EFBFBD>;
|
|||
|
|
}), nullptr));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RecordScene::popScene()
|
|||
|
|
{
|
|||
|
|
float height = Director::getInstance()->getWinSize().height;
|
|||
|
|
|
|||
|
|
if (m_ImageTop)
|
|||
|
|
{
|
|||
|
|
float top_h = m_ImageTop->getContentSize().height;
|
|||
|
|
m_ImageTop->runAction(MoveBy::create(0.2f, Vec2(0, top_h)));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (m_ImageView)
|
|||
|
|
{
|
|||
|
|
float b_h = m_ImageView->getContentSize().height;
|
|||
|
|
|
|||
|
|
auto act = MoveBy::create(0.2f, Vec2(0, 0 - b_h / 2));
|
|||
|
|
auto spawn = Spawn::create(FadeOut::create(0.2f), act, nullptr);
|
|||
|
|
m_ImageView->runAction(Sequence::create(spawn, CallFunc::create([&]()
|
|||
|
|
{
|
|||
|
|
this->removeFromParent();
|
|||
|
|
}), nullptr));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//// <20><>ȡ<EFBFBD><C8A1>Ϣ;
|
|||
|
|
//void RecordScene::RequsetHttpInfo()
|
|||
|
|
//{
|
|||
|
|
// LoadingScene::Instance().show(this);
|
|||
|
|
// std::string strUrl = StringUtils::format("%s/Lobby/Ranking?t=%ld", WEB_SERVER_ADDRESS, time(NULL));
|
|||
|
|
// CWebReq::getInstance().sendRequestDocumentUrl(strUrl, CC_CALLBACK_1(RecordScene::ResponseResult, this), nullptr);
|
|||
|
|
//}
|
|||
|
|
//
|
|||
|
|
////<2F><><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|||
|
|
//void RecordScene::ResponseResult(rapidjson::Document* pDoc)
|
|||
|
|
//{
|
|||
|
|
// LoadingScene::Instance().hide();
|
|||
|
|
// if (pDoc == nullptr) return;
|
|||
|
|
// if (!pDoc->IsArray()) return;
|
|||
|
|
// m_VecRanks.clear();
|
|||
|
|
//
|
|||
|
|
// // <20><><EFBFBD><EFBFBD>;
|
|||
|
|
// for (rapidjson::SizeType i = 0; i < pDoc->Size(); ++i)
|
|||
|
|
// {
|
|||
|
|
// const rapidjson::Value &Newobj = (*pDoc)[i];
|
|||
|
|
// ASSERT(Newobj.IsObject());
|
|||
|
|
//
|
|||
|
|
// tagRankItem tmpitem = tagRankItem();
|
|||
|
|
// if (Newobj.HasMember("id") && Newobj["id"].IsInt())
|
|||
|
|
// {
|
|||
|
|
// tmpitem.dwUserID = Newobj["id"].GetInt();
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// if (Newobj.HasMember("nickname") && Newobj["nickname"].IsString())
|
|||
|
|
// {
|
|||
|
|
// tmpitem.strNickName = Newobj["nickname"].GetString();
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// if (Newobj.HasMember("record") && Newobj["record"].IsInt())
|
|||
|
|
// {
|
|||
|
|
// tmpitem.iRecord = Newobj["record"].GetInt();
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// m_VecRanks.push_back(tmpitem);
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// ShowRank();
|
|||
|
|
//}
|
|||
|
|
//
|
|||
|
|
//void RecordScene::ShowRank()
|
|||
|
|
//{
|
|||
|
|
// if (nullptr == m_pListView) return;
|
|||
|
|
// if (nullptr == m_RankItem) return;
|
|||
|
|
//
|
|||
|
|
// if (m_VecRanks.size() <= 0) return;
|
|||
|
|
//
|
|||
|
|
// m_pListView->removeAllChildren();
|
|||
|
|
//
|
|||
|
|
// static std::string strRanks[3] = {"common/Img/jin.png", "common/Img/yin.png", "common/Img/tong.png"};
|
|||
|
|
//
|
|||
|
|
// for (int i = 0; i < m_VecRanks.size(); i++)
|
|||
|
|
// {
|
|||
|
|
// Layout* tmpRankItem = (Layout*)m_RankItem->clone();
|
|||
|
|
// if (tmpRankItem == nullptr) continue;
|
|||
|
|
// tmpRankItem->setVisible(true);
|
|||
|
|
//
|
|||
|
|
// tagRankItem tmpItem = m_VecRanks[i];
|
|||
|
|
//
|
|||
|
|
// // <20><><EFBFBD><EFBFBD>;
|
|||
|
|
// auto ImgResult = (ImageView*)tmpRankItem->getChildByName("ImgResult");
|
|||
|
|
// auto txtIndex = (Text*)tmpRankItem->getChildByName("txtIndex");
|
|||
|
|
//
|
|||
|
|
// if (i < 3)
|
|||
|
|
// {
|
|||
|
|
// ImgResult->setVisible(true);
|
|||
|
|
// txtIndex->setVisible(false);
|
|||
|
|
// ImgResult->loadTexture(strRanks[i]);
|
|||
|
|
// txtIndex->setString(StringUtils::format("%d", i));
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// ImgResult->setVisible(false);
|
|||
|
|
// txtIndex->setVisible(true);
|
|||
|
|
// txtIndex->setString(StringUtils::format("%d", i));
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// // ͷ<><CDB7>;
|
|||
|
|
//
|
|||
|
|
// // <20>dz<EFBFBD>;
|
|||
|
|
// auto txtUserName = (Text*)tmpRankItem->getChildByName("txtUserName");
|
|||
|
|
// if (txtUserName) txtUserName->setString(tmpItem.strNickName);
|
|||
|
|
//
|
|||
|
|
// // ʤ<><CAA4>;
|
|||
|
|
// auto txtWinLv = (Text*)tmpRankItem->getChildByName("txtWinLv");
|
|||
|
|
// if (txtWinLv) txtWinLv->setString(StringUtils::format("%d", tmpItem.iRecord));
|
|||
|
|
//
|
|||
|
|
// m_pListView->pushBackCustomItem(tmpRankItem);
|
|||
|
|
// }
|
|||
|
|
//}
|