Can now choose which track to play into in the GUI + sow proper screenshots and track names

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3788 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-07-31 01:34:06 +00:00
parent 5a7b97fb50
commit 4c3713789f
8 changed files with 61 additions and 28 deletions

View File

@ -13,6 +13,7 @@
<box proportion="1" width="100%" layout="vertical-row"/>
<ribbon_grid id="tracks" proportion="1" width="95%" square_items="true" text="bottom" align="center" child_width="160" child_height="120" />
<spacer width="20" height="13" />
</box>
<tabs width="100%" height="25" id="trackgroups">
@ -21,7 +22,7 @@
<button id="all" text="All"/>
</tabs>
<spacer width="20" height="20" />
<spacer width="20" height="13" />
</div>

View File

@ -389,7 +389,7 @@ void RibbonGridWidget::updateItemDisplay()
if( icon_id < item_amount )
{
std::string track_sshot = file_manager->getDataDir() + "/" + m_items[icon_id].m_sshot_file;
std::string track_sshot = m_items[icon_id].m_sshot_file;
button->setImage( GUIEngine::getDriver()->getTexture( track_sshot.c_str() ));
button->setPressedImage( GUIEngine::getDriver()->getTexture( track_sshot.c_str()) );

View File

@ -27,11 +27,13 @@
using namespace GUIEngine;
TrackInfoDialog::TrackInfoDialog(const char* trackName, ITexture* screenshot, const float w, const float h) : ModalDialog(w, h)
TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const char* trackName, ITexture* screenshot, const float w, const float h) : ModalDialog(w, h)
{
const int y1 = m_area.getHeight()/7;
const int y2 = m_area.getHeight()*5/7;
const int y3 = m_area.getHeight()*6/7;
m_track_ident = trackIdent;
SpinnerWidget* spinner = new SpinnerWidget();
spinner->x = m_area.getWidth()/2 - 200;
@ -97,7 +99,7 @@ TrackInfoDialog::TrackInfoDialog(const char* trackName, ITexture* screenshot, co
// ------------------------------------------------------------------------------------------------------
// FIXME : this probably doesn't belong here
void startGame()
void startGame(const std::string trackIdent)
{
ModalDialog::dismiss();
@ -111,7 +113,7 @@ void startGame()
StateManager::get()->enterGameState();
//race_manager->setDifficulty(RaceManager::RD_HARD);
race_manager->setTrack("lighthouse");
race_manager->setTrack(trackIdent.c_str());
race_manager->setNumLaps( 3 );
race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge
//race_manager->setNumKarts( 1 );
@ -123,10 +125,10 @@ void startGame()
void TrackInfoDialog::onEnterPressedInternal()
{
startGame();
startGame(m_track_ident);
}
void TrackInfoDialog::processEvent(std::string& eventSource)
{
if (eventSource == "start" ) startGame();
if (eventSource == "start" ) startGame(m_track_ident);
}

View File

@ -23,11 +23,12 @@
class TrackInfoDialog : public GUIEngine::ModalDialog
{
std::string m_track_ident;
public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
TrackInfoDialog(const char* trackName, irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight);
TrackInfoDialog(const std::string& trackIdent, const char* trackName, irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight);
void onEnterPressedInternal();
void processEvent(std::string& eventSource);
};

View File

@ -29,6 +29,7 @@
#include "input/input_manager.hpp"
#include "input/device_manager.hpp"
#include "input/input_device.hpp"
#include "io/file_manager.hpp"
#include "karts/kart.hpp"
#include "karts/kart_properties_manager.hpp"
#include "utils/translation.hpp"
@ -578,8 +579,8 @@ void menuEventKarts(Widget* widget, const std::string& name)
const KartProperties* prop = kart_properties_manager->getKartById(n);
if (prop->getIdent() == "tux")
{
std::string icon_path = "karts/";
icon_path += prop->getIdent() + "/" + prop->getIconFile();
std::string icon_path = file_manager->getDataDir() ;
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str());
break;
}
@ -591,8 +592,8 @@ void menuEventKarts(Widget* widget, const std::string& name)
const KartProperties* prop = kart_properties_manager->getKartById(n);
if (prop->getIdent() != "tux")
{
std::string icon_path = "karts/";
icon_path += prop->getIdent() + "/" + prop->getIconFile();
std::string icon_path = file_manager->getDataDir() ;
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str());
}
}

View File

