diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 14a87e0d3..31008bc4e 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -710,10 +710,11 @@ void IrrDriver::displayFPS() { // We will let pass some time to let things settle before trusting FPS counter // even if we also ignore fps = 1, which tends to happen in first checks -#define NO_TRUST_COUNT 25 + const int NO_TRUST_COUNT = 25; static int no_trust = NO_TRUST_COUNT; - if(no_trust) { + if (no_trust) + { no_trust--; return; } @@ -745,7 +746,7 @@ void IrrDriver::displayFPS() core::stringw fpsString = buffer; static video::SColor fpsColor = video::SColor(255, 255, 0, 0); - font->draw( fpsString.c_str(), core::rect< s32 >(0,0,600,200), fpsColor, true ); + font->draw( fpsString.c_str(), core::rect< s32 >(100,0,400,50), fpsColor, false ); } // updateFPS // ---------------------------------------------------------------------------- diff --git a/src/items/flyable.cpp b/src/items/flyable.cpp index 80b10e6f3..0683ea116 100644 --- a/src/items/flyable.cpp +++ b/src/items/flyable.cpp @@ -326,7 +326,7 @@ void Flyable::hit(Kart *kart_hit, PhysicalObject* object) irr::core::stringw hit_message; switch(m_type) { case POWERUP_CAKE: - hit_message += StringUtils::insertValues(_("%s eats too much %s's cake"), + hit_message += StringUtils::insertValues(_("%s eats too much of %s's cake"), kart_hit->getName().c_str(), m_owner->getName().c_str() ).c_str(); @@ -340,9 +340,9 @@ void Flyable::hit(Kart *kart_hit, PhysicalObject* object) ).c_str(); break; default: - hit_message = _("UFO hit someone, the bug is right here"); + assert(false); } - gui->addMessage(hit_message, NULL, 3.0f, 40, video::SColor(255, 210, 50, 50)); + gui->addMessage(hit_message, NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false); } m_has_hit_something=true; diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 78bfd47fc..3f94a2d59 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -162,7 +162,7 @@ void Plunger::hit(Kart *kart, PhysicalObject *obj) kart->getName().c_str(), m_owner->getName().c_str() ).c_str(); - gui->addMessage(hit_message, NULL, 3.0f, 40, video::SColor(255, 210, 50, 50)); + gui->addMessage(hit_message, NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false); } m_keep_alive = 0; diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index 21a51e0b3..fe6ad82fe 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -146,7 +146,8 @@ void Powerup::use() m_sound_use->position(m_owner->getXYZ()); m_sound_use->play(); // Apocalypse Now style - gui->addMessage(_("Magic, son. Nothing else in the world smells like that."), NULL, 3.0f, 40, video::SColor(255, 210, 50, 50)); + gui->addMessage(_("Magic, son. Nothing else in the world smells like that."), NULL, 3.0f, 40, + video::SColor(255, 255, 255, 255), false); break; case POWERUP_CAKE: case POWERUP_BOWLING: @@ -203,7 +204,7 @@ void Powerup::use() irr::core::stringw anchor_message; anchor_message += StringUtils::insertValues(_("Arrr, the %s dropped anchor, Captain!"), kart->getName().c_str()).c_str(); - gui->addMessage(anchor_message, NULL, 3.0f, 40, video::SColor(255, 210, 50, 50)); + gui->addMessage(anchor_message, NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false); break; } } @@ -240,7 +241,7 @@ void Powerup::use() m_sound_use->play(); // Parachutist shout - gui->addMessage(_("Geronimo!!!"), NULL, 3.0f, 40, video::SColor(255, 210, 50, 50)); + gui->addMessage(_("Geronimo!!!"), NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false); } break; diff --git a/src/items/rubber_band.cpp b/src/items/rubber_band.cpp index f61823f19..edcb0d132 100644 --- a/src/items/rubber_band.cpp +++ b/src/items/rubber_band.cpp @@ -219,7 +219,7 @@ void RubberBand::hit(Kart *kart_hit, const Vec3 *track_xyz) kart_hit->getName().c_str(), m_owner.getName().c_str() ).c_str(); - gui->addMessage(hit_message, NULL, 3.0f, 40, video::SColor(255, 210, 50, 50)); + gui->addMessage(hit_message, NULL, 3.0f, 40, video::SColor(255, 255, 255, 255), false); return; } diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 3f0025d37..17c0e01a1 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -229,7 +229,7 @@ void LinearWorld::newLap(unsigned int kart_index) if(kart_info.m_race_lap+1 == race_manager->getNumLaps()) { m_race_gui->addMessage(_("Final lap!"), m_karts[kart_index], - 3.0f, 40, video::SColor(255, 210, 100, 50)); + 3.0f, 40, video::SColor(255, 210, 100, 50), true); } // Race finished if(kart_info.m_race_lap >= race_manager->getNumLaps() && raceHasLaps()) @@ -259,7 +259,7 @@ void LinearWorld::newLap(unsigned int kart_index) { setFastestLap(kart, time_per_lap); m_race_gui->addMessage(_("New fastest lap"), NULL, - 2.0f, 40, video::SColor(255, 100, 210, 100)); + 2.0f, 40, video::SColor(255, 100, 210, 100), true); std::string s = StringUtils::timeToString(time_per_lap); irr::core::stringw m_fastest_lap_message; diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index f1b89d757..7200fbae8 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -411,6 +411,7 @@ void RaceGUI::drawPowerupIcons(const Kart* kart, if(n>5) n=5; // Display at most 5 items int nSize=(int)(64.0f*std::min(scaling.X, scaling.Y)); + int x1 = (int)((UserConfigParams::m_width/2-32) * scaling.X) + viewport.UpperLeftCorner.X; //int y1 = UserConfigParams::m_height - viewport.LowerRightCorner.Y @@ -420,7 +421,7 @@ void RaceGUI::drawPowerupIcons(const Kart* kart, video::ITexture *t=powerup->getIcon()->getTexture(); core::rect rect(core::position2di(0, 0), t->getOriginalSize()); - + for ( int i = 0 ; i < n ; i++ ) { int x2=(int)(x1+i*std::min(scaling.X, scaling.Y)*30); @@ -652,11 +653,29 @@ void RaceGUI::drawAllMessages(const Kart* kart, const core::recti &viewport, const core::vector2df &scaling) { - // First line of text somewhat under the top of the screen. For now - // start just under the timer display - int y = (int)(viewport.UpperLeftCorner.Y + 164*scaling.Y); + int y = viewport.LowerRightCorner.Y - m_max_font_height; + const int x = (viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X)/2; const int w = (viewport.LowerRightCorner.X + viewport.UpperLeftCorner.X)/2; + + // draw less important first, at the very top of the screen + for (AllMessageType::const_iterator i = m_messages.begin(); i != m_messages.end(); ++i) + { + TimedMessage const &msg = *i; + if (!msg.m_important) + { + // Display only messages for all karts, or messages for this kart + if (msg.m_kart && msg.m_kart!=kart) continue; + + core::rect pos(x - w/2, y, x + w/2, y + m_max_font_height); + GUIEngine::getFont()->draw(core::stringw(msg.m_message.c_str()).c_str(), + pos, msg.m_color, true /* hcenter */, true /* vcenter */); + y -= m_max_font_height; + } + } + + // First line of text somewhat under the top of the viewport. + y = (int)(viewport.UpperLeftCorner.Y + 164*scaling.Y); // The message are displayed in reverse order, so that a multi-line // message (addMessage("1", ...); addMessage("2",...) is displayed @@ -665,6 +684,8 @@ void RaceGUI::drawAllMessages(const Kart* kart, { TimedMessage const &msg = *i; + if (!msg.m_important) continue; // less important messages were already displayed + // Display only messages for all karts, or messages for this kart if (msg.m_kart && msg.m_kart!=kart) continue; @@ -681,9 +702,9 @@ void RaceGUI::drawAllMessages(const Kart* kart, * once). **/ void RaceGUI::addMessage(const core::stringw &msg, const Kart *kart, float time, - int font_size, const video::SColor &color) + int font_size, const video::SColor &color, bool important) { - m_messages.push_back(TimedMessage(msg, kart, time, font_size, color)); + m_messages.push_back(TimedMessage(msg, kart, time, font_size, color, important)); } // addMessage //----------------------------------------------------------------------------- diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index 3933c00bb..b90a01306 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -61,19 +61,21 @@ private: video::SColor m_color; //!< color of message int m_font_size; //!< size const Kart *m_kart; + bool m_important; //!< Important msgs are displayed in the middle of the screen // ----------------------------------------------------- // std::vector needs standard copy-ctor and std-assignment op. // let compiler create defaults .. they'll do the job, no // deep copies here .. TimedMessage(const irr::core::stringw &message, const Kart *kart, float time, int size, - const video::SColor &color) + const video::SColor &color, const bool important) { m_message = message; m_font_size = size; m_kart = kart; m_remaining_time = ( time < 0.0f ) ? -1.0f : time; m_color = color; + m_important = important; } // TimedMessage // ----------------------------------------------------- // in follow leader the clock counts backwards @@ -90,6 +92,7 @@ private: Material *m_plunger_face; typedef std::vector AllMessageType; AllMessageType m_messages; + /** A texture with all mini dots to be displayed in the minimap for all karts. */ video::ITexture *m_marker; @@ -179,7 +182,8 @@ public: void addMessage(const irr::core::stringw &m, const Kart *kart, float time, int fonst_size, - const video::SColor &color=video::SColor(255, 255, 0, 255)); + const video::SColor &color=video::SColor(255, 255, 0, 255), + bool important=true); void clearAllMessages() { m_messages.clear(); }