Replaced Widget's set(De)Activated functions with one setActive(bool)

function, which simplifies code for various screen a lot.
This commit is contained in:
hiker 2015-07-03 16:19:28 +10:00
parent 8059544b21
commit 9b562d31f4
33 changed files with 161 additions and 307 deletions

View File

@ -148,29 +148,15 @@ void Widget::elementRemoved()
// -----------------------------------------------------------------------------
void Widget::setActivated()
void Widget::setActive(bool active)
{
// even if this one is already active, do it anyway on purpose, maybe the
// children widgets need to be updated
m_deactivated = false;
m_deactivated = !active;
const int count = m_children.size();
for (int n=0; n<count; n++)
{
m_children[n].setActivated();
}
}
// -----------------------------------------------------------------------------
void Widget::setDeactivated()
{
// even if this one is already inactive, do it anyway on purpose, maybe the
// children widgets need to be updated
m_deactivated = true;
const int count = m_children.size();
for (int n=0; n<count; n++)
{
m_children[n].setDeactivated();
m_children[n].setActive(active);
}
}

View File

@ -322,7 +322,7 @@ namespace GUIEngine
/**
* \brief Sets the widget (and its children, if any) visible or not.
* Note that setting a widget invisible implicitely calls setDeactivated(), and setting
* it visible implicitely calls setActivated(). If you mix visiblity and (de)activated calls,
* it visible implicitely calls setActive(true). If you mix visiblity and (de)activated calls,
* undefined behavior may ensue (like invisible but clickable buttons).
*/
void setVisible(bool visible);
@ -352,12 +352,11 @@ namespace GUIEngine
* \{
*/
/** \brief undos setDeactivated() */
virtual void setActivated();
/** \brief greys out the widget, making it not clickable for the user */
virtual void setDeactivated();
/** \brief Sets an widget to be either activated or deactivated
* (i.e. greyed out)
* \param active Active (true) or deactive (false). Defaults to
* true. */
virtual void setActive(bool active=true);
/**
* \}

View File

@ -395,36 +395,34 @@ void SpinnerWidget::setValue(irr::core::stringw new_value)
// -----------------------------------------------------------------------------
void SpinnerWidget::setActivated()
void SpinnerWidget::setActive(bool active)
{
Widget::setActivated();
Widget::setActive(active);
setText(L"");
if (m_customText.empty())
if (active)
{
setValue( getValue() ); // Update the display
setText(L"");
if (m_customText.empty())
{
setValue(getValue()); // Update the display
}
else
{
setCustomText(m_customText);
}
}
else
{
setCustomText(m_customText);
// Save it temporary because setValue(which is uses for update in
// this case) overwrites it
core::stringw customText = m_customText;
setText(L"-");
setValue(getValue()); // Update the display
m_customText = customText;
}
}
} // setActive
// -----------------------------------------------------------------------------
void SpinnerWidget::setDeactivated()
{
Widget::setDeactivated();
// Save it temporary because setValue(which is uses for update in this case) overwrites it
core::stringw customText = m_customText;
setText(L"-");
setValue( getValue() ); // Update the display
m_customText = customText;
}
// -----------------------------------------------------------------------------
void SpinnerWidget::setCustomText(const core::stringw& text)
{
m_customText = text;

View File

@ -193,10 +193,7 @@ namespace GUIEngine
// --------------------------------------------------------------------
/** Override method from base class Widget */
virtual void setActivated();
/** Override method from base class Widget */
virtual void setDeactivated();
virtual void setActive(bool active = true);
/** Display custom text in spinner */
void setCustomText(const core::stringw& text);

View File

@ -174,30 +174,16 @@ void TextBoxWidget::elementRemoved()
// -----------------------------------------------------------------------------
void TextBoxWidget::setActivated()
void TextBoxWidget::setActive(bool active)
{
Widget::setActivated();
Widget::setActive(active);
if (m_element != NULL)
{
IGUIEditBox* textCtrl = Widget::getIrrlichtElement<IGUIEditBox>();
assert(textCtrl != NULL);
textCtrl->setEnabled(true);
textCtrl->setEnabled(active);
}
}
// -----------------------------------------------------------------------------
void TextBoxWidget::setDeactivated()
{
Widget::setDeactivated();
if (m_element != NULL)
{
IGUIEditBox* textCtrl = Widget::getIrrlichtElement<IGUIEditBox>();
assert(textCtrl != NULL);
textCtrl->setEnabled(false);
}
}
} // setActive
// -----------------------------------------------------------------------------

