Apply patch by Marc Coll to have better progress reports during long GPs, thanks!
This commit is contained in:
parent
1740407e1e
commit
348a20288f
BIN
data/gui/scroll_down.png
Normal file
BIN
data/gui/scroll_down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
data/gui/scroll_up.png
Normal file
BIN
data/gui/scroll_up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -30,6 +30,7 @@
|
|||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
#include "guiengine/widget.hpp"
|
#include "guiengine/widget.hpp"
|
||||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||||
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "karts/controller/controller.hpp"
|
#include "karts/controller/controller.hpp"
|
||||||
@ -81,6 +82,38 @@ void RaceResultGUI::init()
|
|||||||
|
|
||||||
music_manager->stopMusic();
|
music_manager->stopMusic();
|
||||||
m_finish_sound = sfx_manager->quickSound("race_finish");
|
m_finish_sound = sfx_manager->quickSound("race_finish");
|
||||||
|
|
||||||
|
// Calculate how many track screenshots can fit into the "result-table" widget
|
||||||
|
GUIEngine::Widget* result_table = getWidget("result-table");
|
||||||
|
assert(result_table != NULL);
|
||||||
|
m_sshot_height = (int)(UserConfigParams::m_height*0.1275);
|
||||||
|
m_max_tracks = std::max (1, ((result_table->m_h - getFontHeight () * 5) /
|
||||||
|
(m_sshot_height + SSHOT_SEPARATION))); //Show at least one
|
||||||
|
|
||||||
|
// Calculate screenshot scrolling parameters
|
||||||
|
const std::vector<std::string>& tracks =
|
||||||
|
race_manager->getGrandPrix()->getTrackNames();
|
||||||
|
int currentTrack = race_manager->getTrackNumber();
|
||||||
|
m_start_track = currentTrack;
|
||||||
|
m_end_track = tracks.size();
|
||||||
|
if (m_end_track > m_max_tracks)
|
||||||
|
{
|
||||||
|
if (currentTrack == 0)
|
||||||
|
{
|
||||||
|
m_start_track = 0;
|
||||||
|
m_end_track = m_max_tracks;
|
||||||
|
}
|
||||||
|
else if (currentTrack + m_max_tracks - 1 > (int)tracks.size())
|
||||||
|
{
|
||||||
|
m_start_track = (tracks.size() - m_max_tracks);
|
||||||
|
m_end_track = tracks.size();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_start_track = currentTrack - 1;
|
||||||
|
m_end_track = currentTrack + m_max_tracks - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -183,6 +216,20 @@ void RaceResultGUI::enableAllButtons()
|
|||||||
void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||||
const std::string& name, const int playerID)
|
const std::string& name, const int playerID)
|
||||||
{
|
{
|
||||||
|
int n_tracks = race_manager->getGrandPrix()->getNumberOfTracks();
|
||||||
|
if (name == "up_button" && n_tracks > m_max_tracks && m_start_track > 0)
|
||||||
|
{
|
||||||
|
m_start_track--;
|
||||||
|
m_end_track--;
|
||||||
|
displayScreenShots();
|
||||||
|
}
|
||||||
|
else if (name == "down_button" && n_tracks > m_max_tracks &&
|
||||||
|
m_start_track < (n_tracks - m_max_tracks))
|
||||||
|
{
|
||||||
|
m_start_track++;
|
||||||
|
m_end_track++;
|
||||||
|
displayScreenShots();
|
||||||
|
}
|
||||||
|
|
||||||
// If something was unlocked, the 'continue' button was
|
// If something was unlocked, the 'continue' button was
|
||||||
// actually used to display "Show unlocked feature(s)" text.
|
// actually used to display "Show unlocked feature(s)" text.
|
||||||
@ -462,7 +509,7 @@ void RaceResultGUI::determineTableLayout()
|
|||||||
? 27
|
? 27
|
||||||
: (int)(40*(table_area->m_w/800.0f));
|
: (int)(40*(table_area->m_w/800.0f));
|
||||||
|
|
||||||
m_width_column_space = 20;
|
m_width_column_space = 10;
|
||||||
|
|
||||||
// Determine width of new points column
|
// Determine width of new points column
|
||||||
|
|
||||||
@ -489,8 +536,6 @@ void RaceResultGUI::determineTableLayout()
|
|||||||
+ 2 * m_width_column_space;
|
+ 2 * m_width_column_space;
|
||||||
|
|
||||||
m_leftmost_column = table_area->m_x;
|
m_leftmost_column = table_area->m_x;
|
||||||
|
|
||||||
m_gp_progress_x = (int)(UserConfigParams::m_width*0.65);
|
|
||||||
} // determineTableLayout
|
} // determineTableLayout
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1045,83 +1090,127 @@ void RaceResultGUI::enableGPProgress()
|
|||||||
{
|
{
|
||||||
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||||
{
|
{
|
||||||
const std::vector<std::string>& tracks =
|
GUIEngine::Widget* result_table = getWidget("result-table");
|
||||||
race_manager->getGrandPrix()->getTrackNames();
|
assert(result_table != NULL);
|
||||||
size_t currentTrack = race_manager->getTrackNumber();
|
|
||||||
|
|
||||||
// Assume 5 is the max amount we can render in any given height
|
int currentTrack = race_manager->getTrackNumber();
|
||||||
size_t startTrack = 0;
|
int font_height = getFontHeight ();
|
||||||
size_t endTrack = tracks.size();
|
int w = (int)(UserConfigParams::m_width*0.17);
|
||||||
if (tracks.size() > 5)
|
int x = (int)(result_table->m_x + result_table->m_w - w - 15);
|
||||||
{
|
int y = (m_top + font_height + 5);
|
||||||
if (currentTrack == 0)
|
|
||||||
{
|
|
||||||
startTrack = 0;
|
|
||||||
endTrack = 5;
|
|
||||||
}
|
|
||||||
else if (currentTrack + 4 > tracks.size())
|
|
||||||
{
|
|
||||||
startTrack = tracks.size() - 5;
|
|
||||||
endTrack = tracks.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
startTrack = currentTrack - 1;
|
|
||||||
endTrack = currentTrack + 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(size_t i=startTrack; i<endTrack; i++)
|
//Current progress
|
||||||
|
GUIEngine::LabelWidget* status_label = new GUIEngine::LabelWidget();
|
||||||
|
status_label->m_properties[GUIEngine::PROP_ID] = "status_label";
|
||||||
|
status_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center";
|
||||||
|
status_label->m_x = x;
|
||||||
|
status_label->m_y = y;
|
||||||
|
status_label->m_w = w;
|
||||||
|
status_label->m_h = font_height;
|
||||||
|
status_label->add();
|
||||||
|
status_label->setText(_("Track %i/%i", currentTrack + 1,
|
||||||
|
race_manager->getGrandPrix()->getNumberOfTracks()), true);
|
||||||
|
addGPProgressWidget(status_label);
|
||||||
|
y = (status_label->m_y + status_label->m_h + 5);
|
||||||
|
|
||||||
|
//Scroll up button
|
||||||
|
GUIEngine::IconButtonWidget* up_button = new GUIEngine::IconButtonWidget(
|
||||||
|
GUIEngine::IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
||||||
|
false, false, GUIEngine::IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||||
|
up_button->m_properties[GUIEngine::PROP_ID] = "up_button";
|
||||||
|
up_button->m_x = x;
|
||||||
|
up_button->m_y = y;
|
||||||
|
up_button->m_w = w;
|
||||||
|
up_button->m_h = font_height;
|
||||||
|
up_button->add();
|
||||||
|
up_button->setImage(file_manager->getAsset(FileManager::GUI,"scroll_up.png"));
|
||||||
|
addGPProgressWidget(up_button);
|
||||||
|
y = (up_button->m_y + up_button->m_h + SSHOT_SEPARATION);
|
||||||
|
|
||||||
|
//Track screenshots and labels
|
||||||
|
int n_sshot = 1;
|
||||||
|
for(int i=m_start_track; i<m_end_track; i++)
|
||||||
{
|
{
|
||||||
Track* track = track_manager->getTrack(tracks[i]);
|
//Screenshot
|
||||||
GUIEngine::IconButtonWidget* m_screenshot_widget =
|
GUIEngine::IconButtonWidget* screenshot_widget =
|
||||||
new GUIEngine::IconButtonWidget(GUIEngine::IconButtonWidget::
|
new GUIEngine::IconButtonWidget(
|
||||||
|
GUIEngine::IconButtonWidget::
|
||||||
SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
||||||
false, false,
|
false, false,
|
||||||
GUIEngine::IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
GUIEngine::IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||||
m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);
|
screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);
|
||||||
m_screenshot_widget->m_x = (int)(UserConfigParams::m_width*0.67);
|
screenshot_widget->m_x = x;
|
||||||
m_screenshot_widget->m_y =
|
screenshot_widget->m_y = y;
|
||||||
(int)(UserConfigParams::m_height
|
screenshot_widget->m_w = w;
|
||||||
* (0.10+(i-startTrack)*0.135));
|
screenshot_widget->m_h = m_sshot_height;
|
||||||
m_screenshot_widget->m_w = (int)(UserConfigParams::m_width*0.17);
|
screenshot_widget->m_properties[GUIEngine::PROP_ID] =
|
||||||
m_screenshot_widget->m_h =
|
("sshot_" + StringUtils::toString(n_sshot));
|
||||||
(int)(UserConfigParams::m_height*0.1275);
|
screenshot_widget->add();
|
||||||
|
addGPProgressWidget(screenshot_widget);
|
||||||
|
|
||||||
m_screenshot_widget->m_properties[GUIEngine::PROP_ICON] =
|
//Label
|
||||||
(track ? track->getScreenshotFile()
|
GUIEngine::LabelWidget* sshot_label = new GUIEngine::LabelWidget();
|
||||||
: file_manager->getAsset(FileManager::GUI,"main_help.png"));
|
sshot_label->m_properties[GUIEngine::PROP_ID] =
|
||||||
m_screenshot_widget->m_properties[GUIEngine::PROP_ID] = tracks[i];
|
("sshot_label_" + StringUtils::toString(n_sshot));
|
||||||
|
sshot_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "left";
|
||||||
|
sshot_label->m_x = (x + w + 5);
|
||||||
|
sshot_label->m_y = (y + (m_sshot_height / 2) - (font_height / 2));
|
||||||
|
sshot_label->m_w = (w / 2);
|
||||||
|
sshot_label->m_h = font_height;
|
||||||
|
sshot_label->add();
|
||||||
|
addGPProgressWidget(sshot_label);
|
||||||
|
|
||||||
if(i <= currentTrack)
|
y += (m_sshot_height + SSHOT_SEPARATION);
|
||||||
m_screenshot_widget->setBadge(GUIEngine::OK_BADGE);
|
n_sshot++;
|
||||||
|
|
||||||
m_screenshot_widget->add();
|
|
||||||
m_widgets.push_back(m_screenshot_widget);
|
|
||||||
} // for
|
} // for
|
||||||
|
displayScreenShots();
|
||||||
|
|
||||||
|
//Scroll down button
|
||||||
|
GUIEngine::IconButtonWidget* down_button = new GUIEngine::IconButtonWidget(
|
||||||
|
GUIEngine::IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
||||||
|
false, false, GUIEngine::IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||||
|
down_button->m_properties[GUIEngine::PROP_ID] = "down_button";
|
||||||
|
down_button->m_x = x;
|
||||||
|
down_button->m_y = y;
|
||||||
|
down_button->m_w = w;
|
||||||
|
down_button->m_h = font_height;
|
||||||
|
down_button->add();
|
||||||
|
down_button->setImage(file_manager->getAsset(FileManager::GUI,"scroll_down.png"));
|
||||||
|
addGPProgressWidget(down_button);
|
||||||
|
|
||||||
} // if MAJOR_MODE_GRAND_PRIX)
|
} // if MAJOR_MODE_GRAND_PRIX)
|
||||||
|
|
||||||
} // enableGPProgress
|
} // enableGPProgress
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void RaceResultGUI::addGPProgressWidget(GUIEngine::Widget* widget)
|
||||||
|
{
|
||||||
|
m_widgets.push_back(widget);
|
||||||
|
m_gp_progress_widgets.push_back(widget);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void RaceResultGUI::displayGPProgress()
|
void RaceResultGUI::displayGPProgress()
|
||||||
{
|
{
|
||||||
video::SColor color = video::SColor(255,255,0,0);
|
const wchar_t* msg = _("Grand Prix progress:");
|
||||||
core::recti dest_rect(m_gp_progress_x, m_top, 0, 0);
|
|
||||||
|
|
||||||
m_font->draw(_("Grand Prix progress:"), dest_rect, color, false, false, NULL, true);
|
GUIEngine::Widget* result_table = getWidget("result-table");
|
||||||
|
assert(result_table != NULL);
|
||||||
|
|
||||||
|
video::SColor color = video::SColor(255,255,0,0);
|
||||||
|
core::recti dest_rect(
|
||||||
|
result_table->m_x + result_table->m_w - m_font->getDimension(msg).Width - 5,
|
||||||
|
m_top, 0, 0);
|
||||||
|
|
||||||
|
m_font->draw(msg, dest_rect, color, false, false, NULL, true);
|
||||||
} // displayGPProgress
|
} // displayGPProgress
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void RaceResultGUI::cleanupGPProgress()
|
void RaceResultGUI::cleanupGPProgress()
|
||||||
{
|
{
|
||||||
const std::vector<std::string>& tracks =
|
for (size_t i = 0; i < m_gp_progress_widgets.size(); i++)
|
||||||
race_manager->getGrandPrix()->getTrackNames();
|
m_widgets.remove(m_gp_progress_widgets.get(i));
|
||||||
for(size_t i=0; i<tracks.size(); i++)
|
m_gp_progress_widgets.clearAndDeleteAll();
|
||||||
{
|
|
||||||
GUIEngine::Widget *trackWidget = getWidget(tracks[i].c_str());
|
|
||||||
m_widgets.remove(trackWidget);
|
|
||||||
delete trackWidget;
|
|
||||||
}
|
|
||||||
} // cleanupGPProgress
|
} // cleanupGPProgress
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -1137,7 +1226,7 @@ void RaceResultGUI::displayHighScores()
|
|||||||
{
|
{
|
||||||
video::SColor white_color = video::SColor(255,255,255,255);
|
video::SColor white_color = video::SColor(255,255,255,255);
|
||||||
|
|
||||||
int x = (int)(UserConfigParams::m_width*0.55f);
|
int x = (int)(UserConfigParams::m_width*0.65f);
|
||||||
int y = m_top;
|
int y = m_top;
|
||||||
|
|
||||||
// First draw title
|
// First draw title
|
||||||
@ -1210,3 +1299,39 @@ void RaceResultGUI::displayHighScores()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void RaceResultGUI::displayScreenShots()
|
||||||
|
{
|
||||||
|
const std::vector<std::string>& tracks =
|
||||||
|
race_manager->getGrandPrix()->getTrackNames();
|
||||||
|
int currentTrack = race_manager->getTrackNumber();
|
||||||
|
|
||||||
|
int n_sshot = 1;
|
||||||
|
for(int i = m_start_track; i < m_end_track; i++)
|
||||||
|
{
|
||||||
|
Track* track = track_manager->getTrack(tracks[i]);
|
||||||
|
GUIEngine::IconButtonWidget* sshot = getWidget<GUIEngine::IconButtonWidget>(
|
||||||
|
("sshot_" + StringUtils::toString(n_sshot)).c_str());
|
||||||
|
GUIEngine::LabelWidget* label = getWidget<GUIEngine::LabelWidget>(
|
||||||
|
("sshot_label_" + StringUtils::toString(n_sshot)).c_str());
|
||||||
|
assert(track != NULL && sshot != NULL && label != NULL);
|
||||||
|
|
||||||
|
sshot->setImage(track->getScreenshotFile());
|
||||||
|
if (i <= currentTrack)
|
||||||
|
sshot->setBadge(GUIEngine::OK_BADGE);
|
||||||
|
else
|
||||||
|
sshot->resetAllBadges();
|
||||||
|
|
||||||
|
label->setText(StringUtils::toWString(i + 1), true);
|
||||||
|
|
||||||
|
n_sshot++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
int RaceResultGUI::getFontHeight () const
|
||||||
|
{
|
||||||
|
assert(m_font != NULL);
|
||||||
|
return m_font->getDimension(L"A").Height; //Could be any capital letter
|
||||||
|
}
|
||||||
|
@ -158,9 +158,6 @@ private:
|
|||||||
/** The overall width of the table. */
|
/** The overall width of the table. */
|
||||||
unsigned int m_table_width;
|
unsigned int m_table_width;
|
||||||
|
|
||||||
/** GP Progress text */
|
|
||||||
unsigned int m_gp_progress_x;
|
|
||||||
|
|
||||||
/** The font to use. */
|
/** The font to use. */
|
||||||
gui::ScalableFont *m_font;
|
gui::ScalableFont *m_font;
|
||||||
|
|
||||||
@ -187,16 +184,30 @@ private:
|
|||||||
|
|
||||||
unsigned int m_width_all_points;
|
unsigned int m_width_all_points;
|
||||||
|
|
||||||
|
int m_max_tracks;
|
||||||
|
int m_start_track;
|
||||||
|
int m_end_track;
|
||||||
|
int m_sshot_height;
|
||||||
|
|
||||||
|
PtrVector<GUIEngine::Widget, HOLD> m_gp_progress_widgets;
|
||||||
|
|
||||||
|
static const int SSHOT_SEPARATION = 10;
|
||||||
|
|
||||||
void displayOneEntry(unsigned int x, unsigned int y,
|
void displayOneEntry(unsigned int x, unsigned int y,
|
||||||
unsigned int n, bool display_points);
|
unsigned int n, bool display_points);
|
||||||
void determineTableLayout();
|
void determineTableLayout();
|
||||||
void determineGPLayout();
|
void determineGPLayout();
|
||||||
void enableAllButtons();
|
void enableAllButtons();
|
||||||
void enableGPProgress();
|
void enableGPProgress();
|
||||||
|
void addGPProgressWidget(GUIEngine::Widget* widget);
|
||||||
void displayGPProgress();
|
void displayGPProgress();
|
||||||
void cleanupGPProgress();
|
void cleanupGPProgress();
|
||||||
void displayHighScores();
|
void displayHighScores();
|
||||||
void displaySoccerResults();
|
void displaySoccerResults();
|
||||||
|
void displayScreenShots();
|
||||||
|
|
||||||
|
int getFontHeight () const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RaceResultGUI();
|
RaceResultGUI();
|
||||||
|
Loading…
Reference in New Issue
Block a user