//=============================================================================
void ControllerOptionsButtons::OnHybridButtonNavigatedTo( VPANEL defaultButton )
{
	Panel *panel = ipanel()->GetPanel( defaultButton, GetModuleName() );

	if ( panel )
	{
		OnCommand( panel->GetName() );
	}
}
//-----------------------------------------------------------------------------
// Purpose: serializes settings to a resource data container
//-----------------------------------------------------------------------------
void BuildGroup::GetSettings( KeyValues *resourceData )
{
	// loop through all the objects getting their settings
	for( int i = 0; i < _panelDar.Count(); i++ )
	{
		Panel *panel = _panelDar[i].Get();
		if (!panel)
			continue;

		bool isRuler = false;
		// do not get setting for ruler labels.
		if (_showRulers) // rulers are visible
		{
			for (int i = 0; i < 4; i++)
			{
				if (panel == _rulerNumber[i])
				{
					isRuler = true;
					break;
				}
			}
			if (isRuler)
			{
				isRuler = false;
				continue;
			}
		}

		// Don't save the setting of the buildmodedialog
		if (!stricmp(panel->GetName(), "BuildDialog"))
			continue;

		// get the keys section from the data file
		if (panel->GetName() && *panel->GetName())
		{
			KeyValues *datKey = resourceData->FindKey(panel->GetName(), true);

			// get the settings
			panel->GetSettings(datKey);
		}
	}
}
bool CASW_VGUI_Info_Message::CloseInfoMessage()
{
	if (g_asw_iGUIWindowsOpen <= 0)
		return false;

	bool bFound = false;
	for (int k=0;k<GetClientMode()->GetViewport()->GetChildCount();k++)
	{
		Panel *pChild = GetClientMode()->GetViewport()->GetChild(k);
		if (pChild && 
			( !strcmp(pChild->GetName(), "InfoMessageWindow") || !strcmp(pChild->GetName(), "InfoMessageLog") )
			)
		{
			pChild->MarkForDeletion();
			pChild->SetVisible(false);
			bFound = true;
		}
	}
	return bFound;
}
//-----------------------------------------------------------------------------
// Purpose: serializes settings from a resource data container
//-----------------------------------------------------------------------------
void BuildGroup::ApplySettings( KeyValues *resourceData )
{
	// loop through all the keys, applying them wherever
	for (KeyValues *controlKeys = resourceData->GetFirstSubKey(); controlKeys != NULL; controlKeys = controlKeys->GetNextKey())
	{
		bool bFound = false;

		// Skip keys that are atomic..
		if (controlKeys->GetDataType() != KeyValues::TYPE_NONE)
			continue;

		char const *keyName = controlKeys->GetName();

		// check to see if any buildgroup panels have this name
		for ( int i = 0; i < _panelDar.Count(); i++ )
		{
			Panel *panel = _panelDar[i].Get();

			if (!panel) // this can happen if we had two of the same handle in the list
			{
				_panelDar.Remove(i);
				--i;
				continue;
			}


			Assert (panel);

			// make the control name match CASE INSENSITIVE!
			char const *panelName = panel->GetName();

			if (!Q_stricmp(panelName, keyName))
			{
				// apply the settings
				panel->ApplySettings(controlKeys);
				bFound = true;
				break;
			}
		}

		if ( !bFound )
		{
			// the key was not found in the registered list, check to see if we should create it
			if ( keyName /*controlKeys->GetInt("AlwaysCreate", false)*/ )
			{
				// create the control even though it wasn't registered
				NewControl( controlKeys );
			}
		}
	}
}
CReplayBrowserThumbnail::CReplayBrowserThumbnail( Panel *pParent, const char *pName, QueryableReplayItemHandle_t hReplayItem,
												  IReplayItemManager *pReplayItemManager )
