背景和头像缺失
This commit is contained in:
@@ -369,6 +369,7 @@ void GameUnionScene::popScene()
|
||||
EventCustom event(Get_Union_Room_List);
|
||||
|
||||
CMD_GR_GetUnionRoomInfo getUnionRoom;
|
||||
memset(&getUnionRoom, 0, sizeof(getUnionRoom));
|
||||
getUnionRoom.dwUserID = UserInfo::getInstance()->getUserID();
|
||||
getUnionRoom.dwUnionCode = m_dwSelectUnionCode;
|
||||
event.setUserData(&getUnionRoom);
|
||||
@@ -950,7 +951,7 @@ void GameUnionScene::startUnionRoomTime()
|
||||
|
||||
void GameUnionScene::RequsetUnionRoomList(bool isLoading /*= true*/)
|
||||
{
|
||||
if (this->isVisible() && m_RoomList->isVisible() && m_dwSelectUnionCode != 0)
|
||||
if (this->isVisible() && m_RoomList->isVisible() && m_dwSelectUnionCode > 0 && m_dwSelectUnionCode < 100000000)
|
||||
{
|
||||
// 连续三次刷新失败,强制刷新;
|
||||
if (m_isRefreshing && m_nRefreshErr < 3)
|
||||
@@ -965,6 +966,7 @@ void GameUnionScene::RequsetUnionRoomList(bool isLoading /*= true*/)
|
||||
EventCustom event(Get_Union_Room_List);
|
||||
|
||||
CMD_GR_GetUnionRoomInfo getUnionRoom;
|
||||
memset(&getUnionRoom, 0, sizeof(getUnionRoom));
|
||||
getUnionRoom.dwUserID = UserInfo::getInstance()->getUserID();
|
||||
getUnionRoom.dwUnionCode = m_dwSelectUnionCode;
|
||||
event.setUserData(&getUnionRoom);
|
||||
|
||||
@@ -7,14 +7,8 @@
|
||||
#include "GlobalJosn.h"
|
||||
#include "YvVoiceManager.hpp"
|
||||
#include "13S_GameLogic.h"
|
||||
#include "MD5.h"
|
||||
|
||||
LogonScene::LogonScene()
|
||||
: m_pPanelAccount(nullptr)
|
||||
, m_pTxtUsername(nullptr)
|
||||
, m_pTxtPassword(nullptr)
|
||||
, m_pBtnLogin(nullptr)
|
||||
, m_pBtnClose(nullptr)
|
||||
{
|
||||
m_kLoginMission.setUrl(GlobalJosn::getInstance()->m_strLogonIp.c_str(), GlobalJosn::getInstance()->m_iPort);
|
||||
|
||||
@@ -48,30 +42,6 @@ bool LogonScene::init()
|
||||
CC_ASSERT(btnWeiXinLogon != nullptr);
|
||||
|
||||
btnWeiXinLogon->addClickEventListener(CC_CALLBACK_1(LogonScene::onWeiXinLogon, this));
|
||||
// Account login entry button
|
||||
auto btnAccountLogin = (Button*)rootPanel->getChildByName("btnAccountLogin");
|
||||
if (btnAccountLogin)
|
||||
{
|
||||
btnAccountLogin->addClickEventListener(CC_CALLBACK_1(LogonScene::onShowAccountPanel, this));
|
||||
}
|
||||
|
||||
// Account login panel
|
||||
m_pPanelAccount = rootPanel->getChildByName("panelAccount");
|
||||
if (m_pPanelAccount)
|
||||
{
|
||||
m_pPanelAccount->setVisible(false);
|
||||
auto imgBg = m_pPanelAccount->getChildByName("imgBg");
|
||||
if (imgBg)
|
||||
{
|
||||
m_pTxtUsername = (TextField*)imgBg->getChildByName("txtUsername");
|
||||
m_pTxtPassword = (TextField*)imgBg->getChildByName("txtPassword");
|
||||
m_pBtnLogin = (Button*)imgBg->getChildByName("btnLogin");
|
||||
m_pBtnClose = (Button*)imgBg->getChildByName("btnClose");
|
||||
|
||||
if (m_pBtnLogin) m_pBtnLogin->addClickEventListener(CC_CALLBACK_1(LogonScene::onUsernameLogon, this));
|
||||
if (m_pBtnClose) m_pBtnClose->addClickEventListener(CC_CALLBACK_1(LogonScene::onHideAccountPanel, this));
|
||||
}
|
||||
}
|
||||
|
||||
//对手机返回键的监听
|
||||
auto keyListener = EventListenerKeyboard::create();
|
||||
@@ -169,22 +139,13 @@ void LogonScene::onGPLoginSuccess()
|
||||
UserDefault::getInstance()->setStringForKey("Password", m_kPssword);
|
||||
|
||||
// 更新微信最新信息;
|
||||
// Only update WeChat info for WeChat login (not username login)
|
||||
if (!m_kWeiXinUserInfo.openid.empty())
|
||||
{
|
||||
pGlobalUserData->cbGender = m_kWeiXinUserInfo.sex;
|
||||
strncpy(pGlobalUserData->szNickName, m_kWeiXinUserInfo.nickname.c_str(), LEN_NICKNAME - 1);
|
||||
strncpy(pGlobalUserData->szHeadHttp, m_kWeiXinUserInfo.headimgurl.c_str(), LEN_HEAD_HTTP - 1);
|
||||
pGlobalUserData->cbGender = m_kWeiXinUserInfo.sex;
|
||||
strncpy(pGlobalUserData->szNickName, m_kWeiXinUserInfo.nickname.c_str(), LEN_NICKNAME - 1);
|
||||
strncpy(pGlobalUserData->szHeadHttp, m_kWeiXinUserInfo.headimgurl.c_str(), LEN_HEAD_HTTP - 1);
|
||||
|
||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32
|
||||
UserInfo::Instance().modifyWeiXinInfo(m_kWeiXinUserInfo.sex, m_kWeiXinUserInfo.nickname, m_kWeiXinUserInfo.headimgurl);
|
||||
UserInfo::Instance().modifyWeiXinInfo(m_kWeiXinUserInfo.sex, m_kWeiXinUserInfo.nickname, m_kWeiXinUserInfo.headimgurl);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// Username login: clear head URL to use default avatar
|
||||
pGlobalUserData->szHeadHttp[0] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +159,7 @@ void LogonScene::onGPLoginComplete()
|
||||
|
||||
void LogonScene::onGPLoginFailure(unsigned int iErrorCode,const char* szDescription)
|
||||
{
|
||||
// Only auto-register for WeChat login, show error for username login
|
||||
if ((iErrorCode == 3 || iErrorCode == 1) && !m_kWeiXinUserInfo.openid.empty())
|
||||
if (iErrorCode == 3 || iErrorCode == 1)
|
||||
{
|
||||
RegisterAccount();
|
||||
}
|
||||
@@ -379,81 +339,4 @@ void LogonScene::ResponseResult(rapidjson::Document* pDoc)
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
//==================================================
|
||||
// Username/Password Login
|
||||
//==================================================
|
||||
|
||||
void LogonScene::onShowAccountPanel(Ref*)
|
||||
{
|
||||
YSAudioEngine::Instance().playBtnClickEffect();
|
||||
if (m_pPanelAccount)
|
||||
{
|
||||
m_pPanelAccount->setVisible(true);
|
||||
if (m_pTxtUsername) m_pTxtUsername->setString("");
|
||||
if (m_pTxtPassword) m_pTxtPassword->setString("");
|
||||
}
|
||||
}
|
||||
|
||||
void LogonScene::onHideAccountPanel(Ref*)
|
||||
{
|
||||
YSAudioEngine::Instance().playBtnClickEffect();
|
||||
if (m_pPanelAccount)
|
||||
{
|
||||
m_pPanelAccount->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void LogonScene::onUsernameLogon(Ref*)
|
||||
{
|
||||
YSAudioEngine::Instance().playBtnClickEffect();
|
||||
|
||||
std::string strUsername = "";
|
||||
std::string strPassword = "";
|
||||
if (m_pTxtUsername) strUsername = m_pTxtUsername->getString();
|
||||
if (m_pTxtPassword) strPassword = m_pTxtPassword->getString();
|
||||
|
||||
// Input validation
|
||||
if (strUsername.empty())
|
||||
{
|
||||
PopScene::Instance().show(utility::a_u8("请输入用户名"));
|
||||
return;
|
||||
}
|
||||
if (strPassword.empty())
|
||||
{
|
||||
PopScene::Instance().show(utility::a_u8("请输入密码"));
|
||||
return;
|
||||
}
|
||||
if (strUsername.length() < 4)
|
||||
{
|
||||
PopScene::Instance().show(utility::a_u8("用户名至少4个字符"));
|
||||
return;
|
||||
}
|
||||
if (strPassword.length() < 6)
|
||||
{
|
||||
PopScene::Instance().show(utility::a_u8("密码至少6个字符"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pPanelAccount) m_pPanelAccount->setVisible(false);
|
||||
LoadingScene::Instance().show(this);
|
||||
|
||||
// MD5 encrypt password
|
||||
m_kPssword = md5(strPassword);
|
||||
|
||||
// Clear WeChat info (mark as username login)
|
||||
m_kWeiXinUserInfo = WxUserInfo();
|
||||
|
||||
// Build login packet
|
||||
CMD_GP_LogonAccounts loginAccount;
|
||||
zeromemory(&loginAccount, sizeof(loginAccount));
|
||||
loginAccount.dwPlazaVersion = Helps::Instance()->GetPlazaVersion();
|
||||
loginAccount.cbValidateFlags = MB_VALIDATE_FLAGS | LOW_VER_VALIDATE_FLAGS;
|
||||
strcpy(loginAccount.szAccounts, strUsername.c_str());
|
||||
strcpy(loginAccount.szPassword, m_kPssword.c_str());
|
||||
loginAccount.szOpenId[0] = '\0';
|
||||
loginAccount.szUnionid[0] = '\0';
|
||||
|
||||
cocos2d::log("Username Login: account=%s", loginAccount.szAccounts);
|
||||
m_kLoginMission.loginAccount(loginAccount);
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
#include "cocos2d.h"
|
||||
#include "cocostudio/CocoStudio.h"
|
||||
#include "ui/CocosGUI.h"
|
||||
#include "MD5.h"
|
||||
|
||||
#include "MissionWeiXin.h"
|
||||
#include "LoginMission.h"
|
||||
@@ -53,21 +51,10 @@ public:
|
||||
//请求版本信息结果
|
||||
void ResponseResult(rapidjson::Document* pDoc);
|
||||
|
||||
// Username login
|
||||
void onShowAccountPanel(Ref*);
|
||||
void onHideAccountPanel(Ref*);
|
||||
void onUsernameLogon(Ref*);
|
||||
|
||||
private:
|
||||
LoginMission m_kLoginMission;
|
||||
std::string m_kPssword;
|
||||
|
||||
WxUserInfo m_kWeiXinUserInfo;
|
||||
|
||||
// Account login UI
|
||||
Node* m_pPanelAccount;
|
||||
cocos2d::ui::TextField* m_pTxtUsername;
|
||||
cocos2d::ui::TextField* m_pTxtPassword;
|
||||
cocos2d::ui::Button* m_pBtnLogin;
|
||||
cocos2d::ui::Button* m_pBtnClose;
|
||||
};
|
||||
@@ -372,7 +372,7 @@ void MainScene::startUnionRoomTime()
|
||||
|
||||
void MainScene::RequsetUnionRoomList(bool isLoading /*= true*/)
|
||||
{
|
||||
if (this->isVisible() && m_PanelRoom->isVisible() && m_dwSelectUnionCode != 0)
|
||||
if (this->isVisible() && m_PanelRoom->isVisible() && m_dwSelectUnionCode > 0 && m_dwSelectUnionCode < 100000000)
|
||||
{
|
||||
// 连续三次刷新失败,强制刷新;
|
||||
if (m_isRefreshing && m_nRefreshErr < 3)
|
||||
@@ -387,6 +387,7 @@ void MainScene::RequsetUnionRoomList(bool isLoading /*= true*/)
|
||||
}
|
||||
|
||||
CMD_GR_GetUnionRoomInfo getUnionRoom;
|
||||
memset(&getUnionRoom, 0, sizeof(getUnionRoom)); // 添加这行
|
||||
getUnionRoom.dwUserID = UserInfo::getInstance()->getUserID();
|
||||
getUnionRoom.dwUnionCode = m_dwSelectUnionCode;
|
||||
m_kUserInGameServer.PerformGetUnionRoomList(&getUnionRoom);
|
||||
@@ -399,26 +400,45 @@ void MainScene::RequsetUnionRoomList(bool isLoading /*= true*/)
|
||||
// 显示工会列表;
|
||||
void MainScene::ShowUnionList(tagUnionAndGameList* pUnionAndGameList)
|
||||
{
|
||||
if (m_UnionList == nullptr) return;
|
||||
if (pUnionAndGameList == nullptr) return;
|
||||
utility::mlog("ShowUnionList: called");
|
||||
utility::mlog("ShowUnionList: m_UnionList=%p, m_PanelRoom=%p", m_UnionList, m_PanelRoom);
|
||||
|
||||
if (m_UnionList == nullptr) {
|
||||
utility::mlog("ShowUnionList: m_UnionList is NULL, return!");
|
||||
return;
|
||||
}
|
||||
if (pUnionAndGameList == nullptr) {
|
||||
utility::mlog("ShowUnionList: pUnionAndGameList is NULL, return!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_UnionList->removeAllChildren();
|
||||
|
||||
int iUnionCount = pUnionAndGameList->kUnionList.size();
|
||||
utility::mlog("ShowUnionList: iUnionCount=%d", iUnionCount);
|
||||
|
||||
// 玩家没有工会;
|
||||
if (iUnionCount <= 0)
|
||||
{
|
||||
utility::mlog("ShowUnionList: no unions, hiding panel");
|
||||
m_PanelRoom->setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
utility::mlog("ShowUnionList: showing panel, creating union buttons...");
|
||||
m_PanelRoom->setVisible(true);
|
||||
|
||||
// 获取上次选择的工会;
|
||||
std::string strUnionCode = StringUtils::format("UnionCode_%d", UserInfo::Instance().getGameID());
|
||||
m_dwSelectUnionCode = UserDefault::getInstance()->getIntegerForKey(strUnionCode.c_str(), 0);
|
||||
|
||||
// 校验:过滤无效的工会代码
|
||||
if (m_dwSelectUnionCode < 0 || m_dwSelectUnionCode > 100000000)
|
||||
{
|
||||
utility::mlog("ShowUnionList: invalid m_dwSelectUnionCode=%d, reset to 0", m_dwSelectUnionCode);
|
||||
m_dwSelectUnionCode = 0;
|
||||
UserDefault::getInstance()->setIntegerForKey(strUnionCode.c_str(), 0);
|
||||
}
|
||||
|
||||
uint32 dwMeUserID = CGlobalUserInfo::GetInstance()->getUserID();
|
||||
|
||||
// 列表调整;
|
||||
@@ -434,6 +454,17 @@ void MainScene::ShowUnionList(tagUnionAndGameList* pUnionAndGameList)
|
||||
{
|
||||
tagUnionItem* pUnionItem = &pUnionAndGameList->kUnionList[i];
|
||||
|
||||
// 添加日志
|
||||
utility::mlog("UnionItem[%d]: UserID=%d, Code=%d, GoldOpen=%d, Open=%d, People=%d, Card=%d, Name=%s",
|
||||
i,
|
||||
pUnionItem->dwUserID,
|
||||
pUnionItem->dwUnionCode,
|
||||
pUnionItem->cbUnionGoldOpen,
|
||||
pUnionItem->cbUnionOpen,
|
||||
pUnionItem->lPeople,
|
||||
pUnionItem->lUnionCard,
|
||||
pUnionItem->szUnionName);
|
||||
|
||||
DWORD dwUnionCode = pUnionItem->dwUnionCode;
|
||||
BYTE cbUnionGoldOpen = pUnionItem->cbUnionGoldOpen;
|
||||
|
||||
@@ -488,6 +519,8 @@ void MainScene::ShowUnionList(tagUnionAndGameList* pUnionAndGameList)
|
||||
btnUnionItem->setVisible(true);
|
||||
m_UnionList->addChild(btnUnionItem);
|
||||
}
|
||||
// 在 for 循环结束后添加:
|
||||
utility::mlog("ShowUnionList: added %d union buttons", iUnionCount);
|
||||
|
||||
// 加载房间;
|
||||
if (m_dwSelectUnionCode != 0 && !m_isRefreshing)
|
||||
@@ -510,6 +543,8 @@ void MainScene::ShowUnionList(tagUnionAndGameList* pUnionAndGameList)
|
||||
m_btnBackUnion->setVisible(false);
|
||||
m_btnRefresh->setVisible(false);
|
||||
}
|
||||
// 在函数最后添加:
|
||||
utility::mlog("ShowUnionList: m_dwSelectUnionCode=%d, m_isRefreshing=%d", m_dwSelectUnionCode, m_isRefreshing);
|
||||
}
|
||||
|
||||
// 房间列表;
|
||||
@@ -680,7 +715,7 @@ void MainScene::showUnionRoomList(tagRoomItemList *pRoomItemList)
|
||||
std::string strText = StringUtils::format("%s, %s.", strRoomInfo.c_str(), strGameRule.c_str());
|
||||
std::string strUrl = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_WEIXIN_URL);
|
||||
std::string strUrlInfo = StringUtils::format("%s?param=%d", strUrl.c_str(), dwRoomID);
|
||||
MissionWeiXin::Instance().shareUrlWeiXin(strUrlInfo, utility::a_u8(strGameName), strText);
|
||||
MissionWeiXin::Instance().shareUrlWeiXin(strUrlInfo, strGameName, strText);
|
||||
|
||||
//SelectShareScene::Instance().shareRoomInfo(strUrlInfo, utility::a_u8(strGameName), strText, 0);
|
||||
});
|
||||
@@ -806,7 +841,7 @@ void MainScene::upPlayerInfo()
|
||||
//玩家账号
|
||||
auto txtUserName = (Text*)panelUser->getChildByName("txtUserName");
|
||||
CC_ASSERT(txtUserName != nullptr);
|
||||
txtUserName->setString(UserInfo::Instance().getUserNicName());
|
||||
txtUserName->setString(utility::a_u8(UserInfo::Instance().getUserNicName()));
|
||||
|
||||
//房卡
|
||||
auto txtDiamond = (Text*)panelUser->getChildByName("txtDiamond");
|
||||
@@ -1256,8 +1291,16 @@ void MainScene::onUserInUnion(CMD_GP_InUnion* pNetInfo)
|
||||
|
||||
void MainScene::onUnionAndGameInfo(tagUnionAndGameList *pUnionAndGameList)
|
||||
{
|
||||
// 添加日志
|
||||
utility::mlog("onUnionAndGameInfo: pUnionAndGameList=%p", pUnionAndGameList);
|
||||
if (pUnionAndGameList != nullptr) {
|
||||
utility::mlog("onUnionAndGameInfo: UnionCount=%d", pUnionAndGameList->kUnionList.size());
|
||||
}
|
||||
|
||||
if (pUnionAndGameList == nullptr) return;
|
||||
|
||||
utility::mlog("onUnionAndGameInfo: m_GameUnionNode=%p", m_GameUnionNode);
|
||||
|
||||
if (m_GameUnionNode != nullptr)
|
||||
{
|
||||
m_GameUnionNode->ShowUnionList(pUnionAndGameList);
|
||||
|
||||
@@ -398,7 +398,7 @@ void RecordScene::onGPBackGameTotalRecord(tagPrivateRandTotalRecord* pNetInfo)
|
||||
std::string strMsg = StringUtils::format("欣赏一下我的战绩吧,分享码: %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));
|
||||
MissionWeiXin::Instance().shareUrlWeiXin(strUrl, strTitle, strMsg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ bool SelectShareScene::init()
|
||||
}
|
||||
else
|
||||
{
|
||||
MissionWeiXin::Instance().shareUrlWeiXin(m_ShareItem.strkUrl, m_ShareItem.strkTitle, utility::a_u8(m_ShareItem.strkDesc));
|
||||
MissionWeiXin::Instance().shareUrlWeiXin(m_ShareItem.strkUrl, m_ShareItem.strkTitle, m_ShareItem.strkDesc);
|
||||
this->removeFromParent();
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ bool SelectShareScene::init()
|
||||
}
|
||||
else
|
||||
{
|
||||
MissionWeiXin::Instance().shareUrlXL(m_ShareItem.strkUrl, m_ShareItem.strkTitle, utility::a_u8(m_ShareItem.strkDesc));
|
||||
MissionWeiXin::Instance().shareUrlXL(m_ShareItem.strkUrl, m_ShareItem.strkTitle, m_ShareItem.strkDesc);
|
||||
this->removeFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user