~ubuntu-branches/ubuntu/precise/supertuxkart/precise

« back to all changes in this revision

Viewing changes to src/gui/race_menu.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-02-24 22:36:25 UTC
  • mfrom: (1.1.9 upstream) (6.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110224223625-ygrjfpg92obovuch
Tags: 0.7+dfsg1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  $Id: race_menu.cpp 3833 2009-08-11 12:07:12Z hikerstk $
2
 
//
3
 
//  SuperTuxKart - a fun racing game with go-kart
4
 
//  Copyright (C) 2006 SuperTuxKart-Team
5
 
//
6
 
//  This program is free software; you can redistribute it and/or
7
 
//  modify it under the terms of the GNU General Public License
8
 
//  as published by the Free Software Foundation; either version 3
9
 
//  of the License, or (at your option) any later version.
10
 
//
11
 
//  This program is distributed in the hope that it will be useful,
12
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
//  GNU General Public License for more details.
15
 
//
16
 
//  You should have received a copy of the GNU General Public License
17
 
//  along with this program; if not, write to the Free Software
18
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
 
 
20
 
#include "gui/race_menu.hpp"
21
 
 
22
 
#include <SDL/SDL.h>
23
 
 
24
 
#include "user_config.hpp"
25
 
 
26
 
#include "race_manager.hpp"
27
 
#include "gui/menu_manager.hpp"
28
 
#include "gui/widget_manager.hpp"
29
 
#include "utils/translation.hpp"
30
 
 
31
 
enum WidgetTokens
32
 
{
33
 
    WTOK_PAUSE,
34
 
    WTOK_RETURN_RACE,
35
 
    WTOK_OPTIONS,
36
 
    WTOK_HELP,
37
 
    WTOK_RESTART_RACE,
38
 
    WTOK_SETUP_NEW_RACE,
39
 
    WTOK_QUIT,
40
 
};
41
 
 
42
 
RaceMenu::RaceMenu()
43
 
{
44
 
    widget_manager->switchOrder();
45
 
 
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
 
 
61
 
    widget_manager->layout(WGT_AREA_ALL);
62
 
    if(user_config->m_fullscreen) SDL_ShowCursor(SDL_ENABLE);
63
 
}
64
 
 
65
 
//-----------------------------------------------------------------------------
66
 
RaceMenu::~RaceMenu()
67
 
{
68
 
    widget_manager->reset();
69
 
}
70
 
 
71
 
 
72
 
//-----------------------------------------------------------------------------
73
 
void RaceMenu::select()
74
 
{
75
 
    int clicked_token = widget_manager->getSelectedWgt();
76
 
 
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
 
        race_manager->rerunRace();
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
 
}
114
 
 
115
 
//-----------------------------------------------------------------------------
116
 
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
 
    }
132
 
}
133
 
 
134