背景和头像缺失

This commit is contained in:
2026-03-01 13:48:24 +08:00
parent 9ae4e8e614
commit eaaf7f8c9b
554 changed files with 1871 additions and 1718 deletions

View File

@@ -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);
}