~ubuntu-branches/ubuntu/edgy/pouetchess/edgy-updates

« back to all changes in this revision

Viewing changes to src/scene_init.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc (mr_pouit)
  • Date: 2006-07-15 15:45:57 UTC
  • Revision ID: james.westby@ubuntu.com-20060715154557-3paxq02hx4od0wm4
Tags: upstream-0.2.0
ImportĀ upstreamĀ versionĀ 0.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2006 by Frederic MARTIN                                 *
 
3
 *   martin-frederic@users.sourceforge.net                                 *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
 
 
22
#include "scene_init.h"
 
23
#include "globalInfos.h"
 
24
#include "utils.h"
 
25
#include "models.h"
 
26
 
 
27
//--------------------------------------------------//
 
28
//--------------------------------------------------//
 
29
//                 **  Chess_Scene **               //
 
30
//--------------------------------------------------//
 
31
//--------------------------------------------------//
 
32
 
 
33
Chess_Scene::Chess_Scene()
 
34
{
 
35
        already_loaded=false;
 
36
}
 
37
 
 
38
Chess_Scene::~Chess_Scene()
 
39
{
 
40
 
 
41
}
 
42
 
 
43
void Chess_Scene::finish_loading()
 
44
{
 
45
        SDL_Delay(100);
 
46
        
 
47
 
 
48
        pGlobalInfos->Update();
 
49
        pGlobalInfos->Update();
 
50
        
 
51
        already_loaded=true;    
 
52
}
 
53
 
 
54
//--------------------------------------------------//
 
55
//--------------------------------------------------//
 
56
//               **  E_scene_init **                //
 
57
//--------------------------------------------------//
 
58
//--------------------------------------------------//
 
59
 
 
60
E_scene_init::E_scene_init()
 
61
{
 
62
 
 
63
}
 
64
 
 
65
 
 
66
E_scene_init::~E_scene_init()
 
67
{
 
68
 
 
69
}
 
70
 
 
71
 
 
72
bool E_scene_init::load()
 
73
{
 
74
        if (already_loaded)
 
75
                return true;
 
76
        
 
77
        language="";
 
78
        language_selected = pGlobalInfos->LanguageExists();
 
79
        if (!language_selected)
 
80
        {
 
81
                // gui event listener
 
82
                pGlobalInfos->GUI_SetEvenListener(this);
 
83
                pGlobalInfos->GUI_setScene(GUI_SCENE_LANGUAGE_SELECTION);
 
84
                language = "english";// default language
 
85
        }
 
86
        
 
87
        finish_loading();
 
88
        return true;
 
89
}
 
90
 
 
91
void E_scene_init::unload()
 
92
{
 
93
        if (already_loaded==false)
 
94
                return;
 
95
        
 
96
 
 
97
        
 
98
        already_loaded=false;
 
99
}
 
100
 
 
101
void E_scene_init::update()
 
102
{
 
103
        if (already_loaded==false)
 
104
        {
 
105
                if ( load()==false )
 
106
                {
 
107
                        Logger::writeErrorLog("Loading of 'E_scene_init' failed: exiting...");
 
108
                        pGlobalInfos->QuitGame();
 
109
                        return;
 
110
                }
 
111
        }
 
112
        
 
113
        if (language_selected)
 
114
        {
 
115
                pGlobalInfos->GUI_init_language(language);
 
116
                pGlobalInfos->GUI_setScene(GUI_SCENE_EMPTY);
 
117
                unload();
 
118
                pGlobalInfos->SetCurrentScene(GAME_SCENE_INTRO);
 
119
                return;
 
120
        }
 
121
        
 
122
        go_2D();
 
123
        
 
124
        pGlobalInfos->GUI_updateEvents();
 
125
        pGlobalInfos->GUI_render();
 
126
 
 
127
        exit_2D();
 
128
 
 
129
        SDL_Delay(10);
 
130
 
 
131
}
 
132
 
 
133
 
 
134
void E_scene_init::actionPerformed(GUIEvent &evt)
 
135
{
 
136
        const std::string &callbackString  = evt.getCallbackString();
 
137
        GUIRectangle      *sourceRectangle = evt.getEventSource();
 
138
        int                widgetType      = sourceRectangle->getWidgetType();
 
139
        
 
140
        if(widgetType == WT_BUTTON)
 
141
        {
 
142
                GUIButton   *button = (GUIButton*)sourceRectangle;
 
143
                if(button->isClicked())
 
144
                {
 
145
                        if (callbackString == "okButton")
 
146
                                language_selected=true;
 
147
                }
 
148
        }
 
149
        else if (widgetType == WT_RADIO_BUTTON)
 
150
        {
 
151
                GUIRadioButton *button = (GUIRadioButton*)sourceRectangle;
 
152
                
 
153
                if(button->isClicked())
 
154
                        language=callbackString;        
 
155
        }
 
156
        
 
157
}
 
158
 
 
159
 
 
160
 
 
161
//--------------------------------------------------//
 
162
//--------------------------------------------------//
 
163
//              **  E_scene_intro **                //
 
164
//--------------------------------------------------//
 
165
//--------------------------------------------------//
 
166
 
 
167
E_scene_intro::E_scene_intro()
 
168
{
 
169
 
 
170
}
 
171
 
 
172
E_scene_intro::~E_scene_intro()
 
173
{
 
174
 
 
175
}
 
176
 
 
177
bool E_scene_intro::load()
 
178
{
 
179
        if (already_loaded)
 
180
                return true;
 
181
        
 
182
 
 
183
        
 
184
        
 
185
        
 
186
        finish_loading();
 
187
        return true;
 
188
}
 
189
 
 
190
void E_scene_intro::unload()
 
191
{
 
192
        if (already_loaded==false)
 
193
                return;
 
194
        
 
195
 
 
196
        
 
197
        already_loaded=false;
 
198
        
 
199
}
 
200
 
 
201
void E_scene_intro::update()
 
202
{
 
203
        if (already_loaded==false)
 
204
        {
 
205
                if ( load()==false )
 
206
                {
 
207
                        Logger::writeErrorLog("Loading of 'E_scene_intro' failed: exiting...");
 
208
                        pGlobalInfos->QuitGame();
 
209
                        return;
 
210
                }
 
211
        }
 
212
        
 
213
        
 
214
        pGlobalInfos->SetCurrentScene(GAME_SCENE_MAIN_MENU);
 
215
 
 
216
        SDL_Delay(10);
 
217
}
 
218
 
 
219
 
 
220