diff --git a/src/achievements/achievement.cpp b/src/achievements/achievement.cpp index 29f9bc2d8..c01a5b4d4 100644 --- a/src/achievements/achievement.cpp +++ b/src/achievements/achievement.cpp @@ -24,7 +24,6 @@ #include "guiengine/message_queue.hpp" #include "io/utf_writer.hpp" #include "config/player_manager.hpp" -#include "states_screens/dialogs/notification_dialog.hpp" #include "utils/log.hpp" #include "utils/translation.hpp" diff --git a/src/online/online_player_profile.cpp b/src/online/online_player_profile.cpp index 35865396c..73d6682a9 100644 --- a/src/online/online_player_profile.cpp +++ b/src/online/online_player_profile.cpp @@ -29,7 +29,6 @@ #include "states_screens/online_profile_friends.hpp" #include "states_screens/user_screen.hpp" #include "states_screens/dialogs/change_password_dialog.hpp" -#include "states_screens/dialogs/notification_dialog.hpp" #include "states_screens/dialogs/user_info_dialog.hpp" #include "utils/log.hpp" #include "utils/translation.hpp" diff --git a/src/states_screens/dialogs/notification_dialog.cpp b/src/states_screens/dialogs/notification_dialog.cpp deleted file mode 100644 index f0ada72b7..000000000 --- a/src/states_screens/dialogs/notification_dialog.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2013 Glenn De Jonghe -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include "states_screens/dialogs/notification_dialog.hpp" - -#include - -#include "config/player_manager.hpp" -#include "guiengine/engine.hpp" -#include "states_screens/state_manager.hpp" -#include "states_screens/online_profile_achievements.hpp" -#include "states_screens/online_profile_friends.hpp" -#include "utils/translation.hpp" - - -using namespace GUIEngine; -using namespace irr; -using namespace irr::gui; -using namespace Online; - -// ----------------------------------------------------------------------------- - -NotificationDialog::NotificationDialog(Type type, const core::stringw &info) - : ModalDialog(0.8f,0.5f) -{ - m_info = info; - m_type = type; -} - -void NotificationDialog::load() -{ - loadFromFile("online/notification_dialog.stkgui"); -} - -void NotificationDialog::beforeAddingWidgets() -{ - m_self_destroy = false; - m_view = false; - m_info_widget = getWidget("info"); - assert(m_info_widget != NULL); - m_info_widget->setText(m_info, false); - m_options_widget = getWidget("options"); - assert(m_options_widget != NULL); - m_view_widget = getWidget("view"); - assert(m_view_widget != NULL); - if(m_type == T_Friends) - { - m_view_widget->setText(_("View Friends")); - } - else if (m_type == T_Achievements) - { - m_view_widget->setText(_("View Achievements")); - } - m_cancel_widget = getWidget("cancel"); - assert(m_cancel_widget != NULL); - m_options_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER); -} - - - -// ----------------------------------------------------------------------------- -NotificationDialog::~NotificationDialog() -{ -} - -// ----------------------------------------------------------------------------- -GUIEngine::EventPropagation NotificationDialog::processEvent(const std::string& eventSource) -{ - - if (eventSource == m_options_widget->m_properties[PROP_ID]) - { - const std::string& selection = m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (selection == m_cancel_widget->m_properties[PROP_ID]) - { - m_self_destroy = true; - return GUIEngine::EVENT_BLOCK; - } - else if(selection == m_view_widget->m_properties[PROP_ID]) - { - m_view = true; - return GUIEngine::EVENT_BLOCK; - } - } - return GUIEngine::EVENT_LET; -} - -// ----------------------------------------------------------------------------- - -void NotificationDialog::onEnterPressedInternal() -{ - - //If enter was pressed while none of the buttons was focused interpret as close - const int playerID = PLAYER_ID_GAME_MASTER; - if (GUIEngine::isFocusedForPlayer(m_options_widget, playerID)) - return; - m_self_destroy = true; -} - -// ----------------------------------------------------------------------------- - -bool NotificationDialog::onEscapePressed() -{ - if (m_cancel_widget->isActivated()) - m_self_destroy = true; - return false; -} - -// ----------------------------------------------------------------------------- - -void NotificationDialog::onUpdate(float dt) -{ - //If we want to open the registration dialog, we need to close this one first - if (m_view) m_self_destroy = true; - - // It's unsafe to delete from inside the event handler so we do it here - if (m_self_destroy) - { - // Since dismiss deletes this object, store the instance values which - // we still need - bool view = m_view; - NotificationDialog::Type type = m_type; - ModalDialog::dismiss(); - if (view) - { - if(type == T_Friends) - { - ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); - OnlineProfileFriends::getInstance()->push(); - } - else if (type == T_Achievements) - { - ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); - OnlineProfileAchievements::getInstance()->push(); - } - } - return; - } -} diff --git a/src/states_screens/dialogs/notification_dialog.hpp b/src/states_screens/dialogs/notification_dialog.hpp deleted file mode 100644 index fd4b62faf..000000000 --- a/src/states_screens/dialogs/notification_dialog.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2013 Glenn De Jonghe -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef HEADER_NOTIFICATION_DIALOG_HPP -#define HEADER_NOTIFICATION_DIALOG_HPP - -#include "guiengine/modaldialog.hpp" -#include "guiengine/widgets.hpp" -#include "utils/types.hpp" - -#include - - -/** - * \brief Dialog that allows a user to sign in - * \ingroup states_screens - */ -class NotificationDialog : public GUIEngine::ModalDialog -{ -public: - enum Type - { - T_Friends = 1, - T_Achievements = 2 - }; - -private: - bool m_self_destroy; - bool m_view; - Type m_type; - irr::core::stringw m_info; - - GUIEngine::LabelWidget * m_info_widget; - - GUIEngine::RibbonWidget * m_options_widget; - GUIEngine::IconButtonWidget * m_view_widget; - GUIEngine::IconButtonWidget * m_cancel_widget; - -public: - NotificationDialog(Type type, const core::stringw &info); - ~NotificationDialog(); - - virtual void beforeAddingWidgets(); - virtual void load(); - - void onEnterPressedInternal(); - GUIEngine::EventPropagation processEvent(const std::string& eventSource); - - virtual bool onEscapePressed(); - virtual void onUpdate(float dt); -}; - -#endif