GP info screen now shows cycling screenshots of its tracks
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4701 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a43196a8b4
commit
512326776e
src/states_screens/dialogs
@ -40,6 +40,8 @@ using namespace GUIEngine;
|
|||||||
|
|
||||||
GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const float h) : ModalDialog(w, h)
|
GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const float h) : ModalDialog(w, h)
|
||||||
{
|
{
|
||||||
|
m_curr_time = 0.0f;
|
||||||
|
|
||||||
const int y1 = m_area.getHeight()/7;
|
const int y1 = m_area.getHeight()/7;
|
||||||
const int y2 = m_area.getHeight()*6/7;
|
const int y2 = m_area.getHeight()*6/7;
|
||||||
|
|
||||||
@ -74,7 +76,6 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
|
|||||||
for (int t=0; t<trackAmount; t++)
|
for (int t=0; t<trackAmount; t++)
|
||||||
{
|
{
|
||||||
const int from_y = y1 + height_of_one_line*(t+1);
|
const int from_y = y1 + height_of_one_line*(t+1);
|
||||||
const int next_from_y = y1 + height_of_one_line*(t+2);
|
|
||||||
|
|
||||||
Track* track = track_manager->getTrack(tracks[t]);
|
Track* track = track_manager->getTrack(tracks[t]);
|
||||||
stringw lineText;
|
stringw lineText;
|
||||||
@ -88,36 +89,44 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa
|
|||||||
{
|
{
|
||||||
lineText = track->getName();
|
lineText = track->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LabelWidget* widget = new LabelWidget();
|
||||||
|
widget->m_text = lineText;
|
||||||
|
widget->x = 20;
|
||||||
|
widget->y = from_y;
|
||||||
|
widget->w = m_area.getWidth()/2 - 20;
|
||||||
|
widget->h = height_of_one_line;
|
||||||
|
widget->setParent(m_irrlicht_window);
|
||||||
|
|
||||||
core::rect< s32 > entry_area(20, from_y, m_area.getWidth()/2, next_from_y);
|
m_children.push_back(widget);
|
||||||
IGUIStaticText* line = GUIEngine::getGUIEnv()->addStaticText( lineText.c_str(),
|
widget->add();
|
||||||
entry_area, false , true , // border, word warp
|
|
||||||
m_irrlicht_window);
|
// IGUIStaticText* line = GUIEngine::getGUIEnv()->addStaticText( lineText.c_str(),
|
||||||
|
// entry_area, false , true , // border, word warp
|
||||||
|
// m_irrlicht_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// ---- Track screenshot
|
// ---- Track screenshot
|
||||||
IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
m_screenshot_widget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
||||||
false, false);
|
false, false);
|
||||||
// images are saved squared, but must be stretched to 4:
|
// images are saved squared, but must be stretched to 4:3
|
||||||
screenshotWidget->setCustomAspectRatio(4.0f / 3.0f); 3
|
m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);
|
||||||
core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y1-10);
|
|
||||||
|
|
||||||
screenshotWidget->x = area_right.UpperLeftCorner.X;
|
m_screenshot_widget->x = m_area.getWidth()/2;
|
||||||
screenshotWidget->y = area_right.UpperLeftCorner.Y;
|
m_screenshot_widget->y = y1;
|
||||||
screenshotWidget->w = area_right.getWidth();
|
m_screenshot_widget->w = m_area.getWidth()/2;
|
||||||
screenshotWidget->h = area_right.getHeight();
|
m_screenshot_widget->h = y2 - y1 - 10;
|
||||||
|
|
||||||
// temporary icon, will replace it just after
|
Track* track = track_manager->getTrack(tracks[0]);
|
||||||
screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png";
|
|
||||||
screenshotWidget->setParent(m_irrlicht_window);
|
// temporary icon, will replace it just after adding (hack to support absolute paths [FIXME])
|
||||||
screenshotWidget->add();
|
m_screenshot_widget->m_properties[PROP_ICON] = "gui/main_help.png";
|
||||||
screenshotWidget->setImage(screenshot);
|
|
||||||
m_children.push_back(screenshotWidget);
|
m_screenshot_widget->setParent(m_irrlicht_window);
|
||||||
|
m_screenshot_widget->add();
|
||||||
|
m_screenshot_widget->setImage(track != NULL ? track->getScreenshotFile().c_str() : "gui/main_help.png");
|
||||||
|
m_children.push_back(m_screenshot_widget);
|
||||||
|
|
||||||
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
|
||||||
b->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ---- Start button
|
// ---- Start button
|
||||||
ButtonWidget* okBtn = new ButtonWidget();
|
ButtonWidget* okBtn = new ButtonWidget();
|
||||||
@ -200,3 +209,26 @@ GUIEngine::EventPropagation GPInfoDialog::processEvent(std::string& eventSource)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GPInfoDialog::onUpdate(float dt)
|
||||||
|
{
|
||||||
|
const int frameBefore = (int)(m_curr_time / 1.5f);
|
||||||
|
m_curr_time += dt;
|
||||||
|
int frameAfter = (int)(m_curr_time / 1.5f);
|
||||||
|
|
||||||
|
if (frameAfter == frameBefore) return; // if nothing changed, return right now
|
||||||
|
|
||||||
|
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(m_gp_ident);
|
||||||
|
assert(gp != NULL);
|
||||||
|
const std::vector<std::string>& tracks = gp->getTracks();
|
||||||
|
if (frameAfter >= (int)tracks.size())
|
||||||
|
{
|
||||||
|
frameAfter = 0;
|
||||||
|
m_curr_time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Track* track = track_manager->getTrack(tracks[frameAfter]);
|
||||||
|
m_screenshot_widget->setImage(track != NULL ? track->getScreenshotFile().c_str() : "gui/main_help.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
@ -21,10 +21,17 @@
|
|||||||
|
|
||||||
#include "guiengine/modaldialog.hpp"
|
#include "guiengine/modaldialog.hpp"
|
||||||
|
|
||||||
|
namespace GUIEngine
|
||||||
|
{
|
||||||
|
class IconButtonWidget;
|
||||||
|
}
|
||||||
|
|
||||||
class GPInfoDialog : public GUIEngine::ModalDialog
|
class GPInfoDialog : public GUIEngine::ModalDialog
|
||||||
{
|
{
|
||||||
std::string m_gp_ident;
|
std::string m_gp_ident;
|
||||||
|
GUIEngine::IconButtonWidget* m_screenshot_widget;
|
||||||
|
|
||||||
|
float m_curr_time;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -35,6 +42,9 @@ public:
|
|||||||
|
|
||||||
void onEnterPressedInternal();
|
void onEnterPressedInternal();
|
||||||
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||||
|
|
||||||
|
virtual void onUpdate(float dt);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,7 +90,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
|
|||||||
screenshotWidget->w = area_right.getWidth();
|
screenshotWidget->w = area_right.getWidth();
|
||||||
screenshotWidget->h = area_right.getHeight();
|
screenshotWidget->h = area_right.getHeight();
|
||||||
|
|
||||||
// temporary icon, will replace it just after
|
// temporary icon, will replace it just after (hack to support absolute paths [FIXME])
|
||||||
screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png";
|
screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png";
|
||||||
screenshotWidget->setParent(m_irrlicht_window);
|
screenshotWidget->setParent(m_irrlicht_window);
|
||||||
screenshotWidget->add();
|
screenshotWidget->add();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user