Unify random GP's ID and translatable name in a single place
This commit is contained in:
@@ -66,8 +66,8 @@ void GrandPrixData::createRandomGP(const unsigned int number_of_tracks,
|
||||
bool new_tracks)
|
||||
{
|
||||
m_filename = "Random GP - Not loaded from a file!";
|
||||
m_id = "random";
|
||||
m_name = _("Random Grand Prix");
|
||||
m_id = getRandomGPID();
|
||||
m_name = getRandomGPName();
|
||||
m_editable = false;
|
||||
m_group = GP_NONE;
|
||||
m_reverse_type = use_reverse;
|
||||
|
||||
@@ -148,25 +148,27 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** @return the (potentially translated) user-visible name of the Grand
|
||||
* Prix (apply fribidi as needed) */
|
||||
irr::core::stringw getName() const { return _LTR(m_name.c_str()); }
|
||||
irr::core::stringw getName() const { return _LTR(m_name.c_str()); }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** @return the internal indentifier of the Grand Prix (not translated) */
|
||||
const std::string& getId() const { return m_id; }
|
||||
const std::string& getId() const { return m_id; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if this GP is a random GP. */
|
||||
bool isRandomGP() const { return m_id=="random"; }
|
||||
bool isRandomGP() const { return m_id==getRandomGPID(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the filename of the grand prix xml file. */
|
||||
const std::string& getFilename() const { return m_filename; }
|
||||
const std::string& getFilename() const { return m_filename; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
enum GPGroupType getGroup() const { return m_group; }
|
||||
enum GPGroupType getGroup() const { return m_group; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
enum GPReverseType getReverseType()
|
||||
const { return m_reverse_type; }
|
||||
const { return m_reverse_type; }
|
||||
static const char* getRandomGPID() { return "random"; }
|
||||
static const wchar_t* getRandomGPName() { return _("Random Grand Prix"); }
|
||||
}; // GrandPrixData
|
||||
|
||||
#endif
|
||||
|
||||
@@ -125,7 +125,8 @@ void EnterGPNameDialog::validateName()
|
||||
label->setText(_("Name is empty."), false);
|
||||
SFXManager::get()->quickSound("anvil");
|
||||
}
|
||||
else if (grand_prix_manager->existsName(name) || name == _("Random Grand Prix"))
|
||||
else if (grand_prix_manager->existsName(name) ||
|
||||
name == GrandPrixData::getRandomGPName())
|
||||
{
|
||||
// check for duplicate names
|
||||
label->setText(_("Another grand prix with this name already exists."), false);
|
||||
|
||||
@@ -95,7 +95,7 @@ void GPInfoScreen::loadedFromFile()
|
||||
*/
|
||||
void GPInfoScreen::setGP(const std::string &gp_ident)
|
||||
{
|
||||
if(gp_ident!="random")
|
||||
if(gp_ident!=GrandPrixData::getRandomGPID())
|
||||
m_gp = *grand_prix_manager->getGrandPrix(gp_ident);
|
||||
else
|
||||
{
|
||||
@@ -172,7 +172,6 @@ void GPInfoScreen::init()
|
||||
{
|
||||
RibbonWidget *rb = getWidget<RibbonWidget>("buttons");
|
||||
rb->setLabel(1,_(L"Reload") );
|
||||
getWidget<LabelWidget>("name")->setText(_("Random Grand Prix"), false);
|
||||
std::string restart = file_manager->getAsset(FileManager::GUI, "restart.png");
|
||||
|
||||
// We have to recreate the group spinner, but a new group might have
|
||||
@@ -211,6 +210,8 @@ void GPInfoScreen::init()
|
||||
// Now create the random GP:
|
||||
m_gp.createRandomGP(m_num_tracks_spinner->getValue(),
|
||||
m_group_name, getReverse(), true);
|
||||
|
||||
getWidget<LabelWidget>("name")->setText(m_gp.getName(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ typedef GUIEngine::ButtonWidget Button;
|
||||
/** A Button to save the GP if it was a random GP */
|
||||
void GrandPrixCutscene::saveGPButton()
|
||||
{
|
||||
if (race_manager->getGrandPrix().getId() != "random")
|
||||
if (race_manager->getGrandPrix().getId() != GrandPrixData::getRandomGPID())
|
||||
getWidget<Button>("save")->setVisible(false);
|
||||
} // saveGPButton
|
||||
|
||||
|
||||
@@ -112,8 +112,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
else
|
||||
{
|
||||
GPInfoScreen *gpis = GPInfoScreen::getInstance();
|
||||
gpis->setGP( selection == "Random Grand Prix" ? "random"
|
||||
: selection);
|
||||
gpis->setGP( selection );
|
||||
gpis->push();
|
||||
}
|
||||
}
|
||||
@@ -218,8 +217,8 @@ void TracksScreen::init()
|
||||
// Random GP
|
||||
std::vector<std::string> screenshots;
|
||||
screenshots.push_back(file_manager->getAsset(FileManager::GUI, "main_help.png"));
|
||||
gps_widget->addAnimatedItem(translations->fribidize(_("Random Grand Prix")),
|
||||
"Random Grand Prix",
|
||||
gps_widget->addAnimatedItem(translations->fribidize(GrandPrixData::getRandomGPName()),
|
||||
GrandPrixData::getRandomGPID(),
|
||||
screenshots, 1.5f, 0,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user