Пример #1
0
	BufferCallPaintTraverse( VPANEL panel ) : panel(panel) 
	{
		Panel *pPanel = ipanel()->GetPanel(panel, GetControlsModuleName());
		if( pPanel )
		{
			pPanel->GetPos(posx, posy);
			pPanel->GetSize(sizex, sizey);
			//parent = pPanel->GetVParent();
			if( !pPanel->IsRecordingSBuffer() )
				pPanel->ParentFlushSBuffer();
		}
	}
Пример #2
0
	void Draw() 
	{ 
		int rposx, rposy, rsizex, rsizey;
		VPANEL rparent;

		Panel *pPanel = ipanel()->GetPanel(panel, GetControlsModuleName());

		if( pPanel )
		{
			pPanel->GetPos(rposx, rposy);
			pPanel->GetSize(rsizex, rsizey);
			//rparent = pPanel->GetVParent();

			pPanel->SetPos(posx, posy);
			pPanel->SetSize(sizex, sizey);
			//pPanel->SetParent(parent);
		}
		else
		{
			rposx = rposy = rsizex = rsizey = 0;
			rparent = 0;
		}

		// SolveTraverse will update the panel in relation to the pos and size
		g_pVGuiSurface->Invalidate(panel);
		g_pVGuiSurface->SolveTraverse(panel);

		g_pVGuiSurface->PaintTraverse(panel); 

		if( pPanel )
		{
			pPanel->SetPos(rposx, rposy);
			pPanel->SetSize(rsizex, rsizey);
			//pPanel->SetParent(rparent);
		}
	}
