Beispiel #1
0
void CHudAmmo::UserCmd_Close(void)
{
	if(gpActiveSel)
	{
		gpLastSel   = gpActiveSel;
		gpActiveSel = NULL;
		PlaySound("common/wpn_hudoff.wav", 1);
	}
	else
		ClientCmd("escape");
}
Beispiel #2
0
void CHudAmmo::UserCmd_Close(void)
{
	if (gpActiveSel)
	{
		gpLastSel = gpActiveSel;
		gpActiveSel = NULL;

		// Fograin92: Replaced with new audio engine
		gSoundEngine.PlaySound("common/wpn_hudoff.wav", g_vecZero, SND_2D, 0, CVAR_GET_FLOAT("sm_snd_sfx"));
	}
	else
		ClientCmd("escape");
}
Beispiel #3
0
// selects an item from the menu
void CHudMenu :: SelectMenuItem( int menu_item )
{
	// if menu_item is in a valid slot,  send a menuselect command to the server
	if(( menu_item > 0 ) && ( m_bitsValidSlots & (1 << ( menu_item - 1 ))))
	{
		char szbuf[32];
		sprintf( szbuf, "menuselect %d\n", menu_item );
		ClientCmd( szbuf );

		// remove the menu
		m_fMenuDisplayed = 0;
		m_iFlags &= ~HUD_ACTIVE;
	}
}
Beispiel #4
0
int CHud :: MsgFunc_Clcommand( const char *pszName, int iSize, void *pbuf )
{
	BEGIN_READ( pbuf, iSize );

	const char *tmpcmd2 = READ_STRING();
	int sayteamno		= READ_BYTE();

	char tmpcmd3[512];

	if (sayteamno == 0)
		sprintf(tmpcmd3, "say_team %s", CHudTextMessage::BufferedLocaliseTextString( tmpcmd2 ));
	else
		sprintf(tmpcmd3, "%s", tmpcmd2);

	ClientCmd(tmpcmd3);

	return 1;
}
// Runs a client command, returns success
static int clientCommand(lua_State* inState)
{
	bool theSuccess = false;

	int theNumArgs = lua_gettop(inState);
	if(theNumArgs >= 1)
	{
		string theConsoleCommandString = lua_tostring(inState, 1);

		char theConsoleCommand[1024];
		strcpy(theConsoleCommand, theConsoleCommandString.c_str());
		ClientCmd(theConsoleCommand);

		theSuccess = true;
	}

	lua_pushnumber(inState, theSuccess);

	return 1;
}
Beispiel #6
0
void AvHCommanderModeHandler::mouseReleased(MouseCode code, Panel* inPanel)
{

    App::getInstance()->setMouseCapture(NULL);

    if(code == MOUSE_LEFT)
    {

        if (GetIsPointInPanel(inPanel, mLastMouseX, mLastMouseY))
        {

            ActionButton* theActionButton = dynamic_cast<ActionButton*>(inPanel);

            if(theActionButton && this->mMouseOneDownOnActionButtons)
            {
                this->ActionButtonActivated(theActionButton);
            }
            else if(dynamic_cast<AvHLogoutComponent*>(inPanel) && this->mMouseOneDownOnLogoutButton)
            {
                if(gHUD.GetUIMode() == MAIN_MODE)
                {
                    ClientCmd(kcStopCommandMode);
                    this->mDisplayMenu = AVH_USER3_MENU_BUILD;
                    this->mDisplayMenuMessageID = MENU_BUILD;
                }
            }

        }

        this->mMouseOneDown = false;
        this->mMouseOneDownOnActionButtons = false;
        this->mMouseOneDownOnLogoutButton = false;
    }
    else if(code == MOUSE_RIGHT)
    {
        this->mMouseTwoDown = false;
    }
}
Beispiel #7
0
void CHudMenu::ShowVGUIMenu( int menuType )
{
	const char *szCmd;

	switch(menuType)
	{
	case MENU_TEAM:
		szCmd = "exec touch/chooseteam.cfg";
		break;
	case MENU_CLASS_T:
		szCmd = "exec touch/chooseteam_tr.cfg";
		break;
	case MENU_CLASS_CT:
		szCmd = "exec touch/chooseteam_ct.cfg";
		break;
	case MENU_BUY:
		szCmd = "exec touch/buy.cfg";
		break;
	case MENU_BUY_PISTOL:
		if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
			szCmd = "exec touch/buy_pistol_t.cfg";
		else szCmd = "exec touch/buy_pistol_ct.cfg";
		break;
	case MENU_BUY_SHOTGUN:
		if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
			szCmd = "exec touch/buy_shotgun_t.cfg";
		else szCmd = "exec touch/buy_shotgun_ct.cfg";
		break;
	case MENU_BUY_RIFLE:
		if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
			szCmd = "exec touch/buy_rifle_t.cfg";
		else szCmd ="exec touch/buy_rifle_ct.cfg";
		break;
	case MENU_BUY_SUBMACHINEGUN:
		if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
			szCmd = "exec touch/buy_submachinegun_t.cfg";
		else szCmd = "exec touch/buy_submachinegun_ct.cfg";
		break;
	case MENU_BUY_MACHINEGUN:
		if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
			szCmd = "exec touch/buy_machinegun_t.cfg";
		else szCmd = "exec touch/buy_machinegun_ct.cfg";
		break;
	case MENU_BUY_ITEM:
		if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
			szCmd = "exec touch/buy_item_t.cfg";
		else szCmd = "exec touch/buy_item_ct.cfg";
		break;
	case MENU_RADIOA:
		szCmd = "exec touch/radioa.cfg";
		break;
	case MENU_RADIOB:
		szCmd = "exec touch/radiob.cfg";
		break;
	case MENU_RADIOC:
		szCmd = "exec touch/radioc.cfg";
		break;
	case MENU_RADIOSELECTOR:
		szCmd = "exec touch/radioselector.cfg";
		break;
	case MENU_NUMERICAL_MENU:
		szCmd = "exec touch/numerical_menu.cfg";
		break;
	default:
		szCmd = "touch_removebutton _menu_*"; // back to the default touch page
		m_fMenuDisplayed = 0;
		break;
	}

	m_fMenuDisplayed = 1;
	ClientCmd(szCmd);
}
Beispiel #8
0
// Message handler for ShowMenu message
// takes four values:
//		short: a bitfield of keys that are valid input
//		char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen.
//		byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string
//		string: menu string to display
// if this message is never received, then scores will simply be the combined totals of the players.
int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
{
	char *temp = NULL, *menustring;

	BEGIN_READ( pbuf, iSize );

	m_bitsValidSlots = READ_SHORT();
	int DisplayTime = READ_CHAR();
	int NeedMore = READ_BYTE();

	if ( DisplayTime > 0 )
		m_flShutoffTime = DisplayTime + gHUD.m_flTime;
	else
		m_flShutoffTime = -1;

	if ( !m_bitsValidSlots )
	{
		m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
		m_iFlags &= ~HUD_ACTIVE;
		ClientCmd("touch_removebutton _menu_*");
		return 1;
	}

	menustring = READ_STRING();

	// menu will be replaced by scripted touch config
	// so execute it and exit
	if( _extended_menus->value != 0.0f )
	{
		if( !strcmp(menustring, "#RadioA") )
		{
			ShowVGUIMenu(MENU_RADIOA);
			return 1;
		}
		else if( !strcmp(menustring, "#RadioB"))
		{
			ShowVGUIMenu(MENU_RADIOB);
			return 1;
		}
		else if( !strcmp(menustring, "#RadioC"))
		{
			ShowVGUIMenu(MENU_RADIOC);
			return 1;
		}
		else
		{
			// we just show touch screen numbers
			ShowVGUIMenu(MENU_NUMERICAL_MENU);
		}
	}
	else
	{
		// we just show touch screen numbers
		ShowVGUIMenu(MENU_NUMERICAL_MENU);
	}

	if ( !m_fWaitingForMore ) // this is the start of a new menu
	{
		strncpy( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING );
	}
	else
	{  // append to the current menu string
		strncat( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
	}
	g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0;  // ensure null termination (strncat/strncpy does not)

	if ( !NeedMore )
	{  // we have the whole string, so we can localise it now
		strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING );

		// Swap in characters
		if ( KB_ConvertString( g_szMenuString, &temp ) )
		{
			strncpy( g_szMenuString, temp, MAX_MENU_STRING );
			free( temp );
		}
	}

	m_fMenuDisplayed = 1;
	m_iFlags |= HUD_ACTIVE;

	m_fWaitingForMore = NeedMore;

	return 1;
}
Beispiel #9
0
////////////////////////////////
// Functions from InputSignal //
////////////////////////////////
void UIManager::cursorMoved(int inX, int inY, Panel* inPanel)
{
    if(!inPanel)
    {
        ClientCmd("say cursorMoved with null inPanel!  Yeah!\n");
    }

    // x,y are local to the upper left of the panel. 
    int theLocalX = inX;
    int theLocalY = inY;

    // Get screen coordinates
    int theScreenX, theScreenY;
    this->GetScreenCoords(theScreenX, theScreenY);

    // This function should only be called when mouse visible and we are in edit mode
    if(this->mEditMode)
    {
        // We can't assume that a cursorEntered will always get called before a cursor moved, so 
        // call cursorEntered if we don't have a component yet (happens when toggling between the two modes
        if(!this->mComponentMouseOver)
        {
            this->cursorEntered(inPanel);
        }
        
        // Number of pixels to move with the mouse button down before we start dragging
        const int START_DRAG_PIXEL_DIST = 6;
        const int MIN_DRAG_PIXEL_DIST = 4;
        static int theStartDragLocalXOffset = 0;
        static int theStartDragLocalYOffset = 0;
        
        // Check how far we have moved, are we dragging yet?
        if((!this->mDraggingLMB) &&
            (this->mLMBDownX != -1) && 
            (this->mLMBDownY != -1))
        {
            int theXDiff = theScreenX - this->mLMBDownX;
            int theYDiff = theScreenY - this->mLMBDownY;
            
            // Requires more movement in diagonal direction, probably not
            // worth the extra complexity to change
            if((abs(theXDiff) > START_DRAG_PIXEL_DIST) ||
                (abs(theYDiff) > START_DRAG_PIXEL_DIST))
            {
                //ClientCmd("say Starting drag");
                
                // Save the offset from the component's upper left.  Preserve
                // this when for more intuitive dragging (so dragging doesn't
                // suddenly move the component relative to the mouse).
                theStartDragLocalXOffset = theLocalX;
                theStartDragLocalYOffset = theLocalY;

                //inPanel->setAsMouseArena(true);
                
                this->mDraggingLMB = true;
            }
        }
        
        // Are we dragging?
        if(this->mDraggingLMB)
        {
            // If so, set the component's new position. The position corresponds to the upper
            // left corner of the component, so subtract out the local offset.
            // The component's new position is equal to the current screen pos of the mouse, MINUS
            // the local component offset which we started the drag.  If we were dragging the component
            // around by the upper left corner, this would be like setting the component's position equal
            // to whatever the mouse was at during a mouse move.  If we were dragging it by the center,
            // it would set the component's position to the current screen mouse pos minus half the component
            // width and height. Make sense?
            //ClientCmd("say Setting new component position");
            int theChangeX = theScreenX - theStartDragLocalXOffset;
            int theChangeY = theScreenY - theStartDragLocalYOffset;

            // Make sure we move at least a few pixels, because we're bound by control and we 
            // could've grabbed it near one of the edges
            theChangeX = max(theChangeX, MIN_DRAG_PIXEL_DIST);
            theChangeY = max(theChangeY, MIN_DRAG_PIXEL_DIST);
            this->SetPanelPosition(inPanel, theChangeX, theChangeY);
        }
    }

    // Update new mouse position
    this->mLastMouseX = theScreenX;
    this->mLastMouseY = theScreenY;
}