diff --git a/data/gui/License.txt b/data/gui/License.txt index 2048f6068..bd50cfcad 100644 --- a/data/gui/License.txt +++ b/data/gui/License.txt @@ -16,6 +16,8 @@ title_font, by Marianne Gagnon (Auria), released under CC-BY-SA 3+ screen*.png, by Marianne Gagnon (Auria), including elements from the public domain Tango icon set +Gauge by Dakal, release under CC-BY-SA 3 + ==== Glass Skin by Auria, under CC-BY-SA 3+ diff --git a/data/gui/gauge_empty.png b/data/gui/gauge_empty.png new file mode 100644 index 000000000..b50d95c01 Binary files /dev/null and b/data/gui/gauge_empty.png differ diff --git a/data/gui/gauge_full.png b/data/gui/gauge_full.png new file mode 100644 index 000000000..6db09d8e9 Binary files /dev/null and b/data/gui/gauge_full.png differ diff --git a/data/gui/gauge_goal.png b/data/gui/gauge_goal.png new file mode 100644 index 000000000..2715e392f Binary files /dev/null and b/data/gui/gauge_goal.png differ diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index 21c66db2d..de3cc6a8c 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -392,8 +392,8 @@ void PlayerController::handleZipper(bool play_sound) */ void PlayerController::collectedItem(const Item &item, int add_info, float old_energy) { - if(old_energy < MAX_ITEMS_COLLECTED && - m_kart->getEnergy() == MAX_ITEMS_COLLECTED) + if(old_energy < MAX_NITRO && + m_kart->getEnergy() == MAX_NITRO) { m_full_sound->play(); } diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index ade113b2a..9f05ac2af 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -604,8 +604,8 @@ void Kart::collectedItem(Item *item, int add_info) race_state->itemCollected(getWorldKartId(), item->getItemId()); } - if ( m_collected_energy > MAX_ITEMS_COLLECTED ) - m_collected_energy = MAX_ITEMS_COLLECTED; + if ( m_collected_energy > MAX_NITRO ) + m_collected_energy = MAX_NITRO; m_controller->collectedItem(*item, add_info, old_energy); } // collectedItem diff --git a/src/karts/moveable.hpp b/src/karts/moveable.hpp index 6907140fd..a687f984c 100644 --- a/src/karts/moveable.hpp +++ b/src/karts/moveable.hpp @@ -32,10 +32,7 @@ using namespace irr; class Material; -/* Limits of Kart performance */ -#define CRASH_PITCH -45.0f - -#define MAX_ITEMS_COLLECTED 20 +const int MAX_NITRO = 16; /** * \ingroup karts diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index a42503552..3b08e05cd 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -85,6 +85,10 @@ RaceGUI::RaceGUI() m_plunger_face = material_manager->getMaterial("plungerface.png"); m_music_icon = material_manager->getMaterial("notes.png"); createMarkerTexture(); + + m_gauge_full = irr_driver->getTexture( file_manager->getGUIDir() + "gauge_full.png" ); + m_gauge_empty = irr_driver->getTexture( file_manager->getGUIDir() + "gauge_empty.png" ); + m_gauge_goal = irr_driver->getTexture( file_manager->getGUIDir() + "gauge_goal.png" ); // Translate strings only one in constructor to avoid calling // gettext in each frame. @@ -736,64 +740,52 @@ void RaceGUI::drawEnergyMeter(int x, int y, const Kart *kart, const core::recti &viewport, const core::vector2df &scaling) { - float state = (float)(kart->getEnergy()) / MAX_ITEMS_COLLECTED; - // Don't scale width, it looks too small otherwise - int w = 16; + float state = (float)(kart->getEnergy()) / MAX_NITRO; + if (state < 0.0f) state = 0.0f; + else if (state > 1.0f) state = 1.0f; + int h = (int)(viewport.getHeight()/3); - - // Move energy bar slighty 'into' the speedometer. Leave 10 points - // between right edge of viewport and energy meter, and don't scale. - x -= w+10; - y -= (int)(30*scaling.Y); + int w = h/4; // gauge image is so 1:4 - float coin_target = (float)race_manager->getCoinTarget(); - int th = (int)(h*(coin_target/MAX_ITEMS_COLLECTED)); + x -= w; - video::SColor black_border(255, 0, 0, 0); - video::SColor white_border(255, 255, 255, 255); - video::IVideoDriver *video = irr_driver->getVideoDriver(); -#define LINE(x0,y0,x1,y1, color) video->draw2DLine(core::position2di(x0,y0), \ - core::position2di(x1,y1), color) - - // Left side: - LINE(x-1, y+1, x-1, y-h-1, black_border); - LINE(x, y, x, y-h-2, white_border); - - // Right side: - LINE(x+w, y+1, x+w, y-h-1, black_border); - LINE(x+w+1, y, x+w+1, y-h-2, white_border); - - // Bottom - LINE(x, y+1, x+w, y+1, black_border); - LINE(x+1, y, x+w+1, y, white_border); - - // Top - LINE(x, y-h, x+w, y-h, black_border); - LINE(x, y-h-1, x+w, y-h-1, white_border); - - const int GRADS = (int)(MAX_ITEMS_COLLECTED/5); // each graduation equals 5 items - int gh = (int)(h/GRADS); //graduation height - - // 'Meter marks; - int gh_incr = gh; - for (int i=0; igetVideoDriver()->draw2DImage(m_gauge_empty, core::rect(x, y, x+w, y+h) /* dest rect */, + core::rect(0, 0, 64, 256) /* source rect */, + NULL /* clip rect */, NULL /* colors */, + true /* alpha */); + + // Target + if (race_manager->getCoinTarget() > 0) { - LINE(x+1, y-1-gh, x+1+w, y-1-gh, white_border); - gh+=gh_incr; + float coin_target = (float)race_manager->getCoinTarget() / MAX_NITRO; + + const int EMPTY_TOP_PIXELS = 4; + const int EMPTY_BOTTOM_PIXELS = 3; + int y1 = y + EMPTY_TOP_PIXELS + (h - EMPTY_TOP_PIXELS - EMPTY_BOTTOM_PIXELS)*(1.0f - coin_target); + if (state >= 1.0f) y1 = y; + + core::rect clip(x, y1, x + w, y + h); + irr_driver->getVideoDriver()->draw2DImage(m_gauge_goal, core::rect(x, y, x+w, y+h) /* dest rect */, + core::rect(0, 0, 64, 256) /* source rect */, + &clip, NULL /* colors */, true /* alpha */); } - - //Target line - if (coin_target > 0) + + // Filling (current state) + if (state > 0.0f) { - LINE(x+1, y-1-th, x+1+w, y-1-th, video::SColor(255, 255, 0, 0)); + const int EMPTY_TOP_PIXELS = 4; + const int EMPTY_BOTTOM_PIXELS = 3; + int y1 = y + EMPTY_TOP_PIXELS + (h - EMPTY_TOP_PIXELS - EMPTY_BOTTOM_PIXELS)*(1.0f - state); + if (state >= 1.0f) y1 = y; + + core::rect clip(x, y1, x + w, y + h); + irr_driver->getVideoDriver()->draw2DImage(m_gauge_full, core::rect(x, y, x+w, y+h) /* dest rect */, + core::rect(0, 0, 64, 256) /* source rect */, + &clip, NULL /* colors */, true /* alpha */); } -#undef LINE - - // The actual energy meter - core::rect energy(x+1, y-1-(int)(state*h), x+1+w, y-1); - video::SColor bottom(255, 240, 0, 0); - video::SColor top (160, 240, 200, 0); - video->draw2DRectangle(energy, top, top, bottom, bottom); + + } // drawEnergyMeter //----------------------------------------------------------------------------- @@ -805,17 +797,18 @@ void RaceGUI::drawSpeedAndEnergy(const Kart* kart, const core::recti &viewport, const int SPEEDWIDTH = 128; int meter_width = (int)(SPEEDWIDTH*minRatio); int meter_height = (int)(SPEEDWIDTH*minRatio); - core::vector2df offset; - offset.X = (float)(viewport.LowerRightCorner.X-meter_width) - 15.0f*scaling.X; - offset.Y = viewport.LowerRightCorner.Y-10*scaling.Y; - drawEnergyMeter(viewport.LowerRightCorner.X, - viewport.LowerRightCorner.Y - meter_height, kart, + viewport.LowerRightCorner.Y - meter_height*2, kart, viewport, scaling); // First draw the meter (i.e. the background which contains the numbers etc. // ------------------------------------------------------------------------- + + core::vector2df offset; + offset.X = (float)(viewport.LowerRightCorner.X-meter_width) - 15.0f*scaling.X; + offset.Y = viewport.LowerRightCorner.Y-10*scaling.Y; + video::IVideoDriver *video = irr_driver->getVideoDriver(); const core::rect meter_pos((int)offset.X, (int)(offset.Y-meter_height), diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index 7c96c871c..d6d8c2316 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -100,6 +100,10 @@ private: /** Translated strings 'ready', 'set', 'go'. */ core::stringw m_string_ready, m_string_set, m_string_go; + video::ITexture *m_gauge_empty; + video::ITexture *m_gauge_full; + video::ITexture *m_gauge_goal; + // Minimap related variables // ------------------------- /** The mini map of the track. */