本文整理汇总了C++中PlayerProfile::isLoggedIn方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerProfile::isLoggedIn方法的具体用法?C++ PlayerProfile::isLoggedIn怎么用?C++ PlayerProfile::isLoggedIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerProfile
的用法示例。
在下文中一共展示了PlayerProfile::isLoggedIn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeEntryFieldsVisible
/** Make the entry fields either visible or invisible.
* \param online Online state, which dicates if the entry fields are
* visible (true) or not.
*/
void BaseUserScreen::makeEntryFieldsVisible()
{
#ifdef GUEST_ACCOUNTS_ENABLED
getWidget<LabelWidget>("label_guest")->setVisible(online);
getWidget<CheckBoxWidget>("guest")->setVisible(online);
#endif
bool online = m_online_cb->getState();
getWidget<LabelWidget>("label_username")->setVisible(online);
m_username_tb->setVisible(online);
getWidget<LabelWidget>("label_remember")->setVisible(online);
getWidget<CheckBoxWidget>("remember-user")->setVisible(online);
PlayerProfile *player = getSelectedPlayer();
// Don't show the password fields if the player wants to be online
// and either is the current player and logged in (no need to enter a
// password then) or has a saved session.
if(player && online &&
(player->hasSavedSession() ||
(player==PlayerManager::getCurrentPlayer() && player->isLoggedIn() )
)
)
{
// If we show the online login fields, but the player has a
// saved session, don't show the password field.
getWidget<LabelWidget>("label_password")->setVisible(false);
m_password_tb->setVisible(false);
}
else
{
getWidget<LabelWidget>("label_password")->setVisible(online);
m_password_tb->setVisible(online);
}
} // makeEntryFieldsVisible
示例2: eventCallback
void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == "options_choice")
{
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")
screen = TabbedUserScreen::getInstance();
else if (selection == "tab_controls")
screen = OptionsScreenInput::getInstance();
//else if (selection == "tab_ui")
// screen = OptionsScreenUI::getInstance();
if(screen)
StateManager::get()->replaceTopMostScreen(screen);
}
else if(name == "back")
{
StateManager::get()->escapePressed();
}
else if (name == "skinchoice")
{
GUIEngine::SpinnerWidget* skinSelector = getWidget<GUIEngine::SpinnerWidget>("skinchoice");
assert( skinSelector != NULL );
const core::stringw selectedSkin = skinSelector->getStringValue();
UserConfigParams::m_skin_file = core::stringc(selectedSkin.c_str()).c_str() + std::string(".stkskin");
GUIEngine::reloadSkin();
}
else if (name == "showfps")
{
CheckBoxWidget* fps = getWidget<CheckBoxWidget>("showfps");
assert( fps != NULL );
UserConfigParams::m_display_fps = fps->getState();
}
else if (name=="enable-internet")
{
CheckBoxWidget* internet = getWidget<CheckBoxWidget>("enable-internet");
assert( internet != NULL );
UserConfigParams::m_internet_status =
internet->getState() ? RequestManager::IPERM_ALLOWED
: RequestManager::IPERM_NOT_ALLOWED;
// If internet gets enabled, re-initialise the addon manager (which
// happens in a separate thread) so that news.xml etc can be
// downloaded if necessary.
CheckBoxWidget *stats = getWidget<CheckBoxWidget>("enable-hw-report");
LabelWidget *stats_label = getWidget<LabelWidget>("label-hw-report");
if(internet->getState())
{
NewsManager::get()->init(false);
stats->setVisible(true);
stats_label->setVisible(true);
stats->setState(UserConfigParams::m_hw_report_enable);
}
else
{
stats->setVisible(false);
stats_label->setVisible(false);
PlayerProfile* profile = PlayerManager::getCurrentPlayer();
if (profile != NULL && profile->isLoggedIn())
profile->requestSignOut();
}
}
else if (name=="enable-hw-report")
{
CheckBoxWidget* stats = getWidget<CheckBoxWidget>("enable-hw-report");
UserConfigParams::m_hw_report_enable = stats->getState();
if(stats->getState())
HardwareStats::reportHardwareStats();
}
else if (name=="show-login")
{
CheckBoxWidget* show_login = getWidget<CheckBoxWidget>("show-login");
assert( show_login != NULL );
UserConfigParams::m_always_show_login_screen = show_login->getState();
}
else if (name=="perPlayerDifficulty")
{
CheckBoxWidget* difficulty = getWidget<CheckBoxWidget>("perPlayerDifficulty");
assert( difficulty != NULL );
UserConfigParams::m_per_player_difficulty = difficulty->getState();
}
else if (name == "language")
{
ListWidget* list_widget = getWidget<ListWidget>("language");
std::string selection = list_widget->getSelectionInternalName();
delete translations;
if (selection == "system")
{
#ifdef WIN32
_putenv("LANGUAGE=");
#else
unsetenv("LANGUAGE");
#endif
//.........这里部分代码省略.........
示例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