Fix crash when coming for the second time to the soccer setup screen
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/christmas@12436 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e1bf43149e
commit
03f063ce6d
@ -21,6 +21,7 @@
|
||||
<roundedbox x="2%" y="5%" proportion="1" layout="horizontal-row" height="100%">
|
||||
<!-- Content is added programmatically -->
|
||||
</roundedbox>
|
||||
<header id="vs" text="VS"/>
|
||||
</div>
|
||||
|
||||
<button id="continue" I18N="In soccer setup screen" text="Continue" align="center" width="60%"/>
|
||||
|
@ -76,13 +76,11 @@ void SoccerSetupScreen::beforeAddingWidget()
|
||||
const int center_y = central_div->m_y + central_div->m_h/2;
|
||||
|
||||
// Add "VS" label at the center of the rounded box
|
||||
m_label_vs = new LabelWidget(true, false);
|
||||
m_label_vs->m_x = center_x - vs_width/2;
|
||||
m_label_vs->m_y = center_y - vs_height/2;
|
||||
m_label_vs->m_w = vs_width;
|
||||
m_label_vs->m_h = vs_height;
|
||||
|
||||
central_div->getChildren().push_back(m_label_vs);
|
||||
LabelWidget* label_vs = getWidget<LabelWidget>("vs");
|
||||
label_vs->m_x = center_x - vs_width/2;
|
||||
label_vs->m_y = center_y - vs_height/2;
|
||||
label_vs->m_w = vs_width;
|
||||
label_vs->m_h = vs_height;
|
||||
|
||||
// Add the 3D views for the karts
|
||||
int nb_players = race_manager->getNumLocalPlayers();
|
||||
@ -147,14 +145,28 @@ void SoccerSetupScreen::init()
|
||||
bt_continue->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
bt_continue->setDeactivated();
|
||||
|
||||
// "VS" (needs to be done here for the Irrlicht element to be here)
|
||||
m_label_vs->setText("VS", true);
|
||||
|
||||
// We need players to be able to choose their teams
|
||||
input_manager->getDeviceList()->setAssignMode(ASSIGN);
|
||||
input_manager->setMasterPlayerOnly(false);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void SoccerSetupScreen::tearDown()
|
||||
{
|
||||
Widget* central_div = getWidget<Widget>("central_div");
|
||||
|
||||
// Remove all ModelViewWidgets we created manually
|
||||
PtrVector<Widget>& children = central_div->getChildren();
|
||||
for(int i = children.size()-1 ; i >= 0 ; i--)
|
||||
{
|
||||
if(children[i].getType() == WTYPE_MODEL_VIEW)
|
||||
children.erase(i);
|
||||
}
|
||||
m_kart_view_info.clear();
|
||||
|
||||
Screen::tearDown();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
GUIEngine::EventPropagation SoccerSetupScreen::filterActions( PlayerAction action,
|
||||
int deviceID,
|
||||
@ -263,7 +275,8 @@ void SoccerSetupScreen::updateKartViewsLayout()
|
||||
Widget* central_div = getWidget<Widget>("central_div");
|
||||
|
||||
// Compute/get some dimensions
|
||||
const int vs_width = m_label_vs->m_w;
|
||||
LabelWidget* label_vs = getWidget<LabelWidget>("vs");
|
||||
const int vs_width = label_vs->m_w;
|
||||
const int nb_columns = 2; // two karts maximum per column
|
||||
const int kart_area_width = (central_div->m_w - vs_width) / 2; // size of one half of the screen
|
||||
const int kart_view_size = kart_area_width/nb_columns; // Size (width and height) of a kart view
|
||||
|
@ -33,9 +33,6 @@ class SoccerSetupScreen : public GUIEngine::Screen, public GUIEngine::ScreenSing
|
||||
|
||||
SoccerSetupScreen();
|
||||
|
||||
/** The "VS" text at the center of the screen */
|
||||
GUIEngine::LabelWidget* m_label_vs;
|
||||
|
||||
struct KartViewInfo
|
||||
{
|
||||
GUIEngine::ModelViewWidget* view;
|
||||
@ -63,6 +60,9 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void init() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void tearDown() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual GUIEngine::EventPropagation filterActions( PlayerAction action,
|
||||
int deviceID,
|
||||
|
Loading…
Reference in New Issue
Block a user