112 lines
3.2 KiB
C++
112 lines
3.2 KiB
C++
|
|
#include "cocostudio/CocoStudio.h"
|
||
|
|
#include "ZJH_OpenResultItem.h"
|
||
|
|
#include "ImagicDownManager.h"
|
||
|
|
|
||
|
|
using namespace cocostudio;
|
||
|
|
|
||
|
|
ZJHOpenResultItem::ZJHOpenResultItem()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
ZJHOpenResultItem::~ZJHOpenResultItem()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
bool ZJHOpenResultItem::init()
|
||
|
|
{
|
||
|
|
if (!Node::init())
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
//加载界面数据;
|
||
|
|
auto rootNode = CSLoader::createNode("Games/ZJH/OpenResultItem.csb");
|
||
|
|
addChild(rootNode);
|
||
|
|
|
||
|
|
setContentSize(rootNode->getContentSize());
|
||
|
|
|
||
|
|
//绑定界面元素;
|
||
|
|
_MainPanel = static_cast<ImageView*>(rootNode->getChildByName("imgBg"));
|
||
|
|
CC_ASSERT(_MainPanel != nullptr);
|
||
|
|
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
void ZJHOpenResultItem::initUIData(tagZJHOpenResultItem* pItem, bool bUnionGoldOpen)
|
||
|
|
{
|
||
|
|
CC_ASSERT(pItem!=nullptr);
|
||
|
|
|
||
|
|
//头像;
|
||
|
|
Sprite* sprHead = static_cast<Sprite*>(_MainPanel->getChildByName("imgUserHead"));
|
||
|
|
CC_ASSERT(sprHead!=nullptr);
|
||
|
|
if (sprHead)
|
||
|
|
{
|
||
|
|
ImagicDownManager::Instance().addDown(sprHead, pItem->szHttpHead, pItem->dwGameID);
|
||
|
|
}
|
||
|
|
|
||
|
|
//房主标志;
|
||
|
|
ImageView* imgOwner = static_cast<ImageView*>(_MainPanel->getChildByName("imgOwner"));
|
||
|
|
CC_ASSERT(imgOwner != nullptr);
|
||
|
|
imgOwner->setVisible(pItem->bOwner);
|
||
|
|
|
||
|
|
//昵称显示;
|
||
|
|
Text* txtNickName = static_cast<Text*>(_MainPanel->getChildByName("txtNickName"));
|
||
|
|
CC_ASSERT(txtNickName != nullptr);
|
||
|
|
txtNickName->setString(pItem->szNickName);
|
||
|
|
|
||
|
|
//玩家标识显示;
|
||
|
|
Text* txtUserID = static_cast<Text*>(_MainPanel->getChildByName("txtUserId"));
|
||
|
|
CC_ASSERT(txtUserID != nullptr);
|
||
|
|
txtUserID->setString(StringUtils::format("ID:%d", pItem->dwGameID));
|
||
|
|
|
||
|
|
TextAtlas* txtResultScore = static_cast<TextAtlas*>(_MainPanel->getChildByName("txtTotalScore"));
|
||
|
|
CC_ASSERT(txtResultScore != nullptr);
|
||
|
|
|
||
|
|
Sprite* imgResultIcon = static_cast<Sprite*>(_MainPanel->getChildByName("imgBigWinner"));
|
||
|
|
imgResultIcon->setVisible(pItem->bBigWinner);
|
||
|
|
|
||
|
|
SCORE lGameScore = pItem->lTotalScore;
|
||
|
|
if (lGameScore >= 0)
|
||
|
|
{
|
||
|
|
txtResultScore->setProperty(StringUtils::format(".%d", lGameScore), "Games/ZJH/Result/num_win.png", 38, 55, ".");
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
txtResultScore->setProperty(StringUtils::format("/%d", std::abs(lGameScore)), "Games/ZJH/Result/num_loss.png", 38, 55, ".");
|
||
|
|
}
|
||
|
|
|
||
|
|
Text* txtWinScore = static_cast<Text*>(_MainPanel->getChildByName("txtWinScore"));
|
||
|
|
txtWinScore->setString(StringUtils::format("%d", pItem->lWinScore));
|
||
|
|
|
||
|
|
Text* txtXiScore = static_cast<Text*>(_MainPanel->getChildByName("txtXiScore"));
|
||
|
|
txtXiScore->setString(StringUtils::format("%d", pItem->lXiScore));
|
||
|
|
|
||
|
|
// 欢乐积分;
|
||
|
|
TextAtlas* txtUnionScore = static_cast<TextAtlas*>(_MainPanel->getChildByName("txtUnionScore"));
|
||
|
|
CC_ASSERT(txtUnionScore != nullptr);
|
||
|
|
|
||
|
|
Text* txtAllUnionScore = static_cast<Text*>(_MainPanel->getChildByName("txtAllUnionScore"));
|
||
|
|
CC_ASSERT(txtAllUnionScore != nullptr);
|
||
|
|
|
||
|
|
if (bUnionGoldOpen)
|
||
|
|
{
|
||
|
|
SCORE lUnionScore = pItem->lUnionScore;
|
||
|
|
if (lGameScore >= 0)
|
||
|
|
{
|
||
|
|
txtUnionScore->setProperty(StringUtils::format(".%d", lUnionScore), "Games/ZJH/Result/num_win.png", 38, 55, ".");
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
txtUnionScore->setProperty(StringUtils::format("/%d", std::abs(lUnionScore)), "Games/ZJH/Result/num_loss.png", 38, 55, ".");
|
||
|
|
}
|
||
|
|
|
||
|
|
txtAllUnionScore->setString(StringUtils::format("%d", pItem->lAllUnionScore));
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
txtUnionScore->setVisible(false);
|
||
|
|
txtAllUnionScore->setVisible(false);
|
||
|
|
}
|
||
|
|
}
|