Skip to content

Commit 2a8dda8

Browse files
committed
Refactor profile flow: move create/select into main menu with lightweight overlay
- move profile create/select entry point from startup blocking behavior to the main menu - add active profile display below QUIT (fallback to CREATE when no profile exists) - show current rank and profile points as informational lines in the main menu - open profile selection/creation via click on the profile entry - keep overlay presentation lightweight with alpha background instead of full blocking feel - preserve forced-selection behavior only for first-time users with no profile - improve UX clarity for profile switching and creation without interrupting menu navigation
1 parent f2582c4 commit 2a8dda8

File tree

4 files changed

+307
-91
lines changed

4 files changed

+307
-91
lines changed

engine/code/q3_ui/ui_local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ extern vmCvar_t ui_menuBackPath;
841841
extern vmCvar_t ui_menuBackState;
842842

843843
void UI_ProfileOverlay_InitSession( void );
844+
void UI_ProfileOverlay_Open( qboolean forceSelection );
844845
void UI_ProfileOverlay_MaybeShow( void );
845846
void UI_ProfileOverlay_ClearState( void );
846847
void UI_Profile_MarkStatsDirty( void );

engine/code/q3_ui/ui_menu.c

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ MAIN MENU
3838
#define ID_SETUP 12
3939
#define ID_DEMOS 13
4040
#define ID_CINEMATICS 14
41+
#define ID_PROFILE_ACTION 15
4142

