How many files can I forget in a commit?
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3772 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a193ed47e6
commit
b63935ee83
113
src/states_screens/dialogs/enter_player_name_dialog.cpp
Normal file
113
src/states_screens/dialogs/enter_player_name_dialog.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
// 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/widget.hpp"
|
||||
#include "states_screens/dialogs/enter_player_name_dialog.hpp"
|
||||
#include "states_screens/options_screen.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float 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();
|
||||
widget->m_properties[PROP_TEXT] = _("Enter the new player's name");
|
||||
widget->m_properties[PROP_TEXT_ALIGN] = "center";
|
||||
widget->x = 0;
|
||||
widget->y = 0;
|
||||
widget->w = m_area.getWidth();
|
||||
widget->h = m_area.getHeight()/3;
|
||||
widget->setParent(m_irrlicht_window);
|
||||
|
||||
m_children.push_back(widget);
|
||||
widget->add();
|
||||
|
||||
// ----
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
|
||||
const int textAreaYFrom = m_area.getHeight()/2 - textHeight/2;
|
||||
|
||||
textCtrl = new TextBoxWidget();
|
||||
textCtrl->m_properties[PROP_TEXT] = "";
|
||||
textCtrl->x = 50;
|
||||
textCtrl->y = textAreaYFrom - 10;
|
||||
textCtrl->w = m_area.getWidth()-100;
|
||||
textCtrl->h = textHeight + 5;
|
||||
textCtrl->setParent(m_irrlicht_window);
|
||||
m_children.push_back(textCtrl);
|
||||
textCtrl->add();
|
||||
GUIEngine::getGUIEnv()->setFocus( textCtrl->getIrrlichtElement() );
|
||||
|
||||
// TODO : add Ok button
|
||||
|
||||
cancelButton = new ButtonWidget();
|
||||
cancelButton->m_properties[PROP_ID] = "cancel";
|
||||
cancelButton->m_properties[PROP_TEXT] = _("Cancel");
|
||||
cancelButton->x = 15;
|
||||
cancelButton->y = m_area.getHeight() - textHeight - 12;
|
||||
cancelButton->w = m_area.getWidth() - 30;
|
||||
cancelButton->h = textHeight + 6;
|
||||
cancelButton->setParent(m_irrlicht_window);
|
||||
|
||||
m_children.push_back(cancelButton);
|
||||
cancelButton->add();
|
||||
|
||||
}
|
||||
EnterPlayerNameDialog::~EnterPlayerNameDialog()
|
||||
{
|
||||
textCtrl->getIrrlichtElement()->remove();
|
||||
}
|
||||
void EnterPlayerNameDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if(eventSource == "cancel")
|
||||
{
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
}
|
||||
void EnterPlayerNameDialog::onEnterPressedInternal()
|
||||
{
|
||||
// ---- Cancel button pressed
|
||||
if( GUIEngine::getGUIEnv()->hasFocus(cancelButton->getIrrlichtElement()) )
|
||||
{
|
||||
std::string fakeEvent = "cancel";
|
||||
processEvent(fakeEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
// ---- Otherwise, accept entered name
|
||||
stringw playerName = textCtrl->getText();
|
||||
if(playerName.size() > 0)
|
||||
OptionsScreen::gotNewPlayerName( playerName );
|
||||
|
||||
// irrLicht is too stupid to remove focus from deleted widgets
|
||||
// so do it by hand
|
||||
GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() );
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
|
||||
ModalDialog::dismiss();
|
||||
}
|
45
src/states_screens/dialogs/enter_player_name_dialog.hpp
Normal file
45
src/states_screens/dialogs/enter_player_name_dialog.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
// 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_ENTERPLAYERNAME_DIALOG_HPP
|
||||
#define HEADER_ENTERPLAYERNAME_DIALOG_HPP
|
||||
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
class TextBoxWidget;
|
||||
class ButtonWidget;
|
||||
}
|
||||
|
||||
class EnterPlayerNameDialog : public GUIEngine::ModalDialog
|
||||
{
|
||||
GUIEngine::TextBoxWidget* textCtrl;
|
||||
GUIEngine::ButtonWidget* cancelButton;
|
||||
public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
EnterPlayerNameDialog(const float percentWidth, const float percentHeight);
|
||||
~EnterPlayerNameDialog();
|
||||
|
||||
void onEnterPressedInternal();
|
||||
void processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
223
src/states_screens/dialogs/player_info_dialog.cpp
Normal file
223
src/states_screens/dialogs/player_info_dialog.cpp
Normal file
@ -0,0 +1,223 @@
|
||||
// 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 "config/player.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "states_screens/options_screen.hpp"
|
||||
#include "states_screens/dialogs/player_info_dialog.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
|
||||
PlayerInfoDialog::PlayerInfoDialog(PlayerProfile* player, const float w, const float h) : ModalDialog(w, h)
|
||||
{
|
||||
m_player = player;
|
||||
|
||||
showRegularDialog();
|
||||
}
|
||||
void PlayerInfoDialog::showRegularDialog()
|
||||
{
|
||||
clearWindow();
|
||||
|
||||
const int y1 = m_area.getHeight()/6;
|
||||
const int y2 = m_area.getHeight()*2/6;
|
||||
const int y3 = m_area.getHeight()*3/6;
|
||||
const int y4 = m_area.getHeight()*5/6;
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
const int buttonHeight = textHeight + 10;
|
||||
|
||||
{
|
||||
textCtrl = new TextBoxWidget();
|
||||
textCtrl->m_properties[PROP_ID] = "renameplayer";
|
||||
textCtrl->m_properties[PROP_TEXT] = m_player->getName();
|
||||
textCtrl->x = 50;
|
||||
textCtrl->y = y1 - textHeight/2;
|
||||
textCtrl->w = m_area.getWidth()-100;
|
||||
textCtrl->h = textHeight + 5;
|
||||
textCtrl->setParent(m_irrlicht_window);
|
||||
m_children.push_back(textCtrl);
|
||||
textCtrl->add();
|
||||
GUIEngine::getGUIEnv()->setFocus( textCtrl->getIrrlichtElement() );
|
||||
}
|
||||
|
||||
{
|
||||
ButtonWidget* widget = new ButtonWidget();
|
||||
widget->m_properties[PROP_ID] = "renameplayer";
|
||||
widget->m_properties[PROP_TEXT] = _("Rename");
|
||||
|
||||
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
|
||||
|
||||
widget->x = m_area.getWidth()/2 - textWidth/2;
|
||||
widget->y = y2;
|
||||
widget->w = textWidth;
|
||||
widget->h = buttonHeight;
|
||||
widget->setParent(m_irrlicht_window);
|
||||
m_children.push_back(widget);
|
||||
widget->add();
|
||||
}
|
||||
{
|
||||
ButtonWidget* widget = new ButtonWidget();
|
||||
widget->m_properties[PROP_ID] = "cancel";
|
||||
widget->m_properties[PROP_TEXT] = _("Cancel");
|
||||
|
||||
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
|
||||
|
||||
widget->x = m_area.getWidth()/2 - textWidth/2;
|
||||
widget->y = y3;
|
||||
widget->w = textWidth;
|
||||
widget->h = buttonHeight;
|
||||
widget->setParent(m_irrlicht_window);
|
||||
m_children.push_back(widget);
|
||||
widget->add();
|
||||
}
|
||||
|
||||
{
|
||||
ButtonWidget* widget = new ButtonWidget();
|
||||
widget->m_properties[PROP_ID] = "removeplayer";
|
||||
widget->m_properties[PROP_TEXT] = _("Remove");
|
||||
|
||||
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
|
||||
|
||||
widget->x = m_area.getWidth()/2 - textWidth/2;
|
||||
widget->y = y4;
|
||||
widget->w = textWidth;
|
||||
widget->h = buttonHeight;
|
||||
widget->setParent(m_irrlicht_window);
|
||||
m_children.push_back(widget);
|
||||
widget->add();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlayerInfoDialog::showConfirmDialog()
|
||||
{
|
||||
clearWindow();
|
||||
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
const int buttonHeight = textHeight + 10;
|
||||
|
||||
|
||||
char message[256];
|
||||
sprintf(message, _("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);
|
||||
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( stringw(message).c_str(),
|
||||
area_left, false /* border */, true /* word wrap */,
|
||||
m_irrlicht_window);
|
||||
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
|
||||
{
|
||||
ButtonWidget* widget = new ButtonWidget();
|
||||
widget->m_properties[PROP_ID] = "confirmremove";
|
||||
widget->m_properties[PROP_TEXT] = _("Confirm Remove");
|
||||
|
||||
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
|
||||
|
||||
widget->x = m_area.getWidth()/2 - textWidth/2;
|
||||
widget->y = m_area.getHeight()/2;
|
||||
widget->w = textWidth;
|
||||
widget->h = buttonHeight;
|
||||
widget->setParent(m_irrlicht_window);
|
||||
m_children.push_back(widget);
|
||||
widget->add();
|
||||
}
|
||||
|
||||
{
|
||||
ButtonWidget* widget = new ButtonWidget();
|
||||
widget->m_properties[PROP_ID] = "cancelremove";
|
||||
widget->m_properties[PROP_TEXT] = _("Cancel Remove");
|
||||
|
||||
const int textWidth = font->getDimension( stringw(widget->m_properties[PROP_TEXT].c_str()).c_str() ).Width + 40;
|
||||
|
||||
widget->x = m_area.getWidth()/2 - textWidth/2;
|
||||
widget->y = m_area.getHeight()*3/4;
|
||||
widget->w = textWidth;
|
||||
widget->h = buttonHeight;
|
||||
widget->setParent(m_irrlicht_window);
|
||||
m_children.push_back(widget);
|
||||
widget->add();
|
||||
GUIEngine::getGUIEnv()->setFocus( widget->getIrrlichtElement() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PlayerInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
void PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if(eventSource == "renameplayer")
|
||||
{
|
||||
// accept entered name
|
||||
stringw playerName = textCtrl->getText();
|
||||
if(playerName.size() > 0)
|
||||
{
|
||||
OptionsScreen::gotNewPlayerName( playerName, m_player );
|
||||
}
|
||||
|
||||
// irrLicht is too stupid to remove focus from deleted widgets
|
||||
// so do it by hand
|
||||
GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() );
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
else if(eventSource == "removeplayer")
|
||||
{
|
||||
showConfirmDialog();
|
||||
}
|
||||
else if(eventSource == "confirmremove")
|
||||
{
|
||||
OptionsScreen::deletePlayer( m_player );
|
||||
|
||||
// irrLicht is too stupid to remove focus from deleted widgets
|
||||
// so do it by hand
|
||||
GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() );
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
return;
|
||||
}
|
||||
else if(eventSource == "cancelremove")
|
||||
{
|
||||
showRegularDialog();
|
||||
}
|
||||
else if(eventSource == "cancel")
|
||||
{
|
||||
// irrLicht is too stupid to remove focus from deleted widgets
|
||||
// so do it by hand
|
||||
GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() );
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
48
src/states_screens/dialogs/player_info_dialog.hpp
Normal file
48
src/states_screens/dialogs/player_info_dialog.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
// 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_PLAYERINFO_DIALOG_HPP
|
||||
#define HEADER_PLAYERINFO_DIALOG_HPP
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
class TextBoxWidget;
|
||||
}
|
||||
|
||||
class PlayerInfoDialog : public GUIEngine::ModalDialog
|
||||
{
|
||||
GUIEngine::TextBoxWidget* textCtrl;
|
||||
PlayerProfile* m_player;
|
||||
|
||||
void showRegularDialog();
|
||||
void showConfirmDialog();
|
||||
public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
PlayerInfoDialog(PlayerProfile* PlayerInfoDialog,
|
||||
const float percentWidth, const float percentHeight);
|
||||
void onEnterPressedInternal();
|
||||
void processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
65
src/states_screens/dialogs/press_a_key_dialog.cpp
Normal file
65
src/states_screens/dialogs/press_a_key_dialog.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
// 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/widget.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "states_screens/dialogs/press_a_key_dialog.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
|
||||
ModalDialog(w, h)
|
||||
{
|
||||
LabelWidget* widget = new LabelWidget();
|
||||
widget->m_properties[PROP_TEXT] = _("Press a key");
|
||||
widget->m_properties[PROP_TEXT_ALIGN] = "center";
|
||||
widget->x = 0;
|
||||
widget->y = 0;
|
||||
widget->w = m_area.getWidth();
|
||||
widget->h = m_area.getHeight()/2;
|
||||
widget->setParent(m_irrlicht_window);
|
||||
|
||||
m_children.push_back(widget);
|
||||
widget->add();
|
||||
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
|
||||
ButtonWidget* widget2 = new ButtonWidget();
|
||||
widget2->m_properties[PROP_ID] = "cancel";
|
||||
widget2->m_properties[PROP_TEXT] = _("Press ESC to cancel");
|
||||
widget2->x = 15;
|
||||
widget2->y = m_area.getHeight() - textHeight - 12;
|
||||
widget2->w = m_area.getWidth() - 30;
|
||||
widget2->h = textHeight + 6;
|
||||
widget2->setParent(m_irrlicht_window);
|
||||
|
||||
m_children.push_back(widget2);
|
||||
widget2->add();
|
||||
}
|
||||
void PressAKeyDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if(eventSource == "cancel")
|
||||
{
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
dismiss();
|
||||
}
|
||||
}
|
34
src/states_screens/dialogs/press_a_key_dialog.hpp
Normal file
34
src/states_screens/dialogs/press_a_key_dialog.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
// 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_PRESSAKEY_DIALOG_HPP
|
||||
#define HEADER_PRESSAKEY_DIALOG_HPP
|
||||
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
|
||||
class PressAKeyDialog : public GUIEngine::ModalDialog
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
PressAKeyDialog(const float percentWidth, const float percentHeight);
|
||||
void processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
132
src/states_screens/dialogs/track_info_dialog.cpp
Normal file
132
src/states_screens/dialogs/track_info_dialog.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
// 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/widget.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
|
||||
TrackInfoDialog::TrackInfoDialog(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;
|
||||
|
||||
SpinnerWidget* spinner = new SpinnerWidget();
|
||||
spinner->x = m_area.getWidth()/2 - 200;
|
||||
spinner->y = y2;
|
||||
spinner->w = 400;
|
||||
spinner->h = y3 - y2 - 15;
|
||||
spinner->setParent(m_irrlicht_window);
|
||||
|
||||
spinner->m_properties[PROP_MIN_VALUE] = "1";
|
||||
spinner->m_properties[PROP_MAX_VALUE] = "99";
|
||||
spinner->m_properties[PROP_TEXT] = "%i laps";
|
||||
|
||||
m_children.push_back(spinner);
|
||||
spinner->add();
|
||||
spinner->setValue(3);
|
||||
spinner->getIrrlichtElement()->setTabStop(true);
|
||||
spinner->getIrrlichtElement()->setTabGroup(false);
|
||||
|
||||
ButtonWidget* okBtn = new ButtonWidget();
|
||||
okBtn->m_properties[PROP_ID] = "start";
|
||||
okBtn->m_properties[PROP_TEXT] = _("Start Race");
|
||||
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);
|
||||
|
||||
GUIEngine::getGUIEnv()->setFocus( okBtn->getIrrlichtElement() );
|
||||
|
||||
|
||||
core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);
|
||||
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( stringw(trackName).c_str(),
|
||||
area_top, false, true, // border, word warp
|
||||
m_irrlicht_window);
|
||||
a->setTabStop(false);
|
||||
|
||||
|
||||
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 , true , // border, word warp
|
||||
m_irrlicht_window);
|
||||
b->setTabStop(false);
|
||||
|
||||
|
||||
// TODO : preserve aspect ratio
|
||||
core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10);
|
||||
IGUIImage* screenshotWidget = GUIEngine::getGUIEnv()->addImage( area_right, m_irrlicht_window );
|
||||
screenshotWidget->setImage(screenshot);
|
||||
screenshotWidget->setScaleImage(true);
|
||||
screenshotWidget->setTabStop(false);
|
||||
|
||||
|
||||
|
||||
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
b->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
// FIXME : this probably doesn't belong here
|
||||
void startGame()
|
||||
{
|
||||
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->setTrack("lighthouse");
|
||||
race_manager->setNumLaps( 3 );
|
||||
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 TrackInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
|
||||
void TrackInfoDialog::processEvent(std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "start" ) startGame();
|
||||
}
|
35
src/states_screens/dialogs/track_info_dialog.hpp
Normal file
35
src/states_screens/dialogs/track_info_dialog.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
// 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_TRACKINFO_DIALOG_HPP
|
||||
#define HEADER_TRACKINFO_DIALOG_HPP
|
||||
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
|
||||
class TrackInfoDialog : public GUIEngine::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();
|
||||
void processEvent(std::string& eventSource);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user