Change message functions to no need id (random selection is internal).
Couple define became functions. TODO/DOUBT: pass them attacker & victim names? git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5435 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
f9af96667a
commit
0b14d2ef0c
@ -35,9 +35,15 @@
|
|||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
const wchar_t* getCakeString(const int n)
|
|
||||||
|
const wchar_t* getCakeString()
|
||||||
{
|
{
|
||||||
switch (n)
|
const int CAKE_STRINGS_AMOUNT = 2;
|
||||||
|
|
||||||
|
RandomGenerator r;
|
||||||
|
const int id = r.get(CAKE_STRINGS_AMOUNT);
|
||||||
|
|
||||||
|
switch (id)
|
||||||
{
|
{
|
||||||
//I18N: shown when hit by cake. %1 is the attacker, %0 is the victim.
|
//I18N: shown when hit by cake. %1 is the attacker, %0 is the victim.
|
||||||
case 0: return _("%0 eats too much of %1's cake");
|
case 0: return _("%0 eats too much of %1's cake");
|
||||||
@ -46,11 +52,16 @@ const wchar_t* getCakeString(const int n)
|
|||||||
default: assert(false);
|
default: assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int CAKE_STRINGS_AMOUNT = 2;
|
|
||||||
|
|
||||||
const wchar_t* getBowlingString(const int n)
|
|
||||||
|
const wchar_t* getBowlingString()
|
||||||
{
|
{
|
||||||
switch (n)
|
const int BOWLING_STRINGS_AMOUNT = 3;
|
||||||
|
|
||||||
|
RandomGenerator r;
|
||||||
|
const int id = r.get(BOWLING_STRINGS_AMOUNT);
|
||||||
|
|
||||||
|
switch (id)
|
||||||
{
|
{
|
||||||
//I18N: shown when hit by bowling ball. %1 is the attacker, %0 is the victim.
|
//I18N: shown when hit by bowling ball. %1 is the attacker, %0 is the victim.
|
||||||
case 0 : return _("%0 will not play bowling with %1 again");
|
case 0 : return _("%0 will not play bowling with %1 again");
|
||||||
@ -61,7 +72,7 @@ const wchar_t* getBowlingString(const int n)
|
|||||||
default: assert(false);
|
default: assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int BOWLING_STRINGS_AMOUNT = 3;
|
|
||||||
|
|
||||||
// static variables:
|
// static variables:
|
||||||
float Flyable::m_st_speed [PowerupManager::POWERUP_MAX];
|
float Flyable::m_st_speed [PowerupManager::POWERUP_MAX];
|
||||||
@ -385,9 +396,7 @@ void Flyable::hit(Kart *kart_hit, PhysicalObject* object)
|
|||||||
{
|
{
|
||||||
case PowerupManager::POWERUP_CAKE:
|
case PowerupManager::POWERUP_CAKE:
|
||||||
{
|
{
|
||||||
RandomGenerator r;
|
hit_message += StringUtils::insertValues(getCakeString(),
|
||||||
const int messageID = r.get(CAKE_STRINGS_AMOUNT);
|
|
||||||
hit_message += StringUtils::insertValues(getCakeString(messageID),
|
|
||||||
kart_hit->getName().c_str(),
|
kart_hit->getName().c_str(),
|
||||||
m_owner->getName().c_str()
|
m_owner->getName().c_str()
|
||||||
).c_str();
|
).c_str();
|
||||||
@ -398,10 +407,7 @@ void Flyable::hit(Kart *kart_hit, PhysicalObject* object)
|
|||||||
break;
|
break;
|
||||||
case PowerupManager::POWERUP_BOWLING:
|
case PowerupManager::POWERUP_BOWLING:
|
||||||
{
|
{
|
||||||
RandomGenerator r;
|
hit_message += StringUtils::insertValues(getBowlingString(),
|
||||||
const int messageID = r.get(BOWLING_STRINGS_AMOUNT);
|
|
||||||
|
|
||||||
hit_message += StringUtils::insertValues(getBowlingString(messageID),
|
|
||||||
kart_hit->getName().c_str(),
|
kart_hit->getName().c_str(),
|
||||||
m_owner->getName().c_str()
|
m_owner->getName().c_str()
|
||||||
).c_str();
|
).c_str();
|
||||||
|
@ -33,13 +33,14 @@
|
|||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
|
|
||||||
const wchar_t* getPlungerInFaceString()
|
const wchar_t* getPlungerInFaceString()
|
||||||
{
|
{
|
||||||
const int PLUNGER_IN_FACE_STRING_AMOUNT = 2;
|
const int PLUNGER_IN_FACE_STRINGS_AMOUNT = 2;
|
||||||
|
|
||||||
RandomGenerator r;
|
RandomGenerator r;
|
||||||
const int id = r.get(PLUNGER_IN_FACE_STRING_AMOUNT);
|
const int id = r.get(PLUNGER_IN_FACE_STRINGS_AMOUNT);
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
//I18N: shown when a player receives a plunger in his face
|
//I18N: shown when a player receives a plunger in his face
|
||||||
@ -50,6 +51,7 @@ const wchar_t* getPlungerInFaceString()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
Plunger::Plunger(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_PLUNGER)
|
Plunger::Plunger(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_PLUNGER)
|
||||||
{
|
{
|
||||||
|
@ -32,22 +32,52 @@
|
|||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
// we can't use string array constants here because gettext should not be invoked too
|
|
||||||
// early when STK starts.
|
|
||||||
|
|
||||||
//I18N: message shown when using the anchor weapon; %s is the name of the victim
|
const wchar_t* getAnchorString()
|
||||||
#define ANCHOR_STRING_0 _("Arrr, the %s dropped anchor, Captain!")
|
|
||||||
|
|
||||||
//I18N: message shown when using the parachute weapon
|
|
||||||
#define PARACHUTE_STRING_0 _("Geronimo!!!")
|
|
||||||
|
|
||||||
const int SWAPPER_STRING_COUNT = 2;
|
|
||||||
const wchar_t* getSwapperString(const int id)
|
|
||||||
{
|
{
|
||||||
|
const int ANCHOR_STRINGS_COUNT = 2;
|
||||||
|
|
||||||
|
RandomGenerator r;
|
||||||
|
const int id = r.get(ANCHOR_STRINGS_COUNT);
|
||||||
|
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
//I18N: shown when anchor applied. %s is the victim.
|
||||||
|
case 0: return _("Arrr, the %s dropped anchor, Captain!");
|
||||||
|
case 1: return _("Another round of grog, %s arrived in harbour!");
|
||||||
|
default: assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const wchar_t* getParachuteString()
|
||||||
|
{
|
||||||
|
const int PARACHUTE_STRINGS_COUNT = 2;
|
||||||
|
|
||||||
|
RandomGenerator r;
|
||||||
|
const int id = r.get(PARACHUTE_STRINGS_COUNT);
|
||||||
|
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case 0: return _("Geronimo!!!"); // Parachutist shout
|
||||||
|
case 1: return _("The Space Shuttle has landed!");
|
||||||
|
default: assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const wchar_t* getSwapperString()
|
||||||
|
{
|
||||||
|
const int SWAPPER_STRINGS_COUNT = 3;
|
||||||
|
|
||||||
|
RandomGenerator r;
|
||||||
|
const int id = r.get(SWAPPER_STRINGS_COUNT);
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case 0: return _("Magic, son. Nothing else in the world smells like that.");
|
case 0: return _("Magic, son. Nothing else in the world smells like that.");
|
||||||
case 1: return _("A wizard did it!");
|
case 1: return _("A wizard did it!");
|
||||||
|
case 2: return _("Banana? Box? Banana? Box? Banana? Box?");
|
||||||
default: assert(false);
|
default: assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,10 +214,7 @@ void Powerup::use()
|
|||||||
m_sound_use->position(m_owner->getXYZ());
|
m_sound_use->position(m_owner->getXYZ());
|
||||||
m_sound_use->play();
|
m_sound_use->play();
|
||||||
|
|
||||||
RandomGenerator random;
|
gui->addMessage(getSwapperString(), NULL, 3.0f, 40,
|
||||||
const int message = random.get(SWAPPER_STRING_COUNT);
|
|
||||||
|
|
||||||
gui->addMessage(getSwapperString(message), NULL, 3.0f, 40,
|
|
||||||
video::SColor(255, 255, 255, 255), false);
|
video::SColor(255, 255, 255, 255), false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -245,7 +272,7 @@ void Powerup::use()
|
|||||||
m_sound_use->play();
|
m_sound_use->play();
|
||||||
|
|
||||||
irr::core::stringw anchor_message;
|
irr::core::stringw anchor_message;
|
||||||
anchor_message += StringUtils::insertValues(ANCHOR_STRING_0, kart->getName().c_str()).c_str();
|
anchor_message += StringUtils::insertValues(getAnchorString(), kart->getName().c_str()).c_str();
|
||||||
gui->addMessage(anchor_message, NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false);
|
gui->addMessage(anchor_message, NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -282,8 +309,7 @@ void Powerup::use()
|
|||||||
m_sound_use->position(player_kart->getXYZ());
|
m_sound_use->position(player_kart->getXYZ());
|
||||||
m_sound_use->play();
|
m_sound_use->play();
|
||||||
|
|
||||||
// Parachutist shout
|
gui->addMessage(getParachuteString(), NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false);
|
||||||
gui->addMessage(PARACHUTE_STRING_0, NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -29,9 +29,15 @@
|
|||||||
#include "race/race_manager.hpp"
|
#include "race/race_manager.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
|
||||||
const wchar_t* getPlungerString(const int n)
|
|
||||||
|
const wchar_t* getPlungerString()
|
||||||
{
|
{
|
||||||
switch (n)
|
const int PLUNGER_STRINGS_AMOUNT = 2;
|
||||||
|
|
||||||
|
RandomGenerator r;
|
||||||
|
const int id = r.get(PLUNGER_STRINGS_AMOUNT);
|
||||||
|
|
||||||
|
switch (id)
|
||||||
{
|
{
|
||||||
//I18N: shown when hit by plunger. %0 is the victim, %1 is the attacker
|
//I18N: shown when hit by plunger. %0 is the victim, %1 is the attacker
|
||||||
case 0 : return _("%0 bites %1's bait");
|
case 0 : return _("%0 bites %1's bait");
|
||||||
@ -41,7 +47,7 @@ const wchar_t* getPlungerString(const int n)
|
|||||||
default: assert(false);
|
default: assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int PLUNGER_STRINGS_AMOUNT = 2;
|
|
||||||
|
|
||||||
/** RubberBand constructor. It creates a simple quad and attaches it to the
|
/** RubberBand constructor. It creates a simple quad and attaches it to the
|
||||||
* root(!) of the graph. It's easier this way to get the right coordinates
|
* root(!) of the graph. It's easier this way to get the right coordinates
|
||||||
@ -227,12 +233,9 @@ void RubberBand::hit(Kart *kart_hit, const Vec3 *track_xyz)
|
|||||||
m_hit_kart = kart_hit;
|
m_hit_kart = kart_hit;
|
||||||
m_attached_state = RB_TO_KART;
|
m_attached_state = RB_TO_KART;
|
||||||
|
|
||||||
RandomGenerator r;
|
|
||||||
const int messageID = r.get(PLUNGER_STRINGS_AMOUNT);
|
|
||||||
|
|
||||||
RaceGUI* gui = World::getWorld()->getRaceGUI();
|
RaceGUI* gui = World::getWorld()->getRaceGUI();
|
||||||
irr::core::stringw hit_message;
|
irr::core::stringw hit_message;
|
||||||
hit_message += StringUtils::insertValues(getPlungerString(messageID),
|
hit_message += StringUtils::insertValues(getPlungerString(),
|
||||||
kart_hit->getName().c_str(),
|
kart_hit->getName().c_str(),
|
||||||
m_owner.getName().c_str()
|
m_owner.getName().c_str()
|
||||||
).c_str();
|
).c_str();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user