View File

@ -73,10 +73,7 @@ namespace GUIEngine
virtual void elementRemoved();
/** Override method from base class Widget */
virtual void setActivated();
/** Override method from base class Widget */
virtual void setDeactivated();
virtual void setActive(bool active=true);
};
}

View File

@ -143,7 +143,7 @@ void AddonsScreen::init()
m_sort_default = true;
m_sort_col = 0;
getWidget<GUIEngine::RibbonWidget>("category")->setDeactivated();
getWidget<GUIEngine::RibbonWidget>("category")->setActive(false);
if(UserConfigParams::logAddons())
Log::info("addons", "Using directory <%s>", file_manager->getAddonsDir().c_str());
@ -157,10 +157,8 @@ void AddonsScreen::init()
w_list->setIcons(m_icon_bank, (int)(m_icon_height));
m_type = "kart";
if (UserConfigParams::m_internet_status != RequestManager::IPERM_ALLOWED)
getWidget<GUIEngine::IconButtonWidget>("reload")->setDeactivated();
else
getWidget<GUIEngine::IconButtonWidget>("reload")->setActivated();
bool ip = UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED;
getWidget<GUIEngine::IconButtonWidget>("reload")->setActive(ip);
// Reset filter.
GUIEngine::TextBoxWidget* w_filter_name =
@ -371,7 +369,7 @@ void AddonsScreen::loadList()
}
}
getWidget<GUIEngine::RibbonWidget>("category")->setActivated();
getWidget<GUIEngine::RibbonWidget>("category")->setActive(true);
if(m_type == "kart")
getWidget<GUIEngine::RibbonWidget>("category")->select("tab_kart",
PLAYER_ID_GAME_MASTER);

View File

