Started implementing GP info dialog

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4699 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-02-13 00:36:46 +00:00
parent a2f03f2a0b
commit cc4e1357ba
7 changed files with 251 additions and 16 deletions

View File

@ -262,16 +262,18 @@ supertuxkart_SOURCES = \
states_screens/dialogs/confirm_resolution_dialog.hpp \ states_screens/dialogs/confirm_resolution_dialog.hpp \
states_screens/dialogs/enter_player_name_dialog.cpp \ states_screens/dialogs/enter_player_name_dialog.cpp \
states_screens/dialogs/enter_player_name_dialog.hpp \ states_screens/dialogs/enter_player_name_dialog.hpp \
states_screens/dialogs/gp_info_dialog.cpp \
states_screens/dialogs/gp_info_dialog.hpp \
states_screens/dialogs/player_info_dialog.hpp \ states_screens/dialogs/player_info_dialog.hpp \
states_screens/dialogs/press_a_key_dialog.hpp \
states_screens/dialogs/track_info_dialog.cpp \
states_screens/dialogs/track_info_dialog.hpp \
states_screens/dialogs/player_info_dialog.cpp \ states_screens/dialogs/player_info_dialog.cpp \
states_screens/dialogs/press_a_key_dialog.hpp \
states_screens/dialogs/press_a_key_dialog.cpp \ states_screens/dialogs/press_a_key_dialog.cpp \
states_screens/dialogs/race_over_dialog.cpp \ states_screens/dialogs/race_over_dialog.cpp \
states_screens/dialogs/race_over_dialog.hpp \ states_screens/dialogs/race_over_dialog.hpp \
states_screens/dialogs/race_paused_dialog.hpp \ states_screens/dialogs/race_paused_dialog.hpp \
states_screens/dialogs/race_paused_dialog.cpp \ states_screens/dialogs/race_paused_dialog.cpp \
states_screens/dialogs/track_info_dialog.cpp \
states_screens/dialogs/track_info_dialog.hpp \
states_screens/arenas_screen.cpp \ states_screens/arenas_screen.cpp \
states_screens/arenas_screen.hpp \ states_screens/arenas_screen.hpp \
states_screens/feature_unlocked.cpp \ states_screens/feature_unlocked.cpp \

View File