Пример #3
0
void CFolderMenu::Update()
{
	ReloadControlSettings(false, false);

	MoveToCenterOfScreen();

	Button *entry = dynamic_cast<Button *>(FindChildByName("ApproveButton"));
	if (entry)
		entry->SetVisible(true);

	C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer();

	if (!pPlayer)
		return;

	if (pPlayer->HasCharacterBeenChosen())
		Q_strcpy(m_szCharacter, pPlayer->GetCharacter());
	else
		m_szCharacter[0] = '\0';

	if (ShouldShowCharacterOnly() && !ShouldShowTeams())
	{
		m_pProfileInfo->SetVisible(true);
		if (m_szPreviewCharacter[0])
			m_pProfileInfo->SetText((std::string("#DA_CharacterInfo_") + m_szPreviewCharacter).c_str());
		else if (m_szCharacter[0])
			m_pProfileInfo->SetText((std::string("#DA_CharacterInfo_") + m_szCharacter).c_str());
		else
			m_pProfileInfo->SetText("#DA_CharacterInfo_None");
	}
	else
		m_pProfileInfo->SetVisible(false);

	CFolderLabel *pCharacterName = dynamic_cast<CFolderLabel *>(FindChildByName("AgentName"));
	if (pCharacterName && !ShouldShowTeams())
	{
		std::string sCharacter;
		if (m_szPreviewCharacter[0])
			sCharacter = std::string("#DA_Character_") + m_szPreviewCharacter;
		else if (m_szCharacter[0])
			sCharacter = std::string("#DA_Character_") + m_szCharacter;

		std::wstring sLocalized;
		wchar_t* pszLocalized = g_pVGuiLocalize->Find( sCharacter.c_str() );

		if (pszLocalized)
			sLocalized += pszLocalized;

		if (pPlayer->m_Shared.m_iStyleSkill)
		{
			std::string sSkill = std::string("#DA_Skill_") + SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkill.Get()) + "_Adjective";

			pszLocalized = g_pVGuiLocalize->Find( sSkill.c_str() );

			if (pszLocalized)
				sLocalized += pszLocalized;
		}

		pCharacterName->SetText(sLocalized.c_str());
	}
	else
		pCharacterName->SetText("");

	CFolderLabel* pLabels[2];
	pLabels[0] = dynamic_cast<CFolderLabel *>(FindChildByName("RequestedArmament1"));
	pLabels[1] = dynamic_cast<CFolderLabel *>(FindChildByName("RequestedArmament2"));

	int iArmamentsOn1 = 0;

	std::wostringstream sLabel1;
	std::wostringstream sLabel2;

	SDKWeaponID eFirst = WEAPON_NONE;
	for (int i = 0; i < MAX_LOADOUT; i++)
	{
		if (!pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i))
			continue;

		CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i);
		if (!pWeaponInfo)
			continue;

		if (!eFirst)
		{
			eFirst = (SDKWeaponID)i;

			if (pPlayer->GetLoadoutWeaponCount(eFirst) > 1)
			{
				CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo(eFirst);
				if (pWeaponInfo && pWeaponInfo->m_szAkimbo[0])
				{
					// If we have two of this weapon and this weapon has an akimbo, use the akimbo instead.
					eFirst = AliasToWeaponID(pWeaponInfo->m_szAkimbo);
				}
			}
		}
		else
		{
			if (pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) > 1)
			{
				CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i);
				if (pWeaponInfo && pWeaponInfo->m_szAkimbo[0])
				{
					SDKWeaponID eAkimbo = AliasToWeaponID(pWeaponInfo->m_szAkimbo);
					if (eAkimbo < eFirst)
					{
						// If we have this akimbo and it's preferred to the current weapon, use it instead.
						// (Preferred means lower weapon ID.)
						eFirst = eAkimbo;
					}
				}
			}
		}

		std::wostringstream sLabel;

		const wchar_t *pchFmt = g_pVGuiLocalize->Find( pWeaponInfo->szPrintName );
		if ( pchFmt && pchFmt[0] )
			sLabel << pchFmt;
		else
			sLabel << pWeaponInfo->szPrintName;

		if (pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) > 1)
			sLabel << " x" << pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) << "\n";
		else
			sLabel << "\n";

		if (iArmamentsOn1 >= 2)
			sLabel2 << sLabel.str();
		else
			sLabel1 << sLabel.str();

		iArmamentsOn1++;
	}

	if (pLabels[0])
		pLabels[0]->SetText(sLabel1.str().c_str());

	if (pLabels[1])
		pLabels[1]->SetText(sLabel2.str().c_str());

	const char szPlayerPreviewTemplate[] =
		"	\"model\"\n"
		"	{\n"
		"		\"spotlight\"	\"1\"\n"
		"		\"modelname\"	\"models/player/frank.mdl\"\n"
		"		\"origin_z\"	\"-57\"\n"
		"		\"origin_y\"	\"10\"\n"
		"		\"origin_x\"	\"110\"\n"
		"		\"angles_y\"	\"180\"\n"

		"		\"animation\"\n"
		"		{\n"
		"			\"sequence\"		\"m1911_idle\"\n"
		"			\"pose_parameters\"\n"
		"			{\n"
		"				\"body_yaw\" \"25.0\"\n"
		"				\"body_pitch\" \"-30.0\"\n"
		"			}\n"
		"		}\n"
			
		"		\"attached_model\"\n"
		"		{\n"
		"			\"modelname\" \"models/weapons/m1911.mdl\"\n"
		"		}\n"
		"	}";

	CModelPanel *pPlayerPreview = dynamic_cast<CModelPanel *>(FindChildByName("player_preview"));
	CSDKWeaponInfo* pWeaponInfo = NULL;
	if (eFirst)
		pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo(eFirst);

	if ((m_szCharacter[0] || m_szPreviewCharacter[0]) && pPlayerPreview && !ShouldShowTeams())
	{
		KeyValues* pValues = new KeyValues("preview");
		pValues->LoadFromBuffer("model", szPlayerPreviewTemplate);

		const char* pCharacter = m_szCharacter;
		if (m_szPreviewCharacter[0])
			pCharacter = m_szPreviewCharacter;

		pValues->SetString("modelname", VarArgs("models/player/%s.mdl", pCharacter));

		if (ShouldShowCharacterOnly() || ShouldShowCharacterAndWeapons())
		{
			pValues->SetFloat("origin_x", hud_characterpreview_x.GetFloat());
			pValues->SetFloat("origin_y", hud_characterpreview_y.GetFloat());
			pValues->SetFloat("origin_z", hud_characterpreview_z.GetFloat());
		}
		else
		{
			pValues->SetFloat("origin_x", hud_playerpreview_x.GetFloat());
			pValues->SetFloat("origin_y", hud_playerpreview_y.GetFloat());
			pValues->SetFloat("origin_z", hud_playerpreview_z.GetFloat());
		}

		if (m_pPage && FStrEq(m_pPage->GetName(), "class") && m_szPreviewSequence[0] && m_szPreviewWeaponModel[0] && !pPlayer->GetLoadoutWeight())
		{
			KeyValues* pAnimation = pValues->FindKey("animation");
			if (pAnimation)
				pAnimation->SetString("sequence", m_szPreviewSequence);

			KeyValues* pWeapon = pValues->FindKey("attached_model");
			if (pWeapon)
				pWeapon->SetString("modelname", m_szPreviewWeaponModel);
		}
		else if (pWeaponInfo)
		{
			KeyValues* pAnimation = pValues->FindKey("animation");
			if (pAnimation)
				pAnimation->SetString("sequence", VarArgs("%s_idle", WeaponIDToAlias(eFirst)));

			KeyValues* pWeapon = pValues->FindKey("attached_model");
			if (pWeapon)
				pWeapon->SetString("modelname", pWeaponInfo->szWorldModel);
		}
		else
		{
			KeyValues* pAnimation = pValues->FindKey("animation");
			if (pAnimation)
				pAnimation->SetString("sequence", "idle");

			KeyValues* pWeapon = pValues->FindKey("attached_model");
			if (pWeapon)
				pWeapon->SetString("modelname", "");
		}

		if (SDKGameRules()->IsTeamplay())
		{
			if (pPlayer->GetTeamNumber() == SDK_TEAM_BLUE)
				pValues->SetInt("skin", 1);
			else if (pPlayer->GetTeamNumber() == SDK_TEAM_RED)
				pValues->SetInt("skin", 2);
			else
				pValues->SetInt("skin", 0);
		}
		else
			pValues->SetInt("skin", 0);

		pPlayerPreview->ParseModelInfo(pValues);

		pValues->deleteThis();
	}
	else if (pPlayerPreview)
		pPlayerPreview->SwapModel("");

	for ( int i = 0; i < m_apWeaponIcons.Count(); i++)
	{
		if (m_apWeaponIcons[i].m_pWeaponName)
			m_apWeaponIcons[i].m_pWeaponName->DeletePanel();
	
		if (m_apWeaponIcons[i].m_pSlots)
			m_apWeaponIcons[i].m_pSlots->DeletePanel();

		if (m_apWeaponIcons[i].m_pImage)
			m_apWeaponIcons[i].m_pImage->DeletePanel();

		if (m_apWeaponIcons[i].m_pDelete)
			m_apWeaponIcons[i].m_pDelete->DeletePanel();
	}

	m_apWeaponIcons.RemoveAll();

	const char szWeaponPreviewTemplate[] =
		"	\"model\"\n"
		"	{\n"
		"		\"spotlight\"	\"1\"\n"
		"		\"modelname\"	\"models/weapons/beretta.mdl\"\n"
		"		\"origin_x\"	\"30\"\n"
		"		\"origin_y\"	\"3\"\n"
		"		\"origin_z\"	\"-3\"\n"
		"		\"angles_y\"	\"200\"\n"
		"	}";

	Panel *pWeaponIconArea = FindChildByName("WeaponIconArea");
	if ((ShouldShowCharacterAndWeapons() || ShouldShowEverything()) && pWeaponIconArea)
	{
		int iWeaponAreaX, iWeaponAreaY, iWeaponAreaW, iWeaponAreaH;
		pWeaponIconArea->GetPos(iWeaponAreaX, iWeaponAreaY);
		pWeaponIconArea->GetSize(iWeaponAreaW, iWeaponAreaH);

		int iMargin = 5;

		int iBoxSize = (iWeaponAreaW-5)/2;

		int iWeapon = 0;

		for (int i = 0; i < MAX_LOADOUT; i++)
		{
			if (!pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i))
				continue;

			CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i);
			if (!pWeaponInfo)
				continue;

			for (int j = 0; j < pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i); j++)
			{
				float flMoveRight = 0;
				if (iWeapon%2 == 1)
					flMoveRight = iBoxSize + iMargin;

				CWeaponIcon* pIcon = &m_apWeaponIcons[m_apWeaponIcons.AddToTail()];

				pIcon->m_pWeaponName = new CFolderLabel(this, NULL);
				pIcon->m_pWeaponName->SetText(VarArgs("#DA_Weapon_Obituary_%s", pWeaponInfo->szClassName+7)); // Use the obit version because it's shorter
				pIcon->m_pWeaponName->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + 10 + (iWeapon/2) * (iBoxSize+iMargin));
				pIcon->m_pWeaponName->SetSize(iBoxSize, 15);
				pIcon->m_pWeaponName->SetContentAlignment(Label::a_center);
				pIcon->m_pWeaponName->SetZPos(-5);
				pIcon->m_pWeaponName->SetFont(vgui::scheme()->GetIScheme(GetScheme())->GetFont("FolderLarge"));
				pIcon->m_pWeaponName->SetScheme("FolderScheme");

				std::wostringstream sSlotsLabel;

				if (pWeaponInfo->iWeight)
				{
					const wchar_t *pchFmt = g_pVGuiLocalize->Find( "#DA_BuyMenu_Weapon_Slots" );
					if ( pchFmt && pchFmt[0] )
						sSlotsLabel << pchFmt;
					else
						sSlotsLabel << "Slots: ";

					sSlotsLabel << pWeaponInfo->iWeight;

					pIcon->m_pSlots = new CFolderLabel(this, NULL);
					pIcon->m_pSlots->SetText(sSlotsLabel.str().c_str());
					pIcon->m_pSlots->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + iBoxSize - 10 + (iWeapon/2) * (iBoxSize+iMargin));
					pIcon->m_pSlots->SetSize(iBoxSize, 15);
					pIcon->m_pSlots->SetContentAlignment(Label::a_center);
					pIcon->m_pSlots->SetZPos(-5);
					pIcon->m_pSlots->SetFont(vgui::scheme()->GetIScheme(GetScheme())->GetFont("FolderSmall"));
					pIcon->m_pSlots->SetScheme("FolderScheme");
				}

				KeyValues* pValues = new KeyValues("preview");
				pValues->LoadFromBuffer("model", szWeaponPreviewTemplate);
				pValues->SetString("modelname", pWeaponInfo->szWorldModel);

				if (pWeaponInfo->m_eWeaponType == WT_PISTOL)
				{
					pValues->SetInt("origin_x", 20);
				}
				else if (pWeaponInfo->m_eWeaponType == WT_RIFLE)
				{
					pValues->SetInt("origin_x", 50);
					pValues->SetInt("angles_y", 210);
				}
				else if (pWeaponInfo->m_eWeaponType == WT_SHOTGUN)
				{
					pValues->SetInt("origin_x", 50);
					pValues->SetInt("origin_y", 10);
					pValues->SetInt("angles_y", 150);
				}
				else if (pWeaponInfo->m_eWeaponType == WT_SMG)
				{
				}
				else if (pWeaponInfo->m_eWeaponType == WT_GRENADE)
				{
					pValues->SetInt("origin_x", 20);
				}

				pIcon->m_pImage = new CModelPanel(this, NULL);
				pIcon->m_pImage->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + (iWeapon/2) * (iBoxSize+iMargin));
				pIcon->m_pImage->SetSize(iBoxSize, iBoxSize);
				pIcon->m_pImage->SetZPos(-15);
				pIcon->m_pImage->SetScheme("FolderScheme");
				pIcon->m_pImage->ParseModelInfo(pValues);

				pValues->deleteThis();

				pIcon->m_pDelete = new CImageButton(this, VarArgs("delete_%d", iWeapon));
				pIcon->m_pDelete->SetDimensions(iWeaponAreaX + iBoxSize - 8 + flMoveRight, iWeaponAreaY + 30 + (iWeapon/2) * (iBoxSize+iMargin), 12, 12);
				pIcon->m_pDelete->SetZPos(15);
				pIcon->m_pDelete->SetImage("folder_delete");
				pIcon->m_pDelete->SetPaintBorderEnabled(false);
				pIcon->m_pDelete->SetPaintBackgroundEnabled(true);
				pIcon->m_pDelete->SetCommand(VarArgs("buy remove %d", i));

				iWeapon++;
			}
		}
	}

	CFolderLabel* pWeaponTotalWeightNumber = dynamic_cast<CFolderLabel*>(FindChildByName("WeaponTotalWeightNumber"));
	CFolderLabel* pWeaponTotalWeight = dynamic_cast<CFolderLabel*>(FindChildByName("WeaponTotalWeight"));
	if ((ShouldShowCharacterAndWeapons() || ShouldShowEverything()) && pPlayer->GetLoadoutWeight())
	{
		if (pWeaponTotalWeightNumber)
		{
			wchar_t szText[20];
			_snwprintf( szText, ARRAYSIZE(szText) - 1, L"%d/%d", pPlayer->GetLoadoutWeight(), MAX_LOADOUT_WEIGHT );
			pWeaponTotalWeightNumber->SetText(szText);
			pWeaponTotalWeightNumber->SetVisible(true);
		}

		if (pWeaponTotalWeight)
			pWeaponTotalWeight->SetVisible(true);
	}
	else
	{
		if (pWeaponTotalWeightNumber)
			pWeaponTotalWeightNumber->SetVisible(false);

		if (pWeaponTotalWeight)
			pWeaponTotalWeight->SetVisible(false);
	}

	if (ShouldShowEverything())
	{
		CFolderLabel *pSkillInfo = dynamic_cast<CFolderLabel *>(FindChildByName("SkillInfo"));
		CPanelTexture *pSkillIcon = dynamic_cast<CPanelTexture *>(FindChildByName("SkillIcon"));

		if (pSkillInfo && pSkillIcon)
		{
			if (pPlayer->m_Shared.m_iStyleSkill)
			{
				pSkillInfo->SetText((std::string("#DA_SkillInfo_") + SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkill.Get())).c_str());
				pSkillIcon->SetImage(SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkill.Get()));
			}
			else
			{
				pSkillInfo->SetText("");
				pSkillIcon->SetImage("");
			}
		}
	}

	m_pSuicideOption->SetVisible(pPlayer->IsAlive() && !ShouldShowTeams());

	Button *pProceedButton = dynamic_cast<Button *>(FindChildByName("ProceedButton"));
	if (pProceedButton)
		pProceedButton->SetVisible(m_pPage && FStrEq(m_pPage->GetName(), PANEL_BUY));

	Button *pApproveButton = dynamic_cast<Button *>(FindChildByName("ApproveButton"));
	if (pApproveButton)
		pApproveButton->SetVisible(IsLoadoutComplete());

	Button *pAgentsTab = dynamic_cast<Button *>(FindChildByName("AgentsTab"));
	if (pAgentsTab)
		pAgentsTab->SetVisible(pPlayer->HasCharacterBeenChosen());

	Button *pWeaponsTab = dynamic_cast<Button *>(FindChildByName("WeaponsTab"));
	if (pWeaponsTab)
		pWeaponsTab->SetVisible(pPlayer->HasCharacterBeenChosen());

	Button *pSkillsTab = dynamic_cast<Button *>(FindChildByName("SkillsTab"));
	if (pSkillsTab)
		pSkillsTab->SetVisible(pPlayer->HasSkillsTabBeenSeen());

	Button *pChangeTeams = dynamic_cast<Button *>(FindChildByName("ChangeTeamsButton"));
	if (pChangeTeams)
		pChangeTeams->SetVisible(SDKGameRules()->IsTeamplay());
}
Пример #4
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool BuildGroup::MousePressed(MouseCode code, Panel *panel)
{
	Assert(panel);

	if ( !m_hBuildDialog.Get() )
	{
		if ( panel->GetParent() )
		{
			EditablePanel *ep = dynamic_cast< EditablePanel * >( panel->GetParent() );
			if ( ep )
			{
				BuildGroup *bg = ep->GetBuildGroup();
				if ( bg && bg != this )
				{
					bg->MousePressed( code, panel );
				}
			}
		}
		return false;
	}

	// if people click on the base build dialog panel.
	if (panel == m_hBuildDialog)
	{
		// hide the click menu if its up
		ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("HideNewControlMenu"), NULL);
		return true;
	}

	// don't select unnamed items
	if (strlen(panel->GetName()) < 1)
		return true;
	
	bool shift = ( input()->IsKeyDown(KEY_LSHIFT) || input()->IsKeyDown(KEY_RSHIFT) );	
	if (!shift)
	{
		_controlGroup.RemoveAll();	
	}

	// Show new ctrl menu if they click on the bg (not on a subcontrol)
	if ( code == MOUSE_RIGHT && panel == GetContextPanel())
	{		
		// trigger a drop down menu to create new controls
		ivgui()->PostMessage (m_hBuildDialog->GetVPanel(), new KeyValues("ShowNewControlMenu"), NULL);	
	}	
	else
	{	
		// don't respond if we click on ruler numbers
		if (_showRulers) // rulers are visible
		{
			for ( int i=0; i < 4; i++)
			{
				if ( panel == _rulerNumber[i])
					return true;
			}
		}

		_dragging = true;
		_dragMouseCode = code;
		ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("HideNewControlMenu"), NULL);
		
		int x, y;
		input()->GetCursorPos(x, y);
		
		_dragStartCursorPos[0] = x;
		_dragStartCursorPos[1] = y;
	
		
		input()->SetMouseCapture(panel->GetVPanel());
		
		_groupDeltaX.RemoveAll();
		_groupDeltaY.RemoveAll();

		// basepanel is the panel that all the deltas will be calculated from.
		// it is the last panel we clicked in because if we move the panels  as a group
		// it would be from that one
		Panel *basePanel = NULL;
		// find the panel we clicked in, that is the base panel
		// it might already be in the group
		for (int i=0; i< _controlGroup.Count(); ++i)	
		{
			if (panel == _controlGroup[i].Get())
			{
				basePanel = panel;
				break;
			}
		}

		// if its not in the group we just added this panel. get it in the group 
		if (basePanel == NULL)
		{
			PHandle temp;
			temp = panel;
			_controlGroup.AddToTail(temp);
			basePanel = panel;
		}
		
		basePanel->GetPos(x,y);
		_dragStartPanelPos[0]=x;
		_dragStartPanelPos[1]=y;

		basePanel->GetSize( _dragStartPanelSize[ 0 ], _dragStartPanelSize[ 1 ] );

		// figure out the deltas of the other panels from the base panel
		for (int i=0; i<_controlGroup.Count(); ++i)
		{
			int cx, cy;
			_controlGroup[i].Get()->GetPos(cx, cy);
			_groupDeltaX.AddToTail(cx - x);
			_groupDeltaY.AddToTail(cy - y);
		}
						
		// if this panel wasn't already selected update the buildmode dialog controls to show its info
		if(_currentPanel != panel)
		{			
			_currentPanel = panel;
			
			if ( m_hBuildDialog )
			{
				// think this is taken care of by SetActiveControl.
				//ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("ApplyDataToControls"), NULL);
				
				KeyValues *keyval = new KeyValues("SetActiveControl");
				keyval->SetPtr("PanelPtr", GetCurrentPanel());
				ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), keyval, NULL);
			}		
		}		

		// store undo information upon panel selection.
		ivgui()->PostMessage(m_hBuildDialog->GetVPanel(), new KeyValues("StoreUndo"), NULL);

		panel->RequestFocus();
	}

	return true;
}
Пример #5
0
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
		}
	}
}
Пример #6
0
void QuickJoinPanel::OnThink()
{
	int iNumItems = MIN( m_FriendInfo.Count(), cl_quick_join_scroll_max.GetInt() );

	const int iItemTallMin = 2;
	int iItemTall = iItemTallMin;

	Panel *pItem = m_GplQuickJoinList->GetPanelItem( 0 );
	if ( pItem )
	{
		iItemTall = pItem->GetTall();

		Panel *pItem2 = m_GplQuickJoinList->GetPanelItem( 1 );
		if ( pItem2 )
		{
			int iXPos1, iYPos1;
			int iXPos2, iYPos2;

			pItem->GetPos( iXPos1, iYPos1 );
			pItem2->GetPos( iXPos2, iYPos2 );

			iItemTall = iYPos2 - iYPos1;
		}
	}

	iItemTall = MAX( iItemTall, iItemTallMin );

	long lRateValue = ( system()->GetTimeMillis() / cl_quick_join_scroll_rate.GetInt() );
	int iWrap = ( lRateValue / iItemTall ) + cl_quick_join_scroll_max.GetInt();

	if ( iWrap != m_iPrevWrap )
	{
		RefreshContents( iWrap );
		m_iPrevWrap = iWrap;

		UpdateNumGamesFoundLabel();

		SetVisible( m_FriendInfo.Count() > 0 );

		// Fade out last item completely since we wrapped around and done!
		pItem = m_GplQuickJoinList->GetPanelItem( ( iNumItems > 1 ) ? ( iNumItems - 1 ) : ( 1 ) );
		if ( pItem )
			pItem->SetAlpha( 0.0f );
		return;
	}

	int screenWide, screenTall;
	vgui::surface()->GetScreenSize( screenWide, screenTall );

	int iYOffset = 110;
	if ( IsPC() )
	{
		iYOffset = 30;
	}

	bool bScrolling = ( iNumItems >= cl_quick_join_scroll_start.GetInt() );

	int iCurrentX, iCurrentY;
	GetPos( iCurrentX, iCurrentY );
	iCurrentY = GetSmoothPanelY( iCurrentY, screenTall
								 - vgui::scheme()->GetProportionalScaledValue( iYOffset )
								 - MAX( iNumItems, ( bScrolling ) ? ( 2 ) : ( 1 ) ) * iItemTall );
	SetPos( iCurrentX, iCurrentY );

	if ( iNumItems > cl_quick_join_scroll_start.GetInt() - 1 )
	{
		// Scrolling list illusion
		int iTimeOffset = lRateValue % iItemTall;

		float fTimeOffset = iTimeOffset;

		m_GplQuickJoinList->GetPos( iCurrentX, iCurrentY );
		m_GplQuickJoinList->SetPos( iCurrentX, fTimeOffset + vgui::scheme()->GetProportionalScaledValue( cl_quick_join_scroll_offset.GetFloat() ) );

		float fListEdgeAlphas = 255.0f * ( fTimeOffset / static_cast<float>( iItemTall ) );

		// Fade in first item
		pItem = m_GplQuickJoinList->GetPanelItem( 0 );
		if ( pItem )
		{
			pItem->SetAlpha( fListEdgeAlphas );
		}

		// Fade out last item
		pItem = m_GplQuickJoinList->GetPanelItem( ( iNumItems > 1 ) ? ( iNumItems - 1 ) : ( 1 ) );

		if ( pItem )
		{
			pItem->SetAlpha( 255.0f - fListEdgeAlphas );
		}
	}
	else
	{
		m_GplQuickJoinList->GetPos( iCurrentX, iCurrentY );
		m_GplQuickJoinList->SetPos( iCurrentX, vgui::scheme()->GetProportionalScaledValue( cl_quick_join_scroll_offset.GetFloat() ) );
	}
}