예제 #1
0
/*
* CG_StartBackgroundTrack
*/
void CG_StartBackgroundTrack( void )
{
	char *string;
	char intro[MAX_QPATH], loop[MAX_QPATH];

	string = cgs.configStrings[CS_AUDIOTRACK];
	Q_strncpyz( intro, COM_Parse( &string ), sizeof( intro ) );
	Q_strncpyz( loop, COM_Parse( &string ), sizeof( loop ) );

	if( intro[0] )
		trap_S_StartBackgroundTrack( intro, loop );
	else if( cg_playList->string[0] )
		trap_S_StartBackgroundTrack( cg_playList->string, cg_playListShuffle->integer ? "1" : "0" );
}
예제 #2
0
/*
=================
S_Music_f
=================
*/
void CG_Music_f( void ) {
	int		c;
	char	intro[MAX_QPATH];
	char	loop[MAX_QPATH];
	float	volume;
	float	loopVolume;

	c = trap_Argc();

	if ( c < 2 || c > 5 ) {
		Com_Printf ("Usage: music <musicfile> [loopfile] [volume] [loopvolume]\n");
		return;
	}

	trap_Argv( 1, intro, sizeof( intro ) );
	trap_Argv( 2, loop, sizeof( loop ) );

	volume = loopVolume = 1.0f;

	if ( c > 3 ) {
		volume = loopVolume = atof( CG_Argv( 3 ) );
	}
	if ( c > 4 ) {
		loopVolume = atof( CG_Argv( 4 ) );
	}

	trap_S_StartBackgroundTrack( intro, loop, volume, loopVolume );
}
예제 #3
0
파일: ui_menu.c 프로젝트: Kaperstone/warsow
/*
* UI_Refresh
*/
void UI_Refresh( unsigned int time, int clientState, int serverState, qboolean demoplaying, qboolean backGround )
{
	uis.frameTime = ( time - uis.time ) * 0.001f;
	uis.time = time;
	uis.clientState = clientState;
	uis.serverState = serverState;
	uis.backGround = backGround;
	uis.demoplaying = demoplaying;

	if( !m_drawfunc )  // ui is inactive
		return;

	// draw background
	if( uis.backGround )
	{
		trap_R_DrawStretchPic( 0, 0, uis.vidWidth, uis.vidHeight,
			0, 0, 1, 1, colorWhite, trap_R_RegisterPic( UI_SHADER_VIDEOBACK ) );

		trap_R_DrawStretchPic( 0, 0, uis.vidWidth, uis.vidHeight,
			0, 0, 1, 1, colorWhite, trap_R_RegisterPic( UI_SHADER_FXBACK ) );

		trap_R_DrawStretchPic( 0, 0, uis.vidWidth, uis.vidHeight,
			0, 0, 1, 1, colorWhite, trap_R_RegisterPic( UI_SHADER_BIGLOGO ) );

		if( !uis.backGroundTrackStarted )
		{
			trap_S_StartBackgroundTrack( S_PLAYLIST_MENU, "3" ); // shuffle and loop
			uis.backGroundTrackStarted = qtrue;
		}
	}
	else
	{
		uis.backGroundTrackStarted = qfalse;
		//trap_R_DrawStretchPic( 0, 0, uis.vidWidth, uis.vidHeight,
		//	0, 0, 1, 1, colorDkGrey, trap_R_RegisterPic( "gfx/ui/novideoback" ) );

		//trap_R_DrawStretchPic ( 0, 0, uis.vidWidth, uis.vidHeight,
		//	0, 0, 1, 1, colorWhite, trap_R_RegisterPic( UI_SHADER_BIGLOGO ) );
	}

	m_drawfunc();

	// draw cursor
	if( !uis.bind_grab )
		trap_R_DrawStretchPic( uis.cursorX - 16, uis.cursorY - 16, 32, 32,
		0, 0, 1, 1, colorWhite, trap_R_RegisterPic( UI_SHADER_CURSOR ) );

	// delay playing the enter sound until after the
	// menu has been drawn, to avoid delay while
	// caching images
	if( m_entersound )
	{
		trap_S_StartLocalSound( menu_in_sound );
		m_entersound = qfalse;
	}
}
예제 #4
0
파일: cg_main.c 프로젝트: wombat23/omoh2
/*
======================
CG_StartMusic

======================
*/
void CG_StartMusic( void ) {
	char	*s;
	char	parm1[MAX_QPATH], parm2[MAX_QPATH];

	// start the background music
	s = (char *)CG_ConfigString( CS_MUSIC );
	Q_strncpyz( parm1, COM_Parse( &s ), sizeof( parm1 ) );
	Q_strncpyz( parm2, COM_Parse( &s ), sizeof( parm2 ) );

	trap_S_StartBackgroundTrack( parm1, parm2 );
}
예제 #5
0
static void CG_Rocket_EventPlay()
{
	const char *track = nullptr;

	// Specifying multiple files to randomly select between
	if ( trap_Argc() > 2 )
	{
		int numSounds = atoi( CG_Argv( 1 ) );
		if ( numSounds > 0 )
		{
			int selection = rand() % numSounds + 1;
			track = CG_Argv( 1 + selection );
			trap_S_StartBackgroundTrack( track, track );
		}
	}
	else
	{
		track = CG_Argv( 1 );
		trap_S_StartBackgroundTrack( track, track );
	}
}
예제 #6
0
/*===============
UI_CreditMenu
===============*/
void UI_CreditMenu( void ) {

	uis.menuamount = 0;
	trap_S_StopBackgroundTrack();
	trap_S_StartBackgroundTrack("music/credits.ogg", "music/credits.ogg");
	trap_S_StartLocalSound( menu_exit_sound, CHAN_LOCAL_SOUND );


	memset( &s_credits, 0 ,sizeof(s_credits) );

	s_credits.menu.draw = UI_CreditMenu_Draw;
	s_credits.menu.key = UI_CreditMenu_Key;
	s_credits.menu.fullscreen = qtrue;
	UI_PushMenu ( &s_credits.menu );
}
예제 #7
0
void CG_StartScoreboardMusic( void ) {
	char	var[MAX_TOKEN_CHARS];
	char	*s;
	char	parm1[MAX_QPATH], parm2[MAX_QPATH];

	//if music volume is 0, don't start the scoreboard music
	trap_Cvar_VariableStringBuffer( "s_musicvolume", var, sizeof( var ) );
	if ( !strcmp(var, "0") )
		return;

	// start the background music
	s = (char *)CG_ConfigString( CS_SCOREBOARDMUSIC );
	Q_strncpyz( parm1, COM_Parse( &s ), sizeof( parm1 ) );
	Q_strncpyz( parm2, COM_Parse( &s ), sizeof( parm2 ) );

	trap_S_StartBackgroundTrack( parm1, parm2 );
}
예제 #8
0
static void CG_ServerCommand( void ) {
	const char  *cmd;
	char text[MAX_SAY_TEXT];

	cmd = CG_Argv( 0 );

	if ( !cmd[0] ) {
		// server claimed the command
		return;
	}

	if ( !strcmp( cmd, "startCam" ) ) {
		CG_StartCamera( CG_Argv( 1 ), atoi( CG_Argv( 2 ) ) );
		return;
	}

	if ( !strcmp( cmd, "stopCam" ) ) {
		CG_StopCamera();
		return;
	}

	if ( !strcmp( cmd, "mvspd" ) ) {
		CG_RequestMoveSpeed( CG_Argv( 1 ) );
		return;
	}

	if ( !strcmp( cmd, "dp" ) ) {    // dynamite print (what a hack :(

		CG_CenterPrint( va( "%s %d %s", CG_translateString( "dynamitetimer" ), atoi( CG_Argv( 1 ) ), CG_translateString( "seconds" ) ),
						SCREEN_HEIGHT - ( SCREEN_HEIGHT * 0.25 ), SMALLCHAR_WIDTH );
		return;
	}

	if ( !strcmp( cmd, "cp" ) ) {
		CG_CenterPrint( CG_Argv( 1 ), SCREEN_HEIGHT - ( SCREEN_HEIGHT * 0.25 ), SMALLCHAR_WIDTH );
		return;
	}

	if ( !strcmp( cmd, "cs" ) ) {
		CG_ConfigStringModified();
		return;
	}

	if ( !strcmp( cmd, "print" ) ) {
		CG_Printf( "%s", CG_Argv( 1 ) );
#ifdef MISSIONPACK
		cmd = CG_Argv( 1 );           // yes, this is obviously a hack, but so is the way we hear about
									  // votes passing or failing
		if ( !Q_stricmpn( cmd, "vote failed", 11 ) || !Q_stricmpn( cmd, "team vote failed", 16 ) ) {
			trap_S_StartLocalSound( cgs.media.voteFailed, CHAN_ANNOUNCER );
		} else if ( !Q_stricmpn( cmd, "vote passed", 11 ) || !Q_stricmpn( cmd, "team vote passed", 16 ) ) {
			trap_S_StartLocalSound( cgs.media.votePassed, CHAN_ANNOUNCER );
		}
#endif
		return;
	}

	if ( !strcmp( cmd, "chat" ) ) {
		if ( !cg_teamChatsOnly.integer ) {
			trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
			Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
			CG_RemoveChatEscapeChar( text );
			CG_Printf( "%s\n", text );
		}
		return;
	}

	if ( !strcmp( cmd, "tchat" ) ) {
		trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
		Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
		CG_RemoveChatEscapeChar( text );
		CG_AddToTeamChat( text );
		CG_Printf( "%s\n", text );
		return;
	}

	// NERVE - SMF - limbo chat
	if ( !strcmp( cmd, "lchat" ) ) {
		trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
		Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
		CG_RemoveChatEscapeChar( text );
//		CG_AddToLimboChat( text );
		trap_UI_LimboChat( text );
		CG_Printf( "%s\n", text );
		return;
	}
	// -NERVE - SMF

	if ( !strcmp( cmd, "vchat" ) ) {
//		CG_VoiceChat( SAY_ALL );
		return;
	}

	if ( !strcmp( cmd, "vtchat" ) ) {
//		CG_VoiceChat( SAY_TEAM );
		return;
	}

	if ( !strcmp( cmd, "vtell" ) ) {
//		CG_VoiceChat( SAY_TELL );
		return;
	}

	if ( !strcmp( cmd, "scores" ) ) {
		CG_ParseScores();
		return;
	}

	if ( !strcmp( cmd, "tinfo" ) ) {
		CG_ParseTeamInfo();
		return;
	}

	if ( !strcmp( cmd, "map_restart" ) ) {
		CG_MapRestart();
		return;
	}

	if ( Q_stricmp( cmd, "remapShader" ) == 0 ) {
		if ( trap_Argc() == 4 ) {
			trap_R_RemapShader( CG_Argv( 1 ), CG_Argv( 2 ), CG_Argv( 3 ) );
		}
	}

	// loaddeferred can be both a servercmd and a consolecmd
	if ( !strcmp( cmd, "loaddeferred" ) ) {  // spelling fixed (SA)
		CG_LoadDeferredPlayers();
		return;
	}

	// clientLevelShot is sent before taking a special screenshot for
	// the menu system during development
	if ( !strcmp( cmd, "clientLevelShot" ) ) {
		cg.levelShot = qtrue;
		return;
	}

	// NERVE - SMF
	if ( !Q_stricmp( cmd, "oid" ) ) {
		CG_ObjectivePrint( CG_Argv( 2 ), SMALLCHAR_WIDTH, atoi( CG_Argv( 1 ) ) );
		return;
	}
	// -NERVE - SMF


	//
	// music
	//

	// loops \/
	if ( !strcmp( cmd, "mu_start" ) ) {  // has optional parameter for fade-up time
		int fadeTime = 0;   // default to instant start

		Q_strncpyz( text, CG_Argv( 2 ), MAX_SAY_TEXT );
		if ( text && strlen( text ) ) {
			fadeTime = atoi( text );
		}

		trap_S_StartBackgroundTrack( CG_Argv( 1 ), CG_Argv( 1 ), fadeTime );
		return;
	}
	// plays once then back to whatever the loop was \/
	if ( !strcmp( cmd, "mu_play" ) ) {   // has optional parameter for fade-up time
		int fadeTime = 0;   // default to instant start

		Q_strncpyz( text, CG_Argv( 2 ), MAX_SAY_TEXT );
		if ( text && strlen( text ) ) {
			fadeTime = atoi( text );
		}

		trap_S_StartBackgroundTrack( CG_Argv( 1 ), "onetimeonly", fadeTime );
		return;
	}

	if ( !strcmp( cmd, "mu_stop" ) ) {   // has optional parameter for fade-down time
		int fadeTime = 0;   // default to instant stop

		Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
		if ( text && strlen( text ) ) {
			fadeTime = atoi( text );
		}
		trap_S_FadeBackgroundTrack( 0.0f, fadeTime, 0 );
		trap_S_StartBackgroundTrack( "", "", -2 ); // '-2' for 'queue looping track' (QUEUED_PLAY_LOOPED)
		return;
	}

	if ( !strcmp( cmd, "mu_fade" ) ) {
		trap_S_FadeBackgroundTrack( atof( CG_Argv( 1 ) ), atoi( CG_Argv( 2 ) ), 0 );
		return;
	}

	if ( !strcmp( cmd, "snd_fade" ) ) {
		trap_S_FadeAllSound( atof( CG_Argv( 1 ) ), atoi( CG_Argv( 2 ) ) );
		return;
	}

	if ( !strcmp( cmd, "rockandroll" ) ) {   // map loaded, game is ready to begin.
		CG_Fade( 0, 0, 0, 255, cg.time, 0 );      // go black
		trap_UI_Popup( "pregame" );                // start pregame menu
		trap_Cvar_Set( "cg_norender", "1" );    // don't render the world until the player clicks in and the 'playerstart' func has been called (g_main in G_UpdateCvars() ~ilne 949)

		trap_S_FadeAllSound( 1.0f, 1000 );    // fade sound up

		return;
	}



	// ensure a file gets into a build (mainly for scripted music calls)
	if ( !strcmp( cmd, "addToBuild" ) ) {
		fileHandle_t f;

		if ( !cg_buildScript.integer ) {
			return;
		}

		// just open the file so it gets copied to the build dir
		//CG_FileTouchForBuild(CG_Argv(1));
		trap_FS_FOpenFile( CG_Argv( 1 ), &f, FS_READ );
		trap_FS_FCloseFile( f );
		return;
	}


	CG_Printf( "Unknown client game command: %s\n", cmd );
}
예제 #9
0
파일: ui_menu.c 프로젝트: zturtleman/q3rain
/*
===============
UI_MainMenu

The main menu only comes up when not in a game,
so make sure that the attract loop server is down
and that local cinematics are killed
===============
 */
