void CChildFrame::OnViewSelection() { // get document CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); m_bSelectionVisible = !m_bSelectionVisible; pDoc->UpdateAllViews( NULL); }
void CChildFrame::OnEnableVisibilityTweaks() { // get document CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); m_bDisableVisibilityTweaks = !m_bDisableVisibilityTweaks; pDoc->UpdateAllViews( NULL); }
void CChildFrame::OnRestorePosition03() { m_mvViewer.mv_plViewer = wo_plStored03; m_mvViewer.mv_fTargetDistance = wo_fStored03; CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); pDoc->UpdateAllViews( NULL); }
void CTriangularisationCombo::OnSelchange() { // get document ptr CWorldEditorDoc* pDoc = theApp.GetActiveDocument(); if( pDoc == NULL) return; int iSelected = GetCurSel(); theApp.m_vfpCurrent.vfp_ttTriangularisationType = (enum TriangularisationType) iSelected; pDoc->CreatePrimitive(); pDoc->UpdateAllViews(NULL); }
void CChildFrame::OnToggleVisibilityTweaks() { // get document CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); m_bShowVisibilityTweaks = !m_bShowVisibilityTweaks; // auto turn off disabling of visibility tweaks m_bDisableVisibilityTweaks = FALSE; pDoc->UpdateAllViews( NULL); }
void CChildFrame::TestGame( BOOL bFullScreen) { // turn off info window CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); pMainFrame->HideInfoWindow(); CWorldEditorView *pPerspectiveView = GetPerspectiveView(); ASSERT( pPerspectiveView != NULL); SetActiveView( pPerspectiveView, FALSE); CWorldEditorDoc* pDoc = pPerspectiveView->GetDocument(); CTFileName fnmWorldToPlay; CTFileName fnmTempWorld = CTString("Temp\\TestGame.wld"); // if the world was never saved or if it is modified if( (!pDoc->m_bWasEverSaved && wed_bSaveTestGameFirstTime) || pDoc->IsModified()) { // save world under temporary name ASSERT_VALID(pDoc); try { pDoc->m_woWorld.Save_t(fnmTempWorld); fnmWorldToPlay = fnmTempWorld; } catch( char *strError) { AfxMessageBox( CString(strError)); pPerspectiveView->EnableToolTips(TRUE); return; } // if the world is not modified (it is saved on disk) } else { // use the saved world fnmWorldToPlay = CTString(CStringA(pDoc->GetPathName())); try { fnmWorldToPlay.RemoveApplicationPath_t(); } catch( char *strError) { AfxMessageBox( CString(strError)); pPerspectiveView->EnableToolTips(TRUE); return; } } // set rendering preferences _wrpWorldRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_wrpWorldRenderPrefs; _mrpModelRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_mrpModelRenderPrefs; _wrpWorldRenderPrefs.SetShadowsType( pPerspectiveView->GetChildFrame()->m_stShadowType); _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject); _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject); _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture1, 0); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture2, 1); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture3, 2); _wrpWorldRenderPrefs.DisableVisTweaks(FALSE); _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject); _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject); _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject); // prepare test game view/draw ports CViewPort *pvp = pPerspectiveView->m_pvpViewPort; CDrawPort *pdp = pPerspectiveView->m_pdpDrawPort; pdp->SetOverlappedRendering(FALSE); // we are not rendering scene over already rendered scene (used for CSG layer) // if full screen mode is required HWND hWndFullScreen=NULL; HINSTANCE hInstanceFullScreen; WNDCLASSEX wcFullScreen; char achWindowTitle[256]; // current window title if( bFullScreen) { // get full screen display mode info const PIX pixSizeI = theApp.m_dmFullScreen.dm_pixSizeI; const PIX pixSizeJ = theApp.m_dmFullScreen.dm_pixSizeJ; const DisplayDepth dd = theApp.m_dmFullScreen.dm_ddDepth; const GfxAPIType gat = theApp.m_gatFullScreen; // set OpenGL fullscreen (before window) if( gat==GAT_OGL) { const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd); if( !bRes) { WarningMessage( "Unable to setup full screen display."); return; } } // register the window class hInstanceFullScreen = AfxGetInstanceHandle(); ASSERT( hInstanceFullScreen!=NULL); wcFullScreen.cbSize = sizeof(wcFullScreen); wcFullScreen.style = CS_HREDRAW | CS_VREDRAW; wcFullScreen.lpfnWndProc = ::DefWindowProc; wcFullScreen.cbClsExtra = 0; wcFullScreen.cbWndExtra = 0; wcFullScreen.hInstance = hInstanceFullScreen; wcFullScreen.hIcon = LoadIcon( hInstanceFullScreen, (LPCTSTR)IDR_MAINFRAME ); wcFullScreen.hCursor = NULL; wcFullScreen.hbrBackground = NULL; wcFullScreen.lpszMenuName = CString(APPLICATION_NAME); wcFullScreen.lpszClassName = CString(APPLICATION_NAME); wcFullScreen.hIconSm = NULL; RegisterClassEx(&wcFullScreen); // create a window, invisible initially hWndFullScreen = CreateWindowExA( WS_EX_TOPMOST, APPLICATION_NAME, "Serious Editor - Full Screen Test Game", // title WS_POPUP, 0,0, pixSizeI, pixSizeJ, // window size NULL, NULL, hInstanceFullScreen, NULL); // didn't make it? ASSERT( hWndFullScreen!=NULL); if( hWndFullScreen==NULL) { if( gat==GAT_OGL) _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); WarningMessage( "Unable to setup window for full screen display."); return; } // set windows for engine CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); SE_UpdateWindowHandle( hWndFullScreen); // set window title and show it sprintf( achWindowTitle, "Serious Editor - Test Game (FullScreen %dx%d)", pixSizeI, pixSizeJ); ::SetWindowTextA( hWndFullScreen, achWindowTitle); ::ShowWindow( hWndFullScreen, SW_SHOWNORMAL); // set Direct3D full screen (after window) #ifdef SE1_D3D if( gat==GAT_D3D) { const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd); if( !bRes) { WarningMessage( "Unable to setup full screen display."); ::DestroyWindow( hWndFullScreen); SE_UpdateWindowHandle( pMainFrame->m_hWnd); return; } } #endif // SE1_D3D // create canvas _pGfx->CreateWindowCanvas( hWndFullScreen, &pvp, &pdp); // initial screen fill and swap, just to get context running BOOL bSuccess = FALSE; if( pdp!=NULL && pdp->Lock()) { pdp->Fill(C_dGREEN|CT_OPAQUE); pdp->Unlock(); pvp->SwapBuffers(); bSuccess = TRUE; } // must succeed! ASSERT( bSuccess); if( !bSuccess) { _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); WarningMessage( "Unable to setup canvas for full screen display."); return; } } // enable sound snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16); _pSound->SetFormat( (enum CSoundLibrary::SoundFormat)snd_iFormat, TRUE); // run quick test game extern BOOL _bInOnDraw; _bInOnDraw = TRUE; _pGameGUI->QuickTest( fnmWorldToPlay, pdp, pvp); _bInOnDraw = FALSE; // disable sound _pSound->SetFormat( CSoundLibrary::SF_NONE); // restore default display mode and close test full screen window if( hWndFullScreen!=NULL) { _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); ::DestroyWindow( hWndFullScreen); SE_UpdateWindowHandle( pMainFrame->m_hWnd); } // redraw all views pDoc->UpdateAllViews( NULL); pPerspectiveView->EnableToolTips( TRUE); }
void CDlgPgPosition::DoDataExchange(CDataExchange* pDX) { if( theApp.m_bDisableDataExchange) return; CPropertyPage::DoDataExchange(pDX); SetModified( TRUE); // obtain document CWorldEditorDoc* pDoc = theApp.GetDocument(); // if document doesn't exist, return if( pDoc == NULL) return; // get active view CWorldEditorView *pWorldEditorView = theApp.GetActiveView(); // if dialog is recieving data if( pDX->m_bSaveAndValidate == FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, pick up coordinates for editting from second layer m_fHeading = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(1)); m_fPitch = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(2)); m_fBanking = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(3)); m_fX = pDoc->m_plSecondLayer.pl_PositionVector(1); m_fY = pDoc->m_plSecondLayer.pl_PositionVector(2); m_fZ = pDoc->m_plSecondLayer.pl_PositionVector(3); } // otherwise if we are in entity mode and there is only one entity selected else if( (pDoc->m_iMode == ENTITY_MODE) && ( pDoc->m_selEntitySelection.Count() == 1) ) { // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); m_fHeading = DegAngle( plEntityOnePlacement.pl_OrientationAngle(1)); m_fPitch = DegAngle( plEntityOnePlacement.pl_OrientationAngle(2)); m_fBanking = DegAngle( plEntityOnePlacement.pl_OrientationAngle(3)); m_fX = plEntityOnePlacement.pl_PositionVector(1); m_fY = plEntityOnePlacement.pl_PositionVector(2); m_fZ = plEntityOnePlacement.pl_PositionVector(3); } m_udSelection.MarkUpdated(); } //{{AFX_DATA_MAP(CDlgPgPosition) DDX_Text(pDX, IDC_EDIT_BANKING, m_fBanking); DDX_Text(pDX, IDC_EDIT_HEADING, m_fHeading); DDX_Text(pDX, IDC_EDIT_PITCH, m_fPitch); DDX_Text(pDX, IDC_EDIT_X, m_fX); DDX_Text(pDX, IDC_EDIT_Y, m_fY); DDX_Text(pDX, IDC_EDIT_Z, m_fZ); //}}AFX_DATA_MAP // if dialog is giving data if( pDX->m_bSaveAndValidate != FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, copy coordinates from editting controls into second layer pDoc->m_plSecondLayer.pl_OrientationAngle(1) = AngleDeg( m_fHeading); pDoc->m_plSecondLayer.pl_OrientationAngle(2) = AngleDeg( m_fPitch); pDoc->m_plSecondLayer.pl_OrientationAngle(3) = AngleDeg( m_fBanking); pDoc->m_plSecondLayer.pl_PositionVector(1) = m_fX; pDoc->m_plSecondLayer.pl_PositionVector(2) = m_fY; pDoc->m_plSecondLayer.pl_PositionVector(3) = m_fZ; // snap values to grid pDoc->SnapToGrid( pDoc->m_plSecondLayer, SNAP_FLOAT_12); theApp.m_vfpCurrent.vfp_plPrimitive = pDoc->m_plSecondLayer; // update all document's views pDoc->UpdateAllViews( NULL); } // otherwise if we are in entity mode else if( pDoc->m_iMode == ENTITY_MODE) { // there must be only one entity selected ASSERT( pDoc->m_selEntitySelection.Count() == 1); // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); plEntityOnePlacement.pl_OrientationAngle(1) = AngleDeg( m_fHeading); plEntityOnePlacement.pl_OrientationAngle(2) = AngleDeg( m_fPitch); plEntityOnePlacement.pl_OrientationAngle(3) = AngleDeg( m_fBanking); plEntityOnePlacement.pl_PositionVector(1) = m_fX; plEntityOnePlacement.pl_PositionVector(2) = m_fY; plEntityOnePlacement.pl_PositionVector(3) = m_fZ; // snap entity's placement pDoc->SnapToGrid( plEntityOnePlacement, SNAP_FLOAT_12); // set placement back to entity penEntityOne->SetPlacement( plEntityOnePlacement); pDoc->SetModifiedFlag( TRUE); pDoc->UpdateAllViews( NULL); m_udSelection.MarkUpdated(); // update all document's views pDoc->UpdateAllViews( NULL); } } }