Started implementing track-screen pop-up
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3632 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a1c3cc54f9
commit
28503654ad
@ -18,6 +18,9 @@
|
||||
#include "gui/engine.hpp"
|
||||
#include "gui/modaldialog.hpp"
|
||||
#include "gui/options_screen.hpp"
|
||||
#include "gui/state_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
using namespace irr;
|
||||
@ -43,6 +46,11 @@ void ModalDialog::onEnterPressed()
|
||||
if(modalWindow != NULL) modalWindow->onEnterPressedInternal();
|
||||
}
|
||||
|
||||
bool ModalDialog::isADialogActive()
|
||||
{
|
||||
return modalWindow != NULL;
|
||||
}
|
||||
|
||||
void ModalDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
@ -60,6 +68,7 @@ ModalDialog::ModalDialog(const float percentWidth, const float percentHeight)
|
||||
modalWindow = this;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
|
||||
@ -72,6 +81,7 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
|
||||
label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
|
||||
@ -96,9 +106,76 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
|
||||
GUIEngine::getGUIEnv()->setFocus(textCtrl);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void EnterPlayerNameDialog::onEnterPressedInternal()
|
||||
{
|
||||
stringw playerName = textCtrl->getText();
|
||||
StateManager::gotNewPlayerName( playerName );
|
||||
ModalDialog::dismiss();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
TrackInfoDialog::TrackInfoDialog(const char* trackName, ITexture* screenshot, const float w, const float h) : ModalDialog(w, h)
|
||||
{
|
||||
const int y1 = m_area.getHeight()/3;
|
||||
const int y2 = m_area.getHeight() - 50;
|
||||
|
||||
core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);
|
||||
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( stringw(trackName).c_str(),
|
||||
area_top, false /* border */, true /* word wrap */,
|
||||
m_irrlicht_window);
|
||||
|
||||
|
||||
core::rect< s32 > area_left(0, y1, m_area.getWidth()/2, y2);
|
||||
IGUIStaticText* b = GUIEngine::getGUIEnv()->addStaticText( stringw(_("High Scores & Track Info")).c_str(),
|
||||
area_left, false /* border */, true /* word wrap */,
|
||||
m_irrlicht_window);
|
||||
|
||||
// TODO : preserve aspect ratio
|
||||
core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2);
|
||||
IGUIImage* screenshotWidget = GUIEngine::getGUIEnv()->addImage( area_right, m_irrlicht_window );
|
||||
screenshotWidget->setImage(screenshot);
|
||||
screenshotWidget->setScaleImage(true);
|
||||
|
||||
core::rect< s32 > area_bottom(0, y2, m_area.getWidth(), m_area.getHeight());
|
||||
IGUIStaticText* d = GUIEngine::getGUIEnv()->addStaticText( stringw(_("Number of laps")).c_str(),
|
||||
area_bottom, false /* border */, true /* word wrap */,
|
||||
m_irrlicht_window);
|
||||
|
||||
|
||||
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
b->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
d->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void TrackInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
IVideoDriver* driver = GUIEngine::getDriver();
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
|
||||
// TODO : draw a loading screen
|
||||
driver->endScene();
|
||||
driver->beginScene(true, false);
|
||||
driver->endScene();
|
||||
|
||||
|
||||
StateManager::enterGameState();
|
||||
//race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
race_manager->setTrack("beach");
|
||||
race_manager->setNumLaps( 3 );
|
||||
race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge
|
||||
//race_manager->setNumKarts( 1 );
|
||||
race_manager->setNumPlayers( 1 );
|
||||
race_manager->setNumLocalPlayers( 1 );
|
||||
network_manager->setupPlayerKartInfo();
|
||||
//race_manager->getKartType(1) = KT_PLAYER;
|
||||
|
||||
race_manager->startNew();
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
|
||||
static void dismiss();
|
||||
static void onEnterPressed();
|
||||
static bool isADialogActive();
|
||||
};
|
||||
|
||||
class PressAKeyDialog : public ModalDialog
|
||||
@ -54,7 +55,7 @@ public:
|
||||
|
||||
class EnterPlayerNameDialog : public ModalDialog
|
||||
{
|
||||
IGUIEditBox* textCtrl;
|
||||
irr::gui::IGUIEditBox* textCtrl;
|
||||
public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
@ -62,3 +63,14 @@ public:
|
||||
EnterPlayerNameDialog(const float percentWidth, const float percentHeight);
|
||||
void onEnterPressedInternal();
|
||||
};
|
||||
|
||||
class TrackInfoDialog : public ModalDialog
|
||||
{
|
||||
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);
|
||||
void onEnterPressedInternal();
|
||||
};
|
||||
|
||||
|
@ -527,7 +527,6 @@ void Screen::processAction(const int action, const unsigned int value, Input::In
|
||||
|
||||
case PA_BRAKE:
|
||||
{
|
||||
std::cerr << "brake\n";
|
||||
IGUIElement *el, *first = NULL, *closest = NULL;
|
||||
el = GUIEngine::getGUIEnv()->getFocus();
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "gui/widget.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
@ -294,19 +295,10 @@ namespace StateManager
|
||||
if(w2 != NULL)
|
||||
{
|
||||
std::cout << "Clicked on track " << w2->getSelectionIDString().c_str() << std::endl;
|
||||
|
||||
StateManager::enterGameState();
|
||||
//race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
race_manager->setTrack("beach");
|
||||
race_manager->setNumLaps( 3 );
|
||||
race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge
|
||||
//race_manager->setNumKarts( 1 );
|
||||
race_manager->setNumPlayers( 1 );
|
||||
race_manager->setNumLocalPlayers( 1 );
|
||||
network_manager->setupPlayerKartInfo();
|
||||
//race_manager->getKartType(1) = KT_PLAYER;
|
||||
|
||||
race_manager->startNew();
|
||||
|
||||
ITexture* screenshot = GUIEngine::getDriver()->getTexture( (file_manager->getDataDir() + "/gui/track1.png").c_str() );
|
||||
|
||||
new TrackInfoDialog( w2->getSelectionText().c_str(), screenshot, 0.75, 0.6);
|
||||
}
|
||||
}
|
||||
else if(name == "gps")
|
||||
|
@ -1167,7 +1167,10 @@ void RibbonGridWidget::updateItemDisplay()
|
||||
std::string track_sshot = file_manager->getDataDir() + "/" + 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()) );
|
||||
icon->m_properties[PROP_ID] = m_items[icon_id].m_code_name;
|
||||
|
||||
icon->m_properties[PROP_ID] = m_items[icon_id].m_code_name;
|
||||
icon->m_properties[PROP_TEXT] = m_items[icon_id].m_user_name;
|
||||
|
||||
row.setLabel(i, m_items[icon_id].m_user_name);
|
||||
}
|
||||
else
|
||||
@ -1190,6 +1193,16 @@ const std::string& RibbonGridWidget::getSelectionIDString()
|
||||
return nothing;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
const std::string& RibbonGridWidget::getSelectionText()
|
||||
{
|
||||
RibbonWidget* row = (RibbonWidget*)(m_rows.size() == 1 ? m_rows.get(0) : getSelectedRibbon());
|
||||
|
||||
if(row != NULL) return row->getSelectionText();
|
||||
|
||||
static const std::string nothing = "";
|
||||
return nothing;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
RibbonWidget* RibbonGridWidget::getRowContaining(Widget* w) const
|
||||
{
|
||||
const int row_amount = m_rows.size();
|
||||
|
@ -266,6 +266,7 @@ namespace GUIEngine
|
||||
|
||||
RibbonType getRibbonType() const { return m_ribbon_type; }
|
||||
const std::string& getSelectionIDString() { return m_children[m_selection].m_properties[PROP_ID]; }
|
||||
const std::string& getSelectionText() { return m_children[m_selection].m_properties[PROP_TEXT]; }
|
||||
void setLabel(const int id, std::string new_name);
|
||||
|
||||
RibbonWidget(const RibbonType type=RIBBON_COMBO);
|
||||
@ -325,6 +326,8 @@ namespace GUIEngine
|
||||
bool mouseHovered(Widget* child);
|
||||
|
||||
const std::string& getSelectionIDString();
|
||||
const std::string& getSelectionText();
|
||||
|
||||
void setSelection(int item_id);
|
||||
void setSelection(const std::string& code_name);
|
||||
};
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "gui/options_screen.hpp"
|
||||
#include "gui/state_manager.hpp"
|
||||
#include "gui/modaldialog.hpp"
|
||||
#include "gui/engine.hpp"
|
||||
#include "gui/race_gui.hpp"
|
||||
#include "gui/screen.hpp"
|
||||
@ -197,6 +198,8 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi
|
||||
else if(btnID == KEY_RIGHT) action = PA_RIGHT;
|
||||
else if(btnID == KEY_SPACE) action = PA_FIRE;
|
||||
|
||||
if(btnID == KEY_RETURN && ModalDialog::isADialogActive()) ModalDialog::onEnterPressed();
|
||||
|
||||
if(action != PA_FIRST)
|
||||
{
|
||||
action_found = true;
|
||||
|
Loading…
Reference in New Issue
Block a user