From 6e20eac366ed99df08b13915219fc0c57f0b9b67 Mon Sep 17 00:00:00 2001 From: funto66 Date: Sat, 19 Jan 2013 14:52:40 +0000 Subject: [PATCH] Added an instructions message when connecting wiimotes git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12390 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- .../dialogs/add_device_dialog.cpp | 63 ++++++++++--------- .../dialogs/add_device_dialog.hpp | 7 +-- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/states_screens/dialogs/add_device_dialog.cpp b/src/states_screens/dialogs/add_device_dialog.cpp index 692bed140..5f3b9c824 100644 --- a/src/states_screens/dialogs/add_device_dialog.cpp +++ b/src/states_screens/dialogs/add_device_dialog.cpp @@ -24,9 +24,11 @@ #include "guiengine/widgets/button_widget.hpp" #include "input/device_manager.hpp" #include "input/input_manager.hpp" +#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/options_screen_players.hpp" #include "states_screens/options_screen_input.hpp" #include "states_screens/state_manager.hpp" +#include "utils/cpp2011.h" #include "utils/string_utils.hpp" #include "utils/translation.hpp" #include "input/wiimote_manager.hpp" @@ -150,7 +152,36 @@ void AddDeviceDialog::onEnterPressedInternal() } // onEnterPressedInternal // ---------------------------------------------------------------------------- +#ifdef ENABLE_WIIUSE +class WiimoteDialogListener : public MessageDialog::IConfirmDialogListener +{ +public: + virtual void onConfirm() OVERRIDE + { + ModalDialog::dismiss(); + + wiimote_manager->launchDetection(5); + + int nb_wiimotes = wiimote_manager->getNbWiimotes(); + if(nb_wiimotes > 0) + { + core::stringw msg = StringUtils::insertValues( + _("Found %d wiimote(s)"), + core::stringw(nb_wiimotes)); + + new MessageDialog( msg ); + + ((OptionsScreenInput*)GUIEngine::getCurrentScreen())->rebuildDeviceList(); + } + else + { + new MessageDialog( _("Could not detect any wiimote :/") ); + } + } +}; +#endif +// ---------------------------------------------------------------------------- GUIEngine::EventPropagation AddDeviceDialog::processEvent (const std::string& eventSource) { @@ -173,38 +204,12 @@ GUIEngine::EventPropagation AddDeviceDialog::processEvent #ifdef ENABLE_WIIUSE else if (eventSource == "addwiimote") { - //new MessageDialog( _("Press the buttons 1+2 of your wiimote..."), MessageDialog::MESSAGE_DIALOG_OK, this, false); - //new MessageDialog( _("Press the buttons 1+2 of your wiimote...")); - - wiimote_manager->launchDetection(5); - - int nb_wiimotes = wiimote_manager->getNbWiimotes(); - if(nb_wiimotes > 0) - { - core::stringw msg = StringUtils::insertValues( - _("Found %d wiimote(s)"), - core::stringw(nb_wiimotes)); - - new MessageDialog( msg ); - - ((OptionsScreenInput*)GUIEngine::getCurrentScreen())->rebuildDeviceList(); - } - else - { - new MessageDialog( _("Could not detect any wiimote :/") ); - } - + new MessageDialog( _("Press the buttons 1+2 simultaneously on your wiimote to put " + "it in discovery mode, then click on OK."), + MessageDialog::MESSAGE_DIALOG_CONFIRM, new WiimoteDialogListener(), true); return GUIEngine::EVENT_BLOCK; } #endif return GUIEngine::EVENT_LET; } // processEvent - -// ---------------------------------------------------------------------------- - -void AddDeviceDialog::onConfirm() -{ - ModalDialog::dismiss(); - printf("TEST\n"); -} diff --git a/src/states_screens/dialogs/add_device_dialog.hpp b/src/states_screens/dialogs/add_device_dialog.hpp index 92aed44bb..d5b67f81e 100644 --- a/src/states_screens/dialogs/add_device_dialog.hpp +++ b/src/states_screens/dialogs/add_device_dialog.hpp @@ -21,16 +21,13 @@ #include "config/player.hpp" #include "guiengine/modaldialog.hpp" -#include "states_screens/dialogs/message_dialog.hpp" -#include "utils/cpp2011.h" /** * \brief Dialog that warns the user about the potential problems of * creating multiple keyboard configs. * \ingroup states_screens */ -class AddDeviceDialog : public GUIEngine::ModalDialog, - public MessageDialog::IConfirmDialogListener +class AddDeviceDialog : public GUIEngine::ModalDialog { public: @@ -38,8 +35,6 @@ public: void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); - - virtual void onConfirm() OVERRIDE; };