More work on dialogs (race end dialog further re-implemented)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3977 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2d234f6fbb
commit
d1cff1f1c4
@ -26,12 +26,6 @@ using namespace GUIEngine;
|
|||||||
EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
|
EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
|
||||||
ModalDialog(w, h)
|
ModalDialog(w, h)
|
||||||
{
|
{
|
||||||
//core::rect< s32 > area_top(0, 0, m_area.getWidth(), m_area.getHeight()/2);
|
|
||||||
//IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText( stringw(_("Enter the new player's name")).c_str(),
|
|
||||||
// area_top, false /* border */, true /* word wrap */,
|
|
||||||
// m_irrlicht_window);
|
|
||||||
// label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
|
||||||
|
|
||||||
LabelWidget* widget = new LabelWidget();
|
LabelWidget* widget = new LabelWidget();
|
||||||
|
|
||||||
//I18N: In the 'add new player' dialog
|
//I18N: In the 'add new player' dialog
|
||||||
|
@ -33,6 +33,7 @@ PlayerInfoDialog::PlayerInfoDialog(PlayerProfile* player, const float w, const f
|
|||||||
|
|
||||||
showRegularDialog();
|
showRegularDialog();
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
void PlayerInfoDialog::showRegularDialog()
|
void PlayerInfoDialog::showRegularDialog()
|
||||||
{
|
{
|
||||||
clearWindow();
|
clearWindow();
|
||||||
@ -112,7 +113,7 @@ void PlayerInfoDialog::showRegularDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
void PlayerInfoDialog::showConfirmDialog()
|
void PlayerInfoDialog::showConfirmDialog()
|
||||||
{
|
{
|
||||||
clearWindow();
|
clearWindow();
|
||||||
@ -128,6 +129,9 @@ void PlayerInfoDialog::showConfirmDialog()
|
|||||||
StringUtils::insertValues( _("Do you really want to delete player '%s' ?"), m_player->getName());
|
StringUtils::insertValues( _("Do you really want to delete player '%s' ?"), m_player->getName());
|
||||||
|
|
||||||
core::rect< s32 > area_left(5, 0, m_area.getWidth()-5, m_area.getHeight()/2);
|
core::rect< s32 > area_left(5, 0, m_area.getWidth()-5, m_area.getHeight()/2);
|
||||||
|
|
||||||
|
// 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)
|
||||||
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( message.c_str(),
|
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( message.c_str(),
|
||||||
area_left, false /* border */, true /* word wrap */,
|
area_left, false /* border */, true /* word wrap */,
|
||||||
m_irrlicht_window);
|
m_irrlicht_window);
|
||||||
@ -172,10 +176,11 @@ void PlayerInfoDialog::showConfirmDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
void PlayerInfoDialog::onEnterPressedInternal()
|
void PlayerInfoDialog::onEnterPressedInternal()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
void PlayerInfoDialog::processEvent(std::string& eventSource)
|
void PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||||
{
|
{
|
||||||
if(eventSource == "renameplayer")
|
if(eventSource == "renameplayer")
|
||||||
|
@ -55,6 +55,7 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
|
|||||||
m_children.push_back(widget2);
|
m_children.push_back(widget2);
|
||||||
widget2->add();
|
widget2->add();
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
void PressAKeyDialog::processEvent(std::string& eventSource)
|
void PressAKeyDialog::processEvent(std::string& eventSource)
|
||||||
{
|
{
|
||||||
if(eventSource == "cancel")
|
if(eventSource == "cancel")
|
||||||
|
@ -15,19 +15,169 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#include "challenges/unlock_manager.hpp"
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
|
#include "io/file_manager.hpp"
|
||||||
|
#include "karts/kart.hpp"
|
||||||
|
#include "modes/world.hpp"
|
||||||
|
#include "network/network_manager.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
#include "states_screens/dialogs/race_over_dialog.hpp"
|
#include "states_screens/dialogs/race_over_dialog.hpp"
|
||||||
|
#include "utils/string_utils.hpp"
|
||||||
#include "utils/translation.hpp"
|
#include "utils/translation.hpp"
|
||||||
|
|
||||||
RaceOverDialog::RaceOverDialog(const float percentWidth, const float percentHeight) : ModalDialog(percentWidth, percentHeight)
|
RaceOverDialog::RaceOverDialog(const float percentWidth, const float percentHeight) : ModalDialog(percentWidth, percentHeight)
|
||||||
{
|
{
|
||||||
const int y1 = m_area.getHeight()/2;
|
// Switch to barrier mode: server waits for ack from each client
|
||||||
|
network_manager->beginRaceResultBarrier();
|
||||||
|
|
||||||
core::rect< s32 > area(0, y1 - 100, m_area.getWidth(), y1 + 100);
|
//const int w = m_area.getWidth();
|
||||||
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( _("Race Results"),
|
//const int h = m_area.getHeight();
|
||||||
|
|
||||||
|
IGUIFont* font = GUIEngine::getFont();
|
||||||
|
const int textHeight = font->getDimension(L"X").Height;
|
||||||
|
|
||||||
|
|
||||||
|
if (unlock_manager->getUnlockedFeatures().size()>0)
|
||||||
|
{
|
||||||
|
// TODO: unlocked features
|
||||||
|
}
|
||||||
|
|
||||||
|
core::rect< s32 > area(0, 0, m_area.getWidth(), textHeight);
|
||||||
|
IGUIStaticText* caption = GUIEngine::getGUIEnv()->addStaticText( _("Race Results"),
|
||||||
area, false, false, // border, word warp
|
area, false, false, // border, word warp
|
||||||
m_irrlicht_window);
|
m_irrlicht_window);
|
||||||
a->setTabStop(false);
|
caption->setTabStop(false);
|
||||||
|
caption->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||||
|
|
||||||
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||||
|
{
|
||||||
|
// TODO: offer to continue GP
|
||||||
|
// _("Continue Grand Prix")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: offer to go back to menu
|
||||||
|
// _("Back to the main menu")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : _("Race in this track again")
|
||||||
|
|
||||||
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_SINGLE)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
// _("Setup New Race")
|
||||||
|
}
|
||||||
|
|
||||||
|
// _("Race results")
|
||||||
|
// const unsigned int MAX_STR_LEN = 60;
|
||||||
|
const unsigned int num_karts = race_manager->getNumKarts();
|
||||||
|
|
||||||
|
int* order = new int [num_karts];
|
||||||
|
RaceManager::getWorld()->raceResultOrder( order );
|
||||||
|
|
||||||
|
const bool display_time = (RaceManager::getWorld()->getClockMode() == CHRONO);
|
||||||
|
|
||||||
|
const int line_h = textHeight + 15;
|
||||||
|
const int lines_from_y = textHeight + 15;
|
||||||
|
int kart_id = 0; // 'i' below is not reliable because some karts (e.g. leader) will be skipped
|
||||||
|
for (unsigned int i = 0; i < num_karts; ++i)
|
||||||
|
{
|
||||||
|
if (order[i] == -1) continue;
|
||||||
|
|
||||||
|
stringw kart_results_line;
|
||||||
|
|
||||||
|
const Kart *current_kart = RaceManager::getKart(order[i]);
|
||||||
|
const stringw& kart_name = current_kart->getName();
|
||||||
|
|
||||||
|
char sTime[20];
|
||||||
|
sTime[0]=0;
|
||||||
|
|
||||||
|
const float time = current_kart->getFinishTime();
|
||||||
|
|
||||||
|
if (display_time)
|
||||||
|
{
|
||||||
|
const int min = (int) floor ( time / 60.0 ) ;
|
||||||
|
const int sec = (int) floor ( time - (double) ( 60 * min ) ) ;
|
||||||
|
const int tenths = (int) floor ( 10.0f * (time - (double)(sec + 60* min)));
|
||||||
|
sprintf ( sTime, "%d:%02d:%d", min, sec, tenths ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//This shows position + driver name + time + points earned + total points
|
||||||
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||||
|
{
|
||||||
|
const int prev_score = race_manager->getKartPrevScore(order[i]);
|
||||||
|
const int new_score = race_manager->getKartScore(order[i]);
|
||||||
|
|
||||||
|
kart_results_line = StringUtils::insertValues( L"#%i. %s (%i + %i = %i)",
|
||||||
|
current_kart->getPosition(), kart_name.c_str(), // FIXME: insertValues & wide strings
|
||||||
|
prev_score, (new_score - prev_score), new_score);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::wcout << kart_name.c_str() << std::endl;
|
||||||
|
|
||||||
|
kart_results_line = StringUtils::insertValues( L"%i. %s %s", // FIXME: insertValues & wide strings
|
||||||
|
current_kart->getPosition(), kart_name.c_str(), sTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
const KartProperties* prop = current_kart->getKartProperties();
|
||||||
|
std::string icon_path = file_manager->getDataDir() ;
|
||||||
|
icon_path += "/karts/" + prop->getIdent() + "/" + prop->getIconFile();
|
||||||
|
ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
|
||||||
|
|
||||||
|
const int icon_size = textHeight;
|
||||||
|
core::rect< s32 > entry_area(10 + icon_size, lines_from_y+line_h*i, m_area.getWidth(), lines_from_y+line_h*(i+1));
|
||||||
|
core::rect< s32 > icon_area(5, lines_from_y + line_h*i, 5+icon_size, lines_from_y+icon_size);
|
||||||
|
|
||||||
|
std::wcout << kart_results_line.c_str() << std::endl;
|
||||||
|
|
||||||
|
GUIEngine::getGUIEnv()->addStaticText( kart_results_line.c_str(), entry_area,
|
||||||
|
false , true , // border, word warp
|
||||||
|
m_irrlicht_window);
|
||||||
|
IGUIImage* img = GUIEngine::getGUIEnv()->addImage( icon_area, m_irrlicht_window );
|
||||||
|
img->setImage(kart_icon_texture);
|
||||||
|
img->setScaleImage(true);
|
||||||
|
img->setTabStop(false);
|
||||||
|
|
||||||
|
kart_id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] order;
|
||||||
|
|
||||||
|
/*
|
||||||
|
const HighscoreEntry *hs = RaceManager::getWorld()->getHighscores();
|
||||||
|
if (hs != NULL)
|
||||||
|
{
|
||||||
|
w_prev=widget_manager->addTextWgt( WTOK_HIGHSCORES, 5, 7, _("Highscores") );
|
||||||
|
widget_manager->hideWgtRect(WTOK_HIGHSCORES);
|
||||||
|
w_prev->setPosition(WGT_DIR_FROM_RIGHT, 0.01f, NULL, WGT_DIR_FROM_TOP, 0.01f, NULL);
|
||||||
|
|
||||||
|
unsigned int num_scores = hs->getNumberEntries();
|
||||||
|
char *highscores = new char[num_scores * MAX_STR_LEN];
|
||||||
|
|
||||||
|
for(unsigned int i=0; i<num_scores; i++)
|
||||||
|
{
|
||||||
|
std::string kart_name, name;
|
||||||
|
float T;
|
||||||
|
hs->getEntry(i, kart_name, name, &T);
|
||||||
|
const int MINS = (int) floor ( T / 60.0 ) ;
|
||||||
|
const int SECS = (int) floor ( T - (float) ( 60 * MINS ) ) ;
|
||||||
|
const int TENTHS = (int) floor ( 10.0f * (T - (float)(SECS + 60*MINS)));
|
||||||
|
sprintf((char*)( highscores + MAX_STR_LEN * i ),
|
||||||
|
"%s: %3d:%02d.%01d", name.c_str(), MINS, SECS, TENTHS);
|
||||||
|
|
||||||
|
Widget *w=widget_manager->addTextWgt(WTOK_FIRST_HIGHSCORE + i, 5, 7,
|
||||||
|
(char*)( highscores+MAX_STR_LEN*i ) );
|
||||||
|
w->setPosition(WGT_DIR_FROM_RIGHT, 0.05f, NULL, WGT_DIR_UNDER_WIDGET, 0, w_prev);
|
||||||
|
w_prev=w;
|
||||||
|
} // next score
|
||||||
|
|
||||||
|
widget_manager->sameWidth(WTOK_HIGHSCORES, WTOK_FIRST_HIGHSCORE+num_scores-1);
|
||||||
|
|
||||||
|
bottom_of_list = (num_scores > num_karts) ? w_prev : bottom_of_list;
|
||||||
|
} // end if hs != NULL
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void RaceOverDialog::onEnterPressedInternal()
|
void RaceOverDialog::onEnterPressedInternal()
|
||||||
|
@ -223,13 +223,13 @@ void startGame(const std::string trackIdent, const int num_laps)
|
|||||||
|
|
||||||
race_manager->startNew();
|
race_manager->startNew();
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
void TrackInfoDialog::onEnterPressedInternal()
|
void TrackInfoDialog::onEnterPressedInternal()
|
||||||
{
|
{
|
||||||
const int num_laps = m_spinner->getValue();
|
const int num_laps = m_spinner->getValue();
|
||||||
startGame(m_track_ident, num_laps);
|
startGame(m_track_ident, num_laps);
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
void TrackInfoDialog::processEvent(std::string& eventSource)
|
void TrackInfoDialog::processEvent(std::string& eventSource)
|
||||||
{
|
{
|
||||||
if (eventSource == "start" )
|
if (eventSource == "start" )
|
||||||
|
@ -29,10 +29,12 @@ class TrackInfoDialog : public GUIEngine::ModalDialog
|
|||||||
{
|
{
|
||||||
std::string m_track_ident;
|
std::string m_track_ident;
|
||||||
|
|
||||||
|
// 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::SpinnerWidget* m_spinner;
|
||||||
|
|
||||||
irr::gui::IGUIImage* m_kart_icons[HIGHSCORE_COUNT];
|
irr::gui::IGUIImage* m_kart_icons[HIGHSCORE_COUNT];
|
||||||
irr::gui::IGUIStaticText* m_highscore_entries[HIGHSCORE_COUNT];
|
irr::gui::IGUIStaticText* m_highscore_entries[HIGHSCORE_COUNT];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Creates a modal dialog with given percentage of screen width and height
|
* Creates a modal dialog with given percentage of screen width and height
|
||||||
|
Loading…
Reference in New Issue
Block a user