fixing last issues with the inherited kart selection screen : the screen is now deleted when back is pressed, and re-instantiated when it's loaded again. If not, there was a problem with two screens instantiating the same '.stkgui' file. The screen is not deleted when the user clicks a kart (eg when starting normal game) to allow a working popScreen()
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13378 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
79c5fc03e9
commit
ad18d9299d
@ -485,7 +485,7 @@ namespace GUIEngine
|
|||||||
|
|
||||||
Used on divs, indicate by how many pixels to pad contents
|
Used on divs, indicate by how many pixels to pad contents
|
||||||
|
|
||||||
|
|
||||||
\n
|
\n
|
||||||
<HR>
|
<HR>
|
||||||
\section code Using the engine in code
|
\section code Using the engine in code
|
||||||
@ -904,6 +904,25 @@ namespace GUIEngine
|
|||||||
g_loaded_screens.push_back(cutscene);
|
g_loaded_screens.push_back(cutscene);
|
||||||
} // addScreenToList
|
} // addScreenToList
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void removeScreen(const char* name)
|
||||||
|
{
|
||||||
|
const int screen_amount = g_loaded_screens.size();
|
||||||
|
for(int n=0; n<screen_amount; n++)
|
||||||
|
{
|
||||||
|
if (g_loaded_screens[n].getName() == name)
|
||||||
|
{
|
||||||
|
g_current_screen = g_loaded_screens.get(n);
|
||||||
|
g_current_screen->unload();
|
||||||
|
delete g_current_screen;
|
||||||
|
g_current_screen = NULL;
|
||||||
|
g_loaded_screens.remove(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void reshowCurrentScreen()
|
void reshowCurrentScreen()
|
||||||
{
|
{
|
||||||
|
@ -195,6 +195,8 @@ namespace GUIEngine
|
|||||||
|
|
||||||
/** \brief Add a screen to the list of screens known by the gui engine */
|
/** \brief Add a screen to the list of screens known by the gui engine */
|
||||||
void addScreenToList(Screen* screen);
|
void addScreenToList(Screen* screen);
|
||||||
|
/** \brief Remove a screen from the list of screens known by the gui engine */
|
||||||
|
void removeScreen(const char* name);
|
||||||
|
|
||||||
/** \brief Low-level mean to change current screen.
|
/** \brief Low-level mean to change current screen.
|
||||||
* \note Do not use directly. Use a state manager instead to get higher-level functionnality.
|
* \note Do not use directly. Use a state manager instead to get higher-level functionnality.
|
||||||
|
@ -974,6 +974,7 @@ void KartSelectionScreen::beforeAddingWidget()
|
|||||||
void KartSelectionScreen::init()
|
void KartSelectionScreen::init()
|
||||||
{
|
{
|
||||||
Screen::init();
|
Screen::init();
|
||||||
|
m_must_delete_on_back = false;
|
||||||
|
|
||||||
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
|
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
|
||||||
assert( tabs != NULL );
|
assert( tabs != NULL );
|
||||||
@ -1083,6 +1084,9 @@ void KartSelectionScreen::tearDown()
|
|||||||
|
|
||||||
Screen::tearDown();
|
Screen::tearDown();
|
||||||
m_kart_widgets.clearAndDeleteAll();
|
m_kart_widgets.clearAndDeleteAll();
|
||||||
|
|
||||||
|
if (m_must_delete_on_back)
|
||||||
|
GUIEngine::removeScreen(this->getName().c_str());
|
||||||
} // tearDown
|
} // tearDown
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -1567,7 +1571,7 @@ void KartSelectionScreen::eventCallback(Widget* widget,
|
|||||||
else if (name == "back")
|
else if (name == "back")
|
||||||
{
|
{
|
||||||
m_go_to_overworld_next = false; // valid once
|
m_go_to_overworld_next = false; // valid once
|
||||||
|
m_must_delete_on_back = true;
|
||||||
if (m_from_overworld)
|
if (m_from_overworld)
|
||||||
{
|
{
|
||||||
m_from_overworld = false; // valid once
|
m_from_overworld = false; // valid once
|
||||||
@ -1606,7 +1610,7 @@ void KartSelectionScreen::setMultiplayer(bool multiplayer)
|
|||||||
bool KartSelectionScreen::onEscapePressed()
|
bool KartSelectionScreen::onEscapePressed()
|
||||||
{
|
{
|
||||||
m_go_to_overworld_next = false; // valid once
|
m_go_to_overworld_next = false; // valid once
|
||||||
|
m_must_delete_on_back = true; // delete the screen
|
||||||
if (m_from_overworld)
|
if (m_from_overworld)
|
||||||
{
|
{
|
||||||
m_from_overworld = false; // valid once
|
m_from_overworld = false; // valid once
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#ifndef KART_SELECTION_INCLUDED
|
||||||
|
#define KART_SELECTION_INCLUDED
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||||
@ -61,6 +64,7 @@ protected:
|
|||||||
|
|
||||||
bool m_go_to_overworld_next;
|
bool m_go_to_overworld_next;
|
||||||
|
|
||||||
|
bool m_must_delete_on_back; //!< To delete the screen if back is pressed
|
||||||
|
|
||||||
KartSelectionScreen();
|
KartSelectionScreen();
|
||||||
|
|
||||||
@ -350,3 +354,5 @@ public:
|
|||||||
const irr::core::stringw& selectionText,
|
const irr::core::stringw& selectionText,
|
||||||
const int playerID);
|
const int playerID);
|
||||||
}; // KartHoverListener
|
}; // KartHoverListener
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "states_screens/credits.hpp"
|
#include "states_screens/credits.hpp"
|
||||||
#include "states_screens/help_screen_1.hpp"
|
#include "states_screens/help_screen_1.hpp"
|
||||||
#include "states_screens/offline_kart_selection.hpp"
|
#include "states_screens/offline_kart_selection.hpp"
|
||||||
|
#include "states_screens/network_kart_selection.hpp" // FIXME : remove when not testing
|
||||||
#include "states_screens/options_screen_video.hpp"
|
#include "states_screens/options_screen_video.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
|
|
||||||
@ -271,7 +272,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
#endif
|
#endif
|
||||||
if (selection == "new")
|
if (selection == "new")
|
||||||
{
|
{
|
||||||
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance();
|
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance(); //FIXME : that was for tests
|
||||||
s->setMultiplayer(false);
|
s->setMultiplayer(false);
|
||||||
s->setFromOverworld(false);
|
s->setFromOverworld(false);
|
||||||
StateManager::get()->pushScreen( s );
|
StateManager::get()->pushScreen( s );
|
||||||
|
@ -13,11 +13,32 @@ NetworkKartSelectionScreen::~NetworkKartSelectionScreen()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkKartSelectionScreen::init()
|
||||||
|
{
|
||||||
|
KartSelectionScreen::init();
|
||||||
|
|
||||||
|
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
|
||||||
|
assert( tabs != NULL );
|
||||||
|
tabs->setVisible(false);
|
||||||
|
tabs->select( "standard", PLAYER_ID_GAME_MASTER); // select standard kart group
|
||||||
|
|
||||||
|
// change the back button image (because it makes the game quit)
|
||||||
|
IconButtonWidget* back_button = getWidget<IconButtonWidget>("back");
|
||||||
|
back_button->setImage("gui/main_quit.png");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback handling events from the kart selection menu
|
* Callback handling events from the kart selection menu
|
||||||
*/
|
*/
|
||||||
void NetworkKartSelectionScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
void NetworkKartSelectionScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||||
const int playerID)
|
const int playerID)
|
||||||
{
|
{
|
||||||
Log::info("NetworkKartSelectionScreen", "Fuck events !");
|
if (name != "karts")
|
||||||
|
{
|
||||||
|
KartSelectionScreen::eventCallback(widget, name, playerID);
|
||||||
|
}
|
||||||
|
else // name = karts
|
||||||
|
{
|
||||||
|
// must quit the server here
|
||||||
|
}
|
||||||
} // eventCallback
|
} // eventCallback
|
||||||
|
@ -12,6 +12,7 @@ protected:
|
|||||||
virtual ~NetworkKartSelectionScreen();
|
virtual ~NetworkKartSelectionScreen();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual void init();
|
||||||
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||||
const int playerID) OVERRIDE;
|
const int playerID) OVERRIDE;
|
||||||
};
|
};
|
||||||
|
@ -180,7 +180,7 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
|
|||||||
{
|
{
|
||||||
StateManager::get()->escapePressed();
|
StateManager::get()->escapePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // eventCallback
|
} // eventCallback
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -225,7 +225,7 @@ void RaceSetupScreen::init()
|
|||||||
{
|
{
|
||||||
w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
|
w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinnerWidget* kartamount = getWidget<SpinnerWidget>("aikartamount");
|
SpinnerWidget* kartamount = getWidget<SpinnerWidget>("aikartamount");
|
||||||
kartamount->setActivated();
|
kartamount->setActivated();
|
||||||
|
|
||||||
@ -327,13 +327,13 @@ void RaceSetupScreen::init()
|
|||||||
|
|
||||||
m_mode_listener = new GameModeRibbonListener(this);
|
m_mode_listener = new GameModeRibbonListener(this);
|
||||||
w2->registerHoverListener(m_mode_listener);
|
w2->registerHoverListener(m_mode_listener);
|
||||||
|
|
||||||
|
|
||||||
if (unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
|
if (unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
|
||||||
{
|
{
|
||||||
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
|
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
|
||||||
assert(w != NULL);
|
assert(w != NULL);
|
||||||
|
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user