Example #1
0
/*
============
Select_Ray

If the origin is inside a brush, that brush will be ignored.
============
*/
void Select_Ray( vec3_t origin, vec3_t dir, int flags )
{
	trace_t t;
	
	t = Test_Ray( origin, dir, flags );
	if ( !t.brush )
		return;
		
	if ( flags == SF_SINGLEFACE )
	{
		int nCount = g_SelectedFaces.GetSize();
		bool bOk = true;
		for ( int i = 0; i < nCount; i++ )
		{
			if ( t.face == reinterpret_cast<face_s*>( g_SelectedFaces.GetAt( i ) ) )
			{
				bOk = false;
				// need to move remove i'th entry
				g_SelectedFaces.RemoveAt( i, 1 );
				g_SelectedFaceBrushes.RemoveAt( i, 1 );
			}
		}
		if ( bOk )
		{
			g_SelectedFaces.Add( t.face );
			g_SelectedFaceBrushes.Add( t.brush );
		}
		//selected_face = t.face;
		//selected_face_brush = t.brush;
		Sys_UpdateWindows( W_ALL );
		clearSelection();
		// Texture_SetTexture requires a brushprimit_texdef fitted to the default width=2 height=2 texture
		brushprimit_texdef_s brushprimit_texdef;
		ConvertTexMatWithQTexture( &t.face->brushprimit_texdef, t.face->d_texture, &brushprimit_texdef, NULL );
		Texture_SetTexture( &t.face->texdef, &brushprimit_texdef, false, false );
		UpdateSurfaceDialog();
		return;
	}
	
	// move the brush to the other list
	
	clearSelection();
	
	if ( t.selected )
	{
		Brush_RemoveFromList( t.brush );
		Brush_AddToList( t.brush, &active_brushes );
		UpdatePatchInspector();
	}
	else
	{
		Select_Brush( t.brush, !( GetKeyState( VK_MENU ) & 0x8000 ) );
	}
	
	Sys_UpdateWindows( W_ALL );
}
Example #2
0
void WINAPI QERApp_UnHookWindow( IWindowListener* pListen ){
	for ( int i = 0; i < l_WindowListeners.GetSize(); i++ )
	{
		if ( l_WindowListeners.GetAt( i ) == pListen ) {
			l_WindowListeners.RemoveAt( i );
			pListen->DecRef();
			return;
		}
	}
#ifdef _DEBUG
	Sys_FPrintf( SYS_WRN, "WARNING: IWindowListener not found in QERApp_UnHookWindow\n" );
#endif
}
void WINAPI QERApp_UnHookGLWindow(IGLWindow* pGLW)
{
	for( int i = 0; i < l_GLWindows.GetSize(); i++ )
	{
		if (l_GLWindows.GetAt(i) == pGLW)
		{
			l_GLWindows.RemoveAt(i);
			pGLW->DecRef();
			return;
		}
	}
#ifdef _DEBUG
	Sys_Printf("ERROR: IGLWindow* not found in QERApp_UnHookGLWindow\n");
#endif
}
Example #4
0
DWORD WINAPI ThreadProc_SendEmail( LPVOID lpParameter )
{
	CEMailObject *pEMailObject = (CEMailObject*)lpParameter;
	ASSERT ( pEMailObject );

	CHwSMTP HwSMTP;
	BOOL bRet = HwSMTP.SendEmail (
		pEMailObject->m_csSmtpSrvHost,
		pEMailObject->m_csUserName,
		pEMailObject->m_csPasswd,
		pEMailObject->m_bMustAuth,
		pEMailObject->m_csAddrFrom,
		pEMailObject->m_csAddrTo,
		pEMailObject->m_csSubject,
		pEMailObject->m_csBody,
		pEMailObject->m_csCharSet,
		&pEMailObject->m_StrAryAttach,
		pEMailObject->m_StrCC,
		pEMailObject->m_nSmtpSrvPort,
		pEMailObject->m_csSender
		);
	if ( !bRet)
	{
#ifdef _DEBUG
		CString csError = HwSMTP.GetLastErrorText ();
		csError = FormatString ( _T("Send a email to [%s] failed."), pEMailObject->m_csSmtpSrvHost );
		AfxMessageBox ( csError );
#endif
	}

	m_CSFor__g_PtrAry_Threads.Lock ();
	int nFindPos = FindFromArray ( g_PtrAry_Threads, pEMailObject->m_hThread );
	if ( nFindPos >= 0 )
		g_PtrAry_Threads.RemoveAt ( nFindPos );
	m_CSFor__g_PtrAry_Threads.Unlock ();

	delete pEMailObject;
	return bRet;
}
Example #5
0
/***********************************************************
*	作用:马赛克特效
************************************************************/
void EffectDisplay::MosaicDisplay(CDC* pDC, CDC* pMemDC)
{
    #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }

	int nTileSize = 24;	//马赛克小方块大小
	int nRw = 0;
	int nRh = 0;

	if (s_nPicWidth % nTileSize != 0)
		nRw = 1;
	if (s_nPicHeight % nTileSize != 0)
		nRh = 1;

	//计算小方块的个数
	int nTileCount = (s_nPicWidth / nTileSize + nRw)*
		(s_nPicHeight / nTileSize + nRh);

	CPtrArray points;	//保存所有小方块的左上坐标
	long lx = 0;
	long ly = 0;

	for (int k = 0; k < nTileCount; k++)
	{
		CPoint* point = new CPoint;
		point->x = lx;
		point->y = ly;
		lx = lx + nTileSize;
		if (lx >= s_nPicWidth)
		{
			lx = 0;
			ly = ly + nTileSize;
		}
		points.Add(point);
	}

	//根据图像大小确定时间间隔
	int nDelayTime = 2;
	if (s_nPicHeight * s_nPicWidth > 600 * 500)
		nDelayTime = 1;

	LARGE_INTEGER seed;
	QueryPerformanceFrequency(&seed);
	QueryPerformanceCounter(&seed);

	//初始化一个以微秒为单位的时间种子
	srand((int)seed.QuadPart);

	for (int i = nTileCount - 1; i >= 0; i--)
	{
		int n = rand() % (i + 1);
		CPoint* point = (CPoint*)points[n];

		lx = point->x;
		ly = point->y;

		pDC->BitBlt(lx + s_nOffsetX, ly + s_nOffsetY, nTileSize, nTileSize,
			pMemDC, lx + s_nOffsetX, ly + s_nOffsetY, SRCCOPY);

		SAFE_DELETE(point);
		points.RemoveAt(n);

		DelayTime(nDelayTime);
	}
}
Example #6
0
bool CSfxModel::_nextFrame()
{
	bool ret = false;
	m_currentFrame += m_perSlerp;
	const ushort frame = (ushort)m_currentFrame;

	ushort startFrame, endFrame;
	CPtrArray<Particle>* particles;
	Particle* particle;
	int j;
	for (int i = 0; i < m_particles.GetSize(); i++)
	{
		if (m_particles[i])
		{
			const CSfxPartParticle* part = (CSfxPartParticle*)m_sfx->m_parts[i];
			particles = m_particles[i];

			for (j = 0; j < particles->GetSize(); j++)
			{
				particle = particles->GetAt(j);
				particle->pos += particle->speed;
				particle->speed += part->m_particleAccel;
				if (!part->m_repeatScal)
					particle->scale += part->m_scaleSpeed;
				particle->frame++;
				if (particle->frame >= part->m_particleFrameDisappear)
				{
					Delete(particle);
					particles->RemoveAt(j);
					j--;
				}
			}

			startFrame = 0;
			endFrame = 0;
			if (part->GetFirstKey())
			{
				startFrame = part->GetFirstKey()->frame;
				endFrame = part->GetLastKey()->frame;
			}

			if (frame >= startFrame && frame <= endFrame - part->m_particleFrameDisappear)
			{
				if ((part->m_particleCreate == 0 && frame == startFrame) ||
					(part->m_particleCreate != 0 && (frame - startFrame) % part->m_particleCreate == 0)
					)
				{
					const float rand1 = (rand() % 50000) / 50000.0f;
					const float rand2 = (rand() % 50000) / 50000.0f;
					const float rand3 = (rand() % 50000) / 50000.0f;

					for (j = 0; j < part->m_particleCreateNum; j++)
					{
						particle = new Particle();
						particle->frame = 0;

						const float angle = ((rand() % 50000) / 50000.0f) * 360.0f;
						particle->pos =
							D3DXVECTOR3(
							sin(angle) * part->m_particleStartPosVar,
							rand1 * part->m_particleStartPosVarY,
							cos(angle) * part->m_particleStartPosVar
							);
						const float factor = part->m_particleXZLow + rand2 * (part->m_particleXZHigh - part->m_particleXZLow);
						particle->speed =
							D3DXVECTOR3(
							sin(angle) * factor,
							part->m_particleYLow + rand2 * (part->m_particleYHigh - part->m_particleYLow),
							cos(angle) * factor
							);
						particle->scaleStart = particle->scale = part->m_scale;
						particle->rotation = D3DXVECTOR3(part->m_rotationLow.x + rand1 *
							(part->m_rotationHigh.x - part->m_rotationLow.x),
							part->m_rotationLow.y + rand3 *
							(part->m_rotationHigh.y - part->m_rotationLow.y),
							part->m_rotationLow.z + rand2 *
							(part->m_rotationHigh.z - part->m_rotationLow.z));
						particle->swScal = false;
						particle->scaleEnd = part->m_scaleEnd;
						particle->scaleSpeed = D3DXVECTOR3(part->m_scalSpeedXLow + rand3 *
							(part->m_scalSpeedXHigh - part->m_scalSpeedXLow),
							part->m_scalSpeedYLow + rand2 *
							(part->m_scalSpeedYHigh - part->m_scalSpeedYLow),
							part->m_scalSpeedZLow + rand1 *
							(part->m_scalSpeedZHigh - part->m_scalSpeedZLow));

						particles->Append(particle);
					}
				}
			}

			if (particles->GetSize() > 0 || frame < startFrame)
				ret = true;

#ifndef SFX_EDITOR
			if (part->m_repeat)
			{
				if (endFrame >= 0)
				{
					const float f = m_currentFrame / (float)endFrame;
					if (f >= 0.65f)
						m_currentFrame = (float)endFrame * 0.6f;
				}
			}
#endif // SFX_EDITOR
		}
		else
		{
			if (m_sfx->m_parts[i]->GetNextKey(frame))
				ret = true;
		}
	}

	return ret;
}
Example #7
0
void SubclassChildControls( 
	HWND hWndParent 
	)
{
	if(		hWndParent == NULL 
		||	(!::IsWindow( hWndParent ))
		)
		return;  

	HWND hWnd = ::GetWindow( hWndParent, GW_CHILD ); 
	HWND hWndLast = NULL;
	
	CPtrArray arrGroupBoxes;
	while( hWnd != NULL )
	{
		TCHAR szCompare[512] = _T("");
		::GetClassName(
			hWnd,
			szCompare,
			sizeof( szCompare )/sizeof( szCompare[0] )
			);
		static const TCHAR szStatic[]		= _T("STATIC");
		static const TCHAR szEdit[]			= _T("EDIT");
		static const TCHAR szComboBox[]		= _T("COMBOBOX");
		static const TCHAR szButton[]		= _T("BUTTON");
		static const TCHAR szProgress[]		= _T("PROGRESS");
		static const TCHAR szScrollBar[]	= _T("SCROLLBAR");
		static const TCHAR szSpin[]			= _T("MSCTLS_UPDOWN32");

		// static
		if( _tcsicmp( szCompare, szStatic ) == 0 )
		{
			__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtLabel ); 
		}
		// edit
		else if( _tcsicmp( szCompare, szEdit ) == 0 )
		{
			__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtEdit );
		}
		// combobox
		else if( _tcsicmp( szCompare, szComboBox ) == 0 )
		{
			__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtComboBox );
		}
		// button
		else if( _tcsicmp( szCompare, szButton ) == 0 )
		{
			CWnd * pWnd = CWnd::FromHandlePermanent( hWnd ); 
			if( pWnd == NULL ) 
			{
			#ifdef BS_TYPEMASK
				ASSERT( BS_TYPEMASK == 0x0000000FL );
			#endif
				__EXT_MFC_LONG_PTR dwWndStyle = ::__EXT_MFC_GetWindowLong( hWnd, GWL_STYLE );
				__EXT_MFC_LONG_PTR dwWndType = ( dwWndStyle & 0x0000000FL );
				if(		dwWndType == BS_PUSHBUTTON 
					||	dwWndType == BS_DEFPUSHBUTTON 
					)
				{
					// regular button
					__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtButton );
				}
				else if(	dwWndType == BS_AUTOCHECKBOX
						||	dwWndType == BS_CHECKBOX
						||	dwWndType == BS_AUTO3STATE
						||	dwWndType == BS_3STATE
						)
				{
					// check box
					__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtCheckBox );
				}
				else if(	dwWndType == BS_AUTORADIOBUTTON
						||	dwWndType == BS_RADIOBUTTON
						)
				{
					// radio button
					__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtRadioButton );
				}
				else if( dwWndType == BS_GROUPBOX )
				{
					// group box
					__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtGroupBox );
					arrGroupBoxes.Add( LPVOID( hWnd ) );
					::InvalidateRect( hWnd, NULL, TRUE );
				} 
			} // if( pWnd == NULL )
		}
