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
|
||||
|
||||
|
||||
|
||||
\n
|
||||
<HR>
|
||||
\section code Using the engine in code
|
||||
@ -904,6 +904,25 @@ namespace GUIEngine
|
||||
g_loaded_screens.push_back(cutscene);
|
||||
} // 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()
|
||||
{
|
||||
|
@ -195,6 +195,8 @@ namespace GUIEngine
|
||||
|
||||
/** \brief Add a screen to the list of screens known by the gui engine */
|
||||
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.
|
||||
* \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()
|
||||
{
|
||||
Screen::init();
|
||||
m_must_delete_on_back = false;
|
||||
|
||||
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
|
||||
assert( tabs != NULL );
|
||||
@ -1083,6 +1084,9 @@ void KartSelectionScreen::tearDown()
|
||||
|
||||
Screen::tearDown();
|
||||
m_kart_widgets.clearAndDeleteAll();
|
||||
|
||||
if (m_must_delete_on_back)
|
||||
GUIEngine::removeScreen(this->getName().c_str());
|
||||
} // tearDown
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1567,7 +1571,7 @@ void KartSelectionScreen::eventCallback(Widget* widget,
|
||||
else if (name == "back")
|
||||
{
|
||||
m_go_to_overworld_next = false; // valid once
|
||||
|
||||
m_must_delete_on_back = true;
|
||||
if (m_from_overworld)
|
||||
{
|
||||
m_from_overworld = false; // valid once
|
||||
@ -1606,7 +1610,7 @@ void KartSelectionScreen::setMultiplayer(bool multiplayer)
|
||||
bool KartSelectionScreen::onEscapePressed()
|
||||
{
|
||||
m_go_to_overworld_next = false; // valid once
|
||||
|
||||
m_must_delete_on_back = true; // delete the screen
|
||||
if (m_from_overworld)
|
||||
{
|
||||
m_from_overworld = false; // valid once
|
||||
|
@ -16,6 +16,9 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef KART_SELECTION_INCLUDED
|
||||
#define KART_SELECTION_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
@ -61,6 +64,7 @@ protected:
|
||||
|
||||
bool m_go_to_overworld_next;
|
||||
|
||||
bool m_must_delete_on_back; //!< To delete the screen if back is pressed
|
||||
|
||||
KartSelectionScreen();
|
||||
|
||||
@ -350,3 +354,5 @@ public:
|
||||
const irr::core::stringw& selectionText,
|
||||
const int playerID);
|
||||
}; // KartHoverListener
|
||||
|
||||
#endif
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "states_screens/credits.hpp"
|
||||
#include "states_screens/help_screen_1.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/state_manager.hpp"
|
||||
|
||||
@ -271,7 +272,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
#endif
|
||||
if (selection == "new")
|
||||
{
|
||||
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance();
|
||||
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance(); //FIXME : that was for tests
|
||||
s->setMultiplayer(false);
|
||||
s->setFromOverworld(false);
|
||||
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
|
||||
*/
|
||||
void NetworkKartSelectionScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
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
|
||||
|
@ -12,6 +12,7 @@ protected:
|
||||
virtual ~NetworkKartSelectionScreen();
|
||||
|
||||
public:
|
||||
virtual void init();
|
||||
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
};
|
||||
|
@ -180,7 +180,7 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
|
||||
{
|
||||
StateManager::get()->escapePressed();
|
||||
}
|
||||
|
||||
|
||||
} // eventCallback
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -225,7 +225,7 @@ void RaceSetupScreen::init()
|
||||
{
|
||||
w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
|
||||
}
|
||||
|
||||
|
||||
SpinnerWidget* kartamount = getWidget<SpinnerWidget>("aikartamount");
|
||||
kartamount->setActivated();
|
||||
|
||||
@ -327,13 +327,13 @@ void RaceSetupScreen::init()
|
||||
|
||||
m_mode_listener = new GameModeRibbonListener(this);
|
||||
w2->registerHoverListener(m_mode_listener);
|
||||
|
||||
|
||||
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
|
||||
{
|
||||
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
|
||||
assert(w != NULL);
|
||||
|
||||
|
||||
int index = w->findItemNamed("best");
|
||||
Widget* hardestWidget = &w->getChildren()[index];
|
||||
hardestWidget->setBadge(LOCKED_BADGE);
|
||||
|
Loading…
Reference in New Issue
Block a user