Example #1
0
void UI_TouchButtons_GetButtonList()
{
    if( !uiTouchButtons.initialized )
        return;
    uiTouchButtons.buttonList.numItems = 0;
    CLIENT_COMMAND( 1, "" ); //perform Cbuf_Execute()
    uiTouchButtons.gettingList = true;
    CLIENT_COMMAND( 1, "touch_list\n" );
    uiTouchButtons.gettingList = false;
    int i = uiTouchButtons.buttonList.numItems;

    if( uiTouchButtons.buttonList.generic.charHeight )
    {
        uiTouchButtons.buttonList.numRows = (uiTouchButtons.buttonList.generic.height2 / uiTouchButtons.buttonList.generic.charHeight) - 2;
        if( uiTouchButtons.buttonList.numRows > uiTouchButtons.buttonList.numItems )
            uiTouchButtons.buttonList.numRows = i;
    }

    for ( ; i < UI_MAXGAMES; i++ )
        uiTouchButtons.bNamesPtr[i] = NULL;


    uiTouchButtons.buttonList.itemNames = (const char **)uiTouchButtons.bNamesPtr;
    UI_TouchButtons_UpdateFields();
}
Example #2
0
/*
=================
UI_LoadGame_Callback
=================
*/
static void UI_LoadGame_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	if( event == QM_CHANGED )
	{
		if( uiLoadGame.saveName[uiLoadGame.savesList.curItem][0] == '\0' )
			uiLoadGame.load.generic.flags |= QMF_GRAYED;
		else uiLoadGame.load.generic.flags &= ~QMF_GRAYED;

		if( uiLoadGame.delName[uiLoadGame.savesList.curItem][0] == '\0' )
			uiLoadGame.remove.generic.flags |= QMF_GRAYED;
		else uiLoadGame.remove.generic.flags &= ~QMF_GRAYED;
		return;
	}

	if( event != QM_ACTIVATED )
		return;
	
	switch( item->id )
	{
	case ID_CANCEL:
		UI_PopMenu();
		break;
	case ID_LOAD:
		if( uiLoadGame.saveName[uiLoadGame.savesList.curItem][0] )
		{
			char	cmd[128];
			sprintf( cmd, "load \"%s\"\n", uiLoadGame.saveName[uiLoadGame.savesList.curItem] );

			BACKGROUND_TRACK( NULL, NULL );

			CLIENT_COMMAND( FALSE, cmd );
		}
		break;
	case ID_NO:
	case ID_DELETE:
		UI_DeleteDialog();
		break;
	case ID_YES:
		if( uiLoadGame.delName[uiLoadGame.savesList.curItem][0] )
		{
			char	cmd[128];
			sprintf( cmd, "killsave \"%s\"\n", uiLoadGame.delName[uiLoadGame.savesList.curItem] );

			CLIENT_COMMAND( TRUE, cmd );

			sprintf( cmd, "save/%s.bmp", uiLoadGame.delName[uiLoadGame.savesList.curItem] );
			PIC_Free( cmd );

			// restarts the menu
			UI_PopMenu();
			UI_LoadGame_Menu();
			return;
		}
		UI_DeleteDialog();
		break;
	}
}
Example #3
0
/*
=================
UI_PopMenu
=================
*/
void UI_PopMenu( void )
{
	UI_StartSound( uiSoundOut );

	uiStatic.menuDepth--;

	if( uiStatic.menuDepth < 0 )
		HOST_ERROR( "UI_PopMenu: menu stack underflow\n" );

	UI_PopPButtonStack();

	if( uiStatic.menuDepth )
	{
		uiStatic.menuActive = uiStatic.menuStack[uiStatic.menuDepth-1];
		uiStatic.firstDraw = true;
	}
	else if ( CL_IsActive( ))
	{
		UI_CloseMenu();
	}
	else
	{
		// never trying the close menu when client isn't connected
		KEY_SetDest( KEY_MENU );
		UI_Main_Menu();
	}

	if( uiStatic.m_fDemosPlayed && uiStatic.m_iOldMenuDepth == uiStatic.menuDepth )
	{
		CLIENT_COMMAND( FALSE, "demos\n" );
		uiStatic.m_fDemosPlayed = false;
		uiStatic.m_iOldMenuDepth = 0;
	}
}
Example #4
0
static void UI_DeleteButton()
{
    char command[256];
    snprintf(command, 256, "touch_removebutton \"%s\"\n", uiTouchButtons.selectedName );
    CLIENT_COMMAND(1, command);
    UI_TouchButtons_GetButtonList();
}
Example #5
0
/*
=================
UI_CreateGame_Begin
=================
*/
static void UI_CreateGame_Begin( void )
{
	if( !MAP_IS_VALID( uiCreateGame.mapName[uiCreateGame.mapsList.curItem] ))
		return;	// bad map

	if( CVAR_GET_FLOAT( "host_serverstate" ) && CVAR_GET_FLOAT( "maxplayers" ) == 1 )
		HOST_ENDGAME( "end of the game" );

	CVAR_SET_FLOAT( "deathmatch", 1.0f );	// FIXME
	CVAR_SET_FLOAT( "maxplayers", atoi( uiCreateGame.maxClients.buffer ));
	CVAR_SET_STRING( "hostname", uiCreateGame.hostName.buffer );
	CVAR_SET_STRING( "defaultmap", uiCreateGame.mapName[uiCreateGame.mapsList.curItem] );

	// all done, start server
	if( uiCreateGame.dedicatedServer.enabled )
	{
		HOST_WRITECONFIG ( CVAR_GET_STRING( "servercfgfile" ));

		char cmd[128];
		sprintf( cmd, "#%s", gMenu.m_gameinfo.gamefolder );

		// NOTE: dedicated server will be executed "defaultmap"
		// from engine after restarting
		HOST_CHANGEGAME( cmd, "Starting dedicated server...\n" );
	}
	else
	{
		HOST_WRITECONFIG ( CVAR_GET_STRING( "lservercfgfile" ));

		char cmd[128];
		sprintf( cmd, "exec %s\nmap %s\n", CVAR_GET_STRING( "lservercfgfile" ), CVAR_GET_STRING( "defaultmap" ));
	
		CLIENT_COMMAND( FALSE, cmd );
	}
}
Example #6
0
/*
=================
UI_RefreshInternetServerList
=================
*/
void UI_RefreshInternetServerList( void )
{
	uiStatic.numServers = 0;
	memset( uiStatic.serverAddresses, 0, sizeof( uiStatic.serverAddresses ));
	memset( uiStatic.serverNames, 0, sizeof( uiStatic.serverNames ));

	CLIENT_COMMAND( FALSE, "internetservers\n" );
}
Example #7
0
void DisplayMenuToClient (edict_t *ent, MenuText *menu)
{
   if (!IsValidPlayer (ent))
      return;

   int clientIndex = ENTINDEX (ent) - 1;

   if (menu != null)
   {
      String tempText = String (menu->menuText);
      tempText.Replace ("\v", "\n");

      char *text = g_localizer->TranslateInput (tempText);
      tempText = String (text);

      // make menu looks best
      for (int i = 0; i <= 9; i++)
         tempText.Replace (FormatBuffer ("%d.", i), FormatBuffer ("\\r%d.\\w", i));

      text = tempText;

      while (strlen (text) >= 64)
      {
         MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, g_netMsg->GetId (NETMSG_SHOWMENU), null, ent);
            WRITE_SHORT (menu->validSlots);
            WRITE_CHAR (-1);
            WRITE_BYTE (1);

         for (int i = 0; i <= 63; i++)
            WRITE_CHAR (text[i]);

         MESSAGE_END ();

         text += 64;
      }

      MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, g_netMsg->GetId (NETMSG_SHOWMENU), null, ent);
         WRITE_SHORT (menu->validSlots);
         WRITE_CHAR (-1);
         WRITE_BYTE (0);
         WRITE_STRING (text);
      MESSAGE_END();

      g_clients[clientIndex].menu = menu;
   }
   else
   {
      MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, g_netMsg->GetId (NETMSG_SHOWMENU), null, ent);
         WRITE_SHORT (0);
         WRITE_CHAR (0);
         WRITE_BYTE (0);
         WRITE_STRING ("");
      MESSAGE_END();

     g_clients[clientIndex].menu = null;
   }
   CLIENT_COMMAND (ent, "speak \"player/geiger1\"\n"); // Stops others from hearing menu sounds..
}
qboolean OnClientConnectPost( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] )
{
    if( Initialized && sv_allowdownload->value > 0 )
    {
        if( cvar_enable_debug->value > 0 )
        {
            ModuleDebug.append( UTIL_VarArgs( "\n\"%s\" (index = %d, address = %s) is connecting.\n", pszName, ENTINDEX( pEntity ), pszAddress ) );
        }

        if( rm_enable_downloadfix.value <= 0 )
        {
            NotifyClientDisconnectHook->Restore();
            RETURN_META_VALUE( MRES_IGNORED, TRUE );
        }
        else
        {
            NotifyClientDisconnectHook->Patch();
        }

        char	ip[ 16 ];
        uint32	player				= ENTINDEX( pEntity );
        time_t	timeSystem			= getSysTime();
        time_t*	nextReconnectTime	= &PlayerNextReconnectTime[ player ];
        String*	currentPlayerIp		= &PlayerCurrentIp[ player ];

        // Retrieve server IP one time from there because
        // we need to let server.cfg be executed in case
        // a specific ip is provided and because I have not
        // found forward to use to put this call at this time.
        retrieveServerIp( &ServerInternetIp );

        // Retrieve the current client's IP without the port.
        retrieveClientIp( ip, pszAddress );

        // Sanity IP address check to make sure the index
        // is our expected player. If not, we consider it
        // as a new player and we reset variables to the default.
        if( currentPlayerIp->compare( ip ) )
        {
            *nextReconnectTime = 0;

            currentPlayerIp->clear();
            currentPlayerIp->assign( ip );
        }

        // We are allowed to reconnect the player.
        // We put a cool down of 3 seconds minimum to avoid possible
        // infinite loop since depending where it will download resources,
        // it can connect/disconnect several times.
        if( *nextReconnectTime < timeSystem )
        {
            *nextReconnectTime = timeSystem + 3;
            CLIENT_COMMAND( pEntity, "Connect %s %d\n", isLocalIp( ip ) ? ServerLocalIp.c_str() : ServerInternetIp.c_str(), RANDOM_LONG( 1, 9999 ) );
        }
    }

    RETURN_META_VALUE( MRES_IGNORED, TRUE );
}
Example #9
0
static void UI_DeleteProfile()
{
	char command[256];

	if( uiTouchOptions.profiles.curItem <= uiTouchOptions.firstProfile )
		return;

	snprintf(command, 256, "touch_deleteprofile \"%s\"\n", uiTouchOptions.profileDesc[ uiTouchOptions.profiles.curItem ] );
	CLIENT_COMMAND(1, command);
	UI_TouchOptions_GetProfileList();
}
Example #10
0
void CPointServerCommand::Execute(const char *command)
{
	if (!IS_DEDICATED_SERVER())
	{
		// potentially dangerous for untrusted maps
		// so try to use it for passing through filtered svc_stufftext
		CLIENT_COMMAND(INDEXENT(1), UTIL_VarArgs("%s\n", command));
		return;
	}

	SERVER_COMMAND(UTIL_VarArgs("%s\n", command));
}
/*
=================
UI_NewGame_StartGame
=================
*/
static void UI_NewGame_StartGame( float skill )
{
	if( CVAR_GET_FLOAT( "host_serverstate" ) && CVAR_GET_FLOAT( "maxplayers" ) > 1 )
		HOST_ENDGAME( "end of the game" );

	CVAR_SET_FLOAT( "skill", skill );
	CVAR_SET_FLOAT( "deathmatch", 0.0f );
	CVAR_SET_FLOAT( "teamplay", 0.0f );
	CVAR_SET_FLOAT( "pausable", 1.0f ); // singleplayer is always allowing pause
	CVAR_SET_FLOAT( "maxplayers", 1.0f );
	CVAR_SET_FLOAT( "coop", 0.0f );

	CLIENT_COMMAND( FALSE, "newgame\n" );
}
Example #12
0
void CHostage::ApplyHostagePenalty(CBasePlayer *pAttacker)
{
	if (pAttacker->m_iTeam == TEAM_TERRORIST)
	{
		int iHostagePenalty = (int)CVAR_GET_FLOAT("mp_hostagepenalty");

		if (iHostagePenalty)
		{
			if (pAttacker->m_iHostagesKilled++ == iHostagePenalty)
				pAttacker->HintMessage("#Hint_removed_for_next_hostage_killed", TRUE);
			else if (pAttacker->m_iHostagesKilled >= iHostagePenalty)
				CLIENT_COMMAND(pAttacker->edict(), "disconnect\n");
		}
	}
}
/*
=================
UI_Main_NewGame
=================
*/
static void UI_Main_NewGame( void )
{
	if( CVAR_GET_FLOAT( "host_serverstate" ) && CVAR_GET_FLOAT( "maxplayers" ) > 1 )
		HOST_ENDGAME( "end of the game" );

	CVAR_SET_FLOAT( "skill", 1.0f );
	CVAR_SET_FLOAT( "deathmatch", 0.0f );
	CVAR_SET_FLOAT( "teamplay", 0.0f );
	CVAR_SET_FLOAT( "pausable", 1.0f ); // singleplayer is always allowing pause
	CVAR_SET_FLOAT( "coop", 0.0f );

	BACKGROUND_TRACK( NULL, NULL );

	CLIENT_COMMAND( FALSE, "newgame\n" );
}
Example #14
0
static void UI_ResetButtons()
{
	CLIENT_COMMAND( 0, "touch_pitch 90\n" );
	CLIENT_COMMAND( 0, "touch_yaw 120\n" );
	CLIENT_COMMAND( 0, "touch_forwardzone 0.06\n" );
	CLIENT_COMMAND( 0, "touch_sidezone 0.06\n" );
	CLIENT_COMMAND( 0, "touch_grid 1\n" );
	CLIENT_COMMAND( 0, "touch_grid_count 50\n" );
	UI_TouchOptions_GetConfig();
}
/*
=================
UI_CustomGame_Callback
=================
*/
static void UI_CustomGame_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	if( event == QM_CHANGED )
	{
		// aee if the load button should be grayed
		if( !stricmp( gMenu.m_gameinfo.gamefolder, uiCustomGame.modsDir[uiCustomGame.modList.curItem] ))
			uiCustomGame.load.generic.flags |= QMF_GRAYED;
		else uiCustomGame.load.generic.flags &= ~QMF_GRAYED;

		if( strlen( uiCustomGame.modsWebSites[uiCustomGame.modList.curItem] ) == 0 )
			uiCustomGame.go2url.generic.flags |= QMF_GRAYED;
		else uiCustomGame.go2url.generic.flags &= ~QMF_GRAYED;
		return;
	}

	if( event != QM_ACTIVATED )
		return;

	switch( item->id )
	{
	case ID_DONE:
		UI_PopMenu();
		break;
	case ID_GOTOSITE:
		if( strlen( uiCustomGame.modsWebSites[uiCustomGame.modList.curItem] ))
			SHELL_EXECUTE( uiCustomGame.modsWebSites[uiCustomGame.modList.curItem], NULL, false );
		break;
	case ID_ACTIVATE:
	case ID_NO:
		if ( CL_IsActive( ))
		{
			UI_EndGameDialog();
			break;	// don't f**k up the game
		}
	case ID_YES:
		// restart all engine systems with new game
		char cmd[128];
		sprintf( cmd, "game %s\n", uiCustomGame.modsDir[uiCustomGame.modList.curItem] );
		CLIENT_COMMAND( FALSE, cmd );
		UI_EndGameDialog();
		break;
	}
}
Example #16
0
/*
=================
UI_InternetGames_Menu
=================
*/
void UI_InternetGames_Menu( void )
{
	if ( gMenu.m_gameinfo.gamemode == GAME_SINGLEPLAYER_ONLY )
		return;

	// stop demos to allow open network sockets
	if ( gpGlobals->demoplayback && CVAR_GET_FLOAT( "cl_background" ))
	{
		uiStatic.m_iOldMenuDepth = uiStatic.menuDepth;
		CLIENT_COMMAND( FALSE, "stop\n" );
		uiStatic.m_fDemosPlayed = true;
	}

	UI_InternetGames_Precache();
	UI_InternetGames_Init();

	UI_PushMenu( &uiInternetGames.menu );
}
Example #17
0
static void UI_Controls_ResetKeysList( void )
{
	char *afile = (char *)LOAD_FILE( "gfx/shell/kb_def.lst", NULL );
	char *pfile = afile;
	char token[1024];

	if( !afile )
	{
		Con_Printf( "UI_Parse_KeysList: kb_act.lst not found\n" );
		return;
	}

	while(( pfile = COM_ParseFile( pfile, token )) != NULL )
	{
		char	key[32];

		strncpy( key, token, sizeof( key ));

		pfile = COM_ParseFile( pfile, token );
		if( !pfile ) break;	// technically an error

		char	cmd[128];

		if( key[0] == '\\' && key[1] == '\\' )
		{
			key[0] = '\\';
			key[1] = '\0';
		}

		UI_UnbindCommand( token );

		sprintf( cmd, "bind \"%s\" \"%s\"\n", key, token );
		CLIENT_COMMAND( TRUE, cmd );
	}

	FREE_FILE( afile );
	UI_Controls_RestartMenu ();
}
Example #18
0
void CPointClientCommand::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
	edict_t *pClient = nullptr;
	if (gpGlobals->maxClients == 1)
	{
		pClient = INDEXENT(1);
	}
	else if (pActivator &&
		pActivator->IsPlayer() &&
		pActivator->IsNetClient() &&
		!pActivator->IsDormant())
	{
		// In multiplayer, send it back to the activator
		pClient = pActivator->edict();
	}

	if (pClient)
	{
		for (size_t cmd = 0; cmd < m_uiCommandsCount; cmd++) {
			CLIENT_COMMAND(pClient, UTIL_VarArgs("%s\n", m_iszCommands[cmd].str()));
		}
	}
}
Example #19
0
/*
=================
UI_StartBackGroundMap
=================
*/
bool UI_StartBackGroundMap( void )
{
	static bool	first = TRUE;

	if( !first ) return FALSE;

	first = FALSE;

	// some map is already running
	if( !uiStatic.bgmapcount || CVAR_GET_FLOAT( "host_serverstate" ) || gpGlobals->demoplayback )
		return FALSE;

	int bgmapid = RANDOM_LONG( 0, uiStatic.bgmapcount - 1 );

	char cmd[128];
	sprintf( cmd, "maps/%s.bsp", uiStatic.bgmaps[bgmapid] );
	if( !FILE_EXISTS( cmd )) return FALSE; 

	sprintf( cmd, "map_background %s\n", uiStatic.bgmaps[bgmapid] );
	CLIENT_COMMAND( FALSE, cmd );

	return TRUE;
}
Example #20
0
/*
=================
UI_GameOptions_Callback
=================
*/
static void UI_GameOptions_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	switch( item->id )
	{
	case ID_HAND:
	case ID_ALLOWDOWNLOAD:
	case ID_ALWAYSRUN:
	case ID_ANDROIDSLEEP:
		if( event == QM_PRESSED )
			((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_PRESSED;
		else ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_FOCUS;
		break;
	}

	if( event == QM_CHANGED )
	{
		UI_GameOptions_UpdateConfig();
		return;
	}

	if( event != QM_ACTIVATED )
		return;

	switch( item->id )
	{
	case ID_DONE:
		CLIENT_COMMAND( FALSE, "trysaveconfig\n" );
		UI_PopMenu();
		break;
	case ID_CANCEL:
		UI_GameOptions_DiscardChanges();
		UI_PopMenu();
		break;
	}
}
/*
=========================================================
UpdateClientData

resends any changed player HUD info to the client.
Called every frame by PlayerPreThink
Also called at start of demo recording and playback by
ForceClientDllUpdate to ensure the demo gets messages
reflecting all of the HUD state info.
=========================================================
*/
void CBasePlayer::UpdateClientData()
{
	if( m_bNeedsNewConnectTime )
	{
		m_bNeedsNewConnectTime = false;

		m_flConnectTime = gpGlobals->time;
	}

	if( !m_bWeaponValidationReceived && m_flConnectTime + WEAPON_VALIDATION_GRACE_TIME < gpGlobals->time )
	{
		//If the client didn't send the message in time, drop the client. - Solokiller

		//Set it to true to avoid running this multiple times. - Solokiller
		m_bWeaponValidationReceived = true;

		UTIL_LogPrintf( "Player \"%s\" didn't send weapon validation in time, disconnecting\n", GetNetName() );

		if( !IS_DEDICATED_SERVER() )
		{
			//Listen server hosts usually don't have logging enabled, so echo to console unconditionally for them. - Solokiller
			UTIL_ServerPrintf( "Player \"%s\" didn't send weapon validation in time, disconnecting\n", GetNetName() );
		}

		if( IS_DEDICATED_SERVER() || entindex() != 1 )
		{
			SERVER_COMMAND( UTIL_VarArgs( "kick \"%s\" \"No weapon validation received\"\n", GetNetName() ) );
		}
		else
		{
			//The local player can't be kicked, so terminate the session instead - Solokiller
			CLIENT_COMMAND( edict(), "disconnect\n" );
		}
	}

	//The engine will not call ClientPutInServer after transitions, so we'll have to catch this event every map change. - Solokiller
	if( !m_bSentInitData )
	{
		m_bSentInitData = true;

		//Update Hud colors. - Solokiller
		CMap::GetInstance()->SendHudColors( this, true );
	}

	if( m_fInitHUD )
	{
		m_fInitHUD = false;
		gInitHUD = false;

		MESSAGE_BEGIN( MSG_ONE, gmsgResetHUD, NULL, this );
			WRITE_BYTE( 0 );
		MESSAGE_END();

		if( !m_fGameHUDInitialized )
		{
			MESSAGE_BEGIN( MSG_ONE, gmsgInitHUD, NULL, this );
			MESSAGE_END();

			g_pGameRules->InitHUD( this );
			m_fGameHUDInitialized = true;

			m_iObserverLastMode = OBS_ROAMING;

			if( g_pGameRules->IsMultiplayer() )
			{
				FireTargets( "game_playerjoin", this, this, USE_TOGGLE, 0 );
			}
		}

		FireTargets( "game_playerspawn", this, this, USE_TOGGLE, 0 );

		InitStatusBar();

		SendWeatherUpdate();
	}

	if( m_iHideHUD != m_iClientHideHUD )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgHideWeapon, NULL, this );
			WRITE_BYTE( m_iHideHUD );
		MESSAGE_END();

		m_iClientHideHUD = m_iHideHUD;
	}

	if( m_iFOV != m_iClientFOV )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, this );
			WRITE_BYTE( m_iFOV );
		MESSAGE_END();

		// cache FOV change at end of function, so weapon updates can see that FOV has changed
	}

	// HACKHACK -- send the message to display the game title
	if( gDisplayTitle )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgShowGameTitle, NULL, this );
			WRITE_BYTE( 0 );
		MESSAGE_END();
		gDisplayTitle = false;
	}

	if( pev->health != m_iClientHealth )
	{
		int iHealth = clamp( static_cast<int>( pev->health ), 0, 255 );  // make sure that no negative health values are sent
		if( pev->health > 0.0f && pev->health <= 1.0f )
			iHealth = 1;

		// send "health" update message
		MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, this );
			WRITE_BYTE( iHealth );
		MESSAGE_END();

		m_iClientHealth = pev->health;
	}


	if( pev->armorvalue != m_iClientBattery )
	{
		m_iClientBattery = pev->armorvalue;

		ASSERT( gmsgBattery > 0 );
		// send "health" update message
		MESSAGE_BEGIN( MSG_ONE, gmsgBattery, NULL, this );
			WRITE_SHORT( ( int ) pev->armorvalue );
		MESSAGE_END();
	}

	if( pev->dmg_take || pev->dmg_save || m_bitsHUDDamage != m_bitsDamageType )
	{
		// Comes from inside me if not set
		Vector damageOrigin = GetAbsOrigin();
		// send "damage" message
		// causes screen to flash, and pain compass to show direction of damage
		edict_t *other = pev->dmg_inflictor;
		if( other )
		{
			CBaseEntity *pEntity = CBaseEntity::Instance( other );
			if( pEntity )
				damageOrigin = pEntity->Center();
		}

		// only send down damage type that have hud art
		int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD;

		MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, this );
			WRITE_BYTE( pev->dmg_save );
			WRITE_BYTE( pev->dmg_take );
			WRITE_LONG( visibleDamageBits );
			WRITE_COORD( damageOrigin.x );
			WRITE_COORD( damageOrigin.y );
			WRITE_COORD( damageOrigin.z );
		MESSAGE_END();

		//TODO: both of these can probably be removed. - Solokiller
		pev->dmg_take = 0;
		pev->dmg_save = 0;
		m_bitsHUDDamage = m_bitsDamageType;

		// Clear off non-time-based damage indicators
		m_bitsDamageType &= DMG_TIMEBASED;
	}

	// Update Flashlight
	if( ( m_flFlashLightTime ) && ( m_flFlashLightTime <= gpGlobals->time ) )
	{
		if( FlashlightIsOn() )
		{
			if( m_iFlashBattery )
			{
				m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time;
				m_iFlashBattery--;

				if( !m_iFlashBattery )
					FlashlightTurnOff();
			}
		}
		else
		{
			if( m_iFlashBattery < 100 )
			{
				m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time;
				m_iFlashBattery++;
			}
			else
				m_flFlashLightTime = 0;
		}

		MESSAGE_BEGIN( MSG_ONE, gmsgFlashBattery, NULL, this );
			WRITE_BYTE( m_iFlashBattery );
		MESSAGE_END();
	}

	if( m_iTrain & TRAIN_NEW )
	{
		ASSERT( gmsgTrain > 0 );
		// send "health" update message
		MESSAGE_BEGIN( MSG_ONE, gmsgTrain, NULL, this );
			WRITE_BYTE( m_iTrain & 0xF );
		MESSAGE_END();

		m_iTrain &= ~TRAIN_NEW;
	}

	SendAmmoUpdate();

	// Update all the items
	for( int i = 0; i < MAX_WEAPON_SLOTS; i++ )
	{
		if( m_rgpPlayerItems[ i ] )  // each item updates it's successors
			m_rgpPlayerItems[ i ]->UpdateClientData( this );
	}

	// Cache and client weapon change
	m_pClientActiveItem = m_pActiveItem;
	m_iClientFOV = m_iFOV;

	// Update Status Bar
	if( m_flNextSBarUpdateTime < gpGlobals->time )
	{
		UpdateStatusBar();
		m_flNextSBarUpdateTime = gpGlobals->time + 0.2;
	}
}
Example #22
0
/*
=================
UI_TouchOptions_Callback
=================
*/
static void UI_TouchOptions_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	switch( item->id )
	{
	case ID_ENABLE:
	case ID_GRID:
	case ID_IGNORE_MOUSE:
		if( event == QM_PRESSED )
			((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_PRESSED;
		else ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_FOCUS;
		break;
	}

	if( event == QM_CHANGED )
	{
		// Update cvars based on controls
		UI_TouchOptions_SetConfig();

		if( item->id == ID_PROFILELIST )
		{
			char curprofile[256];
			int isCurrent;
			COM_FileBase( CVAR_GET_STRING( "touch_config_file" ), curprofile );
			isCurrent = !strcmp( curprofile, uiTouchOptions.profileDesc[ uiTouchOptions.profiles.curItem ]);

			// Scrolllist changed, update availiable options
			uiTouchOptions.remove.generic.flags |= QMF_GRAYED;
			if( ( uiTouchOptions.profiles.curItem > uiTouchOptions.firstProfile ) && !isCurrent )
				uiTouchOptions.remove.generic.flags &= ~QMF_GRAYED;

			uiTouchOptions.apply.generic.flags &= ~QMF_GRAYED;
			if( uiTouchOptions.profiles.curItem == 0 || uiTouchOptions.profiles.curItem == uiTouchOptions.firstProfile -1 )
				uiTouchOptions.profiles.curItem ++;
			if( isCurrent )
				uiTouchOptions.apply.generic.flags |= QMF_GRAYED;
		}
		return;
	}

	if( event != QM_ACTIVATED )
		return;

	switch( item->id )
	{
	case ID_DONE:
		UI_TouchOptions_SetConfig();
		UI_PopMenu();
		break;
	case ID_RESET:
		uiTouchOptions.save.generic.flags |= QMF_INACTIVE; 
		uiTouchOptions.remove.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.enable.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.profiles.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.moveX.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.moveY.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.lookX.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.lookY.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.reset.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.profilename.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.done.generic.flags |= QMF_INACTIVE;


		uiTouchOptions.msgBox.generic.flags &= ~QMF_HIDDEN;
		uiTouchOptions.promptMessage.generic.flags &= ~QMF_HIDDEN;
		uiTouchOptions.no.generic.flags &= ~QMF_HIDDEN;
		uiTouchOptions.yes.generic.flags &= ~QMF_HIDDEN;
		strcpy( uiTouchOptions.dialogText, "Reset all buttons?" );
		uiTouchOptions.dialogAction = UI_ResetButtons;
		break;
	case ID_DELETE:
		uiTouchOptions.save.generic.flags |= QMF_INACTIVE; 
		uiTouchOptions.remove.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.enable.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.profiles.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.moveX.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.moveY.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.lookX.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.lookY.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.reset.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.profilename.generic.flags |= QMF_INACTIVE;
		uiTouchOptions.done.generic.flags |= QMF_INACTIVE;


		uiTouchOptions.msgBox.generic.flags &= ~QMF_HIDDEN;
		uiTouchOptions.promptMessage.generic.flags &= ~QMF_HIDDEN;
		uiTouchOptions.no.generic.flags &= ~QMF_HIDDEN;
		uiTouchOptions.yes.generic.flags &= ~QMF_HIDDEN;
		strcpy( uiTouchOptions.dialogText, "Delete selected profile?" );
		uiTouchOptions.dialogAction = UI_DeleteProfile;
		break;
	case ID_YES:
	if( uiTouchOptions.dialogAction )
		uiTouchOptions.dialogAction();
	case ID_NO:
		uiTouchOptions.save.generic.flags &= ~QMF_INACTIVE; 
		uiTouchOptions.remove.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.enable.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.profiles.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.moveX.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.moveY.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.lookX.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.lookY.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.reset.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.profilename.generic.flags &= ~QMF_INACTIVE;
		uiTouchOptions.done.generic.flags &= ~QMF_INACTIVE;

		uiTouchOptions.msgBox.generic.flags |= QMF_HIDDEN;
		uiTouchOptions.promptMessage.generic.flags |= QMF_HIDDEN;
		uiTouchOptions.no.generic.flags |= QMF_HIDDEN;
		uiTouchOptions.yes.generic.flags |= QMF_HIDDEN;
		break;
	case ID_SAVE:
		{
			char name[256];
			if( uiTouchOptions.profilename.buffer[0] )
			{
				snprintf( name, 256, "touch_profiles/%s.cfg", uiTouchOptions.profilename.buffer );
				CVAR_SET_STRING("touch_config_file", name );
			}
			CLIENT_COMMAND( 1, "touch_writeconfig\n" );
		}
		UI_TouchOptions_GetProfileList();
		uiTouchOptions.profilename.buffer[0] = 0;
		uiTouchOptions.profilename.cursor = uiTouchOptions.profilename.scroll = 0;
		break;
	case ID_APPLY:
		{

			int i = uiTouchOptions.profiles.curItem;

			// preset selected
			if( i > 0 && i < uiTouchOptions.firstProfile - 1 )
			{
				char command[256];
				char *curconfig = CVAR_GET_STRING( "touch_config_file" );
				snprintf( command, 256, "exec \"touch_presets/%s\"\n", uiTouchOptions.profileDesc[ i ] );
				CLIENT_COMMAND( 1,  command );

				while( FILE_EXISTS( curconfig ) )
				{
					char copystring[256];
					char filebase[256];

					COM_FileBase( curconfig, filebase );

					if( snprintf( copystring, 256, "touch_profiles/%s (new).cfg", filebase ) > 255 )
						break;

					CVAR_SET_STRING( "touch_config_file", copystring );
					curconfig = CVAR_GET_STRING( "touch_config_file" );
				}
			}
			else if( i == uiTouchOptions.firstProfile )
				CLIENT_COMMAND( 1,"exec touch.cfg\n" );
			else if( i > uiTouchOptions.firstProfile )
			{
				char command[256];
				snprintf( command, 256, "exec \"touch_profiles/%s\"\n", uiTouchOptions.profileDesc[ i ] );
				CLIENT_COMMAND( 1,  command );
			}

			// try save config
			CLIENT_COMMAND( 1,  "touch_writeconfig\n" );

			// check if it failed ant reset profile to default if it is
			if( !FILE_EXISTS( CVAR_GET_STRING( "touch_config_file" ) ))
			{
				CVAR_SET_STRING( "touch_config_file", "touch.cfg" );
				uiTouchOptions.profiles.curItem = uiTouchOptions.firstProfile;
			}
			UI_TouchOptions_GetProfileList();
			UI_TouchOptions_GetConfig();
		}
	}
}
Example #23
0
/*
=================
UI_RecDemo_Callback
=================
*/
static void UI_RecDemo_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	if( event == QM_CHANGED )
	{
		// never overwrite existing saves, because their names was never get collision
		if( strlen( uiRecDemo.demoName[uiRecDemo.demosList.curItem] ) == 0 || !CL_IsActive() || gpGlobals->demoplayback )
			uiRecDemo.record.generic.flags |= QMF_GRAYED;
		else uiRecDemo.record.generic.flags &= ~QMF_GRAYED;

		if( strlen( uiRecDemo.delName[uiRecDemo.demosList.curItem] ) == 0 || !stricmp( gpGlobals->demoname, uiRecDemo.delName[uiRecDemo.demosList.curItem] ))
			uiRecDemo.remove.generic.flags |= QMF_GRAYED;
		else uiRecDemo.remove.generic.flags &= ~QMF_GRAYED;
		return;
	}

	if( event != QM_ACTIVATED )
		return;
	
	switch( item->id )
	{
	case ID_CANCEL:
		UI_PopMenu();
		break;
	case ID_RECORD:
		if( gpGlobals->demorecording )
		{
			CLIENT_COMMAND( FALSE, "stop" );
			uiRecDemo.record.generic.name = "Record";
			uiRecDemo.record.generic.statusText = "Record a new demo";
			uiRecDemo.remove.generic.flags &= ~QMF_GRAYED;
		}
		else if( strlen( uiRecDemo.demoName[uiRecDemo.demosList.curItem] ))
		{
			char	cmd[128];

			sprintf( cmd, "demos/%s.bmp", uiRecDemo.demoName[uiRecDemo.demosList.curItem] );
			PIC_Free( cmd );

			sprintf( cmd, "record \"%s\"\n", uiRecDemo.demoName[uiRecDemo.demosList.curItem] );
			CLIENT_COMMAND( FALSE, cmd );
			UI_CloseMenu();
		}
		break;
	case ID_NO:
	case ID_DELETE:
		UI_DeleteDialog();
		break;
	case ID_YES:
		if( strlen( uiRecDemo.delName[uiRecDemo.demosList.curItem] ))
		{
			char	cmd[128];
			sprintf( cmd, "killdemo \"%s\"\n", uiRecDemo.delName[uiRecDemo.demosList.curItem] );

			CLIENT_COMMAND( TRUE, cmd );

			sprintf( cmd, "demos/%s.bmp", uiRecDemo.delName[uiRecDemo.demosList.curItem] );
			PIC_Free( cmd );

			// restarts the menu
			UI_PopMenu();
			UI_RecDemo_Menu();
			return;
		}
		UI_DeleteDialog();
		break;
	}
}
Example #24
0
/*
=================
UI_PlayDemo_Callback
=================
*/
static void UI_PlayDemo_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	if( event == QM_CHANGED )
	{
		if( strlen( uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] ) == 0 )
			uiPlayDemo.play.generic.flags |= QMF_GRAYED;
		else uiPlayDemo.play.generic.flags &= ~QMF_GRAYED;

		if( strlen( uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ) == 0 || !stricmp( gpGlobals->demoname, uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ))
			uiPlayDemo.remove.generic.flags |= QMF_GRAYED;
		else uiPlayDemo.remove.generic.flags &= ~QMF_GRAYED;
		return;
	}

	if( event != QM_ACTIVATED )
		return;
	
	switch( item->id )
	{
	case ID_CANCEL:
		UI_PopMenu();
		break;
	case ID_PLAY:
		if( gpGlobals->demoplayback || gpGlobals->demorecording )
		{
			CLIENT_COMMAND( FALSE, "stop" );
			uiPlayDemo.play.generic.name = "Play";
			uiPlayDemo.play.generic.statusText = "Play a demo";
			uiPlayDemo.remove.generic.flags &= ~QMF_GRAYED;
		}
		else if( strlen( uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] ))
		{
			char	cmd[128];
			sprintf( cmd, "playdemo \"%s\"\n", uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] );
			CLIENT_COMMAND( FALSE, cmd );
		}
		break;
	case ID_NO:
	case ID_DELETE:
		UI_DeleteDialog();
		break;
	case ID_YES:
		if( strlen( uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ))
		{
			char	cmd[128];
			sprintf( cmd, "killdemo \"%s\"\n", uiPlayDemo.delName[uiPlayDemo.demosList.curItem] );

			CLIENT_COMMAND( TRUE, cmd );

			sprintf( cmd, "demos/%s.bmp", uiPlayDemo.delName[uiPlayDemo.demosList.curItem] );
			PIC_Free( cmd );

			// restarts the menu
			UI_PopMenu();
			UI_PlayDemo_Menu();
			return;
		}
		UI_DeleteDialog();
		break;
	}
}
Example #25
0
/*
=================
UI_TouchButtons_Callback
=================
*/
static void UI_TouchButtons_Callback( void *self, int event )
{
    menuCommon_s	*item = (menuCommon_s *)self;

    switch( item->id )
    {
    case ID_SP:
        if( uiTouchButtons.sp.enabled )
            uiTouchButtons.mp.enabled = false;
    case ID_MP:
        if( uiTouchButtons.mp.enabled )
            uiTouchButtons.sp.enabled = false;
    case ID_HIDE:
    case ID_ADDITIVE:
    case ID_PRECISION:
    case ID_LOCK:
        if( event == QM_PRESSED )
            ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_PRESSED;
        else ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_FOCUS;
        // clean all flags that we may change
        uiTouchButtons.curflags &= ~ ( TOUCH_FL_HIDE | TOUCH_FL_NOEDIT | TOUCH_FL_MP | TOUCH_FL_SP | TOUCH_FL_DRAW_ADDITIVE | TOUCH_FL_PRECISION );
        if( uiTouchButtons.mp.enabled )
            uiTouchButtons.curflags |= TOUCH_FL_MP;
        if( uiTouchButtons.sp.enabled )
            uiTouchButtons.curflags |= TOUCH_FL_SP;
        if( uiTouchButtons.hide.enabled )
            uiTouchButtons.curflags |= TOUCH_FL_HIDE;
        if( uiTouchButtons.lock.enabled )
            uiTouchButtons.curflags |= TOUCH_FL_NOEDIT;
        if( uiTouchButtons.additive.enabled )
            uiTouchButtons.curflags |= TOUCH_FL_DRAW_ADDITIVE;
        if( uiTouchButtons.precision.enabled )
            uiTouchButtons.curflags |= TOUCH_FL_PRECISION;
        break;
    }

    if( event == QM_CHANGED )
    {
        switch( item->id )
        {
        case ID_TEXTURE:
            // update current texture
            if( uiTouchButtons.texture.buffer[0] && uiTouchButtons.texture.buffer[0] != '#' )
                uiTouchButtons.textureid = PIC_Load(uiTouchButtons.texture.buffer);
            else
                uiTouchButtons.textureid = 0;
            break;
        case ID_BUTTONLIST:
            UI_TouchButtons_UpdateFields();
            break;
        }
        return;
    }

    if( event != QM_ACTIVATED )
        return;

    switch( item->id )
    {
    case ID_DONE:
        CLIENT_COMMAND(0, "touch_writeconfig\n");
        UI_PopMenu();
        break;
    case ID_CANCEL:
        CLIENT_COMMAND(0, "touch_loadconfig\n");
        UI_PopMenu();
        break;
    case ID_RESET:
        UI_TouchButtons_DisableButtons();

        uiTouchButtons.msgBox.generic.flags &= ~QMF_HIDDEN;
        uiTouchButtons.promptMessage.generic.flags &= ~QMF_HIDDEN;
        uiTouchButtons.no.generic.flags &= ~QMF_HIDDEN;
        uiTouchButtons.yes.generic.flags &= ~QMF_HIDDEN;
        strcpy( uiTouchButtons.dialogText, "Reset all buttons?" );
        uiTouchButtons.dialogAction = UI_ResetButtons;
        break;
    case ID_DELETE:
        UI_TouchButtons_DisableButtons();


        uiTouchButtons.msgBox.generic.flags &= ~QMF_HIDDEN;
        uiTouchButtons.promptMessage.generic.flags &= ~QMF_HIDDEN;
        uiTouchButtons.no.generic.flags &= ~QMF_HIDDEN;
        uiTouchButtons.yes.generic.flags &= ~QMF_HIDDEN;
        strcpy( uiTouchButtons.dialogText, "Delete selected button?" );
        uiTouchButtons.dialogAction = UI_DeleteButton;
        break;
    case ID_YES:
        if( uiTouchButtons.dialogAction )
            uiTouchButtons.dialogAction();
    case ID_NO:
        UI_TouchButtons_EnableButtons();

        uiTouchButtons.msgBox.generic.flags |= QMF_HIDDEN;
        uiTouchButtons.promptMessage.generic.flags |= QMF_HIDDEN;
        uiTouchButtons.no.generic.flags |= QMF_HIDDEN;
        uiTouchButtons.yes.generic.flags |= QMF_HIDDEN;
        break;
    case ID_SAVE:
        if( strlen(uiTouchButtons.name.buffer) > 0)
        {
            char command[256];
            snprintf( command, 256, "touch_addbutton \"%s\" \"%s\" \"%s\"\n", uiTouchButtons.name.buffer,
                      uiTouchButtons.texture.buffer, uiTouchButtons.command.buffer );
            CLIENT_COMMAND(0, command);
            snprintf( command, 256, "touch_setflags \"%s\" %i\n", uiTouchButtons.name.buffer, uiTouchButtons.curflags );
            CLIENT_COMMAND(0, command);
            snprintf( command, 256, "touch_setcolor \"%s\" %d %d %d %d\n", uiTouchButtons.name.buffer, CURCOLOR1(red), CURCOLOR1(green), CURCOLOR1(blue),CURCOLOR1(alpha) );
            CLIENT_COMMAND(1, command);
            uiTouchButtons.name.buffer[0] = 0;
            uiTouchButtons.name.cursor = 0;
        }
        else
        {
            char command[256];
            snprintf( command, 256, "touch_settexture \"%s\" \"%s\"\n", uiTouchButtons.selectedName, uiTouchButtons.texture.buffer );
            CLIENT_COMMAND(0, command);
            snprintf( command, 256, "touch_setcommand \"%s\" \"%s\"\n", uiTouchButtons.selectedName, uiTouchButtons.command.buffer );
            CLIENT_COMMAND(0, command);
            snprintf( command, 256, "touch_setflags \"%s\" %i\n", uiTouchButtons.selectedName, uiTouchButtons.curflags );
            CLIENT_COMMAND(0, command);
            snprintf( command, 256, "touch_setcolor \"%s\" %d %d %d %d\n", uiTouchButtons.selectedName, CURCOLOR1(red), CURCOLOR1(green), CURCOLOR1(blue),CURCOLOR1(alpha) );
            CLIENT_COMMAND(1, command);
        }
        UI_TouchButtons_GetButtonList();
        break;
    case ID_EDITOR:
        UI_TouchEdit_Menu();
        break;
    case ID_SELECT:
        UI_TouchButtons_DisableButtons();
        uiFileDialogGlobal.npatterns = 7;
        strcpy( uiFileDialogGlobal.patterns[0], "touch/*.tga");
        strcpy( uiFileDialogGlobal.patterns[1], "touch_default/*.tga");
        strcpy( uiFileDialogGlobal.patterns[2], "gfx/touch/*");
        strcpy( uiFileDialogGlobal.patterns[3], "gfx/vgui/*");
        strcpy( uiFileDialogGlobal.patterns[4], "gfx/shell/*");
        strcpy( uiFileDialogGlobal.patterns[5], "*.tga");
        uiFileDialogGlobal.preview = true;
        uiFileDialogGlobal.valid = true;
        uiFileDialogGlobal.callback = UI_TouchButtons_FileDialogCallback;
        UI_FileDialog_Menu();
        break;
    }

}
Example #26
0
/*
=================
UI_Controls_KeyFunc
=================
*/
static const char *UI_Controls_KeyFunc( int key, int down )
{
	char	cmd[128];

	if( uiControls.msgBox1.generic.flags & QMF_HIDDEN )
	{
		if( down && key == K_ESCAPE && uiControls.defaults.generic.flags & QMF_INACTIVE )
		{
			UI_ResetToDefaultsDialog();
			return uiSoundNull;
		}
	}
	
	if( down )
	{
		if( uiControls.bind_grab )	// assume we are in grab-mode
		{
			// defining a key
			if( key == '`' || key == '~' )
			{
				return uiSoundBuzz;
			}
			else if( key != K_ESCAPE )
			{
				const char *bindName = uiControls.keysBind[uiControls.keysList.curItem];
				sprintf( cmd, "bind \"%s\" \"%s\"\n", KEY_KeynumToString( key ), bindName );
				CLIENT_COMMAND( TRUE, cmd );
			}

			uiControls.bind_grab = false;
			UI_Controls_RestartMenu();

			return uiSoundLaunch;
		}

		if( key == K_ENTER && uiControls.dlgMessage.generic.flags & QMF_HIDDEN )
		{
			if( !strlen( uiControls.keysBind[uiControls.keysList.curItem] ))
			{
				// probably it's a seperator
				return uiSoundBuzz;
			}

			// entering to grab-mode
			const char *bindName = uiControls.keysBind[uiControls.keysList.curItem];
			int keys[2];
	
			UI_Controls_GetKeyBindings( bindName, keys );
			if( keys[1] != -1 ) UI_UnbindCommand( bindName );
			uiControls.bind_grab = true;

			UI_PromptDialog();	// show prompt
			return uiSoundKey;
		}

		if(( key == K_BACKSPACE || key == K_DEL ) && uiControls.dlgMessage.generic.flags & QMF_HIDDEN )
		{
			// delete bindings

			if( !strlen( uiControls.keysBind[uiControls.keysList.curItem] ))
			{
				// probably it's a seperator
				return uiSoundNull;
			}

			const char *bindName = uiControls.keysBind[uiControls.keysList.curItem];
			UI_UnbindCommand( bindName );
			UI_StartSound( uiSoundRemoveKey );
			UI_Controls_RestartMenu();

			return uiSoundNull;
		}
	}
	return UI_DefaultKey( &uiControls.menu, key, down );
}
/*
=================
UI_Main_Callback
=================
*/
static void UI_Main_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	switch( item->id )
	{
	case ID_QUIT_BUTTON:
		if( event == QM_PRESSED )
			((menuBitmap_s *)self)->focusPic = ART_CLOSEBTN_D;
		else ((menuBitmap_s *)self)->focusPic = ART_CLOSEBTN_F;
		break;
	case ID_MINIMIZE:
		if( event == QM_PRESSED )
			((menuBitmap_s *)self)->focusPic = ART_MINIMIZE_D;
		else ((menuBitmap_s *)self)->focusPic = ART_MINIMIZE_F;
		break;
	}

	if( event != QM_ACTIVATED )
		return;

	switch( item->id )
	{
	case ID_CONSOLE:
		UI_SetActiveMenu( FALSE );
		KEY_SetDest( KEY_CONSOLE );
		break;
	case ID_RESUME:
		UI_CloseMenu();
		break;
	case ID_NEWGAME:
		if( CL_IsActive( ))
			UI_PromptDialog();
		else UI_Main_NewGame();
		break;
	case ID_MULTIPLAYER:
		UI_MultiPlayer_Menu();
		break;
	case ID_CONFIGURATION:
		UI_Options_Menu();
		break;
	case ID_SAVERESTORE:
		if( CL_IsActive( ))
			UI_SaveLoad_Menu();
		else UI_LoadGame_Menu();
		break;
	case ID_CUSTOMGAME:
		UI_CustomGame_Menu();
		break;
	case ID_PREVIEWS:
		SHELL_EXECUTE( MenuStrings[HINT_PREVIEWS_CMD], NULL, false );
		break;
	case ID_QUIT:
	case ID_QUIT_BUTTON:
		UI_QuitDialog();
		break;
	case ID_MINIMIZE:
		CLIENT_COMMAND( FALSE, "minimize\n" );
		break;
	case ID_YES:
		if( !( uiMain.quitMessage.generic.flags & QMF_HIDDEN ))
			CLIENT_COMMAND( FALSE, "quit\n" );
		else UI_Main_NewGame();
		break;
	case ID_NO:
		if( !( uiMain.quitMessage.generic.flags & QMF_HIDDEN ))
			UI_QuitDialog();
		else UI_PromptDialog();
		break;
	}
}
Example #28
0
/*
=================
UI_SaveGame_Callback
=================
*/
static void UI_SaveGame_Callback( void *self, int event )
{
	menuCommon_s	*item = (menuCommon_s *)self;

	if( event == QM_CHANGED )
	{
		// never overwrite existing saves, because their names was never get collision
		if ( strlen( uiSaveGame.saveName[uiSaveGame.savesList.curItem] ) == 0 || CL_IsActive() == FALSE )
			uiSaveGame.save.generic.flags |= QMF_GRAYED;
		else uiSaveGame.save.generic.flags &= ~QMF_GRAYED;

		if ( strlen( uiSaveGame.delName[uiSaveGame.savesList.curItem] ) == 0 )
			uiSaveGame.remove.generic.flags |= QMF_GRAYED;
		else uiSaveGame.remove.generic.flags &= ~QMF_GRAYED;
		return;
	}

	if( event != QM_ACTIVATED )
		return;
	
	switch( item->id )
	{
	case ID_CANCEL:
		UI_PopMenu();
		break;
	case ID_SAVE:
		if( strlen( uiSaveGame.saveName[uiSaveGame.savesList.curItem] ))
		{
			char	cmd[128];

			sprintf( cmd, "save/%s.bmp", uiSaveGame.saveName[uiSaveGame.savesList.curItem] );
			PIC_Free( cmd );

			sprintf( cmd, "save \"%s\"\n", uiSaveGame.saveName[uiSaveGame.savesList.curItem] );
			CLIENT_COMMAND( FALSE, cmd );
			UI_CloseMenu();
		}
		break;
	case ID_NO:
	case ID_DELETE:
		UI_DeleteDialog();
		break;
	case ID_YES:
		if( strlen( uiSaveGame.delName[uiSaveGame.savesList.curItem] ))
		{
			char	cmd[128];
			sprintf( cmd, "killsave \"%s\"\n", uiSaveGame.delName[uiSaveGame.savesList.curItem] );

			CLIENT_COMMAND( TRUE, cmd );

			sprintf( cmd, "save/%s.bmp", uiSaveGame.delName[uiSaveGame.savesList.curItem] );
			PIC_Free( cmd );

			// restarts the menu
			UI_PopMenu();
			UI_SaveGame_Menu();
			return;
		}
		UI_DeleteDialog();
		break;
	}
}
Example #29
0
static void UI_ResetButtons()
{
    CLIENT_COMMAND( 0, "touch_removeall\n" );
    CLIENT_COMMAND( 1, "touch_loaddefaults\n" );
    UI_TouchButtons_GetButtonList();
}