@ -109,7 +109,7 @@ void CreateServerScreen::onUpdate(float delta)
}
delete m_server_creation_request;
m_server_creation_request = NULL;
//m_options_widget->setActivated();
//m_options_widget->setActive(true);
}
else
{

View File

@ -148,7 +148,7 @@ void ChangePasswordDialog::submit()
}
else
{
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
m_info_widget->setDefaultColor();
// We don't need to use password 2 anymore, it was already confirmed
@ -208,7 +208,7 @@ void ChangePasswordDialog::success()
{
m_info_widget->setDefaultColor();
m_info_widget->setText(_("Password successfully changed."), false);
m_options_widget->setActivated();
m_options_widget->setActive(true);
m_current_password_widget->setText("");
m_new_password1_widget->setText("");
m_new_password2_widget->setText("");
@ -220,7 +220,7 @@ void ChangePasswordDialog::error(const irr::core::stringw & error)
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error, false);
m_options_widget->setActivated();
m_options_widget->setActive(true);
m_current_password_widget->setText("");
m_new_password1_widget->setText("");
m_new_password2_widget->setText("");

View File

@ -107,13 +107,13 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
{
CheckBoxWidget* cb_tex_cmp = getWidget<CheckBoxWidget>("texture_compression");
cb_tex_cmp->setState(false);
cb_tex_cmp->setDeactivated();
cb_tex_cmp->setActive(false);
}
if (!CVS->supportsGlobalIllumination())
{
shadows->setDeactivated();
getWidget<CheckBoxWidget>("global_illumination")->setDeactivated();
shadows->setActive(false);
getWidget<CheckBoxWidget>("global_illumination")->setActive(false);
}
}
@ -227,37 +227,22 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
void CustomVideoSettingsDialog::updateActivation()
{
if(getWidget<CheckBoxWidget>("dynamiclight")->getState())
{
getWidget<CheckBoxWidget>("motionblur")->setActivated();
getWidget<CheckBoxWidget>("dof")->setActivated();
getWidget<SpinnerWidget>("shadows")->setActivated();
getWidget<CheckBoxWidget>("mlaa")->setActivated();
getWidget<CheckBoxWidget>("ssao")->setActivated();
getWidget<CheckBoxWidget>("lightshaft")->setActivated();
getWidget<CheckBoxWidget>("ibl")->setActivated();
getWidget<CheckBoxWidget>("global_illumination")->setActivated();
getWidget<CheckBoxWidget>("glow")->setActivated();
getWidget<CheckBoxWidget>("bloom")->setActivated();
}
else
{
getWidget<CheckBoxWidget>("motionblur")->setDeactivated();
getWidget<CheckBoxWidget>("dof")->setDeactivated();
getWidget<SpinnerWidget>("shadows")->setDeactivated();
getWidget<CheckBoxWidget>("mlaa")->setDeactivated();
getWidget<CheckBoxWidget>("ssao")->setDeactivated();
getWidget<CheckBoxWidget>("lightshaft")->setDeactivated();
getWidget<CheckBoxWidget>("ibl")->setDeactivated();
getWidget<CheckBoxWidget>("global_illumination")->setDeactivated();
getWidget<CheckBoxWidget>("glow")->setDeactivated();
getWidget<CheckBoxWidget>("bloom")->setDeactivated();
}
bool light = getWidget<CheckBoxWidget>("dynamiclight")->getState();
getWidget<CheckBoxWidget>("motionblur")->setActive(light);
getWidget<CheckBoxWidget>("dof")->setActive(true);
getWidget<SpinnerWidget>("shadows")->setActive(light);
getWidget<CheckBoxWidget>("mlaa")->setActive(light);
getWidget<CheckBoxWidget>("ssao")->setActive(light);
getWidget<CheckBoxWidget>("lightshaft")->setActive(light);
getWidget<CheckBoxWidget>("ibl")->setActive(light);
getWidget<CheckBoxWidget>("global_illumination")->setActive(light);
getWidget<CheckBoxWidget>("glow")->setActive(light);
getWidget<CheckBoxWidget>("bloom")->setActive(light);
if (!CVS->supportsShadows() && !CVS->supportsGlobalIllumination())
{
getWidget<SpinnerWidget>("shadows")->setDeactivated();
getWidget<CheckBoxWidget>("global_illumination")->setDeactivated();
getWidget<SpinnerWidget>("shadows")->setActive(false);
getWidget<CheckBoxWidget>("global_illumination")->setActive(false);
}
} // updateActivation

View File

@ -124,7 +124,7 @@ void RecoveryDialog::processInput()
else
{
m_info_widget->setDefaultColor();
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
m_recovery_request = new XMLRequest();
@ -197,7 +197,7 @@ void RecoveryDialog::onUpdate(float dt)
SFXManager::get()->quickSound( "anvil" );
m_info_widget->setErrorColor();
m_info_widget->setText(m_recovery_request->getInfo(), false);
m_options_widget->setActivated();
m_options_widget->setActive(true);
}
delete m_recovery_request;

View File

@ -179,7 +179,7 @@ void UserInfoDialog::sendFriendRequest()
request->queue();
m_processing = true;
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
} // sendFriendRequest
@ -234,7 +234,7 @@ void UserInfoDialog::acceptFriendRequest()
request->queue();
m_processing = true;
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
} // acceptFriendRequest
// -----------------------------------------------------------------------------
@ -285,7 +285,7 @@ void UserInfoDialog::declineFriendRequest()
request->queue();
m_processing = true;
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
} // declineFriendRequest
@ -398,7 +398,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
{
ProfileManager::get()->setVisiting(m_online_profile->getID());
m_enter_profile = true;
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
return GUIEngine::EVENT_BLOCK;
}
else if(selection == m_friend_widget->m_properties[PROP_ID])
@ -415,7 +415,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
removeExistingFriend();
m_processing = true;
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
return GUIEngine::EVENT_BLOCK;
}
else if(selection == m_accept_widget->m_properties[PROP_ID])
@ -435,7 +435,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
// -----------------------------------------------------------------------------
void UserInfoDialog::deactivate()
{
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
} // deactivate
// -----------------------------------------------------------------------------

View File