@ -242,6 +242,7 @@
9553823A10FD4FEC00737979 /* constants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9553823910FD4FEC00737979 /* constants.cpp */; }; 9553823A10FD4FEC00737979 /* constants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9553823910FD4FEC00737979 /* constants.cpp */; };
955DE88310042701006A4F3C /* check_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE88110042701006A4F3C /* check_manager.cpp */; }; 955DE88310042701006A4F3C /* check_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE88110042701006A4F3C /* check_manager.cpp */; };
955DE88C1004273B006A4F3C /* check_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE8871004273B006A4F3C /* check_structure.cpp */; }; 955DE88C1004273B006A4F3C /* check_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE8871004273B006A4F3C /* check_structure.cpp */; };
95634EF21126272C009C145D /* gp_info_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95634EF01126272C009C145D /* gp_info_dialog.cpp */; };
956541BB10DD5F0A00C83E99 /* arenas_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */; }; 956541BB10DD5F0A00C83E99 /* arenas_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */; };
956541E110DD628C00C83E99 /* add_device_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956541DF10DD628C00C83E99 /* add_device_dialog.cpp */; }; 956541E110DD628C00C83E99 /* add_device_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956541DF10DD628C00C83E99 /* add_device_dialog.cpp */; };
956D36A710095035007FCB95 /* player.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956D36A610095035007FCB95 /* player.cpp */; }; 956D36A710095035007FCB95 /* player.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956D36A610095035007FCB95 /* player.cpp */; };
@ -436,6 +437,8 @@
955DE88210042701006A4F3C /* check_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_manager.hpp; path = ../../tracks/check_manager.hpp; sourceTree = SOURCE_ROOT; }; 955DE88210042701006A4F3C /* check_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_manager.hpp; path = ../../tracks/check_manager.hpp; sourceTree = SOURCE_ROOT; };
955DE8871004273B006A4F3C /* check_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_structure.cpp; path = ../../tracks/check_structure.cpp; sourceTree = SOURCE_ROOT; }; 955DE8871004273B006A4F3C /* check_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_structure.cpp; path = ../../tracks/check_structure.cpp; sourceTree = SOURCE_ROOT; };
955DE8881004273B006A4F3C /* check_structure.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_structure.hpp; path = ../../tracks/check_structure.hpp; sourceTree = SOURCE_ROOT; }; 955DE8881004273B006A4F3C /* check_structure.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_structure.hpp; path = ../../tracks/check_structure.hpp; sourceTree = SOURCE_ROOT; };
95634EF01126272C009C145D /* gp_info_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = gp_info_dialog.cpp; path = ../../states_screens/dialogs/gp_info_dialog.cpp; sourceTree = SOURCE_ROOT; };
95634EF11126272C009C145D /* gp_info_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = gp_info_dialog.hpp; path = ../../states_screens/dialogs/gp_info_dialog.hpp; sourceTree = SOURCE_ROOT; };
956541B910DD5F0A00C83E99 /* arenas_screen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arenas_screen.cpp; path = ../../states_screens/arenas_screen.cpp; sourceTree = SOURCE_ROOT; }; 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arenas_screen.cpp; path = ../../states_screens/arenas_screen.cpp; sourceTree = SOURCE_ROOT; };
956541BA10DD5F0A00C83E99 /* arenas_screen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = arenas_screen.hpp; path = ../../states_screens/arenas_screen.hpp; sourceTree = SOURCE_ROOT; }; 956541BA10DD5F0A00C83E99 /* arenas_screen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = arenas_screen.hpp; path = ../../states_screens/arenas_screen.hpp; sourceTree = SOURCE_ROOT; };
956541DF10DD628C00C83E99 /* add_device_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = add_device_dialog.cpp; path = ../../states_screens/dialogs/add_device_dialog.cpp; sourceTree = SOURCE_ROOT; }; 956541DF10DD628C00C83E99 /* add_device_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = add_device_dialog.cpp; path = ../../states_screens/dialogs/add_device_dialog.cpp; sourceTree = SOURCE_ROOT; };
@ -1325,6 +1328,8 @@
95E246BD111A2959000C965D /* confirm_resolution_dialog.hpp */, 95E246BD111A2959000C965D /* confirm_resolution_dialog.hpp */,
95833237101243ED00C5137E /* enter_player_name_dialog.cpp */, 95833237101243ED00C5137E /* enter_player_name_dialog.cpp */,
95833238101243ED00C5137E /* enter_player_name_dialog.hpp */, 95833238101243ED00C5137E /* enter_player_name_dialog.hpp */,
95634EF01126272C009C145D /* gp_info_dialog.cpp */,
95634EF11126272C009C145D /* gp_info_dialog.hpp */,
95833239101243ED00C5137E /* player_info_dialog.cpp */, 95833239101243ED00C5137E /* player_info_dialog.cpp */,
9583323A101243ED00C5137E /* player_info_dialog.hpp */, 9583323A101243ED00C5137E /* player_info_dialog.hpp */,
9583323B101243ED00C5137E /* press_a_key_dialog.cpp */, 9583323B101243ED00C5137E /* press_a_key_dialog.cpp */,
@ -2599,6 +2604,7 @@
95DFC5021106933B00A043A9 /* slip_stream.cpp in Sources */, 95DFC5021106933B00A043A9 /* slip_stream.cpp in Sources */,
95E246BE111A2959000C965D /* confirm_resolution_dialog.cpp in Sources */, 95E246BE111A2959000C965D /* confirm_resolution_dialog.cpp in Sources */,
9574F17C11206881008D202E /* world_status.cpp in Sources */, 9574F17C11206881008D202E /* world_status.cpp in Sources */,
95634EF21126272C009C145D /* gp_info_dialog.cpp in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -0,0 +1,169 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 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 "guiengine/engine.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widget.hpp"
#include "race/grand_prix_manager.hpp"
#include "race/race_manager.hpp"
#include "states_screens/dialogs/gp_info_dialog.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/tracks_screen.hpp"
#include "utils/translation.hpp"
#include "irrlicht.h"
using namespace irr::gui;
using namespace irr::video;
using namespace irr::core;
using namespace GUIEngine;
// ------------------------------------------------------------------------------------------------------
GPInfoDialog::GPInfoDialog(const std::string& gpIdent, 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_gp_ident = gpIdent;
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(gpIdent);
if (gp == NULL)
{
assert(false);
std::cerr << "ERROR at " << __FILE__ << " : " << __LINE__ << "; trying to continue\n";
ModalDialog::dismiss();
return;
}
// ---- GP Name
core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);
IGUIStaticText* title = GUIEngine::getGUIEnv()->addStaticText( gp->getName().c_str(),
area_top, false, true, // border, word warp
m_irrlicht_window);
title->setTabStop(false);
title->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
/*
// ---- Track screenshot
IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
false, false);
// images are saved squared, but must be stretched to 4:
screenshotWidget->setCustomAspectRatio(4.0f / 3.0f); 3
core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10);
screenshotWidget->x = area_right.UpperLeftCorner.X;
screenshotWidget->y = area_right.UpperLeftCorner.Y;
screenshotWidget->w = area_right.getWidth();
screenshotWidget->h = area_right.getHeight();
// temporary icon, will replace it just after
screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png";
screenshotWidget->setParent(m_irrlicht_window);
screenshotWidget->add();
screenshotWidget->setImage(screenshot);
m_children.push_back(screenshotWidget);
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
b->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
*/
// ---- Start button
ButtonWidget* okBtn = new ButtonWidget();
okBtn->m_properties[PROP_ID] = "start";
okBtn->m_text = _("Start Grand Prix");
okBtn->x = m_area.getWidth()/2 - 200;
okBtn->y = y3;
okBtn->w = 400;
okBtn->h = m_area.getHeight() - y3 - 15;
okBtn->setParent(m_irrlicht_window);
m_children.push_back(okBtn);
okBtn->add();
okBtn->getIrrlichtElement()->setTabStop(true);
okBtn->getIrrlichtElement()->setTabGroup(false);
okBtn->setFocusForPlayer( GUI_PLAYER_ID );
}
// ------------------------------------------------------------------------------------------------------
GPInfoDialog::~GPInfoDialog()
{
// Place focus back on selected GP, in case the dialog was cancelled and we're back to
// the track selection screen after
Screen* curr_screen = GUIEngine::getCurrentScreen();
if (curr_screen->getName() == "tracks.stkgui")
{
((TracksScreen*)curr_screen)->setFocusOnGP(m_gp_ident);
}
}
// ------------------------------------------------------------------------------------------------------
// FIXME : this probably doesn't belong here
void startGPGame(const GrandPrixData* gp)
{
assert(gp != NULL);
ModalDialog::dismiss();
IVideoDriver* driver = GUIEngine::getDriver();
//TODO?: draw a loading screen
driver->endScene();
driver->beginScene(true, false);
driver->endScene();
StateManager::get()->enterGameState();
//race_manager->setDifficulty(RaceManager::RD_HARD);
race_manager->setGrandPrix(*gp);
race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge
//race_manager->setNumKarts( 1 );
//network_manager->setupPlayerKartInfo();
//race_manager->getKartType(1) = KT_PLAYER;
race_manager->startNew();
}
// ------------------------------------------------------------------------------------------------------
void GPInfoDialog::onEnterPressedInternal()
{
startGPGame(grand_prix_manager->getGrandPrix(m_gp_ident));
}
// ------------------------------------------------------------------------------------------------------
GUIEngine::EventPropagation GPInfoDialog::processEvent(std::string& eventSource)
{
if (eventSource == "start" )
{
startGPGame(grand_prix_manager->getGrandPrix(m_gp_ident));
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET;
}
// ------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,40 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 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_GP_INFO_DIALOG_HPP
#define HEADER_GP_INFO_DIALOG_HPP
#include "guiengine/modaldialog.hpp"
class GPInfoDialog : public GUIEngine::ModalDialog
{
std::string m_gp_ident;
public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
GPInfoDialog(const std::string& gpIdent, const float percentWidth, const float percentHeight);
virtual ~GPInfoDialog();
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(std::string& eventSource);
};
#endif

View File

@ -82,7 +82,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO, IconButtonWidget* screenshotWidget = 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:
screenshotWidget->setCustomAspectRatio(4.0f / 3.0f); 3 screenshotWidget->setCustomAspectRatio(4.0f / 3.0f);
core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10); core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10);
screenshotWidget->x = area_right.UpperLeftCorner.X; screenshotWidget->x = area_right.UpperLeftCorner.X;

