merge minimal race GUI into normal race GUI. Slight changes but in the same spirit
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13072 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c39795b445
commit
eecf0b67f6
@ -70,10 +70,10 @@ src/guiengine/widgets/label_widget.cpp
|
||||
src/guiengine/widgets/list_widget.cpp
|
||||
src/guiengine/widgets/model_view_widget.cpp
|
||||
src/guiengine/widgets/progress_bar_widget.cpp
|
||||
src/guiengine/widgets/rating_bar_widget.cpp
|
||||
src/guiengine/widgets/ribbon_widget.cpp
|
||||
src/guiengine/widgets/spinner_widget.cpp
|
||||
src/guiengine/widgets/text_box_widget.cpp
|
||||
src/guiengine/widgets/rating_bar_widget.cpp
|
||||
src/input/binding.cpp
|
||||
src/input/device_manager.cpp
|
||||
src/input/input_device.cpp
|
||||
@ -97,8 +97,8 @@ src/items/projectile_manager.cpp
|
||||
src/items/rubber_ball.cpp
|
||||
src/items/rubber_band.cpp
|
||||
src/items/swatter.cpp
|
||||
src/karts/abstract_kart.cpp
|
||||
src/karts/abstract_kart_animation.cpp
|
||||
src/karts/abstract_kart.cpp
|
||||
src/karts/cannon_animation.cpp
|
||||
src/karts/controller/ai_base_controller.cpp
|
||||
src/karts/controller/ai_properties.cpp
|
||||
@ -186,15 +186,14 @@ src/states_screens/help_screen_3.cpp
|
||||
src/states_screens/help_screen_4.cpp
|
||||
src/states_screens/kart_selection.cpp
|
||||
src/states_screens/main_menu_screen.cpp
|
||||
src/states_screens/minimal_race_gui.cpp
|
||||
src/states_screens/options_screen_audio.cpp
|
||||
src/states_screens/options_screen_input.cpp
|
||||
src/states_screens/options_screen_input2.cpp
|
||||
src/states_screens/options_screen_input.cpp
|
||||
src/states_screens/options_screen_players.cpp
|
||||
src/states_screens/options_screen_ui.cpp
|
||||
src/states_screens/options_screen_video.cpp
|
||||
src/states_screens/race_gui.cpp
|
||||
src/states_screens/race_gui_base.cpp
|
||||
src/states_screens/race_gui.cpp
|
||||
src/states_screens/race_gui_overworld.cpp
|
||||
src/states_screens/race_result_gui.cpp
|
||||
src/states_screens/race_setup_screen.cpp
|
||||
@ -254,8 +253,8 @@ src/animations/animation_base.hpp
|
||||
src/animations/ipo.hpp
|
||||
src/animations/three_d_animation.hpp
|
||||
src/audio/dummy_sfx.hpp
|
||||
src/audio/music.hpp
|
||||
src/audio/music_dummy.hpp
|
||||
src/audio/music.hpp
|
||||
src/audio/music_information.hpp
|
||||
src/audio/music_manager.hpp
|
||||
src/audio/music_ogg.hpp
|
||||
@ -263,8 +262,8 @@ src/audio/sfx_base.hpp
|
||||
src/audio/sfx_buffer.hpp
|
||||
src/audio/sfx_manager.hpp
|
||||
src/audio/sfx_openal.hpp
|
||||
src/challenges/challenge.hpp
|
||||
src/challenges/challenge_data.hpp
|
||||
src/challenges/challenge.hpp
|
||||
src/challenges/game_slot.hpp
|
||||
src/challenges/unlock_manager.hpp
|
||||
src/config/device_config.hpp
|
||||
@ -306,24 +305,24 @@ src/guiengine/scalable_font.hpp
|
||||
src/guiengine/screen.hpp
|
||||
src/guiengine/skin.hpp
|
||||
src/guiengine/widget.hpp
|
||||
src/guiengine/widgets.hpp
|
||||
src/guiengine/widgets/bubble_widget.hpp
|
||||
src/guiengine/widgets/button_widget.hpp
|
||||
src/guiengine/widgets/check_box_widget.hpp
|
||||
src/guiengine/widgets/dynamic_ribbon_widget.hpp
|
||||
src/guiengine/widgets.hpp
|
||||
src/guiengine/widgets/icon_button_widget.hpp
|
||||
src/guiengine/widgets/label_widget.hpp
|
||||
src/guiengine/widgets/list_widget.hpp
|
||||
src/guiengine/widgets/model_view_widget.hpp
|
||||
src/guiengine/widgets/progress_bar_widget.hpp
|
||||
src/guiengine/widgets/rating_bar_widget.hpp
|
||||
src/guiengine/widgets/ribbon_widget.hpp
|
||||
src/guiengine/widgets/spinner_widget.hpp
|
||||
src/guiengine/widgets/text_box_widget.hpp
|
||||
src/guiengine/widgets/rating_bar_widget.hpp
|
||||
src/input/binding.hpp
|
||||
src/input/device_manager.hpp
|
||||
src/input/input.hpp
|
||||
src/input/input_device.hpp
|
||||
src/input/input.hpp
|
||||
src/input/input_manager.hpp
|
||||
src/input/wiimote.hpp
|
||||
src/input/wiimote_manager.hpp
|
||||
@ -345,8 +344,8 @@ src/items/projectile_manager.hpp
|
||||
src/items/rubber_ball.hpp
|
||||
src/items/rubber_band.hpp
|
||||
src/items/swatter.hpp
|
||||
src/karts/abstract_kart.hpp
|
||||
src/karts/abstract_kart_animation.hpp
|
||||
src/karts/abstract_kart.hpp
|
||||
src/karts/cannon_animation.hpp
|
||||
src/karts/controller/ai_base_controller.hpp
|
||||
src/karts/controller/ai_properties.hpp
|
||||
@ -357,8 +356,8 @@ src/karts/controller/player_controller.hpp
|
||||
src/karts/controller/skidding_ai.hpp
|
||||
src/karts/explosion_animation.hpp
|
||||
src/karts/ghost_kart.hpp
|
||||
src/karts/kart.hpp
|
||||
src/karts/kart_gfx.hpp
|
||||
src/karts/kart.hpp
|
||||
src/karts/kart_model.hpp
|
||||
src/karts/kart_properties.hpp
|
||||
src/karts/kart_properties_manager.hpp
|
||||
@ -447,15 +446,14 @@ src/states_screens/help_screen_3.hpp
|
||||
src/states_screens/help_screen_4.hpp
|
||||
src/states_screens/kart_selection.hpp
|
||||
src/states_screens/main_menu_screen.hpp
|
||||
src/states_screens/minimal_race_gui.hpp
|
||||
src/states_screens/options_screen_audio.hpp
|
||||
src/states_screens/options_screen_input.hpp
|
||||
src/states_screens/options_screen_input2.hpp
|
||||
src/states_screens/options_screen_input.hpp
|
||||
src/states_screens/options_screen_players.hpp
|
||||
src/states_screens/options_screen_ui.hpp
|
||||
src/states_screens/options_screen_video.hpp
|
||||
src/states_screens/race_gui.hpp
|
||||
src/states_screens/race_gui_base.hpp
|
||||
src/states_screens/race_gui.hpp
|
||||
src/states_screens/race_gui_overworld.hpp
|
||||
src/states_screens/race_result_gui.hpp
|
||||
src/states_screens/race_setup_screen.hpp
|
||||
@ -485,8 +483,8 @@ src/tracks/check_sphere.hpp
|
||||
src/tracks/check_structure.hpp
|
||||
src/tracks/graph_node.hpp
|
||||
src/tracks/lod_node_loader.hpp
|
||||
src/tracks/quad.hpp
|
||||
src/tracks/quad_graph.hpp
|
||||
src/tracks/quad.hpp
|
||||
src/tracks/quad_set.hpp
|
||||
src/tracks/terrain_info.hpp
|
||||
src/tracks/track.hpp
|
||||
|
@ -55,7 +55,6 @@
|
||||
#include "states_screens/dialogs/race_paused_dialog.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "states_screens/main_menu_screen.hpp"
|
||||
#include "states_screens/minimal_race_gui.hpp"
|
||||
#include "states_screens/race_gui.hpp"
|
||||
#include "states_screens/race_result_gui.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
@ -251,10 +250,10 @@ void World::reset()
|
||||
|
||||
void World::createRaceGUI()
|
||||
{
|
||||
if(UserConfigParams::m_minimal_race_gui &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
m_race_gui = new MinimalRaceGUI();
|
||||
else
|
||||
//if(UserConfigParams::m_minimal_race_gui &&
|
||||
// race_manager->getTrackName() != "tutorial")
|
||||
// m_race_gui = new MinimalRaceGUI();
|
||||
//else
|
||||
m_race_gui = new RaceGUI();
|
||||
}
|
||||
|
||||
|
@ -1,493 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
|
||||
// Copyright (C) 2006 Joerg Henrichs, SuperTuxKart-Team, Steve Baker
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "states_screens/minimal_race_gui.hpp"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "items/attachment.hpp"
|
||||
#include "items/attachment_manager.hpp"
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/controller/controller.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "modes/follow_the_leader.hpp"
|
||||
#include "modes/linear_world.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
/** The constructor is called before anything is attached to the scene node.
|
||||
* So rendering to a texture can be done here. But world is not yet fully
|
||||
* created, so only the race manager can be accessed safely.
|
||||
*/
|
||||
MinimalRaceGUI::MinimalRaceGUI()
|
||||
{
|
||||
m_enabled = true;
|
||||
|
||||
// Ignore item messages.
|
||||
ignoreUnimportantMessages();
|
||||
|
||||
// Originally m_map_height was 100, and we take 480 as minimum res
|
||||
const float scaling = irr_driver->getFrameSize().Height / 480.0f;
|
||||
// Marker texture has to be power-of-two for (old) OpenGL compliance
|
||||
m_marker_rendered_size = 2 << ((int) ceil(1.0 + log(32.0 * scaling)));
|
||||
m_marker_ai_size = (int)( 24.0f * scaling);
|
||||
m_marker_player_size = (int)( 34.0f * scaling);
|
||||
m_map_width = (int)(200.0f * scaling);
|
||||
m_map_height = (int)(200.0f * scaling);
|
||||
|
||||
// The location of the minimap varies with number of
|
||||
// splitscreen players:
|
||||
switch(race_manager->getNumLocalPlayers())
|
||||
{
|
||||
case 0 : // In case of profile mode
|
||||
case 1 : // Lower left corner
|
||||
m_map_left = 10;
|
||||
m_map_bottom = UserConfigParams::m_height-10;
|
||||
break;
|
||||
case 2: // Middle of left side
|
||||
m_map_left = 10;
|
||||
m_map_bottom = UserConfigParams::m_height/2 + m_map_height/2;
|
||||
break;
|
||||
case 3: // Lower right quarter (which is not used by a player)
|
||||
m_map_left = UserConfigParams::m_width/2 + 10;
|
||||
m_map_bottom = UserConfigParams::m_height-10;
|
||||
break;
|
||||
case 4: // Middle of the screen.
|
||||
m_map_left = UserConfigParams::m_width/2-m_map_width/2;
|
||||
m_map_bottom = UserConfigParams::m_height/2 + m_map_height/2;
|
||||
break;
|
||||
}
|
||||
|
||||
// Minimap is also rendered bigger via OpenGL, so find power-of-two again
|
||||
const int map_texture = 2 << ((int) ceil(1.0 + log(128.0 * scaling)));
|
||||
m_map_rendered_width = map_texture;
|
||||
m_map_rendered_height = map_texture;
|
||||
|
||||
createMarkerTexture();
|
||||
|
||||
// Translate strings only one in constructor to avoid calling
|
||||
// gettext in each frame.
|
||||
//I18N: Shown at the end of a race
|
||||
m_string_lap = _("Lap");
|
||||
m_string_rank = _("Rank");
|
||||
|
||||
// Scaled fonts don't look good atm.
|
||||
m_font_scale = 1.0f; //race_manager->getNumLocalPlayers()==1 ? 1.2f : 1.0f;
|
||||
|
||||
//read icon frame picture
|
||||
|
||||
// Determine maximum length of the rank/lap text, in order to
|
||||
// align those texts properly on the right side of the viewport.
|
||||
gui::ScalableFont* font = GUIEngine::getFont();
|
||||
float old_scale = font->getScale();
|
||||
font->setScale(m_font_scale);
|
||||
m_lap_width = font->getDimension(m_string_lap.c_str()).Width;
|
||||
m_timer_width = font->getDimension(L"99:99:99").Width;
|
||||
if(race_manager->getNumberOfKarts()>9)
|
||||
m_rank_width = font->getDimension(L"99/99").Width;
|
||||
else
|
||||
m_rank_width = font->getDimension(L"9/9").Width;
|
||||
|
||||
int w;
|
||||
if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
|
||||
race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES ||
|
||||
race_manager->getNumLaps() > 9)
|
||||
w = font->getDimension(L" 99/99").Width;
|
||||
else
|
||||
w = font->getDimension(L" 9/9").Width;
|
||||
m_lap_width += w;
|
||||
font->setScale(old_scale);
|
||||
|
||||
} // MinimalRaceGUI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
MinimalRaceGUI::~MinimalRaceGUI()
|
||||
{
|
||||
} // ~MinimalRaceGUI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Render all global parts of the race gui, i.e. things that are only
|
||||
* displayed once even in splitscreen.
|
||||
* \param dt Timestep sized.
|
||||
*/
|
||||
void MinimalRaceGUI::renderGlobal(float dt)
|
||||
{
|
||||
RaceGUIBase::renderGlobal(dt);
|
||||
cleanupMessages(dt);
|
||||
|
||||
// Special case : when 3 players play, use 4th window to display such
|
||||
// stuff (but we must clear it)
|
||||
if (race_manager->getNumLocalPlayers() == 3 &&
|
||||
!GUIEngine::ModalDialog::isADialogActive())
|
||||
{
|
||||
static video::SColor black = video::SColor(255,0,0,0);
|
||||
irr_driver->getVideoDriver()
|
||||
->draw2DRectangle(black,
|
||||
core::rect<s32>(UserConfigParams::m_width/2,
|
||||
UserConfigParams::m_height/2,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height));
|
||||
}
|
||||
|
||||
World *world = World::getWorld();
|
||||
assert(world != NULL);
|
||||
if(world->getPhase() >= WorldStatus::READY_PHASE &&
|
||||
world->getPhase() <= WorldStatus::GO_PHASE )
|
||||
{
|
||||
drawGlobalReadySetGo();
|
||||
}
|
||||
|
||||
// Timer etc. are not displayed unless the game is actually started.
|
||||
if(!world->isRacePhase()) return;
|
||||
if (!m_enabled) return;
|
||||
|
||||
drawGlobalTimer();
|
||||
if(world->getPhase() == WorldStatus::GO_PHASE ||
|
||||
world->getPhase() == WorldStatus::MUSIC_PHASE)
|
||||
{
|
||||
drawGlobalMusicDescription();
|
||||
}
|
||||
|
||||
drawGlobalMiniMap();
|
||||
|
||||
// in 3 strikes mode we need to see the lives
|
||||
if (world->getIdent() == IDENT_STRIKES)
|
||||
{
|
||||
drawGlobalPlayerIcons(m_map_height);
|
||||
}
|
||||
} // renderGlobal
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Render the details for a single player, i.e. speed, energy,
|
||||
* collectibles, ...
|
||||
* \param kart Pointer to the kart for which to render the view.
|
||||
*/
|
||||
void MinimalRaceGUI::renderPlayerView(const Camera *camera, float dt)
|
||||
{
|
||||
if (!m_enabled) return;
|
||||
|
||||
const core::recti &viewport = camera->getViewport();
|
||||
core::vector2df scaling = camera->getScaling();
|
||||
|
||||
scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size
|
||||
|
||||
const AbstractKart *kart = camera->getKart();
|
||||
if(!kart) return;
|
||||
|
||||
drawPlungerInFace(camera, dt);
|
||||
drawAllMessages (kart, viewport, scaling);
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
drawPowerupIcons (kart, viewport, scaling);
|
||||
drawEnergyMeter (kart, viewport, scaling);
|
||||
drawRankLap (kart, viewport);
|
||||
|
||||
RaceGUIBase::renderPlayerView(camera, dt);
|
||||
} // renderPlayerView
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Displays the racing time on the screen.s
|
||||
*/
|
||||
void MinimalRaceGUI::drawGlobalTimer()
|
||||
{
|
||||
assert(World::getWorld() != NULL);
|
||||
|
||||
if(!World::getWorld()->shouldDrawTimer()) return;
|
||||
std::string s = StringUtils::timeToString(World::getWorld()->getTime());
|
||||
core::stringw sw(s.c_str());
|
||||
|
||||
static video::SColor time_color = video::SColor(255, 255, 255, 255);
|
||||
int x=0,y=0; // initialise to avoid compiler warning
|
||||
switch(race_manager->getNumLocalPlayers())
|
||||
{
|
||||
case 1: x = 10; y=0; break;
|
||||
case 2: x = 10; y=0; break;
|
||||
case 3: x = UserConfigParams::m_width - m_timer_width-10;
|
||||
y = UserConfigParams::m_height/2; break;
|
||||
case 4: x = UserConfigParams::m_width/2 - m_timer_width/2;
|
||||
y = 0; break;
|
||||
} // switch
|
||||
|
||||
core::rect<s32> pos(x, y,
|
||||
UserConfigParams::m_width, y+50);
|
||||
|
||||
|
||||
gui::ScalableFont* font = GUIEngine::getFont();
|
||||
float old_scale = font->getScale();
|
||||
font->setScale(m_font_scale);
|
||||
font->draw(sw.c_str(), pos, time_color, false, false, NULL, true /* ignore RTL */);
|
||||
font->setScale(old_scale);
|
||||
} // drawGlobalTimer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Draws the mini map and the position of all karts on it.
|
||||
*/
|
||||
void MinimalRaceGUI::drawGlobalMiniMap()
|
||||
{
|
||||
World *world = World::getWorld();
|
||||
// arenas currently don't have a map.
|
||||
if(world->getTrack()->isArena() || world->getTrack()->isSoccer()) return;
|
||||
|
||||
const video::ITexture *mini_map = world->getTrack()->getMiniMap();
|
||||
|
||||
int upper_y = m_map_bottom - m_map_height;
|
||||
int lower_y = m_map_bottom;
|
||||
|
||||
if (mini_map != NULL)
|
||||
{
|
||||
core::rect<s32> dest(m_map_left, upper_y,
|
||||
m_map_left + m_map_width, lower_y);
|
||||
core::rect<s32> source(core::position2di(0, 0), mini_map->getOriginalSize());
|
||||
irr_driver->getVideoDriver()->draw2DImage(mini_map, dest, source, 0, 0, true);
|
||||
}
|
||||
|
||||
// In the first iteration, only draw AI karts, then only draw
|
||||
// player karts. This guarantees that player kart icons are always
|
||||
// on top of AI kart icons.
|
||||
for(unsigned int only_draw_player_kart=0; only_draw_player_kart<=1;
|
||||
only_draw_player_kart++)
|
||||
{
|
||||
for(unsigned int i=0; i<world->getNumKarts(); i++)
|
||||
{
|
||||
const AbstractKart *kart = world->getKart(i);
|
||||
if(kart->isEliminated()) continue; // don't draw eliminated kart
|
||||
// Make sure to only draw AI kart icons first, then
|
||||
// only player karts.
|
||||
if(kart->getController()->isPlayerController()
|
||||
!=(only_draw_player_kart==1)) continue;
|
||||
const Vec3& xyz = kart->getXYZ();
|
||||
Vec3 draw_at;
|
||||
world->getTrack()->mapPoint2MiniMap(xyz, &draw_at);
|
||||
|
||||
core::rect<s32> source(i *m_marker_rendered_size,
|
||||
0,
|
||||
(i+1)*m_marker_rendered_size,
|
||||
m_marker_rendered_size);
|
||||
int marker_half_size = (kart->getController()->isPlayerController()
|
||||
? m_marker_player_size
|
||||
: m_marker_ai_size )>>1;
|
||||
core::rect<s32> position(m_map_left+(int)(draw_at.getX()-marker_half_size),
|
||||
lower_y -(int)(draw_at.getY()+marker_half_size),
|
||||
m_map_left+(int)(draw_at.getX()+marker_half_size),
|
||||
lower_y -(int)(draw_at.getY()-marker_half_size));
|
||||
|
||||
// Highlight the player icons with some backgorund image.
|
||||
if (kart->getController()->isPlayerController())
|
||||
{
|
||||
video::SColor colors[4];
|
||||
for (unsigned int i=0;i<4;i++)
|
||||
{
|
||||
colors[i]=kart->getKartProperties()->getColor();
|
||||
}
|
||||
const core::rect<s32> rect(core::position2d<s32>(0,0),
|
||||
m_icons_frame->getTexture()->getOriginalSize());
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(
|
||||
m_icons_frame->getTexture(), position, rect,
|
||||
NULL, colors, true);
|
||||
} // if isPlayerController
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_marker, position, source,
|
||||
NULL, NULL, true);
|
||||
} // for i<getNumKarts
|
||||
} // for only_draw_player_kart
|
||||
} // drawGlobalMiniMap
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Energy meter that gets filled with nitro. This function is called from
|
||||
* drawSpeedAndEnergy, which defines the correct position of the energy
|
||||
* meter.
|
||||
* \param x X position of the meter.
|
||||
* \param y Y position of the meter.
|
||||
* \param kart Kart to display the data for.
|
||||
* \param scaling Scaling applied (in case of split screen)
|
||||
*/
|
||||
void MinimalRaceGUI::drawEnergyMeter(const AbstractKart *kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
float state = (float)(kart->getEnergy())
|
||||
/ kart->getKartProperties()->getNitroMax();
|
||||
if (state < 0.0f) state = 0.0f;
|
||||
else if (state > 1.0f) state = 1.0f;
|
||||
|
||||
int h = (int)(viewport.getHeight()/3);
|
||||
int w = h/4; // gauge image is so 1:4
|
||||
|
||||
// In split screen mode of 3 or 4 players, the players on
|
||||
// the left side will have the energy meter on the left side
|
||||
int mirrored = race_manager->getNumLocalPlayers()>=3 &&
|
||||
viewport.UpperLeftCorner.X==0;
|
||||
|
||||
int x = mirrored ? 0 : viewport.LowerRightCorner.X - w;
|
||||
int y = viewport.UpperLeftCorner.Y + viewport.getHeight()/2- h/2;
|
||||
|
||||
// Background
|
||||
// ----------
|
||||
core::rect<s32> dest(x+mirrored*w, y+mirrored*h,
|
||||
x+(1-mirrored)*w, y+(1-mirrored)*h);
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_gauge_empty, dest,
|
||||
core::rect<s32>(0, 0, 64, 256) /* source rect */,
|
||||
NULL /* clip rect */, NULL /* colors */,
|
||||
true /* alpha */);
|
||||
// Target
|
||||
// ------
|
||||
if (race_manager->getCoinTarget() > 0)
|
||||
{
|
||||
float coin_target = (float)race_manager->getCoinTarget()
|
||||
/ kart->getKartProperties()->getNitroMax();
|
||||
|
||||
const int EMPTY_TOP_PIXELS = 4;
|
||||
const int EMPTY_BOTTOM_PIXELS = 3;
|
||||
int y1 = y + (int)(EMPTY_TOP_PIXELS +
|
||||
(h - EMPTY_TOP_PIXELS - EMPTY_BOTTOM_PIXELS)
|
||||
*(1.0f - coin_target) );
|
||||
if (state >= 1.0f) y1 = y;
|
||||
|
||||
core::rect<s32> clip(x, y1, x + w, y + h);
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_gauge_goal, core::rect<s32>(x, y, x+w, y+h) /* dest rect */,
|
||||
core::rect<s32>(0, 0, 64, 256) /* source rect */,
|
||||
&clip, NULL /* colors */, true /* alpha */);
|
||||
}
|
||||
|
||||
// Filling (current state)
|
||||
// -----------------------
|
||||
if (state > 0.0f)
|
||||
{
|
||||
const int EMPTY_TOP_PIXELS = 4;
|
||||
const int EMPTY_BOTTOM_PIXELS = 3;
|
||||
int y1 = y + (int)(EMPTY_TOP_PIXELS
|
||||
+ (h - EMPTY_TOP_PIXELS - EMPTY_BOTTOM_PIXELS)
|
||||
*(1.0f - state) );
|
||||
if (state >= 1.0f) y1 = y;
|
||||
core::rect<s32> dest(x+mirrored*w,
|
||||
mirrored ? y+h : y,
|
||||
x+(1-mirrored)*w,
|
||||
mirrored ? y : y + h);
|
||||
core::rect<s32> clip(x, y1, x + w, y + h);
|
||||
core::rect<s32> tex_c(0,
|
||||
mirrored ? 256 : 0,
|
||||
64,
|
||||
mirrored ? 0 : 256);
|
||||
video::ITexture *gauge = kart->getControls().m_nitro
|
||||
? m_gauge_full_bright : m_gauge_full;
|
||||
irr_driver->getVideoDriver()->draw2DImage(gauge, dest, tex_c,
|
||||
&clip, NULL /* colors */,
|
||||
true /* alpha */);
|
||||
}
|
||||
|
||||
|
||||
} // drawEnergyMeter
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Displays the rank and the lap of the kart.
|
||||
* \param info Info object c
|
||||
*/
|
||||
void MinimalRaceGUI::drawRankLap(const AbstractKart* kart,
|
||||
const core::recti &viewport)
|
||||
{
|
||||
// Don't display laps or ranks if the kart has already finished the race.
|
||||
if (kart->hasFinishedRace()) return;
|
||||
|
||||
core::recti pos;
|
||||
|
||||
gui::ScalableFont* font = (race_manager->getNumLocalPlayers() > 2
|
||||
? GUIEngine::getSmallFont()
|
||||
: GUIEngine::getFont());
|
||||
float scale = font->getScale();
|
||||
font->setScale(m_font_scale);
|
||||
// Add a black shadow to make the text better readable on
|
||||
// 'white' tracks (e.g. with snow and ice).
|
||||
font->setShadow(video::SColor(255, 0, 0, 0));
|
||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||
WorldWithRank *world = (WorldWithRank*)(World::getWorld());
|
||||
|
||||
if (world->displayRank())
|
||||
{
|
||||
pos.UpperLeftCorner.Y = viewport.UpperLeftCorner.Y;
|
||||
pos.LowerRightCorner.Y = viewport.UpperLeftCorner.Y+50;
|
||||
// Split screen 3 or 4 players, left side:
|
||||
if(viewport.LowerRightCorner.X < UserConfigParams::m_width)
|
||||
{
|
||||
pos.UpperLeftCorner.X = 10;
|
||||
pos.LowerRightCorner.X = viewport.LowerRightCorner.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.UpperLeftCorner.X = viewport.LowerRightCorner.X
|
||||
- m_rank_width-10;
|
||||
pos.LowerRightCorner.X = viewport.LowerRightCorner.X;
|
||||
}
|
||||
|
||||
char str[256];
|
||||
sprintf(str, "%d/%d", kart->getPosition(),
|
||||
world->getCurrentNumKarts());
|
||||
font->draw(str, pos, color);
|
||||
}
|
||||
|
||||
// Don't display laps in follow the leader mode
|
||||
if(world->raceHasLaps())
|
||||
{
|
||||
const int lap = world->getKartLaps(kart->getWorldKartId());
|
||||
|
||||
// don't display 'lap 0/...'
|
||||
if(lap>=0)
|
||||
{
|
||||
pos.LowerRightCorner.Y = viewport.LowerRightCorner.Y;
|
||||
pos.UpperLeftCorner.Y = viewport.LowerRightCorner.Y-60;
|
||||
pos.LowerRightCorner.X = viewport.LowerRightCorner.X;
|
||||
// Split screen 3 or 4 players, left side:
|
||||
if(viewport.LowerRightCorner.X < UserConfigParams::m_width)
|
||||
{
|
||||
pos.UpperLeftCorner.X = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.UpperLeftCorner.X = (int)(viewport.LowerRightCorner.X
|
||||
- m_lap_width -10 );
|
||||
}
|
||||
|
||||
char str[256];
|
||||
sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps());
|
||||
core::stringw s = m_string_lap+" "+str;
|
||||
font->draw(s.c_str(), pos, color);
|
||||
}
|
||||
}
|
||||
font->setScale(scale);
|
||||
font->disableShadow();
|
||||
} // drawRankLap
|
||||
|
||||
//-----------------------------------------------------------------------------
|
@ -1,128 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
|
||||
// Copyright (C) 2006 Joerg Henrichs, SuperTuxKart-Team, Steve Baker
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_MINIMAL_RACE_GUI_HPP
|
||||
#define HEADER_MINIMAL_RACE_GUI_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <vector2d.h>
|
||||
#include <irrString.h>
|
||||
#include <dimension2d.h>
|
||||
namespace irr
|
||||
{
|
||||
namespace video { class ITexture; }
|
||||
}
|
||||
using namespace irr;
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
|
||||
class AbstractKart;
|
||||
class InputMap;
|
||||
class Material;
|
||||
class RaceSetup;
|
||||
|
||||
/**
|
||||
* \brief Handles the in-race GUI (messages, mini-map, rankings, timer, etc...)
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class MinimalRaceGUI : public RaceGUIBase
|
||||
{
|
||||
private:
|
||||
|
||||
/** Translated string 'lap' displayed every frame. */
|
||||
core::stringw m_string_lap;
|
||||
|
||||
/** Length of 'Lap 99/99' */
|
||||
int m_lap_width;
|
||||
|
||||
/** Translated string 'rank' displayed every frame. */
|
||||
core::stringw m_string_rank;
|
||||
|
||||
/** Maximum string length for the timer */
|
||||
int m_timer_width;
|
||||
|
||||
/** The width of the 'X/Y' rank display. */
|
||||
int m_rank_width;
|
||||
|
||||
/** A scaling factor for the font for time, rank, and lap display. */
|
||||
float m_font_scale;
|
||||
|
||||
// Minimap related variables
|
||||
// -------------------------
|
||||
/** The mini map of the track. */
|
||||
video::ITexture *m_mini_map;
|
||||
|
||||
/** The size of a single marker on the screen for AI karts,
|
||||
* need not be a power of 2. */
|
||||
int m_marker_ai_size;
|
||||
|
||||
/** The size of a single marker on the screen or player karts,
|
||||
* need not be a power of 2. */
|
||||
int m_marker_player_size;
|
||||
|
||||
/** The width of the rendered mini map in pixels, must be a power of 2. */
|
||||
int m_map_rendered_width;
|
||||
|
||||
/** The height of the rendered mini map in pixels, must be a power of 2. */
|
||||
int m_map_rendered_height;
|
||||
|
||||
/** Width of the map in pixels on the screen, need not be a power of 2. */
|
||||
int m_map_width;
|
||||
|
||||
/** Height of the map in pixels on the screen, need not be a power of 2. */
|
||||
int m_map_height;
|
||||
|
||||
/** Distance of map from left side of screen. */
|
||||
int m_map_left;
|
||||
|
||||
/** Distance of map from bottom of screen. */
|
||||
int m_map_bottom;
|
||||
|
||||
/** Used to display messages without overlapping */
|
||||
int m_max_font_height;
|
||||
|
||||
/** previous position of icons */
|
||||
std::vector< core::vector2d<s32> > m_previous_icons_position;
|
||||
|
||||
/* Display informat for one player on the screen. */
|
||||
void drawEnergyMeter (const AbstractKart *kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawRankLap (const AbstractKart* kart,
|
||||
const core::recti &viewport);
|
||||
/** Display items that are shown once only (for all karts). */
|
||||
void drawGlobalMiniMap ();
|
||||
void drawGlobalTimer ();
|
||||
|
||||
public:
|
||||
|
||||
MinimalRaceGUI();
|
||||
~MinimalRaceGUI();
|
||||
virtual void renderGlobal(float dt);
|
||||
virtual void renderPlayerView(const Camera *camera, float dt);
|
||||
|
||||
/** Returns the size of the texture on which to render the minimap to. */
|
||||
virtual const core::dimension2du getMiniMapSize() const
|
||||
{ return core::dimension2du(m_map_width, m_map_height); }
|
||||
}; // MinimalRaceGUI
|
||||
|
||||
#endif
|
@ -64,8 +64,17 @@ RaceGUI::RaceGUI()
|
||||
m_marker_rendered_size = 2 << ((int) ceil(1.0 + log(32.0 * scaling)));
|
||||
m_marker_ai_size = (int)( 14.0f * scaling);
|
||||
m_marker_player_size = (int)( 16.0f * scaling);
|
||||
m_map_width = (int)(100.0f * scaling);
|
||||
m_map_height = (int)(100.0f * scaling);
|
||||
|
||||
if (UserConfigParams::m_minimal_race_gui)
|
||||
{
|
||||
m_map_width = (int)(160.0f * scaling);
|
||||
m_map_height = (int)(160.0f * scaling);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_map_width = (int)(100.0f * scaling);
|
||||
m_map_height = (int)(100.0f * scaling);
|
||||
}
|
||||
m_map_left = (int)( 10.0f * scaling);
|
||||
m_map_bottom = (int)( 10.0f * scaling);
|
||||
|
||||
@ -177,7 +186,11 @@ void RaceGUI::renderGlobal(float dt)
|
||||
|
||||
drawGlobalMiniMap();
|
||||
|
||||
if (!m_is_tutorial) drawGlobalPlayerIcons(m_map_height);
|
||||
if (!m_is_tutorial &&
|
||||
(UserConfigParams::m_minimal_race_gui == false || world->getIdent() == IDENT_STRIKES))
|
||||
{
|
||||
drawGlobalPlayerIcons(m_map_height);
|
||||
}
|
||||
} // renderGlobal
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -203,7 +216,9 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt)
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
drawPowerupIcons (kart, viewport, scaling);
|
||||
drawSpeedAndEnergy (kart, viewport, scaling);
|
||||
|
||||
if (UserConfigParams::m_minimal_race_gui == false)
|
||||
drawSpeedAndEnergy (kart, viewport, scaling);
|
||||
|
||||
if (!m_is_tutorial)
|
||||
drawRankLap (kart, viewport);
|
||||
|
@ -287,6 +287,7 @@ void RaceGUIBase::drawAllMessages(const AbstractKart* kart,
|
||||
// Draw less important messages first, at the very bottom of the screen
|
||||
// unimportant messages are skipped in multiplayer, they take too much screen space
|
||||
if (race_manager->getNumLocalPlayers() < 2 &&
|
||||
UserConfigParams::m_minimal_race_gui == false &&
|
||||
!m_ignore_unimportant_messages)
|
||||
{
|
||||
for (AllMessageType::const_iterator i = m_messages.begin();
|
||||
|
Loading…
Reference in New Issue
Block a user