@ -64,8 +64,8 @@ VoteDialog::VoteDialog(const std::string & addon_id)
m_fetch_vote_request->addParameter("addonid", addon_id.substr(6));
m_fetch_vote_request->queue();
m_rating_widget->setDeactivated();
m_cancel_widget->setDeactivated();
m_rating_widget->setActive(false);
m_cancel_widget->setActive(false);
} // VoteDialog
// -----------------------------------------------------------------------------
@ -123,8 +123,8 @@ void VoteDialog::sendVote()
m_perform_vote_request->addParameter("rating", m_rating_widget->getRating());
m_perform_vote_request->queue();
m_rating_widget->setDeactivated();
m_cancel_widget->setDeactivated();
m_rating_widget->setActive(false);
m_cancel_widget->setActive(false);
} // sendVote
@ -196,15 +196,15 @@ void VoteDialog::updateFetchVote()
"Select your desired rating by clicking "
"the stars beneath"), false);
}
m_cancel_widget->setActivated();
m_rating_widget->setActivated();
m_cancel_widget->setActive(true);
m_rating_widget->setActive(true);
} // isSuccess
else
{
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(m_fetch_vote_request->getInfo(), false);
m_cancel_widget->setActivated();
m_cancel_widget->setActive(true);
} // !isSuccess
delete m_fetch_vote_request;
@ -229,15 +229,15 @@ void VoteDialog::onUpdate(float dt)
m_info_widget->setDefaultColor();
m_info_widget->setText(_("Vote successful! You can now close "
"the window."), false);
m_cancel_widget->setActivated();
m_cancel_widget->setActive(true);
} // isSuccess
else
{
SFXManager::get()->quickSound( "anvil" );
m_info_widget->setErrorColor();
m_info_widget->setText(m_perform_vote_request->getInfo(), false);
m_cancel_widget->setActivated();
m_rating_widget->setActivated();
m_cancel_widget->setActive(true);
m_rating_widget->setActive(true);
} // !isSuccess
delete m_perform_vote_request;
m_perform_vote_request = NULL;

View File

@ -159,7 +159,7 @@ void EditGPScreen::init()
IconButtonWidget* button = getWidget<IconButtonWidget>("save");
assert(button != NULL);
button->setDeactivated();
button->setActive(false);
loadList(0);
setModified(false);
@ -274,10 +274,7 @@ void EditGPScreen::setModified(const bool modified)
IconButtonWidget* save_button = getWidget<IconButtonWidget>("save");
assert(save_button != NULL);
if (modified)
save_button->setActivated();
else
save_button->setDeactivated();
save_button->setActive(modified);
LabelWidget* header = getWidget<LabelWidget>("title");
assert(header != NULL);
@ -359,25 +356,10 @@ void EditGPScreen::enableButtons()
assert(edit_button != NULL);
assert(remove_button != NULL);
if (m_selected >= 0 && m_list->getItemCount() > 1)
{
up_button->setActivated();
down_button->setActivated();
}
else
{
up_button->setDeactivated();
down_button->setDeactivated();
}
bool b = m_selected >= 0 && m_list->getItemCount() > 1;
up_button->setActive(b);
down_button->setActive(b);
if (m_selected >= 0)
{
edit_button->setActivated();
remove_button->setActivated();
}
else
{
edit_button->setDeactivated();
remove_button->setDeactivated();
}
edit_button->setActive(m_selected >= 0);
remove_button->setActive(m_selected >= 0);
}

View File

@ -220,7 +220,8 @@ void EditTrackScreen::selectTrack(const std::string& id)
assert(ok_button != NULL);
m_track = track_manager->getTrack(id);
if (m_track != NULL)
ok_button->setActive(m_track!=NULL);
if (m_track)
{
tracks->setSelection(m_track->getIdent(), PLAYER_ID_GAME_MASTER, true);
selected_track->setText(translations->fribidize(m_track->getName()), true);
@ -229,8 +230,6 @@ void EditTrackScreen::selectTrack(const std::string& id)
reverse->setVisible(m_track->reverseAvailable());
label_reverse->setVisible(m_track->reverseAvailable());
ok_button->setActivated();
}
else
{
@ -244,6 +243,5 @@ void EditTrackScreen::selectTrack(const std::string& id)
reverse->setVisible(true);
reverse->setState(false);
ok_button->setDeactivated();
}
}

View File