#ifndef __EXT_MFC_NO_PROGRESS_WND
		else if( _tcsicmp( szCompare, szProgress ) == 0 )
		{
			// progress bar
			__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtProgressWnd );
		}
#endif
		else if( _tcsicmp( szCompare, szScrollBar ) == 0 )
		{
			// scroll bar
			__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtScrollBar );
		} 
#ifndef __EXT_MFC_NO_SPIN
		else if( _tcsicmp( szCompare, szSpin ) == 0 )
		{
			// spin button
			__EXT_SUBCLASS_PROFUISCTRL( hWnd, CExtSpinWnd );
		} 
#endif

		hWndLast = hWnd;

		hWnd = ::GetWindow( hWnd, GW_HWNDNEXT );  
	
	} // while( hWnd != NULL )

	if(		hWndLast != NULL
		&&	arrGroupBoxes.GetSize() > 0
		)
	{
		// move all the group boxes to the back by changing the tab order at runtime
		HWND hWndPrev = hWndLast;
		while( arrGroupBoxes.GetSize() > 0 )
		{
			HWND hWnd = (HWND) arrGroupBoxes.GetAt( 0 );
			if(		hWnd != NULL 
				&&	::IsWindow( hWnd )
				)
			{
				::SetWindowPos(
					hWnd,
					hWndPrev,
					0,0,
					0,0,
					SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE
					);
				hWndPrev = hWnd;
			}
			arrGroupBoxes.RemoveAt( 0 );
		}
	}
}