~armagetronad-dev/armagetronad/0.4-armagetronad-fortress_ai

« back to all changes in this revision

Viewing changes to src/tron/gArmagetron.cpp

  • Committer: Manuel Moos
  • Date: 2010-08-07 21:08:56 UTC
  • mfrom: (2341.1.89 trunk)
  • Revision ID: z-man@users.sf.net-20100807210856-fcyd8v8a36nd9uoq
MergingĀ fromĀ mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
//#include "eTess.h"
44
44
#include "rTexture.h"
45
45
#include "tConfiguration.h"
 
46
#include "tRandom.h"
46
47
#include "tRecorder.h"
47
48
#include "tCommandLine.h"
48
49
#include "eAdvWall.h"
159
160
 
160
161
extern void exit_game_objects(eGrid *grid);
161
162
 
 
163
enum gConnection
 
164
{
 
165
    gLeave,
 
166
    gDialup,
 
167
    gISDN,
 
168
    gDSL
 
169
    // gT1
 
170
};
 
171
 
 
172
// initial setup menu
 
173
void sg_StartupPlayerMenu()
 
174
{
 
175
    uMenu firstSetup("$first_setup", false);
 
176
    firstSetup.SetBot(-.2);
 
177
    
 
178
    uMenuItemExit e2(&firstSetup, "$menuitem_accept", "$menuitem_accept_help");
 
179
    
 
180
    ePlayer * player = ePlayer::PlayerConfig(0);
 
181
    tASSERT( player );
 
182
 
 
183
    gConnection connection = gDSL;
 
184
 
 
185
    uMenuItemSelection<gConnection> net(&firstSetup, "$first_setup_net", "$first_setup_net_help", connection );
 
186
    if ( !st_FirstUse )
 
187
    {
 
188
        net.NewChoice( "$first_setup_leave", "$first_setup_leave_help", gLeave );
 
189
        connection = gLeave;
 
190
    }
 
191
    net.NewChoice( "$first_setup_net_dialup", "$first_setup_net_dialup_help", gDialup );
 
192
    net.NewChoice( "$first_setup_net_isdn", "$first_setup_net_isdn_help", gISDN );
 
193
    net.NewChoice( "$first_setup_net_dsl", "$first_setup_net_dsl_help", gDSL );
 
194
 
 
195
    tString keyboardTemplate("keys_cursor.cfg");
 
196
    uMenuItemSelection<tString> k(&firstSetup, "$first_setup_keys", "$first_setup_keys_help", keyboardTemplate );
 
197
    if ( !st_FirstUse )
 
198
    {
 
199
        k.NewChoice( "$first_setup_leave", "$first_setup_leave_help", tString("") );
 
200
        keyboardTemplate="";
 
201
    }
 
202
    k.NewChoice( "$first_setup_keys_cursor", "$first_setup_keys_cursor_help", tString("keys_cursor.cfg") );
 
203
    k.NewChoice( "$first_setup_keys_wasd", "$first_setup_keys_wasd_help", tString("keys_wasd.cfg") );
 
204
    k.NewChoice( "$first_setup_keys_zqsd", "$first_setup_keys_zqsd_help", tString("keys_zqsd.cfg") );
 
205
    k.NewChoice( "$first_setup_keys_cursor_single", "$first_setup_keys_cursor_single_help", tString("keys_cursor_single.cfg") );
 
206
    // k.NewChoice( "$first_setup_keys_both", "$first_setup_keys_both_help", tString("keys_twohand.cfg") );
 
207
    k.NewChoice( "$first_setup_keys_x", "$first_setup_keys_x_help", tString("keys_x.cfg") );
 
208
 
 
209
    tColor leave(0,0,0,0);
 
210
    tColor color(1,0,0);
 
211
    uMenuItemSelection<tColor> c(&firstSetup,
 
212
                                 "$first_setup_color",
 
213
                                 "$first_setup_color_help",
 
214
                                 color);   
 
215
 
 
216
    if ( !st_FirstUse )
 
217
    {
 
218
        color = leave;
 
219
        c.NewChoice( "$first_setup_leave", "$first_setup_leave_help", leave );
 
220
    }
 
221
 
 
222
    c.NewChoice( "$first_setup_color_red", "", tColor(1,0,0) );
 
223
    c.NewChoice( "$first_setup_color_blue", "", tColor(0,0,1) );
 
224
    c.NewChoice( "$first_setup_color_green", "", tColor(0,1,0) );
 
225
    c.NewChoice( "$first_setup_color_yellow", "", tColor(1,1,0) );
 
226
    c.NewChoice( "$first_setup_color_orange", "", tColor(1,.5,0) );
 
227
    c.NewChoice( "$first_setup_color_purple", "", tColor(.5,0,1) );
 
228
    c.NewChoice( "$first_setup_color_magenta", "", tColor(1,0,1) );
 
229
    c.NewChoice( "$first_setup_color_cyan", "", tColor(0,1,1) );
 
230
    c.NewChoice( "$first_setup_color_white", "", tColor(1,1,1) );
 
231
    c.NewChoice( "$first_setup_color_dark", "", tColor(0,0,0) );
 
232
    
 
233
    if ( st_FirstUse )
 
234
    {
 
235
        for(int i=tRandomizer::GetInstance().Get(4); i>=0; --i)
 
236
        {
 
237
            c.LeftRight(1);
 
238
        }
 
239
    }
 
240
 
 
241
    uMenuItemString n(&firstSetup,
 
242
                      "$player_name_text",
 
243
                      "$player_name_help",
 
244
                      player->name, 16);
 
245
    
 
246
    uMenuItemExit e(&firstSetup, "$menuitem_accept", "$menuitem_accept_help");
 
247
    
 
248
    firstSetup.Enter();
 
249
 
 
250
    // apply network rates
 
251
    switch(connection)
 
252
    {
 
253
    case gDialup:
 
254
        sn_maxRateIn  = 6;
 
255
        sn_maxRateOut = 4;
 
256
        break;
 
257
    case gISDN:
 
258
        sn_maxRateIn  = 8;
 
259
        sn_maxRateOut = 8;
 
260
        break;
 
261
    case gDSL:
 
262
        sn_maxRateIn  = 64;
 
263
        sn_maxRateOut = 16;
 
264
        break;
 
265
    case gLeave:
 
266
        break;
 
267
    }
 
268
 
 
269
    // store color
 
270
    if( ! (color == leave) )
 
271
    {
 
272
        player->rgb[0] = color.r_*15;
 
273
        player->rgb[1] = color.g_*15;
 
274
        player->rgb[2] = color.b_*15;
 
275
    }
 
276
 
 
277
    // load keyboard layout
 
278
    if( keyboardTemplate.Len() > 1 )
 
279
    {
 
280
        std::ifstream s;
 
281
        if( tConfItemBase::OpenFile( s, keyboardTemplate, tConfItemBase::Config ) )
 
282
        {
 
283
            tCurrentAccessLevel level( tAccessLevel_Owner, true );
 
284
            tConfItemBase::ReadFile( s );
 
285
        }
 
286
    }
 
287
}
 