@ -230,7 +230,7 @@ void GPInfoScreen::init()
getWidget<LabelWidget>("ai-text")->setVisible(has_AI);
if (has_AI)
{
m_ai_kart_spinner->setActivated();
m_ai_kart_spinner->setActive(true);
// Avoid negative numbers (which can happen if e.g. the number of karts
// in a previous race was lower than the number of players now.

View File

@ -271,23 +271,13 @@ void GrandPrixEditorScreen::enableButtons()
assert(remove_button != NULL);
assert(rename_button != NULL);
if (m_selection != NULL && m_selection->getNumberOfTracks() > 0)
copy_button->setActivated();
else
copy_button->setDeactivated();
bool b = m_selection && m_selection->getNumberOfTracks() > 0;
copy_button->setActive(b);
if (m_selection != NULL && m_selection->isEditable())
{
edit_button->setActivated();
remove_button->setActivated();
rename_button->setActivated();
}
else
{
edit_button->setDeactivated();
remove_button->setDeactivated();
rename_button->setDeactivated();
}
b = m_selection && m_selection->isEditable();
edit_button->setActive(b);
remove_button->setActive(b);
rename_button->setActive(b);
}
// -----------------------------------------------------------------------------

View File

@ -118,14 +118,8 @@ void HelpScreen1::init()
RibbonWidget* w = this->getWidget<RibbonWidget>("category");
ButtonWidget* tutorial = getWidget<ButtonWidget>("startTutorial");
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
{
tutorial->setDeactivated();
}
else
{
tutorial->setActivated();
}
tutorial->setActive(StateManager::get()->getGameState() !=
GUIEngine::INGAME_MENU);
if (w != NULL) w->select( "page1", PLAYER_ID_GAME_MASTER );
} //init

View File

@ -332,7 +332,7 @@ void KartSelectionScreen::init()
m_game_master_confirmed = false;
tabs->setActivated();
tabs->setActive(true);
m_kart_widgets.clearAndDeleteAll();
StateManager::get()->resetActivePlayers();
@ -775,7 +775,7 @@ void KartSelectionScreen::playerConfirm(const int player_id)
m_game_master_confirmed = true;
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
assert( tabs != NULL );
tabs->setDeactivated();
tabs->setActive(false);
}
// validate choices to notify player of duplicates

View File

@ -125,7 +125,7 @@ void MainMenuScreen::init()
if (addons_manager->isLoading())
{
IconButtonWidget* w = getWidget<IconButtonWidget>("addons");
w->setDeactivated();
w->setActive(false);
w->resetAllBadges();
w->setBadge(LOADING_BADGE);
}
@ -133,7 +133,7 @@ void MainMenuScreen::init()
m_online = getWidget<IconButtonWidget>("online");
if(!m_enable_online)
m_online->setDeactivated();
m_online->setActive(false);
LabelWidget* w = getWidget<LabelWidget>("info_addons");
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
@ -166,19 +166,19 @@ void MainMenuScreen::onUpdate(float delta)
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
{
m_user_id->setText(player->getLastOnlineName() + "@stk");
m_online->setActivated();
m_online->setActive(true);
m_online->setLabel( _("Online"));
}
else if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_OUT)
{
m_online->setActivated();
m_online->setActive(true);
m_online->setLabel( _("Login" ));
m_user_id->setText(player->getName());
}
else
{
// now must be either logging in or logging out
m_online->setDeactivated();
m_online->setActive(false);
m_user_id->setText(player->getName());
}
@ -189,7 +189,7 @@ void MainMenuScreen::onUpdate(float delta)
{
if (addons_manager->wasError())
{
addons_icon->setActivated();
addons_icon->setActive(true);
addons_icon->resetAllBadges();
addons_icon->setBadge(BAD_BADGE);
}
@ -197,13 +197,13 @@ void MainMenuScreen::onUpdate(float delta)
== Online::RequestManager::IPERM_ALLOWED)
{
// Addons manager is still initialising/downloading.
addons_icon->setDeactivated();
addons_icon->setActive(false);
addons_icon->resetAllBadges();
addons_icon->setBadge(LOADING_BADGE);
}
else
{
addons_icon->setActivated();
addons_icon->setActive(true);
addons_icon->resetAllBadges();
}
// maybe add a new badge when not allowed to access the net

