本文整理汇总了C++中PlayerProfile::clearSession方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerProfile::clearSession方法的具体用法?C++ PlayerProfile::clearSession怎么用?C++ PlayerProfile::clearSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerProfile
的用法示例。
在下文中一共展示了PlayerProfile::clearSession方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logoutError
/** Callback from player profile if login was unsuccessful.
* \param error_message Contains the error message.
*/
void BaseUserScreen::logoutError(const irr::core::stringw & error_message)
{
m_state = (UserScreenState) (m_state & ~STATE_LOGOUT);
PlayerProfile *player = getSelectedPlayer();
// Clear information about saved session in case of a problem,
// which allows the player to enter a new password.
if(player && player->hasSavedSession())
player->clearSession();
makeEntryFieldsVisible();
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error_message, false);
m_options_widget->setActive(true);
} // logoutError
示例2: onUpdate
/** Called once every frame. It will replace this screen with the main menu
* screen if a successful login happened.
*/
void BaseUserScreen::onUpdate(float dt)
{
if (!m_options_widget->isActivated())
{
core::stringw message = (m_state & STATE_LOGOUT)
? _(L"Signing out '%s'",m_sign_out_name.c_str())
: _(L"Signing in '%s'", m_sign_in_name.c_str());
m_info_widget->setText(StringUtils::loadingDots(message.c_str()),
false );
}
PlayerProfile *player = getSelectedPlayer();
if(player)
{
// If the player changes the online name, clear the saved session
// flag, and make the password field visible again.
if (m_username_tb->getText()!=player->getLastOnlineName())
{
player->clearSession();
makeEntryFieldsVisible();
}
}
} // onUpdate
示例3: login
/** Called when OK or OK-and-save is clicked.
* This will trigger the actual login (if requested) etc.
* \param remember_me True if the login details should be remembered,
* so that next time this menu can be skipped.
*/
void BaseUserScreen::login()
{
// If an error occurs, the callback informing this screen about the
// problem will activate the widget again.
m_options_widget->setActive(false);
m_state = STATE_NONE;
PlayerProfile *player = getSelectedPlayer();
PlayerProfile *current = PlayerManager::getCurrentPlayer();
core::stringw new_username = m_username_tb->getText();
// If a different player is connecting, or the same local player with
// a different online account, log out the current player.
if(current && current->isLoggedIn() &&
(player!=current ||
current->getLastOnlineName(true/*ignoreRTL*/)!=new_username) )
{
m_sign_out_name = current->getLastOnlineName(true/*ignoreRTL*/);
current->requestSignOut();
m_state = (UserScreenState)(m_state | STATE_LOGOUT);
// If the online user name was changed, reset the save data
// for this user (otherwise later the saved session will be
// resumed, not logging the user with the new account).
if(player==current &&
current->getLastOnlineName(true/*ignoreRTL*/)!=new_username)
current->clearSession();
}
PlayerManager::get()->setCurrentPlayer(player);
assert(player);
// If no online login requested, log the player out (if necessary)
// and go to the main menu screen (though logout needs to finish first)
if(!m_online_cb->getState())
{
if(player->isLoggedIn())
{
m_sign_out_name =player->getLastOnlineName(true/*ignoreRTL*/);
player->requestSignOut();
m_state =(UserScreenState)(m_state| STATE_LOGOUT);
}
player->setWasOnlineLastTime(false);
if(m_state==STATE_NONE)
{
closeScreen();
}
return;
}
// Player wants to be online, and is already online - nothing to do
if(player->isLoggedIn())
{
player->setWasOnlineLastTime(true);
closeScreen();
return;
}
m_state = (UserScreenState) (m_state | STATE_LOGIN);
// Now we need to start a login request to the server
// This implies that this screen will wait till the server responds, so
// that error messages ('invalid password') can be shown, and the user
// can decide what to do about them.
if (player->hasSavedSession())
{
m_sign_in_name = player->getLastOnlineName(true/*ignoreRTL*/);
// Online login with saved token
player->requestSavedSession();
}
else
{
// Online login with password --> we need a valid password
if (m_password_tb->getText() == "")
{
m_info_widget->setText(_("You need to enter a password."), true);
SFXManager::get()->quickSound("anvil");
m_options_widget->setActive(true);
return;
}
m_sign_in_name = m_username_tb->getText();
player->requestSignIn(m_username_tb->getText(),
m_password_tb->getText());
} // !hasSavedSession
} // login