View File

@ -22,6 +22,7 @@
#include "race/grand_prix_manager.hpp" #include "race/grand_prix_manager.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "states_screens/tracks_screen.hpp" #include "states_screens/tracks_screen.hpp"
#include "states_screens/dialogs/gp_info_dialog.hpp"
#include "states_screens/dialogs/track_info_dialog.hpp" #include "states_screens/dialogs/track_info_dialog.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "tracks/track_manager.hpp" #include "tracks/track_manager.hpp"
@ -33,7 +34,7 @@ using namespace irr::video;
const char* ALL_TRACK_GROUPS_ID = "all"; const char* ALL_TRACK_GROUPS_ID = "all";
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
TracksScreen::TracksScreen() : Screen("tracks.stkgui") TracksScreen::TracksScreen() : Screen("tracks.stkgui")
{ {
@ -62,7 +63,7 @@ TracksScreen::TracksScreen() : Screen("tracks.stkgui")
tabs->m_children.push_back(item); tabs->m_children.push_back(item);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
void TracksScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) void TracksScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
{ {
@ -101,20 +102,24 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
} }
else if (name == "gps") else if (name == "gps")
{ {
RibbonWidget* tracks_widget = dynamic_cast<RibbonWidget*>(widget); DynamicRibbonWidget* gps_widget = dynamic_cast<DynamicRibbonWidget*>(widget);
if (tracks_widget != NULL) if (gps_widget != NULL)
{ {
//TODO
std::cout << "Clicked on GrandPrix " std::cout << "Clicked on GrandPrix "
<< tracks_widget->getSelectionIDString(GUI_PLAYER_ID).c_str() << gps_widget->getSelectionIDString(GUI_PLAYER_ID).c_str()
<< std::endl; << std::endl;
new GPInfoDialog( gps_widget->getSelectionIDString(GUI_PLAYER_ID), 0.8f, 0.7f );
}
else
{
assert(false);
} }
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
void TracksScreen::init() void TracksScreen::init()
{ {
@ -197,13 +202,13 @@ void TracksScreen::init()
tracks_widget->updateItemDisplay(); tracks_widget->updateItemDisplay();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
void TracksScreen::tearDown() void TracksScreen::tearDown()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
void TracksScreen::setFocusOnTrack(const std::string& trackName) void TracksScreen::setFocusOnTrack(const std::string& trackName)
{ {
@ -214,5 +219,16 @@ void TracksScreen::setFocusOnTrack(const std::string& trackName)
tracks_widget->setSelection(trackName, 0, true); tracks_widget->setSelection(trackName, 0, true);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
void TracksScreen::setFocusOnGP(const std::string& gpName)
{
DynamicRibbonWidget* gps_widget = this->getWidget<DynamicRibbonWidget>("gps");
assert( gps_widget != NULL );
// FIXME: don't hardcode player 0?
gps_widget->setSelection(gpName, 0, true);
}
// -----------------------------------------------------------------------------------------------

View File

@ -35,6 +35,8 @@ public:
void tearDown(); void tearDown();
void setFocusOnTrack(const std::string& trackName); void setFocusOnTrack(const std::string& trackName);
void setFocusOnGP(const std::string& gpName);
}; };
#endif #endif