View File

@ -55,7 +55,7 @@ void NetworkKartSelectionScreen::init()
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
assert( tabs != NULL );
tabs->select( "standard", PLAYER_ID_GAME_MASTER); // select standard kart group
tabs->setDeactivated();
tabs->setActive(false);
tabs->setVisible(false);
// change the back button image (because it makes the game quit)

View File

@ -115,16 +115,16 @@ void OnlineScreen::beforeAddingWidget()
m_recorded_state == PlayerProfile::OS_SIGNING_IN ||
m_recorded_state == PlayerProfile::OS_SIGNING_OUT)
{
m_quick_play_widget->setDeactivated();
m_find_server_widget->setDeactivated();
m_create_server_widget->setDeactivated();
m_quick_play_widget->setActive(false);
m_find_server_widget->setActive(false);
m_create_server_widget->setActive(false);
m_sign_out_widget->setVisible(false);
m_profile_widget->setVisible(false);
}
else if (m_recorded_state == PlayerProfile::OS_GUEST)
{
m_find_server_widget->setDeactivated();
m_create_server_widget->setDeactivated();
m_find_server_widget->setActive(false);
m_create_server_widget->setActive(false);
m_profile_widget->setVisible(false);
}

View File

@ -206,9 +206,9 @@ void OnlineUserSearch::search()
m_user_list_widget->clear();
m_user_list_widget->addItem("spacer", L"");
m_user_list_widget->addItem("loading", StringUtils::loadingDots(_("Searching")));
m_back_widget->setDeactivated();
m_search_box_widget->setDeactivated();
m_search_button_widget->setDeactivated();
m_back_widget->setActive(false);
m_search_box_widget->setActive(false);
m_search_button_widget->setActive(false);
}
} // search
@ -278,9 +278,9 @@ void OnlineUserSearch::onUpdate(float dt)
delete m_search_request;
m_search_request = NULL;
m_back_widget->setActivated();
m_search_box_widget->setActivated();
m_search_button_widget->setActivated();
m_back_widget->setActive(true);
m_search_box_widget->setActive(true);
m_search_button_widget->setActive(true);
}
else
{

View File

@ -156,14 +156,8 @@ void OptionsScreenInput::init()
eventCallback(devices, name2, PLAYER_ID_GAME_MASTER);
*/
// Disable adding keyboard configurations
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
{
getWidget<ButtonWidget>("add_device")->setDeactivated();
}
else
{
getWidget<ButtonWidget>("add_device")->setActivated();
}
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
getWidget<ButtonWidget>("add_device")->setActive(!in_game);
} // init
// -----------------------------------------------------------------------------

View File

@ -109,16 +109,9 @@ void OptionsScreenInput2::init()
else
{
delete_button->setLabel(_("Delete Configuration"));
if (input_manager->getDeviceManager()->getKeyboardAmount() < 2)
{
// don't allow deleting the last config
delete_button->setDeactivated();
}
else
{
delete_button->setActivated();
}
// Don't allow deleting the last config
delete_button->setActive(
input_manager->getDeviceManager()->getKeyboardAmount() > 1);
}
// Make the two buttons the same length, not strictly needed but will
@ -166,13 +159,8 @@ void OptionsScreenInput2::init()
updateInputButtons();
// Disable deletion keyboard configurations
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
{
getWidget<ButtonWidget>("delete")->setDeactivated();
} else
{
getWidget<ButtonWidget>("delete")->setActivated();
}
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
getWidget<ButtonWidget>("delete")->setActive(!in_game);
} // init
// -----------------------------------------------------------------------------

View File

@ -89,7 +89,7 @@ void OptionsScreenUI::loadedFromFile()
{
Log::warn("OptionsScreenUI", "Could not find a single skin, make sure that "
"the data files are correctly installed");
skinSelector->setDeactivated();
skinSelector->setActive(false);
return;
}
@ -211,14 +211,7 @@ void OptionsScreenUI::init()
// 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();
}
list_widget->setActive(StateManager::get()->getGameState() != GUIEngine::INGAME_MENU);
} // init

View File

