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 // even if this one is already active, do it anyway on purpose, maybe the
// children widgets need to be updated // children widgets need to be updated
m_deactivated = false; m_deactivated = !active;
const int count = m_children.size(); const int count = m_children.size();
for (int n=0; n<count; n++) for (int n=0; n<count; n++)
{ {
m_children[n].setActivated(); m_children[n].setActive(active);
}
}
// -----------------------------------------------------------------------------
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();
} }
} }

View File

@ -322,7 +322,7 @@ namespace GUIEngine
/** /**
* \brief Sets the widget (and its children, if any) visible or not. * \brief Sets the widget (and its children, if any) visible or not.
* Note that setting a widget invisible implicitely calls setDeactivated(), and setting * 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). * undefined behavior may ensue (like invisible but clickable buttons).
*/ */
void setVisible(bool visible); void setVisible(bool visible);
@ -352,12 +352,11 @@ namespace GUIEngine
* \{ * \{
*/ */
/** \brief undos setDeactivated() */ /** \brief Sets an widget to be either activated or deactivated
virtual void setActivated(); * (i.e. greyed out)
* \param active Active (true) or deactive (false). Defaults to
/** \brief greys out the widget, making it not clickable for the user */ * true. */
virtual void setDeactivated(); 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 (active)
if (m_customText.empty())
{ {
setValue( getValue() ); // Update the display setText(L"");
if (m_customText.empty())
{
setValue(getValue()); // Update the display
}
else
{
setCustomText(m_customText);
}
} }
else 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) void SpinnerWidget::setCustomText(const core::stringw& text)
{ {
m_customText = text; m_customText = text;

View File

@ -193,10 +193,7 @@ namespace GUIEngine
// -------------------------------------------------------------------- // --------------------------------------------------------------------
/** Override method from base class Widget */ /** Override method from base class Widget */
virtual void setActivated(); virtual void setActive(bool active = true);
/** Override method from base class Widget */
virtual void setDeactivated();
/** Display custom text in spinner */ /** Display custom text in spinner */
void setCustomText(const core::stringw& text); 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) if (m_element != NULL)
{ {
IGUIEditBox* textCtrl = Widget::getIrrlichtElement<IGUIEditBox>(); IGUIEditBox* textCtrl = Widget::getIrrlichtElement<IGUIEditBox>();
assert(textCtrl != NULL); assert(textCtrl != NULL);
textCtrl->setEnabled(true); textCtrl->setEnabled(active);
} }
} } // setActive
// -----------------------------------------------------------------------------
void TextBoxWidget::setDeactivated()
{
Widget::setDeactivated();
if (m_element != NULL)
{
IGUIEditBox* textCtrl = Widget::getIrrlichtElement<IGUIEditBox>();
assert(textCtrl != NULL);
textCtrl->setEnabled(false);
}
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -179,7 +179,7 @@ void UserInfoDialog::sendFriendRequest()
request->queue(); request->queue();
m_processing = true; m_processing = true;
m_options_widget->setDeactivated(); m_options_widget->setActive(false);
} // sendFriendRequest } // sendFriendRequest
@ -234,7 +234,7 @@ void UserInfoDialog::acceptFriendRequest()
request->queue(); request->queue();
m_processing = true; m_processing = true;
m_options_widget->setDeactivated(); m_options_widget->setActive(false);
} // acceptFriendRequest } // acceptFriendRequest
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -285,7 +285,7 @@ void UserInfoDialog::declineFriendRequest()
request->queue(); request->queue();
m_processing = true; m_processing = true;
m_options_widget->setDeactivated(); m_options_widget->setActive(false);
} // declineFriendRequest } // declineFriendRequest
@ -398,7 +398,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
{ {
ProfileManager::get()->setVisiting(m_online_profile->getID()); ProfileManager::get()->setVisiting(m_online_profile->getID());
m_enter_profile = true; m_enter_profile = true;
m_options_widget->setDeactivated(); m_options_widget->setActive(false);
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
else if(selection == m_friend_widget->m_properties[PROP_ID]) else if(selection == m_friend_widget->m_properties[PROP_ID])
@ -415,7 +415,7 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
removeExistingFriend(); removeExistingFriend();
m_processing = true; m_processing = true;
m_options_widget->setDeactivated(); m_options_widget->setActive(false);
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
else if(selection == m_accept_widget->m_properties[PROP_ID]) 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() void UserInfoDialog::deactivate()
{ {
m_options_widget->setDeactivated(); m_options_widget->setActive(false);
} // deactivate } // 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->addParameter("addonid", addon_id.substr(6));
m_fetch_vote_request->queue(); m_fetch_vote_request->queue();
m_rating_widget->setDeactivated(); m_rating_widget->setActive(false);
m_cancel_widget->setDeactivated(); m_cancel_widget->setActive(false);
} // VoteDialog } // VoteDialog
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -123,8 +123,8 @@ void VoteDialog::sendVote()
m_perform_vote_request->addParameter("rating", m_rating_widget->getRating()); m_perform_vote_request->addParameter("rating", m_rating_widget->getRating());
m_perform_vote_request->queue(); m_perform_vote_request->queue();
m_rating_widget->setDeactivated(); m_rating_widget->setActive(false);
m_cancel_widget->setDeactivated(); m_cancel_widget->setActive(false);
} // sendVote } // sendVote
@ -196,15 +196,15 @@ void VoteDialog::updateFetchVote()
"Select your desired rating by clicking " "Select your desired rating by clicking "
"the stars beneath"), false); "the stars beneath"), false);
} }
m_cancel_widget->setActivated(); m_cancel_widget->setActive(true);
m_rating_widget->setActivated(); m_rating_widget->setActive(true);
} // isSuccess } // isSuccess
else else
{ {
SFXManager::get()->quickSound("anvil"); SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor(); m_info_widget->setErrorColor();
m_info_widget->setText(m_fetch_vote_request->getInfo(), false); m_info_widget->setText(m_fetch_vote_request->getInfo(), false);
m_cancel_widget->setActivated(); m_cancel_widget->setActive(true);
} // !isSuccess } // !isSuccess
delete m_fetch_vote_request; delete m_fetch_vote_request;
@ -229,15 +229,15 @@ void VoteDialog::onUpdate(float dt)
m_info_widget->setDefaultColor(); m_info_widget->setDefaultColor();
m_info_widget->setText(_("Vote successful! You can now close " m_info_widget->setText(_("Vote successful! You can now close "
"the window."), false); "the window."), false);
m_cancel_widget->setActivated(); m_cancel_widget->setActive(true);
} // isSuccess } // isSuccess
else else
{ {
SFXManager::get()->quickSound( "anvil" ); SFXManager::get()->quickSound( "anvil" );
m_info_widget->setErrorColor(); m_info_widget->setErrorColor();
m_info_widget->setText(m_perform_vote_request->getInfo(), false); m_info_widget->setText(m_perform_vote_request->getInfo(), false);
m_cancel_widget->setActivated(); m_cancel_widget->setActive(true);
m_rating_widget->setActivated(); m_rating_widget->setActive(true);
} // !isSuccess } // !isSuccess
delete m_perform_vote_request; delete m_perform_vote_request;
m_perform_vote_request = NULL; m_perform_vote_request = NULL;

View File

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

View File

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

View File

@ -230,7 +230,7 @@ void GPInfoScreen::init()
getWidget<LabelWidget>("ai-text")->setVisible(has_AI); getWidget<LabelWidget>("ai-text")->setVisible(has_AI);
if (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 // 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. // 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(remove_button != NULL);
assert(rename_button != NULL); assert(rename_button != NULL);
if (m_selection != NULL && m_selection->getNumberOfTracks() > 0) bool b = m_selection && m_selection->getNumberOfTracks() > 0;
copy_button->setActivated(); copy_button->setActive(b);
else
copy_button->setDeactivated();
if (m_selection != NULL && m_selection->isEditable()) b = m_selection && m_selection->isEditable();
{ edit_button->setActive(b);
edit_button->setActivated(); remove_button->setActive(b);
remove_button->setActivated(); rename_button->setActive(b);
rename_button->setActivated();
}
else
{
edit_button->setDeactivated();
remove_button->setDeactivated();
rename_button->setDeactivated();
}
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

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

View File

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

View File

@ -125,7 +125,7 @@ void MainMenuScreen::init()
if (addons_manager->isLoading()) if (addons_manager->isLoading())
{ {
IconButtonWidget* w = getWidget<IconButtonWidget>("addons"); IconButtonWidget* w = getWidget<IconButtonWidget>("addons");
w->setDeactivated(); w->setActive(false);
w->resetAllBadges(); w->resetAllBadges();
w->setBadge(LOADING_BADGE); w->setBadge(LOADING_BADGE);
} }
@ -133,7 +133,7 @@ void MainMenuScreen::init()
m_online = getWidget<IconButtonWidget>("online"); m_online = getWidget<IconButtonWidget>("online");
if(!m_enable_online) if(!m_enable_online)
m_online->setDeactivated(); m_online->setActive(false);
LabelWidget* w = getWidget<LabelWidget>("info_addons"); LabelWidget* w = getWidget<LabelWidget>("info_addons");
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage(); const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
@ -166,19 +166,19 @@ void MainMenuScreen::onUpdate(float delta)
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN) PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
{ {
m_user_id->setText(player->getLastOnlineName() + "@stk"); m_user_id->setText(player->getLastOnlineName() + "@stk");
m_online->setActivated(); m_online->setActive(true);
m_online->setLabel( _("Online")); m_online->setLabel( _("Online"));
} }
else if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_OUT) else if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_OUT)
{ {
m_online->setActivated(); m_online->setActive(true);
m_online->setLabel( _("Login" )); m_online->setLabel( _("Login" ));
m_user_id->setText(player->getName()); m_user_id->setText(player->getName());
} }
else else
{ {
// now must be either logging in or logging out // now must be either logging in or logging out
m_online->setDeactivated(); m_online->setActive(false);
m_user_id->setText(player->getName()); m_user_id->setText(player->getName());
} }
@ -189,7 +189,7 @@ void MainMenuScreen::onUpdate(float delta)
{ {
if (addons_manager->wasError()) if (addons_manager->wasError())
{ {
addons_icon->setActivated(); addons_icon->setActive(true);
addons_icon->resetAllBadges(); addons_icon->resetAllBadges();
addons_icon->setBadge(BAD_BADGE); addons_icon->setBadge(BAD_BADGE);
} }
@ -197,13 +197,13 @@ void MainMenuScreen::onUpdate(float delta)
== Online::RequestManager::IPERM_ALLOWED) == Online::RequestManager::IPERM_ALLOWED)
{ {
// Addons manager is still initialising/downloading. // Addons manager is still initialising/downloading.
addons_icon->setDeactivated(); addons_icon->setActive(false);
addons_icon->resetAllBadges(); addons_icon->resetAllBadges();
addons_icon->setBadge(LOADING_BADGE); addons_icon->setBadge(LOADING_BADGE);
} }
else else
{ {
addons_icon->setActivated(); addons_icon->setActive(true);
addons_icon->resetAllBadges(); addons_icon->resetAllBadges();
} }
// maybe add a new badge when not allowed to access the net // 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"); RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
assert( tabs != NULL ); assert( tabs != NULL );
tabs->select( "standard", PLAYER_ID_GAME_MASTER); // select standard kart group tabs->select( "standard", PLAYER_ID_GAME_MASTER); // select standard kart group
tabs->setDeactivated(); tabs->setActive(false);
tabs->setVisible(false); tabs->setVisible(false);
// change the back button image (because it makes the game quit) // 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_IN ||
m_recorded_state == PlayerProfile::OS_SIGNING_OUT) m_recorded_state == PlayerProfile::OS_SIGNING_OUT)
{ {
m_quick_play_widget->setDeactivated(); m_quick_play_widget->setActive(false);
m_find_server_widget->setDeactivated(); m_find_server_widget->setActive(false);
m_create_server_widget->setDeactivated(); m_create_server_widget->setActive(false);
m_sign_out_widget->setVisible(false); m_sign_out_widget->setVisible(false);
m_profile_widget->setVisible(false); m_profile_widget->setVisible(false);
} }
else if (m_recorded_state == PlayerProfile::OS_GUEST) else if (m_recorded_state == PlayerProfile::OS_GUEST)
{ {
m_find_server_widget->setDeactivated(); m_find_server_widget->setActive(false);
m_create_server_widget->setDeactivated(); m_create_server_widget->setActive(false);
m_profile_widget->setVisible(false); m_profile_widget->setVisible(false);
} }

