//-----------------------------------------------------------------------------
// Purpose: called every frame to get ammo info from the weapon
//-----------------------------------------------------------------------------
void CDoDHudAmmo::OnThink()
{
    C_BaseCombatWeapon *wpn = GetActiveWeapon();
    C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();

    hudlcd->SetGlobalStat( "(weapon_print_name)", wpn ? wpn->GetPrintName() : " " );
    hudlcd->SetGlobalStat( "(weapon_name)", wpn ? wpn->GetName() : " " );

    if ( !wpn || !player || !wpn->UsesPrimaryAmmo() )
    {
        hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
        hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );

        SetPaintEnabled( false );
        SetPaintBackgroundEnabled( false );
        return;
    }
    else
    {
        SetPaintEnabled( true );
        SetPaintBackgroundEnabled( true );
    }

    // get the ammo in our clip
    int ammo1 = wpn->Clip1();
    int ammo2;
    if ( ammo1 < 0 )
    {
        // we don't use clip ammo, just use the total ammo count
        ammo1 = player->GetAmmoCount( wpn->GetPrimaryAmmoType() );
        ammo2 = 0;
    }
    else
    {
        // we use clip ammo, so the second ammo is the total ammo
        ammo2 = player->GetAmmoCount( wpn->GetPrimaryAmmoType() );
    }

    hudlcd->SetGlobalStat( "(ammo_primary)", VarArgs( "%d", ammo1 ) );
    hudlcd->SetGlobalStat( "(ammo_secondary)", VarArgs( "%d", ammo2 ) );

    if ( wpn == m_hCurrentActiveWeapon )
    {
        // same weapon, just update counts
        SetAmmo( ammo1, true );
        SetAmmo2( ammo2, true );
    }
    else
    {
        // diferent weapon, change without triggering
        SetAmmo( ammo1, false );
        SetAmmo2( ammo2, false );

        // update whether or not we show the total ammo display
        m_bUsesClips = wpn->UsesClipsForAmmo1();
        m_hCurrentActiveWeapon = wpn;
    }
}
    virtual void OnThink()
    {
        // set whether or not the panel draws based on if we have a weapon that supports secondary ammo
        C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
        C_BaseCombatWeapon *wpn = player ? player->GetActiveWeapon() : NULL;
        IClientVehicle *pVehicle = player ? player->GetVehicle() : NULL;
        if (!wpn || !player || pVehicle)
        {
            m_hCurrentActiveWeapon = NULL;
            SetPaintEnabled(false);
            SetPaintBackgroundEnabled(false);
            return;
        }
        else
        {
            SetPaintEnabled(true);
            SetPaintBackgroundEnabled(true);
        }

        UpdateAmmoState();
    }
