4b825dc642cb6eb9a060e54bf8d69288fbee490494a6641b73026d662261604d7d192beae70b11dc
 
 
1
#include <assert.h>
 
 
2
#include <SDL/SDL.h>
 
 
3
#include <GL/gl.h>
 
 
4
#include "menus.h"
 
 
5
#include <time.h>
 
 
6
#include "system.h"
 
 
7
#include "prototyp.h"
 
 
8
#include "stratdef.h"
 
 
9
#include "net.h"
 
 
10
#include "hud.h"
 
 
11
#include "userprofile.h"
 
 
12
#include "avp_mp_config.h"
 
 
13
#include "savegame.h"
 
 
14
#include "psnd.h"
 
 
15
#include "bh_types.h"
 
 
16
 
 
 
17
extern void MakeMarineKeyConfigMenu();
 
 
18
extern void MakePredatorKeyConfigMenu();
 
 
19
extern void MakeAlienKeyConfigMenu();
 
 
20
extern void DrawSliderBar(int x, int y, int alpha);
 
 
21
extern void DrawSlider(int x, int y, int alpha);
 
 
22
extern void DrawRectangle(int x, int y, int w, int h, int alpha);
 
 
23
extern void Rectangle(int x0, int y0, int x1, int y1, int r, int g, int b, int a);
 
 
24
extern void DrawColourBar(int yTop, int yBottom, int rScale, int gScale, int bScale);
 
 
25
extern void GetNextAllowedSpecies(int* species,int search_forwards);
 
 
26
 
 
 
27
extern const char* marine_episodes[];
 
 
28
extern const char* predator_episodes[];
 
 
29
extern const char* alien_episodes[];
 
 
30
extern const char* marine_briefing_text[];
 
 
31
extern const char* alien_briefing_text[];
 
 
32
extern const char* predator_briefing_text[];
 
 
33
extern const char* cheat_modes[];
 
 
34
extern const char* coop_levels[];
 
 
35
extern const char* multiplayer_levels[];
 
 
36
static const char* BriefingTextString[5];
 
 
37
 
 
 
38
extern int MP_Species;
 
 
39
extern uint8_t* Keyboard;
 
 
40
extern int number_of_available_keys;
 
 
41
 
 
 
42
extern struct AVP_USER_PROFILE UserProfile;
 
 
43
SAVE_SLOT_HEADER SaveGameSlot[NUMBER_OF_SAVE_SLOTS];
 
 
44
 
 
 
45
extern char AAFontWidths[256];
 
 
46
extern int RealFrameTime;
 
 
47
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
 
 
48
 
 
 
49
extern char IPAddressString[]; 
 
 
50
extern char MP_Config_Description[];
 
 
51
extern char MP_Config_Name[];
 
 
52
static AVP_MENUS Menus;
 
 
53
extern MENU MenusData[];
 
 
54
 
 
 
55
extern int episode_to_play;
 
 
56
extern int CloakingPhase;
 
 
57
 
 
 
58
static int InputIsDebounced = 0;
 
 
59
static int KeyDepressedCounter = 0;
 
 
60
static int EpisodeSelectScrollOffset;
 
 
61
static int MaximumSelectableLevel;
 
 
62
static int KeyConfigSelectionColumn;
 
 
63
 
 
 
64
static int Brightness[16];
 
 
65
 
 
 
66
static uint8_t MultipleAssignments[2][32];
 
 
67
 
 
 
68
static PLAYER_INPUT_CONFIGURATION PlayerInputPrimaryConfig;
 
 
69
static PLAYER_INPUT_CONFIGURATION PlayerInputSecondaryConfig;
 
 
70
 
 
 
71
CONTROL_METHODS PlayerControlMethods;
 
 
72
 
 
 
73
static int MultiplayerConfigurationIndex; //just used for the configuration deletion stuff
 
 
74
static const char* MultiplayerConfigurationName = NULL; //ditto
 
 
75
 
 
 
76
static int HeightOfMenuElement(MENU_ELEMENT *elementPtr)
 
 
77
{
 
 
78
    int h = MENU_ELEMENT_SPACING;
 
 
79
 
 
 
80
    switch(elementPtr->ElementID)
 
 
81
    {
 
 
82
        default:
 
 
83
        {
 
 
84
            if (Menus.FontToUse == MENU_FONT_BIG)
 
 
85
                h += MENU_FONT_HEIGHT;
 
 
86
            else
 
 
87
                h = HUD_FONT_HEIGHT+4;
 
 
88
        }
 
 
89
        break;
 
 
90
        case MENU_ELEMENT_LOADGAME:
 
 
91
        case MENU_ELEMENT_SAVEGAME:
 
 
92
            h = HUD_FONT_HEIGHT*2+4;
 
 
93
        break;
 
 
94
        case MENU_ELEMENT_TEXTFIELD_SMALLWRAPPED :
 
 
95
            h += HUD_FONT_HEIGHT*4;
 
 
96
    }
 
 
97
 
 
 
98
return h;
 
 
99
}
 
 
100
 
 
 
101
static void SetBriefingTextToBlank()
 
 
102
{    
 
 
103
    BriefingTextString[0] = "";
 
 
104
    BriefingTextString[1] = "";
 
 
105
    BriefingTextString[2] = "";
 
 
106
    BriefingTextString[3] = "";
 
 
107
    BriefingTextString[4] = "";
 
 
108
}
 
 
109
 
 
 
110
static void SetBriefingTextForEpisode(int episode)
 
 
111
{
 
 
112
    int i=0;
 
 
113
    const char ** temp_ptr;
 
 
114
 
 
 
115
    switch(AvP.PlayerType)
 
 
116
    {
 
 
117
        default:
 
 
118
            SetBriefingTextToBlank();
 
 
119
        return;
 
 
120
        case I_Marine:
 
 
121
            temp_ptr = marine_briefing_text;
 
 
122
        break;
 
 
123
        case I_Predator:
 
 
124
            temp_ptr = predator_briefing_text;
 
 
125
        break;
 
 
126
        case I_Alien:
 
 
127
            temp_ptr = alien_briefing_text;
 
 
128
    }
 
 
129
 
 
 
130
    for(; i < 5; i++)
 
 
131
        BriefingTextString[i] =  temp_ptr[episode * 5 + i];
 
 
132
}
 
 
133
 
 
 
134
static int NumberOfAvailableLevels()
 
 
135
{
 
 
136
    int i;
 
 
137
    int maximumLevel;
 
 
138
    int numberOfBasicLevels;
 
 
139
    enum gamedifficulty maxDifficulty = I_Hard;
 
 
140
 
 
 
141
    episode_to_play = EpisodeSelectScrollOffset = 0;
 
 
142
 
 
 
143
    switch(AvP.PlayerType)
 
 
144
    {
 
 
145
        case I_Marine:
 
 
146
            maximumLevel = MAX_NO_OF_MARINE_EPISODES-1;
 
 
147
            numberOfBasicLevels = MAX_NO_OF_BASIC_MARINE_EPISODES;
 
 
148
        break;
 
 
149
        case I_Predator:
 
 
150
            maximumLevel = MAX_NO_OF_PREDATOR_EPISODES-1;
 
 
151
            numberOfBasicLevels = MAX_NO_OF_BASIC_PREDATOR_EPISODES;
 
 
152
        break;
 
 
153
        case I_Alien:
 
 
154
            maximumLevel = MAX_NO_OF_ALIEN_EPISODES-1;
 
 
155
            numberOfBasicLevels = MAX_NO_OF_BASIC_ALIEN_EPISODES;
 
 
156
    }
 
 
157
 
 
 
158
    for (i=0; i < numberOfBasicLevels; i++)
 
 
159
    {
 
 
160
        if (Not_Completed == UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i])
 
 
161
            return (MaximumSelectableLevel = i);
 
 
162
        else if (UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i] < maxDifficulty)
 
 
163
            maxDifficulty = UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i];
 
 
164
    }
 
 
165
 
 
 
166
    MaximumSelectableLevel = maximumLevel;
 
 
167
 
 
 
168
    switch(maxDifficulty)
 
 
169
    {
 
 
170
        default:
 
 
171
        case I_Easy:
 
 
172
            MaximumSelectableLevel -= 3;
 
 
173
        break;
 
 
174
        case I_Medium:
 
 
175
            MaximumSelectableLevel -= 1;
 
 
176
        case I_Hard:
 
 
177
        break;
 
 
178
    }
 
 
179
 
 
 
180
return maximumLevel;
 
 
181
}
 
 
182
 
 
 
183
static int LevelMostLikelyToPlay(int number_of_episodes)
 
 
184
{
 
 
185
    int i;
 
 
186
 
 
 
187
    for(i=0; i < number_of_episodes; i++)
 
 
188
    {
 
 
189
        if(I_Hard == UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i])
 
 
190
            continue;
 
 
191
        else
 
 
192
            break;
 
 
193
    }
 
 
194
 
 
 
195
    if(number_of_episodes == i)
 
 
196
        return 0; // All done
 
 
197
 
 
 
198
    if(!i)
 
 
199
    {
 
 
200
        for(; i < number_of_episodes; i++)
 
 
201
        {
 
 
202
            if(I_Medium == UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i])
 
 
203
                continue;
 
 
204
            else if(I_Hard == UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i]) // bonus levels is set to I_Hard by default
 
 
205
                continue;
 
 
206
            else
 
 
207
                break;
 
 
208
        }
 
 
209
 
 
 
210
        if(number_of_episodes == i)
 
 
211
            return 0; // begin with new difficulty?
 
 
212
    }
 
 
213
 
 
 
214
    if(!i)
 
 
215
    {
 
 
216
        for(; i < number_of_episodes; i++)
 
 
217
        {
 
 
218
            if((I_Easy == UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i])
 
 
219
            ||
 
 
220
            (I_Hard == UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i])) // bonus levels is set to I_Hard by default
 
 
221
                continue;
 
 
222
            else
 
 
223
                break;
 
 
224
        }
 
 
225
 
 
 
226
        if(number_of_episodes == i)
 
 
227
            return 0; // begin with new difficulty?
 
 
228
    }
 
 
229
 
 
 
230
return i;
 
 
231
}
 
 
232
 
 
 
233
static void SetupNewMenu(enum MENU_ID menuID)
 
 
234
{
 
 
235
    Menus.CurrentMenu = menuID;
 
 
236
 
 
 
237
    /* set pointer to the start of the menu's element data */
 
 
238
    Menus.MenuElements = MenusData[menuID].MenuElements; // could use default
 
 
239
 
 
 
240
    Menus.FontToUse = MenusData[menuID].FontToUse;
 
 
241
    Menus.CurrentlySelectedElement = 0;
 
 
242
    Menus.UserEnteringText = 0;
 
 
243
    Menus.UserChangingKeyConfig = 0;
 
 
244
    Menus.PositionInTextField = 0;
 
 
245
    Menus.WidthLeftForText = 0;
 
 
246
 
 
 
247
    switch(menuID)
 
 
248
    {
 
 
249
        case MENU_MAIN:
 
 
250
        {
 
 
251
            AvP.PlayMode = SinglePlayer;
 
 
252
            static int do_once = 0;
 
 
253
 
 
 
254
            if (!do_once && AnyCheatModesAllowed())
 
 
255
            {
 
 
256
                do_once = 1;
 
 
257
                MenusData->MenuElements[5] = MenusData->MenuElements[6];
 
 
258
                MenusData->MenuElements[5].ElementID = MENU_ELEMENT_GOTOMENU;
 
 
259
                MenusData->MenuElements[6].ElementID = MENU_ELEMENT_QUITGAME;
 
 
260
            }
 
 
261
        }
 
 
262
        break;
 
 
263
        case MENU_SKIRMISH:
 
 
264
            netGameData.gameType = NGT_Coop; //force 'cooperative' game if using skirmish mode
 
 
265
        // no break;
 
 
266
        case MENU_MULTIPLAYER_HOSTSETUP:
 
 
267
        {
 
 
268
            MENU_ELEMENT *elementPtr;
 
 
269
 
 
 
270
            AvP.PlayMode = (MENU_SKIRMISH == menuID) ? Skirmish : NetworkHost;
 
 
271
 
 
 
272
            if(NGT_Coop == netGameData.gameType)
 
 
273
            {
 
 
274
                extern const char** CoopLevelNames;
 
 
275
                extern int NumCoopLevels;
 
 
276
 
 
 
277
                elementPtr = MenusData[MENU_SKIRMISH].MenuElements;
 
 
278
                elementPtr += 2;
 
 
279
                elementPtr->b.MaxSliderValue = NumCoopLevels - 1;
 
 
280
                elementPtr->d.TextSliderStringPointer = CoopLevelNames;
 
 
281
 
 
 
282
                elementPtr = MenusData[MENU_MULTIPLAYER_HOSTSETUP].MenuElements;
 
 
283
                elementPtr += 2;
 
 
284
                elementPtr->b.MaxSliderValue = NumCoopLevels - 1;
 
 
285
                elementPtr->d.TextSliderStringPointer = CoopLevelNames;
 
 
286
            }
 
 
287
            else
 
 
288
            {
 
 
289
                extern const char** MultiplayerLevelNames;
 
 
290
                extern int NumMultiplayerLevels;
 
 
291
 
 
 
292
                elementPtr = MenusData[MENU_MULTIPLAYER_HOSTSETUP].MenuElements;
 
 
293
                elementPtr += 2;
 
 
294
                elementPtr->b.MaxSliderValue = NumMultiplayerLevels - 1;
 
 
295
                elementPtr->d.TextSliderStringPointer = MultiplayerLevelNames;
 
 
296
            }
 
 
297
 
 
 
298
            LoadMultiplayerConfiguration("previous_game");
 
 
299
        }
 
 
300
        break;
 
 
301
        /*
 
 
302
        case MENU_MULTIPLAYER_SAVECONFIG:
 
 
303
            Menus.UserEnteringText = 1;
 
 
304
            Menus.WidthLeftForText = 0; //will be calculated properly when menus are drawn
 
 
305
        break;
 
 
306
        */
 
 
307
        case MENU_SELECT_EPISODE:
 
 
308
        {
 
 
309
            switch(AvP.PlayerType)
 
 
310
            {
 
 
311
                default:
 
 
312
                case I_Alien:
 
 
313
                    Menus.MenuElements->b.MaxSliderValue = NumberOfAvailableLevels();
 
 
314
                    *Menus.MenuElements->c.SliderValuePtr = LevelMostLikelyToPlay(MAX_NO_OF_ALIEN_EPISODES);
 
 
315
                break;
 
 
316
                case I_Marine:
 
 
317
                    Menus.MenuElements->b.MaxSliderValue = NumberOfAvailableLevels();
 
 
318
                    *Menus.MenuElements->c.SliderValuePtr = LevelMostLikelyToPlay(MAX_NO_OF_MARINE_EPISODES);
 
 
319
                break;
 
 
320
                case I_Predator:
 
 
321
                    Menus.MenuElements->b.MaxSliderValue = NumberOfAvailableLevels();
 
 
322
                    *Menus.MenuElements->c.SliderValuePtr = LevelMostLikelyToPlay(MAX_NO_OF_PREDATOR_EPISODES);
 
 
323
            }
 
 
324
        }
 
 
325
        break;
 
 
326
        case MENU_ALIENKEYCONFIG:
 
 
327
        {
 
 
328
            MakeAlienKeyConfigMenu();
 
 
329
            PlayerInputPrimaryConfig = UserProfile.AlienInputPrimaryConfig;
 
 
330
            PlayerInputSecondaryConfig = UserProfile.AlienInputSecondaryConfig;
 
 
331
            EpisodeSelectScrollOffset = 0;
 
 
332
            KeyConfigSelectionColumn = 0;
 
 
333
        }
 
 
334
        break;
 
 
335
        case MENU_MARINEKEYCONFIG:
 
 
336
        {
 
 
337
            MakeMarineKeyConfigMenu();
 
 
338
            PlayerInputPrimaryConfig = UserProfile.MarineInputPrimaryConfig;
 
 
339
            PlayerInputSecondaryConfig = UserProfile.MarineInputSecondaryConfig;
 
 
340
            EpisodeSelectScrollOffset = 0;
 
 
341
            KeyConfigSelectionColumn = 0;
 
 
342
        }
 
 
343
        break;
 
 
344
        case MENU_PREDATORKEYCONFIG:
 
 
345
        {
 
 
346
            MakePredatorKeyConfigMenu();
 
 
347
            PlayerInputPrimaryConfig = UserProfile.PredatorInputPrimaryConfig;
 
 
348
            PlayerInputSecondaryConfig = UserProfile.PredatorInputSecondaryConfig;
 
 
349
            EpisodeSelectScrollOffset = 0;
 
 
350
            KeyConfigSelectionColumn = 0;
 
 
351
        }
 
 
352
        break;
 
 
353
        case MENU_MOUSEOPTIONS:
 
 
354
            PlayerControlMethods = UserProfile.ControlMethods;
 
 
355
        break;
 
 
356
        case MENU_SAVEGAME:
 
 
357
        case MENU_LOADGAME:
 
 
358
            ScanSaveSlots();
 
 
359
        break;
 
 
360
        case MENU_SINGLEPLAYER:
 
 
361
            AvP.PlayMode = SinglePlayer;
 
 
362
        default:
 
 
363
        break;
 
 
364
    }
 
 
365
 
 
 
366
    /* count the number of elements in the menu */
 
 
367
    {
 
 
368
        MENU_ELEMENT *elementPtr = Menus.MenuElements;
 
 
369
        Menus.NumberOfElementsInMenu = 0;
 
 
370
        Menus.MenuHeight = 0;
 
 
371
 
 
 
372
        do
 
 
373
        {
 
 
374
            elementPtr->Brightness = BRIGHTNESS_OF_DARKENED_ELEMENT;
 
 
375
 
 
 
376
            Menus.MenuHeight += HeightOfMenuElement(elementPtr);
 
 
377
            Menus.NumberOfElementsInMenu++;
 
 
378
            elementPtr++;
 
 
379
 
 
 
380
        } while(elementPtr->ElementID != MENU_ELEMENT_ENDOFMENU);
 
 
381
    }       
 
 
382
 
 
 
383
    switch(menuID)
 
 
384
    {
 
 
385
        case MENU_BONUSOPTIONS:
 
 
386
            //UserProfile.active_bonus = 0;
 
 
387
        break;
 
 
388
        case MENU_MARINEKEYCONFIG:
 
 
389
        case MENU_ALIENKEYCONFIG:
 
 
390
        case MENU_PREDATORKEYCONFIG:
 
 
391
            Menus.MenuHeight += 50;
 
 
392
        break;
 
 
393
        case MENU_LEVELBRIEFING_BASIC:
 
 
394
        {
 
 
395
            /* find available difficulty levels */
 
 
396
            if(!episode_to_play)
 
 
397
            {
 
 
398
                Menus.NumberOfElementsInMenu = 3;
 
 
399
                // highlight a suitable level of difficulty
 
 
400
                // default to medium difficulty for first level
 
 
401
                Menus.CurrentlySelectedElement = 1;
 
 
402
            }
 
 
403
            else
 
 
404
            {
 
 
405
                switch(UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[episode_to_play-1])
 
 
406
                {
 
 
407
                    default:
 
 
408
                    case I_Easy:
 
 
409
                        Menus.NumberOfElementsInMenu = 1;
 
 
410
                        Menus.CurrentlySelectedElement = 0;
 
 
411
                    break;
 
 
412
                    case I_Medium:
 
 
413
                        Menus.NumberOfElementsInMenu = 2;
 
 
414
                        Menus.CurrentlySelectedElement = 1;
 
 
415
                    break;
 
 
416
                    case I_Hard:
 
 
417
                        Menus.NumberOfElementsInMenu = 3;
 
 
418
                        Menus.CurrentlySelectedElement = 2;
 
 
419
                }
 
 
420
            }
 
 
421
        }
 
 
422
        case MENU_LEVELBRIEFING_BONUS:
 
 
423
            SetBriefingTextForEpisode(episode_to_play);
 
 
424
        break;
 
 
425
        default:
 
 
426
            SetBriefingTextToBlank();
 
 
427
    }
 
 
428
}
 
 
429
 
 
 
