[_GSoC Uni_] 'Screen' has now a callback 'onDialogClose' which gets called by 'ModalDialog' after being dismissed. (Also removed a debug line in RibbonWidget)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13048 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
965a429bca
commit
a6b492129e
@ -187,6 +187,7 @@ void ModalDialog::dismiss()
|
|||||||
{
|
{
|
||||||
if(modalWindow != NULL) delete modalWindow;
|
if(modalWindow != NULL) delete modalWindow;
|
||||||
modalWindow = NULL;
|
modalWindow = NULL;
|
||||||
|
GUIEngine::getCurrentScreen()->onDialogClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -302,6 +302,10 @@ namespace GUIEngine
|
|||||||
int axisDir,
|
int axisDir,
|
||||||
int value) {}
|
int value) {}
|
||||||
|
|
||||||
|
/** Callback that gets called when a dialog is closed.
|
||||||
|
* Can be used to set focus for instance.
|
||||||
|
*/
|
||||||
|
virtual void onDialogClose() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,6 @@ void RibbonWidget::select(std::string item, const int mousePlayerID)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
EventPropagation RibbonWidget::rightPressed(const int playerID)
|
EventPropagation RibbonWidget::rightPressed(const int playerID)
|
||||||
{
|
{
|
||||||
Log::info("RibbonWidget", "Right Pressed");
|
|
||||||
if (m_deactivated) return EVENT_LET;
|
if (m_deactivated) return EVENT_LET;
|
||||||
// empty ribbon, or only one item (can't move right)
|
// empty ribbon, or only one item (can't move right)
|
||||||
if (m_active_children.size() < 2) return EVENT_LET;
|
if (m_active_children.size() < 2) return EVENT_LET;
|
||||||
|
@ -40,7 +40,6 @@ LoginDialog::LoginDialog(const Message message_type) :
|
|||||||
{
|
{
|
||||||
m_self_destroy = false;
|
m_self_destroy = false;
|
||||||
m_open_registration_dialog = false;
|
m_open_registration_dialog = false;
|
||||||
m_reshow_current_screen = false;
|
|
||||||
loadFromFile("online/login_dialog.stkgui");
|
loadFromFile("online/login_dialog.stkgui");
|
||||||
|
|
||||||
m_info_widget = getWidget<LabelWidget>("info");
|
m_info_widget = getWidget<LabelWidget>("info");
|
||||||
@ -105,7 +104,6 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
|
|||||||
stringw info = "";
|
stringw info = "";
|
||||||
if(CurrentOnlineUser::get()->signIn(username,password,info))
|
if(CurrentOnlineUser::get()->signIn(username,password,info))
|
||||||
{
|
{
|
||||||
m_reshow_current_screen = true;
|
|
||||||
m_self_destroy = true;
|
m_self_destroy = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -128,7 +126,7 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
|
|||||||
|
|
||||||
void LoginDialog::onEnterPressedInternal()
|
void LoginDialog::onEnterPressedInternal()
|
||||||
{
|
{
|
||||||
//If enter was pressed while "cancel" nor "signup" was selected, then interpret as "signin" press.
|
//If enter was pressed while none of the other widgets are focused, then interpret as "signin" press.
|
||||||
const int playerID = PLAYER_ID_GAME_MASTER;
|
const int playerID = PLAYER_ID_GAME_MASTER;
|
||||||
if (!GUIEngine::isFocusedForPlayer(m_recovery_widget, playerID) &&
|
if (!GUIEngine::isFocusedForPlayer(m_recovery_widget, playerID) &&
|
||||||
!GUIEngine::isFocusedForPlayer(m_register_widget, playerID) &&
|
!GUIEngine::isFocusedForPlayer(m_register_widget, playerID) &&
|
||||||
@ -150,14 +148,6 @@ void LoginDialog::onUpdate(float dt)
|
|||||||
if (m_self_destroy)
|
if (m_self_destroy)
|
||||||
{
|
{
|
||||||
ModalDialog::dismiss();
|
ModalDialog::dismiss();
|
||||||
if (m_reshow_current_screen)
|
|
||||||
/*Replaced to online state screen. Not 100% how I will handle this.
|
|
||||||
* Thee options :
|
|
||||||
* - Listener
|
|
||||||
* - Directly calling GUIEngine::reshowCurrentScreen(); (old option)
|
|
||||||
* - Underlying stateschreen is responsible for polling changed state (current option)
|
|
||||||
*/
|
|
||||||
true;//GUIEngine::reshowCurrentScreen();
|
|
||||||
if (m_open_registration_dialog)
|
if (m_open_registration_dialog)
|
||||||
new RegistrationDialog(0.8f, 0.9f);
|
new RegistrationDialog(0.8f, 0.9f);
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ private:
|
|||||||
|
|
||||||
bool m_self_destroy;
|
bool m_self_destroy;
|
||||||
bool m_open_registration_dialog;
|
bool m_open_registration_dialog;
|
||||||
bool m_reshow_current_screen;
|
|
||||||
|
|
||||||
GUIEngine::LabelWidget * m_info_widget;
|
GUIEngine::LabelWidget * m_info_widget;
|
||||||
GUIEngine::TextBoxWidget * m_username_widget;
|
GUIEngine::TextBoxWidget * m_username_widget;
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
#include "main_loop.hpp"
|
#include "main_loop.hpp"
|
||||||
#include "states_screens/online_screen.hpp"
|
#include "states_screens/online_screen.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
#include "states_screens/dialogs/login_dialog.hpp"
|
|
||||||
#include "states_screens/dialogs/message_dialog.hpp"
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
|
#include "states_screens/dialogs/login_dialog.hpp"
|
||||||
#include "states_screens/dialogs/registration_dialog.hpp"
|
#include "states_screens/dialogs/registration_dialog.hpp"
|
||||||
#include "modes/demo_world.hpp"
|
#include "modes/demo_world.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
@ -133,12 +133,8 @@ void OnlineScreen::beforeAddingWidget()
|
|||||||
void OnlineScreen::init()
|
void OnlineScreen::init()
|
||||||
{
|
{
|
||||||
Screen::init();
|
Screen::init();
|
||||||
if(m_recorded_state == Not)
|
setInitialFocus();
|
||||||
m_bottom_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
DemoWorld::resetIdleTime(); //FIXME : what's this?
|
||||||
else
|
|
||||||
m_top_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
|
||||||
|
|
||||||
DemoWorld::resetIdleTime();
|
|
||||||
m_online_status_widget->setText(irr::core::stringw(_("Signed in as : ")) + CurrentOnlineUser::get()->getUserName() + ".", false);
|
m_online_status_widget->setText(irr::core::stringw(_("Signed in as : ")) + CurrentOnlineUser::get()->getUserName() + ".", false);
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
@ -205,7 +201,6 @@ void OnlineScreen::tearDown()
|
|||||||
} // tearDown
|
} // tearDown
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void OnlineScreen::onDisabledItemClicked(const std::string& item)
|
void OnlineScreen::onDisabledItemClicked(const std::string& item)
|
||||||
{
|
{
|
||||||
if (item == "find_server" || item =="create_server")
|
if (item == "find_server" || item =="create_server")
|
||||||
@ -217,3 +212,21 @@ void OnlineScreen::onDisabledItemClicked(const std::string& item)
|
|||||||
new LoginDialog(LoginDialog::Signing_In_Required);
|
new LoginDialog(LoginDialog::Signing_In_Required);
|
||||||
}
|
}
|
||||||
} // onDisabledItemClicked
|
} // onDisabledItemClicked
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void OnlineScreen::setInitialFocus()
|
||||||
|
{
|
||||||
|
if(m_recorded_state == Not)
|
||||||
|
m_bottom_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||||
|
else
|
||||||
|
m_top_menu_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||||
|
} // setInitialFocus
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void OnlineScreen::onDialogClose()
|
||||||
|
{
|
||||||
|
if (hasStateChanged())
|
||||||
|
GUIEngine::reshowCurrentScreen();
|
||||||
|
else
|
||||||
|
setInitialFocus();
|
||||||
|
} // onLoginDialogClose()
|
||||||
|
@ -29,7 +29,8 @@ namespace GUIEngine { class Widget; class ListWidget; }
|
|||||||
* \brief Handles the main menu
|
* \brief Handles the main menu
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
*/
|
*/
|
||||||
class OnlineScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OnlineScreen>
|
class OnlineScreen : public GUIEngine::Screen,
|
||||||
|
public GUIEngine::ScreenSingleton<OnlineScreen>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
friend class GUIEngine::ScreenSingleton<OnlineScreen>;
|
friend class GUIEngine::ScreenSingleton<OnlineScreen>;
|
||||||
@ -59,6 +60,8 @@ private:
|
|||||||
|
|
||||||
/** \brief Checks if the recorded state differs from the actual state and sets it. */
|
/** \brief Checks if the recorded state differs from the actual state and sets it. */
|
||||||
bool hasStateChanged();
|
bool hasStateChanged();
|
||||||
|
/** \brief Sets which widget has to be focused. Depends on the user state. */
|
||||||
|
void setInitialFocus();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -82,6 +85,9 @@ public:
|
|||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||||
virtual void onDisabledItemClicked(const std::string& item) OVERRIDE;
|
virtual void onDisabledItemClicked(const std::string& item) OVERRIDE;
|
||||||
|
|
||||||
|
/** \brief Implements the callback when a dialog gets closed. */
|
||||||
|
virtual void onDialogClose() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user