Key captures in cgame

Locked
themuffinman
Posts: 384
Joined: Fri Mar 05, 2010 5:29 pm

Key captures in cgame

Post by themuffinman »

Hey all,

I'm trying to add an introduction menu to display when a client initially connects to a server. It does a key capture, bringing up the cursor allowing you to click on a button to join the game. I'd got the menu loading, but ran into 2 problems:
1. the action events don't work (ie: if you click on a button it does nothing) among other things such as transition events
2. it blocks the main menu from opening when pressing esc

This is using TA's ui menu script code btw. Here's the main function that is accessed through CG_Draw2D(), pretty short and simple:

Code: Select all

static qboolean CG_DrawIntro( void ) {
	playerState_t	*ps = &cg.predictedPlayerState;

	if ( ps->persistant[PERS_TEAM] != TEAM_SPECTATOR ) return qfalse;
	if ( ps->persistant[PERS_SPECTATOR] != SPECTATOR_INTRO ) return qfalse;

	if ( menuIntro ) {
		menuIntro->window.flags &= ~WINDOW_FORCED;
		menuIntro->window.flags |= WINDOW_MOUSEOVER;
		menuIntro->window.flags |= WINDOW_HASFOCUS;
	}

	menuIntro = Menus_FindByName( "joingame_menu" );

	if ( menuIntro ) {
		Menu_Paint( menuIntro, qtrue );
		trap_Key_SetCatcher( KEYCATCH_UI );
	}

	//trap_ShowIntroMenu();
	return qtrue;
}
I've fiddled around for a while without success. I've tried the other key capture options to set it on a lower priority one than the main menu such as KEYCATCH_CGAME but then the game crashes. Loading it through the UI module with a system call had about the same result only that the scoreboard was blocked instead of the main menu - I'd like both to be accessible while the menu is showing. Is there something else that needs to be initialised? Anyone with a solution?
Sheepsquatch
Posts: 19
Joined: Wed Apr 03, 2013 7:23 pm

Re: Key captures in cgame

Post by Sheepsquatch »

Maybe adding :

Code: Select all

int    key;

	if ( cgs.gametype == GT_TEAM ) {
		
		if (key == TEAM_RED)
			trap_SendClientCommand( "team r" );
		else
			trap_SendClientCommand( "team b" );
	} else
		trap_SendClientCommand( "team p" );
themuffinman
Posts: 384
Joined: Fri Mar 05, 2010 5:29 pm

Re: Key captures in cgame

Post by themuffinman »

The menu script handles that.

Still not getting anywhere. I've also tried these one by one:
Menu_Init( menuIntro );

menuIntro = Menu_GetFocused();

Menus_Activate( menuIntro );
Locked