430
static void RenderBriefingText(int centreY, int brightness)
 
 
431
{
 
 
432
    int lengthOfLongestLine = -1;
 
 
433
    int x,y,i;
 
 
434
 
 
 
435
    for(i=0; i < 5; i++)
 
 
436
    {
 
 
437
        int length = 0;
 
 
438
 
 
 
439
        const char *ptr = BriefingTextString[i];
 
 
440
 
 
 
441
        if (ptr)
 
 
442
        while(*ptr)
 
 
443
            length += AAFontWidths[(uint8_t)(*ptr++)];
 
 
444
 
 
 
445
        if (lengthOfLongestLine < length)
 
 
446
            lengthOfLongestLine = length;
 
 
447
    }
 
 
448
 
 
 
449
    x = (ScreenDescriptorBlock.SDB_Width - lengthOfLongestLine)/2;
 
 
450
    y = centreY - 3*HUD_FONT_HEIGHT;
 
 
451
 
 
 
452
    for(i=0; i < 5; i++)
 
 
453
    {
 
 
454
        RenderSmallMenuText(BriefingTextString[i], x, y, brightness, MENUFORMAT_LEFTJUSTIFIED/*,MENU_CENTREY-60-100,MENU_CENTREY-60+180*/);
 
 
455
 
 
 
456
        y += i ? HUD_FONT_HEIGHT : HUD_FONT_HEIGHT*2; 
 
 
457
    }
 
 
458
}
 
 
459
 
 
 
460
static void RenderBriefingScreenInfo()
 
 
461
{
 
 
462
    const char * episode_ptr;
 
 
463
 
 
 
464
    switch (AvP.PlayerType)
 
 
465
    {
 
 
466
        case I_Marine:
 
 
467
            episode_ptr =  marine_episodes[episode_to_play];
 
 
468
        break;
 
 
469
        case I_Predator:
 
 
470
            episode_ptr =  predator_episodes[episode_to_play];
 
 
471
        break;
 
 
472
        case I_Alien:
 
 
473
            episode_ptr =  alien_episodes[episode_to_play];
 
 
474
        break;
 
 
475
        default:
 
 
476
            episode_ptr = "";
 
 
477
    }
 
 
478
 
 
 
479
    RenderSmallMenuText(episode_ptr, MENU_LEFTXEDGE, 120, ONE_FIXED, MENUFORMAT_LEFTJUSTIFIED);
 
 
480
 
 
 
481
    RenderBriefingText(ScreenDescriptorBlock.SDB_CentreY, ONE_FIXED);
 
 
482
}
 
 
483
 
 
 
484
int LengthOfSmallMenuText(const char *textPtr)
 
 
485
{
 
 
486
    int width = 0;
 
 
487
 
 
 
488
    while (textPtr && *textPtr) 
 
 
489
    {
 
 
490
        width += AAFontWidths[(unsigned int) *textPtr];
 
 
491
 
 
 
492
        textPtr++;
 
 
493
    }
 
 
494
 
 
 
495
return width;
 
 
496
}
 
 
497
 
 
 
498
static int IsFlamerInLevel(int level)
 
 
499
{
 
 
500
    return (level != AVP_ENVIRONMENT_SUBWAY_MP && level != AVP_ENVIRONMENT_SUBWAY_COOP);
 
 
501
}
 
 
502
 
 
 
503
static int IsMinigunInLevel(int level)
 
 
504
{
 
 
505
    return (level != AVP_ENVIRONMENT_SEWER);
 
 
506
}
 
 
507
 
 
 
508
static int IsSadarInLevel(int level)
 
 
509
{
 
 
510
    switch(level)
 
 
511
    {
 
 
512
    case AVP_ENVIRONMENT_MASSACRE:
 
 
513
    case AVP_ENVIRONMENT_MEATFACTORY_MP:
 
 
514
    case AVP_ENVIRONMENT_MEATFACTORY_COOP:
 
 
515
    case AVP_ENVIRONMENT_HADLEYSHOPE_MP:
 
 
516
    case AVP_ENVIRONMENT_HADLEYSHOPE_COOP:
 
 
517
    case AVP_ENVIRONMENT_HIVE:
 
 
518
    case AVP_ENVIRONMENT_HIVE_COOP:
 
 
519
    case AVP_ENVIRONMENT_KENS_COOP:
 
 
520
    case AVP_ENVIRONMENT_LEADWORKS_MP:
 
 
521
    case AVP_ENVIRONMENT_LEADWORKS_COOP:
 
 
522
        return 0;
 
 
523
    default:
 
 
524
        return 1;
 
 
525
    }
 
 
526
}
 
 
527
 
 
 
528
static int IsSkeeterInLevel(int level)
 
 
529
{
 
 
530
    return (level != AVP_ENVIRONMENT_LEADWORKS_MP && level != AVP_ENVIRONMENT_LEADWORKS_COOP);
 
 
531
}
 
 
532
 
 
 
533
static int IsSmartgunInLevel(int level)
 
 
534
{
 
 
535
    return (level != AVP_ENVIRONMENT_NOSTROMO_MP);
 
 
536
}
 
 
537
 
 
 
538
static char MultiplayerBriefing[3][100];
 
 
539
 
 
 
540
static void AddMultiplayerBriefingString(const char* text)
 
 
541
{
 
 
542
    int shortest = 0;
 
 
543
    int shortest_length =1000;
 
 
544
    int i=0;
 
 
545
 
 
 
546
    for(; i < 3; i++)
 
 
547
    {
 
 
548
        int length = strlen(MultiplayerBriefing[i]);
 
 
549
 
 
 
550
        if(length < shortest_length)
 
 
551
        {
 
 
552
            shortest = i;
 
 
553
            shortest_length = length;
 
 
554
        }
 
 
555
    }
 
 
556
 
 
 
557
    if(shortest_length + 3 + strlen(text) >= 100)
 
 
558
        return;
 
 
559
 
 
 
560
    if(shortest_length > 0)
 
 
561
        strcat(MultiplayerBriefing[shortest], " , ");
 
 
562
 
 
 
563
    strcat(MultiplayerBriefing[shortest], text);
 
 
564
}
 
 
565
 
 
 
566
static int SetBriefingTextForMultiplayer()
 
 
567
{
 
 
568
    int level = NumberForCurrentLevel();
 
 
569
    int num_not_available = 0;
 
 
570
 
 
 
571
    SetBriefingTextToBlank();
 
 
572
 
 
 
573
    if ((level >= AVP_ENVIRONMENT_END_OF_MULTIPACK_LIST))
 
 
574
        return 0;
 
 
575
 
 
 
576
/*
 
 
577
    if(netGameData.customLevelName[0] != 0)
 
 
578
    {
 
 
579
        //custom level
 
 
580
        BriefingTextString[0] = netGameData.customLevelName;
 
 
581
        return;
 
 
582
    }
 
 
583
*/
 
 
584
 
 
 
585
    MultiplayerBriefing[0][0] = '\0';
 
 
586
    MultiplayerBriefing[1][0] = '\0';
 
 
587
    MultiplayerBriefing[2][0] = '\0';
 
 
588
 
 
 
589
    if(!netGameData.allowSmartgun || !IsSmartgunInLevel(level))
 
 
590
    {
 
 
591
        AddMultiplayerBriefingString("Smartgun");
 
 
592
        num_not_available++;
 
 
593
    }
 
 
594
 
 
 
595
    if(!netGameData.allowFlamer || !IsFlamerInLevel(level))
 
 
596
    {
 
 
597
        AddMultiplayerBriefingString("Flamethrower");
 
 
598
        num_not_available++;
 
 
599
    }
 
 
600
 
 
 
601
    if(!netGameData.allowSadar || !IsSadarInLevel(level))
 
 
602
    {
 
 
603
        AddMultiplayerBriefingString("SADAR");
 
 
604
        num_not_available++;
 
 
605
    }
 
 
606
 
 
 
607
    if(!netGameData.allowGrenadeLauncher)
 
 
608
    {
 
 
609
        AddMultiplayerBriefingString("Grenade Launcher");
 
 
610
        num_not_available++;
 
 
611
    }
 
 
612
 
 
 
613
    if(!netGameData.allowMinigun || !IsMinigunInLevel(level))
 
 
614
    {
 
 
615
        AddMultiplayerBriefingString("Minigun");
 
 
616
        num_not_available++;
 
 
617
    }
 
 
618
 
 
 
619
    if(!netGameData.allowSmartDisc || !IsSkeeterInLevel(level))
 
 
620
    {
 
 
621
        AddMultiplayerBriefingString("Skeeter Launcher");
 
 
622
        num_not_available++;
 
 
623
    }
 
 
624
 
 
 
625
    if(!netGameData.allowPistols)
 
 
626
    {
 
 
627
        AddMultiplayerBriefingString("Pistol");
 
 
628
        num_not_available++;
 
 
629
    }
 
 
630
 
 
 
631
    if(!netGameData.allowDisc)
 
 
632
    {
 
 
633
        AddMultiplayerBriefingString("Disc");
 
 
634
        num_not_available++;
 
 
635
    }
 
 
636
 
 
 
637
    if(!netGameData.allowPistol)
 
 
638
    {
 
 
639
        AddMultiplayerBriefingString("Predator Pistol");
 
 
640
        num_not_available++;
 
 
641
    }
 
 
642
 
 
 
643
    if(!netGameData.allowPlasmaCaster)
 
 
644
    {
 
 
645
        AddMultiplayerBriefingString("Shoulder Cannon");
 
 
646
        num_not_available++;
 
 
647
    }
 
 
648
 
 
 
649
    if(!netGameData.allowSpeargun)
 
 
650
    {
 
 
651
        AddMultiplayerBriefingString("Speargun");
 
 
652
        num_not_available++;
 
 
653
    }
 
 
654
 
 
 
655
    if(!netGameData.allowMedicomp)
 
 
656
    {
 
 
657
        AddMultiplayerBriefingString("Medicomp");
 
 
658
        num_not_available++;
 
 
659
    }
 
 
660
 
 
 
661
    if (NGT_Coop == netGameData.gameType)
 
 
662
        BriefingTextString[0] = coop_levels[netGameData.levelNumber];
 
 
663
    else
 
 
664
        BriefingTextString[0] = multiplayer_levels[netGameData.levelNumber];
 
 
665
 
 
 
666
    if(num_not_available)
 
 
667
    {
 
 
668
        BriefingTextString[1] = "Unavailable weapons:";
 
 
669
        BriefingTextString[2] = MultiplayerBriefing[0];
 
 
670
        BriefingTextString[3] = MultiplayerBriefing[1];
 
 
671
        BriefingTextString[4] = MultiplayerBriefing[2];
 
 
672
    }
 
 
673
 
 
 
674
return num_not_available;
 
 
675
}
 
 
676
 
 
 
