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; } }
/* ============== Z_MouseDown ============== */ void Z_MouseDown (int x, int y, int buttons) { vec3_t org, dir, vup, vright; brush_t *b; Sys_GetCursorPos (&cursorx, &cursory); vup[0] = 0; vup[1] = 0; vup[2] = 1/z.scale; VectorCopy (z.origin, org); org[2] += (y - (z.height/2))/z.scale; org[1] = g_MinWorldCoord; b = selected_brushes.next; if (b != &selected_brushes) { org[0] = (b->mins[0] + b->maxs[0])/2; } dir[0] = 0; dir[1] = 1; dir[2] = 0; vright[0] = 0; vright[1] = 0; vright[2] = 0; // 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_MBUTTON) // || (buttons == (MK_MBUTTON|MK_CONTROL)) || (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL)) ) { Drag_Begin (x, y, buttons, vright, vup, org, dir); return; } // control mbutton = move camera if ((buttons == (MK_CONTROL|nMouseButton) ) || (buttons == (MK_CONTROL|MK_LBUTTON))) { g_pParentWnd->GetCamWnd()->Camera()->origin[2] = org[2] ; Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z); } }
/* ============== Z_MouseDown ============== */ void Z_MouseDown (int x, int y, int buttons) { vec3_t org, dir, vup, vright; brush_t *b; Sys_GetCursorPos (&cursorx, &cursory); vup[0] = 0; vup[1] = 0; vup[2] = 1/z.scale; VectorCopy (z.origin, org); org[2] += (y - (z.height/2))/z.scale; org[1] = MIN_WORLD_COORD; b = selected_brushes.next; if (b != &selected_brushes) { org[0] = (b->mins[0] + b->maxs[0])/2; } dir[0] = 0; dir[1] = 1; dir[2] = 0; vright[0] = 0; vright[1] = 0; vright[2] = 0; // new mouse code for ZClip, I'll do this stuff before falling through into the standard ZWindow mouse code... // if (g_pParentWnd->GetZWnd()->m_pZClip) // should always be the case I think, but this is safer { bool bToggle = false; bool bSetTop = false; bool bSetBot = false; bool bReset = false; if (g_PrefsDlg.m_nMouseButtons == 2) { // 2 button mice... // bToggle = (GetKeyState(VK_F1) & 0x8000); bSetTop = (GetKeyState(VK_F2) & 0x8000); bSetBot = (GetKeyState(VK_F3) & 0x8000); bReset = (GetKeyState(VK_F4) & 0x8000); } else { // 3 button mice... // bToggle = (buttons == (MK_RBUTTON|MK_SHIFT|MK_CONTROL)); bSetTop = (buttons == (MK_RBUTTON|MK_SHIFT)); bSetBot = (buttons == (MK_RBUTTON|MK_CONTROL)); bReset = (GetKeyState(VK_F4) & 0x8000); } if (bToggle) { g_pParentWnd->GetZWnd()->m_pZClip->Enable(!(g_pParentWnd->GetZWnd()->m_pZClip->IsEnabled())); Sys_UpdateWindows (W_ALL); return; } if (bSetTop) { g_pParentWnd->GetZWnd()->m_pZClip->SetTop(org[2]); Sys_UpdateWindows (W_ALL); return; } if (bSetBot) { g_pParentWnd->GetZWnd()->m_pZClip->SetBottom(org[2]); Sys_UpdateWindows (W_ALL); return; } if (bReset) { g_pParentWnd->GetZWnd()->m_pZClip->Reset(); Sys_UpdateWindows (W_ALL); return; } } // 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 // // see code above for these next 3, I just commented them here as well for clarity... // // ctrl-shift-RIGHT button = toggle ZClip on/off // shift-RIGHT button = set ZClip top marker // ctrl-RIGHT button = set ZClip bottom marker int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON; if ( (buttons == MK_LBUTTON) || (buttons == (MK_LBUTTON | MK_SHIFT)) || (buttons == MK_MBUTTON) // || (buttons == (MK_MBUTTON|MK_CONTROL)) || (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL)) ) { Drag_Begin (x, y, buttons, vright, vup, org, dir); return; } // control mbutton = move camera if ((buttons == (MK_CONTROL|nMouseButton) ) || (buttons == (MK_CONTROL|MK_LBUTTON))) { g_pParentWnd->GetCamera()->Camera().origin[2] = org[2] ; Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY|W_Z); } }
/* ============== XY_MouseDown ============== */ void XY_MouseDown (int x, int y, int buttons) { vec3_t point; vec3_t origin, dir, right, up; buttonstate = buttons; pressx = x; pressy = y; VectorCopy (vec3_origin, pressdelta); XY_ToPoint (x, y, point); VectorCopy (point, origin); origin[2] = 8192; dir[0] = 0; dir[1] = 0; dir[2] = -1; right[0] = 1/g_qeglobals.d_xy.scale; right[1] = 0; right[2] = 0; up[0] = 0; up[1] = 1/g_qeglobals.d_xy.scale; up[2] = 0; press_selection = (selected_brushes.next != &selected_brushes); Sys_GetCursorPos (&cursorx, &cursory); // lbutton = manipulate selection // shift-LBUTTON = select if ( (buttons == MK_LBUTTON) || (buttons == (MK_LBUTTON | MK_SHIFT)) || (buttons == (MK_LBUTTON | MK_CONTROL)) || (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT)) ) { Drag_Begin (x, y, buttons, right, up, origin, dir); return; } // control mbutton = move camera if (buttonstate == (MK_CONTROL|MK_MBUTTON) ) { camera.origin[0] = point[0]; camera.origin[1] = point[1]; Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY); } // mbutton = angle camera if (buttonstate == MK_MBUTTON) { VectorSubtract (point, camera.origin, point); if (point[1] || point[0]) { camera.angles[YAW] = 180/Q_PI*atan2 (point[1], point[0]); Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY); } } // shift mbutton = move z checker if (buttonstate == (MK_SHIFT|MK_MBUTTON) ) { XY_ToPoint (x, y, point); z.origin[0] = point[0]; z.origin[1] = point[1]; Sys_UpdateWindows (W_XY_OVERLAY|W_Z); return; } }