:	CReplayBasePanel( pParent, pName ),
	m_hReplayItem( hReplayItem ),
	m_pReplayItemManager( pReplayItemManager ),
	m_bMouseOver( false ),
	m_pMoviePlayer( NULL ),
	m_flLastMovieScrubTime( 0.0f ),
	m_flHoverStartTime( 0.0f ),
	m_flLastProgressChangeTime( 0.0f )
{
	SetScheme( "ClientScheme" );

	ivgui()->AddTickSignal( GetVPanel(), 10 );

	// Add the list panel as an action signal target
	// NOTE: Vile hack.
	Panel *pTarget = GetParent();
	while ( pTarget )
	{
		if ( !V_strcmp( "BasePage", pTarget->GetName() ) )
			break;
		pTarget = pTarget->GetParent();
	}
	Assert( pTarget );
	AddActionSignalTarget( pTarget );

	m_pScreenshotThumb = new CCrossfadableImagePanel( this, "ScreenshotThumbnail" );
	m_pTitle = new Label( this, "TitleLabel", "" );
	m_pDownloadLabel = new Label( this, "DownloadLabel", "" );
	m_pRecordingInProgressLabel = new Label( this, "RecordingInProgressLabel", "" );
	m_pDownloadProgress = new ProgressBar( this, "DownloadProgress" );
	m_pDownloadButton = new CExButton( this, "DownloadButton", "#Replay_Download" );
	m_pDeleteButton = new CExButton( this, "DeleteButton", "#X_Delete" );
	m_pErrorLabel = new Label( this, "ErrorLabel", "" );
	m_pDownloadOverlay = new Panel( this, "DownloadOverlay" );
	m_pBorderPanel = new EditablePanel( this, "BorderPanel" );

	m_pScreenshotThumb->InstallMouseHandler( this );

	m_pDownloadButton->AddActionSignalTarget( this );
	m_pDownloadButton->SetCommand( new KeyValues( "download" ) );

	m_pDeleteButton->AddActionSignalTarget( this );
	m_pDeleteButton->SetCommand( new KeyValues( "delete_replayitem" ) );

	SetProportional( true );

	SetReplayItem( hReplayItem );
}
//-----------------------------------------------------------------------------
// Purpose: check to see if any buildgroup panels have this fieldname
// Input  : fieldName, name to check
// Output : ptr to a panel that has the name if it is taken
//-----------------------------------------------------------------------------
Panel *BuildGroup::FieldNameTaken(const char *fieldName)
{	 	
	for ( int i = 0; i < _panelDar.Count(); i++ )
	{
		Panel *panel = _panelDar[i].Get();
		if ( !panel )
			continue;

		if (!stricmp(panel->GetName(), fieldName) )
		{
			return panel;
		}
	}
	return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: gets all the children's user config settings
//-----------------------------------------------------------------------------
void EditablePanel::GetUserConfigSettings(KeyValues *userConfig)
{
	for (int i = 0; i < GetChildCount(); i++)
	{
		Panel *child = GetChild(i);
		if (child->HasUserConfigSettings())
		{
			const char *name = child->GetName();
			if (name && *name)
			{
				child->GetUserConfigSettings(userConfig->FindKey(name, true));
			}
		}
	}
}
void CDialog_PPEPrecache::CheckButtonChecked( KeyValues *pKV )
{
	bool bChecked = pKV->GetInt( "state" ) != 0;
	Panel *p = (Panel*)pKV->GetPtr( "panel" );
	Assert( p );

	int index = GetPPCache()->FindPostProcessingEffect( p->GetName() );
	Assert( index >= 0 && index < GetPPCache()->GetNumPostProcessingEffects() );

	GetPPCache()->GetPostProcessingEffect( index )->bStartEnabled = bChecked;
	GetPPCache()->GetPostProcessingEffect( index )->bIsEnabled = bChecked;

	if ( pEditorRoot->GetSafeFlowgraph()->GetFlowgraphType() == CNodeView::FLOWGRAPH_POSTPROC )
		pEditorRoot->GetSafeFlowgraph()->UpdatePPECache();
}
//-----------------------------------------------------------------------------
// Purpose: starts a variable animation
//-----------------------------------------------------------------------------
void AnimationController::StartCmd_Animate(UtlSymId_t seqName, AnimCmdAnimate_t &cmd, Panel *pWithinParent)
{
	Assert( pWithinParent );

	// make sure the child exists
	Panel *panel = pWithinParent->FindChildByName(g_ScriptSymbols.String(cmd.panel),true);
	if ( !panel )
	{
		// Check the parent
		Panel *parent = GetParent();
		if ( !Q_stricmp( parent->GetName(), g_ScriptSymbols.String(cmd.panel) ) )
		{
			panel = parent;
		}
	}
	if (!panel)
		return;

	StartCmd_Animate(panel, seqName, cmd);
}
//-----------------------------------------------------------------------------
// Purpose: removes an existing set of commands from the queue
//-----------------------------------------------------------------------------
void AnimationController::RemoveQueuedAnimationCommands(UtlSymId_t seqName, Panel *pWithinParent)
{
	// Msg("Removing queued anims for sequence %s\n", g_ScriptSymbols.String(seqName));

	// remove messages posted by this sequence
	// if pWithinParent is specified, remove only messages under that parent
	{for (int i = 0; i < m_PostedMessages.Count(); i++)
	{
		if ( ( m_PostedMessages[i].seqName == seqName ) &&
			 ( !pWithinParent || ( m_PostedMessages[i].parent == pWithinParent ) ) )
		{
			m_PostedMessages.Remove(i);
			--i;
		}
	}}

	// remove all animations
	// if pWithinParent is specified, remove only animations under that parent
	for (int i = 0; i < m_ActiveAnimations.Count(); i++)
	{
		if ( m_ActiveAnimations[i].seqName != seqName )
			continue;

		// panel this anim is on, m_ActiveAnimations[i].panel
		if ( pWithinParent )
		{
			Panel *animPanel = m_ActiveAnimations[i].panel;

			if ( !animPanel )
				continue;

			Panel *foundPanel = pWithinParent->FindChildByName(animPanel->GetName(),true);

			if ( foundPanel != animPanel )
				continue;
		}

		m_ActiveAnimations.Remove(i);
		--i;
	}
}
Exemple #11
0
//-----------------------------------------------------------------------------
void CBaseModFrame::OnNavigateTo( const char* panelName )
{
	for(int i = 0; i < GetChildCount(); ++i)
	{
		Panel* child = GetChild(i);
		if(child != NULL && (!Q_strcmp(panelName, child->GetName())))
		{
			const char* helpText = child->GetTooltip()->GetText();
			if(helpText && *helpText)
			{
				SetHelpText(helpText);
			}
			else
			{
				SetHelpText("");
			}
						
			m_ActiveControl = child;
			break;
		}
	}
}
void ResizeWindowControls( EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY )
{
	if (!pWindow || !pWindow->GetBuildGroup() || !pWindow->GetBuildGroup()->GetPanelList())
		return;

	CUtlVector<PHandle> *panelList = pWindow->GetBuildGroup()->GetPanelList();
	CUtlVector<Panel *> resizedPanels;
	CUtlVector<Panel *> movedPanels;

	// Resize to account for 1.25 aspect ratio (1280x1024) screens
	{
		for ( int i = 0; i < panelList->Size(); ++i )
		{
			PHandle handle = (*panelList)[i];

			Panel *panel = handle.Get();

			bool found = false;
			for ( int j = 0; j < resizedPanels.Size(); ++j )
			{
				if (panel == resizedPanels[j])
					found = true;
			}

			if (!panel || found)
			{
				continue;
			}

			resizedPanels.AddToTail( panel ); // don't move a panel more than once

			if ( panel != pWindow )
			{
				RepositionControl( panel );
			}
		}
	}

	// and now re-center them.  Woohoo!
	for ( int i = 0; i < panelList->Size(); ++i )
	{
		PHandle handle = (*panelList)[i];

		Panel *panel = handle.Get();

		bool found = false;
		for ( int j = 0; j < movedPanels.Size(); ++j )
		{
			if (panel == movedPanels[j])
				found = true;
		}

		if (!panel || found)
		{
			continue;
		}

		movedPanels.AddToTail( panel ); // don't move a panel more than once

		if ( panel != pWindow )
		{
			int x, y;

			panel->GetPos( x, y );
			panel->SetPos( x + offsetX, y + offsetY );

#if DEBUG_WINDOW_REPOSITIONING
			DevMsg( "Repositioning '%s' from (%d,%d) to (%d,%d) -- a distance of (%d,%d)\n",
				panel->GetName(), x, y, x + offsetX, y + offsetY, offsetX, offsetY );
#endif
		}
	}
}