View File

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

View File

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

View File

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

View File

@ -89,7 +89,7 @@ void OptionsScreenUI::loadedFromFile()
{ {
Log::warn("OptionsScreenUI", "Could not find a single skin, make sure that " Log::warn("OptionsScreenUI", "Could not find a single skin, make sure that "
"the data files are correctly installed"); "the data files are correctly installed");
skinSelector->setDeactivated(); skinSelector->setActive(false);
return; return;
} }
@ -211,14 +211,7 @@ void OptionsScreenUI::init()
// Forbid changing language while in-game, since this crashes (changing the language involves // 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) // tearing down and rebuilding the menu stack. not good when in-game)
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) list_widget->setActive(StateManager::get()->getGameState() != GUIEngine::INGAME_MENU);
{
list_widget->setDeactivated();
}
else
{
list_widget->setActivated();
}
} // init } // init

View File

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

View File

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

View File

@ -326,7 +326,7 @@ void RegisterScreen::doRegister()
*/ */
void RegisterScreen::acceptTerms() void RegisterScreen::acceptTerms()
{ {
m_options_widget->setDeactivated(); m_options_widget->setActive(false);
core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim(); core::stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
core::stringw password = m_password_widget->getText().trim(); core::stringw password = m_password_widget->getText().trim();
@ -374,7 +374,7 @@ void RegisterScreen::onUpdate(float dt)
} }
delete m_signup_request; delete m_signup_request;
m_signup_request = NULL; m_signup_request = NULL;
m_options_widget->setActivated(); m_options_widget->setActive(true);
} }
} }
else if(m_info_message_shown && !ModalDialog::isADialogActive()) 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("spacer", L"");
m_server_list_widget->addItem("loading", m_server_list_widget->addItem("loading",
StringUtils::loadingDots(_("Fetching servers"))); 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; delete m_refresh_request;
m_refresh_request = NULL; m_refresh_request = NULL;
m_reload_widget->setActivated(); m_reload_widget->setActive(true);
} }
else else
{ {
@ -214,6 +214,6 @@ void ServerSelection::onUpdate(float dt)
{ {
loadList(); loadList();
m_fake_refresh = false; m_fake_refresh = false;
m_reload_widget->setActivated(); m_reload_widget->setActive(true);
} }
} // onUpdate } // onUpdate

View File

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

View File

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