Added experimental code to give a background per line for the race

result. Too much is hardcoded atm, so it needs some work should
we want this look. Check for #ifdef USE_PER_LINE_BACKGROUND
to see what was done.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5991 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-09-14 01:28:19 +00:00
parent 5fbc6eb0bb
commit 79b0471b01
3 changed files with 32 additions and 10 deletions

View File

@ -242,11 +242,13 @@ namespace GUIEngine
irr::video::ITexture* bg_image; irr::video::ITexture* bg_image;
#ifdef USE_PER_LINE_BACKGROUND
public:
#endif
void drawBoxFromStretchableTexture(SkinWidgetContainer* w, const irr::core::rect< irr::s32 > &dest, void drawBoxFromStretchableTexture(SkinWidgetContainer* w, const irr::core::rect< irr::s32 > &dest,
BoxRenderParams& params, bool deactivated=false, BoxRenderParams& params, bool deactivated=false,
const irr::core::rect<irr::s32>* clipRect=NULL); const irr::core::rect<irr::s32>* clipRect=NULL);
private:
// my utility methods, to work around irrlicht's very Windows-95-like-look-enforcing skin system // my utility methods, to work around irrlicht's very Windows-95-like-look-enforcing skin system
void process3DPane(irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const bool pressed); void process3DPane(irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const bool pressed);
void drawButton(Widget* w, const irr::core::rect< irr::s32 > &rect, const bool pressed, const bool focused); void drawButton(Widget* w, const irr::core::rect< irr::s32 > &rect, const bool pressed, const bool focused);

View File

@ -23,6 +23,7 @@
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp" #include "guiengine/scalable_font.hpp"
#include "guiengine/widget.hpp" #include "guiengine/widget.hpp"
#include "io/file_manager.hpp"
#include "modes/world_with_rank.hpp" #include "modes/world_with_rank.hpp"
#include "states_screens/dialogs/race_over_dialog.hpp" #include "states_screens/dialogs/race_over_dialog.hpp"
#include "states_screens/main_menu_screen.hpp" #include "states_screens/main_menu_screen.hpp"
@ -293,8 +294,8 @@ void RaceResultGUI::determineTableLayout()
m_time_for_points = 1.0f; m_time_for_points = 1.0f;
// Determine text height // Determine text height
r = m_font->getDimension(L"Y"); r = m_font->getDimension(L"Y");
m_distance_between_rows = (int)(1.5f*r.Height); m_distance_between_rows = (int)(1.5f*r.Height);
// If there are too many karts, reduce size between rows // If there are too many karts, reduce size between rows
if(m_distance_between_rows * num_karts > height) if(m_distance_between_rows * num_karts > height)
@ -314,18 +315,18 @@ void RaceResultGUI::determineTableLayout()
core::dimension2du r_all_p = m_font->getDimension(L"999"); core::dimension2du r_all_p = m_font->getDimension(L"999");
unsigned int width_all_points = r_all_p.Width; unsigned int width_all_points = r_all_p.Width;
unsigned int table_width = m_width_icon + m_width_column_space m_table_width = m_width_icon + m_width_column_space
+ m_width_kart_name; + m_width_kart_name;
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER) if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
table_width += m_width_finish_time + m_width_column_space; m_table_width += m_width_finish_time + m_width_column_space;
// Only in GP mode are the points displayed. // Only in GP mode are the points displayed.
if (race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX) if (race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX)
table_width += m_width_new_points + width_all_points m_table_width += m_width_new_points + width_all_points
+ 2 * m_width_column_space; + 2 * m_width_column_space;
m_leftmost_column = table_area->m_x + (table_area->m_w - table_width)/2; m_leftmost_column = table_area->m_x + (table_area->m_w - m_table_width)/2;
} // determineTableLayout } // determineTableLayout
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -583,6 +584,16 @@ void RaceResultGUI::displayOneEntry(unsigned int x, unsigned int y,
video::SColor color = ri->m_is_player_kart ? video::SColor(255,255,0, 0 ) video::SColor color = ri->m_is_player_kart ? video::SColor(255,255,0, 0 )
: video::SColor(255,255,255,255); : video::SColor(255,255,255,255);
#ifdef USE_PER_LINE_BACKGROUND
// Draw the background image
core::rect<s32> dest(x-50, y,
x+50+m_table_width,
(int)(y+m_distance_between_rows));
ri->m_box_params.setTexture(irr_driver->getTexture( (file_manager->getGUIDir() + "skins/glass/glassbutton_focused.png").c_str() ) );
GUIEngine::getSkin()->drawBoxFromStretchableTexture(&(ri->m_widget_container),
dest,
ri->m_box_params);
#endif
unsigned int current_x = x; unsigned int current_x = x;
// First draw the icon // First draw the icon

View File

@ -95,6 +95,12 @@ private:
video::ITexture *m_kart_icon; video::ITexture *m_kart_icon;
/** The times of all karts in the right order. */ /** The times of all karts in the right order. */
core::stringw m_finish_time_string; core::stringw m_finish_time_string;
#ifdef USE_PER_LINE_BACKGROUND
/** For the background bar behind each line. */
GUIEngine::SkinWidgetContainer m_widget_container;
/** The parameter for rendering the background box. */
GUIEngine::BoxRenderParams m_box_params;
#endif
}; // Rowinfo }; // Rowinfo
std::vector<RowInfo> m_all_row_infos; std::vector<RowInfo> m_all_row_infos;
@ -141,6 +147,9 @@ private:
/** Size of space between columns. */ /** Size of space between columns. */
unsigned int m_width_column_space; unsigned int m_width_column_space;
/** The overall width of the table. */
unsigned int m_table_width;
/** The font to use. */ /** The font to use. */
gui::ScalableFont *m_font; gui::ScalableFont *m_font;