4243
#define ID_MODS 16
4344
#define ID_GARAGE 17
@@ -60,6 +61,11 @@ typedef struct {
6061
menutext_s mods;
6162
menutext_s garage;
6263
menutext_s exit;
64+
menutext_s profileAction;
65+
menutext_s profileInfoLine1;
66+
menutext_s profileInfoLine2;
67+
char profileRankLine[64];
68+
char profilePointsLine[64];
6369

6470
menutext_s banner;
6571
menubitmap_s carlogo;
@@ -73,6 +79,30 @@ typedef struct {
7379

7480

7581
static mainmenu_t s_main;
82+
static vec4_t s_profileActionColor;
83+
84+
static void MainMenu_UpdateProfileTexts( void ) {
85+
const profile_stats_t *activeProfileStats;
86+
profile_rank_t activeRank;
87+
const char *activeProfileName;
88+
qboolean hasActiveProfile;
89+
90+
activeProfileName = UI_Profile_GetActiveName();
91+
hasActiveProfile = UI_Profile_HasActiveProfile();
92+
s_main.profileAction.string = ( hasActiveProfile && activeProfileName && activeProfileName[0] ) ? (char *)activeProfileName : "CREATE";
93+
94+
activeProfileStats = UI_Profile_GetActiveStats();
95+
if ( activeProfileStats && UI_Profile_GetRank( activeProfileStats, &activeRank ) && activeRank.current && activeRank.current->name ) {
96+
Com_sprintf( s_main.profileRankLine, sizeof( s_main.profileRankLine ), "RANK: %s", activeRank.current->name );
97+
Com_sprintf( s_main.profilePointsLine, sizeof( s_main.profilePointsLine ), "POINTS: %d", activeProfileStats->playerScore );
98+
} else {
99+
Q_strncpyz( s_main.profileRankLine, "RANK: -", sizeof( s_main.profileRankLine ) );
100+
Q_strncpyz( s_main.profilePointsLine, "POINTS: 0", sizeof( s_main.profilePointsLine ) );
101+
}
102+
103+
s_main.profileInfoLine1.string = s_main.profileRankLine;
104+
s_main.profileInfoLine2.string = s_main.profilePointsLine;
105+
}
76106

77107
/*
78108
=================
@@ -207,6 +237,10 @@ void Main_MenuEvent (void* ptr, int event) {
207237
uis.transitionOut = uis.realtime;
208238
break;
209239

240+
case ID_PROFILE_ACTION:
241+
UI_ProfileOverlay_Open( qfalse );
242+
break;
243+
210244
case ID_EXIT:
211245
UI_ConfirmMenu( "EXIT GAME?", 0, MainMenu_ExitAction );
212246
break;
@@ -259,6 +293,8 @@ MainMenu_RunTransition
259293
===============
260294
*/
261295
void MainMenu_RunTransition( float frac ) {
296+
vec4_t profileActionColor;
297+
262298
uis.text_color[0] = text_color_normal[0];
263299
uis.text_color[1] = text_color_normal[1];
264300
uis.text_color[2] = text_color_normal[2];
@@ -275,6 +311,15 @@ void MainMenu_RunTransition( float frac ) {
275311
s_main.mods.color = uis.text_color;
276312
s_main.exit.color = uis.text_color;
277313

314+
s_profileActionColor[0] = color_red[0];
315+
s_profileActionColor[1] = color_red[1];
316+
s_profileActionColor[2] = color_red[2];
317+
s_profileActionColor[3] = color_red[3] * frac;
318+
s_main.profileAction.color = s_profileActionColor;
319+
320+
s_main.profileInfoLine1.color = uis.text_color;
321+
s_main.profileInfoLine2.color = uis.text_color;
322+
278323
s_main.carlogo.generic.x = (int)(640 - 440 * frac);
279324
}
280325

@@ -285,6 +330,8 @@ MainMenu_Prepare
285330
*/
286331
void MainMenu_Prepare( void ) {
287332

333+
UI_Profile_MarkStatsDirty();
334+
MainMenu_UpdateProfileTexts();
288335
MainMenu_Update();
289336

290337
}
@@ -297,6 +344,8 @@ Main_MenuDraw
297344
*/
298345
static void Main_MenuDraw( void ) {
299346

347+
MainMenu_UpdateProfileTexts();
348+
300349
// standard menu drawing
301350

302351
Menu_Draw( &s_main.menu );
@@ -312,7 +361,6 @@ static void Main_MenuDraw( void ) {
312361

313362
}
314363

315-
UI_ProfileOverlay_MaybeShow();
316364
}
317365

318366

@@ -364,6 +412,22 @@ static void InitMenuText(menutext_s *item, int id, char *label, int x, int y) {
364412
item->color = text_color_normal;
365413
}
366414

415+
/*
416+
=================
417+
InitMenuTextInfo
418+
=================
419+
*/
420+
static void InitMenuTextInfo(menutext_s *item, char *label, int x, int y) {
421+
422+
item->generic.type = MTYPE_PTEXT;
423+
item->generic.flags = QMF_LEFT_JUSTIFY|QMF_INACTIVE;
424+
item->generic.x = x;
425+
item->generic.y = y;
426+
item->style = UI_LEFT|UI_SMALLFONT|UI_DROPSHADOW;
427+
item->string = label;
428+
item->color = text_color_normal;
429+
}
430+
367431
/*
368432
===============
369433
UI_MainMenu
@@ -377,10 +441,13 @@ void UI_MainMenu( void ) {
377441

378442
int x;
379443
int y;
444+
int profileY;
445+
int profileInfoY;
380446
int numMusicFiles;
381447
int selectedMusic;
382448
char musicFiles[256][MAX_QPATH];
383449
char musicCommand[MAX_QPATH];
450+
int menuSpacing;
384451

385452

386453
numMusicFiles = UI_BuildFileList("music", "ogg", "menumusic", qtrue, qfalse, qfalse, 0, musicFiles);
@@ -422,25 +489,26 @@ void UI_MainMenu( void ) {
422489
s_main.banner.style = UI_CENTER|UI_DROPSHADOW;
423490

424491
x = 175;
425-
y = 100;
492+
y = 75;
493+
menuSpacing = MAIN_MENU_VERTICAL_SPACING - 5;
426494

427495

428496
InitMenuText(&s_main.singleplayer, ID_SINGLEPLAYER, "OFFLINE", x - 10, y + 12);
429497

430498

431-
y += MAIN_MENU_VERTICAL_SPACING;
499+
y += menuSpacing;
432500
InitMenuText(&s_main.multiplayer, ID_MULTIPLAYER, "ONLINE", x - 10, y + 12);
433501

434502

435-
y += MAIN_MENU_VERTICAL_SPACING;
503+
y += menuSpacing;
436504
InitMenuText(&s_main.setup, ID_SETUP, "CONFIG", x - 10, y + 12);
437505

438506

439-
y += MAIN_MENU_VERTICAL_SPACING;
507+
y += menuSpacing;
440508
InitMenuText(&s_main.garage, ID_GARAGE, "THE GARAGE", x - 10, y + 12);
441509

442510

443-
y += MAIN_MENU_VERTICAL_SPACING;
511+
y += menuSpacing;
444512
InitMenuText(&s_main.demos, ID_DEMOS, "DEMOS", x - 10, y + 12);
445513

446514

@@ -452,10 +520,23 @@ void UI_MainMenu( void ) {
452520
s_main.carlogo.width = 480;
453521
s_main.carlogo.height = 480;
454522

455-
y += MAIN_MENU_VERTICAL_SPACING;
523+
y += menuSpacing;
456524
InitMenuText(&s_main.exit, ID_EXIT, "QUIT", x - 10, y + 12);
457525

458526

527+
y += menuSpacing;
528+
profileY = y + 22;
529+
profileInfoY = y + 16;
530+
InitMenuText(&s_main.profileAction, ID_PROFILE_ACTION, "CREATE", x - 10, profileY);
531+
s_main.profileAction.generic.flags = QMF_RIGHT_JUSTIFY;
532+
533+
Q_strncpyz( s_main.profileRankLine, "RANK: -", sizeof( s_main.profileRankLine ) );
534+
Q_strncpyz( s_main.profilePointsLine, "POINTS: 0", sizeof( s_main.profilePointsLine ) );
535+
InitMenuTextInfo(&s_main.profileInfoLine1, s_main.profileRankLine, x + 20, profileInfoY);
536+
InitMenuTextInfo(&s_main.profileInfoLine2, s_main.profilePointsLine, x + 20, profileInfoY + 16);
537+
MainMenu_UpdateProfileTexts();
538+
539+
459540
Menu_AddItem( &s_main.menu, &s_main.banner );
460541
Menu_AddItem( &s_main.menu, &s_main.carlogo );
461542
Menu_AddItem( &s_main.menu, &s_main.singleplayer );
@@ -464,13 +545,19 @@ void UI_MainMenu( void ) {
464545
Menu_AddItem( &s_main.menu, &s_main.garage );
465546
Menu_AddItem( &s_main.menu, &s_main.demos );
466547
Menu_AddItem( &s_main.menu, &s_main.exit );
548+
Menu_AddItem( &s_main.menu, &s_main.profileAction );
549+
Menu_AddItem( &s_main.menu, &s_main.profileInfoLine1 );
550+
Menu_AddItem( &s_main.menu, &s_main.profileInfoLine2 );
467551

468552
trap_Key_SetCatcher( KEYCATCH_UI );
469553
uis.menusp = 0;
470554

471555
UI_PushMenu ( &s_main.menu );
472556

557+
UI_ProfileOverlay_MaybeShow();
473558

474-
uis.transitionIn = uis.realtime;
559+
if ( uis.activemenu == &s_main.menu ) {
560+
uis.transitionIn = uis.realtime;
561+
}
475562

476563
}

engine/code/q3_ui/ui_rally_controls.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,15 @@ static qboolean Controls_SearchActive( void )
496496
return s_controlsSearchText[0] != '\0';
497497
}
498498

499+
static qboolean Controls_SearchFieldHasFocus( void )
500+
{
501+
if ( !s_controls.menu.items || s_controls.menu.cursor < 0 || s_controls.menu.cursor >= s_controls.menu.nitems ) {
502+
return qfalse;
503+
}
504+
505+
return s_controls.menu.items[s_controls.menu.cursor] == (void *)&s_controls.search;
506+
}
507+
499508
static qboolean Controls_ShowDeveloper( void )
500509
{
501510
return trap_Cvar_VariableValue( "ui_controls_showDeveloper" ) != 0;
@@ -1522,7 +1531,7 @@ static sfxHandle_t Controls_MenuKey( int key )
15221531
bind_t* bindptr;
15231532
found = qfalse;
15241533

1525-
if ( !s_controls.waitingforkey && ( key & K_CHAR_FLAG ) ) {
1534+
if ( !s_controls.waitingforkey && Controls_SearchFieldHasFocus() && ( key & K_CHAR_FLAG ) ) {
15261535
ch = key & ~K_CHAR_FLAG;
15271536
if ( ch == 8 ) {
15281537
int len = strlen( s_controlsSearchText );
@@ -1569,7 +1578,7 @@ static sfxHandle_t Controls_MenuKey( int key )
15691578
else
15701579
{
15711580
if (key & K_CHAR_FLAG)
1572-
goto ignorekey;
1581+
return 0;
15731582

15741583
switch (key)
15751584
{

0 commit comments

Comments
 (0)