void UI_MainMenu(void) {
    int x, y;
    int style = UI_LEFT | UI_DROPSHADOW | UI_SMALLFONT;

    trap_Cvar_Set("sv_killserver", "1");

    memset(&s_main, 0, sizeof (mainmenu_t));
    memset(&s_errorMessage, 0, sizeof (errorMessage_t));

    MainMenu_Cache();

    trap_Cvar_VariableStringBuffer("com_errorMessage", s_errorMessage.errorMessage, sizeof (s_errorMessage.errorMessage));
    if (strlen(s_errorMessage.errorMessage)) {
        s_errorMessage.menu.draw = Main_MenuDraw;
        s_errorMessage.menu.key = ErrorMessage_Key;
        s_errorMessage.menu.fullscreen = qtrue;
        s_errorMessage.menu.wrapAround = qtrue;
        s_errorMessage.menu.showlogo = qtrue;

        trap_Key_SetCatcher(KEYCATCH_UI);
        uis.menusp = 0;
        UI_PushMenu(&s_errorMessage.menu);

        return;
    }

    trap_S_StartBackgroundTrack("music/mainmenu.ogg", "");

    s_main.menu.draw = Main_MenuDraw;
    s_main.menu.fullscreen = qtrue;
    s_main.menu.wrapAround = qtrue;
    s_main.menu.showlogo = qfalse;

    s_main.fade = -100.0f;
    s_main.up = qtrue;

    x = 40;
    s_main.multiplayer.generic.type = MTYPE_PTEXT;
    s_main.multiplayer.generic.flags = QMF_LEFT_JUSTIFY | QMF_PULSEIFFOCUS;
    s_main.multiplayer.generic.x = x;
    s_main.multiplayer.generic.y = 440;
    s_main.multiplayer.generic.id = ID_MULTIPLAYER;
    s_main.multiplayer.generic.callback = Main_MenuEvent;
    s_main.multiplayer.string = "Multiplayer";
    s_main.multiplayer.color = color_blue;
    s_main.multiplayer.style = style;

    x += MAIN_MENU_HORIZONTAL_SPACING;
    s_main.singleplayer.generic.type = MTYPE_PTEXT;
    s_main.singleplayer.generic.flags = QMF_LEFT_JUSTIFY | QMF_PULSEIFFOCUS;
    s_main.singleplayer.generic.x = x;
    s_main.singleplayer.generic.y = 440;
    s_main.singleplayer.generic.id = ID_SINGLEPLAYER;
    s_main.singleplayer.generic.callback = Main_MenuEvent;
    s_main.singleplayer.string = "Singleplayer";
    s_main.singleplayer.color = color_blue;
    s_main.singleplayer.style = style;

    x += MAIN_MENU_HORIZONTAL_SPACING;
    s_main.options.generic.type = MTYPE_PTEXT;
    s_main.options.generic.flags = QMF_LEFT_JUSTIFY | QMF_PULSEIFFOCUS;
    s_main.options.generic.x = x;
    s_main.options.generic.y = 440;
    s_main.options.generic.id = ID_OPTIONS;
    s_main.options.generic.callback = Main_MenuEvent;
    s_main.options.string = "Options";
    s_main.options.color = color_blue;
    s_main.options.style = style;

    x += MAIN_MENU_HORIZONTAL_SPACING;
    s_main.demos.generic.type = MTYPE_PTEXT;
    s_main.demos.generic.flags = QMF_LEFT_JUSTIFY | QMF_PULSEIFFOCUS;
    s_main.demos.generic.x = x;
    s_main.demos.generic.y = 440;
    s_main.demos.generic.id = ID_DEMOS;
    s_main.demos.generic.callback = Main_MenuEvent;
    s_main.demos.string = "Demos";
    s_main.demos.color = color_blue;
    s_main.demos.style = style;

    x += MAIN_MENU_HORIZONTAL_SPACING;
    s_main.exit.generic.type = MTYPE_PTEXT;
    s_main.exit.generic.flags = QMF_LEFT_JUSTIFY | QMF_PULSEIFFOCUS;
    s_main.exit.generic.x = x;
    s_main.exit.generic.y = 440;
    s_main.exit.generic.id = ID_EXIT;
    s_main.exit.generic.callback = Main_MenuEvent;
    s_main.exit.string = "Exit";
    s_main.exit.color = color_blue;
    s_main.exit.style = style;

    Menu_AddItem(&s_main.menu, &s_main.multiplayer);
    Menu_AddItem(&s_main.menu, &s_main.singleplayer);
    Menu_AddItem(&s_main.menu, &s_main.options);
    Menu_AddItem(&s_main.menu, &s_main.demos);
    Menu_AddItem(&s_main.menu, &s_main.exit);

    s_main.servers = (int) trap_Cvar_VariableValue("ma_servers");
    s_main.players = (int) trap_Cvar_VariableValue("ma_players");
    s_main.motd = UI_Cvar_VariableString("ma_motd");

    trap_Key_SetCatcher(KEYCATCH_UI);
    uis.menusp = 0;
    UI_PushMenu(&s_main.menu);

}
예제 #10
0
/*
======================
CG_StartMusic

======================
*/
void CG_StartMusic( void ) {

	trap_S_StartBackgroundTrack( CG_LoadMusic(CG_ConfigString(CS_MUSIC)),"" );
}
예제 #11
0
/*
* CG_AddLocalSounds
*/
static void CG_AddLocalSounds( void )
{
	static bool postmatchsound_set = false, demostream = false, background = false;
	static unsigned int lastSecond = 0;

	// add local announces
	if( GS_Countdown() )
	{
		if( GS_MatchDuration() )
		{
			unsigned int duration, curtime, remainingSeconds;
			float seconds;

			curtime = GS_MatchPaused() ? cg.frame.serverTime : cg.time;
			duration = GS_MatchDuration();

			if( duration + GS_MatchStartTime() < curtime )
				duration = curtime - GS_MatchStartTime(); // avoid negative results

			seconds = (float)( GS_MatchStartTime() + duration - curtime ) * 0.001f;
			remainingSeconds = (unsigned int)seconds;

			if( remainingSeconds != lastSecond )
			{
				if( 1 + remainingSeconds < 4 )
				{
					struct sfx_s *sound = trap_S_RegisterSound( va( S_ANNOUNCER_COUNTDOWN_COUNT_1_to_3_SET_1_to_2, 1 + remainingSeconds, 1 ) );
					CG_AddAnnouncerEvent( sound, false );
				}

				lastSecond = remainingSeconds;
			}
		}
	}
	else
		lastSecond = 0;

	// add sounds from announcer
	CG_ReleaseAnnouncerEvents();

	// if in postmatch, play postmatch song
	if( GS_MatchState() >= MATCH_STATE_POSTMATCH )
	{
		if( !postmatchsound_set && !demostream )
		{
			trap_S_StartBackgroundTrack( S_PLAYLIST_POSTMATCH, NULL, 3 ); // loop random track from the playlist
			postmatchsound_set = true;
			background = false;
		}
	}
	else
	{
		if( cgs.demoPlaying && cgs.demoAudioStream && !demostream )
		{
			trap_S_StartBackgroundTrack( cgs.demoAudioStream, NULL, 0 );
			demostream = true;
		}

		if( postmatchsound_set )
		{
			trap_S_StopBackgroundTrack();
			postmatchsound_set = false;
			background = false;
		}

		if( (!postmatchsound_set && !demostream) && !background )
		{
			CG_StartBackgroundTrack();
			background = true;
		}

		// notice: these 2 sound files aren't used anymore
		//cgs.media.sfxTimerBipBip
		//cgs.media.sfxTimerPloink
	}
}