initial support for the 'enter a new player' dialog

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3623 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-06-20 01:05:10 +00:00
parent 7f925012a6
commit c06dd7cbe2
3 changed files with 29 additions and 2 deletions

View File

@ -67,6 +67,21 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
ModalDialog(w, h)
{
core::rect< s32 > area2(0, 0, m_area.getWidth(), m_area.getHeight());
GUIEngine::getGUIEnv()->addButton( area2, m_irrlicht_window, -1, stringw(_("Enter the new player's name")).c_str() );
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);
IGUIFont* font = GUIEngine::getFont();
const int textHeight = font->getDimension(L"X").Height;
const int bottomYFrom = m_area.getHeight()/2;
const int bottomYTo = m_area.getHeight();
const int bottomHeight = bottomYTo - bottomYFrom;
const int textAreaYFrom = bottomYFrom + bottomHeight/2 - textHeight/2;
core::rect< s32 > area_bottom(50, textAreaYFrom - 10, m_area.getWidth()-50, textAreaYFrom + textHeight + 10);
IGUIEditBox* textCtrl = GUIEngine::getGUIEnv()->addEditBox (L"", area_bottom, true /* border */, m_irrlicht_window);
GUIEngine::getGUIEnv()->setFocus(textCtrl);
}

View File

@ -288,6 +288,11 @@ namespace StateManager
eventInput(devices, name2);
}
void eventPlayers(Widget* widget, const std::string& name)
{
new EnterPlayerNameDialog(0.5f, 0.4f);
}
// -----------------------------------------------------------------------------
static PlayerAction binding_to_set;
static std::string binding_to_set_button;
@ -514,6 +519,7 @@ namespace StateManager
{
if(screen_name == "options_av.stkgui") eventAudioVideo(widget, name);
else if(screen_name == "options_input.stkgui") eventInput(widget, name);
else if(screen_name == "options_players.stkgui") eventPlayers(widget, name);
}
}

View File

@ -842,6 +842,12 @@ void Skin::draw3DButtonPaneStandard (IGUIElement *element, const core::rect< s32
void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, bool flat, bool fillBackGround, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
{
if(dynamic_cast<IGUIEditBox*>(element) != NULL)
{
GUIEngine::getDriver()->draw2DRectangle( SColor(100, 150, 150, 150), rect );
return;
}
const int id = element->getID();
Widget* widget = GUIEngine::getCurrentScreen()->getWidget(id);