本文整理汇总了C++中CheckBoxWidget类的典型用法代码示例。如果您正苦于以下问题:C++ CheckBoxWidget类的具体用法?C++ CheckBoxWidget怎么用?C++ CheckBoxWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CheckBoxWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// -----------------------------------------------------------------------------
void SoccerSetupScreen::init()
{
m_schedule_continue = false;
Screen::init();
// TODO: remember in config.xml the last number of goals
if (UserConfigParams::m_soccer_time_limit <= 0)
UserConfigParams::m_soccer_time_limit = 3;
SpinnerWidget* goalamount = getWidget<SpinnerWidget>("goalamount");
goalamount->setValue(3);
goalamount->setActivated();
SpinnerWidget* timeAmount = getWidget<SpinnerWidget>("timeamount");
timeAmount->setValue(UserConfigParams::m_soccer_time_limit);
timeAmount->setDeactivated();
CheckBoxWidget* timeEnabled = getWidget<CheckBoxWidget>("time_enabled");
timeEnabled->setState(false);
// Set focus on "continue"
ButtonWidget* bt_continue = getWidget<ButtonWidget>("continue");
bt_continue->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
// We need players to be able to choose their teams
input_manager->setMasterPlayerOnly(false);
} // init
示例2: init
// -----------------------------------------------------------------------------
void SoccerSetupScreen::init()
{
m_schedule_continue = false;
Screen::init();
if (UserConfigParams::m_num_goals <= 0)
UserConfigParams::m_num_goals = 3;
if (UserConfigParams::m_soccer_time_limit <= 0)
UserConfigParams::m_soccer_time_limit = 3;
SpinnerWidget* goalamount = getWidget<SpinnerWidget>("goalamount");
goalamount->setValue(UserConfigParams::m_num_goals);
goalamount->setActive(!UserConfigParams::m_soccer_use_time_limit);
SpinnerWidget* timeAmount = getWidget<SpinnerWidget>("timeamount");
timeAmount->setValue(UserConfigParams::m_soccer_time_limit);
timeAmount->setActive(UserConfigParams::m_soccer_use_time_limit);
CheckBoxWidget* timeEnabled = getWidget<CheckBoxWidget>("time_enabled");
timeEnabled->setState(UserConfigParams::m_soccer_use_time_limit);
// Set focus on "continue"
ButtonWidget* bt_continue = getWidget<ButtonWidget>("continue");
bt_continue->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
// We need players to be able to choose their teams
input_manager->setMasterPlayerOnly(false);
// This flag will cause that a 'fire' event will be mapped to 'select' (if
// 'fire' is not assigned to a GUI event). This is done to support the old
// way of player joining by pressing 'fire' instead of 'select'.
input_manager->getDeviceManager()->mapFireToSelect(true);
} // init
示例3: _
void OptionsScreenAudio::init()
{
Screen::init();
RibbonWidget* ribbon = this->getWidget<RibbonWidget>("options_choice");
if (ribbon != NULL) ribbon->select( "tab_audio", PLAYER_ID_GAME_MASTER );
ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") );
ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") );
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
// ---- sfx volume
SpinnerWidget* gauge = this->getWidget<SpinnerWidget>("sfx_volume");
assert(gauge != NULL);
gauge->setValue( (int)(sfx_manager->getMasterSFXVolume()*10.0f) );
gauge = this->getWidget<SpinnerWidget>("music_volume");
assert(gauge != NULL);
gauge->setValue( (int)(music_manager->getMasterMusicVolume()*10.f) );
// ---- music volume
CheckBoxWidget* sfx = this->getWidget<CheckBoxWidget>("sfx_enabled");
CheckBoxWidget* music = this->getWidget<CheckBoxWidget>("music_enabled");
// ---- audio enables/disables
sfx->setState( UserConfigParams::m_sfx );
music->setState( UserConfigParams::m_music );
} // init
示例4: if
// ----------------------------------------------------------------------------
void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if(m_schedule_continue)
return;
if(name == "continue")
{
int nb_players = (int)m_kart_view_info.size();
if(!areAllKartsConfirmed())
{
for(int i=0 ; i < nb_players ; i++)
{
if (!m_kart_view_info[i].confirmed)
{
m_kart_view_info[i].confirmed = true;
m_kart_view_info[i].view->setRotateTo( KART_CONFIRMATION_TARGET_ANGLE, KART_CONFIRMATION_ROTATION_SPEED );
m_kart_view_info[i].view->setBadge(OK_BADGE);
}
}
SFXManager::get()->quickSound( "wee" );
m_schedule_continue = true;
}
else
{
m_schedule_continue = true;
}
}
else if (name == "back")
{
StateManager::get()->escapePressed();
}
else if(name == "time_enabled")
{
CheckBoxWidget* timeEnabled = dynamic_cast<CheckBoxWidget*>(widget);
bool timed = timeEnabled->getState();
UserConfigParams::m_soccer_use_time_limit = timed;
getWidget<SpinnerWidget>("goalamount")->setActive(!timed);
getWidget<SpinnerWidget>("timeamount")->setActive(timed);
}
else if (name == "red_team")
{
if (m_kart_view_info.size() == 1)
{
changeTeam(0, SOCCER_TEAM_RED);
}
}
else if (name == "blue_team")
{
if (m_kart_view_info.size() == 1)
{
changeTeam(0, SOCCER_TEAM_BLUE);
}
}
} // eventCallback
示例5: if
void StoryModeLobbyScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == "back")
{
StateManager::get()->escapePressed();
}
else if (name == "creategame")
{
new EnterPlayerNameDialog(this, 0.5f, 0.4f);
}
else if (name == "gameslots")
{
ListWidget* list = getWidget<ListWidget>("gameslots");
bool slot_found = false;
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
for (int n=0; n<players.size(); n++)
{
if (list->getSelectionLabel() == players[n].getName())
{
unlock_manager->setCurrentSlot(players[n].getUniqueID());
unlock_manager->updateActiveChallengeList();
slot_found = true;
break;
}
}
if (!slot_found)
{
fprintf(stderr, "[StoryModeLobbyScreen] ERROR: cannot find player corresponding to slot '%s'\n",
core::stringc(list->getSelectionLabel().c_str()).c_str());
}
else
{
CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
if (cb->getState())
{
UserConfigParams::m_default_player = list->getSelectionLabel();
}
}
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
}
} // eventCallback
示例6: assert
// -----------------------------------------------------------------------------
void EditTrackScreen::selectTrack(const std::string& id)
{
DynamicRibbonWidget* tracks = getWidget<DynamicRibbonWidget>("tracks");
assert(tracks != NULL);
LabelWidget* selected_track = getWidget<LabelWidget>("selected_track");
assert(selected_track != NULL);
SpinnerWidget* laps = getWidget<SpinnerWidget>("laps");
assert(laps != NULL);
LabelWidget* label_reverse = getWidget<LabelWidget>("reverse_label");
assert(label_reverse != NULL);
CheckBoxWidget* reverse = getWidget<CheckBoxWidget>("reverse");
assert(reverse != NULL);
ButtonWidget* ok_button = getWidget<ButtonWidget>("ok");
assert(ok_button != NULL);
m_track = track_manager->getTrack(id);
if (m_track != NULL)
{
tracks->setSelection(m_track->getIdent(), PLAYER_ID_GAME_MASTER, true);
selected_track->setText(m_track->getName(), true);
laps->setValue(m_laps);
reverse->setVisible(m_track->reverseAvailable());
label_reverse->setVisible(m_track->reverseAvailable());
ok_button->setActivated();
}
else
{
tracks->setSelection("", PLAYER_ID_GAME_MASTER, true);
selected_track->setText(_("Select a track"), true);
// We can't set a better default for number of laps. On the other
// hand, if a track is selected, the number of laps will be updated.
laps->setValue(3);
reverse->setVisible(true);
reverse->setState(false);
ok_button->setDeactivated();
}
}
示例7: init
void StoryModeLobbyScreen::init()
{
Screen::init();
CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
cb->setState(false);
ListWidget* list = getWidget<ListWidget>("gameslots");
list->clear();
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
if (UserConfigParams::m_default_player.toString().size() > 0)
{
for (int n=0; n<players.size(); n++)
{
if (players[n].getName() == UserConfigParams::m_default_player.toString())
{
unlock_manager->setCurrentSlot(players[n].getUniqueID());
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
return;
}
}
}
for (int n=0; n<players.size(); n++)
{
if (players[n].isGuestAccount()) continue;
// FIXME: we're using a trunacted ascii version of the player name as
// identifier, let's hope this causes no issues...
list->addItem(core::stringc(players[n].getName().c_str()).c_str(),
players[n].getName() );
}
list->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
list->setSelectionID(0);
} // init
示例8: if
// -----------------------------------------------------------------------------
void EditTrackScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name,
const int playerID)
{
if (name == "ok")
{
m_result = true;
StateManager::get()->popMenu();
}
else if (name == "cancel")
{
m_result = false;
StateManager::get()->popMenu();
}
else if (name == "tracks")
{
DynamicRibbonWidget* tracks = getWidget<DynamicRibbonWidget>("tracks");
assert(tracks != NULL);
selectTrack(tracks->getSelectionIDString(PLAYER_ID_GAME_MASTER));
}
else if (name == "trackgroups")
{
RibbonWidget* tabs = getWidget<RibbonWidget>("trackgroups");
assert(tabs != NULL);
m_track_group = tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER);
loadTrackList();
}
else if (name == "laps")
{
SpinnerWidget* laps = getWidget<SpinnerWidget>("laps");
assert(laps != NULL);
m_laps = laps->getValue();
}
else if (name == "reverse")
{
CheckBoxWidget* reverse = getWidget<CheckBoxWidget>("reverse");
assert(reverse != NULL);
m_reverse = reverse->getState();
}
}
示例9: if
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).c_str();
if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance());
else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance());
else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
}
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* news = getWidget<CheckBoxWidget>("enable-internet");
assert( news != NULL );
if(INetworkHttp::get())
{
INetworkHttp::get()->stopNetworkThread();
INetworkHttp::destroy();
}
UserConfigParams::m_internet_status =
news->getState() ? INetworkHttp::IPERM_ALLOWED
: INetworkHttp::IPERM_NOT_ALLOWED;
INetworkHttp::create();
// Note that the network thread must be started after the assignment
// to network_http (since the thread might use network_http, otherwise
// a race condition can be introduced resulting in a crash).
INetworkHttp::get()->startNetworkThread();
}
else if (name=="minimal-racegui")
{
CheckBoxWidget* min_gui = getWidget<CheckBoxWidget>("minimal-racegui");
assert( min_gui != NULL );
UserConfigParams::m_minimal_race_gui =
!UserConfigParams::m_minimal_race_gui;
}
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
}
else
{
#ifdef WIN32
std::string s=std::string("LANGUAGE=")+selection.c_str();
_putenv(s.c_str());
#else
setenv("LANGUAGE", selection.c_str(), 1);
#endif
}
translations = new Translations();
GUIEngine::getStateManager()->hardResetAndGoToScreen<MainMenuScreen>();
GUIEngine::getFont()->updateRTL();
GUIEngine::getTitleFont()->updateRTL();
GUIEngine::getSmallFont()->updateRTL();
UserConfigParams::m_language = selection.c_str();
user_config->saveConfig();
GUIEngine::getStateManager()->pushScreen(OptionsScreenUI::getInstance());
}
} // eventCallback
示例10: _
void OptionsScreenUI::init()
{
Screen::init();
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
if (ribbon != NULL) ribbon->select( "tab_ui", PLAYER_ID_GAME_MASTER );
ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") );
ribbon->getRibbonChildren()[1].setTooltip( _("Audio") );
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
GUIEngine::SpinnerWidget* skinSelector = getWidget<GUIEngine::SpinnerWidget>("skinchoice");
assert( skinSelector != NULL );
// ---- video modes
CheckBoxWidget* fps = getWidget<CheckBoxWidget>("showfps");
assert( fps != NULL );
fps->setState( UserConfigParams::m_display_fps );
CheckBoxWidget* news = getWidget<CheckBoxWidget>("enable-internet");
assert( news != NULL );
news->setState( UserConfigParams::m_internet_status
==INetworkHttp::IPERM_ALLOWED );
CheckBoxWidget* min_gui = getWidget<CheckBoxWidget>("minimal-racegui");
assert( min_gui != NULL );
min_gui->setState( UserConfigParams::m_minimal_race_gui);
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
min_gui->setDeactivated();
else
min_gui->setActivated();
// --- select the right skin in the spinner
bool currSkinFound = false;
const int skinCount = m_skins.size();
for (int n=0; n<skinCount; n++)
{
const std::string skinFileName = StringUtils::getBasename(m_skins[n]);
if (UserConfigParams::m_skin_file.c_str() == skinFileName)
{
skinSelector->setValue(n);
currSkinFound = true;
break;
}
}
if (!currSkinFound)
{
std::cerr << "WARNING: couldn't find current skin in the list of skins!!\n";
skinSelector->setValue(0);
GUIEngine::reloadSkin();
}
// --- language
ListWidget* list_widget = getWidget<ListWidget>("language");
// I18N: in the language choice, to select the same language as the OS
list_widget->addItem("system", _("System Language"));
const std::vector<std::string>* lang_list = translations->getLanguageList();
const int amount = lang_list->size();
for (int n=0; n<amount; n++)
{
std::string code_name = (*lang_list)[n];
std::string nice_name = tinygettext::Language::from_name(code_name.c_str()).get_name();
list_widget->addItem(code_name, core::stringw(code_name.c_str()) + " (" +
nice_name.c_str() + ")");
}
list_widget->setSelectionID( list_widget->getItemID(UserConfigParams::m_language) );
// Forbid changing language while in-game, since this crashes (changing the language involves
// tearing down and rebuilding the menu stack. not good when in-game)
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
{
list_widget->setDeactivated();
}
else
{
list_widget->setActivated();
}
} // init
示例11: if
void OptionsScreenVideo::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 == "custom")
{
new CustomVideoSettingsDialog(0.8f, 0.9f);
}
else if(name == "apply_resolution")
{
using namespace GUIEngine;
DynamicRibbonWidget* w1=getWidget<DynamicRibbonWidget>("resolutions");
assert(w1 != NULL);
const std::string& res =
w1->getSelectionIDString(PLAYER_ID_GAME_MASTER);
int w = -1, h = -1;
if (sscanf(res.c_str(), "%ix%i", &w, &h) != 2 || w == -1 || h == -1)
{
Log::error("OptionsScreenVideo", "Failed to decode resolution %s", res.c_str());
return;
}
CheckBoxWidget* w2 = getWidget<CheckBoxWidget>("fullscreen");
assert(w2 != NULL);
irr_driver->changeResolution(w, h, w2->getState());
}
else if (name == "gfx_level")
{
GUIEngine::SpinnerWidget* gfx_level =
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
assert( gfx_level != NULL );
const int level = gfx_level->getValue() - 1;
UserConfigParams::m_show_steering_animations = GFX_PRESETS[level].animatedCharacters;
UserConfigParams::m_graphical_effects = GFX_PRESETS[level].animatedScenery;
UserConfigParams::m_anisotropic = GFX_PRESETS[level].anisotropy;
UserConfigParams::m_bloom = GFX_PRESETS[level].bloom;
UserConfigParams::m_glow = GFX_PRESETS[level].glow;
UserConfigParams::m_dynamic_lights = GFX_PRESETS[level].lights;
UserConfigParams::m_light_shaft = GFX_PRESETS[level].lightshaft;
UserConfigParams::m_mlaa = GFX_PRESETS[level].mlaa;
UserConfigParams::m_motionblur = GFX_PRESETS[level].motionblur;
//UserConfigParams::m_pixel_shaders = GFX_PRESETS[level].shaders;
UserConfigParams::m_shadows_resolution = GFX_PRESETS[level].shadows;
UserConfigParams::m_ssao = GFX_PRESETS[level].ssao;
UserConfigParams::m_weather_effects = GFX_PRESETS[level].weather;
UserConfigParams::m_dof = GFX_PRESETS[level].dof;
UserConfigParams::m_gi = GFX_PRESETS[level].global_illumination;
UserConfigParams::m_degraded_IBL = GFX_PRESETS[level].degraded_ibl;
UserConfigParams::m_high_definition_textures = 0x02 | GFX_PRESETS[level].hd_textures;
updateGfxSlider();
}
else if (name == "vsync")
{
GUIEngine::CheckBoxWidget* vsync =
getWidget<GUIEngine::CheckBoxWidget>("vsync");
assert( vsync != NULL );
UserConfigParams::m_vsync = vsync->getState();
}
else if (name == "rememberWinpos")
{
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
UserConfigParams::m_remember_window_location = rememberWinpos->getState();
}
else if (name == "fullscreen")
{
CheckBoxWidget* fullscreen = getWidget<CheckBoxWidget>("fullscreen");
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
rememberWinpos->setActive(!fullscreen->getState());
}
} // eventCallback
示例12: assert
void OptionsScreenVideo::init()
{
Screen::init();
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
assert(ribbon != NULL);
ribbon->select( "tab_video", PLAYER_ID_GAME_MASTER );
ribbon->getRibbonChildren()[1].setTooltip( _("Audio") );
ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") );
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
GUIEngine::ButtonWidget* applyBtn =
getWidget<GUIEngine::ButtonWidget>("apply_resolution");
assert( applyBtn != NULL );
GUIEngine::SpinnerWidget* gfx =
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
assert( gfx != NULL );
GUIEngine::CheckBoxWidget* vsync =
getWidget<GUIEngine::CheckBoxWidget>("vsync");
assert( vsync != NULL );
vsync->setState( UserConfigParams::m_vsync );
// ---- video modes
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
assert( res != NULL );
CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen");
assert( full != NULL );
full->setState( UserConfigParams::m_fullscreen );
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
rememberWinpos->setState(UserConfigParams::m_remember_window_location);
rememberWinpos->setActive(UserConfigParams::m_fullscreen);
// --- get resolution list from irrlicht the first time
if (!m_inited)
{
res->clearItems();
const std::vector<IrrDriver::VideoMode>& modes =
irr_driver->getVideoModes();
const int amount = (int)modes.size();
std::vector<Resolution> resolutions;
Resolution r;
bool found_config_res = false;
// for some odd reason, irrlicht sometimes fails to report the good
// old standard resolutions
// those are always useful for windowed mode
bool found_1024_768 = false;
for (int n=0; n<amount; n++)
{
r.width = modes[n].getWidth();
r.height = modes[n].getHeight();
resolutions.push_back(r);
if (r.width == UserConfigParams::m_width &&
r.height == UserConfigParams::m_height)
{
found_config_res = true;
}
if (r.width == 1024 && r.height == 768)
{
found_1024_768 = true;
}
}
if (!found_config_res)
{
r.width = UserConfigParams::m_width;
r.height = UserConfigParams::m_height;
resolutions.push_back(r);
if (r.width == 1024 && r.height == 768)
{
found_1024_768 = true;
}
} // next found resolution
// Add default resolutions that were not found by irrlicht
if (!found_1024_768)
{
r.width = 1024;
r.height = 768;
resolutions.push_back(r);
}
// Sort resolutions by size
std::sort(resolutions.begin(), resolutions.end());
//.........这里部分代码省略.........
示例13: if
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).c_str();
if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance());
else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance());
else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
}
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.
if(internet->getState())
NewsManager::get()->init(false);
}
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
}
else
{
#ifdef WIN32
std::string s=std::string("LANGUAGE=")+selection.c_str();
_putenv(s.c_str());
#else
setenv("LANGUAGE", selection.c_str(), 1);
#endif
}
translations = new Translations();
GUIEngine::getStateManager()->hardResetAndGoToScreen<MainMenuScreen>();
GUIEngine::getFont()->updateRTL();
GUIEngine::getTitleFont()->updateRTL();
GUIEngine::getSmallFont()->updateRTL();
UserConfigParams::m_language = selection.c_str();
user_config->saveConfig();
GUIEngine::getStateManager()->pushScreen(OptionsScreenUI::getInstance());
}
} // eventCallback
示例14: assert
void OptionsScreenUI::init()
{
Screen::init();
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
assert(ribbon != NULL);
ribbon->select( "tab_ui", PLAYER_ID_GAME_MASTER );
ribbon->getRibbonChildren()[0].setTooltip( _("Graphics") );
ribbon->getRibbonChildren()[1].setTooltip( _("Audio") );
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
GUIEngine::SpinnerWidget* skinSelector = getWidget<GUIEngine::SpinnerWidget>("skinchoice");
assert( skinSelector != NULL );
// ---- video modes
CheckBoxWidget* fps = getWidget<CheckBoxWidget>("showfps");
assert( fps != NULL );
fps->setState( UserConfigParams::m_display_fps );
CheckBoxWidget* news = getWidget<CheckBoxWidget>("enable-internet");
assert( news != NULL );
news->setState( UserConfigParams::m_internet_status
==RequestManager::IPERM_ALLOWED );
CheckBoxWidget* stats = getWidget<CheckBoxWidget>("enable-hw-report");
assert( stats != NULL );
LabelWidget *stats_label = getWidget<LabelWidget>("label-hw-report");
assert( stats_label );
stats->setState(UserConfigParams::m_hw_report_enable);
if(news->getState())
{
stats_label->setVisible(true);
stats->setVisible(true);
stats->setState(UserConfigParams::m_hw_report_enable);
}
else
{
stats_label->setVisible(false);
stats->setVisible(false);
}
CheckBoxWidget* difficulty = getWidget<CheckBoxWidget>("perPlayerDifficulty");
assert( difficulty != NULL );
difficulty->setState( UserConfigParams::m_per_player_difficulty );
difficulty->setTooltip(_("In multiplayer mode, players can select handicapped (more difficult) profiles on the kart selection screen"));
CheckBoxWidget* show_login = getWidget<CheckBoxWidget>("show-login");
assert( show_login!= NULL );
show_login->setState( UserConfigParams::m_always_show_login_screen);
// --- select the right skin in the spinner
bool currSkinFound = false;
const int skinCount = (int) m_skins.size();
for (int n=0; n<skinCount; n++)
{
const std::string skinFileName = StringUtils::getBasename(m_skins[n]);
if (UserConfigParams::m_skin_file.c_str() == skinFileName)
{
skinSelector->setValue(n);
currSkinFound = true;
break;
}
}
if (!currSkinFound)
{
Log::warn("OptionsScreenUI",
"Couldn't find current skin in the list of skins!");
skinSelector->setValue(0);
GUIEngine::reloadSkin();
}
// --- language
ListWidget* list_widget = getWidget<ListWidget>("language");
// I18N: in the language choice, to select the same language as the OS
list_widget->addItem("system", _("System Language"));
const std::vector<std::string>* lang_list = translations->getLanguageList();
const int amount = (int)lang_list->size();
// The names need to be sorted alphabetically. Store the 2-letter
// language names in a mapping, to be able to get them from the
// user visible full name.
std::vector<core::stringw> nice_lang_list;
std::map<core::stringw, std::string> nice_name_2_id;
for (int n=0; n<amount; n++)
{
std::string code_name = (*lang_list)[n];
std::string s_name = translations->getLocalizedName(code_name) +
" (" + tinygettext::Language::from_name(code_name).get_language() + ")";
core::stringw nice_name = translations->fribidize(StringUtils::utf8ToWide(s_name));
nice_lang_list.push_back(nice_name);
nice_name_2_id[nice_name] = code_name;
}
std::sort(nice_lang_list.begin(), nice_lang_list.end());
for(unsigned int i=0; i<nice_lang_list.size(); i++)
{
list_widget->addItem(nice_name_2_id[nice_lang_list[i]],
nice_lang_list[i]);
//.........这里部分代码省略.........
示例15: getNumKartsInTeam
// ----------------------------------------------------------------------------
void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if(m_schedule_continue)
return;
if(name == "continue")
{
int nb_players = m_kart_view_info.size();
if (getNumKartsInTeam(SOCCER_TEAM_RED) == 0 ||
getNumKartsInTeam(SOCCER_TEAM_BLUE) == 0)
{
for(int i=0 ; i < nb_players ; i++)
{
if (!m_kart_view_info[i].confirmed)
{
m_kart_view_info[i].view->setBadge(BAD_BADGE);
}
}
sfx_manager->quickSound( "anvil" );
return;
}
else if(!areAllKartsConfirmed())
{
for(int i=0 ; i < nb_players ; i++)
{
if (!m_kart_view_info[i].confirmed)
{
m_kart_view_info[i].confirmed = true;
m_kart_view_info[i].view->setRotateTo( KART_CONFIRMATION_TARGET_ANGLE, KART_CONFIRMATION_ROTATION_SPEED );
m_kart_view_info[i].view->setBadge(OK_BADGE);
}
}
sfx_manager->quickSound( "wee" );
m_schedule_continue = true;
}
else
{
m_schedule_continue = true;
}
if(getWidget<SpinnerWidget>("goalamount")->isActivated())
race_manager->setMaxGoal(getWidget<SpinnerWidget>("goalamount")->getValue());
else
race_manager->setTimeTarget((float)getWidget<SpinnerWidget>("timeamount")->getValue()*60);
input_manager->setMasterPlayerOnly(true);
}
else if (name == "back")
{
StateManager::get()->escapePressed();
}
else if(name == "time_enabled")
{
CheckBoxWidget* timeEnabled = dynamic_cast<CheckBoxWidget*>(widget);
if(timeEnabled->getState())
{
getWidget<SpinnerWidget>("goalamount")->setDeactivated();
getWidget<SpinnerWidget>("timeamount")->setActivated();
}
else
{
getWidget<SpinnerWidget>("timeamount")->setDeactivated();
getWidget<SpinnerWidget>("goalamount")->setActivated();
}
}
} // eventCallback