-
Notifications
You must be signed in to change notification settings - Fork 2
/
menu.c
executable file
·2382 lines (2054 loc) · 101 KB
/
menu.c
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 <kernel.h>
#include <libmc.h>
#include <libpad.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <osd_config.h>
#include <timer.h>
#include <limits.h>
#include <fileXio_rpc.h>
#include <netman.h>
#include <wchar.h>
#include <gsKit.h>
#include "main.h"
#ifdef ENABLE_NETWORK_SUPPORT
#include <ps2ip.h>
#include <netman.h>
#endif
#include "pad.h"
#include "graphics.h"
#include "font.h"
#include "UI.h"
#include "menu.h"
#include "OSD.h"
#include "IconLoader.h"
#include "IconRender.h"
#include "HDLGameList.h"
#include "system.h"
#include "settings.h"
extern GSGLOBAL *gsGlobal;
extern GSTEXTURE BackgroundTexture;
extern GSTEXTURE PadLayoutTexture;
extern GSTEXTURE DeviceIconTexture;
extern unsigned short int SelectButton, CancelButton;
extern struct RuntimeData RuntimeData;
static char FreeDiskSpaceDisplay[16];
static char IPAddressDisplay[16]; // XXX.XXX.XXX.XXX
static u8 mac_address[6];
static void DrawButton(const char *label, float x, float y, u64 TextColour, int IsSelected);
static int GetUserGameSettings(struct GameSettings *GameSettings);
static int InitIconPreview(const char *device, const char *icon, struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData, GSTEXTURE *texture);
static void DeinitIconPreview(struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData);
static int GetUserIconFileSelectionFromDevice(const char *device, int unit, char **IconPath);
static int GetUserIconFileSelection(char **IconPath);
static int GetUserIconSourceChoice(char **IconPath);
static void RedrawMainMenu(struct HDLGameEntry *HDLGameList, unsigned int NumHDLGames, unsigned int SelectedGameIndex, unsigned int GameListViewPortStart);
static void DeleteGame(struct HDLGameEntry *HDLGameList, unsigned int GameIndex);
static int UpdateGame(struct HDLGameEntry *HDLGameList, unsigned int GameIndex);
static void EnterRemoteClientMenu(struct RuntimeData *RuntimeData);
static int StartInstallGame(sceCdRMode *ReadMode);
static void UpdateNetworkStatus(void);
static void UpdateHardwareAddress(void);
static void ShowNetworkStatus(void);
static int ShowOptions(void);
static void DrawMenuExitAnimation(void);
/*
In this whole file, some variables and values used would be:
SelectedMenu -> 0 = The game list.
1 = The control panel.
SelectedMenuOption -> The element in the menu that is currently selected.
*/
enum ConfigMenuFieldTypes {
CONFIG_MENU_FIELD_OPTION = 0, /* Normal "enabled/disabled" option. */
CONFIG_MENU_FIELD_BLANK, /* An open-ended option. */
CONFIG_MENU_FIELD_RADIO, /* A radio button option. */
};
struct ConfigMenuRadioOption
{
const char *label;
};
struct ConfigMenuFieldData
{
const char *label;
unsigned int FieldType;
unsigned short int x, y, ValueXOffset, ValueYOffset;
void *value;
int SelectedValue;
unsigned int FieldLength;
};
struct GameListDisplayData
{
unsigned int SelectedGameIndex;
unsigned int GameListViewPortStart;
};
struct MenuPageConfigData
{
unsigned int NumFields;
struct ConfigMenuFieldData *fields;
};
struct MenuConfigData
{
unsigned short int NumPages;
char FormIndex; // Form index = the position of the form in a series of forms, where 0 = the first form.
char NumForms; // Number of forms in this set of forms.
const struct MenuPageConfigData *pages;
};
static int ShowMenu(struct MenuConfigData *MenuConfigData, int (*MenuValidatorCallbackFunction)(struct MenuConfigData *MenuConfigData));
static int UserGameSettingsMenuValidator(struct MenuConfigData *MenuConfigData);
static unsigned int GetGameListData(struct HDLGameEntry **HDLGameList, struct GameListDisplayData *GameListDisplayData);
static unsigned int ReloadGameList(struct HDLGameEntry **HDLGameList, struct GameListDisplayData *GameListDisplayData);
void RedrawLoadingScreen(unsigned int frame)
{
short int xRel, x, y;
int NumDots;
SyncFlipFB();
NumDots = frame % 240 / 60;
DrawBackground(gsGlobal, &BackgroundTexture);
FontPrintf(gsGlobal, 10, 10, 0, 2.5f, GS_WHITE_FONT, "HDLGameInstaller v" HDLGAME_INSTALLER_VERSION);
x = 420;
y = 380;
FontPrintfWithFeedback(gsGlobal, x, y, 0, 1.8f, GS_WHITE_FONT, "Loading ", &xRel, NULL);
x += xRel;
switch (NumDots) {
case 1:
FontPrintf(gsGlobal, x, y, 0, 1.8f, GS_WHITE_FONT, ".");
break;
case 2:
FontPrintf(gsGlobal, x, y, 0, 1.8f, GS_WHITE_FONT, ". .");
break;
case 3:
FontPrintf(gsGlobal, x, y, 0, 1.8f, GS_WHITE_FONT, ". . .");
break;
}
if (frame < 60) { // Fade in
gsKit_prim_quad(gsGlobal, 0.0f, 0.0f,
gsGlobal->Width, 0.0f,
0.0f, gsGlobal->Height,
gsGlobal->Width, gsGlobal->Height,
0, GS_SETREG_RGBAQ(0, 0, 0, 0x00 + (frame * 2), 0));
}
}
/* Warning: Do not specify a label longer than MAX_BTN_LAB_LEN. */
static void DrawButton(const char *label, float x, float y, u64 TextColour, int IsSelected)
{
gsKit_prim_quad(gsGlobal, x, y, x + 240, y, x, y + 20, x + 240, y + 20, 2, IsSelected ? GS_LGREY : GS_GREY);
/* Draw the label. Centre it. */
FontPrintf(gsGlobal, (MAX_BTN_LAB_LEN - mbslen(label)) * BTN_FNT_CHAR_WIDTH + x, y, 1, 1.0f, TextColour, label);
}
static int ShowMenu(struct MenuConfigData *MenuConfigData, int (*MenuValidatorCallbackFunction)(struct MenuConfigData *MenuConfigData))
{
int result, CurrentPage, SelectedOption;
unsigned char done;
unsigned int PadStatus, i;
u64 FontColour;
const struct MenuPageConfigData *CurrentPageConfig;
const char *ConfirmButtonText, *CancelButtonText;
if (MenuConfigData->FormIndex == 0) { // First form
ConfirmButtonText = GetUILabel(SYS_UI_LBL_NEXT);
CancelButtonText = GetUILabel(SYS_UI_LBL_CANCEL);
} else if (MenuConfigData->FormIndex == MenuConfigData->NumForms - 1) { // Last form
ConfirmButtonText = GetUILabel(SYS_UI_LBL_OK);
CancelButtonText = GetUILabel(SYS_UI_LBL_BACK);
} else { // Somewhere in the middle.
ConfirmButtonText = GetUILabel(SYS_UI_LBL_NEXT);
CancelButtonText = GetUILabel(SYS_UI_LBL_BACK);
}
done = 0;
result = 0;
SelectedOption = 0;
CurrentPage = 0;
CurrentPageConfig = &MenuConfigData->pages[0];
do {
DrawBackground(gsGlobal, &BackgroundTexture);
for (i = 0; i < CurrentPageConfig->NumFields; i++) {
FontPrintf(gsGlobal, CurrentPageConfig->fields[i].x, CurrentPageConfig->fields[i].y, 1, 1.0f, GS_WHITE_FONT, CurrentPageConfig->fields[i].label);
switch (CurrentPageConfig->fields[i].FieldType) {
case CONFIG_MENU_FIELD_OPTION:
FontColour = (i == SelectedOption) ? GS_YELLOW_FONT : GS_BLUE_FONT;
FontPrintf(gsGlobal, CurrentPageConfig->fields[i].x + CurrentPageConfig->fields[i].ValueXOffset, CurrentPageConfig->fields[i].y + CurrentPageConfig->fields[i].ValueYOffset, 1, 1.0f, FontColour, CurrentPageConfig->fields[i].SelectedValue == 1 ? GetUILabel(SYS_UI_LBL_ENABLED) : GetUILabel(SYS_UI_LBL_DISABLED));
break;
case CONFIG_MENU_FIELD_BLANK:
FontColour = (i == SelectedOption) ? GS_YELLOW_FONT : GS_BLUE_FONT;
wFontPrintTitle(gsGlobal, CurrentPageConfig->fields[i].x + CurrentPageConfig->fields[i].ValueXOffset, CurrentPageConfig->fields[i].y + CurrentPageConfig->fields[i].ValueYOffset + 16, 1, 1.0f, FontColour, CurrentPageConfig->fields[i].value, MENU_BLANK_MAX_WIDTH);
FontColour = (i == SelectedOption) ? GS_YELLOW : GS_BLUE;
gsKit_prim_line(gsGlobal, CurrentPageConfig->fields[i].x + CurrentPageConfig->fields[i].ValueXOffset, CurrentPageConfig->fields[i].y + CurrentPageConfig->fields[i].ValueYOffset + 32, 620, CurrentPageConfig->fields[i].y + CurrentPageConfig->fields[i].ValueYOffset + 32, 1, FontColour);
break;
case CONFIG_MENU_FIELD_RADIO:
FontColour = (i == SelectedOption) ? GS_YELLOW_FONT : GS_BLUE_FONT;
FontPrintf(gsGlobal, CurrentPageConfig->fields[i].x + CurrentPageConfig->fields[i].ValueXOffset, CurrentPageConfig->fields[i].y + CurrentPageConfig->fields[i].ValueYOffset, 1, 1.0f, FontColour, ((struct ConfigMenuRadioOption *)CurrentPageConfig->fields[i].value)[CurrentPageConfig->fields[i].SelectedValue].label);
break;
}
}
DrawButton(ConfirmButtonText, 20, 360, GS_WHITE_FONT, SelectedOption == -1 ? 1 : 0);
DrawButton(CancelButtonText, 320, 360, GS_WHITE_FONT, SelectedOption == -2 ? 1 : 0);
/* Draw the legend. */
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_UD_DPAD, 20, 390, 4);
FontPrintf(gsGlobal, 60, 390, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_SELECT_FIELD));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_LR_DPAD, 20, 420, 4);
FontPrintf(gsGlobal, 60, 420, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_TOGGLE_OPTION));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, SelectButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 300, 400, 4);
FontPrintf(gsGlobal, 324, 400, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_OK));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, CancelButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 380, 400, 4);
FontPrintf(gsGlobal, 404, 400, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_CANCEL));
if (MenuConfigData->NumPages > 1) {
if (CurrentPage > 0) {
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_L1, 10, 320, 4);
}
if (CurrentPage < MenuConfigData->NumPages - 1) {
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_R1, 620, 320, 4);
}
}
PadStatus = ReadCombinedPadStatus();
if (PadStatus & PAD_START) {
SelectedOption = -1; /* Highlight the confirm button. */
}
if (PadStatus & CancelButton) {
SelectedOption = -2;
}
/* If the user did not select the confirm or cancel buttons */
if (SelectedOption != -1 && SelectedOption != -2) {
if (PadStatus & SelectButton && CurrentPageConfig->fields[SelectedOption].FieldType == CONFIG_MENU_FIELD_BLANK) {
DisplaySoftKeyboard(CurrentPageConfig->fields[SelectedOption].value, CurrentPageConfig->fields[SelectedOption].FieldLength, 0);
}
if ((PadStatus & PAD_L1) || (PadStatus & PAD_R1)) {
if (PadStatus & PAD_L1) {
if (CurrentPage > 0)
CurrentPage--;
} else if (PadStatus & PAD_R1) {
if (CurrentPage < MenuConfigData->NumPages - 1)
CurrentPage++;
}
CurrentPageConfig = &MenuConfigData->pages[CurrentPage];
SelectedOption = 0;
} else if (PadStatus & PAD_UP) {
if (SelectedOption > 0)
SelectedOption--;
} else if (PadStatus & PAD_DOWN) {
if (SelectedOption < CurrentPageConfig->NumFields - 1) {
SelectedOption++;
} else {
SelectedOption = -1;
}
}
switch (CurrentPageConfig->fields[SelectedOption].FieldType) {
case CONFIG_MENU_FIELD_OPTION:
if (PadStatus & PAD_LEFT && CurrentPageConfig->fields[SelectedOption].SelectedValue == 1) {
CurrentPageConfig->fields[SelectedOption].SelectedValue = 0;
}
if (PadStatus & PAD_RIGHT && CurrentPageConfig->fields[SelectedOption].SelectedValue == 0) {
CurrentPageConfig->fields[SelectedOption].SelectedValue = 1;
}
break;
case CONFIG_MENU_FIELD_BLANK:
break;
case CONFIG_MENU_FIELD_RADIO:
if (PadStatus & PAD_LEFT && CurrentPageConfig->fields[SelectedOption].SelectedValue > 0) {
CurrentPageConfig->fields[SelectedOption].SelectedValue--;
}
if (PadStatus & PAD_RIGHT && CurrentPageConfig->fields[SelectedOption].SelectedValue < CurrentPageConfig->fields[SelectedOption].FieldLength - 1) {
CurrentPageConfig->fields[SelectedOption].SelectedValue++;
}
break;
}
}
/* Otherwise, the user has selected either the "OK" or "Cancel" buttons */
else {
if (PadStatus & SelectButton || PadStatus & CancelButton) {
if (SelectedOption == -1 && (PadStatus & SelectButton)) {
result = 0;
if ((MenuValidatorCallbackFunction != NULL && MenuValidatorCallbackFunction(MenuConfigData) == 0) || (MenuValidatorCallbackFunction == NULL)) {
if (DisplayPromptMessage(SYS_UI_MSG_PROCEED, SYS_UI_LBL_CANCEL, SYS_UI_LBL_OK) == 2) {
done = 1;
}
}
} else if (SelectedOption == -2 && (PadStatus & CancelButton || PadStatus & SelectButton)) {
if (DisplayPromptMessage(SYS_UI_MSG_CANCEL_INPUT, SYS_UI_LBL_CANCEL, SYS_UI_LBL_OK) == 2) {
result = 1;
done = 1;
}
}
} else if (PadStatus & PAD_UP) {
SelectedOption = CurrentPageConfig->NumFields - 1;
} else if (PadStatus & PAD_LEFT && SelectedOption == -2) {
SelectedOption = -1;
} else if (PadStatus & PAD_RIGHT && SelectedOption == -1) {
SelectedOption = -2;
}
}
SyncFlipFB();
} while (!done);
return result;
}
#define USER_GAME_SETTINGS_MENU_NUM_OPTIONS 12
static int UserGameSettingsMenuValidator(struct MenuConfigData *MenuConfigData)
{
int result;
const struct MenuPageConfigData *CurrentPageConfig;
CurrentPageConfig = &MenuConfigData->pages[0];
result = 0;
if (wcslen(CurrentPageConfig->fields[0].value) < 1) {
DisplayErrorMessage(SYS_UI_MSG_FULL_GAME_TITLE);
result = 1;
}
if (wcslen(CurrentPageConfig->fields[1].value) < 1) {
DisplayErrorMessage(SYS_UI_MSG_OSD_TITLE_1);
result = 1;
}
return result;
}
static int GetUserGameSettings(struct GameSettings *GameSettings)
{
int result;
unsigned int i;
static struct ConfigMenuFieldData UserGameSettingsMenuFields[USER_GAME_SETTINGS_MENU_NUM_OPTIONS] = {
{NULL,
CONFIG_MENU_FIELD_BLANK,
10, 48, 0, 0, NULL, 0, GAME_TITLE_MAX_LEN},
{NULL,
CONFIG_MENU_FIELD_BLANK,
10, 96, 0, 0, NULL, 0, OSD_TITLE_MAX_LEN},
{NULL,
CONFIG_MENU_FIELD_BLANK,
10, 144, 0, 0, NULL, 0, OSD_TITLE_MAX_LEN},
{/* OPL compatibility mode 1 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 192, 440, 0, NULL, 0, 4},
{/* OPL compatibility mode 2 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 208, 440, 0, NULL, 0, 4},
{/* OPL compatibility mode 3 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 224, 440, 0, NULL, 0, 4},
{/* OPL compatibility mode 4 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 240, 440, 0, NULL, 0, 4},
{/* OPL compatibility mode 5 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 256, 440, 0, NULL, 0, 4},
{/* OPL compatibility mode 6 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 272, 440, 0, NULL, 0, 4},
{/* OPL compatibility mode 7 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 288, 440, 0, NULL, 0, 4},
{/* OPL compatibility mode 8 */
NULL,
CONFIG_MENU_FIELD_OPTION,
10, 304, 440, 0, NULL, 0, 4},
{NULL,
CONFIG_MENU_FIELD_OPTION,
10, 320, 440, 0, NULL, 0, 4}};
static const unsigned int MainMenuStringIDs[USER_GAME_SETTINGS_MENU_NUM_OPTIONS] = {
SYS_UI_LBL_INST_FULL_TITLE,
SYS_UI_LBL_INST_OSD_TITLE_1,
SYS_UI_LBL_INST_OSD_TITLE_2,
SYS_UI_LBL_INST_OPTION_1,
SYS_UI_LBL_INST_OPTION_2,
SYS_UI_LBL_INST_OPTION_3,
SYS_UI_LBL_INST_OPTION_4,
SYS_UI_LBL_INST_OPTION_5,
SYS_UI_LBL_INST_OPTION_6,
SYS_UI_LBL_INST_OPTION_7,
SYS_UI_LBL_INST_OPTION_8,
SYS_UI_LBL_INST_TRANSFER_OPTION,
};
static const struct MenuPageConfigData MenuPageConfigData = {
USER_GAME_SETTINGS_MENU_NUM_OPTIONS,
UserGameSettingsMenuFields};
static struct MenuConfigData MenuConfigData = {
1, 0, 2,
&MenuPageConfigData};
DEBUG_PRINTF("-= Gathering user game settings =-\n");
result = 0;
for (i = 0; i < USER_GAME_SETTINGS_MENU_NUM_OPTIONS; i++) {
switch (UserGameSettingsMenuFields[i].FieldType) {
case CONFIG_MENU_FIELD_OPTION:
case CONFIG_MENU_FIELD_RADIO:
UserGameSettingsMenuFields[i].value = NULL;
UserGameSettingsMenuFields[i].SelectedValue = 0;
break;
case CONFIG_MENU_FIELD_BLANK:
UserGameSettingsMenuFields[i].value = malloc((UserGameSettingsMenuFields[i].FieldLength + 1) * sizeof(wchar_t));
memset(UserGameSettingsMenuFields[i].value, 0, (UserGameSettingsMenuFields[i].FieldLength + 1) * sizeof(wchar_t));
break;
}
UserGameSettingsMenuFields[i].label = GetUILabel(MainMenuStringIDs[i]);
}
/* Set default options. */
wcsncpy(UserGameSettingsMenuFields[0].value, GameSettings->FullTitle, UserGameSettingsMenuFields[0].FieldLength);
wcsncpy(UserGameSettingsMenuFields[1].value, GameSettings->OSDTitleLine1, UserGameSettingsMenuFields[1].FieldLength);
wcsncpy(UserGameSettingsMenuFields[2].value, GameSettings->OSDTitleLine2, UserGameSettingsMenuFields[2].FieldLength);
for (i = 0; i <= 8; i++)
UserGameSettingsMenuFields[i + 3].SelectedValue = (GameSettings->CompatibilityModeFlags) >> i & 1;
UserGameSettingsMenuFields[11].SelectedValue = GameSettings->UseMDMA0;
result = ShowMenu(&MenuConfigData, &UserGameSettingsMenuValidator);
/* Process the user's input. */
if (result == 0) {
wcsncpy(GameSettings->FullTitle, UserGameSettingsMenuFields[0].value, GAME_TITLE_MAX_LEN);
GameSettings->FullTitle[GAME_TITLE_MAX_LEN] = '\0';
wcsncpy(GameSettings->OSDTitleLine1, UserGameSettingsMenuFields[1].value, OSD_TITLE_MAX_LEN);
GameSettings->OSDTitleLine1[OSD_TITLE_MAX_LEN] = '\0';
wcsncpy(GameSettings->OSDTitleLine2, UserGameSettingsMenuFields[2].value, OSD_TITLE_MAX_LEN);
GameSettings->OSDTitleLine2[OSD_TITLE_MAX_LEN] = '\0';
GameSettings->CompatibilityModeFlags = 0;
for (i = 0; i <= 8; i++)
GameSettings->CompatibilityModeFlags |= UserGameSettingsMenuFields[i + 3].SelectedValue << i;
GameSettings->UseMDMA0 = UserGameSettingsMenuFields[11].SelectedValue;
}
/* Free allocated memory. */
for (i = 0; i < USER_GAME_SETTINGS_MENU_NUM_OPTIONS; i++) {
if (UserGameSettingsMenuFields[i].value != NULL)
free(UserGameSettingsMenuFields[i].value);
}
return result;
}
#define MAX_ENTRIES_IN_LIST 12
static int InitIconPreview(const char *device, const char *icon, struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData, GSTEXTURE *texture)
{
char *fullpath, filename[65];
mcIcon McSaveIconSys;
int result;
if ((fullpath = malloc(strlen(device) + strlen(icon) + 35)) != NULL) {
sprintf(fullpath, "%s/%s", device, icon);
if ((result = LoadMcSaveSysFromPath(fullpath, &McSaveIconSys)) == 0) {
strncpy(filename, McSaveIconSys.view, sizeof(filename) - 1);
filename[sizeof(filename) - 1] = '\0';
sprintf(fullpath, "%s/%s/%s", device, icon, filename);
if ((result = LoadPS2IconModel(fullpath, IconModel)) == 0) {
UploadIcon(IconModel, texture);
InitIconModelRuntimeData(IconModel, IconRuntimeData);
result = 0;
}
}
free(fullpath);
} else
result = -ENOMEM;
return result;
}
static void DeinitIconPreview(struct PS2IconModel *IconModel, struct IconModelAnimRuntimeData *IconRuntimeData)
{
FreeIconModelRuntimeData(IconModel, IconRuntimeData);
UnloadPS2IconModel(IconModel);
memset(IconModel, 0, sizeof(struct PS2IconModel));
memset(IconRuntimeData, 0, sizeof(struct IconModelAnimRuntimeData));
}
static int GetUserIconFileSelectionFromDevice(const char *device, int unit, char **IconPath)
{
struct IconInfo *IconList;
unsigned char done;
unsigned int i, PadStatus, ListStartIndex, SelectedIndexInList, FrameNumber;
int NumIcons, result;
struct PS2IconModel IconModel;
struct IconModelAnimRuntimeData IconRuntimeData;
GSTEXTURE IconTexture;
char SelectedDeviceName[8];
sprintf(SelectedDeviceName, "%s%u:", device, unit);
NumIcons = GetIconListFromDevice(SelectedDeviceName, &IconList);
DEBUG_PRINTF("Loaded, num icons: %d\n", NumIcons);
done = 0;
ListStartIndex = 0;
SelectedIndexInList = 0;
result = 1;
*IconPath = NULL;
FrameNumber = 0;
ReinitializeUI();
memset(&IconModel, 0, sizeof(IconModel));
memset(&IconRuntimeData, 0, sizeof(IconRuntimeData));
memset(&IconTexture, 0, sizeof(IconTexture));
IconTexture.Vram = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(128, 128, GS_PSM_CT16), GSKIT_ALLOC_USERBUFFER);
if (NumIcons > 0) {
InitIconPreview(SelectedDeviceName, IconList[ListStartIndex + SelectedIndexInList].foldername, &IconModel, &IconRuntimeData, &IconTexture);
}
while (!done) {
DrawBackground(gsGlobal, &BackgroundTexture);
PadStatus = ReadCombinedPadStatus();
FontPrintf(gsGlobal, 16, 16, 1, 1.2f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_SELECT_ICON));
if (GetIsDeviceUnitReady(device, unit) != 1) {
// Unit was disconnected.
done = 1;
result = 1;
}
if (NumIcons > 0) {
/* Draw the highlight. */
gsKit_prim_quad(gsGlobal, 40, 64 + SelectedIndexInList * 16, 40, 64 + SelectedIndexInList * 16 + 16, 540, 64 + SelectedIndexInList * 16, 540, 64 + SelectedIndexInList * 16 + 16, 8, GS_LRED_TRANS);
for (i = 0; i < MAX_ENTRIES_IN_LIST; i++) {
if (ListStartIndex + i < NumIcons) {
wFontPrintf(gsGlobal, 40, 64 + i * 16, 1, 1.0f, GS_WHITE_FONT, IconList[ListStartIndex + i].title);
} else
break;
}
// Draw the icon preview.
TransformIcon(FrameNumber, 400.0, 128.0f, 0, 4.0f, &IconModel, &IconRuntimeData);
DrawIcon(&IconModel, &IconRuntimeData, &IconTexture);
// Draw the legend.
DrawButtonLegend(gsGlobal, &PadLayoutTexture, SelectButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 50, 404, 2);
FontPrintf(gsGlobal, 75, 406, 2, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_OK));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, CancelButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 200, 404, 2);
FontPrintf(gsGlobal, 240, 406, 2, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_CANCEL));
if (PadStatus & (PAD_UP | PAD_DOWN)) {
if (PadStatus & PAD_UP) {
if (SelectedIndexInList > 0)
SelectedIndexInList--;
else {
if (ListStartIndex > 0)
ListStartIndex--;
}
} else if (PadStatus & PAD_DOWN) {
if (SelectedIndexInList < MAX_ENTRIES_IN_LIST - 1 && SelectedIndexInList < NumIcons - 1)
SelectedIndexInList++;
else {
if (ListStartIndex + MAX_ENTRIES_IN_LIST < NumIcons)
ListStartIndex++;
}
}
DeinitIconPreview(&IconModel, &IconRuntimeData);
InitIconPreview(SelectedDeviceName, IconList[ListStartIndex + SelectedIndexInList].foldername, &IconModel, &IconRuntimeData, &IconTexture);
}
if (PadStatus & SelectButton) {
if ((*IconPath = malloc(strlen(SelectedDeviceName) + strlen(IconList[ListStartIndex + SelectedIndexInList].foldername) + 2)) != NULL) {
sprintf(*IconPath, "%s/%s", SelectedDeviceName, IconList[ListStartIndex + SelectedIndexInList].foldername);
result = 0;
} else
result = -ENOMEM;
done = 1;
}
} else {
FontPrintf(gsGlobal, 40, 64, 1, 1.0f, GS_WHITE_FONT, GetUIString(SYS_UI_MSG_NO_ICONS));
}
if (PadStatus & CancelButton) {
result = 1;
done = 1;
}
SyncFlipFB();
FrameNumber++;
}
if (IconList != NULL)
free(IconList);
DeinitIconPreview(&IconModel, &IconRuntimeData);
ReinitializeUI();
return result;
}
#define NUM_SUPPORTED_DEVICES 3
struct SupportedDevice
{
const char *name;
const char *label, *UnitLabel;
unsigned char unit;
unsigned char icon;
unsigned char IsReady;
};
static int GetUserIconFileSelection(char **IconPath)
{
unsigned char done, NumDevicesAvailable, DeviceID;
unsigned int PadStatus;
int result, i, devicesInRow, deviceRow, SelectedDevice;
u64 FontColour;
static struct SupportedDevice devices[NUM_SUPPORTED_DEVICES] = {
{
"mc",
NULL,
NULL,
0,
DEVICE_TYPE_DISK,
0,
},
{
"mc",
NULL,
NULL,
1,
DEVICE_TYPE_DISK,
0,
},
{
"mass",
NULL,
NULL,
0,
DEVICE_TYPE_USB_DISK,
0,
}};
static const unsigned int IconFileSelMenuDevStringIDs[NUM_SUPPORTED_DEVICES] = {
SYS_UI_LBL_DEV_MC,
SYS_UI_LBL_DEV_MC,
SYS_UI_LBL_DEV_MASS};
static const unsigned int IconFileSelMenuDevUnitStringIDs[NUM_SUPPORTED_DEVICES] = {
SYS_UI_LBL_MC_SLOT_1,
SYS_UI_LBL_MC_SLOT_2,
SYS_UI_LBL_COUNT};
// Allow the user to browse for icon sets on mc0:, mc1: and mass:.
for (i = 0; i < NUM_SUPPORTED_DEVICES; i++) {
devices[i].label = GetUILabel(IconFileSelMenuDevStringIDs[i]);
devices[i].UnitLabel = IconFileSelMenuDevUnitStringIDs[i] != SYS_UI_LBL_COUNT ? GetUILabel(IconFileSelMenuDevUnitStringIDs[i]) : NULL;
}
StartDevicePollingThread();
done = 0;
SelectedDevice = 0;
result = 0;
do {
DrawBackground(gsGlobal, &BackgroundTexture);
for (i = 0, NumDevicesAvailable = 0; i < NUM_SUPPORTED_DEVICES; i++) {
if (GetIsDeviceUnitReady(devices[i].name, devices[i].unit) == 1) {
devices[i].IsReady = 1;
NumDevicesAvailable++;
} else
devices[i].IsReady = 0;
}
PadStatus = ReadCombinedPadStatus();
FontPrintf(gsGlobal, 16, 16, 1, 1.2f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_SELECT_DEVICE));
// Draw the legend.
DrawButtonLegend(gsGlobal, &PadLayoutTexture, SelectButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 50, 404, 2);
FontPrintf(gsGlobal, 75, 406, 2, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_OK));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, CancelButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 200, 404, 2);
FontPrintf(gsGlobal, 240, 406, 2, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_CANCEL));
if (NumDevicesAvailable > 0) {
if (SelectedDevice >= NumDevicesAvailable) {
SelectedDevice = NumDevicesAvailable - 1;
}
if (PadStatus & PAD_LEFT) {
if (SelectedDevice > 0)
SelectedDevice--;
} else if (PadStatus & PAD_RIGHT) {
if (SelectedDevice < NumDevicesAvailable - 1)
SelectedDevice++;
}
if (PadStatus & PAD_UP) {
if (SelectedDevice - MAX_DEVICES_IN_ROW >= 0)
SelectedDevice -= MAX_DEVICES_IN_ROW;
} else if (PadStatus & PAD_DOWN) {
if (SelectedDevice + MAX_DEVICES_IN_ROW <= NumDevicesAvailable - 1)
SelectedDevice += MAX_DEVICES_IN_ROW;
}
// Display a list of available devices and allow the user to choose a device to browse for icons from.
for (i = 0, DeviceID = 0, devicesInRow = 0, deviceRow = 0; i < NumDevicesAvailable; DeviceID++) {
if (devices[DeviceID].IsReady) {
FontColour = (i == SelectedDevice) ? GS_YELLOW_FONT : GS_BLUE_FONT;
DrawDeviceIcon(gsGlobal, &DeviceIconTexture, devices[DeviceID].icon, DEVICE_LIST_X + 32 + 200 * devicesInRow, DEVICE_LIST_Y + 100 * deviceRow, 1);
FontPrintf(gsGlobal, DEVICE_LIST_X + 200 * devicesInRow, DEVICE_LIST_Y + 48 + 100 * deviceRow, 1, 1.0f, FontColour, devices[DeviceID].label);
if (devices[DeviceID].UnitLabel != NULL)
FontPrintf(gsGlobal, DEVICE_LIST_X + 200 * devicesInRow, DEVICE_LIST_Y + 64 + 100 * deviceRow, 1, 1.0f, FontColour, devices[DeviceID].UnitLabel);
i++;
devicesInRow++;
if (devicesInRow == MAX_DEVICES_IN_ROW) {
devicesInRow = 0;
deviceRow++;
}
}
}
if (PadStatus & SelectButton) {
for (i = 0, DeviceID = 0; DeviceID < NUM_SUPPORTED_DEVICES; DeviceID++) {
if (devices[DeviceID].IsReady) {
if (i == SelectedDevice) {
break;
}
i++;
}
}
SelectedDevice = DeviceID;
StopDevicePollingThread(); // Polling the MCs will cause a deadlock. Didn't look much into it though.
if ((result = GetUserIconFileSelectionFromDevice(devices[SelectedDevice].name, devices[SelectedDevice].unit, IconPath)) == 0) {
result = 0;
done = 1;
}
StartDevicePollingThread();
}
}
if (PadStatus & CancelButton) {
result = 1;
done = 1;
}
SyncFlipFB();
} while (!done);
StopDevicePollingThread();
return result;
}
#define USER_ICON_CHOICE_MENU_NUM_OPTIONS 1
static int GetUserIconSourceChoice(char **IconPath)
{
int result, i;
static const unsigned int IconSourceChoiceMenuStringIDs[] = {
SYS_UI_LBL_ICON_SEL_DEFAULT,
SYS_UI_LBL_ICON_SEL_SAVE_DATA,
SYS_UI_LBL_ICON_SEL_EXTERNAL};
static struct ConfigMenuRadioOption IconSourceRadioOptions[3];
static struct ConfigMenuFieldData UserIconSettingsMenuFields[USER_GAME_SETTINGS_MENU_NUM_OPTIONS] = {
{NULL,
CONFIG_MENU_FIELD_RADIO,
10, 200, 400, 0, IconSourceRadioOptions, 0, 3}};
static const struct MenuPageConfigData MenuPageConfigData = {
USER_ICON_CHOICE_MENU_NUM_OPTIONS,
UserIconSettingsMenuFields};
static struct MenuConfigData MenuConfigData = {
1, 1, 2,
&MenuPageConfigData};
for (i = 0; i < 3; i++) {
IconSourceRadioOptions[i].label = GetUILabel(IconSourceChoiceMenuStringIDs[i]);
}
UserIconSettingsMenuFields[0].label = GetUILabel(SYS_UI_LBL_ICON_SOURCE);
RedisplayMenu:
if ((result = ShowMenu(&MenuConfigData, NULL)) == 0) {
switch (UserIconSettingsMenuFields[0].SelectedValue) {
case 0:
case 1:
*IconPath = NULL;
break;
case 2:
if (GetUserIconFileSelection(IconPath) != 0) {
goto RedisplayMenu;
}
break;
}
result = UserIconSettingsMenuFields[0].SelectedValue;
} else
result = -1;
return result;
}
void DrawInstallGameScreen(const wchar_t *GameTitle, const char *DiscID, unsigned char DiscType, float percentage, unsigned int rate, unsigned int SecondsRemaining)
{
char CharBuffer[32];
float ProgressBarFillEndX;
unsigned int HoursRemaining;
unsigned char MinutesRemaining;
FontPrintf(gsGlobal, 5, 5, 1, 1.5f, GS_WHITE_FONT, "HDLGame Installer");
FontPrintf(gsGlobal, 10, 64, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_NOW_INSTALLING));
FontPrintf(gsGlobal, 10, 94, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_TITLE));
wFontPrintf(gsGlobal, 190, 94, 1, 1.0f, GS_WHITE_FONT, GameTitle);
FontPrintf(gsGlobal, 10, 114, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_DISC_ID));
FontPrintf(gsGlobal, 190, 114, 1, 1.0f, GS_WHITE_FONT, DiscID);
FontPrintf(gsGlobal, 10, 134, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_DISC_TYPE));
FontPrintf(gsGlobal, 190, 134, 1, 1.0f, GS_WHITE_FONT, DiscType == 0x14 ? "DVD" : "CD-ROM");
FontPrintf(gsGlobal, 10, 154, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_RATE));
sprintf(CharBuffer, "%uKB/s", rate);
FontPrintf(gsGlobal, 190, 154, 1, 1.0f, GS_WHITE_FONT, CharBuffer);
FontPrintf(gsGlobal, 10, 174, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_TIME_REMAINING));
HoursRemaining = SecondsRemaining / 3600;
MinutesRemaining = (SecondsRemaining - HoursRemaining * 3600) / 60;
if (SecondsRemaining < UINT_MAX) {
sprintf(CharBuffer, "%02u:%02u:%02u", HoursRemaining, MinutesRemaining, SecondsRemaining - HoursRemaining * 3600 - MinutesRemaining * 60);
} else {
strcpy(CharBuffer, "--:--:--");
}
FontPrintf(gsGlobal, 190, 184, 1, 1.0f, GS_WHITE_FONT, CharBuffer);
/* Draw the progress bar. */
DrawProgressBar(gsGlobal, percentage, PROGRESS_BAR_START_X, PROGRESS_BAR_START_Y, 4, PROGRESS_BAR_LENGTH, GS_BLUE);
DrawButtonLegend(gsGlobal, &PadLayoutTexture, CancelButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 240, 360, 4);
FontPrintf(gsGlobal, 280, 362, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_CANCEL));
}
static void RedrawMainMenu(struct HDLGameEntry *HDLGameList, unsigned int NumHDLGames, unsigned int SelectedGameIndex, unsigned int GameListViewPortStart)
{
int len, lineMax;
unsigned int i, SelectedGameListItem, NumGamesToDisplay, ScrollOffset;
wchar_t title[GAME_TITLE_MAX_LEN + 1];
static unsigned int PausedFrames = 0, frames = 0, LastSelectedItem = 0;
SelectedGameListItem = SelectedGameIndex - GameListViewPortStart;
FontPrintf(gsGlobal, 5, 5, 1, 1.8f, GS_WHITE_FONT, "HDLGame Installer");
FontPrintf(gsGlobal, 380, 16, 1, 1.0f, GS_WHITE_FONT, FreeDiskSpaceDisplay);
#ifdef ENABLE_NETWORK_SUPPORT
FontPrintf(gsGlobal, 480, 16, 1, 1.0f, GS_WHITE_FONT, IPAddressDisplay);
#else
FontPrintf(gsGlobal, 480, 16, 1, 1.0f, GS_WHITE_FONT, "000.000.000.000");
#endif
/**********************************************************************************/
/* Draw the outline of the table. Each row is 16 pixels tall. */
/* Draw the top of the table... */
gsKit_prim_line(gsGlobal, 5.0f, 54.0f, 5.0f + GAME_LIST_WIDTH + 5, 54.0f, 4, GS_WHITE);
gsKit_prim_quad(gsGlobal, 5.0f, 50.0f, 5.0f, 53.0f, 5.0f + GAME_LIST_WIDTH + 5, 50.0f, 5.0f + GAME_LIST_WIDTH + 5, 53.0f, 4, GS_GREY);
/* Draw left side */
gsKit_prim_line(gsGlobal, 10.0f, 54.0f, 10.0f, 311.0f, 4, GS_WHITE);
gsKit_prim_quad(gsGlobal, 5.0f, 50.0f, 10.0f, 50.0f, 5.0f, 312.0f, 10.0f, 312.0f, 4, GS_GREY);
/* Draw right side */
gsKit_prim_line(gsGlobal, 5.0f + GAME_LIST_WIDTH - 1, 54.0f, 5.0f + GAME_LIST_WIDTH - 1, 311.0f, 4, GS_WHITE);
gsKit_prim_quad(gsGlobal, 5.0f + GAME_LIST_WIDTH, 50.0f, 5.0f + GAME_LIST_WIDTH + 5, 50.0f, 5.0f + GAME_LIST_WIDTH, 312.0f, 5.0f + GAME_LIST_WIDTH + 5, 312.0f, 4, GS_GREY);
/* Draw the bottom of the table... */
gsKit_prim_line(gsGlobal, 9.0f, 311.0f, 5.0f + GAME_LIST_WIDTH, 311.0f, 4, GS_WHITE);
gsKit_prim_quad(gsGlobal, 5.0f, 312.0f, 5.0f, 315.0f, 5.0f + GAME_LIST_WIDTH + 5, 312.0f, 5.0f + GAME_LIST_WIDTH + 5, 315.0f, 4, GS_GREY);
#ifndef UI_TEST_MODE
NumGamesToDisplay = (NumHDLGames < GAME_LIST_MAX_DISPLAYED_GAMES) ? NumHDLGames : GAME_LIST_MAX_DISPLAYED_GAMES;
if (LastSelectedItem != SelectedGameListItem) {
frames = 0;
PausedFrames = 0;
LastSelectedItem = SelectedGameListItem;
}
/* Draw the game list */
for (i = 0; i < NumGamesToDisplay; i++) {
mbstowcs(title, HDLGameList[GameListViewPortStart + i].GameTitle, GAME_TITLE_MAX_LEN + 1);
if (i == SelectedGameListItem) {
if (frames > GAME_LIST_TITLE_SCROLL_START_PAUSE_INTERVAL)
ScrollOffset = (frames - GAME_LIST_TITLE_SCROLL_START_PAUSE_INTERVAL) / GAME_LIST_TITLE_SCROLL_INTERVAL;
else
ScrollOffset = 0;
len = wcslen(title);
// Scroll if necessary.
if (wFontPrintField(gsGlobal, 14, 60 + i * 16, 1, 1.0f, GS_WHITE_FONT, &title[ScrollOffset], GAME_LIST_TITLE_MAX_PIX, -1) < len - ScrollOffset) {
frames++;
} else { // At the very end of the scrolling, pause.
PausedFrames++;
if (PausedFrames >= GAME_LIST_TITLE_SCROLL_END_PAUSE_INTERVAL) { // When paused for long enough, start scrolling again from the start.
frames = 0;
PausedFrames = 0;
}
}
} else {
// Line is not selected. Print the title, but truncate if necessary.
wFontPrintTitle(gsGlobal, 14, 60 + i * 16, 1, 1.0f, GS_WHITE_FONT, title, GAME_LIST_TITLE_MAX_PIX);
}
}
#else
NumGamesToDisplay = GAME_LIST_MAX_DISPLAYED_GAMES;
for (i = 0; i < NumGamesToDisplay; i++) {
FontPrintf(gsGlobal, 14, 60 + i * 16, 1, 1.0f, GS_WHITE_FONT, "Game title here");
// FontPrintf(gsGlobal, 14, 60 + i * 16, 1, 1.0f, GS_WHITE_FONT, "111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999");
}
#endif
/* Draw the highlight. */
gsKit_prim_quad(gsGlobal, 11, 60 + SelectedGameListItem * 16, 11, 60 + SelectedGameListItem * 16 + 16, GAME_LIST_WIDTH, 60 + SelectedGameListItem * 16, GAME_LIST_WIDTH, 60 + SelectedGameListItem * 16 + 16, 8, GS_LBLUE_TRANS);
/* Draw the button legend. */
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_UD_DPAD, 10, 330, 4);
FontPrintf(gsGlobal, 50, 330, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_SELECT_GAME));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, SelectButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 300, 330, 4);
FontPrintf(gsGlobal, 340, 330, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_GAME_OPTIONS));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_TRIANGLE, 10, 360, 4);
FontPrintf(gsGlobal, 50, 360, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_DELETE_GAME));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_START, 300, 360, 4);
FontPrintf(gsGlobal, 340, 360, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_INSTALL_GAME));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, CancelButton == PAD_CIRCLE ? BUTTON_TYPE_CIRCLE : BUTTON_TYPE_CROSS, 10, 390, 4);
FontPrintf(gsGlobal, 50, 390, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_QUIT));
DrawButtonLegend(gsGlobal, &PadLayoutTexture, BUTTON_TYPE_SELECT, 300, 390, 4);
FontPrintf(gsGlobal, 340, 390, 1, 1.0f, GS_WHITE_FONT, GetUILabel(SYS_UI_LBL_OPTIONS));
}
static unsigned int GetGameListData(struct HDLGameEntry **HDLGameList, struct GameListDisplayData *GameListDisplayData)
{
unsigned int NumGames;
NumGames = GetHDLGameList(HDLGameList);
GameListDisplayData->SelectedGameIndex = GameListDisplayData->GameListViewPortStart = 0;
return NumGames;
}
static unsigned int LoadGameList(struct HDLGameEntry **HDLGameList, struct GameListDisplayData *GameListDisplayData)
{
unsigned int result;
result = GetGameListData(HDLGameList, GameListDisplayData);
sysGetFreeDiskSpaceDisplay(FreeDiskSpaceDisplay);
return result;
}
static unsigned int ReloadGameList(struct HDLGameEntry **HDLGameList, struct GameListDisplayData *GameListDisplayData)
{
unsigned int result;
DisplayFlashStatusUpdate(SYS_UI_MSG_PLEASE_WAIT);
LoadHDLGameList(HDLGameList);
return LoadGameList(HDLGameList, GameListDisplayData);
}
static void DeleteGame(struct HDLGameEntry *HDLGameList, unsigned int GameIndex)
{
#ifndef UI_TEST_MODE
char *path;
path = malloc(strlen(HDLGameList[GameIndex].PartName) + 6); /* Length of "hdd0:" + length of partition name + 1 NULL terminator. */
sprintf(path, "hdd0:%s", HDLGameList[GameIndex].PartName);
RemoveGameInstallation(path);
free(path);
#endif
}