//-----------------------------------------------------------------------------
// C_SDKRootPanel implementation.
//-----------------------------------------------------------------------------
C_SDKRootPanel::C_SDKRootPanel( vgui::VPANEL parent )
	: BaseClass( NULL, "SDK Root Panel" )
{
	SetParent( parent );
	SetPaintEnabled( false );
	SetPaintBorderEnabled( false );
	SetPaintBackgroundEnabled( false );

	// This panel does post child painting
	SetPostChildPaintEnabled( true );

	// Make it screen sized
	SetBounds( 0, 0, ScreenWidth(), ScreenHeight() );

	// Ask for OnTick messages
	vgui::ivgui()->AddTickSignal( GetVPanel() );
}
void CEditorRoot::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

	SetPaintBackgroundEnabled(true);
	SetPaintBorderEnabled(false);
	SetPaintEnabled(true);
	SetCloseButtonVisible(false);
	SetSizeable(false);
	SetMoveable(false);

	InitColors();

	SetTitle( "", true );
	SetTitleBarVisible( false );
	m_pLabelTitle->SetText( GetEditorTitle() );
	m_pLabelTitle->SetFont( pScheme->GetFont( "UiBold", false ) );

	SetPaintBackgroundType( 0 );
	OnShaderNameChanged();
	GenerateFonts(pScheme);
}
示例#5
0
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CToolUI::CToolUI( vgui::Panel *pParent, const char *panelName, CBaseToolSystem *pBaseToolSystem ) :
	BaseClass( pParent, panelName ), m_pClientArea( 0 ), m_pBaseToolSystem( pBaseToolSystem )
{
	SetPaintEnabled(false);
	SetPaintBackgroundEnabled(false);
	SetPaintBorderEnabled(false);

	int w, h;
	pParent->GetSize( w, h );
	SetBounds( 0, 0, w, h );

	m_pMenuBar = m_pBaseToolSystem->CreateMenuBar( m_pBaseToolSystem );
	m_pMenuBar->SetParent( this );
	m_pMenuBar->SetSize( w, MENU_HEIGHT );
	// This can be NULL if no status bar should be included
	m_pStatusBar = m_pBaseToolSystem->CreateStatusBar( this );
	m_pStatusBar->SetParent( this );

	m_pClientArea = new vgui::Panel( this, "ClientArea" );
	m_pClientArea->SetMouseInputEnabled( false );
	m_pClientArea->SetCursor( vgui::dc_none );
	m_pClientArea->SetBounds( 0, MENU_HEIGHT, w, h - MENU_HEIGHT );
}
CCode_Editor::CCode_Editor( CSheet_Base *parent, const char *pName, CSmartText::CodeEditMode_t mode ) : BaseClass( parent, pName )
{
	m_iMode = mode;

	Activate();
	SetVisible( true );

	SetPaintBackgroundEnabled(true);
	SetPaintEnabled(true);

	SetSizeable(true);
	SetMoveable(true);
	SetMinimumSize( 500, 400 );

	SetDeleteSelfOnClose( true );

	m_iLastAppliedCodeIndex = 0;

	m_pCodeWindow = new CSmartText( this, "codewindow", mode );
	m_pCodeWindow->AddActionSignalTarget( this );

	/*
	TextEntry *pT = new TextEntry( this, "codewindow" );
	pT->SetMultiline( true );
	pT->SetEditable( true );
	pT->SetCatchEnterKey( true );
	pT->SetVerticalScrollbar( true );
	*/

	LoadControlSettings( "shadereditorui/vgui/code_editor_Window.res" );

	UpdateButtonEnabled( true, true );
	SetCloseButtonVisible(false);

	int w,t;
	surface()->GetScreenSize( w, t );
	w *= 0.75f;
	t *= 0.75f;
	SetSize( max( w, 500 ), max( t, 400 ) );
	
	//SetKeyBoardInputEnabled( false );
	//SetMouseInputEnabled( true );

	//SetTitle( "Editor", true );
	SetTitle( "", false );

	Panel *pButton = FindChildByName( "button_save" );
	if ( pButton )
		pButton->SetKeyBoardInputEnabled( false );

	pButton = FindChildByName( "button_apply" );
	if ( pButton )
		pButton->SetKeyBoardInputEnabled( false );
	pButton = FindChildByName( "button_cancel" );
	if ( pButton )
		pButton->SetKeyBoardInputEnabled( false );

	DoModal();

	int rx, ry, rsx, rsy;
	if ( pEditorRoot->GetCodeEditorBounds( rx, ry, rsx, rsy ) )
		SetBounds( rx, ry, rsx, rsy );
	else
		MoveToCenterOfScreen();
}
CEditorRoot::CEditorRoot( const char *pElementName ) : BaseClass( NULL, "editor" )
{
	pEditorRoot = this;
	Q_memset( hFonts, 0, sizeof(hFonts) );
	Q_memset( hFonts2, 0, sizeof(hFonts2) );
//	m_pKV_MainPreviewMat = NULL;
	//m_pMat_MainPreview = NULL;
//	m_pKV_BGPreviewMat = NULL;
	//m_pMat_BGPreview = NULL;
	m_bPainting = false;
	m_bAutoCompile = true;
	m_bAutoFullcompile = false;
	m_bAutoShaderPublish = true;
	m_bAutoPrecacheUpdate = true;
	m_bWarnOnClose = true;

	InitColors();

	pPreview = NULL;
	m_pKV_NodeHelp = NULL;

	m_iNumMaterials = 0;
	m_pszMaterialList = NULL;

	m_pLastFullCompiledShader = NULL;

	//vgui::VPANEL GameUIRoot = enginevgui->GetPanel( PANEL_GAMEUIDLL );
	vgui::VPANEL EngineRoot = enginevgui->GetPanel( PANEL_ROOT );
	//vgui::VPANEL DLLRoot = VGui_GetClientDLLRootPanel();

	vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SourceScheme.res", "SourceScheme");
	SetScheme( scheme );

	m_pLabelTitle = new Label( this, "title_label", "" );

	pNodeSheet = new CFlowGraphSheet( this, "flowgraphsheets", true, true );
	pNodeSheet->AddActionSignalTarget( this );
	pNodeSheet->SetAddTabButtonEnabled( true );
	//pNodeSheet->ShowContextButtons(true);
	/*pNodeView =*/
	AddNewTab();

	//CFlowGraphPage *page = new CFlowGraphPage( this );
	//m_hFlowGraphPages.AddToTail( page );
	//CNodeView *view = new CNodeView( page, this, "main_nodeview" );
	//m_hNodeViews.AddToTail( pNodeView );
	//page->SetFlowGraph( pNodeView );
	//pNodeSheet->AddPage( page, GetDefaultTabName() );

	m_pLabel_Coords = new Label( this, "mouse_node_coords", "" );
	m_pLabel_FrameTime = new Label( this, "framespeed", "" );


	m_pMenuBar = new MenuBar( this, "menu_bar" );
	m_pMBut_File = new MenuButton( this, "mbut_file", "File" );
	m_pMBut_File->AddActionSignalTarget( this );
	Menu *pMenu_File = new Menu( m_pMBut_File, "" );
	pMenu_File->AddMenuItem( "New", new KeyValues("onmenufile","entry",ER_FMENU_NEW), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Open", new KeyValues("onmenufile","entry",ER_FMENU_OPEN), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Save", new KeyValues("onmenufile","entry",ER_FMENU_SAVE), this );
	pMenu_File->AddMenuItem( "Save as", new KeyValues("onmenufile","entry",ER_FMENU_SAVE_AS), this );
	pMenu_File->AddMenuItem( "Save all", new KeyValues("onmenufile","entry",ER_FMENU_SAVE_ALL), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Undo", new KeyValues("onmenufile","entry",ER_FMENU_UNDO), this );
	pMenu_File->AddMenuItem( "Redo", new KeyValues("onmenufile","entry",ER_FMENU_REDO), this );
	pMenu_File->AddSeparator();
	pMenu_File->AddMenuItem( "Take screenshot", new KeyValues("onmenufile","entry",ER_FMENU_SCREENSHOT), this );
	pMenu_File->AddMenuItem( "Editor config", new KeyValues("onmenufile","entry",ER_FMENU_ECONFIG), this );
	m_pMBut_File->SetMenu( pMenu_File );
	m_pMenuBar->AddButton( m_pMBut_File );

	m_pMBut_Shader = new MenuButton( this, "mbut_shader", "Shader" );
	Menu *pMenu_Shader = new Menu( m_pMBut_Shader, "" );
	pMenu_Shader->AddMenuItem( "Shader settings", new KeyValues("onmenushader","entry",ER_SMENU_SCONFIG), this );
	pMenu_Shader->AddMenuItem( "Shader precache", new KeyValues("onmenushader","entry",ER_SMENU_SPRECACHE), this );
	pMenu_Shader->AddSeparator();
	pMenu_Shader->AddMenuItem( "Full compile", new KeyValues("onmenushader","entry",ER_SMENU_FULLCOMPILE), this );
	pMenu_Shader->AddMenuItem( "Compile all precached", new KeyValues("onmenushader","entry",ER_SMENU_ALLCOMPILE), this );
	pMenu_Shader->AddMenuItem( "Terminate compilers", new KeyValues("onmenushader","entry",ER_SMENU_KILLCOMPILER), this );
	pMenu_Shader->AddSeparator();
	pMenu_Shader->AddMenuItem( "Inject shader into world", new KeyValues("onmenushader","entry",ER_SMENU_INJECT), this );
	pMenu_Shader->AddMenuItem( "Paint world", new KeyValues("onmenushader","entry",ER_SMENU_PAINT), this );
	m_pMBut_Shader->SetMenu( pMenu_Shader );
	m_pMenuBar->AddButton( m_pMBut_Shader );

	m_pMBut_PostProc = new MenuButton( this, "mbut_postproc", "Post processing" );
	Menu *pMenu_PostProc = new Menu( m_pMBut_PostProc, "" );
	pMenu_PostProc->AddMenuItem( "Effect settings", new KeyValues("onmenupostprocessing","entry",ER_PMENU_PCONFIG), this );
	pMenu_PostProc->AddMenuItem( "Effect precache", new KeyValues("onmenupostprocessing","entry",ER_PMENU_PPRECACHE), this );
	pMenu_PostProc->AddMenuItem( "Manage rendertargets", new KeyValues("onmenupostprocessing","entry",ER_PMENU_RTS), this );
	m_pMBut_PostProc->SetMenu( pMenu_PostProc );
	m_pMenuBar->AddButton( m_pMBut_PostProc );

	//m_pLabel_CurrentFileName = new Label( this, "filename", "-" );

	LoadControlSettings("shadereditorui/vgui/shadereditor_root.res");
	OnShaderNameChanged();

	Activate();
	SetVisible( true );
	SetPaintBorderEnabled( false );
	SetPaintBackgroundEnabled( true );
	SetPaintEnabled( true );
	SetParent( EngineRoot );

	m_pKV_SelectionCopy = NULL;
	bFontsLoaded = false;

	m_bHalfView = false;
	m_bHasInput = true;
	//m_bNeedsButtonPush = false;

	m_bDraw_Datatypes = true;
	m_bDraw_Shadows = true;
	m_bDraw_AllLimits = true;
	m_bDoTooltips = true;

	//m_szShaderName[0] = '\0';
	px = py = psx = psy = 0;
	cedit_x = cedit_y = cedit_sx = cedit_sy = -1;
	//m_flErrorTime = 0;

	AllocProceduralMaterials();
	UpdateVariablePointer();

	//m_iLastCompileIndex = GetSafeFlowgraph()->GetStackIndex();
}
//-----------------------------------------------------------------------------
// Purpose: called every frame to get ammo info from the weapon
//-----------------------------------------------------------------------------
void CHudAmmo::UpdatePlayerAmmo( C_BasePlayer *player )
{
    // Clear out the vehicle entity
    m_hCurrentVehicle = NULL;

    C_BaseCombatWeapon *wpn = player ? player->GetActiveWeapon() : NULL;

    hudlcd->SetGlobalStat( "(weapon_print_name)", wpn ? wpn->GetPrintName() : " " );
    hudlcd->SetGlobalStat( "(weapon_name)", wpn ? wpn->GetName() : " " );

    if ( !wpn || !player || !wpn->UsesPrimaryAmmo() )
    {
        hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
        hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );

        SetPaintEnabled(false);
        SetPaintBackgroundEnabled(false);
        return;
    }

    SetPaintEnabled(true);
    SetPaintBackgroundEnabled(true);

    // get the ammo in our clip
    int ammo1 = wpn->Clip1();
    int ammo2;
    if (ammo1 < 0)
    {
        // we don't use clip ammo, just use the total ammo count
        ammo1 = player->GetAmmoCount(wpn->GetPrimaryAmmoType());
        ammo2 = 0;
    }
    else
    {
        // we use clip ammo, so the second ammo is the total ammo
        ammo2 = player->GetAmmoCount(wpn->GetPrimaryAmmoType());
    }

    hudlcd->SetGlobalStat( "(ammo_primary)", VarArgs( "%d", ammo1 ) );
    hudlcd->SetGlobalStat( "(ammo_secondary)", VarArgs( "%d", ammo2 ) );

    if (wpn == m_hCurrentActiveWeapon)
    {
        // same weapon, just update counts
        SetAmmo(ammo1, true);
        SetAmmo2(ammo2, true);
    }
    else
    {
        // diferent weapon, change without triggering
        SetAmmo(ammo1, false);
        SetAmmo2(ammo2, false);

        // update whether or not we show the total ammo display
        if (wpn->UsesClipsForAmmo1())
        {
            SetShouldDisplaySecondaryValue(true);
            GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("WeaponUsesClips");
        }
        else
        {
            GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseClips");
            SetShouldDisplaySecondaryValue(false);
        }

        GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("WeaponChanged");
        m_hCurrentActiveWeapon = wpn;
    }
}