@ -192,9 +192,7 @@ void OptionsScreenVideo::init()
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
rememberWinpos->setState(UserConfigParams::m_remember_window_location);
if (UserConfigParams::m_fullscreen) rememberWinpos->setDeactivated();
else rememberWinpos->setActivated();
rememberWinpos->setActive(UserConfigParams::m_fullscreen);
// --- get resolution list from irrlicht the first time
if (!m_inited)
@ -353,23 +351,13 @@ void OptionsScreenVideo::init()
// ---- forbid changing resolution or animation settings from in-game
// (we need to disable them last because some items can't be edited when
// disabled)
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
{
res->setDeactivated();
full->setDeactivated();
applyBtn->setDeactivated();
gfx->setDeactivated();
getWidget<ButtonWidget>("custom")->setDeactivated();
}
else
{
// Enable back widgets if they were visited in-game previously
res->setActivated();
full->setActivated();
applyBtn->setActivated();
gfx->setActivated();
getWidget<ButtonWidget>("custom")->setActivated();
}
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
res->setActive(!in_game);
full->setActive(!in_game);
applyBtn->setActive(!in_game);
gfx->setActive(!in_game);
getWidget<ButtonWidget>("custom")->setActive(!in_game);
} // init
// ----------------------------------------------------------------------------
@ -597,8 +585,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
CheckBoxWidget* fullscreen = getWidget<CheckBoxWidget>("fullscreen");
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
if (fullscreen->getState()) rememberWinpos->setDeactivated();
else rememberWinpos->setActivated();
rememberWinpos->setActive(!fullscreen->getState());
}
} // eventCallback

View File

@ -289,7 +289,7 @@ void RaceSetupScreen::init()
int index = w->findItemNamed("best");
Widget* hardestWidget = &w->getChildren()[index];
hardestWidget->setBadge(LOCKED_BADGE);
hardestWidget->setDeactivated();
hardestWidget->setActive(false);
}
} // init

View File

@ -326,7 +326,7 @@ void RegisterScreen::doRegister()
*/
void RegisterScreen::acceptTerms()
{
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
core::stringw password = m_password_widget->getText().trim();
@ -374,7 +374,7 @@ void RegisterScreen::onUpdate(float dt)
}
delete m_signup_request;
m_signup_request = NULL;
m_options_widget->setActivated();
m_options_widget->setActive(true);
}
}
else if(m_info_message_shown && !ModalDialog::isADialogActive())

View File

@ -65,7 +65,7 @@ void ServerSelection::refresh()
m_server_list_widget->addItem("spacer", L"");
m_server_list_widget->addItem("loading",
StringUtils::loadingDots(_("Fetching servers")));
m_reload_widget->setDeactivated();
m_reload_widget->setActive(false);
}
@ -202,7 +202,7 @@ void ServerSelection::onUpdate(float dt)
}
delete m_refresh_request;
m_refresh_request = NULL;
m_reload_widget->setActivated();
m_reload_widget->setActive(true);
}
else
{
@ -214,6 +214,6 @@ void ServerSelection::onUpdate(float dt)
{
loadList();
m_fake_refresh = false;
m_reload_widget->setActivated();
m_reload_widget->setActive(true);
}
} // onUpdate

View File

@ -111,16 +111,9 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
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();
}
bool timed = timeEnabled->getState();
getWidget<SpinnerWidget>("goalamount")->setActive(!timed);
getWidget<SpinnerWidget>("timeamount")->setActive(timed);
}
} // eventCallback
@ -208,11 +201,11 @@ void SoccerSetupScreen::init()
SpinnerWidget* goalamount = getWidget<SpinnerWidget>("goalamount");
goalamount->setValue(UserConfigParams::m_num_goals);
goalamount->setActivated();
goalamount->setActive(true);
SpinnerWidget* timeAmount = getWidget<SpinnerWidget>("timeamount");
timeAmount->setValue(UserConfigParams::m_soccer_time_limit);
timeAmount->setDeactivated();
timeAmount->setActive(false);
CheckBoxWidget* timeEnabled = getWidget<CheckBoxWidget>("time_enabled");
timeEnabled->setState(false);

View File

