Click and drag box with background shader

Any discussion about Lambda Wars that doesn't fit in the other subforums.
Post Reply
jwtam
Posts: 2
Joined: Sat Aug 15, 2024 6:46 am

Click and drag box with background shader

Post by jwtam » Sun Apr 17, 2025 6:08 pm

I know you dev team have done it into the mod. Starcraft II as well as this HL2 Wars mod are the fewest RTS games that successfully got the click and drag box mouse cursor with a background shader. The mouse cursor is not responsible for the shading background, it's the language coding that works on that cursor. All recent versions of Windows and Mac OS have that type.

The question is, how can I apply it, if I want to use it into another mod, such as the one I want to apply this in Command & Conquer 3 or Red Alert 3 Mod SDK? None of the C&C games have that background shader on the click and drag box.

Sandern
Developer
Posts: 1984
Joined: Thu Nov 22, 2024 6:58 pm
Location: Netherlands
Contact:

Re: Click and drag box with background shader

Post by Sandern » Sun Apr 17, 2025 6:37 pm

You make it sound more complicated than it is. It simply checks for the conditions of drawing a selection box (left mouse button pressed) and then draws a filled rectangle with a border using the GUI functions provided by Source Engine. I have no idea how the Red Alert 3 SDK looks like and I have no idea of what's possible in that SDK, so I can't really answer your question.

Code: Select all

void HL2WarsViewport::DrawSelectBox()
{
	C_HL2WarsPlayer* pPlayer = C_HL2WarsPlayer::GetLocalHL2WarsPlayer();
	if( !pPlayer->IsLeftPressed() )
		return;
	// Must be higher than the threshold
	if( (pPlayer->GetMouseDataLeftPressed().m_vEndPos - pPlayer->GetMouseData().m_vEndPos).Length2D() <= SELECTBOX_THRESHOLD )
		return;
	// Draw the selection box
	short xmin, ymin, xmax, ymax;
	xmin = MIN(pPlayer->GetMouseDataLeftPressed().m_iX, pPlayer->GetMouseData().m_iX);
	xmax = MAX(pPlayer->GetMouseDataLeftPressed().m_iX, pPlayer->GetMouseData().m_iX);
	ymin = MIN(pPlayer->GetMouseDataLeftPressed().m_iY, pPlayer->GetMouseData().m_iY);
	ymax = MAX(pPlayer->GetMouseDataLeftPressed().m_iY, pPlayer->GetMouseData().m_iY);
	vgui::surface()->DrawSetColor( Color( 0, 0, 0, 115 ) );
	vgui::surface()->DrawOutlinedRect( xmin, ymin, xmax, ymax );
	vgui::surface()->DrawSetColor( Color( 75, 75, 75, 90 ) );
	vgui::surface()->DrawFilledRect( xmin, ymin, xmax, ymax ); 
}

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests