Started implementing in-game pause dialog (not usable yet)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3987 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-09-03 01:50:13 +00:00
parent a18c750e1b
commit 6abe2523bc
9 changed files with 199 additions and 4 deletions

BIN
data/gui/back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
data/gui/restart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -257,6 +257,8 @@ supertuxkart_SOURCES = \
states_screens/dialogs/press_a_key_dialog.cpp \
states_screens/dialogs/race_over_dialog.cpp \
states_screens/dialogs/race_over_dialog.hpp \
states_screens/dialogs/race_paused_dialog.hpp \
states_screens/dialogs/race_paused_dialog.cpp \
states_screens/credits.cpp \
states_screens/credits.hpp \
states_screens/kart_selection.cpp \

View File

@ -993,7 +993,8 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
else if(type == WTYPE_ICON_BUTTON)
{
if(!focused) return; /* don't draw any border in this case */
else drawButton(widget, rect, pressed /* pressed */, true /* focused */);
// else drawButton(widget, rect, pressed /* pressed */, true /* focused */);
// TODO : draw focus for icon buttons
}
else if(type == WTYPE_BUTTON)
{

View File

@ -32,6 +32,7 @@ void IconButtonWidget::add()
{
// ---- Icon
ITexture* texture = GUIEngine::getDriver()->getTexture((file_manager->getDataDir() + "/" +m_properties[PROP_ICON]).c_str());
assert(texture != NULL);
const int texture_w = texture->getSize().Width, texture_h = texture->getSize().Height;
/*
if(w < texture_w) ... ;

View File

@ -254,6 +254,7 @@
95833240101243ED00C5137E /* player_info_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95833239101243ED00C5137E /* player_info_dialog.cpp */; };
95833241101243ED00C5137E /* press_a_key_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9583323B101243ED00C5137E /* press_a_key_dialog.cpp */; };
95833242101243ED00C5137E /* track_info_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9583323D101243ED00C5137E /* track_info_dialog.cpp */; };
958D8C54104F523000A81934 /* race_paused_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958D8C53104F523000A81934 /* race_paused_dialog.cpp */; };
95B5CD14102DE08F00EF2001 /* device_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95B5CD13102DE08F00EF2001 /* device_config.cpp */; };
95CB476C0FF30EF400413BAE /* bezier_curve.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95CB476B0FF30EF400413BAE /* bezier_curve.cpp */; };
95D1F5F70FC8C3E300FF6968 /* input.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D1F5F60FC8C3E300FF6968 /* input.cpp */; };
@ -434,6 +435,8 @@
9583323C101243ED00C5137E /* press_a_key_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = press_a_key_dialog.hpp; path = ../../states_screens/dialogs/press_a_key_dialog.hpp; sourceTree = SOURCE_ROOT; };
9583323D101243ED00C5137E /* track_info_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = track_info_dialog.cpp; path = ../../states_screens/dialogs/track_info_dialog.cpp; sourceTree = SOURCE_ROOT; };
9583323E101243ED00C5137E /* track_info_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = track_info_dialog.hpp; path = ../../states_screens/dialogs/track_info_dialog.hpp; sourceTree = SOURCE_ROOT; };
958D8C52104F523000A81934 /* race_paused_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = race_paused_dialog.hpp; path = games/supertuxkart/src/states_screens/dialogs/race_paused_dialog.hpp; sourceTree = SYSTEM_DEVELOPER_DIR; };
958D8C53104F523000A81934 /* race_paused_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = race_paused_dialog.cpp; path = games/supertuxkart/src/states_screens/dialogs/race_paused_dialog.cpp; sourceTree = SYSTEM_DEVELOPER_DIR; };
95A118290F77EA3100B18B3D /* input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = input.hpp; path = ../../input/input.hpp; sourceTree = SOURCE_ROOT; };
95A1182A0F77EA3100B18B3D /* input_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = input_manager.cpp; path = ../../input/input_manager.cpp; sourceTree = SOURCE_ROOT; };
95A1182B0F77EA3100B18B3D /* input_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = input_manager.hpp; path = ../../input/input_manager.hpp; sourceTree = SOURCE_ROOT; };
@ -1247,6 +1250,8 @@
9583323E101243ED00C5137E /* track_info_dialog.hpp */,
9551DB33104CABFC001C53E5 /* race_over_dialog.cpp */,
9551DB32104CABFC001C53E5 /* race_over_dialog.hpp */,
958D8C53104F523000A81934 /* race_paused_dialog.cpp */,
958D8C52104F523000A81934 /* race_paused_dialog.hpp */,
);
name = dialogs;
path = ../../states_screens/dialogs;
@ -2480,6 +2485,7 @@
952A1554103F68D000B1895D /* profile_world.cpp in Sources */,
9524739610497C75000C197E /* dynamic_ribbon_widget.cpp in Sources */,
9551DB34104CABFC001C53E5 /* race_over_dialog.cpp in Sources */,
958D8C54104F523000A81934 /* race_paused_dialog.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -0,0 +1,148 @@
// 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 "states_screens/dialogs/race_paused_dialog.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets.hpp"
#include "io/file_manager.hpp"
#include "utils/translation.hpp"
#include <string>
using namespace GUIEngine;
RacePausedDialog::RacePausedDialog(const float percentWidth, const float percentHeight) : ModalDialog(percentWidth, percentHeight)
{
IGUIFont* font = GUIEngine::getFont();
const int text_height = font->getDimension(L"X").Height;
core::rect< s32 > area(0, 0, m_area.getWidth(), text_height);
IGUIStaticText* caption = GUIEngine::getGUIEnv()->addStaticText( _("Paused"),
area, false, false, // border, word warp
m_irrlicht_window);
caption->setTabStop(false);
caption->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
ITexture* back_texture = irr_driver->getTexture( (file_manager->getGUIDir() + "/back.png").c_str() ) ;
const int tex_w = back_texture->getSize().Width;
const int tex_h = back_texture->getSize().Height;
IconButtonWidget* back_btn = new IconButtonWidget();
back_btn->m_properties[PROP_ID] = "backbtn";
back_btn->m_properties[PROP_ICON] = "gui/back.png";
//I18N: In the 'paused' screen
back_btn->m_text = L"Back to Race";
back_btn->x = m_area.getWidth() / 2 - tex_w / 2;
back_btn->y = text_height;
back_btn->w = tex_w;
back_btn->h = tex_h;
back_btn->setParent(m_irrlicht_window);
m_children.push_back(back_btn);
back_btn->add();
GUIEngine::getGUIEnv()->setFocus( back_btn->getIrrlichtElement() );
}
/*
46 widget_manager->addTitleWgt( WTOK_PAUSE, 50, 7, _("Paused") );
47
48 widget_manager->addTextButtonWgt( WTOK_RETURN_RACE, 50, 7, _("Return To Race"));
49 widget_manager->addTextButtonWgt( WTOK_OPTIONS, 50, 7, _("Options") );
50 widget_manager->addTextButtonWgt( WTOK_HELP, 50, 7, _("Help") );
51 widget_manager->addTextButtonWgt( WTOK_RESTART_RACE, 50, 7, _("Restart Race") );
52
53 if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_QUICK_RACE)
54 {
55 widget_manager->addTextButtonWgt( WTOK_SETUP_NEW_RACE, 50, 7,
56 _("Setup New Race") );
57 }
58
59 widget_manager->addTextButtonWgt( WTOK_QUIT, 50, 7, _("Exit Race") );
60
*/
/*
77 switch (clicked_token)
78 {
79 case WTOK_RETURN_RACE:
80 RaceManager::getWorld()->unpause();
81 menu_manager->popMenu();
82 if(user_config->m_fullscreen) SDL_ShowCursor(SDL_DISABLE);
83 break;
84
85 case WTOK_SETUP_NEW_RACE:
86 RaceManager::getWorld()->unpause();
87 race_manager->exit_race();
88 menu_manager->pushMenu(MENUID_CHARSEL_P1);
89 break;
90
91 case WTOK_RESTART_RACE:
92 menu_manager->popMenu();
93 if(user_config->m_fullscreen) SDL_ShowCursor(SDL_DISABLE);
94 RaceManager::getWorld()->restartRace();
95 break;
96
97 case WTOK_OPTIONS:
98 menu_manager->pushMenu(MENUID_OPTIONS);
99 break;
100
101 case WTOK_HELP:
102 menu_manager->pushMenu(MENUID_HELP1);
103 break;
104
105 case WTOK_QUIT:
106 RaceManager::getWorld()->unpause();
107 race_manager->exit_race();
108 break;
109
110 default:
111 break;
112 }
113 }
*/
/*
void RaceMenu::handle(GameAction ga, int value)
117 {
118 switch ( ga )
119 {
120 case GA_LEAVE:
121 if (value)
122 break;
123
124 RaceManager::getWorld()->unpause();
125 menu_manager->popMenu();
126 break;
127
128 default:
129 BaseGUI::handle(ga, value);
130 break;
131 }
*/
/*
resetAndGoToMenu("main.stkgui");
input_manager->setMode(InputManager::MENU);
*/
void RacePausedDialog::onEnterPressedInternal()
{
}
void RacePausedDialog::processEvent(std::string& eventSource)
{
}

View File

@ -0,0 +1,36 @@
// 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_RACE_PAUSED_DIALOG_HPP
#define HEADER_RACE_PAUSED_DIALOG_HPP
#include "guiengine/modaldialog.hpp"
class RacePausedDialog : public GUIEngine::ModalDialog
{
public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
RacePausedDialog(const float percentWidth, const float percentHeight);
void onEnterPressedInternal();
void processEvent(std::string& eventSource);
};
#endif

View File

@ -38,6 +38,7 @@
#include "states_screens/kart_selection.hpp"
#include "states_screens/credits.hpp"
#include "states_screens/dialogs/track_info_dialog.hpp"
#include "states_screens/dialogs/race_paused_dialog.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/translation.hpp"
@ -469,9 +470,9 @@ void StateManager::escapePressed()
// In-game
else if(m_game_mode)
{
// TODO : show in-game menu
resetAndGoToMenu("main.stkgui");
input_manager->setMode(InputManager::MENU);
new RacePausedDialog(0.6f, 0.4f);
//resetAndGoToMenu("main.stkgui");
//input_manager->setMode(InputManager::MENU);
}
// In menus
else