677
static void RenderBriefingText2(int centreY, int brightness)
 
 
678
{
 
 
679
    int i;
 
 
680
    int x = ScreenDescriptorBlock.SDB_CentreX;
 
 
681
    int y = centreY - 4 * HUD_FONT_HEIGHT;
 
 
682
 
 
 
683
    for(i=1; i < 5; i++)
 
 
684
    {
 
 
685
        RenderSmallMenuText(BriefingTextString[i], x, y, brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
686
        y += HUD_FONT_HEIGHT;
 
 
687
    }
 
 
688
}
 
 
689
 
 
 
690
static void RenderMenuElement(MENU_ELEMENT *elementPtr, int e, int y)
 
 
691
{
 
 
692
    switch(elementPtr->ElementID)
 
 
693
    {
 
 
694
        case MENU_ELEMENT_STARTSKIRMISH:
 
 
695
        {
 
 
696
            RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
697
 
 
 
698
            if(SetBriefingTextForMultiplayer())
 
 
699
                RenderBriefingText2(y, ONE_FIXED);
 
 
700
        }
 
 
701
        break;
 
 
702
        case MENU_ELEMENT_STARTMPGAME: //fall thru
 
 
703
        case MENU_ELEMENT_JOINMPGAME: // fall thru
 
 
704
        {
 
 
705
            //RenderBriefingText(ScreenDescriptorBlock.SDB_CentreY, ONE_FIXED);
 
 
706
            if(SetBriefingTextForMultiplayer())
 
 
707
                RenderBriefingText2(y, ONE_FIXED);
 
 
708
 
 
 
709
        } // no break for you
 
 
710
        case MENU_ELEMENT_GOTOMENU:
 
 
711
        case MENU_ELEMENT_RESUMEGAME:
 
 
712
        case MENU_ELEMENT_RESTARTGAME:
 
 
713
        case MENU_ELEMENT_DIFFICULTYLEVEL:
 
 
714
        case MENU_ELEMENT_KEYCONFIGOK:
 
 
715
        case MENU_ELEMENT_RESETKEYCONFIG:
 
 
716
        case MENU_ELEMENT_SAVEMPCONFIG:
 
 
717
        case MENU_ELEMENT_RESETMPCONFIG:
 
 
718
        case MENU_ELEMENT_DELETEMPCONFIG:
 
 
719
        case MENU_ELEMENT_QUITGAME:
 
 
720
        case MENU_ELEMENT_STARTLEVELWITHCHEAT:
 
 
721
        case MENU_ELEMENT_SELECT_SPECIES:
 
 
722
            RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
723
        break;
 
 
724
        case MENU_ELEMENT_LEVELNAME:
 
 
725
        {
 
 
726
            extern char LevelName[];
 
 
727
            RenderSmallMenuText("Environment", ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
728
 
 
 
729
            if(elementPtr->d.TextSliderStringPointer)
 
 
730
            {
 
 
731
                int index = *elementPtr->c.SliderValuePtr;
 
 
732
                const char *level_name = elementPtr->d.TextSliderStringPointer[index];
 
 
733
                strncpy(LevelName, level_name, 39);
 
 
734
 
 
 
735
                if(index >= ((NGT_Coop == netGameData.gameType) ? MAX_NO_OF_COOPERATIVE_EPISODES : MAX_NO_OF_MULTIPLAYER_EPISODES))
 
 
736
                {
 
 
737
                    char *p = strstr(LevelName, "(c)");
 
 
738
 
 
 
739
                    if(NULL != p)
 
 
740
                    {
 
 
741
                        *p = '\0';
 
 
742
                    }
 
 
743
                    else
 
 
744
                    {
 
 
745
                        p = strstr(LevelName, ".rif");
 
 
746
 
 
 
747
                        if(NULL != p)
 
 
748
                            *p = '\0';
 
 
749
                    }
 
 
750
                    strcat(LevelName, " (custom)");
 
 
751
                    RenderSmallMenuText(LevelName, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_LEFTJUSTIFIED);
 
 
752
                    snprintf(LevelName, 40, "custom/%s", elementPtr->d.TextSliderStringPointer[index]);
 
 
753
                    break;
 
 
754
                }
 
 
755
            }
 
 
756
            else
 
 
757
            {
 
 
758
                strcpy(LevelName, "FIX THIS");
 
 
759
            }
 
 
760
 
 
 
761
            RenderSmallMenuText(LevelName, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
762
        }
 
 
763
        break;
 
 
764
        case MENU_ELEMENT_LOADSOUNDS:
 
 
765
        case MENU_ELEMENT_TOGGLE_MOUSE_GRAB:
 
 
766
        case MENU_ELEMENT_TOGGLE_FULLSCREEN:
 
 
767
            RenderSmallMenuText(*elementPtr->c.NumberPtr ? "On" : "Off", ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y,
elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
768
            RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
769
        break;
 
 
770
        case MENU_ELEMENT_TEXTSLIDER:
 
 
771
        {
 
 
772
            const char *textPtr = elementPtr->d.TextSliderStringPointer[*elementPtr->c.SliderValuePtr];
 
 
773
 
 
 
774
            int length = LengthOfSmallMenuText(textPtr);
 
 
775
 
 
 
776
            if (length > (ScreenDescriptorBlock.SDB_Width - ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING*2))
 
 
777
            {
 
 
778
    RenderSmallMenuText(textPtr, ScreenDescriptorBlock.SDB_Width-MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED);
 
 
779
    RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_Width-MENU_ELEMENT_SPACING*2-length, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
780
            }
 
 
781
            else
 
 
782
            {
 
 
783
                RenderSmallMenuText(textPtr, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
784
                RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
785
            }
 
 
786
        }
 
 
787
        break;
 
 
788
        case MENU_ELEMENT_SPECIES_TEXTSLIDER:
 
 
789
        {
 
 
790
            RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
791
            const char * textPtr = elementPtr->d.TextSliderStringPointer[*elementPtr->c.SliderValuePtr];
 
 
792
            RenderSmallMenuText(textPtr, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
793
        }
 
 
794
        break;
 
 
795
        case MENU_ELEMENT_CHEATMODE_TEXTSLIDER:
 
 
796
            RenderSmallMenuText("Cheat Mode", ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
797
            RenderSmallMenuText(cheat_modes[*elementPtr->c.SliderValuePtr], ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y,
elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
798
        break;
 
 
799
        case MENU_ELEMENT_CHEATMODE_SPECIES_TEXTSLIDER:
 
 
800
        {
 
 
801
            const char *textPtr = elementPtr->d.TextSliderStringPointer[*elementPtr->c.SliderValuePtr];
 
 
802
            RenderSmallMenuText (elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
803
            RenderSmallMenuText (textPtr, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
804
        }
 
 
805
        break;
 
 
806
        case MENU_ELEMENT_CHEATMODE_ENVIRONMENT_TEXTSLIDER:
 
 
807
        {
 
 
808
            const char *textPtr;
 
 
809
 
 
 
810
            if (*elementPtr->c.SliderValuePtr < MAX_NO_OF_MARINE_EPISODES)
 
 
811
            {
 
 
812
                textPtr =  marine_episodes[*elementPtr->c.SliderValuePtr];
 
 
813
            }
 
 
814
            else if ( *elementPtr->c.SliderValuePtr < MAX_NO_OF_PREDATOR_EPISODES + MAX_NO_OF_MARINE_EPISODES)
 
 
815
            {
 
 
816
                textPtr =  predator_episodes[*elementPtr->c.SliderValuePtr - MAX_NO_OF_MARINE_EPISODES];
 
 
817
            }
 
 
818
            else
 
 
819
            {
 
 
820
                textPtr =  alien_episodes[*elementPtr->c.SliderValuePtr - MAX_NO_OF_MARINE_EPISODES - MAX_NO_OF_PREDATOR_EPISODES];
 
 
821
            }
 
 
822
 
 
 
823
            RenderSmallMenuText ("Environment", ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
824
            RenderSmallMenuText (textPtr, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
825
        }
 
 
826
        break;
 
 
827
        case MENU_ELEMENT_TEXTFIELD:
 
 
828
        {
 
 
829
            if (NULL == elementPtr->menu_name)
 
 
830
            {
 
 
831
                if (Menus.UserEnteringText && (e == Menus.CurrentlySelectedElement))
 
 
832
                {
 
 
833
                    int b = GetSin(CloakingPhase & 4095);
 
 
834
                    int x = RenderSmallMenuText(elementPtr->c.TextPtr, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness/2,
MENUFORMAT_CENTREJUSTIFIED);
 
 
835
                    x = RenderSmallMenuText("I", x, y, MUL_FIXED(b, b), MENUFORMAT_CENTREJUSTIFIED);
 
 
836
 
 
 
837
                    //work out how much space was left over
 
 
838
                    if(Menus.PositionInTextField)
 
 
839
                        Menus.WidthLeftForText = MENU_RIGHTXEDGE -x;
 
 
840
                    else
 
 
841
                        Menus.WidthLeftForText = MENU_RIGHTXEDGE - ScreenDescriptorBlock.SDB_CentreX;
 
 
842
                }
 
 
843
                else
 
 
844
                {
 
 
845
                    RenderSmallMenuText(elementPtr->c.TextPtr, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
846
                }
 
 
847
            }
 
 
848
            else
 
 
849
            {
 
 
850
                RenderSmallMenuText(elementPtr->menu_name , ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
851
 
 
 
852
                if (Menus.UserEnteringText && e == Menus.CurrentlySelectedElement)
 
 
853
                {
 
 
854
                    int b = GetSin(CloakingPhase & 4095);
 
 
855
                    int x =
RenderSmallMenuText(elementPtr->c.TextPtr,ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING,y,elementPtr->Brightness/2,MENUFORMAT_LEFTJUSTIFIED);
 
 
856
                    x = RenderSmallMenuText("I", x + LengthOfSmallMenuText(elementPtr->c.TextPtr), y, MUL_FIXED(b, b), MENUFORMAT_LEFTJUSTIFIED);
 
 
857
 
 
 
858
                    //work out how much space was left over
 
 
859
                    if(Menus.PositionInTextField)
 
 
860
                        Menus.WidthLeftForText = MENU_RIGHTXEDGE -x;
 
 
861
                    else
 
 
862
                        Menus.WidthLeftForText = MENU_RIGHTXEDGE -(ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING);
 
 
863
                }
 
 
864
                else
 
 
865
                {
 
 
866
                    RenderSmallMenuText(elementPtr->c.TextPtr, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_LEFTJUSTIFIED);
 
 
867
                }
 
 
868
            }
 
 
869
        }
 
 
870
        break;
 
 
871
        case MENU_ELEMENT_TEXTFIELD_SMALLWRAPPED:
 
 
872
        {
 
 
873
            if (!elementPtr->menu_name)
 
 
874
            {
 
 
875
                int left = MENU_LEFTXEDGE;
 
 
876
                int right = MENU_RIGHTXEDGE;
 
 
877
                int bottom = y + 4 * HUD_FONT_HEIGHT;
 
 
878
 
 
 
879
                if (Menus.UserEnteringText && e == Menus.CurrentlySelectedElement)
 
 
880
                {
 
 
881
                    int output_x,output_y;
 
 
882
                    int b = GetSin(CloakingPhase & 4095);
 
 
883
                    output_x = RenderSmallMenuText("I", output_x, output_y, MUL_FIXED(b,b), MENUFORMAT_LEFTJUSTIFIED);
 
 
884
 
 
 
885
                    //work out how much space was left over
 
 
886
                    if(bottom - output_y < HUD_FONT_HEIGHT)
 
 
887
                    {
 
 
888
                        //no space left
 
 
889
                        Menus.WidthLeftForText= 0;
 
 
890
                    }
 
 
891
                    else if(bottom - output_y >= 2 * HUD_FONT_HEIGHT)
 
 
892
                    {
 
 
893
                        //at least a whole line left
 
 
894
                        Menus.WidthLeftForText = right - left;
 
 
895
                    }
 
 
896
                    else
 
 
897
                    {
 
 
898
                        //on the last line
 
 
899
                        Menus.WidthLeftForText = right - output_x;
 
 
900
                    }
 
 
901
                }
 
 
902
            }
 
 
903
            else
 
 
904
            {
 
 
905
                int left = ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING;
 
 
906
                int right = MENU_RIGHTXEDGE;
 
 
907
                int bottom = y + 4 * HUD_FONT_HEIGHT;
 
 
908
 
 
 
909
RenderSmallMenuText(elementPtr->menu_name,
ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING,y+HUD_FONT_HEIGHT,elementPtr->Brightness,MENUFORMAT_RIGHTJUSTIFIED);
 
 
910
 
 
 
911
                if (Menus.UserEnteringText && e == Menus.CurrentlySelectedElement)
 
 
912
                {
 
 
913
                    int output_x,output_y;
 
 
914
                    int b = GetSin(CloakingPhase&4095);
 
 
915
                    output_x = RenderSmallMenuText("I",output_x,output_y,MUL_FIXED(b,b),MENUFORMAT_LEFTJUSTIFIED);
 
 
916
 
 
 
917
                    //work out how much space was left over
 
 
918
                    if(bottom - output_y < HUD_FONT_HEIGHT)
 
 
919
                    {
 
 
920
                        //no space left
 
 
921
                        Menus.WidthLeftForText = 0;
 
 
922
                    }
 
 
923
                    else if(bottom - output_y >= 2*HUD_FONT_HEIGHT)
 
 
924
                    {
 
 
925
                        //at least a whole line left
 
 
926
                        Menus.WidthLeftForText = right - left;
 
 
927
                    }
 
 
928
                    else
 
 
929
                    {
 
 
930
                        //on the last line
 
 
931
                        Menus.WidthLeftForText = right - output_x;
 
 
932
                    }
 
 
933
                }
 
 
934
            }
 
 
935
        }
 
 
936
        break;
 
 
937
        case MENU_ELEMENT_NUMBERFIELD:
 
 
938
        {
 
 
939
            RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
940
 
 
 
941
            if(*elementPtr->c.NumberPtr != 0 || elementPtr->print_zero == 0)
 
 
942
            {
 
 
943
                char NumberString[50]={'\0'};
 
 
944
 
 
 
945
                sprintf(NumberString, "%d ", *elementPtr->c.NumberPtr);
 
 
946
 
 
 
947
                if (elementPtr->d.TextSliderStringPointer != 0)
 
 
948
                    strncat(NumberString, elementPtr->d.TextSliderStringPointer, 50 - strlen(NumberString));
 
 
949
 
 
 
950
                RenderSmallMenuText(NumberString, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_LEFTJUSTIFIED);
 
 
951
            }
 
 
952
            else
 
 
953
            {
 
 
954
                RenderSmallMenuText(elementPtr->print_zero, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_LEFTJUSTIFIED);
 
 
955
            }
 
 
956
        }
 
 
957
        break;
 
 
958
        case MENU_ELEMENT_LOADMPCONFIG:
 
 
959
        case MENU_ELEMENT_LOADIPADDRESS:
 
 
960
            RenderSmallMenuText(elementPtr->c.TextPtr, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
961
        break;
 
 
962
        case MENU_ELEMENT_SLIDER:
 
 
963
        {
 
 
964
            int x = ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING+3;
 
 
965
            x += (201*(*elementPtr->c.SliderValuePtr))/elementPtr->b.MaxSliderValue;
 
 
966
 
 
 
967
            RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
968
 
 
 
969
            DrawSliderBar(ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING,y+1,elementPtr->Brightness);
 
 
970
            DrawSlider(x,y+4,elementPtr->Brightness);
 
 
971
        }
 
 
972
        break;
 
 
973
        case MENU_ELEMENT_SELECT_WINDOWSIZE:
 
 
974
        {
 
 
975
            char buf[64];
 
 
976
            snprintf(buf, 64, "%dx%d", UserProfile.screen.width , UserProfile.screen.height);
 
 
977
 
 
 
978
            int length = LengthOfSmallMenuText(buf);
 
 
979
 
 
 
980
            if (length > (ScreenDescriptorBlock.SDB_Width - ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING*2))
 
 
981
            {
 
 
982
                RenderSmallMenuText(buf, ScreenDescriptorBlock.SDB_Width-MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED);
 
 
983
                RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_Width-MENU_ELEMENT_SPACING*2-length, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
984
            }
 
 
985
            else
 
 
986
            {
 
 
987
                RenderSmallMenuText(buf, ScreenDescriptorBlock.SDB_CentreX+MENU_ELEMENT_SPACING, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
988
                RenderSmallMenuText(elementPtr->menu_name, ScreenDescriptorBlock.SDB_CentreX-MENU_ELEMENT_SPACING, y, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
989
            }
 
 
990
        }
 
 
991
        break;
 
 
992
        case MENU_ELEMENT_KEYCONFIG:
 
 
993
        {
 
 
994
            SDLKey *primaryKey = ((SDLKey *)&PlayerInputPrimaryConfig) + e - 2;
 
 
995
            SDLKey *secondaryKey = ((SDLKey *)&PlayerInputSecondaryConfig) + e - 2;
 
 
996
            const char * char_ptr_primary;
 
 
997
            const char * char_ptr_secondary;
 
 
998
 
 
 
999
            {
 
 
1000
 
 
 
1001
            char *tmp;
 
 
1002
            int i=0;
 
 
1003
            int tmp_key = *primaryKey;
 
 
1004
 
 
 
1005
                for (; i < 2; tmp_key = *secondaryKey )
 
 
1006
                {
 
 
1007
                    switch(tmp_key)
 
 
1008
                    {
 
 
1009
                    case SDLK_CLEAR:
 
 
1010
                        tmp = "";
 
 
1011
                    break;
 
 
1012
                    case SDL_BUTTON_LEFT:
 
 
1013
                        tmp = "left Mouse";
 
 
1014
                    break;
 
 
1015
                    case SDL_BUTTON_RIGHT:
 
 
1016
                        tmp = "right Mouse";
 
 
1017
                    break;
 
 
1018
                    case SDL_BUTTON_MIDDLE:
 
 
1019
                        tmp = "middle Mouse";
 
 
1020
                    break;
 
 
1021
                    case SDL_BUTTON_WHEELUP:
 
 
1022
                        tmp = "mouse wheel up";
 
 
1023
                    break;
 
 
1024
                    case SDL_BUTTON_WHEELDOWN:
 
 
1025
                        tmp = "mouse wheel down";
 
 
1026
                    break;
 
 
1027
                    default:
 
 
1028
                        tmp = SDL_GetKeyName(tmp_key);
 
 
1029
                    }
 
 
1030
 
 
 
1031
                    if (i++)    
 
 
1032
                        char_ptr_secondary = tmp;
 
 
1033
                    else
 
 
1034
                        char_ptr_primary = tmp;
 
 
1035
                }
 
 
1036
            }
 
 
1037
 
 
 
1038
            if (e == Menus.CurrentlySelectedElement)
 
 
1039
            {
 
 
1040
                int x,g;
 
 
1041
 
 
 
1042
                if (KeyConfigSelectionColumn)
 
 
1043
                    x = MENU_RIGHTXEDGE;
 
 
1044
                else
 
 
1045
                    x = ScreenDescriptorBlock.SDB_CentreX;
 
 
1046
 
 
 
1047
                if (Menus.UserChangingKeyConfig)
 
 
1048
                    g = 255;
 
 
1049
                else
 
 
1050
                    g = 128;
 
 
1051
 
 
 
1052
                    Rectangle(x-100, y-4, x+4, y+19, 0, g, 0, 255);
 
 
1053
            }
 
 
1054
 
 
 
1055
            if (Menus.UserChangingKeyConfig && e == Menus.CurrentlySelectedElement)
 
 
1056
            {
 
 
1057
                int b = GetSin(CloakingPhase & 4095);
 
 
1058
 
 
 
1059
                if (Menus.ChangingPrimaryConfig)
 
 
1060
                {
 
 
1061
                    RenderSmallMenuText("_", ScreenDescriptorBlock.SDB_CentreX, y , MUL_FIXED(b,b), MENUFORMAT_RIGHTJUSTIFIED);
 
 
1062
                    RenderSmallMenuText(char_ptr_secondary , MENU_RIGHTXEDGE, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED );
 
 
1063
                }
 
 
1064
                else
 
 
1065
                {
 
 
1066
                    RenderSmallMenuText(char_ptr_primary, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED );
 
 
1067
                    RenderSmallMenuText("_",MENU_RIGHTXEDGE,y,MUL_FIXED(b,b),MENUFORMAT_RIGHTJUSTIFIED);
 
 
1068
                }
 
 
1069
            }
 
 
1070
            else
 
 
1071
            {
 
 
1072
 
 
 
1073
                if (MultipleAssignments[0][e-2])
 
 
1074
    RenderSmallMenuText_Coloured(char_ptr_primary, ScreenDescriptorBlock.SDB_CentreX, y, ONE_FIXED, MENUFORMAT_RIGHTJUSTIFIED, ONE_FIXED, ONE_FIXED, 0 );
 
 
1075
                else
 
 
1076
    RenderSmallMenuText(char_ptr_primary, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED );
 
 
1077
 
 
 
1078
                if (MultipleAssignments[1][e-2])
 
 
1079
    RenderSmallMenuText_Coloured(char_ptr_secondary, MENU_RIGHTXEDGE, y, ONE_FIXED, MENUFORMAT_RIGHTJUSTIFIED, ONE_FIXED, ONE_FIXED, 0 );
 
 
1080
                else
 
 
1081
    RenderSmallMenuText(char_ptr_secondary, MENU_RIGHTXEDGE, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED );
 
 
1082
 
 
 
1083
            }
 
 
1084
 
 
 
1085
            RenderSmallMenuText(elementPtr->c.TextPtr, MENU_LEFTXEDGE, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED );
 
 
1086
        }
 
 
1087
        default:
 
 
1088
        break;
 
 
1089
    }
 
 
1090
}
 
 
1091
 
 
 
1092
static void RenderMenu()
 
 
1093
{
 
 
1094
    MENU_ELEMENT *elementPtr = Menus.MenuElements;
 
 
1095
    int e;
 
 
1096
    int y;
 
 
1097
 
 
 
1098
    if (Menus.MenusState == MENUSSTATE_MAINMENUS)
 
 
1099
    {
 
 
1100
        RenderSmallMenuText("Aliens Versus Predator", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
1101
 
 
 
1102
        if ((Menus.CurrentMenu == MENU_LEVELBRIEFING_BASIC) || (Menus.CurrentMenu == MENU_LEVELBRIEFING_BONUS))
 
 
1103
        {
 
 
1104
            y = ScreenDescriptorBlock.SDB_CentreY + HUD_FONT_HEIGHT*5;
 
 
1105
            RenderBriefingScreenInfo();
 
 
1106
        }
 
 
1107
        else
 
 
1108
        {
 
 
1109
            y = MENU_CENTREY - (Menus.MenuHeight)/2;
 
 
1110
        }
 
 
1111
    }
 
 
1112
    else
 
 
1113
    {
 
 
1114
        y = (ScreenDescriptorBlock.SDB_Height - Menus.MenuHeight)/2;
 
 
1115
    }
 
 
1116
 
 
 
1117
    for (e = 0; e < Menus.NumberOfElementsInMenu; e++, elementPtr++)
 
 
1118
    {
 
 
1119
        int targetBrightness;
 
 
1120
 
 
 
1121
        if (e == Menus.CurrentlySelectedElement)
 
 
1122
            targetBrightness = BRIGHTNESS_OF_HIGHLIGHTED_ELEMENT;
 
 
1123
        else
 
 
1124
            targetBrightness = BRIGHTNESS_OF_DARKENED_ELEMENT;
 
 
1125
 
 
 
1126
        if (targetBrightness > elementPtr->Brightness)
 
 
1127
        {
 
 
1128
            elementPtr->Brightness += BRIGHTNESS_CHANGE_SPEED;
 
 
1129
 
 
 
1130
            if(elementPtr->Brightness > targetBrightness)
 
 
1131
                elementPtr->Brightness = targetBrightness;
 
 
1132
        }
 
 
1133
        else
 
 
1134
        {
 
 
1135
            elementPtr->Brightness -= BRIGHTNESS_CHANGE_SPEED;
 
 
1136
 
 
 
1137
            if(elementPtr->Brightness < targetBrightness)
 
 
1138
                elementPtr->Brightness = targetBrightness;
 
 
1139
        }
 
 
1140
 
 
 
1141
        RenderMenuElement(elementPtr, e, y);
 
 
1142
        y += HeightOfMenuElement(elementPtr);
 
 
1143
    }
 
 
1144
}
 
 
1145
 
 
 
1146
static void RenderEpisodeSelectMenu(int numberOfBasicLevels, const char **textPtr)
 
 
1147
{
 
 
1148
    MENU_ELEMENT *elementPtr = &Menus.MenuElements[Menus.CurrentlySelectedElement];
 
 
1149
    int currentEpisode = *(elementPtr->c.SliderValuePtr);
 
 
1150
    int centrePosition = currentEpisode * 65536 + EpisodeSelectScrollOffset;
 
 
1151
    char *TextPtr;
 
 
1152
    int i;
 
 
1153
 
 
 
1154
    RenderSmallMenuText("Select Episode", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
1155
 
 
 
1156
    for (i=0; i <= elementPtr->b.MaxSliderValue; i++)
 
 
1157
    {
 
 
1158
        int y = MUL_FIXED(i*65536-centrePosition, 100);
 
 
1159
 
 
 
1160
        if (y >= -150 && y <= 150)
 
 
1161
        {
 
 
1162
            int targetBrightness = (i == currentEpisode) ? BRIGHTNESS_OF_HIGHLIGHTED_ELEMENT : BRIGHTNESS_OF_DARKENED_ELEMENT;
 
 
1163
 
 
 
1164
            if (targetBrightness > Brightness[i])
 
 
1165
            {
 
 
1166
                Brightness[i] += BRIGHTNESS_CHANGE_SPEED;
 
 
1167
 
 
 
1168
                if(Brightness[i] > targetBrightness)
 
 
1169
                    Brightness[i] = targetBrightness;
 
 
1170
            }
 
 
1171
            else
 
 
1172
            {
 
 
1173
                Brightness[i] -= BRIGHTNESS_CHANGE_SPEED;
 
 
1174
 
 
 
1175
                if(Brightness[i] < targetBrightness)
 
 
1176
                    Brightness[i] = targetBrightness;
 
 
1177
            }
 
 
1178
 
 
 
1179
            int b = Brightness[i];
 
 
1180
            int yCoord = MENU_CENTREY+y-60;
 
 
1181
 
 
 
1182
            RenderSmallMenuText(textPtr[i], MENU_LEFTXEDGE+150, yCoord, b, MENUFORMAT_LEFTJUSTIFIED);
 
 
1183
 
 
 
1184
            if (MaximumSelectableLevel >= i)
 
 
1185
            {
 
 
1186
                if (i < numberOfBasicLevels)
 
 
1187
                {
 
 
1188
                    switch(UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i])
 
 
1189
                    {
 
 
1190
                        case I_Easy:
 
 
1191
                            TextPtr = "Completed on Easy";
 
 
1192
                        break;    
 
 
1193
                        case I_Medium:
 
 
1194
                            TextPtr = "Completed on Medium";
 
 
1195
                        break;
 
 
1196
                        case I_Hard:
 
 
1197
                            TextPtr = "Completed on Hard";
 
 
1198
                        break;
 
 
1199
                        case Not_Completed:
 
 
1200
                        default: 
 
 
1201
                            TextPtr = "Not yet completed";
 
 
1202
                    }
 
 
1203
                }
 
 
1204
                else
 
 
1205
                {
 
 
1206
                    TextPtr = (Not_Completed == UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[i]) ? "Not yet completed" :
"Completed";
 
 
1207
                }
 
 
1208
            }
 
 
1209
            else
 
 
1210
            {
 
 
1211
                TextPtr = (i == elementPtr->b.MaxSliderValue) ? "Not yet available - to acess complete game on Hard" : "Not yet available - to
acess complete game on Medium";
 
 
1212
            }
 
 
1213
 
 
 
1214
            RenderSmallMenuText(TextPtr, MENU_LEFTXEDGE+150, yCoord+30, b, MENUFORMAT_LEFTJUSTIFIED );
 
 
1215
        }
 
 
1216
    }
 
 
1217
 
 
 
1218
    if (EpisodeSelectScrollOffset > 0)
 
 
1219
    {
 
 
1220
        EpisodeSelectScrollOffset -= MUL_FIXED(EpisodeSelectScrollOffset*2+8192, RealFrameTime<<1);
 
 
1221
 
 
 
1222
        if (EpisodeSelectScrollOffset < 0)
 
 
1223
            EpisodeSelectScrollOffset = 0;
 
 
1224
    }
 
 
1225
    else if (EpisodeSelectScrollOffset < 0)
 
 
1226
    {
 
 
1227
        EpisodeSelectScrollOffset += MUL_FIXED(-EpisodeSelectScrollOffset*2+8192, RealFrameTime<<1);
 
 
1228
 
 
 
1229
        if (EpisodeSelectScrollOffset > 0)
 
 
1230
            EpisodeSelectScrollOffset = 0;
 
 
1231
    }
 
 
1232
}
 
 
1233
 
 
 
1234
static void RenderKeyConfigurationMenu()
 
 
1235
{
 
 
1236
    MENU_ELEMENT *elementPtr = Menus.MenuElements;
 
 
1237
    int centrePosition;
 
 
1238
    int i, y;
 
 
1239
    int centreY = ScreenDescriptorBlock.SDB_CentreY +25;
 
 
1240
 
 
 
1241
    {
 
 
1242
        int b = ONE_FIXED;
 
 
1243
        if (!(Menus.CurrentlySelectedElement >= 2))
 
 
1244
            b /= 4;
 
 
1245
 
 
 
1246
        //RenderSmallMenuText(MenusData[Menus.CurrentMenu].MenuTitle, ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
1247
        DrawRectangle(10, (ScreenDescriptorBlock.SDB_CentreY + 25 - 115), (ScreenDescriptorBlock.SDB_Width-20), 250, b);
 
 
1248
    }
 
 
1249
 
 
 
1250
    y = centreY-160;
 
 
1251
 
 
 
1252
    for (i = 0; i < 2; i++, elementPtr++)
 
 
1253
    {
 
 
1254
        int targetBrightness = (i == Menus.CurrentlySelectedElement) ? BRIGHTNESS_OF_HIGHLIGHTED_ELEMENT : BRIGHTNESS_OF_DARKENED_ELEMENT;
 
 
1255
 
 
 
1256
        if (targetBrightness > elementPtr->Brightness)
 
 
1257
        {
 
 
1258
            elementPtr->Brightness += BRIGHTNESS_CHANGE_SPEED;
 
 
1259
 
 
 
1260
            if(elementPtr->Brightness > targetBrightness)
 
 
1261
                elementPtr->Brightness = targetBrightness;
 
 
1262
        }
 
 
1263
        else
 
 
1264
        {
 
 
1265
            elementPtr->Brightness -= BRIGHTNESS_CHANGE_SPEED;
 
 
1266
 
 
 
1267
            if(elementPtr->Brightness < targetBrightness)
 
 
1268
                elementPtr->Brightness = targetBrightness;
 
 
1269
        }
 
 
1270
 
 
 
1271
        RenderMenuElement(elementPtr, i, y);
 
 
1272
        y += HeightOfMenuElement(elementPtr);
 
 
1273
    }
 
 
1274
 
 
 
1275
    centrePosition = Menus.CurrentlySelectedElement * ONE_FIXED;
 
 
1276
 
 
 
1277
    if (centrePosition < 2 * ONE_FIXED)
 
 
1278
        centrePosition = 2* ONE_FIXED;
 
 
1279
 
 
 
1280
    for (i=2; i < Menus.NumberOfElementsInMenu; i++, elementPtr++)
 
 
1281
    {
 
 
1282
        y = MUL_FIXED(i*65536-centrePosition,20);
 
 
1283
 
 
 
1284
        if (y >= -100 && y <= 100)
 
 
1285
        {
 
 
1286
            int targetBrightness;
 
 
1287
 
 
 
1288
            if (i == Menus.CurrentlySelectedElement)
 
 
1289
                targetBrightness = BRIGHTNESS_OF_HIGHLIGHTED_ELEMENT;
 
 
1290
            else
 
 
1291
                targetBrightness = BRIGHTNESS_OF_DARKENED_ELEMENT;
 
 
1292
 
 
 
1293
            elementPtr->Brightness = targetBrightness;
 
 
1294
            RenderMenuElement(elementPtr, i, centreY+y);
 
 
1295
        }
 
 
1296
    }
 
 
1297
 
 
 
1298
    if (EpisodeSelectScrollOffset > 0)
 
 
1299
    {
 
 
1300
        EpisodeSelectScrollOffset -= MUL_FIXED(EpisodeSelectScrollOffset*2+8192, RealFrameTime<<1);
 
 
1301
 
 
 
1302
        if (EpisodeSelectScrollOffset < 0)
 
 
1303
            EpisodeSelectScrollOffset=0;
 
 
1304
    }
 
 
1305
    else if (EpisodeSelectScrollOffset < 0)
 
 
1306
    {
 
 
1307
        EpisodeSelectScrollOffset += MUL_FIXED(-EpisodeSelectScrollOffset*2+8192, RealFrameTime<<1);
 
 
1308
 
 
 
1309
        if (EpisodeSelectScrollOffset > 0)
 
 
1310
            EpisodeSelectScrollOffset=0;
 
 
1311
    }
 
 
1312
}
 
 
1313
 
 
 
1314
static void RenderLoadSaveGameMenu(int save_menu)
 
 
1315
{
 
 
1316
    MENU_ELEMENT *elementPtr = Menus.MenuElements;
 
 
1317
    int e;
 
 
1318
    int y;
 
 
1319
 
 
 
1320
    if (Menus.MenusState == MENUSSTATE_MAINMENUS)
 
 
1321
        y = MENU_CENTREY - (Menus.MenuHeight)/2;
 
 
1322
    else
 
 
1323
        y = (ScreenDescriptorBlock.SDB_Height - Menus.MenuHeight)/2;
 
 
1324
 
 
 
1325
    for (e = 0; e < Menus.NumberOfElementsInMenu; e++, elementPtr++)
 
 
1326
    {
 
 
1327
        char buffer[100];
 
 
1328
        SAVE_SLOT_HEADER *slotPtr = &SaveGameSlot[e];
 
 
1329
        int targetBrightness;
 
 
1330
 
 
 
1331
        if (e == Menus.CurrentlySelectedElement)
 
 
1332
        {
 
 
1333
            Rectangle(MENU_LEFTXEDGE, y-2, MENU_RIGHTXEDGE, y+4+HUD_FONT_HEIGHT*2, 0, 128, 0, 255);
 
 
1334
 
 
 
1335
            targetBrightness = BRIGHTNESS_OF_HIGHLIGHTED_ELEMENT;
 
 
1336
        }
 
 
1337
        else
 
 
1338
        { 
 
 
1339
            targetBrightness = BRIGHTNESS_OF_DARKENED_ELEMENT;
 
 
1340
        }
 
 
1341
 
 
 
1342
        if (targetBrightness > elementPtr->Brightness)
 
 
1343
        {
 
 
1344
            elementPtr->Brightness+=BRIGHTNESS_CHANGE_SPEED;
 
 
1345
 
 
 
1346
            if(elementPtr->Brightness > targetBrightness)
 
 
1347
                elementPtr->Brightness = targetBrightness;
 
 
1348
        }
 
 
1349
        else
 
 
1350
        {
 
 
1351
            elementPtr->Brightness-=BRIGHTNESS_CHANGE_SPEED;
 
 
1352
 
 
 
1353
            if(elementPtr->Brightness < targetBrightness)
 
 
1354
                elementPtr->Brightness = targetBrightness;
 
 
1355
        }
 
 
1356
 
 
 
1357
        sprintf(buffer, "%d.", e+1);
 
 
1358
        RenderSmallMenuText(buffer, MENU_LEFTXEDGE+20, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED);
 
 
1359
 
 
 
1360
        if (slotPtr->SlotUsed)
 
 
1361
        {
 
 
1362
            int numberOfBasicEpisodes;
 
 
1363
 
 
 
1364
            const char * episode_ptr;
 
 
1365
            const char * species;
 
 
1366
 
 
 
1367
            switch(slotPtr->player_type)
 
 
1368
            {
 
 
1369
                case I_Marine:
 
 
1370
                {
 
 
1371
                    episode_ptr =  marine_episodes[slotPtr->Episode];
 
 
1372
                    species = "Marine";
 
 
1373
                    numberOfBasicEpisodes = MAX_NO_OF_BASIC_MARINE_EPISODES;
 
 
1374
                }
 
 
1375
                break;
 
 
1376
                case I_Predator:
 
 
1377
                {
 
 
1378
                    episode_ptr =  predator_episodes[slotPtr->Episode];
 
 
1379
                    species = "Predator";
 
 
1380
                    numberOfBasicEpisodes = MAX_NO_OF_BASIC_PREDATOR_EPISODES;
 
 
1381
                }
 
 
1382
                break;
 
 
1383
                case I_Alien:
 
 
1384
                {
 
 
1385
                    episode_ptr =  alien_episodes[slotPtr->Episode];
 
 
1386
                    species = "Alien";
 
 
1387
                    numberOfBasicEpisodes = MAX_NO_OF_BASIC_ALIEN_EPISODES;
 
 
1388
                }
 
 
1389
            }
 
 
1390
 
 
 
1391
            RenderSmallMenuText(species, MENU_LEFTXEDGE+30, y, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
1392
            RenderSmallMenuText(episode_ptr, ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
1393
 
 
 
1394
            if (numberOfBasicEpisodes > slotPtr->Episode)
 
 
1395
            {
 
 
1396
                const char *ptr;
 
 
1397
 
 
 
1398
                switch (slotPtr->Difficulty)
 
 
1399
                {
 
 
1400
                    case 0:
 
 
1401
                        ptr = "Training";
 
 
1402
                    break;
 
 
1403
                    case 1:
 
 
1404
                        ptr = "Realistic";
 
 
1405
                    break;
 
 
1406
                    case 2:
 
 
1407
                        ptr = "Director's Cut";
 
 
1408
                    break;
 
 
1409
                    default: // should not happen
 
 
1410
                    ptr = "fix this2";
 
 
1411
                }
 
 
1412
 
 
 
1413
                RenderSmallMenuText(ptr, MENU_RIGHTXEDGE-30, y, elementPtr->Brightness, MENUFORMAT_RIGHTJUSTIFIED);
 
 
1414
            }
 
 
1415
 
 
 
1416
            sprintf(buffer, "%s %02d:%02d:%02d", "Time Elapsed: ", slotPtr->ElapsedTime_Hours, slotPtr->ElapsedTime_Minutes,
slotPtr->ElapsedTime_Seconds);
 
 
1417
            RenderSmallMenuText(buffer, MENU_LEFTXEDGE+30, y+HUD_FONT_HEIGHT+1, elementPtr->Brightness, MENUFORMAT_LEFTJUSTIFIED);
 
 
1418
 
 
 
1419
            sprintf(buffer, "%s: %d", "Saves left: ", slotPtr->SavesLeft);
 
 
1420
            RenderSmallMenuText(buffer, ScreenDescriptorBlock.SDB_CentreX, y+HUD_FONT_HEIGHT+1, elementPtr->Brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
1421
            RenderSmallMenuText(ctime(&slotPtr->TimeStamp), MENU_RIGHTXEDGE-30, y+HUD_FONT_HEIGHT+1, elementPtr->Brightness,
MENUFORMAT_RIGHTJUSTIFIED);
 
 
1422
        }
 
 
1423
        else
 
 
1424
        {
 
 
1425
            RenderSmallMenuText("Emtpy Save Slot", ScreenDescriptorBlock.SDB_CentreX, y, elementPtr->Brightness, MENUFORMAT_CENTREJUSTIFIED);
 
 
1426
        }
 
 
1427
 
 
 
1428
        y += HeightOfMenuElement(elementPtr);
 
 
1429
    }
 
 
1430
 
 
 
1431
    if (Menus.MenusState == MENUSSTATE_MAINMENUS)
 
 
1432
    {
 
 
1433
        RenderSmallMenuText("Load Game", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
1434
    }
 
 
1435
    else
 
 
1436
    {
 
 
1437
        y = (ScreenDescriptorBlock.SDB_Height - Menus.MenuHeight)/2 - 30;
 
 
1438
 
 
 
1439
        if(save_menu)
 
 
1440
        {
 
 
1441
            static char text [22]= "Number of saves left  ";
 
 
1442
 
 
 
1443
            switch(PlayerStatus.saves_left)
 
 
1444
            {
 
 
1445
            case 0:
 
 
1446
                text[21] = '0';
 
 
1447
            break;
 
 
1448
            case 1:
 
 
1449
                text[21] = '1';
 
 
1450
            break;
 
 
1451
            case 2:
 
 
1452
                text[21] = '2';
 
 
1453
            break;
 
 
1454
            case 3:
 
 
1455
                text[21] = '3';
 
 
1456
            break;
 
 
1457
            case 4:
 
 
1458
                text[21] = '4';
 
 
1459
            break;
 
 
1460
            default:
 
 
1461
                text[21] = '?';
 
 
1462
            }
 
 
1463
 
 
 
1464
            RenderSmallMenuText(text, ScreenDescriptorBlock.SDB_CentreX, y, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
1465
        }
 
 
1466
        else
 
 
1467
        {
 
 
1468
            RenderSmallMenuText("Load Game", ScreenDescriptorBlock.SDB_CentreX, y, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
1469
        }
 
 
1470
    }
 
 
1471
}
 
 
1472
 
 
 
1473
static int get_new_env(int slot, int force_load)
 
 
1474
{
 
 
1475
    AvP.Difficulty = SaveGameSlot[slot].Difficulty;
 
 
1476
    SetBriefingTextForEpisode(SaveGameSlot[slot].Episode);
 
 
1477
 
 
 
1478
        //see if we will need to change level
 
 
1479
    if(force_load || (SaveGameSlot[slot].player_type != AvP.PlayerType) || (SaveGameSlot[slot].Episode != episode_to_play))
 
 
1480
    {
 
 
1481
        AvP.PlayerType = SaveGameSlot[slot].player_type;
 
 
1482
        episode_to_play = SaveGameSlot[slot].Episode;
 
 
1483
        SetLevelToLoadForSinglePlayer(episode_to_play);
 
 
1484
        return 1;
 
 
1485
    }
 
 
1486
 
 
 
1487
return 0;
 
 
1488
}
 
 
1489
 
 
 
1490
static void InteractWithMenuElement(enum MENU_ELEMENT_INTERACTION_ID interactionID)
 
 
1491
{
 
 
1492
    MENU_ELEMENT *elementPtr = &Menus.MenuElements[Menus.CurrentlySelectedElement];
 
 
1493
 
 
 
1494
    if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1495
        Sound_Play(SID_MENUS_SELECT_ITEM, "r");
 
 
1496
    else
 
 
1497
        Sound_Play(SID_MENUS_CHANGE_ITEM, "r");
 
 
1498
 
 
 
1499
    switch(elementPtr->ElementID)
 
 
1500
    {
 
 
1501
        case MENU_ELEMENT_SELECT_SPECIES:
 
 
1502
        {
 
 
1503
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1504
            {
 
 
1505
                AvP.PlayerType = Menus.CurrentlySelectedElement;
 
 
1506
                SetupNewMenu(elementPtr->b.MenuToGoTo);
 
 
1507
            }
 
 
1508
        }
 
 
1509
        break;
 
 
1510
        case MENU_ELEMENT_GOTOMENU:
 
 
1511
        {
 
 
1512
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1513
                SetupNewMenu(elementPtr->b.MenuToGoTo);
 
 
1514
        }
 
 
1515
        break;
 
 
1516
        case MENU_ELEMENT_SAVEMPCONFIG:
 
 
1517
        {
 
 
1518
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1519
            {
 
 
1520
                if(MP_Config_Name[0])
 
 
1521
                    SaveMultiplayerConfiguration(MP_Config_Name);
 
 
1522
 
 
 
1523
                SetupNewMenu(elementPtr->b.MenuToGoTo);
 
 
1524
            }
 
 
1525
        }
 
 
1526
        break;
 
 
1527
        case MENU_ELEMENT_TEXTFIELD:
 
 
1528
        {
 
 
1529
            Menus.UserEnteringText = 1;
 
 
1530
            Menus.PositionInTextField = strlen(elementPtr->c.TextPtr);
 
 
1531
            Menus.WidthLeftForText = 0; //will be calculated properly when menus are drawn
 
 
1532
            elementPtr->c.TextPtr[Menus.PositionInTextField] = 0;
 
 
1533
        }
 
 
1534
        break;
 
 
1535
        case MENU_ELEMENT_TEXTFIELD_SMALLWRAPPED:
 
 
1536
        {
 
 
1537
            Menus.UserEnteringText = 1;
 
 
1538
            Menus.PositionInTextField = strlen(elementPtr->c.TextPtr);
 
 
1539
            Menus.WidthLeftForText = 0; //will be calculated properly when menus are drawn
 
 
1540
        }
 
 
1541
        break;
 
 
1542
        case MENU_ELEMENT_NUMBERFIELD:
 
 
1543
        {
 
 
1544
            if(interactionID == MENU_ELEMENT_INTERACTION_DECREASE)
 
 
1545
            {
 
 
1546
                (*elementPtr->c.NumberPtr)--;
 
 
1547
 
 
 
1548
                if(*elementPtr->c.NumberPtr < 0)
 
 
1549
                    *elementPtr->c.NumberPtr = 0;
 
 
1550
            }
 
 
1551
            else if(interactionID == MENU_ELEMENT_INTERACTION_INCREASE)
 
 
1552
            {
 
 
1553
                (*elementPtr->c.NumberPtr)++;
 
 
1554
 
 
 
1555
                if(*elementPtr->c.NumberPtr > elementPtr->b.MaxValue)
 
 
1556
                    *elementPtr->c.NumberPtr = elementPtr->b.MaxValue;
 
 
1557
            }
 
 
1558
            else
 
 
1559
            {
 
 
1560
                *elementPtr->c.NumberPtr = 0;
 
 
1561
            }
 
 
1562
        }
 
 
1563
        break;
 
 
1564
        case MENU_ELEMENT_DUMMYTEXTSLIDER:
 
 
1565
        case MENU_ELEMENT_DUMMYTEXTSLIDER_POINTER:
 
 
1566
        break;
 
 
1567
        case MENU_ELEMENT_SLIDER:
 
 
1568
        {
 
 
1569
            if ((interactionID == MENU_ELEMENT_INTERACTION_SELECT) || (interactionID == MENU_ELEMENT_INTERACTION_INCREASE))
 
 
1570
            {
 
 
1571
                if (*elementPtr->c.SliderValuePtr < elementPtr->b.MaxSliderValue)
 
 
1572
                    *elementPtr->c.SliderValuePtr += 1;
 
 
1573
            }
 
 
1574
            else
 
 
1575
            {
 
 
1576
                if (*elementPtr->c.SliderValuePtr > 0)
 
 
1577
                    *elementPtr->c.SliderValuePtr -= 1;
 
 
1578
            }
 
 
1579
        }
 
 
1580
        break;
 
 
1581
        case MENU_ELEMENT_TOGGLE_MOUSE_GRAB:
 
 
1582
        {
 
 
1583
            extern void toggle_mouse_grab();
 
 
1584
            UserProfile.grabmouse ^= 1;
 
 
1585
            toggle_mouse_grab();
 
 
1586
        }
 
 
1587
        break;
 
 
1588
        case MENU_ELEMENT_TOGGLE_FULLSCREEN:
 
 
1589
        {
 
 
1590
            extern int SetVideoMode();
 
 
1591
            UserProfile.fullscreen ^= 1;
 
 
1592
            SetVideoMode();
 
 
1593
        }
 
 
1594
        break;
 
 
1595
        case MENU_ELEMENT_LOADSOUNDS:
 
 
1596
        case MENU_ELEMENT_LEVELNAME:
 
 
1597
        case MENU_ELEMENT_TEXTSLIDER:
 
 
1598
        {
 
 
1599
            if ((interactionID == MENU_ELEMENT_INTERACTION_SELECT) || (interactionID == MENU_ELEMENT_INTERACTION_INCREASE))
 
 
1600
            {
 
 
1601
                *elementPtr->c.SliderValuePtr += 1;
 
 
1602
 
 
 
1603
                if (*elementPtr->c.SliderValuePtr > elementPtr->b.MaxSliderValue)
 
 
1604
                    *elementPtr->c.SliderValuePtr = 0;
 
 
1605
            }
 
 
1606
            else
 
 
1607
            {
 
 
1608
                *elementPtr->c.SliderValuePtr -= 1;
 
 
1609
 
 
 
1610
                if (*elementPtr->c.SliderValuePtr < 0)
 
 
1611
                    *elementPtr->c.SliderValuePtr = elementPtr->b.MaxSliderValue;
 
 
1612
            }
 
 
1613
        }
 
 
1614
        break;
 
 
1615
        case MENU_ELEMENT_SPECIES_TEXTSLIDER:
 
 
1616
        {
 
 
1617
            if ((interactionID == MENU_ELEMENT_INTERACTION_SELECT) || (interactionID == MENU_ELEMENT_INTERACTION_INCREASE))
 
 
1618
            {
 
 
1619
                *elementPtr->c.SliderValuePtr += 1;
 
 
1620
 
 
 
1621
                if (*elementPtr->c.SliderValuePtr > elementPtr->b.MaxSliderValue)
 
 
1622
                    *elementPtr->c.SliderValuePtr = 0;
 
 
1623
 
 
 
1624
                GetNextAllowedSpecies(elementPtr->c.SliderValuePtr, 1);
 
 
1625
            }
 
 
1626
            else
 
 
1627
            {
 
 
1628
                *elementPtr->c.SliderValuePtr -= 1;
 
 
1629
 
 
 
1630
                if (*elementPtr->c.SliderValuePtr < 0)
 
 
1631
                    *elementPtr->c.SliderValuePtr = elementPtr->b.MaxSliderValue;
 
 
1632
 
 
 
1633
                GetNextAllowedSpecies(elementPtr->c.SliderValuePtr, 0);
 
 
1634
            }
 
 
1635
        }
 
 
1636
        break;
 
 
1637
        case MENU_ELEMENT_CHEATMODE_SPECIES_TEXTSLIDER:
 
 
1638
        {
 
 
1639
            if ((interactionID == MENU_ELEMENT_INTERACTION_SELECT) || (interactionID == MENU_ELEMENT_INTERACTION_INCREASE))
 
 
1640
            {
 
 
1641
                *elementPtr->c.SliderValuePtr += 1;
 
 
1642
 
 
 
1643
                if (*elementPtr->c.SliderValuePtr > elementPtr->b.MaxSliderValue)
 
 
1644
                    *elementPtr->c.SliderValuePtr = 0;
 
 
1645
 
 
 
1646
                CheatMode_GetNextAllowedSpecies(elementPtr->c.SliderValuePtr, 1);
 
 
1647
            }
 
 
1648
            else
 
 
1649
            {
 
 
1650
                *elementPtr->c.SliderValuePtr -= 1;
 
 
1651
 
 
 
1652
                if (*elementPtr->c.SliderValuePtr < 0)
 
 
1653
                    *elementPtr->c.SliderValuePtr = elementPtr->b.MaxSliderValue;
 
 
1654
 
 
 
1655
                CheatMode_GetNextAllowedSpecies(elementPtr->c.SliderValuePtr, 0);
 
 
1656
            }
 
 
1657
        }
 
 
1658
        break;
 
 
1659
        case MENU_ELEMENT_CHEATMODE_TEXTSLIDER:
 
 
1660
        {
 
 
1661
            if ((interactionID == MENU_ELEMENT_INTERACTION_SELECT) || (interactionID == MENU_ELEMENT_INTERACTION_INCREASE))
 
 
1662
            {
 
 
1663
                *elementPtr->c.SliderValuePtr += 1;
 
 
1664
 
 
 
1665
                if (*elementPtr->c.SliderValuePtr > elementPtr->b.MaxSliderValue)
 
 
1666
                    *elementPtr->c.SliderValuePtr = 0;
 
 
1667
 
 
 
1668
                CheatMode_GetNextAllowedMode(elementPtr->c.SliderValuePtr, 1);
 
 
1669
            }
 
 
1670
            else
 
 
1671
            {
 
 
1672
                *elementPtr->c.SliderValuePtr -= 1;
 
 
1673
 
 
 
1674
                if (*elementPtr->c.SliderValuePtr < 0)
 
 
1675
                    *elementPtr->c.SliderValuePtr = elementPtr->b.MaxSliderValue;
 
 
1676
 
 
 
1677
                CheatMode_GetNextAllowedMode(elementPtr->c.SliderValuePtr, 0);
 
 
1678
            }
 
 
1679
        }
 
 
1680
        break;
 
 
1681
        case MENU_ELEMENT_CHEATMODE_ENVIRONMENT_TEXTSLIDER:
 
 
1682
        {
 
 
1683
            if ((interactionID == MENU_ELEMENT_INTERACTION_SELECT) || (interactionID == MENU_ELEMENT_INTERACTION_INCREASE))
 
 
1684
            {
 
 
1685
                *elementPtr->c.SliderValuePtr += 1;
 
 
1686
 
 
 
1687
                if (*elementPtr->c.SliderValuePtr > elementPtr->b.MaxSliderValue)
 
 
1688
                    *elementPtr->c.SliderValuePtr = 0;
 
 
1689
 
 
 
1690
                CheatMode_GetNextAllowedEnvironment(elementPtr->c.SliderValuePtr, 1);
 
 
1691
            }
 
 
1692
            else
 
 
1693
            {
 
 
1694
                *elementPtr->c.SliderValuePtr -= 1;
 
 
1695
 
 
 
1696
                if (*elementPtr->c.SliderValuePtr < 0)
 
 
1697
                    *elementPtr->c.SliderValuePtr = elementPtr->b.MaxSliderValue;
 
 
1698
 
 
 
1699
                CheatMode_GetNextAllowedEnvironment(elementPtr->c.SliderValuePtr, 0);
 
 
1700
            }
 
 
1701
        }
 
 
1702
        break;
 
 
1703
        case MENU_ELEMENT_QUITGAME:
 
 
1704
        {
 
 
1705
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1706
            {
 
 
1707
                AvP.MainLoopRunning = 0;
 
 
1708
                Menus.MenusState = MENUSSTATE_OUTSIDEMENUS;
 
 
1709
            }
 
 
1710
        }
 
 
1711
        break;
 
 
1712
        case MENU_ELEMENT_DELETEMPCONFIG:
 
 
1713
        {
 
 
1714
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1715
            {
 
 
1716
                //DeleteMultiplayerConfigurationByIndex(MultiplayerConfigurationIndex);
 
 
1717
                //go back to the load config menu
 
 
1718
                //SetupNewMenu(MENU_MULTIPLAYER_LOADCONFIG);
 
 
1719
            }
 
 
1720
        }
 
 
1721
        break;  
 
 
1722
        case MENU_ELEMENT_DIFFICULTYLEVEL:
 
 
1723
        {
 
 
1724
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1725
            {
 
 
1726
                AvP.Difficulty = (Menus.CurrentMenu == MENU_LEVELBRIEFING_BASIC) ? Menus.CurrentlySelectedElement : I_Hard;
 
 
1727
                Menus.MenusState = MENUSSTATE_STARTGAME;
 
 
1728
                SetLevelToLoadForSinglePlayer(episode_to_play);
 
 
1729
            }
 
 
1730
        }
 
 
1731
        break;
 
 
1732
        case MENU_ELEMENT_SELECTEPISODE:
 
 
1733
        {
 
 
1734
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT && MaximumSelectableLevel >= *elementPtr->c.SliderValuePtr)
 
 
1735
            {
 
 
1736
                int number_of_bacis_levels;
 
 
1737
 
 
 
1738
                switch(AvP.PlayerType)
 
 
1739
                {
 
 
1740
                    case I_Alien:
 
 
1741
                        number_of_bacis_levels = MAX_NO_OF_BASIC_ALIEN_EPISODES;
 
 
1742
                    break;
 
 
1743
                    case I_Marine:
 
 
1744
                        number_of_bacis_levels = MAX_NO_OF_BASIC_MARINE_EPISODES;
 
 
1745
                    break;
 
 
1746
                    case I_Predator:
 
 
1747
                        number_of_bacis_levels = MAX_NO_OF_BASIC_PREDATOR_EPISODES;
 
 
1748
                }
 
 
1749
 
 
 
1750
                SetupNewMenu((episode_to_play < number_of_bacis_levels) ? MENU_LEVELBRIEFING_BASIC : MENU_LEVELBRIEFING_BONUS);
 
 
1751
            }
 
 
1752
            else
 
 
1753
            {
 
 
1754
                /* This code is reached when an EPISODE element has been
 
 
1755
                activated but not "selected" i.e. the user wants to change
 
 
1756
                the current episode, not start playing the current episode */
 
 
1757
                if (interactionID == MENU_ELEMENT_INTERACTION_INCREASE)
 
 
1758
                {
 
 
1759
                    if (*elementPtr->c.SliderValuePtr < elementPtr->b.MaxSliderValue)
 
 
1760
                    {
 
 
1761
                        *elementPtr->c.SliderValuePtr +=1;
 
 
1762
                        EpisodeSelectScrollOffset -= ONE_FIXED;
 
 
1763
                    }
 
 
1764
                }
 
 
1765
                else if (*elementPtr->c.SliderValuePtr > 0)
 
 
1766
                {
 
 
1767
                    *elementPtr->c.SliderValuePtr -= 1;
 
 
1768
                    EpisodeSelectScrollOffset += ONE_FIXED;
 
 
1769
                }
 
 
1770
            }
 
 
1771
        }
 
 
1772
        break;
 
 
1773
        case MENU_ELEMENT_STARTLEVELWITHCHEAT:
 
 
1774
        {
 
 
1775
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1776
            {
 
 
1777
                Menus.MenusState = MENUSSTATE_STARTGAME;
 
 
1778
                AvP.PlayerType = CheatMode_Species;
 
 
1779
                AvP.Difficulty = I_Hard;
 
 
1780
                SetLevelToLoadForCheatMode(CheatMode_Environment);
 
 
1781
            }
 
 
1782
        }
 
 
1783
        break;
 
 
1784
        case MENU_ELEMENT_STARTSKIRMISH:
 
 
1785
        case MENU_ELEMENT_STARTMPGAME:
 
 
1786
        {
 
 
1787
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1788
            {
 
 
1789
                //save the 'Previous Game' multiplayer configuration
 
 
1790
                strcpy(MP_Config_Description, "previous_game");
 
 
1791
                SaveMultiplayerConfiguration("previous_game");
 
 
1792
 
 
 
1793
                if (InitAVPNetGameForHost(UserProfile.PlayerName, MP_Species, netGameData.gameType, netGameData.levelNumber))
 
 
1794
                {
 
 
1795
                    Menus.MenusState = MENUSSTATE_STARTGAME;
 
 
1796
 
 
 
1797
                    if(netGameData.gameType == NGT_Coop)
 
 
1798
                        SetLevelToLoadForCooperative(netGameData.levelNumber);
 
 
1799
                    else
 
 
1800
                        SetLevelToLoadForMultiplayer(netGameData.levelNumber);
 
 
1801
                }
 
 
1802
            }
 
 
1803
        }
 
 
1804
        break;
 
 
1805
        case MENU_ELEMENT_JOINMPGAME:
 
 
1806
        {
 
 
1807
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1808
            {
 
 
1809
                Menus.MenusState = MENUSSTATE_STARTGAME;
 
 
1810
                netGameData.myStartFlag = 1;        
 
 
1811
            }
 
 
1812
        }
 
 
1813
        break;
 
 
1814
        case MENU_ELEMENT_LOADMPCONFIG:
 
 
1815
        {
 
 
1816
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1817
            {
 
 
1818
                //LoadMultiplayerConfigurationByIndex(Menus.CurrentlySelectedElement);
 
 
1819
                SetupNewMenu(elementPtr->b.MenuToGoTo);
 
 
1820
            }
 
 
1821
        }
 
 
1822
        break;
 
 
1823
        case MENU_ELEMENT_LOADIPADDRESS:
 
 
1824
        {
 
 
1825
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1826
            {
 
 
1827
                LoadIPAddress(elementPtr->c.TextPtr);
 
 
1828
                SetupNewMenu(elementPtr->b.MenuToGoTo);
 
 
1829
            }
 
 
1830
        }
 
 
1831
        break;
 
 
1832
        case MENU_ELEMENT_SELECT_WINDOWSIZE:
 
 
1833
        {
 
 
1834
            extern void change_video_mode(int);
 
 
1835
            change_video_mode(((interactionID == MENU_ELEMENT_INTERACTION_SELECT) || (interactionID == MENU_ELEMENT_INTERACTION_INCREASE)));
 
 
1836
        }
 
 
1837
        break;
 
 
1838
        case MENU_ELEMENT_RESUMEGAME:
 
 
1839
        {
 
 
1840
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1841
                Menus.MenusState = MENUSSTATE_OUTSIDEMENUS;
 
 
1842
        }
 
 
1843
        break;
 
 
1844
        case MENU_ELEMENT_RESTARTGAME:
 
 
1845
        {
 
 
1846
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1847
            {
 
 
1848
                Menus.MenusState = MENUSSTATE_OUTSIDEMENUS;
 
 
1849
                AvP.RestartLevel = 1;
 
 
1850
                AvP.MainLoopRunning = 0;
 
 
1851
            }
 
 
1852
        }
 
 
1853
        break;
 
 
1854
        case MENU_ELEMENT_KEYCONFIG:
 
 
1855
        {
 
 
1856
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1857
            {
 
 
1858
                Menus.UserChangingKeyConfig = 1;
 
 
1859
                Menus.ChangingPrimaryConfig = !KeyConfigSelectionColumn;
 
 
1860
            }
 
 
1861
            else
 
 
1862
            {
 
 
1863
                KeyConfigSelectionColumn = !KeyConfigSelectionColumn;     
 
 
1864
            }
 
 
1865
        }
 
 
1866
        break;
 
 
1867
        case MENU_ELEMENT_KEYCONFIGOK:
 
 
1868
        {
 
 
1869
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1870
            {
 
 
1871
                switch (Menus.CurrentMenu)
 
 
1872
                {
 
 
1873
                    case MENU_MARINEKEYCONFIG:
 
 
1874
                    {
 
 
1875
                        UserProfile.MarineInputPrimaryConfig = PlayerInputPrimaryConfig;
 
 
1876
                        UserProfile.MarineInputSecondaryConfig = PlayerInputSecondaryConfig;
 
 
1877
                    }
 
 
1878
                    break;
 
 
1879
                    case MENU_PREDATORKEYCONFIG:
 
 
1880
                    {
 
 
1881
                        UserProfile.PredatorInputPrimaryConfig = PlayerInputPrimaryConfig;
 
 
1882
                        UserProfile.PredatorInputSecondaryConfig = PlayerInputSecondaryConfig;
 
 
1883
                    }
 
 
1884
                    break;
 
 
1885
                    case MENU_ALIENKEYCONFIG:
 
 
1886
                    {
 
 
1887
                        UserProfile.AlienInputPrimaryConfig = PlayerInputPrimaryConfig;
 
 
1888
                        UserProfile.AlienInputSecondaryConfig = PlayerInputSecondaryConfig;
 
 
1889
                    }
 
 
1890
                    break;
 
 
1891
                    case MENU_MOUSEOPTIONS:
 
 
1892
                        UserProfile.ControlMethods = PlayerControlMethods;
 
 
1893
                    default:
 
 
1894
                    break;
 
 
1895
                }
 
 
1896
 
 
 
1897
                SaveUserProfile();
 
 
1898
            }
 
 
1899
        }
 
 
1900
        break;
 
 
1901
        case MENU_ELEMENT_RESETKEYCONFIG:
 
 
1902
        {
 
 
1903
            if (interactionID == MENU_ELEMENT_INTERACTION_SELECT)
 
 
1904
            {
 
 
1905
                switch (Menus.CurrentMenu)
 
 
1906
                {
 
 
1907
                    case MENU_MARINEKEYCONFIG:
 
 
1908
                    {
 
 
1909
                        UserProfile.MarineInputPrimaryConfig = DefaultMarineInputPrimaryConfig;
 
 
1910
                        UserProfile.MarineInputSecondaryConfig = DefaultMarineInputSecondaryConfig;
 
 
1911
                    }
 
 
1912
                    break;
 
 
1913
                    case MENU_PREDATORKEYCONFIG:
 
 
1914
                    {
 
 
1915
                        UserProfile.PredatorInputPrimaryConfig = DefaultPredatorInputPrimaryConfig;
 
 
1916
                        UserProfile.PredatorInputSecondaryConfig = DefaultPredatorInputSecondaryConfig;
 
 
1917
                    }
 
 
1918
                    break;
 
 
1919
                    case MENU_ALIENKEYCONFIG:
 
 
1920
                    {
 
 
1921
                        UserProfile.AlienInputPrimaryConfig = DefaultAlienInputPrimaryConfig;
 
 
1922
                        UserProfile.AlienInputPrimaryConfig = DefaultAlienInputSecondaryConfig;
 
 
1923
                    }
 
 
1924
                    default:
 
 
1925
                        break;
 
 
1926
                }
 
 
1927
            }
 
 
1928
        }
 
 
1929
        break;
 
 
1930
        case MENU_ELEMENT_RESETMPCONFIG:
 
 
1931
        {
 
 
1932
            //reset the multiplayer configuration
 
 
1933
            extern void SetDefaultMultiplayerConfig();
 
 
1934
            SetDefaultMultiplayerConfig();
 
 
1935
        }
 
 
1936
        break;
 
 
1937
        case MENU_ELEMENT_LOADGAME:
 
 
1938
        {
 
 
1939
            int slot = Menus.CurrentlySelectedElement;
 
 
1940
 
 
 
1941
            if(slot >= 0 && slot < NUMBER_OF_SAVE_SLOTS)
 
 
1942
            {
 
 
1943
                if(SaveGameSlot[slot].SlotUsed)
 
 
1944
                {
 
 
1945
                    LoadGameRequest = slot;
 
 
1946
 
 
 
1947
                    if(Menus.MenusState == MENUSSTATE_INGAMEMENUS)
 
 
1948
                    {
 
 
1949
                        if (!get_new_env(slot, 0))
 
 
1950
                            AvP.RestartLevel = 1;
 
 
1951
 
 
 
1952
                            AvP.MainLoopRunning = 0;
 
 
1953
                    }
 
 
1954
                    else
 
 
1955
                    {
 
 
1956
                        get_new_env(slot, 1);
 
 
1957
                    }
 
 
1958
 
 
 
1959
                    Menus.MenusState = MENUSSTATE_STARTGAME;    
 
 
1960
                }
 
 
1961
            }
 
 
1962
        }
 
 
1963
        break;
 
 
1964
        case MENU_ELEMENT_SAVEGAME:
 
 
1965
        {
 
 
1966
            int slot = Menus.CurrentlySelectedElement;
 
 
1967
 
 
 
1968
            if(slot >= 0 && slot < NUMBER_OF_SAVE_SLOTS)
 
 
1969
            {
 
 
1970
                Menus.MenusState = MENUSSTATE_STARTGAME;
 
 
1971
 
 
 
1972
                if(!PlayerStatus.Alive || (CHEATMODE_NONACTIVE != UserProfile.active_bonus) || (PlayerStatus.saves_left < 1))
 
 
1973
                {
 
 
1974
                    //empty
 
 
1975
                }
 
 
1976
                else
 
 
1977
                {
 
 
1978
                    SaveGame(slot);
 
 
1979
                }
 
 
1980
            }
 
 
1981
        }
 
 
1982
        break;
 
 
1983
        default:
 
 
1984
        assert("UNKNOWN MENU ELEMENT"==0);
 
 
1985
    }
 
 
1986
}
 
 
1987
 
 
 
1988
static void ActUponUsersInput()
 
 
1989
{
 
 
1990
    if (Menus.UserEnteringText)
 
 
1991
    {
 
 
1992
        MENU_ELEMENT *elementPtr = &Menus.MenuElements[Menus.CurrentlySelectedElement];
 
 
1993
 
 
 
1994
        if (Keyboard[SDLK_ESCAPE] || Keyboard[SDLK_RETURN])
 
 
1995
        {
 
 
1996
            elementPtr->c.TextPtr[Menus.PositionInTextField] = 0;
 
 
1997
            Menus.UserEnteringText = 0;
 
 
1998
 
 
 
1999
            // KJL 10:09:35 09/02/00 - when the user has entered their name,
 
 
2000
            // move down to the next option. If the user enters a null
 
 
2001
            // string, replace it with a placeholder name        
 
 
2002
            if((Menus.CurrentMenu == MENU_SKIRMISH) || (Menus.CurrentMenu == MENU_MULTIPLAYER_MAINSTART))
 
 
2003
            {
 
 
2004
                if(!Menus.PositionInTextField)
 
 
2005
                    strcpy(elementPtr->c.TextPtr, "DeadMeat");
 
 
2006
 
 
 
2007
                Menus.CurrentlySelectedElement++;
 
 
2008
            }
 
 
2009
        }
 
 
2010
        else if (Keyboard[SDLK_BACKSPACE] || Keyboard[SDLK_DELETE])
 
 
2011
        {
 
 
2012
            if (Menus.PositionInTextField > 0)
 
 
2013
                elementPtr->c.TextPtr[--Menus.PositionInTextField] = 0;
 
 
2014
        }
 
 
2015
        else if(Keyboard[SDLK_LEFT])
 
 
2016
        {
 
 
2017
            if (Menus.PositionInTextField > 0)
 
 
2018
                --Menus.PositionInTextField;
 
 
2019
        }
 
 
2020
        else
 
 
2021
        {
 
 
2022
            if (Menus.PositionInTextField < elementPtr->b.MaxTextLength)
 
 
2023
            {
 
 
2024
                signed int key = SDLK_FIRST;
 
 
2025
 
 
 
2026
                for (; key < number_of_available_keys; key++)
 
 
2027
                {
 
 
2028
                    if (key != SDLK_ESCAPE && key != SDLK_RETURN)
 
 
2029
                    {
 
 
2030
                        if (Keyboard[key])
 
 
2031
                        {
 
 
2032
                            if (Menus.PositionInTextField < elementPtr->b.MaxTextLength)
 
 
2033
                            {
 
 
2034
                                //see if there is room for this character
 
 
2035
                                if(Menus.FontToUse == MENU_FONT_BIG && elementPtr->ElementID != MENU_ELEMENT_TEXTFIELD_SMALLWRAPPED)
 
 
2036
                                {
 
 
2037
                                    //using large font
 
 
2038
                                    //allocate 32 pixels for each new character for the moment
 
 
2039
                                    //the true amount used will be worked out when the font is drawn
 
 
2040
                                    //Might cause a slight glitch for fast typists , but I forgot about 
 
 
2041
                                    //the damned kerned fonts until after I'd written most of this
 
 
2042
                                        if(Menus.WidthLeftForText < 32)
 
 
2043
                                            break;
 
 
2044
 
 
 
2045
                                    Menus.WidthLeftForText -= 32;
 
 
2046
                                }
 
 
2047
                                else
 
 
2048
                                {
 
 
2049
                                    //using small font
 
 
2050
                                    if(Menus.WidthLeftForText < AAFontWidths[(uint8_t)key])
 
 
2051
                                            break;
 
 
2052
 
 
 
2053
                                    Menus.WidthLeftForText -= AAFontWidths[(uint8_t)key];
 
 
2054
                                }
 
 
2055
 
 
 
2056
                                elementPtr->c.TextPtr[Menus.PositionInTextField++] = key;
 
 
2057
                                elementPtr->c.TextPtr[Menus.PositionInTextField] = 0;
 
 
2058
                            }
 
 
2059
 
 
 
2060
                        break;
 
 
2061
                        }
 
 
2062
                    }
 
 
2063
                }
 
 
2064
 
 
 
2065
            }
 
 
2066
        }
 
 
2067
 
 
 
2068
        memset(&Keyboard[0], 0, number_of_available_keys); //SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); does not work
 
 
2069
    }
 
 
2070
    else if (Menus.UserChangingKeyConfig)
 
 
2071
    {
 
 
2072
        if (Keyboard[SDLK_ESCAPE])
 
 
2073
        {
 
 
2074
            Menus.UserChangingKeyConfig = 0;
 
 
2075
        }
 
 
2076
        else
 
 
2077
        {
 
 
2078
            int key = SDLK_FIRST;
 
 
2079
 
 
 
2080
            for (; key < number_of_available_keys; key++)
 
 
2081
            {
 
 
2082
                if (!(key == SDLK_ESCAPE) && !(key >= SDLK_0 && key <= SDLK_9) && !( key == SDLK_RETURN))
 
 
2083
                {
 
 
2084
                    if (Keyboard[key])
 
 
2085
                    {
 
 
2086
                        if (Menus.ChangingPrimaryConfig)
 
 
2087
                        {
 
 
2088
                            *(((SDLKey*)&PlayerInputPrimaryConfig)+Menus.CurrentlySelectedElement-2) = key;
 
 
2089
                            Menus.UserChangingKeyConfig=0;
 
 
2090
                        }
 
 
2091
                        else // changing Secondary
 
 
2092
                        {
 
 
2093
                            *(((SDLKey*)&PlayerInputSecondaryConfig)+Menus.CurrentlySelectedElement-2) = key;
 
 
2094
                            Menus.UserChangingKeyConfig=0;
 
 
2095
                        }
 
 
2096
                    break;
 
 
2097
                    }
 
 
2098
                }
 
 
2099
            }
 
 
2100
        }
 
 
2101
    }
 
 
2102
    else
 
 
2103
    {
 
 
2104
        if ((Keyboard[SDLK_ESCAPE] || Keyboard[SDL_BUTTON_RIGHT]) && (Menus.CurrentMenu != MENU_MAIN))
 
 
2105
        {
 
 
2106
            switch(Menus.CurrentMenu)
 
 
2107
            {
 
 
2108
            /*
 
 
2109
                case MENU_MULTIPLAYER_CONFIG_JOIN:
 
 
2110
                    AddNetMsg_PlayerLeaving();
 
 
2111
                    NetSendMessages();
 
 
2112
                break;
 
 
2113
            */
 
 
2114
                case MENU_GAMEOPTIONS:
 
 
2115
                    SetDetailLevelsFromMenu();
 
 
2116
                break;
 
 
2117
                case MENU_BONUSOPTIONS:
 
 
2118
                    //UserProfile.active_bonus = CHEATMODE_NONACTIVE;
 
 
2119
                break;    
 
 
2120
                case MENU_SKIRMISH:
 
 
2121
                case MENU_MULTIPLAYER_HOSTSETUP:
 
 
2122
                case MENU_MULTIPLAYER_MAINSTART:
 
 
2123
                default:
 
 
2124
                break;
 
 
2125
            }
 
 
2126
 
 
 
2127
            if(InputIsDebounced)
 
 
2128
            {
 
 
2129
                if (Menus.CurrentMenu == MENU_INGAME)
 
 
2130
                    Menus.MenusState = MENUSSTATE_STARTGAME;
 
 
2131
                else
 
 
2132
                    SetupNewMenu(MenusData[Menus.CurrentMenu].ParentMenu);
 
 
2133
 
 
 
2134
                InputIsDebounced = 0;
 
 
2135
            }
 
 
2136
        }
 
 
2137
        else if (Keyboard[SDLK_RETURN] || Keyboard[SDLK_SPACE] || Keyboard[SDL_BUTTON_LEFT])
 
 
2138
        {
 
 
2139
            if (InputIsDebounced)
 
 
2140
            {
 
 
2141
                InteractWithMenuElement(MENU_ELEMENT_INTERACTION_SELECT);
 
 
2142
                InputIsDebounced = 0;
 
 
2143
            }
 
 
2144
        }
 
 
2145
        else if (Keyboard[SDLK_UP] || Keyboard[SDL_BUTTON_WHEELUP])
 
 
2146
        {
 
 
2147
            if (InputIsDebounced)
 
 
2148
            {
 
 
2149
                switch (Menus.CurrentMenu)
 
 
2150
                {
 
 
2151
                    case MENU_SELECT_EPISODE:
 
 
2152
                        InteractWithMenuElement(MENU_ELEMENT_INTERACTION_DECREASE);
 
 
2153
                    break;
 
 
2154
                    case MENU_MARINEKEYCONFIG:
 
 
2155
                    case MENU_PREDATORKEYCONFIG:
 
 
2156
                    case MENU_ALIENKEYCONFIG:
 
 
2157
                    {
 
 
2158
                        if (Menus.CurrentlySelectedElement > 0)
 
 
2159
                        {
 
 
2160
                            Menus.CurrentlySelectedElement--;
 
 
2161
                            //Sound_Play(SID_MENUS_CHANGE_ITEM, "r");
 
 
2162
                        }
 
 
2163
                    }
 
 
2164
                    break;
 
 
2165
                    default:
 
 
2166
                    {
 
 
2167
                        Menus.CurrentlySelectedElement--;
 
 
2168
 
 
 
2169
                        if (Menus.CurrentlySelectedElement < 0)
 
 
2170
                            Menus.CurrentlySelectedElement = Menus.NumberOfElementsInMenu-1;
 
 
2171
 
 
 
2172
                        Sound_Play(SID_MENUS_CHANGE_ITEM, "r");
 
 
2173
                    }
 
 
2174
                }
 
 
2175
                InputIsDebounced = 0;
 
 
2176
            }
 
 
2177
            else
 
 
2178
            {
 
 
2179
                KeyDepressedCounter += RealFrameTime;
 
 
2180
            }
 
 
2181
        }
 
 
2182
        else if (Keyboard[SDLK_DOWN] || Keyboard[SDL_BUTTON_WHEELDOWN])
 
 
2183
        {
 
 
2184
            if (InputIsDebounced)
 
 
2185
            {
 
 
2186
                switch (Menus.CurrentMenu)
 
 
2187
                {
 
 
2188
                    case MENU_SELECT_EPISODE:
 
 
2189
                        InteractWithMenuElement(MENU_ELEMENT_INTERACTION_INCREASE);
 
 
2190
                    break;
 
 
2191
                    case MENU_MARINEKEYCONFIG:
 
 
2192
                    case MENU_PREDATORKEYCONFIG:
 
 
2193
                    case MENU_ALIENKEYCONFIG:
 
 
2194
                    {
 
 
2195
                        if (Menus.CurrentlySelectedElement < Menus.NumberOfElementsInMenu-1)
 
 
2196
                        {
 
 
2197
                            Menus.CurrentlySelectedElement++;
 
 
2198
                            Sound_Play(SID_MENUS_CHANGE_ITEM, "r");
 
 
2199
                        }
 
 
2200
                        break;
 
 
2201
                    }
 
 
2202
                    default:
 
 
2203
                    {
 
 
2204
                        Menus.CurrentlySelectedElement++;
 
 
2205
 
 
 
2206
                        if (Menus.CurrentlySelectedElement >= Menus.NumberOfElementsInMenu)
 
 
2207
                            Menus.CurrentlySelectedElement= 0;
 
 
2208
 
 
 
2209
                        Sound_Play(SID_MENUS_CHANGE_ITEM, "r");
 
 
2210
                        break;
 
 
2211
                    }
 
 
2212
                }
 
 
2213
 
 
 
2214
                InputIsDebounced = 0;
 
 
2215
            }
 
 
2216
            else
 
 
2217
            {
 
 
2218
                KeyDepressedCounter += RealFrameTime;
 
 
2219
            }
 
 
2220
        }
 
 
2221
        else if (Keyboard[SDLK_LEFT])
 
 
2222
        {
 
 
2223
            if (InputIsDebounced)
 
 
2224
            {
 
 
2225
                InteractWithMenuElement(MENU_ELEMENT_INTERACTION_DECREASE);
 
 
2226
                InputIsDebounced = 0;
 
 
2227
            }
 
 
2228
            else
 
 
2229
            {
 
 
2230
                KeyDepressedCounter += RealFrameTime;
 
 
2231
            }
 
 
2232
        }
 
 
2233
        else if (Keyboard[SDLK_RIGHT])
 
 
2234
        {
 
 
2235
            if (InputIsDebounced)
 
 
2236
            {
 
 
2237
                InteractWithMenuElement(MENU_ELEMENT_INTERACTION_INCREASE);
 
 
2238
                InputIsDebounced = 0;
 
 
2239
            }
 
 
2240
            else
 
 
2241
            {
 
 
2242
                KeyDepressedCounter += RealFrameTime;
 
 
2243
            }
 
 
2244
        }
 
 
2245
        else if (Keyboard[SDLK_BACKSPACE]) 
 
 
2246
        {
 
 
2247
            switch (Menus.MenuElements[Menus.CurrentlySelectedElement].ElementID)
 
 
2248
            {
 
 
2249
                case MENU_ELEMENT_KEYCONFIG:
 
 
2250
                {
 
 
2251
                    if (!KeyConfigSelectionColumn)
 
 
2252
                    {
 
 
2253
                        *( ((uint8_t*)&PlayerInputPrimaryConfig) + Menus.CurrentlySelectedElement-2) = "fix";
 
 
2254
                    }
 
 
2255
                    else // changing Secondary
 
 
2256
                    {
 
 
2257
                        *( ((uint8_t*)&PlayerInputSecondaryConfig) + Menus.CurrentlySelectedElement-2) = "fix";
 
 
2258
                    }
 
 
2259
                    break;
 
 
2260
                }
 
 
2261
                case MENU_ELEMENT_LOADMPCONFIG :
 
 
2262
                {
 
 
2263
                    //take note of the current configuration
 
 
2264
                    MultiplayerConfigurationIndex = Menus.CurrentlySelectedElement;
 
 
2265
                    MultiplayerConfigurationName = Menus.MenuElements[Menus.CurrentlySelectedElement].c.TextPtr;
 
 
2266
                    //setup the delete configuration menu
 
 
2267
                }
 
 
2268
                default:
 
 
2269
                break;
 
 
2270
            }
 
 
2271
        }
 
 
2272
        else  
 
 
2273
        {
 
 
2274
            InputIsDebounced = 1;
 
 
2275
            KeyDepressedCounter = 0;
 
 
2276
        }
 
 
2277
 
 
 
2278
        if (KeyDepressedCounter > ONE_FIXED)
 
 
2279
            InputIsDebounced = 1;
 
 
2280
    }
 
 
2281
}
 
 
2282
 
 
 
2283
static void CheckForKeysWithMultipleAssignments()
 
 
2284
{
 
 
2285
    SDLKey *configPtr[2];
 
 
2286
    int column,row;
 
 
2287
 
 
 
2288
    configPtr[0] = (SDLKey*)&PlayerInputPrimaryConfig;
 
 
2289
    configPtr[1] = (SDLKey*)&PlayerInputSecondaryConfig;
 
 
2290
 
 
 
2291
    for (column=0; column <= 1; column++)
 
 
2292
    {
 
 
2293
        for (row=0; row < 32; row++)
 
 
2294
        {
 
 
2295
            int innerColumn,innerRow;
 
 
2296
 
 
 
2297
            MultipleAssignments[column][row] = 0;
 
 
2298
 
 
 
2299
            for (innerColumn=0; innerColumn<=1; innerColumn++)
 
 
2300
            for (innerRow=0; innerRow<32; innerRow++)
 
 
2301
            {
 
 
2302
                if (innerRow==row) continue;
 
 
2303
                // && innerColumn==column) continue;
 
 
2304
                if ( (configPtr[column])[row]==(configPtr[innerColumn])[innerRow] )
 
 
2305
                {
 
 
2306
                    MultipleAssignments[column][row] = 1;
 
 
2307
                }
 
 
2308
            }
 
 
2309
        }
 
 
2310
    }
 
 
2311
}
 
 
2312
 
 
 
2313
static void TestValidityOfCheatMenu()
 
 
2314
{
 
 
2315
    CheatMode_GetNextAllowedMode(Menus.MenuElements[0].c.SliderValuePtr, 1);
 
 
2316
    CheatMode_GetNextAllowedSpecies(Menus.MenuElements[1].c.SliderValuePtr, 1);
 
 
2317
    CheatMode_GetNextAllowedEnvironment(Menus.MenuElements[2].c.SliderValuePtr, 1);
 
 
2318
}
 
 
2319
 
 
 
2320
static void RenderScrollyMenu()
 
 
2321
{
 
 
2322
    MENU_ELEMENT *elementPtr = Menus.MenuElements;
 
 
2323
    int i;
 
 
2324
    int y;
 
 
2325
    int first = Menus.CurrentlySelectedElement;
 
 
2326
    int last = Menus.CurrentlySelectedElement;
 
 
2327
    int available_above = (MENU_HEIGHT-HeightOfMenuElement(&elementPtr[Menus.CurrentlySelectedElement]))/2;
 
 
2328
    int available_below = available_above;
 
 
2329
    int done = 0;
 
 
2330
 
 
 
2331
    //work out the first and last element to be drawn
 
 
2332
    do
 
 
2333
    {
 
 
2334
        done = 1;
 
 
2335
 
 
 
2336
        if(first-1 >= 0)
 
 
2337
        {
 
 
2338
            int h = HeightOfMenuElement(&elementPtr[first-1]);
 
 
2339
 
 
 
2340
            if(h <= available_above)
 
 
2341
            {
 
 
2342
                available_above -= h;
 
 
2343
                first--;
 
 
2344
                done = 0;
 
 
2345
            }
 
 
2346
            else
 
 
2347
            {
 
 
2348
                available_below += available_above;
 
 
2349
                available_above = 0;
 
 
2350
            }
 
 
2351
        }
 
 
2352
 
 
 
2353
        if(!first)
 
 
2354
        {
 
 
2355
            //no more elements above selected element
 
 
2356
            available_below += available_above;
 
 
2357
            available_above = 0;
 
 
2358
        }
 
 
2359
 
 
 
2360
        if(last+1 < Menus.NumberOfElementsInMenu)
 
 
2361
        {
 
 
2362
            int h = HeightOfMenuElement(&elementPtr[last+1]);
 
 
2363
 
 
 
2364
            if(h <= available_below)
 
 
2365
            {
 
 
2366
                available_below -= h;
 
 
2367
                last++;
 
 
2368
                done = 0;
 
 
2369
            }
 
 
2370
        }
 
 
2371
 
 
 
2372
        if(last == (Menus.NumberOfElementsInMenu-1))
 
 
2373
        {
 
 
2374
            //no more elements below selected element
 
 
2375
            available_above += available_below;
 
 
2376
            available_below = 0;
 
 
2377
        }
 
 
2378
 
 
 
2379
    } while(!done);
 
 
2380
 
 
 
2381
    //draw the appropriate elements
 
 
2382
    elementPtr = &elementPtr[first];
 
 
2383
    y = MENU_TOPY;
 
 
2384
 
 
 
2385
    for(i=first; i <= last; i++, elementPtr++)
 
 
2386
    {
 
 
2387
        elementPtr->Brightness = (i == Menus.CurrentlySelectedElement) ? BRIGHTNESS_OF_HIGHLIGHTED_ELEMENT : BRIGHTNESS_OF_DARKENED_ELEMENT;
 
 
2388
        RenderMenuElement(elementPtr, i, y);
 
 
2389
        y += HeightOfMenuElement(elementPtr);
 
 
2390
    }
 
 
2391
}
 
 
2392
 
 
 
2393
static int ActualGammaSetting = -1;
 
 
2394
unsigned char GammaValues[256];
 
 
2395
 
 
 
2396
static void UpdateGammaSettings()
 
 
2397
{
 
 
2398
    if (UserProfile.GammaSetting != ActualGammaSetting) 
 
 
2399
    {
 
 
2400
        int i;
 
 
2401
 
 
 
2402
        for (i=0; i <= 255; i++)
 
 
2403
        {
 
 
2404
            int u = ((i*65536)/255);
 
 
2405
            int m = MUL_FIXED(u,u);
 
 
2406
            int l = MUL_FIXED(2*u,ONE_FIXED-u);
 
 
2407
 
 
 
2408
            int a = m + MUL_FIXED(UserProfile.GammaSetting*256,l);
 
 
2409
 
 
 
2410
            m = MUL_FIXED(a,a);
 
 
2411
            l = MUL_FIXED(2*a, ONE_FIXED-a);
 
 
2412
 
 
 
2413
            a = m/256 + MUL_FIXED(UserProfile.GammaSetting,l);
 
 
2414
 
 
 
2415
            GammaValues[i]= (a < 0) ? 0 : (a > 255) ? 255 : a;
 
 
2416
        }
 
 
2417
 
 
 
2418
        ActualGammaSetting = UserProfile.GammaSetting;
 
 
2419
    }
 
 
2420
}
 
 
2421
 
 
 
2422
static void UpdateMenus()
 
 
2423
{
 
 
2424
    switch (Menus.CurrentMenu)
 
 
2425
    {
 
 
2426
        case MENU_LOADGAME:
 
 
2427
            RenderLoadSaveGameMenu(0);
 
 
2428
        break;
 
 
2429
        case MENU_SAVEGAME:
 
 
2430
            if(!PlayerStatus.Alive)
 
 
2431
            {
 
 
2432
                RenderSmallMenuText("No save in when dead.", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
2433
            }
 
 
2434
            else if(CHEATMODE_NONACTIVE != UserProfile.active_bonus)
 
 
2435
            {
 
 
2436
                RenderSmallMenuText("No save in cheat/debug mode.", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
2437
            }
 
 
2438
            else if(PlayerStatus.saves_left < 1)
 
 
2439
            {
 
 
2440
                RenderSmallMenuText("No saves left.", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
2441
            }
 
 
2442
            else
 
 
2443
            {
 
 
2444
                RenderLoadSaveGameMenu(1);
 
 
2445
            }
 
 
2446
        break;
 
 
2447
        case MENU_SELECT_EPISODE:
 
 
2448
            switch(AvP.PlayerType)
 
 
2449
            {
 
 
2450
                default:
 
 
2451
                case I_Alien:
 
 
2452
                    RenderEpisodeSelectMenu(MAX_NO_OF_BASIC_ALIEN_EPISODES, alien_episodes);
 
 
2453
                break;
 
 
2454
                case I_Marine:
 
 
2455
                    RenderEpisodeSelectMenu(MAX_NO_OF_BASIC_MARINE_EPISODES, marine_episodes);
 
 
2456
                break;
 
 
2457
                case I_Predator:
 
 
2458
                    RenderEpisodeSelectMenu(MAX_NO_OF_BASIC_PREDATOR_EPISODES, predator_episodes);
 
 
2459
            }
 
 
2460
        break;
 
 
2461
        case MENU_ALIENKEYCONFIG:
 
 
2462
        case MENU_MARINEKEYCONFIG:
 
 
2463
        case MENU_PREDATORKEYCONFIG:
 
 
2464
            CheckForKeysWithMultipleAssignments();
 
 
2465
            RenderKeyConfigurationMenu();
 
 
2466
        break;
 
 
2467
        case MENU_SKIRMISH:
 
 
2468
            RenderSmallMenuText("Skirmish", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
2469
            RenderScrollyMenu();
 
 
2470
        break;
 
 
2471
        case MENU_MULTIPLAYER_HOSTSETUP:
 
 
2472
            RenderSmallMenuText("Multiplayer Configuration", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
2473
            RenderScrollyMenu();
 
 
2474
        break;
 
 
2475
        //case MENU_MULTIPLAYER_CONFIG_JOIN: RenderScrollyMenu(); break;
 
 
2476
        //case MENU_MULTIPLAYER_LOADCONFIG:
 
 
2477
            //RenderSmallMenuText("Load Configuration", ScreenDescriptorBlock.SDB_CentreX, 70, ONE_FIXED, MENUFORMAT_CENTREJUSTIFIED);
 
 
2478
            //RenderScrollyMenu();
 
 
2479
        break;
 
 
2480
        case MENU_AUDIOVIDEOOPTIONS:
 
 
2481
        {
 
 
2482
            if(3 == Menus.CurrentlySelectedElement)
 
 
2483
                SoundSys_ChangeVolume(MUL_FIXED(UserProfile.EffectsSoundVolume, MasterVolumeFadeLevel));
 
 
2484
            else if(5 == Menus.CurrentlySelectedElement)
 
 
2485
                UpdateGammaSettings();
 
 
2486
 
 
 
2487
            int scale = DIV_FIXED(ScreenDescriptorBlock.SDB_Height, ScreenDescriptorBlock.SDB_Width);
 
 
2488
            int h = scale/2048;
 
 
2489
            int offset = scale/4096;
 
 
2490
            DrawColourBar(offset, offset+h,  ONE_FIXED, 0, 0);
 
 
2491
            DrawColourBar(offset*2+h, offset*2+h*2,  0, ONE_FIXED, 0);
 
 
2492
            DrawColourBar(ScreenDescriptorBlock.SDB_Height - offset*2-h*2, ScreenDescriptorBlock.SDB_Height - offset*2-h,  0, 0, ONE_FIXED);
 
 
2493
            DrawColourBar(ScreenDescriptorBlock.SDB_Height - offset-h, ScreenDescriptorBlock.SDB_Height - offset, ONE_FIXED, ONE_FIXED, ONE_FIXED);
 
 
2494
            RenderMenu();
 
 
2495
        }
 
 
2496
        break;
 
 
2497
        case MENU_BONUSOPTIONS:
 
 
2498
            TestValidityOfCheatMenu();
 
 
2499
            RenderMenu();
 
 
2500
        break;
 
 
2501
        /*
 
 
2502
        case MENU_MULTIPLAYER_DELETECONFIG:
 
 
2503
            //show the name of the configuration we're trying to delete
 
 
2504
            RenderSmallMenuText(MultiplayerConfigurationName,ScreenDescriptorBlock.SDB_CentreX,MENU_CENTREY-100,ONE_FIXED,MENUFORMAT_CENTREJUSTIFIED);
 
 
2505
        break;
 
 
2506
        */
 
 
2507
        default:
 
 
2508
            RenderMenu();
 
 
2509
    }
 
 
2510
 
 
 
2511
    ActUponUsersInput();
 
 
2512
}
 
 
2513
 
 
 
2514
int MainMenus()
 
 
2515
{
 
 
2516
    extern void SetDefaultNetStruct();
 
 
2517
 
 
 
2518
    SetDefaultNetStruct();
 
 
2519
    UpdateGammaSettings();
 
 
2520
    UserProfile.active_bonus = CHEATMODE_NONACTIVE;
 
 
2521
 
 
 
2522
    if(AvP.LevelCompleted)
 
 
2523
    {
 
 
2524
        if (UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[episode_to_play] < AvP.Difficulty)
 
 
2525
        {
 
 
2526
            UserProfile.LevelCompleted[AvP.PlayerType].Difficulty[episode_to_play] = AvP.Difficulty;
 
 
2527
            SaveUserProfile();
 
 
2528
        }
 
 
2529
 
 
 
2530
        SetupNewMenu(MENU_SELECT_EPISODE);
 
 
2531
        AvP.LevelCompleted = 0;
 
 
2532
    }
 
 
2533
    else
 
 
2534
    {
 
 
2535
        SetupNewMenu(MENU_MAIN);
 
 
2536
    }
 
 
2537
 
 
 
2538
    Menus.MenusState = MENUSSTATE_MAINMENUS;
 
 
2539
    MakeOptionsMenu(0);
 
 
2540
 
 
 
2541
    do
 
 
2542
    {
 
 
2543
        glClear(GL_COLOR_BUFFER_BIT);
 
 
2544
        read_user_input();
 
 
2545
        UpdateMenus();
 
 
2546
        SDL_GL_SwapBuffers();
 
 
2547
        FrameCounterHandler();
 
 
2548
        SoundSys_Management();
 
 
2549
 
 
 
2550
    } while(Menus.MenusState == MENUSSTATE_MAINMENUS);
 
 
2551
 
 
 
2552
    SoundSys_StopAll();
 
 
2553
 
 
 
2554
return (Menus.MenusState == MENUSSTATE_STARTGAME);
 
 
2555
}
 
 
2556
 
 
 
2557
void TriggerInGameMenus()
 
 
2558
{
 
 
2559
    Menus.MenusState = MENUSSTATE_INGAMEMENUS;
 
 
2560
    MakeOptionsMenu(1);
 
 
2561
    SetupNewMenu(MENU_INGAME);
 
 
2562
    SoundSys_StopAll();
 
 
2563
 
 
 
2564
    do
 
 
2565
    {
 
 
2566
        FrameCounterHandler();
 
 
2567
        glClear(GL_COLOR_BUFFER_BIT);
 
 
2568
        read_user_input();
 
 
2569
        UpdateMenus();
 
 
2570
        SDL_GL_SwapBuffers();
 
 
2571
 
 
 
2572
    } while(Menus.MenusState == MENUSSTATE_INGAMEMENUS);
 
 
2573
}