Removed old track info dialog, fixed crashes in track info screen
(caused when making some spinners etc. visible).
This commit is contained in:
parent
4b507a4eda
commit
76767141f7
@ -10,13 +10,13 @@
|
||||
<spacer width="1" height="5%"/>
|
||||
|
||||
<box width="95%" height="45%" padding="10" layout="horizontal-row">
|
||||
<!-- Right pane -->
|
||||
<!-- Left pane -->
|
||||
<div proportion="1" height="100%" layout="vertical-row">
|
||||
<placeholder proportion="1" width="100%" height="100%" id="screenshot_div">
|
||||
</placeholder>
|
||||
|
||||
</div>
|
||||
<!-- Left pane -->
|
||||
<!-- Right pane -->
|
||||
<div proportion="1" height="100%" layout="vertical-row">
|
||||
<label id="highscores" width="100%" text_align="center" text="= Highscores ="/>
|
||||
|
||||
@ -58,15 +58,15 @@
|
||||
<spacer width="40" height="2" />
|
||||
<label id="lap-text" height="100%" width="40%" I18N="Number of laps" text="Number of laps"/>
|
||||
<spacer witdh="40" height="2" />
|
||||
<spinner id="lapcountspinner" width="20%" min_value="1" max_value="20" align="center"
|
||||
<spinner id="lap-spinner" width="20%" min_value="1" max_value="20" align="center"
|
||||
wrap_around="true" />
|
||||
<spacer proportion="1" height="2" />
|
||||
</div>
|
||||
<div width="75%" height="fit" layout="horizontal-row" >
|
||||
<spacer width="40" height="2" />
|
||||
<label id="karts-text" height="100%" width="40%" I18N="Number of AI karts" text="Number of AI karts"/>
|
||||
<label id="ai-text" height="100%" width="40%" I18N="Number of AI karts" text="Number of AI karts"/>
|
||||
<spacer with="40" height="2" />
|
||||
<spinner id="kartcountspinner" width="20%" min_value="1" max_value="20" align="center"
|
||||
<spinner id="ai-spinner" width="20%" min_value="1" max_value="20" align="center"
|
||||
wrap_around="true" />
|
||||
<spacer proportion="1" height="2" />
|
||||
</div>
|
||||
|
@ -1,73 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stkgui>
|
||||
<div x="1%" y="1%" width="99%" height="99%">
|
||||
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row">
|
||||
<label id="name" width="100%" text_align="center"/>
|
||||
|
||||
<spacer width="1" height="5%"/>
|
||||
|
||||
<div width="95%" proportion="5" layout="horizontal-row">
|
||||
|
||||
<!-- Left pane -->
|
||||
<div proportion="1" height="100%" layout="vertical-row">
|
||||
<label id="highscores" width="100%" text_align="center" text="= Highscores ="/>
|
||||
|
||||
<spacer width="1" height="2%"/>
|
||||
|
||||
<div width="95%" height="fit" layout="horizontal-row">
|
||||
<icon id="iconscore1" icon="gui/random_kart.png" width="font" height="font"/>
|
||||
<spacer width="2%" height="1"/>
|
||||
<label id="highscore1" proportion="1" text="(Empty)"/>
|
||||
</div>
|
||||
|
||||
<spacer width="1" height="2%"/>
|
||||
|
||||
<div width="95%" height="fit" layout="horizontal-row">
|
||||
<icon id="iconscore2" icon="gui/random_kart.png" width="font" height="font"/>
|
||||
<spacer width="2%" height="1"/>
|
||||
<label id="highscore2" proportion="1" text="(Empty)"/>
|
||||
</div>
|
||||
|
||||
<spacer width="1" height="2%"/>
|
||||
|
||||
<div width="95%" height="fit" layout="horizontal-row">
|
||||
<icon id="iconscore3" icon="gui/random_kart.png" width="font" height="font"/>
|
||||
<spacer width="2%" height="1"/>
|
||||
<label id="highscore3" proportion="1" text="(Empty)"/>
|
||||
</div>
|
||||
|
||||
<spacer width="1" proportion="1"/>
|
||||
|
||||
<label id="author" width="100%" text_align="center" word_wrap="true"/>
|
||||
</div>
|
||||
|
||||
<!-- Right pane -->
|
||||
<div proportion="1" height="100%" layout="vertical-row">
|
||||
<placeholder proportion="1" width="100%" height="100%" id="screenshot_div">
|
||||
</placeholder>
|
||||
<div width="75%" height="fit" layout="horizontal-row" >
|
||||
<spacer proportion="1" height="2" />
|
||||
<checkbox id="reverse"/>
|
||||
<spacer width="20" height="2" />
|
||||
<label id="reverse-text" height="100%" I18N="Drive the track reverse" text="Reverse"/>
|
||||
<spacer proportion="1" height="2" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer width="1" height="5%"/>
|
||||
|
||||
<spinner id="lapcountspinner" width="50%" min_value="1" max_value="20" align="center" wrap_around="true"
|
||||
I18N="In the track setup screen (number of laps choice, where %i is the number)" text="%i laps"/>
|
||||
|
||||
<spacer width="1" height="5%"/>
|
||||
|
||||
<button id="start" text="Start Race" align="center"/>
|
||||
|
||||
<spacer width="1" height="2%"/>
|
||||
</div>
|
||||
|
||||
<icon-button id="closePopup" x="0" y="0" width="8%" height="8%" icon="gui/back.png"/>
|
||||
</div>
|
||||
</stkgui>
|
@ -185,12 +185,13 @@ public:
|
||||
case MINOR_MODE_SOCCER: return _("Soccer");
|
||||
default: assert(false); return NULL;
|
||||
}
|
||||
}
|
||||
} // getNameOf
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
static bool hasAI(const MinorRaceModeType mode)
|
||||
/** Returns if the currently set minor game mode can be used by the AI. */
|
||||
bool hasAI()
|
||||
{
|
||||
switch (mode)
|
||||
switch (m_minor_mode)
|
||||
{
|
||||
case MINOR_MODE_NORMAL_RACE: return true;
|
||||
case MINOR_MODE_TIME_TRIAL: return true;
|
||||
@ -200,7 +201,7 @@ public:
|
||||
case MINOR_MODE_SOCCER: return false;
|
||||
default: assert(false); return false;
|
||||
}
|
||||
}
|
||||
} // hasAI
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "io/file_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/arenas_screen.hpp"
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
#include "states_screens/track_info_screen.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/random_generator.hpp"
|
||||
@ -163,13 +163,11 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const
|
||||
RandomGenerator random;
|
||||
const int randomID = random.get(curr_group.size());
|
||||
|
||||
Track* clickedTrack = track_manager->getTrack( curr_group[randomID] );
|
||||
if (clickedTrack != NULL)
|
||||
Track* clicked_track = track_manager->getTrack( curr_group[randomID] );
|
||||
if (clicked_track != NULL)
|
||||
{
|
||||
ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() );
|
||||
|
||||
new TrackInfoDialog(selection, clickedTrack->getIdent(), clickedTrack->getName(),
|
||||
screenshot, 0.8f, 0.7f);
|
||||
TrackInfoScreen::getInstance()->setTrack(clicked_track);
|
||||
StateManager::get()->pushScreen(TrackInfoScreen::getInstance());
|
||||
}
|
||||
|
||||
}
|
||||
@ -182,13 +180,11 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const
|
||||
}
|
||||
else
|
||||
{
|
||||
Track* clickedTrack = track_manager->getTrack(selection);
|
||||
if (clickedTrack != NULL)
|
||||
Track* clicked_track = track_manager->getTrack(selection);
|
||||
if (clicked_track != NULL)
|
||||
{
|
||||
ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() );
|
||||
|
||||
new TrackInfoDialog(selection, clickedTrack->getIdent(), clickedTrack->getName(),
|
||||
screenshot, 0.8f, 0.7f);
|
||||
TrackInfoScreen::getInstance()->setTrack(clicked_track);
|
||||
StateManager::get()->pushScreen(TrackInfoScreen::getInstance());
|
||||
} // clickedTrack != NULL
|
||||
} // if random_track
|
||||
|
||||
|
@ -1,285 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009-2013 Marianne Gagnon
|
||||
//
|
||||
// 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/dialogs/track_info_dialog.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "race/highscores.hpp"
|
||||
#include "race/highscore_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/tracks_screen.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <IGUIEnvironment.h>
|
||||
#include <IGUIImage.h>
|
||||
#include <IGUIStaticText.h>
|
||||
|
||||
using namespace irr::gui;
|
||||
using namespace irr::video;
|
||||
using namespace irr::core;
|
||||
using namespace GUIEngine;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::string& trackIdent,
|
||||
const irr::core::stringw& trackName, ITexture* screenshot,
|
||||
const float w, const float h) : ModalDialog(w, h)
|
||||
{
|
||||
loadFromFile("track_info_dialog.stkgui");
|
||||
|
||||
const bool has_laps = race_manager->modeHasLaps();
|
||||
const bool has_highscores = race_manager->modeHasHighscores();
|
||||
|
||||
m_track_ident = trackIdent;
|
||||
m_ribbon_item = ribbonItem;
|
||||
|
||||
getWidget<LabelWidget>("name")->setText(trackName.c_str(), false);
|
||||
|
||||
Track* track = track_manager->getTrack(trackIdent);
|
||||
//I18N: when showing who is the author of track '%s' (place %s where the name of the author should appear)
|
||||
getWidget<LabelWidget>("author")->setText( _("Track by %s", track->getDesigner().c_str()), false );
|
||||
|
||||
|
||||
// ---- Track screenshot
|
||||
Widget* screenshot_div = getWidget("screenshot_div");
|
||||
IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
||||
false /* tab stop */, false /* focusable */);
|
||||
// images are saved squared, but must be stretched to 4:
|
||||
screenshotWidget->setCustomAspectRatio(4.0f / 3.0f);
|
||||
|
||||
screenshotWidget->m_x = screenshot_div->m_x;
|
||||
screenshotWidget->m_y = screenshot_div->m_y;
|
||||
screenshotWidget->m_w = screenshot_div->m_w;
|
||||
screenshotWidget->m_h = screenshot_div->m_h;
|
||||
|
||||
// temporary icon, will replace it just after (but it will be shown if the given icon is not found)
|
||||
screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png";
|
||||
screenshotWidget->setParent(m_irrlicht_window);
|
||||
screenshotWidget->add();
|
||||
|
||||
if (screenshot != NULL)
|
||||
screenshotWidget->setImage(screenshot);
|
||||
m_widgets.push_back(screenshotWidget);
|
||||
|
||||
|
||||
// ---- Lap count m_spinner
|
||||
if (has_laps)
|
||||
{
|
||||
m_spinner = getWidget<SpinnerWidget>("lapcountspinner");
|
||||
if (UserConfigParams::m_artist_debug_mode)
|
||||
m_spinner->setMin(0);
|
||||
|
||||
m_spinner->setValue(track->getActualNumberOfLap());
|
||||
race_manager->setNumLaps(m_spinner->getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<SpinnerWidget>("lapcountspinner")->setVisible(false);
|
||||
m_spinner = NULL;
|
||||
}
|
||||
|
||||
|
||||
// Reverse track
|
||||
const bool reverse_available = track->reverseAvailable() &&
|
||||
race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG;
|
||||
if (reverse_available)
|
||||
{
|
||||
m_checkbox = getWidget<CheckBoxWidget>("reverse");
|
||||
m_checkbox->setState(race_manager->getReverseTrack());
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<CheckBoxWidget>("reverse")->setVisible(false);
|
||||
getWidget<LabelWidget>("reverse-text")->setVisible(false);
|
||||
m_checkbox = NULL;
|
||||
race_manager->setReverseTrack(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_entries[0] = getWidget<LabelWidget>("highscore1");
|
||||
m_highscore_entries[1] = getWidget<LabelWidget>("highscore2");
|
||||
m_highscore_entries[2] = getWidget<LabelWidget>("highscore3");
|
||||
|
||||
updateHighScores();
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<IconButtonWidget>("iconscore1")->setVisible(false);
|
||||
getWidget<IconButtonWidget>("iconscore2")->setVisible(false);
|
||||
getWidget<IconButtonWidget>("iconscore3")->setVisible(false);
|
||||
|
||||
getWidget<LabelWidget>("highscores")->setVisible(false);
|
||||
getWidget<LabelWidget>("highscore1")->setVisible(false);
|
||||
getWidget<LabelWidget>("highscore2")->setVisible(false);
|
||||
getWidget<LabelWidget>("highscore3")->setVisible(false);
|
||||
}
|
||||
|
||||
getWidget<ButtonWidget>("start")->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
|
||||
|
||||
} // TrackInfoDialog
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
TrackInfoDialog::~TrackInfoDialog()
|
||||
{
|
||||
// Place focus back on selected track, in case the dialog was cancelled and we're back to
|
||||
// the track selection screen after
|
||||
GUIEngine::Screen* curr_screen = GUIEngine::getCurrentScreen();
|
||||
if (curr_screen->getName() == "tracks.stkgui")
|
||||
{
|
||||
((TracksScreen*)curr_screen)->setFocusOnTrack(m_ribbon_item);
|
||||
}
|
||||
|
||||
} // ~TrackInfoDialog
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void TrackInfoDialog::updateHighScores()
|
||||
{
|
||||
std::string game_mode_ident = RaceManager::getIdentOf( race_manager->getMinorMode() );
|
||||
const Highscores::HighscoreType type = "HST_" + game_mode_ident;
|
||||
|
||||
Highscores* highscores =
|
||||
highscore_manager->getHighscores(type,
|
||||
race_manager->getNumberOfKarts(),
|
||||
race_manager->getDifficulty(),
|
||||
m_track_ident,
|
||||
race_manager->getNumLaps(),
|
||||
race_manager->getReverseTrack() );
|
||||
const int amount = highscores->getNumberEntries();
|
||||
|
||||
std::string kart_name;
|
||||
core::stringw name;
|
||||
float time;
|
||||
|
||||
// fill highscore entries
|
||||
for (int n=0; n<HIGHSCORE_COUNT; n++)
|
||||
{
|
||||
irr::core::stringw line;
|
||||
|
||||
// Check if this entry is filled or still empty
|
||||
if (n < amount)
|
||||
{
|
||||
highscores->getEntry(n, kart_name, name, &time);
|
||||
|
||||
std::string time_string = StringUtils::timeToString(time);
|
||||
|
||||
const KartProperties* prop = kart_properties_manager->getKart(kart_name);
|
||||
if (prop != NULL)
|
||||
{
|
||||
const std::string &icon_path = prop->getAbsoluteIconFile();
|
||||
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
|
||||
m_kart_icons[n]->setImage(kart_icon_texture);
|
||||
}
|
||||
line = name + "\t" + core::stringw(time_string.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
//I18N: for empty highscores entries
|
||||
line = _("(Empty)");
|
||||
|
||||
ITexture* no_kart_texture = irr_driver->getTexture(
|
||||
file_manager->getAsset(FileManager::GUI,
|
||||
"random_kart.png") );
|
||||
m_kart_icons[n]->setImage(no_kart_texture);
|
||||
|
||||
}
|
||||
|
||||
m_highscore_entries[n]->setText( line.c_str(), false );
|
||||
|
||||
}
|
||||
} // updateHighScores
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void TrackInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
|
||||
// Create a copy of member variables we still need, since they will
|
||||
// not be accessible after dismiss:
|
||||
const int num_laps = (m_spinner == NULL ? -1 : m_spinner->getValue());
|
||||
const bool reverse_track = m_checkbox == NULL ? false
|
||||
: m_checkbox->getState();
|
||||
track_manager->getTrack(m_track_ident)->setActualNumberOfLaps(num_laps);
|
||||
race_manager->setReverseTrack(reverse_track);
|
||||
std::string track_ident = m_track_ident;
|
||||
// Disable accidentally unlocking of a challenge
|
||||
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
|
||||
|
||||
ModalDialog::dismiss();
|
||||
race_manager->startSingleRace(track_ident, num_laps, false);
|
||||
} // onEnterPressedInternal
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation TrackInfoDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "start" )
|
||||
{
|
||||
onEnterPressedInternal();
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "closePopup")
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "reverse")
|
||||
{
|
||||
race_manager->setReverseTrack(m_checkbox->getState());
|
||||
// Makes sure the highscores get swapped when clicking the 'reverse'
|
||||
// checkbox.
|
||||
if (race_manager->modeHasHighscores())
|
||||
{
|
||||
updateHighScores();
|
||||
}
|
||||
}
|
||||
else if (eventSource == "lapcountspinner")
|
||||
{
|
||||
assert(m_spinner != NULL);
|
||||
const int num_laps = m_spinner->getValue();
|
||||
race_manager->setNumLaps(num_laps);
|
||||
UserConfigParams::m_num_laps = num_laps;
|
||||
updateHighScores();
|
||||
}
|
||||
|
||||
return GUIEngine::EVENT_LET;
|
||||
} // processEvent
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
@ -1,70 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009-2013 Marianne Gagnon
|
||||
//
|
||||
// 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_TRACKINFO_DIALOG_HPP
|
||||
#define HEADER_TRACKINFO_DIALOG_HPP
|
||||
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/widgets/check_box_widget.hpp"
|
||||
|
||||
static const int HIGHSCORE_COUNT = 3;
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
class SpinnerWidget;
|
||||
class IconButtonWidget;
|
||||
class LabelWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Dialog that shows the information about a given track
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class TrackInfoDialog : public GUIEngine::ModalDialog
|
||||
{
|
||||
std::string m_track_ident;
|
||||
std::string m_ribbon_item;
|
||||
|
||||
// When there is no need to tab through / click on images/labels, we can add directly
|
||||
// irrlicht labels (more complicated uses require the use of our widget set)
|
||||
GUIEngine::SpinnerWidget* m_spinner;
|
||||
GUIEngine::CheckBoxWidget* m_checkbox;
|
||||
GUIEngine::IconButtonWidget* m_kart_icons[HIGHSCORE_COUNT];
|
||||
GUIEngine::LabelWidget* m_highscore_entries[HIGHSCORE_COUNT];
|
||||
|
||||
void updateHighScores();
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Creates a track info modal dialog with given percentage of screen width and height
|
||||
* \param ribbonItem identifier name of the ribbon item that was clicked in the track selection
|
||||
* screen to get there (often will be 'trackIdent' but may also be the random item)
|
||||
* \param trackIdent identifier name of the track to show information about
|
||||
* \param trackName human-readable, possibly translated, name of the track to show information about
|
||||
* \param screenshot screenshot of the track to show information about
|
||||
*/
|
||||
TrackInfoDialog(const std::string& ribbonItem, const std::string& trackIdent,
|
||||
const irr::core::stringw& trackName, irr::video::ITexture* screenshot,
|
||||
const float percentWidth, const float percentHeight);
|
||||
virtual ~TrackInfoDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
@ -26,7 +26,7 @@
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
#include "states_screens/track_info_screen.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -80,19 +80,13 @@ void EasterEggScreen::eventCallback(Widget* widget, const std::string& name, con
|
||||
std::string track = m_random_track_list.front();
|
||||
m_random_track_list.pop_front();
|
||||
m_random_track_list.push_back(track);
|
||||
Track* clickedTrack = track_manager->getTrack( track );
|
||||
Track* clicked_track = track_manager->getTrack( track );
|
||||
|
||||
|
||||
if (clickedTrack != NULL)
|
||||
if (clicked_track != NULL)
|
||||
{
|
||||
ITexture* screenshot =
|
||||
irr_driver->getTexture( clickedTrack->getScreenshotFile(),
|
||||
"While loading screenshot for track '%s':",
|
||||
clickedTrack->getFilename() );
|
||||
|
||||
new TrackInfoDialog(selection, clickedTrack->getIdent(),
|
||||
translations->fribidize(clickedTrack->getName()),
|
||||
screenshot, 0.8f, 0.7f);
|
||||
TrackInfoScreen::getInstance()->setTrack(clicked_track);
|
||||
StateManager::get()->pushScreen(TrackInfoScreen::getInstance());
|
||||
}
|
||||
|
||||
}
|
||||
@ -100,22 +94,13 @@ void EasterEggScreen::eventCallback(Widget* widget, const std::string& name, con
|
||||
{
|
||||
unlock_manager->playLockSound();
|
||||
}
|
||||
else if (selection == RibbonWidget::NO_ITEM_ID)
|
||||
else if (selection != RibbonWidget::NO_ITEM_ID)
|
||||
{
|
||||
}
|
||||
else
|
||||
Track* clicked_track = track_manager->getTrack(selection);
|
||||
if (clicked_track != NULL)
|
||||
{
|
||||
Track* clickedTrack = track_manager->getTrack(selection);
|
||||
if (clickedTrack != NULL)
|
||||
{
|
||||
ITexture* screenshot =
|
||||
irr_driver->getTexture( clickedTrack->getScreenshotFile(),
|
||||
"While loading screenshot for track '%s'",
|
||||
clickedTrack->getFilename());
|
||||
|
||||
new TrackInfoDialog(selection, clickedTrack->getIdent(),
|
||||
translations->fribidize(clickedTrack->getName()),
|
||||
screenshot, 0.8f, 0.7f);
|
||||
TrackInfoScreen::getInstance()->setTrack(clicked_track);
|
||||
StateManager::get()->pushScreen(TrackInfoScreen::getInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "states_screens/edit_gp_screen.hpp"
|
||||
#include "states_screens/dialogs/enter_gp_name_dialog.hpp"
|
||||
#include "states_screens/dialogs/gp_info_dialog.hpp"
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
@ -333,18 +333,10 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
#endif
|
||||
if (selection == "new")
|
||||
{
|
||||
#undef XX
|
||||
#ifdef XX
|
||||
Track *track = track_manager->getTrack("olivermath");
|
||||
TrackInfoScreen *tis = TrackInfoScreen::getInstance();
|
||||
tis->setTrack(track);
|
||||
StateManager::get()->pushScreen(tis);
|
||||
#else
|
||||
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance(); //FIXME : that was for tests
|
||||
s->setMultiplayer(false);
|
||||
s->setFromOverworld(false);
|
||||
StateManager::get()->pushScreen( s );
|
||||
#endif
|
||||
}
|
||||
else if (selection == "multiplayer")
|
||||
{
|
||||
|
@ -54,15 +54,22 @@ using namespace GUIEngine;
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( TrackInfoScreen );
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
//TrackInfoScreen::TrackInfoScreen(const std::string& ribbonItem, const std::string& trackIdent,
|
||||
// const irr::core::stringw& trackName, ITexture* screenshot)
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Constructor, which loads the corresponding track_info.stkgui file. */
|
||||
TrackInfoScreen::TrackInfoScreen()
|
||||
: Screen("track_info.stkgui")
|
||||
{
|
||||
} // TrackInfoScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/* Saves some often used pointers. */
|
||||
void TrackInfoScreen::loadedFromFile()
|
||||
{
|
||||
m_lap_spinner = getWidget<SpinnerWidget>("lap-spinner");
|
||||
m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner");
|
||||
m_reverse = getWidget<CheckBoxWidget>("reverse");
|
||||
} // loadedFromFile
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TrackInfoScreen::setTrack(const Track *track)
|
||||
{
|
||||
@ -75,9 +82,6 @@ void TrackInfoScreen::setTrack(const Track *track)
|
||||
*/
|
||||
void TrackInfoScreen::init()
|
||||
{
|
||||
RaceManager::MinorRaceModeType minor = race_manager->getMinorMode();
|
||||
|
||||
const bool has_AI = race_manager->hasAI(minor);
|
||||
const bool has_laps = race_manager->modeHasLaps();
|
||||
const bool has_highscores = race_manager->modeHasHighscores();
|
||||
|
||||
@ -115,29 +119,23 @@ void TrackInfoScreen::init()
|
||||
|
||||
// Lap count m_lap_spinner
|
||||
// -----------------------
|
||||
m_lap_spinner->setVisible(has_laps);
|
||||
getWidget<LabelWidget>("lap-text")->setVisible(has_laps);
|
||||
if (has_laps)
|
||||
{
|
||||
m_lap_spinner = getWidget<SpinnerWidget>("lapcountspinner");
|
||||
m_lap_spinner->setVisible(true);
|
||||
getWidget<LabelWidget>("lap-text")->setVisible(true);
|
||||
if (UserConfigParams::m_artist_debug_mode)
|
||||
m_lap_spinner->setMin(0);
|
||||
|
||||
m_lap_spinner->setValue(m_track->getActualNumberOfLap());
|
||||
race_manager->setNumLaps(m_lap_spinner->getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<SpinnerWidget>("lapcountspinner")->setVisible(false);
|
||||
getWidget<LabelWidget>("lap-text")->setVisible(false);
|
||||
m_lap_spinner = NULL;
|
||||
}
|
||||
|
||||
// Number of AIs
|
||||
// -------------
|
||||
const bool has_AI = race_manager->hasAI();
|
||||
m_ai_kart_spinner->setVisible(has_AI);
|
||||
getWidget<LabelWidget>("ai-text")->setVisible(has_AI);
|
||||
if (has_AI)
|
||||
{
|
||||
m_ai_kart_spinner = getWidget<SpinnerWidget>("kartcountspinner");
|
||||
m_ai_kart_spinner->setActivated();
|
||||
|
||||
// Avoid negative numbers (which can happen if e.g. the number of karts
|
||||
@ -145,30 +143,27 @@ void TrackInfoScreen::init()
|
||||
int num_ai = UserConfigParams::m_num_karts - race_manager->getNumLocalPlayers();
|
||||
if (num_ai < 0) num_ai = 0;
|
||||
m_ai_kart_spinner->setValue(num_ai);
|
||||
m_ai_kart_spinner->setMax(stk_config->m_max_karts - race_manager->getNumLocalPlayers());
|
||||
race_manager->setNumKarts(num_ai + race_manager->getNumLocalPlayers());
|
||||
m_ai_kart_spinner->setMax(stk_config->m_max_karts - race_manager->getNumLocalPlayers());
|
||||
// A ftl reace needs at least three karts to make any sense
|
||||
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||
{
|
||||
m_ai_kart_spinner->setMin(3-race_manager->getNumLocalPlayers());
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<SpinnerWidget>("kartcountspinner")->setVisible(false);
|
||||
m_ai_kart_spinner = NULL;
|
||||
}
|
||||
m_ai_kart_spinner->setMin(0);
|
||||
|
||||
} // has_AI
|
||||
|
||||
// Reverse track
|
||||
// -------------
|
||||
const bool reverse_available = m_track->reverseAvailable() &&
|
||||
race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG;
|
||||
m_reverse->setVisible(reverse_available);
|
||||
getWidget<LabelWidget>("reverse-text")->setVisible(reverse_available);
|
||||
if (reverse_available)
|
||||
{
|
||||
m_checkbox = getWidget<CheckBoxWidget>("reverse");
|
||||
m_checkbox->setState(race_manager->getReverseTrack());
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<CheckBoxWidget>("reverse")->setVisible(false);
|
||||
getWidget<LabelWidget>("reverse-text")->setVisible(false);
|
||||
m_checkbox = NULL;
|
||||
race_manager->setReverseTrack(false);
|
||||
m_reverse->setState(race_manager->getReverseTrack());
|
||||
}
|
||||
|
||||
// ---- High Scores
|
||||
@ -196,9 +191,7 @@ void TrackInfoScreen::init()
|
||||
getWidget<LabelWidget>("highscore3")->setVisible(false);
|
||||
}
|
||||
|
||||
//FIXME getWidget<ButtonWidget>("start")->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
|
||||
|
||||
} // TrackInfoScreen
|
||||
} // init
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -271,9 +264,10 @@ void TrackInfoScreen::onEnterPressedInternal()
|
||||
|
||||
// Create a copy of member variables we still need, since they will
|
||||
// not be accessible after dismiss:
|
||||
const int num_laps = (m_lap_spinner == NULL ? -1 : m_lap_spinner->getValue());
|
||||
const bool reverse_track = m_checkbox == NULL ? false
|
||||
: m_checkbox->getState();
|
||||
const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue()
|
||||
: -1;
|
||||
const bool reverse_track = m_reverse == NULL ? false
|
||||
: m_reverse->getState();
|
||||
//FIXME m_track->setActualNumberOfLaps(num_laps);
|
||||
race_manager->setReverseTrack(reverse_track);
|
||||
|
||||
@ -302,7 +296,7 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (name == "reverse")
|
||||
{
|
||||
race_manager->setReverseTrack(m_checkbox->getState());
|
||||
race_manager->setReverseTrack(m_reverse->getState());
|
||||
// Makes sure the highscores get swapped when clicking the 'reverse'
|
||||
// checkbox.
|
||||
if (race_manager->modeHasHighscores())
|
||||
@ -310,20 +304,20 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
updateHighScores();
|
||||
}
|
||||
}
|
||||
else if (name == "lapcountspinner")
|
||||
else if (name == "lap-spinner")
|
||||
{
|
||||
assert(m_lap_spinner != NULL);
|
||||
assert(race_manager->modeHasLaps());
|
||||
const int num_laps = m_lap_spinner->getValue();
|
||||
race_manager->setNumLaps(num_laps);
|
||||
UserConfigParams::m_num_laps = num_laps;
|
||||
updateHighScores();
|
||||
}
|
||||
else if (name=="kartcountspinner")
|
||||
else if (name=="ai-spinner")
|
||||
{
|
||||
SpinnerWidget* w = dynamic_cast<SpinnerWidget*>(widget);
|
||||
race_manager->setNumKarts( race_manager->getNumLocalPlayers() + w->getValue() );
|
||||
UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers() + w->getValue();
|
||||
|
||||
const int num_ai = m_ai_kart_spinner->getValue();
|
||||
race_manager->setNumKarts( race_manager->getNumLocalPlayers() + num_ai );
|
||||
UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers() + num_ai;
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
|
@ -55,9 +55,13 @@ class TrackInfoScreen : public GUIEngine::Screen,
|
||||
/** Spinner for number of AI karts. */
|
||||
GUIEngine::SpinnerWidget* m_ai_kart_spinner;
|
||||
|
||||
/** */
|
||||
GUIEngine::CheckBoxWidget* m_checkbox;
|
||||
/** Check box for reverse mode. */
|
||||
GUIEngine::CheckBoxWidget* m_reverse;
|
||||
|
||||
/** 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();
|
||||
@ -75,7 +79,7 @@ public:
|
||||
virtual ~TrackInfoScreen();
|
||||
|
||||
virtual void init();
|
||||
virtual void loadedFromFile() {}
|
||||
virtual void loadedFromFile();
|
||||
virtual void eventCallback(GUIEngine::Widget *,const std::string &name ,
|
||||
const int player_id);
|
||||
void onEnterPressedInternal();
|
||||
|
Loading…
Reference in New Issue
Block a user