Merge branch 'master' of https://github.com/marcoll/stk-code into marcoll-master
This commit is contained in:
commit
c5434aa845
@ -23,7 +23,6 @@
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <IGUIEnvironment.h>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
@ -46,6 +45,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row)
|
||||
m_check_inside_me = true;
|
||||
m_supports_multiplayer = true;
|
||||
m_scrolling_enabled = true;
|
||||
m_animated_contents = false;
|
||||
|
||||
// by default, set all players to have no selection in this ribbon
|
||||
for (unsigned int n=0; n<MAX_PLAYER_COUNT; n++)
|
||||
@ -62,7 +62,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row)
|
||||
// -----------------------------------------------------------------------------
|
||||
DynamicRibbonWidget::~DynamicRibbonWidget()
|
||||
{
|
||||
m_font->drop();
|
||||
delete m_font;
|
||||
if (m_animated_contents)
|
||||
{
|
||||
GUIEngine::needsUpdate.remove(this);
|
||||
|
@ -42,6 +42,7 @@ IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop,
|
||||
m_label = NULL;
|
||||
m_font = NULL;
|
||||
m_texture = NULL;
|
||||
m_deactivated_texture = NULL;
|
||||
m_highlight_texture = NULL;
|
||||
m_custom_aspect_ratio = 1.0f;
|
||||
|
||||
@ -273,6 +274,56 @@ void IconButtonWidget::unfocused(const int playerID, Widget* new_focus)
|
||||
m_label->setVisible(false);
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
const video::ITexture* IconButtonWidget::getTexture()
|
||||
{
|
||||
if (Widget::isActivated())
|
||||
{
|
||||
return m_texture;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_deactivated_texture == NULL)
|
||||
m_deactivated_texture = getDeactivatedTexture(m_texture);
|
||||
return m_deactivated_texture;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* texture)
|
||||
{
|
||||
video::ITexture* t;
|
||||
|
||||
std::string name = texture->getName().getPath().c_str();
|
||||
name += "_disabled";
|
||||
t = irr_driver->getTexture(name);
|
||||
if (t == NULL)
|
||||
{
|
||||
SColor c;
|
||||
u32 g;
|
||||
|
||||
video::IVideoDriver* driver = irr_driver->getVideoDriver();
|
||||
std::auto_ptr<video::IImage> image (driver->createImageFromData (texture->getColorFormat(),
|
||||
texture->getSize(), texture->lock(), false));
|
||||
texture->unlock();
|
||||
|
||||
//Turn the image into grayscale
|
||||
for (u32 x = 0; x < image->getDimension().Width; x++)
|
||||
{
|
||||
for (u32 y = 0; y < image->getDimension().Height; y++)
|
||||
{
|
||||
c = image->getPixel(x, y);
|
||||
g = ((c.getRed() + c.getGreen() + c.getBlue()) / 3);
|
||||
c.set(std::max (0, (int)c.getAlpha() - 120), g, g, g);
|
||||
image->setPixel(x, y, c);
|
||||
}
|
||||
}
|
||||
|
||||
t = driver->addTexture(name.c_str(), image.get ());
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void IconButtonWidget::setTexture(video::ITexture* texture)
|
||||
@ -280,6 +331,7 @@ void IconButtonWidget::setTexture(video::ITexture* texture)
|
||||
m_texture = texture;
|
||||
if (texture == NULL)
|
||||
{
|
||||
m_deactivated_texture = NULL;
|
||||
m_texture_w = 0;
|
||||
m_texture_h = 0;
|
||||
}
|
||||
|
@ -43,9 +43,11 @@ namespace GUIEngine
|
||||
{
|
||||
private:
|
||||
irr::video::ITexture* m_texture;
|
||||
irr::video::ITexture* m_deactivated_texture;
|
||||
irr::video::ITexture* m_highlight_texture;
|
||||
int m_texture_w, m_texture_h;
|
||||
|
||||
video::ITexture* getDeactivatedTexture(video::ITexture* texture);
|
||||
void setLabelFont();
|
||||
|
||||
public:
|
||||
@ -158,7 +160,7 @@ namespace GUIEngine
|
||||
virtual void unfocused(const int playerID, Widget* new_focus);
|
||||
// --------------------------------------------------------------------
|
||||
/** Returns the texture of this button. */
|
||||
const video::ITexture* getTexture() const { return m_texture; }
|
||||
const video::ITexture* getTexture();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,16 @@ void TrackInfoScreen::loadedFromFile()
|
||||
m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner");
|
||||
m_reverse = getWidget<CheckBoxWidget>("reverse");
|
||||
m_reverse->setState(false);
|
||||
|
||||
m_highscore_label = getWidget<LabelWidget>("highscores");
|
||||
|
||||
m_kart_icons[0] = getWidget<IconButtonWidget>("iconscore1");
|
||||
m_kart_icons[1] = getWidget<IconButtonWidget>("iconscore2");
|
||||
m_kart_icons[2] = getWidget<IconButtonWidget>("iconscore3");
|
||||
|
||||
m_highscore_entries[0] = getWidget<LabelWidget>("highscore1");
|
||||
m_highscore_entries[1] = getWidget<LabelWidget>("highscore2");
|
||||
m_highscore_entries[2] = getWidget<LabelWidget>("highscore3");
|
||||
} // loadedFromFile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -181,30 +191,16 @@ void TrackInfoScreen::init()
|
||||
m_reverse->setState(false);
|
||||
|
||||
// ---- High Scores
|
||||
if (has_highscores)
|
||||
{
|
||||
m_kart_icons[0] = getWidget<IconButtonWidget>("iconscore1");
|
||||
m_kart_icons[1] = getWidget<IconButtonWidget>("iconscore2");
|
||||
m_kart_icons[2] = getWidget<IconButtonWidget>("iconscore3");
|
||||
m_highscore_label->setVisible(has_highscores);
|
||||
|
||||
m_highscore_entries[0] = getWidget<LabelWidget>("highscore1");
|
||||
m_highscore_entries[1] = getWidget<LabelWidget>("highscore2");
|
||||
m_highscore_entries[2] = getWidget<LabelWidget>("highscore3");
|
||||
m_kart_icons[0]->setVisible(has_highscores);
|
||||
m_kart_icons[1]->setVisible(has_highscores);
|
||||
m_kart_icons[2]->setVisible(has_highscores);
|
||||
|
||||
updateHighScores();
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<IconButtonWidget>("iconscore1")->setVisible(false);
|
||||
getWidget<IconButtonWidget>("iconscore2")->setVisible(false);
|
||||
getWidget<IconButtonWidget>("iconscore3")->setVisible(false);
|
||||
m_highscore_entries[0]->setVisible(has_highscores);
|
||||
m_highscore_entries[1]->setVisible(has_highscores);
|
||||
m_highscore_entries[2]->setVisible(has_highscores);
|
||||
|
||||
getWidget<LabelWidget>("highscores")->setVisible(false);
|
||||
getWidget<LabelWidget>("highscore1")->setVisible(false);
|
||||
getWidget<LabelWidget>("highscore2")->setVisible(false);
|
||||
getWidget<LabelWidget>("highscore3")->setVisible(false);
|
||||
}
|
||||
|
||||
RibbonWidget* bt_start = getWidget<GUIEngine::RibbonWidget>("buttons");
|
||||
bt_start->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
@ -220,6 +216,9 @@ TrackInfoScreen::~TrackInfoScreen()
|
||||
|
||||
void TrackInfoScreen::updateHighScores()
|
||||
{
|
||||
if (!race_manager->modeHasHighscores())
|
||||
return;
|
||||
|
||||
std::string game_mode_ident = RaceManager::getIdentOf( race_manager->getMinorMode() );
|
||||
const Highscores::HighscoreType type = "HST_" + game_mode_ident;
|
||||
|
||||
@ -281,7 +280,7 @@ void TrackInfoScreen::onEnterPressedInternal()
|
||||
|
||||
// Create a copy of member variables we still need, since they will
|
||||
// not be accessible after dismiss:
|
||||
const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue()
|
||||
const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue()
|
||||
: -1;
|
||||
const bool reverse_track = m_reverse == NULL ? false
|
||||
: m_reverse->getState();
|
||||
@ -318,10 +317,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
race_manager->setReverseTrack(m_reverse->getState());
|
||||
// Makes sure the highscores get swapped when clicking the 'reverse'
|
||||
// checkbox.
|
||||
if (race_manager->modeHasHighscores())
|
||||
{
|
||||
updateHighScores();
|
||||
}
|
||||
updateHighScores();
|
||||
}
|
||||
else if (name == "lap-spinner")
|
||||
{
|
||||
|
@ -58,18 +58,21 @@ class TrackInfoScreen : public GUIEngine::Screen,
|
||||
/** Check box for reverse mode. */
|
||||
GUIEngine::CheckBoxWidget* m_reverse;
|
||||
|
||||
/** The label of the highscore list. */
|
||||
GUIEngine::LabelWidget* m_highscore_label;
|
||||
|
||||
/** The icons for the highscore list. */
|
||||
GUIEngine::IconButtonWidget* m_kart_icons[HIGHSCORE_COUNT];
|
||||
|
||||
/** The actual highscore text values shown. */
|
||||
GUIEngine::LabelWidget* m_highscore_entries[HIGHSCORE_COUNT];
|
||||
|
||||
|
||||
void updateHighScores();
|
||||
|
||||
|
||||
public:
|
||||
TrackInfoScreen();
|
||||
virtual ~TrackInfoScreen();
|
||||
|
||||
|
||||
virtual void init();
|
||||
virtual void loadedFromFile();
|
||||
virtual void eventCallback(GUIEngine::Widget *,const std::string &name ,
|
||||
|
Loading…
x
Reference in New Issue
Block a user