// If the button in the command bar is clicked, then this function will be called // virtual BOOL S2_CrvLineSegCmd::OnExecute() { // Initialize FW_Cmd::OnExecute(); // Get active view FW_View* pView = GetView(); if(!pView) return FALSE; // Get root node GR_DLNode* pDLNode = pView->GetDLNode(); if(!pDLNode) return FALSE; m_pDLNodeSketch2D = GR_DLNodeSketch2D::GetActive(pDLNode); if(!m_pDLNodeSketch2D) return FALSE; m_pPtPrevious = NULL; m_pDLCrvPreview = NULL; return TRUE; }
LRESULT CSimpleGraph::OnMouseHover(WPARAM, LPARAM lp) { CPoint pt(LOWORD(lp), HIWORD(lp)); // client window coords CHexEditView *pv = GetView(); ASSERT(pv != NULL); m_bar = get_bar(pt); if (m_bar > -1 && !m_tip.IsWindowVisible()) { // Update the tip info m_tip.Clear(); CString ss; if (theApp.hex_ucase_) ss.Format("Byte: %d [%02.2Xh] %s", m_bar, m_bar, pv->DescChar(m_bar)); else ss.Format("Byte: %d [%02.2xh] %s", m_bar, m_bar, pv->DescChar(m_bar)); m_tip.AddString(ss); char buf[32]; // used with sprintf (CString::Format can't handle __int64) sprintf(buf, "%I64d", m_val[m_bar]); ss = buf; AddCommas(ss); m_tip.AddString("Count: " +ss); // Work out the tip window display position and move the tip window there CPoint tip_pt = pt + CSize(16, 16); ClientToScreen(&tip_pt); m_tip.Move(tip_pt, false); m_tip.Show(); track_mouse(TME_LEAVE); return 0; // return 0 to say we processed it } return 1; }
//----------------------------------------------------------------------------- // Purpose: Sets view parameters for level overview mode // Input : *rect - //----------------------------------------------------------------------------- void CViewRender::SetUpOverView() { static int oldCRC = 0; CViewSetup &view = GetView ( STEREO_EYE_MONO ); view.m_bOrtho = true; float aspect = (float)view.width/(float)view.height; int size_y = 1024.0f * cl_leveloverview.GetFloat(); // scale factor, 1024 = OVERVIEW_MAP_SIZE int size_x = size_y * aspect; // standard screen aspect view.origin.x -= size_x / 2; view.origin.y += size_y / 2; view.m_OrthoLeft = 0; view.m_OrthoTop = -size_y; view.m_OrthoRight = size_x; view.m_OrthoBottom = 0; view.angles = QAngle( 90, 90, 0 ); // simple movement detector, show position if moved int newCRC = view.origin.x + view.origin.y + view.origin.z; if ( newCRC != oldCRC ) { Msg( "Overview: scale %.2f, pos_x %.0f, pos_y %.0f\n", cl_leveloverview.GetFloat(), view.origin.x, view.origin.y ); oldCRC = newCRC; } CMatRenderContextPtr pRenderContext( materials ); pRenderContext->ClearColor4ub( 0, 255, 0, 255 ); // render->DrawTopView( true ); }
Ray Camera::GetScreenRay(float x, float y) const { Ray ret; // If projection is invalid, just return a ray pointing forward if (!IsProjectionValid()) { ret.origin_ = node_ ? node_->GetWorldPosition() : Vector3::ZERO; ret.direction_ = node_ ? node_->GetWorldDirection() : Vector3::FORWARD; return ret; } Matrix4 viewProjInverse = (GetProjection(false) * GetView()).Inverse(); // The parameters range from 0.0 to 1.0. Expand to normalized device coordinates (-1.0 to 1.0) & flip Y axis x = 2.0f * x - 1.0f; y = 1.0f - 2.0f * y; Vector3 near(x, y, 0.0f); Vector3 far(x, y, 1.0f); ret.origin_ = viewProjInverse * near; ret.direction_ = ((viewProjInverse * far) - ret.origin_).Normalized(); return ret; }
BOOL DTransformScale::OnSetActive() { // return DTransformScale::OnSetActive(); GView *view = GetView(); // make translation event handler active GMoveTransformHandler *h = new GMoveTransformHandler(view); h->SetMapMode(m_type); h->SetTransformMode(GMoveTransformHandler::MODE_SCALE); h->SetDialog(this); h->SetAxes(GetAxes()); h->scaleUniform = m_uniform; h->ref(); m_pView->Message("Select and drag scales object"); m_handler = h; view->PushEventHandler(h); return CPropertyPage::OnSetActive(); }
NS_IMETHODIMP nsPlaceholderFrame::List(FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); #ifdef DEBUG_waterson fprintf(out, " [parent=%p]", static_cast<void*>(mParent)); #endif if (HasView()) { fprintf(out, " [view=%p]", (void*)GetView()); } fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height); if (0 != mState) { fprintf(out, " [state=%016llx]", mState); } nsIFrame* prevInFlow = GetPrevInFlow(); nsIFrame* nextInFlow = GetNextInFlow(); if (nsnull != prevInFlow) { fprintf(out, " prev-in-flow=%p", static_cast<void*>(prevInFlow)); } if (nsnull != nextInFlow) { fprintf(out, " next-in-flow=%p", static_cast<void*>(nextInFlow)); } if (nsnull != mContent) { fprintf(out, " [content=%p]", static_cast<void*>(mContent)); } if (nsnull != mStyleContext) { fprintf(out, " [sc=%p]", static_cast<void*>(mStyleContext)); } if (mOutOfFlowFrame) { fprintf(out, " outOfFlowFrame="); nsFrame::ListTag(out, mOutOfFlowFrame); } fputs("\n", out); return NS_OK; }
BOOL DTransformRotation::OnSetActive() { // TODO: Add your specialized code here and/or call the base class // return DTransformScale::OnSetActive(); GView *view = GetView(); // make translation event handler active GMoveTransformHandler *h = new GMoveTransformHandler(view); h->SetMapMode(m_type); h->SetTransformMode(GMoveTransformHandler::MODE_ROTATE); h->SetDialog(this); h->SetAxes(GetAxes()); h->rotateTrackball = m_trackball; h->ref(); m_pView->Message("Select and drag scales object"); m_handler = h; view->PushEventHandler(h); return CPropertyPage::OnSetActive(); }
// Sends the bitmap extracted from the View window to a printer of your choice // This function provides a useful reference for printing bitmaps in general void CDoc::Print() { // Get the dimensions of the View window CRect rcView = GetView().GetClientRect(); int Width = rcView.Width(); int Height = rcView.Height(); // Copy the bitmap from the View window CClientDC ViewDC(GetView()); CMemDC MemDC(ViewDC); CBitmap bmView; bmView.CreateCompatibleBitmap(ViewDC, Width, Height); MemDC.SelectObject(bmView); MemDC.BitBlt(0, 0, Width, Height, ViewDC, 0, 0, SRCCOPY); CPrintDialog PrintDlg; try { // Bring up a dialog to choose the printer if (PrintDlg.DoModal(GetView()) == IDOK) // throws exception if there is no default printer { // Zero and then initialize the members of a DOCINFO structure. DOCINFO di; memset(&di, 0, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); di.lpszDocName = _T("Scribble Printout"); di.lpszOutput = (LPTSTR)NULL; di.lpszDatatype = (LPTSTR)NULL; di.fwType = 0; // Begin a print job by calling the StartDoc function. CDC dcPrint = PrintDlg.GetPrinterDC(); if (SP_ERROR == StartDoc(dcPrint, &di)) throw CUserException(_T("Failed to start print job")); // Inform the driver that the application is about to begin sending data. if (0 > StartPage(dcPrint)) throw CUserException(_T("StartPage failed")); BITMAPINFOHEADER bi; ZeroMemory(&bi, sizeof(BITMAPINFOHEADER)); bi.biSize = sizeof(BITMAPINFOHEADER); bi.biHeight = Height; bi.biWidth = Width; bi.biPlanes = 1; bi.biBitCount = 24; bi.biCompression = BI_RGB; // Note: BITMAPINFO and BITMAPINFOHEADER are the same for 24 bit bitmaps // Get the size of the image data MemDC.GetDIBits(bmView, 0, Height, NULL, reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS); // Retrieve the image data std::vector<byte> vBits(bi.biSizeImage, 0); // a vector to hold the byte array byte* pByteArray = &vBits.front(); MemDC.GetDIBits(bmView, 0, Height, pByteArray, reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS); // Determine the scaling factors required to print the bitmap and retain its original proportions. float fLogPelsX1 = (float)ViewDC.GetDeviceCaps(LOGPIXELSX); float fLogPelsY1 = (float)ViewDC.GetDeviceCaps(LOGPIXELSY); float fLogPelsX2 = (float)GetDeviceCaps(dcPrint, LOGPIXELSX); float fLogPelsY2 = (float)GetDeviceCaps(dcPrint, LOGPIXELSY); float fScaleX = MAX(fLogPelsX1, fLogPelsX2) / MIN(fLogPelsX1, fLogPelsX2); float fScaleY = MAX(fLogPelsY1, fLogPelsY2) / MIN(fLogPelsY1, fLogPelsY2); // Compute the coordinates of the upper left corner of the centered bitmap. int cWidthPels = GetDeviceCaps(dcPrint, HORZRES); int xLeft = ((cWidthPels / 2) - ((int)(((float)Width) * fScaleX)) / 2); int cHeightPels = GetDeviceCaps(dcPrint, VERTRES); int yTop = ((cHeightPels / 2) - ((int)(((float)Height) * fScaleY)) / 2); // Use StretchDIBits to scale the bitmap and maintain its original proportions if (GDI_ERROR == (UINT)StretchDIBits(dcPrint, xLeft, yTop, (int)((float)Width * fScaleX), (int)((float)Height * fScaleY), 0, 0, Width, Height, pByteArray, reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS, SRCCOPY)) { throw CUserException(_T("Failed to resize image for printing")); } // Inform the driver that the page is finished. if (0 > EndPage(dcPrint)) throw CUserException(_T("EndPage failed")); // Inform the driver that document has ended. if (0 > EndDoc(dcPrint)) throw CUserException(_T("EndDoc failed")); } } catch (const CException& e) { // Display a message box indicating why printing failed. CString strMsg = CString(e.GetText()) + CString("\n") + e.GetErrorString(); CString strType = CString(e.what()); ::MessageBox(NULL, strMsg, strType, MB_ICONWARNING); } }
void CGUIViewControl::SetCurrentView(int viewMode, bool bRefresh /* = false */) { // grab the previous control CGUIControl *previousView = NULL; if (m_currentView >= 0 && m_currentView < (int)m_visibleViews.size()) previousView = m_visibleViews[m_currentView]; UpdateViewVisibility(); // viewMode is of the form TYPE << 16 | ID VIEW_TYPE type = (VIEW_TYPE)(viewMode >> 16); int id = viewMode & 0xffff; // first find a view that matches this view, if possible... int newView = GetView(type, id); if (newView < 0) // no suitable view that matches both id and type, so try just type newView = GetView(type, 0); if (newView < 0 && type == VIEW_TYPE_BIG_ICON) // try icon view if they want big icon newView = GetView(VIEW_TYPE_ICON, 0); if (newView < 0 && type == VIEW_TYPE_BIG_INFO) newView = GetView(VIEW_TYPE_INFO, 0); if (newView < 0) // try a list view newView = GetView(VIEW_TYPE_LIST, 0); if (newView < 0) // try anything! newView = GetView(VIEW_TYPE_NONE, 0); if (newView < 0) return; m_currentView = newView; CGUIControl *pNewView = m_visibleViews[m_currentView]; // make only current control visible... for (ciViews view = m_allViews.begin(); view != m_allViews.end(); ++view) (*view)->SetVisible(false); pNewView->SetVisible(true); if (!bRefresh && pNewView == previousView) return; // no need to actually update anything (other than visibility above) // CLog::Log(LOGDEBUG,"SetCurrentView: Oldview: %i, Newview :%i", m_currentView, viewMode); bool hasFocus(false); int item = -1; if (previousView) { // have an old view - let's clear it out and hide it. hasFocus = previousView->HasFocus(); item = GetSelectedItem(previousView); CGUIMessage msg(GUI_MSG_LABEL_RESET, m_parentWindow, previousView->GetID()); previousView->OnMessage(msg); } // Update it with the contents UpdateContents(pNewView, item); // and focus if necessary if (hasFocus) { CGUIMessage msg(GUI_MSG_SETFOCUS, m_parentWindow, pNewView->GetID(), 0); g_windowManager.SendMessage(msg, m_parentWindow); } UpdateViewAsControl(((IGUIContainer *)pNewView)->GetLabel()); }
void GameObject::Draw(){ //ゲームステージが無効ならリターン if (m_GameStgae.expired()){ return; } //デバイスの取得 auto Dev = App::GetApp()->GetDeviceResources(); auto pDx11Device = Dev->GetD3DDevice(); auto pID3D11DeviceContext = Dev->GetD3DDeviceContext(); //ステータスのポインタ auto RenderStatePtr = Dev->GetRenderState(); auto Stage = m_GameStgae.lock(); auto ViewPtr = Stage->GetView(); //ビューからカメラを取り出す auto PtrCamera = ViewPtr->GetCamera(); //カメラの取得 Matrix4X4 View, Proj; View = PtrCamera->GetViewMatrix(); Proj = PtrCamera->GetProjMatrix(); //コンスタントバッファの設定 Texture3DConstantBuffer cb1; //行列の設定(転置する) cb1.Model = Matrix4X4EX::Transpose(m_WorldMatrix); cb1.View = Matrix4X4EX::Transpose(View); cb1.Projection = Matrix4X4EX::Transpose(Proj); //ライトの設定 //ステージから0番目のライトを取り出す auto PtrLight = ViewPtr->GetMultiLight()->GetLight(0); cb1.LightDir = PtrLight->GetDirectional(); cb1.LightDir.w = 1.0f; //コンスタントバッファの更新 pID3D11DeviceContext->UpdateSubresource(CBTexture3D::GetPtr()->GetBuffer(), 0, nullptr, &cb1, 0, 0); //ストライドとオフセット UINT stride = sizeof(VertexPositionNormalTexture); UINT offset = 0; //頂点バッファの設定 pID3D11DeviceContext->IASetVertexBuffers(0, 1, m_VertexBuffer.GetAddressOf(), &stride, &offset); //インデックスバッファのセット pID3D11DeviceContext->IASetIndexBuffer(m_IndexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0); //描画方法(3角形) pID3D11DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); //透明処理 pID3D11DeviceContext->OMSetBlendState(RenderStatePtr->GetAlphaBlendEx(), nullptr, 0xffffffff); //デプスステンシルは使用する pID3D11DeviceContext->OMSetDepthStencilState(RenderStatePtr->GetDepthDefault(), 0); //シェーダの設定 pID3D11DeviceContext->VSSetShader(VSTexture3D::GetPtr()->GetShader(), nullptr, 0); pID3D11DeviceContext->PSSetShader(PSTexture3D::GetPtr()->GetShader(), nullptr, 0); //リニアサンプラーを設定 ID3D11SamplerState* samplerState = RenderStatePtr->GetLinearClamp(); pID3D11DeviceContext->PSSetSamplers(0, 1, &samplerState); for (auto& m : m_Materials){ //テクスチャを設定 pID3D11DeviceContext->PSSetShaderResources(0, 1, m.m_ShaderResView.GetAddressOf()); //インプットレイアウトの設定 pID3D11DeviceContext->IASetInputLayout(VSTexture3D::GetPtr()->GetInputLayout()); //コンスタントバッファの設定 ID3D11Buffer* pConstantBuffer = CBTexture3D::GetPtr()->GetBuffer(); pID3D11DeviceContext->VSSetConstantBuffers(0, 1, &pConstantBuffer); pID3D11DeviceContext->PSSetConstantBuffers(0, 1, &pConstantBuffer); //レンダリングステート pID3D11DeviceContext->RSSetState(RenderStatePtr->GetCullFront()); //描画 pID3D11DeviceContext->DrawIndexed(m.m_IndexCount, m.m_StartIndex, 0); //レンダリングステート pID3D11DeviceContext->RSSetState(RenderStatePtr->GetCullBack()); //描画 pID3D11DeviceContext->DrawIndexed(m.m_IndexCount, m.m_StartIndex,0); } //後始末 Dev->InitializeStates(RenderStatePtr); }
BOOL CWordPadDoc::DoSave(LPCTSTR pszPathName, BOOL bReplace /*=TRUE*/) // Save the document data to a file // pszPathName = path name where to save document file // if pszPathName is NULL then the user will be prompted (SaveAs) // note: pszPathName can be different than 'm_strPathName' // if 'bReplace' is TRUE will change file name if successful (SaveAs) // if 'bReplace' is FALSE will not change path name (SaveCopyAs) { CString newName = pszPathName; int nOrigDocType = m_nDocType; //saved in case of SaveCopyAs or failure // newName bWrite type result // empty TRUE - SaveAs dialog // empty FALSE - SaveAs dialog // notempty TRUE - nothing // notempty FALSE W6 warn (change to wordpad, save as, cancel) // notempty FALSE other warn (save as, cancel) BOOL bModified = IsModified(); ScanForConverters(); BOOL bSaveAs = FALSE; if (newName.IsEmpty()) bSaveAs = TRUE; else if (!doctypes[m_nDocType].bWrite) { if (m_nDocType == RD_WINWORD6) { // DWORD nHelpIDs[] = // { // 0, 0 // }; int nRes = CButtonDialog::DisplayMessageBox( MAKEINTRESOURCE(IDS_WORD6_WARNING), AfxGetAppName(), MAKEINTRESOURCE(IDS_WORD6_WARNING_BUTTONS), MB_ICONQUESTION, 1, 2); if (nRes == 0) // Save SetDocType(RD_WORDPAD, TRUE); else if (nRes == 2) // Cancel return FALSE; else bSaveAs = TRUE; // else save as } else // { if (AfxMessageBox(IDS_SAVE_UNSUPPORTED, MB_YESNO | MB_ICONQUESTION) != IDYES) { return FALSE; } else bSaveAs = TRUE; } } if (m_lpRootStg == NULL && IsTextType(m_nDocType) && !GetView()->IsFormatText()) { // formatting changed in plain old text file DWORD nHelpIDs[] = { 0, IDH_WORDPAD_WORD6FILE, 0, IDH_WORDPAD_FORMATTED, 0, IDH_WORDPAD_TEXTFILE, 0, 0 }; CString str; AfxFormatString1(str, IDS_SAVE_FORMAT_TEXT, GetTitle()); int nRes = CButtonDialog::DisplayMessageBox(str, MAKEINTRESOURCE(AFX_IDS_APP_TITLE), MAKEINTRESOURCE(IDS_TF_BUTTONS), MB_ICONQUESTION, 0, 3, nHelpIDs); if (nRes == 3) return FALSE; int nDocType = (nRes == 0) ? RD_DEFAULT: //Word 6 (nRes == 1) ? RD_RICHTEXT : //RTF RD_TEXT; //text if (IsTextType(m_nDocType) && nDocType != RD_TEXT) SetDocType(nDocType, TRUE); if (nDocType != RD_TEXT) bSaveAs = TRUE; } GetView()->GetParentFrame()->RecalcLayout(); if (bSaveAs) { newName = m_strPathName; if (bReplace && newName.IsEmpty()) { newName = m_strTitle; int iBad = newName.FindOneOf(_T(" #%;/\\")); // dubious filename if (iBad != -1) newName.ReleaseBuffer(iBad); // append the default suffix if there is one newName += GetExtFromType(m_nDocType); } int nDocType = m_nDocType; if (!theApp.PromptForFileName(newName, bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, &nDocType)) { SetDocType(nOrigDocType, TRUE); return FALSE; // don't even try to save } SetDocType(nDocType, TRUE); } BeginWaitCursor(); if (!OnSaveDocument(newName)) { if (pszPathName == NULL) { // be sure to delete the file TRY { CFile::Remove(newName); } CATCH_ALL(e) { TRACE0("Warning: failed to delete file after failed SaveAs\n"); } END_CATCH_ALL } // restore orginal document type SetDocType(nOrigDocType, TRUE); EndWaitCursor(); return FALSE; }
// This is called by cdll_client_int to setup view model origins. This has to be done before // simulation so entities can access attachment points on view models during simulation. void CViewRender::OnRenderStart() { VPROF_("CViewRender::OnRenderStart", 2, VPROF_BUDGETGROUP_OTHER_UNACCOUNTED, false, 0); IterateRemoteSplitScreenViewSlots_Push( true ); FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( hh ); // This will fill in one of the m_UserView[ hh ] slots SetUpView(); // Adjust mouse sensitivity based upon the current FOV C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( player ) { default_fov.SetValue( player->m_iDefaultFOV ); //Update our FOV, including any zooms going on int iDefaultFOV = default_fov.GetInt(); int localFOV = player->GetFOV(); int min_fov = player->GetMinFOV(); // Don't let it go too low localFOV = MAX( min_fov, localFOV ); GetHud().m_flFOVSensitivityAdjust = 1.0f; #ifndef _XBOX if ( GetHud().m_flMouseSensitivityFactor ) { GetHud().m_flMouseSensitivity = sensitivity.GetFloat() * GetHud().m_flMouseSensitivityFactor; } else #endif { // No override, don't use huge sensitivity if ( localFOV == iDefaultFOV ) { #ifndef _XBOX // reset to saved sensitivity GetHud().m_flMouseSensitivity = 0; #endif } else { // Set a new sensitivity that is proportional to the change from the FOV default and scaled // by a separate compensating factor if ( iDefaultFOV == 0 ) { Assert(0); // would divide by zero, something is broken with iDefatulFOV iDefaultFOV = 1; } GetHud().m_flFOVSensitivityAdjust = ((float)localFOV / (float)iDefaultFOV) * // linear fov downscale zoom_sensitivity_ratio.GetFloat(); // sensitivity scale factor #ifndef _XBOX GetHud().m_flMouseSensitivity = GetHud().m_flFOVSensitivityAdjust * sensitivity.GetFloat(); // regular sensitivity #endif } } } } // Setup the frustum cache for this frame. m_bAllowViewAccess = true; FOR_EACH_VALID_SPLITSCREEN_PLAYER( iSlot ) { const CViewSetup &view = GetView( iSlot ); FrustumCache()->Add( &view, iSlot ); } FrustumCache()->SetUpdated(); m_bAllowViewAccess = false; IterateRemoteSplitScreenViewSlots_Pop(); }
BOOL CGameEngine::WndProcCallback( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { UNUSED(hWnd); switch (uMsg) // Check For Windows Messages { case WM_CREATE: { return TRUE; } case WM_ACTIVATE: // Watch For Window Activate Message { if (!HIWORD(wParam)) // Check Minimization State { m_bActive=TRUE; // Program Is Active if ( GetInput() ) { GetInput()->GetGamepad(0)->Acquire(); GetInput()->GetGamepad(1)->Acquire(); } } else { m_bActive=FALSE; // Program Is No Longer Active } return TRUE; // Return To The Message Loop } case WM_SYSCOMMAND: // Intercept System Commands { switch (wParam) // Check System Calls { case SC_SCREENSAVE: // Screensaver Trying To Start? case SC_MONITORPOWER: // Monitor Trying To Enter Powersave? return TRUE; // Prevent From Happening } break; // Exit } case WM_CLOSE: // Did We Receive A Close Message? { if ( m_pCurrentGameMode ) { m_pCurrentGameMode->OnClose(); } PostQuitMessage(0); // Send A Quit Message return TRUE; // Jump Back } case WM_KEYDOWN: // Is A Key Being Held Down? { m_pInput->GetKeyboard()->KeyDownCallback( wParam ); return TRUE; // Jump Back } case WM_KEYUP: // Has A Key Been Released? { m_pInput->GetKeyboard()->KeyUpCallback( wParam ); return TRUE; // Jump Back } case WM_LBUTTONDOWN: { INT xPos = GET_X_LPARAM(lParam); INT yPos = GET_Y_LPARAM(lParam); m_pInput->GetMouse()->MouseDownCallback( EMouseButton_Left, VECTOR( xPos, yPos ) ); return TRUE; } case WM_LBUTTONUP: { INT xPos = GET_X_LPARAM(lParam); INT yPos = GET_Y_LPARAM(lParam); m_pInput->GetMouse()->MouseUpCallback( EMouseButton_Left, VECTOR( xPos, yPos ) ); return TRUE; } case WM_RBUTTONDOWN: { INT xPos = GET_X_LPARAM(lParam); INT yPos = GET_Y_LPARAM(lParam); m_pInput->GetMouse()->MouseDownCallback( EMouseButton_Right, VECTOR( xPos, yPos ) ); return TRUE; } case WM_RBUTTONUP: { INT xPos = GET_X_LPARAM(lParam); INT yPos = GET_Y_LPARAM(lParam); m_pInput->GetMouse()->MouseUpCallback( EMouseButton_Right, VECTOR( xPos, yPos ) ); return TRUE; } case WM_MBUTTONDOWN: { INT xPos = GET_X_LPARAM(lParam); INT yPos = GET_Y_LPARAM(lParam); m_pInput->GetMouse()->MouseDownCallback( EMouseButton_Middle, VECTOR( xPos, yPos ) ); return TRUE; } case WM_MBUTTONUP: { INT xPos = GET_X_LPARAM(lParam); INT yPos = GET_Y_LPARAM(lParam); m_pInput->GetMouse()->MouseUpCallback( EMouseButton_Middle, VECTOR( xPos, yPos ) ); return TRUE; } case WM_MOUSEMOVE: { INT xPos = GET_X_LPARAM(lParam); INT yPos = GET_Y_LPARAM(lParam); m_pInput->GetMouse()->MouseMoveCallback( VECTOR( xPos, yPos ) ); return TRUE; } case WM_MOUSEWHEEL: { INT zDelta = GET_WHEEL_DELTA_WPARAM(wParam); INT nMove = zDelta / WHEEL_DELTA; if ( nMove > 0 ) { GetView()->DecreaseZoom(); } else { GetView()->IncreaseZoom(); } return TRUE; } case WM_SIZE: // Resize The OpenGL Window { m_pView->Resize(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height return TRUE; // Jump Back } case WM_COMMAND: { std::list<CMenuCallback*>::iterator it; for ( it = m_MenuCallbacks.begin() ; it != m_MenuCallbacks.end(); it++ ) { (*it)->MenuSelected( LOWORD(wParam) ); } switch( LOWORD(wParam) ) { case ID_CONTROLLER_XBOX: { m_pGameSettings->SetKeyConfig( EKeyConfig_Xbox ); } break; case ID_CONTROLLER_PS3: { m_pGameSettings->SetKeyConfig( EKeyConfig_PS3 ); } break; case ID_CONTROLLER_PS4: { m_pGameSettings->SetKeyConfig( EKeyConfig_TimSpecial ); } break; } } break; case WM_DROPFILES: { std::vector< std::string > Files; HDROP hDrop = (HDROP)wParam; INT nNumFiles = DragQueryFile( hDrop, 0xFFFFFFFF, 0, 0 ); for (INT i = 0; i < nNumFiles; i++) { CHAR Buf[MAX_PATH]; DragQueryFile( hDrop, i, Buf, MAX_PATH ); std::string strFile = Buf; UINT nPos = strFile.rfind( "Data\\" ); if ( nPos < strFile.size() ) { strFile = strFile.substr( nPos + 5, strFile.size() - 1 ); } Files.push_back( strFile ); } std::list<CDragDropCallback*>::iterator it; for ( it = m_DragDropCallbacks.begin() ; it != m_DragDropCallbacks.end(); it++ ) { (*it)->DragDropFiles( Files ); } } break; default: { //TRACE( "msg %d\n", uMsg ); } } return FALSE; }
//----------------------------------------------------------------------------- // Purpose: Render current view into specified rectangle // Input : *rect - is computed by CVideoMode_Common::GetClientViewRect() //----------------------------------------------------------------------------- void CViewRender::Render( vrect_t *rect ) { Assert(s_DbgSetupOrigin == m_View.origin); Assert(s_DbgSetupAngles == m_View.angles); VPROF_BUDGET( "CViewRender::Render", "CViewRender::Render" ); tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "%s", __FUNCTION__ ); vrect_t vr = *rect; // Stub out the material system if necessary. CMatStubHandler matStub; engine->EngineStats_BeginFrame(); // Assume normal vis m_bForceNoVis = false; C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); // Set for console commands, etc. render->SetMainView ( m_View.origin, m_View.angles ); for( StereoEye_t eEye = GetFirstEye(); eEye <= GetLastEye(); eEye = (StereoEye_t)(eEye+1) ) { CViewSetup &view = GetView( eEye ); #if 0 && defined( CSTRIKE_DLL ) const bool bPlayingBackReplay = g_pEngineClientReplay && g_pEngineClientReplay->IsPlayingReplayDemo(); if ( pPlayer && !bPlayingBackReplay ) { C_BasePlayer *pViewTarget = pPlayer; if ( pPlayer->IsObserver() && pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) { pViewTarget = dynamic_cast<C_BasePlayer*>( pPlayer->GetObserverTarget() ); } if ( pViewTarget ) { float targetFOV = (float)pViewTarget->m_iFOV; if ( targetFOV == 0 ) { // FOV of 0 means use the default FOV targetFOV = g_pGameRules->DefaultFOV(); } float deltaFOV = view.fov - m_flLastFOV; float FOVDirection = targetFOV - pViewTarget->m_iFOVStart; // Clamp FOV changes to stop FOV oscillation if ( ( deltaFOV < 0.0f && FOVDirection > 0.0f ) || ( deltaFOV > 0.0f && FOVDirection < 0.0f ) ) { view.fov = m_flLastFOV; } // Catch case where FOV overshoots its target FOV if ( ( view.fov < targetFOV && FOVDirection <= 0.0f ) || ( view.fov > targetFOV && FOVDirection >= 0.0f ) ) { view.fov = targetFOV; } m_flLastFOV = view.fov; } } #endif static ConVarRef sv_restrict_aspect_ratio_fov( "sv_restrict_aspect_ratio_fov" ); float aspectRatio = engine->GetScreenAspectRatio() * 0.75f; // / (4/3) float limitedAspectRatio = aspectRatio; if ( ( sv_restrict_aspect_ratio_fov.GetInt() > 0 && engine->IsWindowedMode() && gpGlobals->maxClients > 1 ) || sv_restrict_aspect_ratio_fov.GetInt() == 2 ) { limitedAspectRatio = MIN( aspectRatio, 1.85f * 0.75f ); // cap out the FOV advantage at a 1.85:1 ratio (about the widest any legit user should be) } view.fov = ScaleFOVByWidthRatio( view.fov, limitedAspectRatio ); view.fovViewmodel = ScaleFOVByWidthRatio( view.fovViewmodel, aspectRatio ); // Let the client mode hook stuff. g_pClientMode->PreRender(&view); g_pClientMode->AdjustEngineViewport( vr.x, vr.y, vr.width, vr.height ); ToolFramework_AdjustEngineViewport( vr.x, vr.y, vr.width, vr.height ); float flViewportScale = mat_viewportscale.GetFloat(); view.m_nUnscaledX = vr.x; view.m_nUnscaledY = vr.y; view.m_nUnscaledWidth = vr.width; view.m_nUnscaledHeight = vr.height; switch( eEye ) { case STEREO_EYE_MONO: { #if 0 // Good test mode for debugging viewports that are not full-size. view.width = vr.width * flViewportScale * 0.75f; view.height = vr.height * flViewportScale * 0.75f; view.x = vr.x + view.width * 0.10f; view.y = vr.y + view.height * 0.20f; #else view.x = vr.x * flViewportScale; view.y = vr.y * flViewportScale; view.width = vr.width * flViewportScale; view.height = vr.height * flViewportScale; #endif float engineAspectRatio = engine->GetScreenAspectRatio(); view.m_flAspectRatio = ( engineAspectRatio > 0.0f ) ? engineAspectRatio : ( (float)view.width / (float)view.height ); } break; case STEREO_EYE_RIGHT: case STEREO_EYE_LEFT: { g_pSourceVR->GetViewportBounds( (ISourceVirtualReality::VREye)(eEye - 1 ), &view.x, &view.y, &view.width, &view.height ); view.m_nUnscaledWidth = view.width; view.m_nUnscaledHeight = view.height; view.m_nUnscaledX = view.x; view.m_nUnscaledY = view.y; } break; default: Assert ( false ); break; } // if we still don't have an aspect ratio, compute it from the view size if( view.m_flAspectRatio <= 0.f ) view.m_flAspectRatio = (float)view.width / (float)view.height; int nClearFlags = VIEW_CLEAR_DEPTH | VIEW_CLEAR_STENCIL; if( gl_clear_randomcolor.GetBool() ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->ClearColor3ub( rand()%256, rand()%256, rand()%256 ); pRenderContext->ClearBuffers( true, false, false ); pRenderContext->Release(); } else if ( gl_clear.GetBool() ) { nClearFlags |= VIEW_CLEAR_COLOR; } else if ( IsPosix() ) { MaterialAdapterInfo_t adapterInfo; materials->GetDisplayAdapterInfo( materials->GetCurrentAdapter(), adapterInfo ); // On Posix, on ATI, we always clear color if we're antialiasing if ( adapterInfo.m_VendorID == 0x1002 ) { if ( g_pMaterialSystem->GetCurrentConfigForVideoCard().m_nAASamples > 0 ) { nClearFlags |= VIEW_CLEAR_COLOR; } } } // Determine if we should draw view model ( client mode override ) bool drawViewModel = g_pClientMode->ShouldDrawViewModel(); if ( cl_leveloverview.GetFloat() > 0 ) { SetUpOverView(); nClearFlags |= VIEW_CLEAR_COLOR; drawViewModel = false; } // Apply any player specific overrides if ( pPlayer ) { // Override view model if necessary if ( !pPlayer->m_Local.m_bDrawViewmodel ) { drawViewModel = false; } } int flags = 0; if( eEye == STEREO_EYE_MONO || eEye == STEREO_EYE_LEFT || ( g_ClientVirtualReality.ShouldRenderHUDInWorld() ) ) { flags = RENDERVIEW_DRAWHUD; } if ( drawViewModel ) { flags |= RENDERVIEW_DRAWVIEWMODEL; } if( eEye == STEREO_EYE_RIGHT ) { // we should use the monitor view from the left eye for both eyes flags |= RENDERVIEW_SUPPRESSMONITORRENDERING; } RenderView( view, nClearFlags, flags ); if ( UseVR() ) { bool bDoUndistort = ! engine->IsTakingScreenshot(); if ( bDoUndistort ) { g_ClientVirtualReality.PostProcessFrame( eEye ); } // logic here all cloned from code in viewrender.cpp around RenderHUDQuad: // figure out if we really want to draw the HUD based on freeze cam bool bInFreezeCam = ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM ); // draw the HUD after the view model so its "I'm closer" depth queues work right. if( !bInFreezeCam && g_ClientVirtualReality.ShouldRenderHUDInWorld() ) { // TODO - a bit of a shonky test - basically trying to catch the main menu, the briefing screen, the loadout screen, etc. bool bTranslucent = !g_pMatSystemSurface->IsCursorVisible(); g_ClientVirtualReality.OverlayHUDQuadWithUndistort( view, bDoUndistort, g_pClientMode->ShouldBlackoutAroundHUD(), bTranslucent ); } } } // TODO: should these be inside or outside the stereo eye stuff? g_pClientMode->PostRender(); engine->EngineStats_EndFrame(); #if !defined( _X360 ) // Stop stubbing the material system so we can see the budget panel matStub.End(); #endif // Draw all of the UI stuff "fullscreen" // (this is not health, ammo, etc. Nor is it pre-game briefing interface stuff - this is the stuff that appears when you hit Esc in-game) // In stereo mode this is rendered inside of RenderView so it goes into the render target if( !g_ClientVirtualReality.ShouldRenderHUDInWorld() ) { CViewSetup view2d; view2d.x = rect->x; view2d.y = rect->y; view2d.width = rect->width; view2d.height = rect->height; render->Push2DView( view2d, 0, NULL, GetFrustum() ); render->VGui_Paint( PAINT_UIPANELS | PAINT_CURSOR ); render->PopView( GetFrustum() ); } }
void csCanvas::OnLeftClick(double x, double y, int WXUNUSED(keys)) { csEditorToolPalette *palette = wxGetApp().GetDiagramPalette(); if (palette->GetSelection() == PALETTE_ARROW) { GetView()->SelectAll(false); wxClientDC dc(this); PrepareDC(dc); Redraw(dc); return; } if (palette->GetSelection() == PALETTE_TEXT_TOOL) { wxString newLabel; #if wxUSE_WX_RESOURCES // Ask for a label and create a new free-floating text region csLabelEditingDialog* dialog = new csLabelEditingDialog(GetParent()); dialog->SetShapeLabel( wxEmptyString ); dialog->SetTitle(_T("New text box")); if (dialog->ShowModal() == wxID_CANCEL) { dialog->Destroy(); return; } newLabel = dialog->GetShapeLabel(); dialog->Destroy(); #endif // wxUSE_WX_RESOURCES wxShape* shape = new csTextBoxShape; shape->AssignNewIds(); shape->SetEventHandler(new csEvtHandler(shape, shape, newLabel)); wxComboBox* comboBox = wxGetApp().GetPointSizeComboBox(); wxString str(comboBox->GetValue()); long pointSize; str.ToLong( &pointSize ); wxFont* newFont = wxTheFontList->FindOrCreateFont(pointSize, shape->GetFont()->GetFamily(), shape->GetFont()->GetStyle(), shape->GetFont()->GetWeight(), shape->GetFont()->GetUnderlined(), shape->GetFont()->GetFaceName()); shape->SetFont(newFont); shape->SetX(x); shape->SetY(y); csDiagramCommand* cmd = new csDiagramCommand(_T("Text box"), (csDiagramDocument *)GetView()->GetDocument(), new csCommandState(ID_CS_ADD_SHAPE, shape, NULL)); GetView()->GetDocument()->GetCommandProcessor()->Submit(cmd); palette->SetSelection(PALETTE_ARROW); return; } csSymbol* symbol = wxGetApp().GetSymbolDatabase()->FindSymbol(palette->GetSelection()); if (symbol) { wxShape* theShape = symbol->GetShape()->CreateNewCopy(); wxComboBox* comboBox = wxGetApp().GetPointSizeComboBox(); wxString str(comboBox->GetValue()); long pointSize; str.ToLong( &pointSize ); wxFont* newFont = wxTheFontList->FindOrCreateFont(pointSize, symbol->GetShape()->GetFont()->GetFamily(), symbol->GetShape()->GetFont()->GetStyle(), symbol->GetShape()->GetFont()->GetWeight(), symbol->GetShape()->GetFont()->GetUnderlined(), symbol->GetShape()->GetFont()->GetFaceName()); theShape->SetFont(newFont); theShape->AssignNewIds(); theShape->SetX(x); theShape->SetY(y); csDiagramCommand* cmd = new csDiagramCommand(symbol->GetName(), (csDiagramDocument *)GetView()->GetDocument(), new csCommandState(ID_CS_ADD_SHAPE, theShape, NULL)); GetView()->GetDocument()->GetCommandProcessor()->Submit(cmd); palette->SetSelection(PALETTE_ARROW); } }
void CViewRender::Render( vrect_t *rect ) { VPROF_BUDGET( "CViewRender::Render", "CViewRender::Render" ); m_bAllowViewAccess = true; CUtlVector< vgui::Panel * > roots; VGui_GetPanelList( roots ); // Stub out the material system if necessary. CMatStubHandler matStub; engine->EngineStats_BeginFrame(); // Assume normal vis m_bForceNoVis = false; float flViewportScale = mat_viewportscale.GetFloat(); vrect_t engineRect = *rect; // The tool framework wants to adjust the entire 3d viewport, not the per-split screen one from below ToolFramework_AdjustEngineViewport( engineRect.x, engineRect.y, engineRect.width, engineRect.height ); IterateRemoteSplitScreenViewSlots_Push( true ); FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( hh ); CViewSetup &view = GetView( hh ); float engineAspectRatio = engine->GetScreenAspectRatio( view.width, view.height ); Assert( s_DbgSetupOrigin[ hh ] == view.origin ); Assert( s_DbgSetupAngles[ hh ] == view.angles ); // Using this API gives us a chance to "inset" the 3d views as needed for splitscreen int insetX, insetY; VGui_GetEngineRenderBounds( hh, view.x, view.y, view.width, view.height, insetX, insetY ); float aspectRatio = engineAspectRatio * 0.75f; // / (4/3) view.fov = ScaleFOVByWidthRatio( view.fov, aspectRatio ); view.fovViewmodel = ScaleFOVByWidthRatio( view.fovViewmodel, aspectRatio ); // Let the client mode hook stuff. GetClientMode()->PreRender( &view ); GetClientMode()->AdjustEngineViewport( view.x, view.y, view.width, view.height ); view.width *= flViewportScale; view.height *= flViewportScale; if ( IsX360() ) { // view must be compliant to resolve restrictions view.width = AlignValue( view.width, GPU_RESOLVE_ALIGNMENT ); view.height = AlignValue( view.height, GPU_RESOLVE_ALIGNMENT ); } view.m_flAspectRatio = ( engineAspectRatio > 0.0f ) ? engineAspectRatio : ( (float)view.width / (float)view.height ); int nClearFlags = VIEW_CLEAR_DEPTH | VIEW_CLEAR_STENCIL; if ( gl_clear_randomcolor.GetBool() ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->ClearColor3ub( rand()%256, rand()%256, rand()%256 ); pRenderContext->ClearBuffers( true, false, false ); pRenderContext->Release(); } else if ( gl_clear.GetBool() ) { nClearFlags |= VIEW_CLEAR_COLOR; } // Determine if we should draw view model ( client mode override ) bool drawViewModel = GetClientMode()->ShouldDrawViewModel(); // Apply any player specific overrides C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer ) { // Override view model if necessary if ( !pPlayer->m_Local.m_bDrawViewmodel ) { drawViewModel = false; } } if ( cl_leveloverview.GetFloat() > 0 ) { SetUpOverView(); nClearFlags |= VIEW_CLEAR_COLOR; drawViewModel = false; } render->SetMainView( view.origin, view.angles ); int flags = (pPlayer == NULL) ? 0 : RENDERVIEW_DRAWHUD; if ( drawViewModel ) { flags |= RENDERVIEW_DRAWVIEWMODEL; } // This is the hook for per-split screen player views C_BaseEntity::PreRenderEntities( hh ); if ( ( ss_debug_draw_player.GetInt() < 0 ) || ( hh == ss_debug_draw_player.GetInt() ) ) { CViewSetup hudViewSetup; VGui_GetHudBounds( hh, hudViewSetup.x, hudViewSetup.y, hudViewSetup.width, hudViewSetup.height ); RenderView( view, hudViewSetup, nClearFlags, flags ); } GetClientMode()->PostRender(); } IterateRemoteSplitScreenViewSlots_Pop(); engine->EngineStats_EndFrame(); #if !defined( _X360 ) // Stop stubbing the material system so we can see the budget panel matStub.End(); #endif // Render the new-style embedded UI // TODO: when embedded UI will be used for HUD, we will need it to maintain // a separate screen for HUD and a separate screen stack for pause menu & main menu. // for now only render embedded UI in pause menu & main menu #if defined( GAMEUI_UISYSTEM2_ENABLED ) && 0 BaseModUI::CBaseModPanel *pBaseModPanel = BaseModUI::CBaseModPanel::GetSingletonPtr(); // render the new-style embedded UI only if base mod panel is not visible (game-hud) // otherwise base mod panel will render the embedded UI on top of video/productscreen if ( !pBaseModPanel || !pBaseModPanel->IsVisible() ) { Rect_t uiViewport; uiViewport.x = rect->x; uiViewport.y = rect->y; uiViewport.width = rect->width; uiViewport.height = rect->height; g_pGameUIGameSystem->Render( uiViewport, gpGlobals->curtime ); } #endif // Draw all of the UI stuff "fullscreen" if ( true ) // For PIXEVENT { #if PIX_ENABLE { CMatRenderContextPtr pRenderContext( materials ); PIXEVENT( pRenderContext, "VGui UI" ); } #endif CViewSetup view2d; view2d.x = rect->x; view2d.y = rect->y; view2d.width = rect->width; view2d.height = rect->height; render->Push2DView( view2d, 0, NULL, GetFrustum() ); render->VGui_Paint( PAINT_UIPANELS ); { // The engine here is trying to access CurrentView() etc. which is bogus ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 ); render->PopView( GetFrustum() ); } } m_bAllowViewAccess = false; }
void CViewRender::WriteSaveGameScreenshotOfSize( const char *pFilename, int width, int height ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PushMatrix(); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PushMatrix(); g_bRenderingScreenshot = true; m_bAllowViewAccess = true; // Push back buffer on the stack with small viewport pRenderContext->PushRenderTargetAndViewport( NULL, 0, 0, width, height ); // render out to the backbuffer CViewSetup viewSetup = GetView(); viewSetup.x = 0; viewSetup.y = 0; viewSetup.width = width; viewSetup.height = height; viewSetup.fov = ScaleFOVByWidthRatio( GetView().fov, ( (float)width / (float)height ) / ( 4.0f / 3.0f ) ); viewSetup.m_bRenderToSubrectOfLargerScreen = true; // draw out the scene // Don't draw the HUD or the viewmodel RenderView( viewSetup, viewSetup, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, 0 ); // get the data from the backbuffer and save to disk // bitmap bits unsigned char *pImage = ( unsigned char * )malloc( width * 3 * height ); // Get Bits from the material system pRenderContext->ReadPixels( 0, 0, width, height, pImage, IMAGE_FORMAT_RGB888 ); // allocate a buffer to write the tga into int iMaxTGASize = 1024 + (width * height * 4); void *pTGA = malloc( iMaxTGASize ); CUtlBuffer buffer( pTGA, iMaxTGASize ); if( !TGAWriter::WriteToBuffer( pImage, buffer, width, height, IMAGE_FORMAT_RGB888, IMAGE_FORMAT_RGB888 ) ) { Error( "Couldn't write bitmap data snapshot.\n" ); } free( pImage ); // async write to disk (this will take ownership of the memory) char szPathedFileName[_MAX_PATH]; Q_snprintf( szPathedFileName, sizeof(szPathedFileName), "//MOD/%s", pFilename ); filesystem->AsyncWrite( szPathedFileName, buffer.Base(), buffer.TellPut(), true ); // restore our previous state pRenderContext->PopRenderTargetAndViewport(); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PopMatrix(); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PopMatrix(); g_bRenderingScreenshot = false; m_bAllowViewAccess = false; }
//----------------------------------------------------------------------------- // Sets up the view parameters //----------------------------------------------------------------------------- void CViewRender::SetUpView() { ASSERT_LOCAL_PLAYER_RESOLVABLE(); int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT(); m_bAllowViewAccess = true; VPROF("CViewRender::SetUpView"); // Initialize view structure with default values float farZ = GetZFar(); CViewSetup &view = GetView(); view.zFar = farZ; view.zFarViewmodel = farZ; // UNDONE: Make this farther out? // closest point of approach seems to be view center to top of crouched box view.zNear = GetZNear(); view.zNearViewmodel = 1; view.fov = default_fov.GetFloat(); view.m_bOrtho = false; // Enable spatial partition access to edicts partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, false ); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); bool bNoViewEnt = false; if( pPlayer == NULL ) { pPlayer = GetSplitScreenViewPlayer( nSlot ); bNoViewEnt = true; } if ( g_bEngineIsHLTV ) { HLTVCamera()->CalcView( view.origin, view.angles, view.fov ); } #if defined( REPLAY_ENABLED ) else if ( engine->IsReplay() ) { ReplayCamera()->CalcView( view.origin, view.angles, view.fov ); } #endif else { // FIXME: Are there multiple views? If so, then what? // FIXME: What happens when there's no player? if (pPlayer) { pPlayer->CalcView( view.origin, view.angles, view.zNear, view.zFar, view.fov ); // If we are looking through another entities eyes, then override the angles/origin for GetView() int viewentity = render->GetViewEntity(); if ( !bNoViewEnt && !g_nKillCamMode && (pPlayer->entindex() != viewentity) ) { C_BaseEntity *ve = cl_entitylist->GetEnt( viewentity ); if ( ve ) { VectorCopy( ve->GetAbsOrigin(), view.origin ); VectorCopy( ve->GetAbsAngles(), view.angles ); } } pPlayer->CalcViewModelView( view.origin, view.angles ); // Is this the proper place for this code? if ( cl_camera_follow_bone_index.GetInt() >= -1 && input->CAM_IsThirdPerson() ) { VectorCopy( g_cameraFollowPos, view.origin ); } } // Even if the engine is paused need to override the view // for keeping the camera control during pause. GetClientMode()->OverrideView( &GetView() ); } // give the toolsystem a chance to override the view ToolFramework_SetupEngineView( view.origin, view.angles, view.fov ); if ( engine->IsPlayingDemo() ) { if ( cl_demoviewoverride.GetFloat() > 0.0f ) { // Retreive view angles from engine ( could have been set in IN_AdjustAngles above ) CalcDemoViewOverride( view.origin, view.angles ); } else { s_DemoView = view.origin; s_DemoAngle = view.angles; } } // Disable spatial partition access partition->SuppressLists( PARTITION_ALL_CLIENT_EDICTS, true ); //Find the offset our current FOV is from the default value float flFOVOffset = default_fov.GetFloat() - view.fov; //Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end view.fovViewmodel = GetClientMode()->GetViewModelFOV() - flFOVOffset; // Compute the world->main camera transform ComputeCameraVariables( view.origin, view.angles, &g_vecVForward[ nSlot ], &g_vecVRight[ nSlot ], &g_vecVUp[ nSlot ], &g_matCamInverse[ nSlot ] ); // set up the hearing origin... AudioState_t audioState; audioState.m_Origin = view.origin; audioState.m_Angles = view.angles; audioState.m_bIsUnderwater = pPlayer && pPlayer->AudioStateIsUnderwater( view.origin ); ToolFramework_SetupAudioState( audioState ); view.origin = audioState.m_Origin; view.angles = audioState.m_Angles; GetClientMode()->OverrideAudioState( &audioState ); engine->SetAudioState( audioState ); g_vecPrevRenderOrigin[ nSlot ] = g_vecRenderOrigin[ nSlot ]; g_vecPrevRenderAngles[ nSlot ] = g_vecRenderAngles[ nSlot ]; g_vecRenderOrigin[ nSlot ] = view.origin; g_vecRenderAngles[ nSlot ] = view.angles; #ifdef DBGFLAG_ASSERT s_DbgSetupOrigin[ nSlot ] = view.origin; s_DbgSetupAngles[ nSlot ] = view.angles; #endif m_bAllowViewAccess = false; }
void Ctrl::ScrollView(const Rect& _r, int dx, int dy) { GuiLock __; if(IsFullRefresh() || !IsVisible()) return; Size vsz = GetSize(); dx = sgn(dx) * min(abs(dx), vsz.cx); dy = sgn(dy) * min(abs(dy), vsz.cy); Rect r = _r & vsz; Ctrl *w; for(w = this; w->parent; w = w->parent) if(w->InFrame()) { Refresh(); return; } if(!w || !w->top) return; Rect view = InFrame() ? GetView() : GetClippedView(); Rect sr = (r + view.TopLeft()) & view; sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft(); if(w->AddScroll(sr, dx, dy)) Refresh(); else { LTIMING("ScrollCtrls1"); Top *top = GetTopCtrl()->top; for(Ctrl *q = GetFirstChild(); q; q = q->GetNext()) if(q->InView()) { Rect cr = q->GetRect(); if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs Rect to = cr; GetTopRect(to, false); if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs Rect from = cr.Offseted(-dx, -dy); GetTopRect(from, false); MoveCtrl *m = FindMoveCtrlPtr(top->move, q); if(m && m->from == from && m->to == to) { LLOG("ScrollView Matched " << from << " -> " << to); m->ctrl = NULL; goto done; } } if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs Rect from = to; to = cr.Offseted(dx, dy); GetTopRect(to, false); MoveCtrl& m = top->scroll_move.Add(q); m.from = from; m.to = to; m.ctrl = q; LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to); goto done; } cr &= r; if(!cr.IsEmpty()) { Refresh(cr); Refresh(cr + Point(dx, dy)); } done:; } } } }
void CViewRender::WriteSaveGameScreenshotOfSize( const char *pFilename, int width, int height, bool bCreatePowerOf2Padded/*=false*/, bool bWriteVTF/*=false*/ ) { #ifndef _X360 CMatRenderContextPtr pRenderContext( materials ); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PushMatrix(); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PushMatrix(); g_bRenderingScreenshot = true; // Push back buffer on the stack with small viewport pRenderContext->PushRenderTargetAndViewport( NULL, 0, 0, width, height ); // render out to the backbuffer CViewSetup viewSetup = GetView ( STEREO_EYE_MONO ); viewSetup.x = 0; viewSetup.y = 0; viewSetup.width = width; viewSetup.height = height; viewSetup.fov = ScaleFOVByWidthRatio( viewSetup.fov, ( (float)width / (float)height ) / ( 4.0f / 3.0f ) ); viewSetup.m_bRenderToSubrectOfLargerScreen = true; // draw out the scene // Don't draw the HUD or the viewmodel RenderView( viewSetup, VIEW_CLEAR_DEPTH | VIEW_CLEAR_COLOR, 0 ); // get the data from the backbuffer and save to disk // bitmap bits unsigned char *pImage = ( unsigned char * )malloc( width * height * 3 ); // Get Bits from the material system pRenderContext->ReadPixels( 0, 0, width, height, pImage, IMAGE_FORMAT_RGB888 ); // Some stuff to be setup dependent on padded vs. not padded int nSrcWidth, nSrcHeight; unsigned char *pSrcImage; // Create a padded version if necessary unsigned char *pPaddedImage = NULL; if ( bCreatePowerOf2Padded ) { // Setup dimensions as needed int nPaddedWidth = SmallestPowerOfTwoGreaterOrEqual( width ); int nPaddedHeight = SmallestPowerOfTwoGreaterOrEqual( height ); // Allocate int nPaddedImageSize = nPaddedWidth * nPaddedHeight * 3; pPaddedImage = ( unsigned char * )malloc( nPaddedImageSize ); // Zero out the entire thing V_memset( pPaddedImage, 255, nPaddedImageSize ); // Copy over each row individually for ( int nRow = 0; nRow < height; ++nRow ) { unsigned char *pDst = pPaddedImage + 3 * ( nRow * nPaddedWidth ); const unsigned char *pSrc = pImage + 3 * ( nRow * width ); V_memcpy( pDst, pSrc, 3 * width ); } // Setup source data nSrcWidth = nPaddedWidth; nSrcHeight = nPaddedHeight; pSrcImage = pPaddedImage; } else { // Use non-padded info nSrcWidth = width; nSrcHeight = height; pSrcImage = pImage; } // allocate a buffer to write the tga into CUtlBuffer buffer; bool bWriteResult; if ( bWriteVTF ) { // Create and initialize a VTF texture IVTFTexture *pVTFTexture = CreateVTFTexture(); const int nFlags = TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_NOLOD | TEXTUREFLAGS_SRGB; if ( pVTFTexture->Init( nSrcWidth, nSrcHeight, 1, IMAGE_FORMAT_RGB888, nFlags, 1, 1 ) ) { // Copy the image data over to the VTF unsigned char *pDestBits = pVTFTexture->ImageData(); int nDstSize = nSrcWidth * nSrcHeight * 3; V_memcpy( pDestBits, pSrcImage, nDstSize ); // Allocate output buffer int iMaxVTFSize = 1024 + ( nSrcWidth * nSrcHeight * 3 ); void *pVTF = malloc( iMaxVTFSize ); buffer.SetExternalBuffer( pVTF, iMaxVTFSize, 0 ); // Serialize to the buffer bWriteResult = pVTFTexture->Serialize( buffer ); // Free the VTF texture DestroyVTFTexture( pVTFTexture ); } else { bWriteResult = false; } } else { // Write TGA format to buffer int iMaxTGASize = 1024 + ( nSrcWidth * nSrcHeight * 4 ); void *pTGA = malloc( iMaxTGASize ); buffer.SetExternalBuffer( pTGA, iMaxTGASize, 0 ); bWriteResult = TGAWriter::WriteToBuffer( pSrcImage, buffer, nSrcWidth, nSrcHeight, IMAGE_FORMAT_RGB888, IMAGE_FORMAT_RGB888 ); } if ( !bWriteResult ) { Error( "Couldn't write bitmap data snapshot.\n" ); } free( pImage ); free( pPaddedImage ); // async write to disk (this will take ownership of the memory) char szPathedFileName[_MAX_PATH]; Q_snprintf( szPathedFileName, sizeof(szPathedFileName), "//MOD/%s", pFilename ); filesystem->AsyncWrite( szPathedFileName, buffer.Base(), buffer.TellPut(), true ); // restore our previous state pRenderContext->PopRenderTargetAndViewport(); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PopMatrix(); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PopMatrix(); g_bRenderingScreenshot = false; #endif }
void Ctrl::Refresh(const Rect& area) { GuiLock __; if(fullrefresh || !IsVisible() || !IsOpen()) return; LLOG("Refresh " << Name() << ' ' << area); RefreshFrame((area + GetView().TopLeft()) & GetView().Inflated(OverPaint())); }
void CMainFrame::OnFileNew() { GetDoc().GetPoints().clear(); m_PathName = _T(""); GetView().Invalidate(); }
bool BigGridTable::writeEvent( VscpRXObj *pRecord, bool bUpdate ) { // Validate pointer //if ( NULL == pRecord ) return false; // File should be open //if ( !m_temFile.IsOpened() ) return false; // Go to end //m_temFile.SeekEnd( 0 ); // Write record //if ( sizeof(VscpRecord) != m_temFile.Write( &pRecord->m_event, sizeof(VscpRecord) ) ) { // return false; //} m_rxList.Append( pRecord ); if ( bUpdate ) { // Add one row to the grid AppendRows( 1 ); //wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1); //GetView()->ProcessTableMessage(msg); //if ( GetView() ) //{ // wxGridTableMessage msg( this, // wxGRIDTABLE_NOTIFY_ROWS_APPENDED, // 1 ); // GetView()->ProcessTableMessage( msg ); //} // If selected mow the added row into seight if ( g_Config.m_bAutoscollRcv ) { GetView()->MakeCellVisible( m_rxList.GetCount()-1, 0 ); } /* if ( VSCP_EVENT_DIRECTION_RX == pRecord->m_nDir ) { for ( int i=0; i<10; i++ ) { GetView()->SetCellTextColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameRxTextColour ); GetView()->SetCellBackgroundColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameRxBgColour ); } } else { for ( int i=0; i<10; i++ ) { GetView()->SetCellTextColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameTxTextColour ); GetView()->SetCellBackgroundColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameTxBgColour ); } } // RX/TX GetView()->SetCellAlignment( m_rxList.GetCount()-1, 0, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Class GetView()->SetCellAlignment( m_rxList.GetCount()-1, 3, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Type GetView()->SetCellAlignment( m_rxList.GetCount()-1, 4, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Head GetView()->SetCellAlignment( m_rxList.GetCount()-1, 5, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Count GetView()->SetCellAlignment( m_rxList.GetCount()-1, 6, wxALIGN_CENTRE, wxALIGN_CENTRE ); */ GetView()->ForceRefresh(); } return true; }
/// <summary>Gets the text selection.</summary> /// <returns></returns> CHARRANGE ScriptDocument::GetSelection() const { return GetView()->GetSelection(); }
//----------------------------------------------------------------------------- // Purpose: // Output : const CViewSetup //----------------------------------------------------------------------------- const CViewSetup *CViewRender::GetPlayerViewSetup( void ) const { const CViewSetup &view = GetView ( STEREO_EYE_MONO ); return &view; }
CTreeViewFiles* CWorkspaceWnd::GetTreeViewFiles() { return (CTreeViewFiles*)GetView(RUNTIME_CLASS(CTreeViewFiles)); }
nsresult nsBox::SyncLayout(nsBoxLayoutState& aState) { /* PRBool collapsed = PR_FALSE; IsCollapsed(aState, collapsed); if (collapsed) { CollapseChild(aState, this, PR_TRUE); return NS_OK; } */ if (GetStateBits() & NS_FRAME_IS_DIRTY) Redraw(aState); RemoveStateBits(NS_FRAME_HAS_DIRTY_CHILDREN | NS_FRAME_IS_DIRTY | NS_FRAME_FIRST_REFLOW | NS_FRAME_IN_REFLOW); nsPresContext* presContext = aState.PresContext(); PRUint32 flags = 0; GetLayoutFlags(flags); PRUint32 stateFlags = aState.LayoutFlags(); flags |= stateFlags; nsRect rect(nsPoint(0, 0), GetSize()); if (ComputesOwnOverflowArea()) { rect = GetOverflowRect(); } else { if (!DoesClipChildren() && !IsCollapsed(aState)) { // See if our child frames caused us to overflow after being laid // out. If so, store the overflow area. This normally can't happen // in XUL, but it can happen with the CSS 'outline' property and // possibly with other exotic stuff (e.g. relatively positioned // frames in HTML inside XUL). nsIFrame* box = GetChildBox(); while (box) { nsRect bounds = box->GetOverflowRect() + box->GetPosition(); rect.UnionRect(rect, bounds); box = box->GetNextBox(); } } FinishAndStoreOverflow(&rect, GetSize()); } nsIView* view = GetView(); if (view) { // Make sure the frame's view is properly sized and positioned and has // things like opacity correct nsHTMLContainerFrame::SyncFrameViewAfterReflow( presContext, this, view, &rect, flags); } return NS_OK; }
void CWorkspaceWnd::Enable(BOOL bEnable) { GetView(0)->EnableWindow(bEnable); }
/*---------------------------------------------------------------------------*/ void wxGridColumnsTable::SetValue(int row, int col, const wxString& value) { if (col == 0) { if (CheckName(value, row)) m_Columns[row]->SetName(value.Upper()); } else if (col == 1) { if (value == ("INTEGER")) { long l_Long; wxString val; m_Columns[row]->SetType(cttInteger); val = m_Columns[row]->GetDefault(); if ((val != wxEmptyString) && !val.ToLong(&l_Long)) SetValue(row, 4, wxEmptyString); } else if (value == ("INTEGER AUTOINCREMENT")) { if (CheckAutoInc()) return; m_Columns[row]->SetType(cttIntegerAutoinc); SetValueAsBool(row, 3, true); SetValue(row, 4, wxEmptyString); // Oblige la grille à prendre en compte le changement GetView()->SetCellValue(row, 3, ("1")); } else if (value == ("REAL")) { double l_Double; wxString val; m_Columns[row]->SetType(cttReal); val = m_Columns[row]->GetDefault(); if ((val != wxEmptyString) && !val.ToDouble(&l_Double)) SetValue(row, 4, wxEmptyString); } else if (value == ("TEXT")) m_Columns[row]->SetType(cttText); else if (value == ("BLOB")) m_Columns[row]->SetType(cttBlob); } else if (col == 4) { if (value != wxEmptyString) { long l_Long; double l_Double; switch (m_Columns[row]->GetType()) { case cttInteger : if (value.ToLong(&l_Long)) m_Columns[row]->SetDefault(wxString::Format(("%li"), l_Long)); break; case cttIntegerAutoinc : return; case cttReal : if (value.ToDouble(&l_Double)) m_Columns[row]->SetDefault(wxString::Format(("%f"), l_Double)); break; case cttText : case cttBlob : if ((value.Upper() == ("CURRENT_TIME"))|| (value.Upper() == ("CURRENT_DATE"))|| (value.Upper() == ("CURRENT_TIMESTAMP"))) m_Columns[row]->SetDefault(value.Upper()); else m_Columns[row]->SetDefault(value); } } else m_Columns[row]->SetDefault(wxEmptyString); } }
void CEnListCtrl::OnPaint() { // if no items or in report mode draw to back buffer then blt if (GetItemCount() && GetView() != LVS_REPORT) Default(); else { CPaintDC cleanup(this); CHeaderCtrl* pHeader = GetHeader(); CDC& paintdc = *GetDC(); CDC dc; dc.CreateCompatibleDC(&paintdc); CRect rClient; GetClientRect( &rClient ); CBitmap bitmap; bitmap.CreateCompatibleBitmap(&paintdc, rClient.right, rClient.bottom); CBitmap *pOldBitmap = dc.SelectObject(& bitmap); if (pHeader && m_nCurView == LVS_REPORT && !(GetStyle() & LVS_NOCOLUMNHEADER)) { CRect rHeader; pHeader->GetWindowRect(&rHeader); ScreenToClient(rHeader); dc.ExcludeClipRect(rHeader); rClient.top = rHeader.bottom; } // fill with back color COLORREF crBack = GetItemBackColor(0, FALSE, FALSE, FALSE); dc.FillSolidRect(rClient, crBack); // default drawing CListCtrl::DefWindowProc(WM_PAINT, (WPARAM)dc.m_hDC, 0); // do empty text if nec if (GetItemCount() == 0) { CString sText = GetNoItemsText(); // virtual call if (!sText.IsEmpty()) { sText.TrimRight(); sText.TrimLeft(); if (sText[0] != '(') sText = "(" + sText; if (sText[sText.GetLength() - 1] != ')') sText += ")"; dc.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); dc.SetBkColor(crBack); dc.SelectStockObject( ANSI_VAR_FONT ); rClient.top += 10; dc.DrawText( sText, rClient, DT_CENTER | DT_WORDBREAK | DT_NOPREFIX/* | DT_NOCLIP */); rClient.top -= 10; // reset } } paintdc.BitBlt(0, rClient.top, rClient.right, rClient.bottom, &dc, 0, rClient.top, SRCCOPY); dc.SelectObject(pOldBitmap); ReleaseDC(&paintdc); } // Do not call CListView::OnPaint() for painting messages }