use parent to remove copy+paste code
This commit is contained in:
@@ -16,12 +16,16 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "modes/cutscene_world.hpp"
|
||||
#include "states_screens/grand_prix_cutscene.hpp"
|
||||
|
||||
typedef GUIEngine::ButtonWidget Button;
|
||||
|
||||
/** A Button to save the GP if it was a random one */
|
||||
void GrandPrixCutscene::saveGPButton()
|
||||
{
|
||||
#ifdef IMPLEMENTATION_FINISHED
|
||||
if (race_manager->getGrandPrix().getId() == "random")
|
||||
{
|
||||
core::stringw text = _("Save Grand Prix");
|
||||
@@ -36,4 +40,37 @@ void GrandPrixCutscene::saveGPButton()
|
||||
save_button->add();
|
||||
manualAddWidget(save_button);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // saveGPButton
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void GrandPrixCutscene::eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
if (name == "continue")
|
||||
{
|
||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||
}
|
||||
else if (name == "save_gp")
|
||||
{
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool GrandPrixCutscene::onEscapePressed()
|
||||
{
|
||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||
return false;
|
||||
} // onEscapePressed
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixCutscene::tearDown()
|
||||
{
|
||||
Screen::tearDown();
|
||||
} // tearDown
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@ public:
|
||||
GrandPrixCutscene(const char * filename) : CutsceneScreen(filename) {}
|
||||
protected:
|
||||
void saveGPButton();
|
||||
|
||||
// implement callbacks from parent class GUIEngine::Screen
|
||||
void eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
bool onEscapePressed() OVERRIDE;
|
||||
void tearDown() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -109,14 +109,6 @@ void GrandPrixLose::onCutsceneEnd()
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
bool GrandPrixLose::onEscapePressed()
|
||||
{
|
||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||
return false;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixLose::loadedFromFile()
|
||||
{
|
||||
m_kart_node[0] = NULL;
|
||||
@@ -138,22 +130,7 @@ void GrandPrixLose::init()
|
||||
|
||||
World::getWorld()->setPhase(WorldStatus::RACE_PHASE);
|
||||
|
||||
if (race_manager->getGrandPrix().getId() == "random")
|
||||
{
|
||||
core::stringw text = _("Save Grand Prix");
|
||||
|
||||
typedef GUIEngine::ButtonWidget Button;
|
||||
Button* save_button = new Button();
|
||||
save_button->m_properties[GUIEngine::PROP_ID] = "save gp";
|
||||
Button* c = getWidget<Button>("continue");
|
||||
save_button->m_x = c->m_x + c->m_w + 20;
|
||||
save_button->m_y = c->m_y;
|
||||
save_button->m_w = GUIEngine::getFont()->getDimension(text.c_str()).Width + 30;
|
||||
save_button->m_h = c->m_h;
|
||||
save_button->setText(text);
|
||||
save_button->add();
|
||||
manualAddWidget(save_button);
|
||||
}
|
||||
saveGPButton();
|
||||
|
||||
m_phase = 1;
|
||||
m_global_time = 0.0f;
|
||||
@@ -161,13 +138,6 @@ void GrandPrixLose::init()
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixLose::tearDown()
|
||||
{
|
||||
Screen::tearDown();
|
||||
} // tearDown
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixLose::onUpdate(float dt)
|
||||
{
|
||||
m_global_time += dt;
|
||||
@@ -207,21 +177,6 @@ void GrandPrixLose::onUpdate(float dt)
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixLose::eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
if (name == "continue")
|
||||
{
|
||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||
}
|
||||
else if (name == "save_gp")
|
||||
{
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
|
||||
{
|
||||
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
|
||||
|
||||
@@ -57,8 +57,6 @@ class GrandPrixLose :
|
||||
public:
|
||||
virtual void onCutsceneEnd() OVERRIDE;
|
||||
|
||||
virtual bool onEscapePressed() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile() OVERRIDE;
|
||||
|
||||
@@ -68,13 +66,6 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void init() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void tearDown() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
|
||||
/** \brief set which karts lost this GP */
|
||||
void setKarts(std::vector<std::string> ident);
|
||||
};
|
||||
|
||||
@@ -182,22 +182,7 @@ void GrandPrixWin::init()
|
||||
{
|
||||
m_unlocked_label = NULL;
|
||||
|
||||
if (race_manager->getGrandPrix().getId() == "random")
|
||||
{
|
||||
core::stringw text = _("Save Grand Prix");
|
||||
|
||||
typedef GUIEngine::ButtonWidget Button;
|
||||
Button* save_button = new Button();
|
||||
save_button->m_properties[GUIEngine::PROP_ID] = "save gp";
|
||||
Button* c = getWidget<Button>("continue");
|
||||
save_button->m_x = c->m_x + c->m_w + 20;
|
||||
save_button->m_y = c->m_y;
|
||||
save_button->m_w = GUIEngine::getFont()->getDimension(text.c_str()).Width + 30;
|
||||
save_button->m_h = c->m_h;
|
||||
save_button->setText(text);
|
||||
save_button->add();
|
||||
manualAddWidget(save_button);
|
||||
}
|
||||
saveGPButton();
|
||||
}
|
||||
|
||||
m_global_time = 0.0f;
|
||||
@@ -208,21 +193,6 @@ void GrandPrixWin::init()
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
bool GrandPrixWin::onEscapePressed()
|
||||
{
|
||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||
return false;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixWin::tearDown()
|
||||
{
|
||||
Screen::tearDown();
|
||||
} // tearDown
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixWin::onUpdate(float dt)
|
||||
{
|
||||
m_global_time += dt;
|
||||
@@ -338,20 +308,6 @@ void GrandPrixWin::onUpdate(float dt)
|
||||
true/* center h */, true /* center v */ );
|
||||
} // onUpdate
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixWin::eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
if (name == "continue")
|
||||
{
|
||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||
}
|
||||
else if (name == "save_gp")
|
||||
{
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -64,8 +64,6 @@ public:
|
||||
|
||||
virtual void onCutsceneEnd() OVERRIDE;
|
||||
|
||||
virtual bool onEscapePressed() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile() OVERRIDE {};
|
||||
|
||||
@@ -75,13 +73,6 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void init() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void tearDown() OVERRIDE;
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
|
||||
/** \pre must be called after pushing the screen, but before onUpdate had the chance to be invoked */
|
||||
void setKarts(const std::string idents[3]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user