예제 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CGameUI::SetProgressLevelName( const char *levelName )
{
	MEM_ALLOC_CREDIT();
	if ( g_hLoadingBackgroundDialog )
	{
		KeyValues *pKV = new KeyValues( "ProgressLevelName" );
		pKV->SetString( "levelName", levelName );
		vgui::ivgui()->PostMessage( g_hLoadingBackgroundDialog, pKV, NULL );
	}

	if ( g_hLoadingDialog.Get() )
	{
		// TODO: g_hLoadingDialog->SetLevelName( levelName );
	}
}
예제 #2
0
//-----------------------------------------------------------------------------
// Purpose: sets loading info text
//-----------------------------------------------------------------------------
bool CGameUI::SetProgressBarStatusText(const char *statusText)
{
	if (!g_hLoadingDialog.Get())
		return false;

	if (!statusText)
		return false;

	if (!stricmp(statusText, m_szPreviousStatusText))
		return false;

	g_hLoadingDialog->SetStatusText(statusText);
	Q_strncpy(m_szPreviousStatusText, statusText, sizeof(m_szPreviousStatusText));
	return true;
}
예제 #3
0
void ShowInGameBriefing()
{
	using namespace vgui;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (!pPlayer)
		return;

	if (engine->IsLevelMainMenuBackground())		// don't show player list on main menu
	{		
		return;
	}
	vgui::Panel *pContainer = GetClientMode()->GetViewport()->FindChildByName("InGameBriefingContainer", true);
	if (pContainer)	
	{
		pContainer->SetVisible(false);
		pContainer->MarkForDeletion();
		pContainer = NULL;
		return;
	}

	if (g_hBriefingFrame.Get() || GetClientModeASW()->m_hCampaignFrame.Get() || GetClientModeASW()->m_hMissionCompleteFrame.Get())
	{
		return;
	}

	vgui::Frame* pFrame = new InGameMissionPanelFrame( GetClientMode()->GetViewport(), "InGameBriefingContainer" );
	HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew");
	pFrame->SetScheme(scheme);		

	// the panel to show the info
	CNB_Mission_Panel *missionpanel = new CNB_Mission_Panel( pFrame, "MissionPanel" );
	missionpanel->SetVisible( true );	

	if (!pFrame)
	{
		Msg("Error: ingame briefing frame was closed immediately on opening\n");
	}
	else
	{
		pFrame->RequestFocus();
		pFrame->SetVisible(true);
		pFrame->SetEnabled(true);
		pFrame->SetKeyBoardInputEnabled(false);
		pFrame->SetZPos(200);		
		GetClientModeASW()->m_hInGameBriefingFrame = pFrame;
	}
}
예제 #4
0
//-----------------------------------------------------------------------------
// Purpose: Display the tooltip
//-----------------------------------------------------------------------------
void Tooltip::ShowTooltip(Panel *currentPanel)
{
	if ( s_TooltipWindow.Get() )
	{
		int nLen = s_TooltipWindow->GetTextLength();
		char *pBuf = (char*)_alloca( nLen+1 );
		s_TooltipWindow->GetText( pBuf, nLen+1 );
		Panel *pCurrentParent = s_TooltipWindow->GetParent();

		_isDirty = _isDirty || ( pCurrentParent != currentPanel );
		s_TooltipWindow->SetText( m_Text.Base() );
		s_TooltipWindow->SetParent(currentPanel);
	}
	_makeVisible = true;

	PerformLayout();
}
예제 #5
0
//-----------------------------------------------------------------------------
// Purpose: Size the text window so all the text fits inside it.
//-----------------------------------------------------------------------------
void Tooltip::SizeTextWindow()
{
	if ( !s_TooltipWindow.Get() )
		return;

	if (_displayOnOneLine)
	{
		// We want the tool tip to be one line
		s_TooltipWindow->SetMultiline(false);
		s_TooltipWindow->SetToFullWidth();
	}
	else
	{
		// We want the tool tip to be one line
		s_TooltipWindow->SetMultiline(false);
		s_TooltipWindow->SetToFullWidth();
		int wide, tall;
		s_TooltipWindow->GetSize( wide, tall );
		double newWide = sqrt( (2.0/1) * wide * tall );
		double newTall = (1/2) * newWide;
		s_TooltipWindow->SetMultiline(true);
		s_TooltipWindow->SetSize((int)newWide, (int)newTall );
		s_TooltipWindow->SetToFullHeight();
		
		s_TooltipWindow->GetSize( wide, tall );
		
		if (( wide < 100 ) && ( s_TooltipWindow->GetNumLines() == 2) ) 
		{
			s_TooltipWindow->SetMultiline(false);
			s_TooltipWindow->SetToFullWidth();	
		}
		else
		{
			
			while ( (float)wide/(float)tall < 2 )
			{
				s_TooltipWindow->SetSize( wide + 1, tall );
				s_TooltipWindow->SetToFullHeight();
				s_TooltipWindow->GetSize( wide, tall );
			}
		}
		s_TooltipWindow->GetSize( wide, tall );
	//	ivgui()->DPrintf("End Ratio: %f\n", (float)wide/(float)tall);		
	}
}
예제 #6
0
//-----------------------------------------------------------------------------
// Purpose: stops progress bar, displays error if necessary
//-----------------------------------------------------------------------------
void CGameUI::StopProgressBar(bool bError, const char *failureReason, const char *extendedReason)
{
	if (!g_hLoadingDialog.Get())
		return;

	if ( !IsX360() && bError )
	{
		// turn the dialog to error display mode
		g_hLoadingDialog->DisplayGenericError(failureReason, extendedReason);
	}
	else
	{
		// close loading dialog
		g_hLoadingDialog->Close();
		g_hLoadingDialog = NULL;
	}
	// should update the background to be in a transition here
}
//-----------------------------------------------------------------------------
// Sets a panel to be the main panel
//-----------------------------------------------------------------------------
void CVsVGuiWindow::SetMainPanel( vgui::EditablePanel * pPanel )
{
	Assert( m_hMainPanel.Get() == NULL );
	Assert( m_hVGuiContext == vgui::DEFAULT_VGUI_CONTEXT );

	m_hMainPanel = pPanel;

	m_hMainPanel->SetParent( vgui::surface()->GetEmbeddedPanel() );
	m_hMainPanel->SetVisible( true );
	m_hMainPanel->SetCursor( vgui::dc_arrow );

	m_hVGuiContext = vgui::ivgui()->CreateContext();
	vgui::ivgui()->AssociatePanelWithContext( m_hVGuiContext, m_hMainPanel->GetVPanel() );

	pPanel->InvalidateLayout();

	EnableWindow( m_hWnd, true );
	SetFocus( m_hWnd );
}
void CBaseActionPlaySoundStartDialog::OnCommand( char const *command )
{
	if ( !Q_strcasecmp( command, "choosesound" ) )
	{
		if ( !m_hFileOpenDialog.Get() )
		{
			m_hFileOpenDialog = new vgui::FileOpenDialog( this, "Choose .wav file", true );
		}
		if ( m_hFileOpenDialog )
		{
			char startPath[ MAX_PATH ];
			Q_strncpy( startPath, com_gamedir, sizeof( startPath ) );
			COM_FixSlashes( startPath );
			m_hFileOpenDialog->SetStartDirectory( va( "%s/sound", startPath ) );
			m_hFileOpenDialog->DoModal( false );
		}
		return;
	}
	
	BaseClass::OnCommand( command );
}
예제 #9
0
CASW_VGUI_Info_Message::~CASW_VGUI_Info_Message()
{
	if (GetControllerFocus())
	{
		GetControllerFocus()->RemoveFromFocusList(m_pOkayButton);
		if (m_pLogButton)
			GetControllerFocus()->RemoveFromFocusList(m_pLogButton);
	}
	g_asw_iGUIWindowsOpen--;
	if (g_hCurrentInfoPanel.Get() == this)
		g_hCurrentInfoPanel = NULL;

	NotifyServerOfClose();

	if ( !asw_info_sound_continue.GetBool() )
	{
		StopInfoMessageSound();
	}

	ASWInput()->SetCameraFixed( false );
}
예제 #10
0
//-----------------------------------------------------------------------------
// Purpose: Display the tooltip
//-----------------------------------------------------------------------------
void TextTooltip::PerformLayout()
{
	if ( !ShouldLayout() )
		return;
	// we're ready, just make us visible
	if ( !s_TooltipWindow.Get() )
		return;

	_isDirty = false;

	s_TooltipWindow->SetVisible(true);
	s_TooltipWindow->MakePopup( false, true );
	s_TooltipWindow->SetKeyBoardInputEnabled( false );
	s_TooltipWindow->SetMouseInputEnabled( false );

	// relayout the textwindow immediately so that we know it's size
	//m_pTextEntry->InvalidateLayout(true);

	SizeTextWindow();
	PositionWindow( s_TooltipWindow );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CGameUI::StartProgressBar(const char *progressType, int progressSteps)
{
//	TRACE_FUNCTION("CGameUI::StartProgressBar");

	if (!g_hLoadingDialog.Get())
	{
		g_hLoadingDialog = new CLoadingDialog(staticPanel);
	}

	// close the start menu
	staticPanel->SetBackgroundRenderState(CBasePanel::BACKGROUND_LOADING);
	m_pszCurrentProgressType = progressType;
	if (m_flProgressStartTime < 0.001f)
	{
		m_flProgressStartTime = (float)vgui::system()->GetCurrentTime();
	}

	// open a loading dialog
	g_hLoadingDialog->SetProgressRange(0 , progressSteps); 
	g_hLoadingDialog->SetProgressPoint(0);
	g_hLoadingDialog->DisplayProgressBar(progressType, "invalid");
}
예제 #12
0
//-----------------------------------------------------------------------------
// Purpose: Display the tooltip
//-----------------------------------------------------------------------------
void TextTooltip::ShowTooltip(Panel *currentPanel)
{
	if ( s_TooltipWindow.Get() )
	{
		int nLen = s_TooltipWindow->GetTextLength();

		if ( nLen <= 0 )
		{
			// Empty tool tip, no need to show it
			_makeVisible = false;
			return;
		}

		char *pBuf = (char*)_alloca( nLen+1 );
		s_TooltipWindow->GetText( pBuf, nLen+1 );
		Panel *pCurrentParent = s_TooltipWindow->GetParent();

		_isDirty = _isDirty || ( pCurrentParent != currentPanel );
		s_TooltipWindow->SetText( m_Text.Base() );
		s_TooltipWindow->SetParent(currentPanel);
	}
	BaseTooltip::ShowTooltip( currentPanel );
}
예제 #13
0
//-----------------------------------------------------------------------------
// Purpose: Set the tooltip text
//-----------------------------------------------------------------------------
void Tooltip::SetText(const char *text)
{
	if (!text)
	{
		text = "";
	}

	if (m_Text.Size() > 0)
	{
		m_Text.RemoveAll();
	}

	for (unsigned int i = 0; i < strlen(text); i++)
	{
		m_Text.AddToTail(text[i]);
	}
	m_Text.AddToTail('\0');
	
	if (s_TooltipWindow.Get())
	{
		s_TooltipWindow->SetText(m_Text.Base());
	}
}
예제 #14
0
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
Tooltip::Tooltip(Panel *parent, const char *text) 
{
	if (!s_TooltipWindow.Get())
	{
		s_TooltipWindow = new TextEntry(NULL, "tooltip");
	}
	s_iTooltipWindowCount++;

	// this line prevents the main window from losing focus
	// when a tooltip pops up
	s_TooltipWindow->MakePopup(false, true);
	
	SetText(text);
	s_TooltipWindow->SetText(m_Text.Base());
	s_TooltipWindow->SetEditable(false);
	s_TooltipWindow->SetMultiline(true);
	s_TooltipWindow->SetVisible(false);

	_displayOnOneLine = false;
	_makeVisible = false;

	_tooltipDelay = 500; // default delay for opening tooltips
	_delay = 0;
}
예제 #15
0
void ShowPlayerList()
{
	if ( gpGlobals->maxClients <= 1 )
		return;

	using namespace vgui;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (!pPlayer)
		return;

	if (engine->IsLevelMainMenuBackground())		// don't show player list on main menu
	{		
		return;
	}
	vgui::Panel *pContainer = GetClientMode()->GetViewport()->FindChildByName("g_PlayerListFrame", true);
	if (pContainer)	
	{
		pContainer->SetVisible(false);
		pContainer->MarkForDeletion();
		pContainer = NULL;
		return;
	}

	vgui::Frame* pFrame = NULL;

	if (g_hBriefingFrame.Get())
		pContainer = new PlayerListContainer( g_hBriefingFrame.Get(), "g_PlayerListFrame" );
	else
	{
		if (GetClientModeASW()->m_hCampaignFrame.Get())
		{
			pContainer = new PlayerListContainer( GetClientModeASW()->m_hCampaignFrame.Get(), "g_PlayerListFrame" );
		}
		else
		{
			if (GetClientModeASW()->m_hMissionCompleteFrame.Get())
			{
				pContainer = new PlayerListContainer( GetClientModeASW()->m_hMissionCompleteFrame.Get(), "g_PlayerListFrame" );
			}
			else
			{
				pFrame = new PlayerListContainerFrame( GetClientMode()->GetViewport(), "g_PlayerListFrame" );
				pContainer = pFrame;
			}
		}
	}
	HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew");
	pContainer->SetScheme(scheme);		

	// the panel to show the info
	PlayerListPanel *playerlistpanel = new PlayerListPanel( pContainer, "PlayerListPanel" );
	playerlistpanel->SetVisible( true );

	if (!pContainer)
	{
		Msg("Error: Player list pContainer frame was closed immediately on opening\n");
	}
	else
	{
		pContainer->RequestFocus();
		pContainer->SetVisible(true);
		pContainer->SetEnabled(true);
		pContainer->SetKeyBoardInputEnabled(false);
		pContainer->SetZPos(200);		
	}
}
예제 #16
0
//-----------------------------------------------------------------------------
// Purpose: Display the tooltip
//-----------------------------------------------------------------------------
void Tooltip::PerformLayout()
{
	if (!_makeVisible)
		return;
	if (_delay > system()->GetTimeMillis())
		return;	

	// we're ready, just make us visible
	if ( !s_TooltipWindow.Get() )
		return;

	// We only need to layout when we first become visible
	if ( !_isDirty )
		return;

	_isDirty = false;

	s_TooltipWindow->SetVisible(true);
	s_TooltipWindow->MakePopup( false, true );
	s_TooltipWindow->SetKeyBoardInputEnabled( false );
	s_TooltipWindow->SetMouseInputEnabled( false );

	IScheme *pScheme = scheme()->GetIScheme( s_TooltipWindow->GetScheme() );

	s_TooltipWindow->SetBgColor(s_TooltipWindow->GetSchemeColor("Tooltip.BgColor", s_TooltipWindow->GetBgColor(), pScheme));
	s_TooltipWindow->SetFgColor(s_TooltipWindow->GetSchemeColor("Tooltip.TextColor", s_TooltipWindow->GetFgColor(), pScheme));
	s_TooltipWindow->SetBorder(pScheme->GetBorder("ToolTipBorder"));

	// get cursor position
	int cursorX, cursorY;
	input()->GetCursorPos(cursorX, cursorY);
	
	// relayout the textwindow immediately so that we know it's size
	//m_pTextEntry->InvalidateLayout(true);
	SizeTextWindow();
	int menuWide, menuTall;
	s_TooltipWindow->GetSize(menuWide, menuTall);
	
	// work out where the cursor is and therefore the best place to put the menu
	int wide, tall;
	surface()->GetScreenSize(wide, tall);
	
	if (wide - menuWide > cursorX)
	{
		cursorY += 20;
		// menu hanging right
		if (tall - menuTall > cursorY)
		{
			// menu hanging down
			s_TooltipWindow->SetPos(cursorX, cursorY);
		}
		else
		{
			// menu hanging up
			s_TooltipWindow->SetPos(cursorX, cursorY - menuTall - 20);
		}
	}
	else
	{
		// menu hanging left
		if (tall - menuTall > cursorY)
		{
			// menu hanging down
			s_TooltipWindow->SetPos(cursorX - menuWide, cursorY);
		}
		else
		{
			// menu hanging up
			s_TooltipWindow->SetPos(cursorX - menuWide, cursorY - menuTall - 20 );
		}
	}	
}
예제 #17
0
vgui::EditablePanel *CVsVGuiWindow::GetMainPanel()
{
	return m_hMainPanel.Get();
}
예제 #18
0
CASW_VGUI_Info_Message::CASW_VGUI_Info_Message( vgui::Panel *pParent, const char *pElementName, C_ASW_Info_Message* pMessage ) 
:	vgui::Panel( pParent, pElementName ),
	CASW_VGUI_Ingame_Panel()
{	
	//input->MouseEvent(0, false);	// unclick all our mouse buttons when this panel pops up (so firing doesn't get stuck on)

	if (g_hCurrentInfoPanel.Get())
	{
		g_hCurrentInfoPanel->MarkForDeletion();
		g_hCurrentInfoPanel->SetVisible(false);
	}
	g_hCurrentInfoPanel = this;
	m_hMessage = pMessage;
	for (int i=0;i<4;i++)
	{
		m_pLine[i] = new vgui::WrappedLabel(this, "InfoMessageLabel", "");
		m_pLine[i]->SetContentAlignment(vgui::Label::a_northwest);
		m_pLine[i]->SetMouseInputEnabled(false);
	}	
	m_pOkayButton = new ImageButton(this, "OkayButton", "#asw_close");
	m_pOkayButton->AddActionSignalTarget(this);
	KeyValues *msg = new KeyValues("Command");	
	msg->SetString("command", "OkayButton");
	m_pOkayButton->SetCommand(msg);

	m_pMessageImage = new vgui::ImagePanel(this, "MessageImage");
	m_pMessageImage->SetVisible(false);
	m_pMessageImage->SetShouldScaleImage(true);
	m_szImageName[0] = '\0';
	
	if (ShouldAddLogButton())
	{
		m_pLogButton = new ImageButton(this, "LogButton", "#asw_message_log");
		m_pLogButton->AddActionSignalTarget(this);
		KeyValues *msg = new KeyValues("Command");	
		msg->SetString("command", "MessageLog");
		m_pLogButton->SetCommand(msg);
	}
	else
	{
		Msg("  so not adding it\n");
		m_pLogButton = NULL;
	}

	// find use key bind	
	char lkeybuffer[12];
	Q_snprintf(lkeybuffer, sizeof(lkeybuffer), "%s", ASW_FindKeyBoundTo("+use"));
	Q_strupr(lkeybuffer);

	// copy the found key into wchar_t format (localize it if it's a token rather than a normal keyname)
	wchar_t keybuffer[24];
	if (lkeybuffer[0] == '#')
	{
		const wchar_t *pLocal = g_pVGuiLocalize->Find(lkeybuffer);
		if (pLocal)
			wcsncpy(keybuffer, pLocal, 24);
		else
			g_pVGuiLocalize->ConvertANSIToUnicode(lkeybuffer, keybuffer, sizeof(keybuffer));
	}
	else
		g_pVGuiLocalize->ConvertANSIToUnicode(lkeybuffer, keybuffer, sizeof(keybuffer));

	// look up close text localised
	const wchar_t *pLocal = g_pVGuiLocalize->Find("#asw_close");
	
	if (pLocal)
	{
		// join use key and close text together
		wchar_t buffer[ 256 ];
		g_pVGuiLocalize->ConstructString( buffer, sizeof(buffer), g_pVGuiLocalize->Find("#asw_use_icon_format"), 2, keybuffer, pLocal );
		// set label
		m_pOkayButton->SetText(buffer);
	}

	if (GetControllerFocus())
	{
		GetControllerFocus()->AddToFocusList(m_pOkayButton);
		GetControllerFocus()->SetFocusPanel(m_pOkayButton);
		if (m_pLogButton)
		{
			GetControllerFocus()->AddToFocusList(m_pLogButton);
		}
	}

	m_bClosingMessage = false;	
	
	CLocalPlayerFilter filter;

	// check for a special sound in the info message
	const char *pszSound = pMessage ? pMessage->GetSound() : NULL;	
	if (pszSound && Q_strlen(pszSound) > 0)
	{
		StopInfoMessageSound();

		EmitSound_t ep;
		ep.m_pSoundName = pszSound;
		ep.m_flVolume = 1.0f;
		ep.m_nPitch = PITCH_NORM;
		ep.m_SoundLevel = SNDLVL_NONE;
		ep.m_nChannel = CHAN_STATIC;

		C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, ep ); 
		g_LastInfoSoundGUID = enginesound->GetGuidForLastSoundEmitted();
	}

	UpdateMessage();

	SetAlpha(0);
	vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 255, 0.0f, 0.3f, vgui::AnimationController::INTERPOLATOR_LINEAR);	

	SetKeyBoardInputEnabled(true);
	SetMouseInputEnabled(true);
	RequestFocus();

	ASWInput()->SetCameraFixed( true );

	g_asw_iGUIWindowsOpen++;		
}