@ -25,6 +25,7 @@
#include "guiengine/widget.hpp"
#include "input/input_manager.hpp"
#include "input/device_manager.hpp"
#include "io/file_manager.hpp"
#include "states_screens/dialogs/enter_player_name_dialog.hpp"
#include "states_screens/dialogs/player_info_dialog.hpp"
#include "states_screens/dialogs/press_a_key_dialog.hpp"
@ -94,20 +95,20 @@ namespace OptionsScreen
#define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01)
if( ABOUT_EQUAL( ratio, (5.0f/4.0f) ) )
res->addItem(name,name,"gui/screen54.png");
res->addItem(name, name, file_manager->getDataDir() + "/gui/screen54.png");
else if( ABOUT_EQUAL( ratio, (4.0f/3.0f) ) )
res->addItem(name,name,"gui/screen43.png");
res->addItem(name, name, file_manager->getDataDir() + "/gui/screen43.png");
else if( ABOUT_EQUAL( ratio, (16.0f/10.0f) ) )
res->addItem(name,name,"gui/screen1610.png");
res->addItem(name, name, file_manager->getDataDir() + "/gui/screen1610.png");
else if( ABOUT_EQUAL( ratio, (5.0f/3.0f) ) )
res->addItem(name,name,"gui/screen53.png");
res->addItem(name, name, file_manager->getDataDir() + "/gui/screen53.png");
else if( ABOUT_EQUAL( ratio, (3.0f/2.0f) ) )
res->addItem(name,name,"gui/screen32.png");
res->addItem(name, name, file_manager->getDataDir() + "/gui/screen32.png");
else
{
std::cout << "Unknown screen size ratio : " << ratio << std::endl;
// FIXME - do something better than showing a random icon
res->addItem(name,name,"gui/screen1610.png");
res->addItem(name,name, file_manager->getDataDir() + "/gui/screen1610.png");
}
#undef ABOUT_EQUAL
} // next resolution
@ -271,7 +272,7 @@ namespace OptionsScreen
if(!getCurrentScreen()->m_inited)
{
devices->addItem("Keyboard","keyboard","gui/keyboard.png");
devices->addItem("Keyboard","keyboard", file_manager->getDataDir() + "/gui/keyboard.png");
const int gamepad_count = input_manager->getDeviceList()->getGamePadAmount();
@ -280,7 +281,7 @@ namespace OptionsScreen
std::string name = input_manager->getDeviceList()->getGamePad(i)->m_name;
char internal_name[32];
sprintf(internal_name, "gamepad%i", i);
devices->addItem(name,internal_name,"gui/gamepad.png");
devices->addItem(name,internal_name, file_manager->getDataDir() + "/gui/gamepad.png");
}
getCurrentScreen()->m_inited = true;

View File

@ -37,6 +37,8 @@
#include "states_screens/kart_selection.hpp"
#include "states_screens/credits.hpp"
#include "states_screens/dialogs/track_info_dialog.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/translation.hpp"
using namespace GUIEngine;
@ -150,16 +152,16 @@ void StateManager::menuEventRaceSetup(Widget* widget, const std::string& name)
{
w2->addItem( _("Snaky Competition\nAll blows allowed, so catch weapons and make clever use of them!"),
"normal",
"gui/mode_normal.png");
file_manager->getDataDir() + "/gui/mode_normal.png");
w2->addItem( _("Time Trial\nContains no powerups, so only your driving skills matter!"),
"timetrial",
"gui/mode_tt.png");
file_manager->getDataDir() + "/gui/mode_tt.png");
w2->addItem( _("Follow the Leader\nrun for second place, as the last kart will be disqualified every time the counter hits zero. Beware : going in front of the leader will get you eliminated too!"),
"ftl",
"gui/mode_ftl.png");
file_manager->getDataDir() + "/gui/mode_ftl.png");
w2->addItem( _("3-Strikes Battle\nonly in multiplayer games. Hit others with weapons until they lose all their lives."),
"3strikes",
"gui/mode_3strikes.png");
file_manager->getDataDir() + "/gui/mode_3strikes.png");
getCurrentScreen()->m_inited = true;
}
w2->updateItemDisplay();
@ -253,6 +255,25 @@ void StateManager::menuEventTracks(Widget* widget, const std::string& name)
if(!getCurrentScreen()->m_inited)
{
/*
const std::vector<std::string>&
getAllGroups() const { return m_all_groups; }
size_t getNumberOfTracks() const { return m_tracks.size(); }
Track *getTrack(size_t id) const { return m_tracks[id]; }
Track *getTrack(const std::string& ident) const;
void unavailable(const std::string &ident);
void setUnavailableTracks(const std::vector<std::string> &tracks);
bool isAvailable(unsigned int n) const {return m_track_avail[n];}
*/
const int trackAmount = track_manager->getNumberOfTracks();
for (int n=0; n<trackAmount; n++)
{
Track* curr = track_manager->getTrack(n);
w->addItem(curr->getName(), curr->getIdent(), curr->getScreenshotFile());
}
/*
w->addItem("Track 1","t1","gui/track1.png");
w->addItem("Track 2","t2","gui/track2.png");
w->addItem("Track 3","t3","gui/track3.png");
@ -261,6 +282,7 @@ void StateManager::menuEventTracks(Widget* widget, const std::string& name)
w->addItem("Track 6","t6","gui/track6.png");
w->addItem("Track 7","t7","gui/track7.png");
w->addItem("Track 8","t8","gui/track8.png");
*/
getCurrentScreen()->m_inited = true;
}
w->updateItemDisplay();
@ -274,9 +296,13 @@ void StateManager::menuEventTracks(Widget* widget, const std::string& name)
{
std::cout << "Clicked on track " << w2->getSelectionIDString().c_str() << std::endl;
ITexture* screenshot = GUIEngine::getDriver()->getTexture( (file_manager->getDataDir() + "/gui/track1.png").c_str() );
new TrackInfoDialog( w2->getSelectionText().c_str(), screenshot, 0.8f, 0.7f);
Track* clickedTrack = track_manager->getTrack(w2->getSelectionIDString());
if (clickedTrack != NULL)
{
ITexture* screenshot = GUIEngine::getDriver()->getTexture( clickedTrack->getScreenshotFile().c_str() );
new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(), screenshot, 0.8f, 0.7f);
}
}
}
else if(name == "gps")

View File

@ -186,7 +186,7 @@ void Track::loadTrack(const std::string &filename)
m_specular_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
m_diffuse_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
XMLNode *root = file_manager->createXMLTree(m_filename);
if(!root || root->getName()!="track")
{
std::ostringstream o;
@ -219,6 +219,7 @@ void Track::loadTrack(const std::string &filename)
root->get("gravity", &m_gravity);
root->get("arena", &m_is_arena);
root->get("groups", &m_groups);
if(m_groups.size()==0)
m_groups.push_back("standard");
// if both camera position and rotation are defined,