-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFrontEnd.cpp
More file actions
1633 lines (1336 loc) · 42.7 KB
/
Copy pathFrontEnd.cpp
File metadata and controls
1633 lines (1336 loc) · 42.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "Common.h"
#include "FrontEnd.h"
#include "EventManager.h"
#include "CLIParams.h"
#include "Platform.h"
#include "SoundManager.h"
#include "Music.h"
#include "Career.h"
#include "RenderInfo.h"
#include "SpriteRenderer.h"
#include "engine.h"
#include "meshrenderer.h"
#include "BattleEngineDataManager.h"
#include "WorldPhysicsManager.h"
#include "FEMessBox.h"
#include "memorycard.h"
#include "reconnectinterface.h"
#include "endleveldata.h"
#include "Game.h"
#if TARGET == PS2
#include "PS2Profiler.h"
#endif
//*********************************************************************************
extern SINT performing_stress_test;
//*********************************************************************************
CFrontEnd::CFrontEnd(void)
:
mAutoSave(CFrontEnd::AUTO_SAVE_NOT),
mFirstRun(TRUE),
mSelectedLevel(-1),
mAllLevelsCheatActive(FALSE)
{
mSaveFilename[0] = 0;
mPlayer0ControllerPort = -1;
}
// slightly different loading speeds on the different platforms.
#define LOADING_STEP_1 80
#define LOADING_STEP_2 90
#define LOADING_STEP_3 100
//*********************************************************************************
BOOL CFrontEnd::Init(EFrontEndEntry entry,BOOL inLoadedSystem)
{
CONSOLE.SetLoading(TRUE);
if (inLoadedSystem)
CONSOLE.SetLoadingRange( 50.f, 62.5f );
else
CONSOLE.SetLoadingRange( 0.f, 25.f );
#if TARGET == XBOX
// Let's get the sounds for the frontend.
if (CLIPARAMS.mSound)
SOUND.LoadXAPFile();
#endif
EVENT_MANAGER.Init() ;
// CAREER.Test();
CAREER.Update() ;
if (inLoadedSystem)
CONSOLE.SetLoadingRange( 62.5f, LOADING_STEP_1/2+50.0f );
else
CONSOLE.SetLoadingRange( 25.f, LOADING_STEP_1 );
// Initialise Data
if (!FED.Init())
return FALSE;
if (!FET.Init())
return FALSE;
if (inLoadedSystem)
CONSOLE.SetLoadingRange( LOADING_STEP_1/2+50.0f, LOADING_STEP_2/2+50.0f );
else
CONSOLE.SetLoadingRange( LOADING_STEP_1, LOADING_STEP_2 );
if (!FEV.Init())
return FALSE;
// Memory cards
MEMORYCARD.Initialise();
// Initialise the messagebox class
FEMESSBOX.Init();
if (inLoadedSystem)
CONSOLE.SetLoadingRange( LOADING_STEP_2/2+50.0f, LOADING_STEP_3/2+50.0f );
else
CONSOLE.SetLoadingRange( LOADING_STEP_2, LOADING_STEP_3 );
// Build pointer list for pages
SINT c0;
// fill with unknown to start with.
for (c0 = 0; c0 < FEP_NUM_PAGES; c0 ++)
mPages[c0] = &mFEPUnknown;
// and the actual pages
mPages[FEP_MAIN] = &mFEPMain;
mPages[FEP_DEVELOPMENT] = &mFEPDevelopment;
mPages[FEP_COMMON] = &mFEPCommon;
mPages[FEP_BE_CONFIG] = &mFEPBEConfig;
mPages[FEP_WINGMEN] = &mFEPWingmen;
mPages[FEP_BRIEFING] = &mFEPBriefing;
mPages[FEP_DEBRIEFING] = &mFEPDebriefing;
mPages[FEP_LEVEL_SELECT] = &mFEPLevelSelect;
mPages[FEP_GOODIES] = &mFEPGoodies;
mPages[FEP_DEVSELECT] = &mFEPDevSelect;
mPages[FEP_LOADGAME] = &mFEPLoadGame;
mPages[FEP_SAVEGAME] = &mFEPSaveGame;
mPages[FEP_INTRO] = &mFEPIntro;
mPages[FEP_MULTIPLAYER] = &mFEPMultiplayer;
mPages[FEP_MULTIPLAYER_START] = &mFEPMultiplayerStart;
mPages[FEP_OPTIONS] = &mFEPOptions;
mPages[FEP_CREDITS] = &mFEPCredits;
mPages[FEP_CONTROLLER] = &mFEPController;
mPages[FEP_VIRTUAL_KEYBOARD] = &mFEPVirtualKeyboard;
mPages[FEP_DIRECTORY] = &mFEPDirectory;
mPages[FEP_E3_LEVEL_SELECT] = &mFEPE3LevelSelect;
mPages[FEP_LANGUAGE_TEST] = &mFEPLanguageTest;
mPages[FEP_DEMOMAIN] = &mFEPDemoMain;
mPages[FEP_UNKNOWN] = &mFEPUnknown;
// Initialise all pages
BOOL ok = TRUE;
for (c0 = 0; c0 < FEP_NUM_PAGES; c0 ++)
{
char buf[20];
sprintf(buf, "FEP %d...", c0);
TRACE(buf);
ok &= mPages[c0]->Init();
TRACE("done.\n");
CONSOLE.SetLoadingFraction(float(c0) / float(FEP_NUM_PAGES));
}
if (!ok)
return FALSE;
#ifdef E3BUILD
GAME.mSupervisorMode = FALSE; // for E3
CAREER.Blank();
#else
GAME.mSupervisorMode = TRUE; // for E3
#endif
// Controller Stuff
for (int port = 0; port < NUM_CONTROLLER_PORTS; port++)
mControllers[port]=new(MEMTYPE_CONTROLLER) CCONTROLLER(this,port);
PLATFORM.FlushInputBuffers(); // clear up keystrokes pressed while loading
// Other Data
mCounter = 0;
mQuit = -2;
mLastRenderTime = -100.f;
GAME.mRenderFrameNumber=0;
// start point
if (CLIPARAMS.mGoStraightToDeviceSelectScreen != -1)
{
// We were on the "new career" screen before we went to the xbox dashboard
mActivePage = FEP_UNKNOWN;
SetPage(FEP_DEVSELECT, 0);
FRONTEND.SetSaveMode(1);
FRONTEND.SetAutoSave(FRONTEND.AUTO_SAVE_NORMAL);
ASSERT(!CAREER.InProgress());
mFEPDevSelect.SetCurrentCard(CLIPARAMS.mGoStraightToDeviceSelectScreen);
}
else if (mFirstRun || entry == FEE_FROM_ATTRACT)
{
mFirstRun = FALSE;
if (!CLIPARAMS.mDeveloperMode)
{
mActivePage = FEP_UNKNOWN;
if (PLAYABLE_DEMO)
{
SetPage(FEP_INTRO, 0);
}
else
{
SetPage(FEP_INTRO, 0);
}
// SetPage(FEP_MAIN, 0);
// SetPage(FEP_LEVEL_SELECT, 0);
// SetPage(FEP_BRIEFING, 0);
// SetPage(FEP_DEBRIEFING, 0);
// SetPage(FEP_DEBRIEFING, 30);
}
else
{
mActivePage = FEP_UNKNOWN;
if (PLAYABLE_DEMO)
{
SetPage(FEP_INTRO, 0);
}
else
{
if (GAME.mSupervisorMode)
SetPage(FEP_MAIN, 0);
else
SetPage(FEP_INTRO, 0);
}
}
}
else if (entry == FEE_TITLE_SCREEN)
{
mActivePage = FEP_UNKNOWN;
SetPage(FEP_MAIN, 0);
}
else
{
if ((mSelectedLevel > 900) && (mSelectedLevel < 906)) // Race levels
mActivePage = FEP_GOODIES;
else if ((mSelectedLevel >= 850) && (mSelectedLevel < 880))
mActivePage = FEP_MULTIPLAYER;
else
{
// If it's not the first run, we should autosave.
#ifdef E3BUILD
mActivePage = FEP_INTRO;
#else
if (PLAYABLE_DEMO)
{
// mActivePage = FEP_DEMOMAIN;
if (CLIPARAMS.mAttractMode)
mActivePage=FEP_INTRO;
else
mActivePage = FEP_DEBRIEFING;
}
else
{
#if TARGET !=PC
if ((GetAutoSave() != AUTO_SAVE_PRETEND) && (performing_stress_test == 0))
{
// Save the damn thing.
FRONTEND.SetSaveMode(TRUE);
mActivePage = FEP_UNKNOWN;
SetPage(FEP_SAVEGAME, 0);
SetSuccessFEP(FEP_DEBRIEFING, 50);
}
else
{
mActivePage = FEP_DEBRIEFING;
}
#else
mActivePage = FEP_DEBRIEFING;
#endif
}
#endif
}
}
if (mActivePage != FEP_TRANSITION)
{
mPages[mActivePage]->TransitionNotification(FEP_COMMON);
mPages[mActivePage]->ActiveNotification(FEP_COMMON);
}
else
{
mPages[mTransitionTo]->TransitionNotification(FEP_COMMON);
// mPages[mTransitionTo]->ActiveNotification(FEP_COMMON);
}
// Selected Data
mSelectedLevel = 100;
#if TARGET == XBOX
char buf[200];
extern DWORD entry_time;
sprintf(buf, "Step 1 after %d ms\n", GetTickCount() - entry_time);
TRACE(buf);
#endif
#if TARGET == XBOX
sprintf(buf, "Step 2 after %d ms\n", GetTickCount() - entry_time);
TRACE(buf);
#endif
// Load and cache all the language Files
for (c0 = 0; c0 < NUM_LANGUAGES; c0 ++)
{
mTextSets[c0].Init();
mTextSets[c0].Load(c0);
}
if (inLoadedSystem)
CONSOLE.SetLoadingRange( LOADING_STEP_2/2+50.0f, 100.f );
else
CONSOLE.SetLoadingRange( LOADING_STEP_2, 100.f );
#if TARGET == XBOX
sprintf(buf, "Step 3 after %d ms\n", GetTickCount() - entry_time);
TRACE(buf);
// let's get the frontend music track in place.
PLATFORM.CacheFile(MUSIC.GetSong(MUSIC.GetTrackForFrontEnd())->mFilename);
CONSOLE.SetLoadingFraction(.5f);
PLATFORM.CacheFile(MUSIC.GetSong(MUSIC.GetTrackForCredits ())->mFilename);
CONSOLE.SetLoadingFraction(1.f);
#endif
CONSOLE.SetLoading(FALSE);
#ifndef TEXT_RESOURCE_TEST_BUILD
// Start the music
if (CLIPARAMS.mMusic)
MUSIC.PlaySelection(MUS_FRONTEND);
#endif
#if TARGET == XBOX
sprintf(buf, "Step 4 after %d ms\n", GetTickCount() - entry_time);
TRACE(buf);
#endif
return TRUE;
}
//*********************************************************************************
#define READWRITE(t, saving, file)\
{\
if (saving)\
{\
fwrite(&(t), sizeof(t), 1, file);\
}\
else\
{\
fread (&(t), sizeof(t), 1, file);\
}\
}
bool CFrontEnd::SerialiseState(FILE *file, bool saving)
{
// only needed for the Xbox reboot!
#if TARGET == XBOX
// we'll try to share loading and saving code so that I don't get them out of sync.
READWRITE(mSaveMode , saving, file);
READWRITE(mAutoSave , saving, file);
READWRITE(mMemoryCardNumber , saving, file);
READWRITE(mFEPSaveGame.mSaveGameName, saving, file);
READWRITE(mSelectedLevel , saving, file);
READWRITE(END_LEVEL_DATA , saving, file);
READWRITE(mPlayer0ControllerPort , saving, file);
MEM_MANAGER.Validate();
if (!saving)
{
wcscpy(mFEPVirtualKeyboard.m_strData, mFEPSaveGame.mSaveGameName);
mFEPDevSelect.SetCurrentCard(mMemoryCardNumber);
}
#endif
return true;
}
//*********************************************************************************
void CFrontEnd::Shutdown()
{
// Stop the music
if (CLIPARAMS.mMusic)
MUSIC.Stop();
// Memory cards
MEMORYCARD.Shutdown();
// free up the text
SINT c0;
for (c0 = 0; c0 < NUM_LANGUAGES; c0 ++)
{
mTextSets[c0].Shutdown();
}
IController::Shutdown();
// Send final deactivation Notification
if (mActivePage == FEP_TRANSITION)
{
mPages[mTransitionFrom]->DeActiveNotification();
mPages[mTransitionTo]->DeActiveNotification();
}
else
mPages[mActivePage]->DeActiveNotification();
// Shutdown all pages
for (c0 = 0; c0 < FEP_NUM_PAGES; c0 ++)
mPages[c0]->Shutdown();
// Shutdown FMV
FEV.Shutdown();
FET.Shutdown();
// Shutdown Data
#if TARGET == XBOX
LT.BlockUntilIdle(); // make sure we're not still rendering..
#endif
FED.Shutdown();
// Shutdown Controller
for (int port = 0; port < NUM_CONTROLLER_PORTS; port++)
{
delete mControllers[port];
mControllers[port]=NULL;
}
// Shutdown System Stuff
EVENT_MANAGER.Shutdown();
CONSOLE.ClearCommandsAndVariables();
// Clean up memory.
MEM_MANAGER.SetMerge( TRUE );
MEM_MANAGER.Cleanup();
}
//*********************************************************************************
int CFrontEnd::GetPlayer0ControllerPort()
{
if (mPlayer0ControllerPort == -1) return 0;
return mPlayer0ControllerPort;
}
//*********************************************************************************
int CFrontEnd::GetPortFromController(CController *controller)
{
for (int i = 0; i < NUM_CONTROLLER_PORTS; i++)
{
if (controller == mControllers[i]) return i;
}
// Not found, what the hell.
return 0;
}
//*********************************************************************************
int CFrontEnd::NumControllersPresent()
{
int retval = 0;
for (int i = 0; i < NUM_CONTROLLER_PORTS; i++)
{
if (mControllers[i]->IsPresent()) retval++;
}
return retval;
}
//*********************************************************************************
void CFrontEnd::ReceiveButtonAction(CController* from_controller, int button, float val)
{
// We make decisions about which controller is which player.
// The first person to press anything is player 0.
#if TARGET == PS2
if (mPlayer0ControllerPort == -1 && button == BUTTON_START)
#else
if (mPlayer0ControllerPort == -1 && button == BUTTON_FRONTEND_MENU_SELECT)
#endif
{
// He can be this.
mPlayer0ControllerPort = GetPortFromController(from_controller);
}
else
if (mPlayer0ControllerPort != -1)
{
// There was a player 0 controller already. It may not be this one,
// in which case we ignore inputs
// Unless we're in the multiplayer start screen which understands multiple controllers.
if (mActivePage != FEP_MULTIPLAYER_START && GetPortFromController(from_controller) != mPlayer0ControllerPort) return;
}
// globally remember the current controller.
mReceivingButtonActionPort = GetPortFromController(from_controller);
#if TARGET==PC
// SRG temporay allow to save career
if (button == BUTTON_SAVE_CAREER)
{
CAREER.Save() ;
}
if (button == BUTTON_LOAD_CAREER)
{
CAREER.Load() ;
}
if (button == BUTTON_LOG_CAREER)
{
CAREER.Log() ;
}
// SRG end hack
#endif
mAllLevelsCheatActive = TRUE;
if ((button == BUTTON_FRONTEND_CHEAT) &&
(mActivePage != FEP_TRANSITION))
{
mAllLevelsCheatActive = TRUE;
#ifndef E3BUILD
mAllLevelsCheatActive=!mAllLevelsCheatActive;
mPages[mActivePage]->ButtonPressed(button, val);
#else
if (GAME.mSupervisorMode)
{
SetPage(FEP_INTRO, 0);
GAME.mSupervisorMode = FALSE;
}
else
{
SetPage(FEP_LEVEL_SELECT, 0);
GAME.mSupervisorMode = TRUE;
mAllLevelsCheatActive = TRUE;
}
#endif
}
else if (FEMESSBOX.BeingDisplayed())
{
// If a message box is being displayed, then redirect the input into that
FEMESSBOX.ButtonPressed(button, val);
}
else
{
// Pass Button Action on to page
if (mActivePage != FEP_TRANSITION)
mPages[mActivePage]->ButtonPressed(button, val);
}
}
//*********************************************************************************
void CFrontEnd::SetLanguage(SINT l)
{
TEXT_DB.Copy(mTextSets[l]);
}
//*********************************************************************************
void CFrontEnd::SetPage(EFrontEndPage page, SINT time)
{
// ASSERT(mActivePage != FEP_TRANSITION); // !JS! I commented this out
// Shouldn't happen...
if (mActivePage == FEP_TRANSITION)
mActivePage = mTransitionFrom;
if (time == 0)
{
mPages[mActivePage]->DeActiveNotification();
// go straight there
mPages[page]->TransitionNotification(mActivePage);
mPages[page]->ActiveNotification(mActivePage);
mActivePage = page;
}
else
{
// Setup Transition Parameters
mTransitionFrom = mActivePage;
mTransitionTo = page;
mTransitionCount = 0;
mTransitionTime = time;
mActivePage = FEP_TRANSITION;
mPages[mTransitionTo]->TransitionNotification(mTransitionFrom);
}
}
//*********************************************************************************
void CFrontEnd::Process()
{
mCounter ++;
// Start / stop profiling - there's no doubt somewhere better for this!
#if TARGET == PS2
#ifdef PROFILE
if(PLATFORM.KeyOnce(KEYCODE_F9))
{
PS2PROFILER.SetProfileEnabled( !PS2PROFILER.GetProfileEnabled() );
if (PS2PROFILER.GetProfileEnabled())
TRACE("Profiler on\n");
else
TRACE("Profiler off\n");
}
#endif
#endif
//System Stuff
EQuitType q = PLATFORM.Process();
// We need to check if we have to quit due to user inactivity (will only happen in playable demo.
if (CController::InactivityMeansQuitGame())
{
#if TARGET==PS2
CLIPARAMS.mAttractMode=TRUE;
#else
q = QT_QUIT_TO_SYSTEM;
#endif
}
#if TARGET==PS2
if (PLATFORM.HasTimeoutExpired())
{
q=QT_QUIT_TO_SYSTEM;
}
#endif
if (q != QT_NONE)
mQuit = -1;
EVENT_MANAGER.Update() ;
PARTICLE_MANAGER.Process(1.f, TRUE);
SOUND.UpdateStatus();
MUSIC.UpdateStatus();
// Update controller
for (int port = 0; port < NUM_CONTROLLER_PORTS; port++)
mControllers[port]->Flush();
// Update Video, but don't wait for the next frame of the video
#if TARGET!=PS2
FEV.NextFrame(false);
#endif
// We need to process insertion and removal of controllers
if (mPlayer0ControllerPort != -1)
{
// As soon as someone has control, he's stuck with it. So you can't pull it out and then expect to
// control the frontend with another controller. This is because I don't want to silently
// not mind about controller unplugging.
if (!RECONNECT_INTERFACE[0].Process(mControllers[mPlayer0ControllerPort], false) && RECONNECT_INTERFACE[0].GetState() != CReconnectInterface::OK)
{
// we're still unconnected. So no frontend processing thanks.
return;
}
}
// deal with transitions
if (mActivePage == FEP_TRANSITION)
{
mTransitionCount ++;
if (mTransitionCount == mTransitionTime)
{
mPages[mTransitionFrom]->DeActiveNotification();
mActivePage = mTransitionTo;
mPages[mActivePage]->ActiveNotification(mTransitionFrom);
}
}
// process pages
SINT c0;
for (c0 = 0; c0 < FEP_NUM_PAGES; c0 ++)
{
EFEPState state = FEPS_INACTIVE;
if (mActivePage == c0)
state = FEPS_ACTIVE;
else if (mActivePage == FEP_TRANSITION)
{
if (c0 == mTransitionFrom)
state = FEPS_TRANSITIONING_FROM;
if (c0 == mTransitionTo)
state = FEPS_TRANSITIONING_TO;
}
mPages[c0]->Process(state);
}
// Process the messagebox
FEMESSBOX.Process();
// Keyboard Mappings
//!! Definitly shouldn't be here. the Controller stuff is shit...
// if (PLATFORM.KeyOnce(KEYCODE_DOWN))
// ReceiveButtonAction(BUTTON_FRONTEND_MENU_DOWN, 0);
// if (PLATFORM.KeyOnce(KEYCODE_UP))
// ReceiveButtonAction(BUTTON_FRONTEND_MENU_UP, 0);
// if (PLATFORM.KeyOnce(KEYCODE_RETURN))
// ReceiveButtonAction(BUTTON_FRONTEND_MENU_SELECT, 0);
}
//*********************************************************************************
#define LINE_SPRITE_SIZE 32.f
void CFrontEnd::DrawLine(float sx, float sy, float ex, float ey, DWORD col, float width, float depth, float perc)
{
// essentially a dodgy line draw
float dx = ex - sx;
float dy = ey - sy;
float cx = (sx + ex) / 2;
float cy = (sy + ey) / 2;
float yaw = atan2f(dy, dx);
float xscale = sqrtf(dx * dx + dy * dy) / LINE_SPRITE_SIZE * perc;
float yscale = width / LINE_SPRITE_SIZE / 2.f;
RENDERINFO.SetFogEnabled(FALSE);
CSPRITERENDERER::DrawColouredSprite(cx, cy, depth, FED.GetTexture(FET_LEVEL_LINK),col, xscale, yscale, SA_CENTRE, SPT_NONE, 1.f, yaw);
}
//*********************************************************************************
void CFrontEnd::DrawBox(float tlx, float tly, float brx, float bry, DWORD col, float width, float depth)
{
DrawLine( tlx, tly, brx, tly, col, width, depth, 1.0f );
DrawLine( brx, tly, brx, bry, col, width, depth, 1.0f );
DrawLine( brx, bry, tlx, bry, col, width, depth, 1.0f );
DrawLine( tlx, bry, tlx, tly, col, width, depth, 1.0f );
}
//*********************************************************************************
#define BLANK_PANEL_SIZE ( 16.0f )
void CFrontEnd::DrawPanel(float tlx, float tly, float brx, float bry, float z, DWORD col)
{
RENDERINFO.STS(0, TSS_ADDRESSU, TADDRESS_CLAMP);
RENDERINFO.STS(0, TSS_ADDRESSV, TADDRESS_CLAMP);
RENDERINFO.SetFogEnabled(FALSE);
CSPRITERENDERER::DrawColouredSprite(tlx, tly, z, FED.GetTexture(FET2_BLANK), col, ((brx - tlx) / BLANK_PANEL_SIZE), ((bry - tly) / BLANK_PANEL_SIZE), SA_TOP_LEFT);
RENDERINFO.STS(0, TSS_ADDRESSU, TADDRESS_WRAP);
RENDERINFO.STS(0, TSS_ADDRESSV, TADDRESS_WRAP);
}
//*********************************************************************************
void CFrontEnd::DrawBarGraph(float tlx, float tly, float brx, float bry, float num, float max, float z, SINT bordercol, SINT backcol, SINT forecol)
{
// Draw background
DrawPanel(tlx, tly, brx, bry, z, backcol);
// Draw bar
if (num)
{
DrawPanel(tlx, tly, tlx + ((brx - tlx) * (num / max)), bry, z, forecol);
}
}
//*********************************************************************************
// does this page have the curve on either side?
static BOOL got_standard_SlidingTextBordersAndMask(EFrontEndPage dest)
{
switch(dest)
{
case FEP_DEVSELECT:
case FEP_DIRECTORY:
case FEP_GOODIES:
case FEP_LEVEL_SELECT:
case FEP_LOADGAME:
case FEP_MULTIPLAYER:
// case FEP_MULTIPLAYER_START:
case FEP_SAVEGAME:
case FEP_VIRTUAL_KEYBOARD:
case FEP_CONTROLLER:
return TRUE;
default:
return FALSE;
}
}
BOOL check_draw_twice(EFrontEndPage cp, EFrontEndPage dest)
{
if (got_standard_SlidingTextBordersAndMask(cp) && got_standard_SlidingTextBordersAndMask(dest))
return SINT(dest) > SINT(cp); // cheeky!
else
return FALSE;
}
void CFrontEnd::DrawSlidingTextBordersAndMask(float transition, EFrontEndPage dest)
{
EFrontEndPage from = FEP_UNKNOWN;
// make sure we don't draw it twice...
if (GetCurrentPage() == FEP_TRANSITION)
{
from = GetTransitionTo() == dest ? GetTransitionFrom(): GetTransitionTo();
if (check_draw_twice(from, dest))
return;
}
float tr, scale, yaw;
SINT alpha;
DWORD col;
RENDERINFO.SetFogEnabled(false);
//*************************************************************************
// Sliding Text
if ((dest != FEP_BRIEFING) && (dest != FEP_DEBRIEFING) && (dest != FEP_MULTIPLAYER_START))
tr = RangeTransition(transition, 0.75f, 1.f);
else
tr = 1.f;
FRONTEND.GetCommonPage()->RenderSmallForsetiText(tr);
//*************************************************************************
// Metal Borders
#define SELECT_BRACKET_X 328
#define SELECT_BRACKET_Y 343
#define SELECT_BRACKET_SCALE 1.25f
#define SELECT_BRACKET_SCALE2 1.4f
if (got_standard_SlidingTextBordersAndMask(dest) && (from != FEP_VIRTUAL_KEYBOARD))
transition = 1.f;
/* else
if ((dest == FEP_BRIEFING) || (dest == FEP_DEBRIEFING))
tr = RangeTransition(transition, 0.25f, 1.f);
else
tr = RangeTransition(transition, 0.25f, 0.75f);*/
// Draw inside bracket
col = 0xffffffff;
alpha = 0xff;
scale = (GetCurrentPage() == FEP_VIRTUAL_KEYBOARD ? SELECT_BRACKET_SCALE2 : SELECT_BRACKET_SCALE);
yaw = 0.f;
if ((transition < 1.f) && (dest == FEP_MAIN))
{
if (transition < 0.2f)
{
alpha = 0;
}
if (transition < 0.5f)
{
tr = RangeTransition(transition, 0.2f, 0.5f);
alpha = MakeAlpha(tr);
scale = tr * 1.f;
yaw = -(tr * 0.3f);
}
else if (transition < 0.6f)
{
scale = 1.f;
}
else if (transition < 0.7f)
{
tr = RangeTransition(transition, 0.6f, 0.7f);
scale = Range(tr, 1.f, SELECT_BRACKET_SCALE);
}
}
else if ((transition < 1.f) && (from == FEP_VIRTUAL_KEYBOARD))
{
scale = CosResize(transition, SELECT_BRACKET_SCALE, SELECT_BRACKET_SCALE2);
}
else if (transition < 1.f)
{
tr = 1.f - RangeTransition(transition, 0.5f, 1.f);
alpha = MakeAlpha(1.f - tr);
scale = SELECT_BRACKET_SCALE + (tr * 1.4f);
yaw = -tr * 1.0f;
}
BlendAlpha(col, alpha);
CSPRITERENDERER::DrawColouredSprite(SELECT_BRACKET_X + 5 + FRONTEND.GetShadowOffsetX(), SELECT_BRACKET_Y + 10 + FRONTEND.GetShadowOffsetY(), FO(350), FED.GetTexture(FET3_SELECT_BRACKET1), BlendAlpha2(0x3F000000, alpha), scale * 1.05f, scale * 1.05f, SA_CENTRE, SPT_NONE, 1.f, yaw);
CSPRITERENDERER::DrawColouredSprite(SELECT_BRACKET_X, SELECT_BRACKET_Y, FO(200), FED.GetTexture(FET3_SELECT_BRACKET1), col, scale, scale, SA_CENTRE, SPT_NONE, 1.f, yaw);
float savescale = scale;
// Draw outside bracket
col = 0xffffffff;
alpha = 0xff;
scale = 1.f;
yaw = 0.f;
BOOL draw = FALSE;
if ((transition < 1.f) && (dest == FEP_MAIN))
{
if (transition < 0.2f)
{
}
if (transition < 0.5f)
{
tr = RangeTransition(transition, 0.2f, 0.5f);
alpha = MakeAlpha(tr);
scale = tr * 1.f;
yaw = -(tr * 0.3f);
draw = TRUE;
}
else if (transition < 0.7f)
{
scale = 1.f;
draw = TRUE;
}
else if (transition < 0.9f)
{
tr = 1.f - RangeTransition(transition, 0.7f, 0.9f);
alpha = MakeAlpha(tr);
scale = tr * 1.f;
yaw = -(tr * 0.3f);
draw = TRUE;
}
}
BlendAlpha(col, alpha);
if (draw)
{
CSPRITERENDERER::DrawColouredSprite(SELECT_BRACKET_X + 5 + FRONTEND.GetShadowOffsetX(), SELECT_BRACKET_Y + 10 + FRONTEND.GetShadowOffsetY(), FO(350), FED.GetTexture(FET3_SELECT_BRACKET2), BlendAlpha2(0x3F000000, alpha), scale * 1.05f, scale * 1.05f, SA_CENTRE, SPT_NONE, 1.f, yaw);
CSPRITERENDERER::DrawColouredSprite(SELECT_BRACKET_X, SELECT_BRACKET_Y, FO(200), FED.GetTexture(FET3_SELECT_BRACKET2), col, scale, scale, SA_CENTRE, SPT_NONE, 1.f, yaw);
}
/* if (got_standard_SlidingTextBordersAndMask(dest))
tr = 1.f;
else
if ((dest == FEP_BRIEFING) || (dest == FEP_DEBRIEFING))
tr = RangeTransition(transition, 0.25f, 1.f);
else
tr = RangeTransition(transition, 0.25f, 0.75f);
if (tr > 0)
{
if ((dest == FEP_BRIEFING) || (dest == FEP_DEBRIEFING))
{
tr = 2.f - tr;
scale = 1.f + ((tr - 1.f) * 1.f);
}
else
{
scale = (tr / 2.f) + 0.5f;
}
alpha = MakeAlpha(tr);
float yaw = (1.f - tr) * (PI / 2.f);
x = LEVEL_SELECT_LEFT_X;
y = LEVEL_SELECT_LEFT_Y;
if ((dest == FEP_BRIEFING) || (dest == FEP_DEBRIEFING))
Rotate2D(x, y, LEVEL_ROT_POINT2_X, LEVEL_ROT_POINT2_Y, yaw, scale);
else
Rotate2D(x, y, LEVEL_ROT_POINT_X, LEVEL_ROT_POINT_Y, yaw, scale);
// col = BlendAlpha2(0x3f000000, alpha);
// CSPRITERENDERER::DrawColouredSprite(x + 5 + FRONTEND.GetShadowOffsetX(), y + 10 + FRONTEND.GetShadowOffsetY(), FO(200), FED.GetTexture(FET2_LEVEL_SELECT_LEFT), col, scale * 1.05f, scale * 1.05f, SA_CENTRE, SPT_NONE, 1.f, yaw);
col = BlendAlpha2(0xffffffff, alpha);
CSPRITERENDERER::DrawColouredSprite(x, y, FO(100), FED.GetTexture(FET2_LEVEL_SELECT_LEFT), col, scale, scale, SA_CENTRE, SPT_NONE, 1.f, yaw);
x = LEVEL_SELECT_RIGHT_X;
y = LEVEL_SELECT_RIGHT_Y;
if ((dest == FEP_BRIEFING) || (dest == FEP_DEBRIEFING))
Rotate2D(x, y, LEVEL_ROT_POINT2_X, LEVEL_ROT_POINT2_Y, yaw, scale);
else
Rotate2D(x, y, LEVEL_ROT_POINT_X, LEVEL_ROT_POINT_Y, yaw, scale);
// col = BlendAlpha2(0x3f000000, alpha);
// CSPRITERENDERER::DrawColouredSprite(x + 5 + FRONTEND.GetShadowOffsetX(), y + 10 + FRONTEND.GetShadowOffsetY(), FO(200), FED.GetTexture(FET2_LEVEL_SELECT_RIGHT), col, scale * 1.05f, scale * 1.05f, SA_CENTRE, SPT_NONE, 1.f, yaw);
col = BlendAlpha2(0xffffffff, alpha);
CSPRITERENDERER::DrawColouredSprite(x, y, FO(100), FED.GetTexture(FET2_LEVEL_SELECT_RIGHT), col, scale, scale, SA_CENTRE, SPT_NONE, 1.f, yaw);
}
*/
// masks?
if (transition > 0.75f || (from == FEP_VIRTUAL_KEYBOARD))
{
RENDERINFO.SRS(RS_SRCBLEND, BLEND_ZERO);
RENDERINFO.SRS(RS_DESTBLEND, BLEND_ONE);
RENDERINFO.STS(0, TSS_ADDRESSU, TADDRESS_CLAMP);
RENDERINFO.STS(0, TSS_ADDRESSV, TADDRESS_CLAMP);
#if TARGET==PS2
RENDERINFO.SRS(RS_TEXCLAMPENABLE,TRUE);