Пример #1
0
void CCamWnd::Cam_MouseDown(int x, int y, int buttons)
{
	vec3_t		dir;
	float		f, r, u;
	int			i;

	//
	// calc ray direction
	//
	u = (float)(y - m_Camera.height/2) / (m_Camera.width/2);
	r = (float)(x - m_Camera.width/2) / (m_Camera.width/2);
	f = 1;

	for (i=0 ; i<3 ; i++)
		dir[i] = m_Camera.vpn[i] * f + m_Camera.vright[i] * r + m_Camera.vup[i] * u;
	VectorNormalize (dir);

	GetCursorPos(&m_ptCursor);

	m_nCambuttonstate = buttons;
	m_ptButton.x = x;
	m_ptButton.y = y;

	// LBUTTON = manipulate selection
	// shift-LBUTTON = select
	// middle button = grab texture
	// ctrl-middle button = set entire brush to texture
	// ctrl-shift-middle button = set single face to texture
	int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;
	if ((buttons == MK_LBUTTON)
		        || (buttons == (MK_LBUTTON | MK_SHIFT))
		        || (buttons == (MK_LBUTTON | MK_CONTROL))
		        || (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT))
		        || (buttons == nMouseButton)
		        || (buttons == (nMouseButton|MK_SHIFT))
		        || (buttons == (nMouseButton|MK_CONTROL))
		        || (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL)))
	{

    if (g_PrefsDlg.m_nMouseButtons == 2 && (buttons == (MK_RBUTTON | MK_SHIFT)))
		  Cam_MouseControl (0.1);
    else
    {
      // something global needs to track which window is responsible for stuff
      Patch_SetView(W_CAMERA);
		  Drag_Begin (x, y, buttons, m_Camera.vright, m_Camera.vup,	m_Camera.origin, dir);
    }
    return;
	}

	if (buttons == MK_RBUTTON)
	{
		Cam_MouseControl (0.1);
		return;
	}
}
Пример #2
0
/*
==================
WinMain

==================
*/
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance
					,LPSTR lpCmdLine, int nCmdShow)
{
    MSG        msg;
	double		time, oldtime, delta;
	HACCEL		accelerators;

	g_qeglobals.d_hInstance = hInstance;

	InitCommonControls ();

	screen_width = GetSystemMetrics (SM_CXFULLSCREEN);
	screen_height = GetSystemMetrics (SM_CYFULLSCREEN);

	// hack for broken NT 4.0 dual screen
	if (screen_width > 2*screen_height)
		screen_width /= 2;

	accelerators = LoadAccelerators (hInstance
		, MAKEINTRESOURCE(IDR_ACCELERATOR1));
	if (!accelerators)
		Error ("LoadAccelerators failed");

	Main_Create (hInstance);

	WCam_Create (hInstance);
	WXY_Create (hInstance);
	WZ_Create (hInstance);
	CreateEntityWindow(hInstance);

	// the project file can be specified on the command line,
	// or implicitly found in the scripts directory
	if (lpCmdLine && strlen(lpCmdLine))
	{
		ParseCommandLine (lpCmdLine);
		if (!QE_LoadProject(argv[1]))
			Error ("Couldn't load %s project file", argv[1]);
	}
	else if (!QE_LoadProject("scripts/quake.qe4"))
		Error ("Couldn't load scripts/quake.qe4 project file");

	QE_Init ();

	Sys_Printf ("Entering message loop\n");

	oldtime = Sys_DoubleTime ();

	while (!have_quit)
	{
		Sys_EndWait ();		// remove wait cursor if active

		while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (!TranslateAccelerator(g_qeglobals.d_hwndMain, accelerators, &msg) )
			{
      			TranslateMessage (&msg);
      			DispatchMessage (&msg);
			}
			if (msg.message == WM_QUIT)
				have_quit = true;
		}


		CheckBspProcess ();

		time = Sys_DoubleTime ();
		delta = time - oldtime;
		oldtime = time;
		if (delta > 0.2)
			delta = 0.2;

		// run time dependant behavior
		Cam_MouseControl (delta);

		// update any windows now
		if (update_bits & W_CAMERA)
		{
			InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
			UpdateWindow (g_qeglobals.d_hwndCamera);
		}
		if (update_bits & (W_Z | W_Z_OVERLAY) )
		{
			InvalidateRect(g_qeglobals.d_hwndZ, NULL, false);
			UpdateWindow (g_qeglobals.d_hwndZ);
		}
			
		if ( update_bits & W_TEXTURE )
		{
			InvalidateRect(g_qeglobals.d_hwndTexture, NULL, false);
			UpdateWindow (g_qeglobals.d_hwndEntity);
		}
	
		if (update_bits & (W_XY | W_XY_OVERLAY))
		{
			InvalidateRect(g_qeglobals.d_hwndXY, NULL, false);
			UpdateWindow (g_qeglobals.d_hwndXY);
		}

		update_bits = 0;

		if (!cambuttonstate && !have_quit)
		{	// if not driving in the camera view, block
			WaitMessage ();
		}

	}

    /* return success of application */
    return TRUE;

}