Show GP Position During a Race in SuperTuxKart
After quite some time, here is an update!
In SuperTuxKart, I have grown to like doing Grand Prix with
- 19 AI opponents
- Lots of races (for example, all of them and only 1 lap each)
This has sometimes lead to confusion during the race as to who my direct opponents were and who harmless flies. So I did what any sane person would do and dug in the source code to add it myself of course.
Before you get started, you will need a shiny up to date version straight from the STK svn repo, for which I conveniently present you with an earlier post. After you have gone through all that, it is time to dive in.
Note, I will use $STK_HOME
to refer to the directory that is the repo clone.
Which will be, if you followed my earlier post, /opt/supertuxkart/stk
. Open the
file $STK_HOME/src/states_screens/race_gui.cpp
in your favourite text editor
and look for this part in the code
if (info[kart_id].m_text.size() > 0)
{
video::SColor color = video::SColor(255,
(int)(255*info[kart_id].r),
(int)(255*info[kart_id].g),
(int)(255*info[kart_id].b) );
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5,
x+ICON_PLAYER_WIDTH, y+5);
core::stringw s=info[kart_id].m_text.c_str();
font->draw(s.c_str(), pos, color, false, false, NULL, true /* ignore RTL */);
}
if (info[kart_id].special_title.size() > 0)
{
static video::SColor color = video::SColor(255, 255, 0, 0);
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5,
x+ICON_PLAYER_WIDTH, y+5);
core::stringw s(info[kart_id].special_title.c_str());
font->draw(s.c_str(), pos, color, false, false, NULL, true /* ignore RTL */);
}
Before this part in the code, add
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX
&& info[kart_id].m_text.size() == 0)
{
video::SColor color = video::SColor(255,
(int)(255*info[kart_id].r),
(int)(255*info[kart_id].g),
(int)(255*info[kart_id].b) );
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5,
x+ICON_PLAYER_WIDTH, y+5);
char s[16];
sprintf(s, "%d (%d)", race_manager->getKartGPRank(kart_id) + 1, race_manager->getKartScore(kart_id));
font->draw(s, pos, color, false, false, NULL, true /* ignore RTL */);
}
Next open $STK_HOME
in a terminal and make
again. You will now have in game
information similar to this picture (format is Rank (Points)).