288
 
162
289
#ifndef DEDICATED
163
290
static void welcome(){
164
291
    bool textOutBack = sr_textOut;
188
315
 
189
316
    if (st_FirstUse)
190
317
    {
191
 
        st_FirstUse=false;
192
318
        sr_LoadDefaultConfig();
193
319
        textOutBack = sr_textOut;
194
320
        sr_textOut = false;
277
403
    }
278
404
    rSysDep::SwapGL();
279
405
 
280
 
    sg_LanguageMenu();
281
 
 
282
 
    // catch some keyboard input
283
 
    {
284
 
        uInputProcessGuard inputProcessGuard;
285
 
        while (su_GetSDLInput(tEvent)) ;
286
 
    }
287
 
 
288
 
    timeout = tSysTimeFloat() + 10;
289
 
 
290
 
    sr_UnlockSDL();
291
 
    uInputProcessGuard inputProcessGuard;
292
 
    while((!su_GetSDLInput(tEvent) || tEvent.type!=SDL_KEYDOWN) &&
293
 
            tSysTimeFloat() < timeout){
294
 
 
295
 
        sr_ResetRenderState(true);
296
 
        rViewport::s_viewportFullscreen.Select();
297
 
 
298
 
        if ( sr_glOut )
299
 
        {
300
 
            rSysDep::ClearGL();
301
 
 
302
 
            uMenu::GenericBackground();
303
 
 
304
 
            REAL w=16*2/640.0;
305
 
            REAL h=32*2/480.0;
306
 
 
307
 
 
308
 
            //REAL middle=-.6;
309
 
 
310
 
            Color(1,1,1);
311
 
            DisplayText(0,.8,h,tOutput("$welcome_message_heading"), sr_fontError);
312
 
 
313
 
            w/=2;
314
 
            h/=2;
315
 
 
316
 
            rTextField c(-.8,.6, h, sr_fontError);
317
 
 
318
 
 
319
 
            c << tOutput("$welcome_message_intro");
320
 
 
321
 
            c.SetIndent(12);
322
 
 
323
 
            c << tOutput("$welcome_message_vendor")   << gl_vendor   << '\n';
324
 
            c << tOutput("$welcome_message_renderer") << gl_renderer << '\n';
325
 
            c << tOutput("$welcome_message_version")  << gl_version  << '\n';
326
 
 
327
 
            c.SetIndent(0);
328
 
 
329
 
            c << tOutput("$welcome_message_finish");
330
 
 
331
 
            rSysDep::SwapGL();
332
 
        }
333
 
 
334
 
        tAdvanceFrame();
335
 
    }
336
 
    sr_LockSDL();
 
406
    sr_textOut = textOutBack;
 
407
    sg_StartupLanguageMenu();
 
408
 
 
409
    sr_textOut = textOutBack;
 
410
    sg_StartupPlayerMenu();
 
411
 
 
412
    st_FirstUse=false;
 
413
 
 
414
    sr_textOut = textOutBack;
 
415
    uMenu::Message( tOutput("$welcome_message_heading"), tOutput("$welcome_message"), 300 );
 
416
 
 
417
    // start a first single player game
 
418
    sg_currentSettings->speedFactor = -2;
 
419
    sg_currentSettings->autoNum = 0;
 
420
    sr_textOut = textOutBack;
 
421
    sg_SinglePlayerGame();
 
422
    sg_currentSettings->autoNum = 1;
 
423
    sg_currentSettings->speedFactor = 0;
 
424
 
 
425
    sr_textOut = textOutBack;
 
426
    uMenu::Message( tOutput("$welcome_message_2_heading"), tOutput("$welcome_message_2"), 300 );
337
427
 
338
428
    sr_textOut = textOutBack;
339
429
}