@ -148,7 +148,7 @@ void TrackInfoScreen::init()
getWidget<LabelWidget>("ai-text")->setVisible(has_AI);
if (has_AI)
{
m_ai_kart_spinner->setActivated();
m_ai_kart_spinner->setActive(true);
// Avoid negative numbers (which can happen if e.g. the number of karts
// in a previous race was lower than the number of players now.

View File

@ -115,7 +115,7 @@ void BaseUserScreen::init()
m_sign_in_name = "";
// It should always be activated ... but just in case
m_options_widget->setActivated();
m_options_widget->setActive(true);
// Clean any error message still shown
m_info_widget->setText("", true);
m_info_widget->setErrorColor();
@ -148,20 +148,12 @@ void BaseUserScreen::init()
selectUser(0);
// Disable changing the user while in game
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
{
getWidget<IconButtonWidget>("ok")->setDeactivated();
getWidget<IconButtonWidget>("new_user")->setDeactivated();
getWidget<IconButtonWidget>("rename")->setDeactivated();
getWidget<IconButtonWidget>("delete")->setDeactivated();
}
else
{
getWidget<IconButtonWidget>("ok")->setActivated();
getWidget<IconButtonWidget>("new_user")->setActivated();
getWidget<IconButtonWidget>("rename")->setActivated();
getWidget<IconButtonWidget>("delete")->setActivated();
}
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
getWidget<IconButtonWidget>("ok")->setActive(!in_game);
getWidget<IconButtonWidget>("new_user")->setActive(!in_game);
getWidget<IconButtonWidget>("rename")->setActive(!in_game);
getWidget<IconButtonWidget>("delete")->setActive(!in_game);
m_new_registered_data = false;
if (m_auto_login)
{
@ -229,10 +221,7 @@ void BaseUserScreen::selectUser(int index)
makeEntryFieldsVisible();
getWidget<CheckBoxWidget>("remember-user")->setState(
profile->rememberPassword());
if(profile->getLastOnlineName().size() > 0)
m_username_tb->setDeactivated();
else
m_username_tb->setActivated();
m_username_tb->setActive(profile->getLastOnlineName().size() == 0);
// And make the password invisible if the session is saved (i.e
// the user does not need to enter a password).
@ -282,7 +271,7 @@ void BaseUserScreen::makeEntryFieldsVisible()
m_password_tb->setVisible(online);
// Is user has no online name, make sure the user can enter one
if (player->getLastOnlineName().empty())
m_username_tb->setActivated();
m_username_tb->setActive(true);
}
} // makeEntryFieldsVisible
@ -348,7 +337,7 @@ void BaseUserScreen::eventCallback(Widget* widget,
// Make sure the new user will have an empty online name field
// that can also be edited.
m_username_tb->setText("");
m_username_tb->setActivated();
m_username_tb->setActive(true);
}
else if (button == "cancel")
{
@ -403,7 +392,7 @@ void BaseUserScreen::login()
{
// If an error occurs, the callback informing this screen about the
// problem will activate the widget again.
m_options_widget->setDeactivated();
m_options_widget->setActive(false);
m_state = STATE_NONE;
PlayerProfile *player = getSelectedPlayer();
@ -471,7 +460,7 @@ void BaseUserScreen::login()
{
m_info_widget->setText(_("You need to enter a password."), true);
SFXManager::get()->quickSound("anvil");
m_options_widget->setActivated();
m_options_widget->setActive(true);
return;
}
m_sign_in_name = m_username_tb->getText();
@ -504,7 +493,7 @@ void BaseUserScreen::loginSuccessful()
{
PlayerProfile *player = getSelectedPlayer();
player->setWasOnlineLastTime(true);
m_options_widget->setActivated();
m_options_widget->setActive(true);
// Clean any error message still shown
m_info_widget->setText("", true);
m_info_widget->setErrorColor();
@ -530,7 +519,7 @@ void BaseUserScreen::loginError(const irr::core::stringw & error_message)
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error_message, false);
m_options_widget->setActivated();
m_options_widget->setActive(true);
} // loginError
// ----------------------------------------------------------------------------
@ -560,7 +549,7 @@ void BaseUserScreen::logoutError(const irr::core::stringw & error_message)
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error_message, false);
m_options_widget->setActivated();
m_options_widget->setActive(true);
} // logoutError
// ----------------------------------------------------------------------------