105 lines
1.9 KiB
C++
105 lines
1.9 KiB
C++
|
|
#include "IpTipScene.h"
|
|||
|
|
#include "Define.h"
|
|||
|
|
#include "ImagicDownManager.h"
|
|||
|
|
|
|||
|
|
SINGLETON_STORAGE(IpTipScene);
|
|||
|
|
|
|||
|
|
IpTipScene::IpTipScene()
|
|||
|
|
{
|
|||
|
|
init();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
IpTipScene::~IpTipScene()
|
|||
|
|
{
|
|||
|
|
m_vecNickName.clear();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool IpTipScene::init()
|
|||
|
|
{
|
|||
|
|
if (!Node::init())
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
auto rootPanel = CSLoader::createNodeWithVisibleSize("Platform/IpTipScene.csb");
|
|||
|
|
CC_ASSERT(rootPanel != nullptr);
|
|||
|
|
this->addChild(rootPanel);
|
|||
|
|
|
|||
|
|
m_ImageViewBg = (ImageView*)rootPanel->getChildByName("Image_bg");
|
|||
|
|
CC_ASSERT(m_ImageViewBg);
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>ı<EFBFBD>
|
|||
|
|
for (int i = 0; i < IP_TABLE_PLAYER_COUNT; i++)
|
|||
|
|
{
|
|||
|
|
auto txtTip = (Text*)m_ImageViewBg->getChildByName(StringUtils::format("txtip_%d", i));
|
|||
|
|
CC_ASSERT(txtTip != nullptr);
|
|||
|
|
txtTip->setVisible(false);
|
|||
|
|
|
|||
|
|
m_vecNickName.push_back(txtTip);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void IpTipScene::show(std::string aryNames[], std::string aryIps[], BYTE cbCount)
|
|||
|
|
{
|
|||
|
|
if (getParent() == nullptr)
|
|||
|
|
{
|
|||
|
|
Scene* pScene = Director::getInstance()->getRunningScene();
|
|||
|
|
pScene->addChild(this);
|
|||
|
|
this->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>ı<EFBFBD>
|
|||
|
|
for (int i = 0; i < m_vecNickName.size(); i++)
|
|||
|
|
{
|
|||
|
|
auto txtTip = (Text*)m_vecNickName[i];
|
|||
|
|
if (txtTip)
|
|||
|
|
{
|
|||
|
|
txtTip->setVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|||
|
|
for (int i = 0; i < cbCount; i++)
|
|||
|
|
{
|
|||
|
|
auto txtTip = (Text*)m_vecNickName[i];
|
|||
|
|
if (txtTip && aryIps[i].size() > 0)
|
|||
|
|
{
|
|||
|
|
std::string strTip = StringUtils::format("%s: %s", aryNames[i].c_str(), aryIps[i].c_str());
|
|||
|
|
txtTip->setString(utility::a_u8(strTip));
|
|||
|
|
txtTip->setVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pushScene();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void IpTipScene::pushScene()
|
|||
|
|
{
|
|||
|
|
if (m_ImageViewBg)
|
|||
|
|
{
|
|||
|
|
this->setVisible(true);
|
|||
|
|
m_ImageViewBg->runAction(FadeIn::create(0.2f));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void IpTipScene::hide()
|
|||
|
|
{
|
|||
|
|
if (this->isVisible())
|
|||
|
|
{
|
|||
|
|
if (m_ImageViewBg)
|
|||
|
|
{
|
|||
|
|
this->setVisible(true);
|
|||
|
|
m_ImageViewBg->setScale(0.8f);
|
|||
|
|
|
|||
|
|
m_ImageViewBg->runAction(Sequence::create(DelayTime::create(5.f), FadeOut::create(1.2f), CallFunc::create([=]{
|
|||
|
|
this->setVisible(false);
|
|||
|
|
}), nullptr));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->setVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|