ChildFrm.cpp 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // ChildFrm.cpp : implementation of the CChildFrame class
  13. //
  14. #include "stdafx.h"
  15. #include "ChildFrm.h"
  16. #ifdef _DEBUG
  17. #undef new
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. extern INDEX wed_bSaveTestGameFirstTime = TRUE;
  23. ENGINE_API extern INDEX snd_iFormat;
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CChildFrame
  26. IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
  27. BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
  28. //{{AFX_MSG_MAP(CChildFrame)
  29. ON_COMMAND(ID_GRID_ON_OFF, OnGridOnOff)
  30. ON_UPDATE_COMMAND_UI(ID_GRID_ON_OFF, OnUpdateGridOnOff)
  31. ON_COMMAND(ID_TEST_GAME, OnTestGameWindowed)
  32. ON_COMMAND(ID_TEST_GAME_FULLSCREEN, OnTestGameFullScreen)
  33. ON_UPDATE_COMMAND_UI(ID_TEST_GAME, OnUpdateTestGame)
  34. ON_COMMAND(ID_RENDER_TARGETS, OnRenderTargets)
  35. ON_UPDATE_COMMAND_UI(ID_RENDER_TARGETS, OnUpdateRenderTargets)
  36. ON_COMMAND(ID_MOVE_ANCHORED, OnMoveAnchored)
  37. ON_UPDATE_COMMAND_UI(ID_MOVE_ANCHORED, OnUpdateMoveAnchored)
  38. ON_WM_TIMER()
  39. ON_COMMAND(ID_SCENE_RENDERING_TIME, OnSceneRenderingTime)
  40. ON_UPDATE_COMMAND_UI(ID_SCENE_RENDERING_TIME, OnUpdateSceneRenderingTime)
  41. ON_COMMAND(ID_AUTO_MIP_LEVELING, OnAutoMipLeveling)
  42. ON_UPDATE_COMMAND_UI(ID_AUTO_MIP_LEVELING, OnUpdateAutoMipLeveling)
  43. ON_COMMAND(ID_WINDOW_CLOSE, OnWindowClose)
  44. ON_COMMAND(ID_VIEW_SELECTION, OnViewSelection)
  45. ON_UPDATE_COMMAND_UI(ID_VIEW_SELECTION, OnUpdateViewSelection)
  46. ON_COMMAND(ID_MAXIMIZE_VIEW, OnMaximizeView)
  47. ON_COMMAND(ID_TOGGLE_VIEW_PICTURES, OnToggleViewPictures)
  48. ON_UPDATE_COMMAND_UI(ID_TOGGLE_VIEW_PICTURES, OnUpdateToggleViewPictures)
  49. ON_COMMAND(ID_VIEW_FROM_ENTITY, OnViewFromEntity)
  50. ON_UPDATE_COMMAND_UI(ID_VIEW_FROM_ENTITY, OnUpdateViewFromEntity)
  51. ON_COMMAND(ID_VIEW_SHADOWS_ONOFF, OnViewShadowsOnoff)
  52. ON_COMMAND(ID_CALCULATE_SHADOWS_ONOFF, OnCalculateShadowsOnoff)
  53. ON_UPDATE_COMMAND_UI(ID_VIEW_SHADOWS_ONOFF, OnUpdateViewShadowsOnoff)
  54. ON_UPDATE_COMMAND_UI(ID_CALCULATE_SHADOWS_ONOFF, OnUpdateCalculateShadowsOnoff)
  55. ON_COMMAND(ID_STORE_POSITION01, OnStorePosition01)
  56. ON_COMMAND(ID_STORE_POSITION02, OnStorePosition02)
  57. ON_COMMAND(ID_RESTORE_POSITION01, OnRestorePosition01)
  58. ON_COMMAND(ID_RESTORE_POSITION02, OnRestorePosition02)
  59. ON_COMMAND(ID_TOGGLE_ENTITY_NAMES, OnToggleEntityNames)
  60. ON_UPDATE_COMMAND_UI(ID_TOGGLE_ENTITY_NAMES, OnUpdateToggleEntityNames)
  61. ON_COMMAND(ID_TOGGLE_VISIBILITY_TWEAKS, OnToggleVisibilityTweaks)
  62. ON_UPDATE_COMMAND_UI(ID_TOGGLE_VISIBILITY_TWEAKS, OnUpdateToggleVisibilityTweaks)
  63. ON_COMMAND(ID_ENABLE_VISIBILITY_TWEAKS, OnEnableVisibilityTweaks)
  64. ON_UPDATE_COMMAND_UI(ID_ENABLE_VISIBILITY_TWEAKS, OnUpdateEnableVisibilityTweaks)
  65. ON_COMMAND(ID_RESTORE_POSITION03, OnRestorePosition03)
  66. ON_COMMAND(ID_RESTORE_POSITION04, OnRestorePosition04)
  67. ON_COMMAND(ID_STORE_POSITION03, OnStorePosition03)
  68. ON_COMMAND(ID_STORE_POSITION04, OnStorePosition04)
  69. ON_COMMAND(ID_KEY_B, OnKeyB)
  70. ON_UPDATE_COMMAND_UI(ID_KEY_B, OnUpdateKeyB)
  71. ON_COMMAND(ID_KEY_G, OnKeyG)
  72. ON_UPDATE_COMMAND_UI(ID_KEY_G, OnUpdateKeyG)
  73. ON_COMMAND(ID_KEY_Y, OnKeyY)
  74. ON_UPDATE_COMMAND_UI(ID_KEY_Y, OnUpdateKeyY)
  75. ON_UPDATE_COMMAND_UI(ID_TEST_GAME_FULLSCREEN, OnUpdateTestGame)
  76. ON_COMMAND(ID_KEY_CTRL_G, OnKeyCtrlG)
  77. ON_UPDATE_COMMAND_UI(ID_KEY_CTRL_G, OnUpdateKeyCtrlG)
  78. //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80. /////////////////////////////////////////////////////////////////////////////
  81. // CChildFrame construction/destruction
  82. CChildFrame::CChildFrame()
  83. {
  84. m_bShowVisibilityTweaks=FALSE;
  85. m_bDisableVisibilityTweaks=FALSE;
  86. m_bTestGameOn = FALSE;
  87. m_bShowTargets = FALSE;
  88. m_bShowEntityNames = FALSE;
  89. m_fManualMipBrushingFactor = 1.0f;
  90. m_bLastAutoMipBrushingOn = FALSE;
  91. m_bAutoMipBrushingOn = FALSE;
  92. m_iSelectedConfiguration = 0;
  93. m_bSceneRenderingTime = FALSE;
  94. m_bRenderViewPictures = FALSE;
  95. // don't allow moving of anchored entities
  96. m_bAncoredMovingAllowed = FALSE;
  97. if( theApp.m_Preferences.ap_bHideShadowsOnOpen)
  98. {
  99. m_stShadowType = CWorldRenderPrefs::SHT_NONE;
  100. m_bShadowsVisible = FALSE;
  101. m_bShadowsCalculate = TRUE;
  102. }
  103. else
  104. {
  105. m_stShadowType = CWorldRenderPrefs::SHT_FULL;
  106. m_bShadowsVisible = TRUE;
  107. m_bShadowsCalculate = TRUE;
  108. }
  109. m_iAnchoredResetTimerID = -1;
  110. m_bInfoVisible = 0;
  111. m_bSelectionVisible = TRUE;
  112. m_bViewFromEntity = FALSE;
  113. wo_plStored01 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0));
  114. wo_plStored02 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0));
  115. wo_plStored03 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0));
  116. wo_plStored04 = CPlacement3D( FLOAT3D(0.0f,0.0f,0.0f), ANGLE3D(0,0,0));
  117. wo_fStored01 = 10.0f;
  118. wo_fStored02 = 10.0f;
  119. wo_fStored03 = 10.0f;
  120. wo_fStored04 = 10.0f;
  121. }
  122. CChildFrame::~CChildFrame()
  123. {
  124. }
  125. BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  126. CCreateContext* pContext)
  127. {
  128. return m_wndSplitter.Create( this,
  129. 2, 2, // TODO: adjust the number of rows, columns
  130. CSize( 10, 10 ), // TODO: adjust the minimum pane size
  131. pContext, WS_CHILD | WS_VISIBLE | SPLS_DYNAMIC_SPLIT);
  132. }
  133. BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
  134. {
  135. // TODO: Modify the Window class or styles here by modifying
  136. // the CREATESTRUCT cs
  137. BOOL bMaximized = FALSE;
  138. CMDIFrameWnd *pFrame = (CMDIFrameWnd *)AfxGetApp()->m_pMainWnd;
  139. if( ((pFrame->MDIGetActive( &bMaximized) == NULL) || (bMaximized)) &&
  140. (theApp.m_Preferences.ap_AutoMaximizeWindow) )
  141. {
  142. cs.style |= WS_VISIBLE | WS_MAXIMIZE;
  143. }
  144. return CMDIChildWnd::PreCreateWindow(cs);
  145. }
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CChildFrame diagnostics
  148. #ifdef _DEBUG
  149. void CChildFrame::AssertValid() const
  150. {
  151. CMDIChildWnd::AssertValid();
  152. }
  153. void CChildFrame::Dump(CDumpContext& dc) const
  154. {
  155. CMDIChildWnd::Dump(dc);
  156. }
  157. #endif //_DEBUG
  158. /////////////////////////////////////////////////////////////////////////////
  159. // CChildFrame message handlers
  160. /*
  161. * Set new child's configuration
  162. */
  163. void CChildFrame::RememberChildConfiguration( INDEX iViewConfiguration)
  164. {
  165. INDEX i, j;
  166. // get client size
  167. CRect rectClient;
  168. GetClientRect( &rectClient);
  169. PIX pixClientWidth, pixClientHeight;
  170. pixClientWidth = rectClient.Width();
  171. pixClientHeight = rectClient.Height();
  172. // create reference to choosed view configuration
  173. CChildConfiguration &CC = theApp.m_ccChildConfigurations[ iViewConfiguration];
  174. // look for numbers of vertical splitter windows
  175. CC.m_iVerticalSplitters = m_wndSplitter.GetColumnCount();
  176. ASSERT( CC.m_iVerticalSplitters <= 2);
  177. // look for numbers of horizontal splitter windows
  178. CC.m_iHorizontalSplitters = m_wndSplitter.GetRowCount();
  179. ASSERT( CC.m_iHorizontalSplitters <= 2);
  180. // here we will receive splitter's sizes
  181. int iCurWidth, iCurHeight;
  182. // get width and height of splitter windows
  183. CWnd *pWnd = m_wndSplitter.GetPane( 0, 0);
  184. CRect rectLU;
  185. pWnd->GetClientRect( &rectLU);
  186. iCurWidth = rectLU.Width();
  187. iCurHeight = rectLU.Height();
  188. // if window is splitted vericaly
  189. if( CC.m_iVerticalSplitters != 1)
  190. {
  191. // calculate percentages of left window
  192. CC.m_fPercentageLeft = ((FLOAT)iCurWidth)/pixClientWidth;
  193. }
  194. // if window is splitted horizontaly
  195. if( CC.m_iHorizontalSplitters != 1)
  196. {
  197. // calculate percentages of top window
  198. CC.m_fPercentageTop = ((FLOAT)iCurHeight)/pixClientHeight;
  199. }
  200. // remember grid on/off flag
  201. CC.m_bGridOn = m_bGridOn;
  202. // remember rendering preferences of all views
  203. for( j=0; j<CC.m_iVerticalSplitters; j++)
  204. {
  205. for( i=0; i<CC.m_iHorizontalSplitters; i++)
  206. {
  207. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( j, i);
  208. ASSERT( pWEDView != NULL);
  209. CC.m_vpViewPrefs[ j*2 + i] = pWEDView->m_vpViewPrefs;
  210. CC.m_ptProjectionType[ j*2 + i] = pWEDView->m_ptProjectionType;
  211. }
  212. }
  213. }
  214. void CChildFrame::ApplySettingsFromPerspectiveView( CWorldEditorView *pwedView, INDEX iViewConfiguration)
  215. {
  216. CChildConfiguration &cc = theApp.m_ccChildConfigurations[ iViewConfiguration];
  217. // type of projection
  218. for( INDEX iView=0; iView<cc.m_iHorizontalSplitters*cc.m_iHorizontalSplitters; iView++)
  219. {
  220. if( cc.m_ptProjectionType[ iView] == CSlaveViewer::PT_PERSPECTIVE)
  221. {
  222. pwedView->m_vpViewPrefs = cc.m_vpViewPrefs[ iView];
  223. }
  224. }
  225. }
  226. /*
  227. * Set new child's configuration
  228. */
  229. void CChildFrame::SetChildConfiguration( INDEX iViewConfiguration)
  230. {
  231. INDEX i, j;
  232. // get client size
  233. CRect rectClient;
  234. GetClientRect( &rectClient);
  235. PIX pixClientWidth, pixClientHeight;
  236. pixClientWidth = rectClient.Width();
  237. pixClientHeight = rectClient.Height();
  238. CChildConfiguration &CC = theApp.m_ccChildConfigurations[ iViewConfiguration];
  239. m_iSelectedConfiguration = iViewConfiguration;
  240. // delete all possible columns
  241. for( i=1; i<m_wndSplitter.GetColumnCount(); i++)
  242. {
  243. m_wndSplitter.DeleteColumn( 0);
  244. }
  245. // delete all possible rows
  246. for( i=1; i<m_wndSplitter.GetRowCount(); i++)
  247. {
  248. m_wndSplitter.DeleteRow( 0);
  249. }
  250. // restore grid on/off flag
  251. m_bGridOn = CC.m_bGridOn;
  252. // here we will prepare splitter's size
  253. int iCurWidth, iCurHeight;
  254. // if window is splitted vericaly
  255. if( CC.m_iVerticalSplitters != 1)
  256. {
  257. // add new splitter with position calculated using remembered percentage
  258. iCurWidth = (int) (pixClientWidth * CC.m_fPercentageLeft) + 2;
  259. m_wndSplitter.SplitColumn( iCurWidth);
  260. }
  261. // if window is splitted horizontaly
  262. if( CC.m_iHorizontalSplitters != 1)
  263. {
  264. // add new splitter with position calculated using remembered percentage
  265. iCurHeight = (int) (pixClientHeight * CC.m_fPercentageTop) + 3;
  266. m_wndSplitter.SplitRow( iCurHeight);
  267. }
  268. // restore rendering preferences of all views
  269. for( j=0; j<CC.m_iVerticalSplitters; j++)
  270. {
  271. for( i=0; i<CC.m_iHorizontalSplitters; i++)
  272. {
  273. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( j, i);
  274. ASSERT( pWEDView != NULL);
  275. pWEDView->m_vpViewPrefs = CC.m_vpViewPrefs[ j*2 + i];
  276. pWEDView->m_ptProjectionType = CC.m_ptProjectionType[ j*2 + i];
  277. // resize it
  278. pWEDView->m_pvpViewPort->Resize();
  279. }
  280. }
  281. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  282. // redraw all views, child configuration changed
  283. pWEDView->GetDocument()->UpdateAllViews( NULL);
  284. RecalcLayout();
  285. }
  286. void CChildFrame::KeyPressed(UINT nChar, UINT nRepCnt, UINT nFlags)
  287. {
  288. // first set invalid view configuration buffer number
  289. INDEX iViewConfiguration = -1;
  290. // if control pressed
  291. BOOL bCtrl = (GetKeyState( VK_CONTROL) & 128) != 0;
  292. // look for wanted keys on numeric part of keyboard and extract buffer number
  293. if( nFlags == 0x52) iViewConfiguration = 0;
  294. if( nFlags == 0x4f) iViewConfiguration = 1;
  295. if( nFlags == 0x50) iViewConfiguration = 2;
  296. if( nFlags == 0x51) iViewConfiguration = 3;
  297. if( nFlags == 0x4b) iViewConfiguration = 4;
  298. if( nFlags == 0x4c) iViewConfiguration = 5;
  299. if( nFlags == 0x4d) iViewConfiguration = 6;
  300. if( nFlags == 0x47) iViewConfiguration = 7;
  301. if( nFlags == 0x48) iViewConfiguration = 8;
  302. if( nFlags == 0x49) iViewConfiguration = 9;
  303. // if any of view configuration buffers requested
  304. if( iViewConfiguration != -1)
  305. {
  306. if( bCtrl)
  307. {
  308. // edit child's configuration
  309. RememberChildConfiguration( iViewConfiguration);
  310. }
  311. else
  312. {
  313. // set new child's configuration
  314. SetChildConfiguration( iViewConfiguration);
  315. }
  316. }
  317. }
  318. void CChildFrame::ActivateFrame(int nCmdShow)
  319. {
  320. CMDIChildWnd::ActivateFrame(nCmdShow);
  321. // set default child's configuration
  322. SetChildConfiguration( theApp.m_Preferences.ap_iStartupWindowSetup);
  323. }
  324. void CChildFrame::OnGridOnOff()
  325. {
  326. m_bGridOn = !m_bGridOn;
  327. Invalidate( FALSE);
  328. }
  329. void CChildFrame::OnUpdateGridOnOff(CCmdUI* pCmdUI)
  330. {
  331. pCmdUI->SetCheck( m_bGridOn);
  332. }
  333. CWorldEditorView *CChildFrame::GetPerspectiveView(void)
  334. {
  335. CWorldEditorView *pPerspectiveView = NULL;
  336. // create reference to choosed view configuration
  337. CChildConfiguration &CC = theApp.m_ccChildConfigurations[ m_iSelectedConfiguration];
  338. // find perspective view
  339. for( INDEX iVerticalSpliter=0; iVerticalSpliter<GetVSplitters(); iVerticalSpliter++)
  340. {
  341. for( INDEX iHorizontalSpliter=0; iHorizontalSpliter<GetHSplitters(); iHorizontalSpliter++)
  342. {
  343. CWorldEditorView *pWEDView = (CWorldEditorView *)
  344. m_wndSplitter.GetPane( iVerticalSpliter, iHorizontalSpliter);
  345. ASSERT( pWEDView != NULL);
  346. if( pWEDView->m_ptProjectionType == CSlaveViewer::PT_PERSPECTIVE)
  347. {
  348. pPerspectiveView = pWEDView;
  349. break;
  350. }
  351. }
  352. }
  353. return pPerspectiveView;
  354. }
  355. // test game routines
  356. #define APPLICATION_NAME "TestGame FullScreen"
  357. void CChildFrame::TestGame( BOOL bFullScreen)
  358. {
  359. // turn off info window
  360. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  361. pMainFrame->HideInfoWindow();
  362. CWorldEditorView *pPerspectiveView = GetPerspectiveView();
  363. ASSERT( pPerspectiveView != NULL);
  364. SetActiveView( pPerspectiveView, FALSE);
  365. CWorldEditorDoc* pDoc = pPerspectiveView->GetDocument();
  366. CTFileName fnmWorldToPlay;
  367. CTFileName fnmTempWorld = CTString("Temp\\TestGame.wld");
  368. // if the world was never saved or if it is modified
  369. if( (!pDoc->m_bWasEverSaved && wed_bSaveTestGameFirstTime) || pDoc->IsModified())
  370. { // save world under temporary name
  371. ASSERT_VALID(pDoc);
  372. try {
  373. pDoc->m_woWorld.Save_t(fnmTempWorld);
  374. fnmWorldToPlay = fnmTempWorld;
  375. } catch( char *strError) {
  376. AfxMessageBox( CString(strError));
  377. pPerspectiveView->EnableToolTips(TRUE);
  378. return;
  379. }
  380. // if the world is not modified (it is saved on disk)
  381. } else
  382. { // use the saved world
  383. fnmWorldToPlay = CTString(CStringA(pDoc->GetPathName()));
  384. try {
  385. fnmWorldToPlay.RemoveApplicationPath_t();
  386. } catch( char *strError) {
  387. AfxMessageBox( CString(strError));
  388. pPerspectiveView->EnableToolTips(TRUE);
  389. return;
  390. }
  391. }
  392. // set rendering preferences
  393. _wrpWorldRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_wrpWorldRenderPrefs;
  394. _mrpModelRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_mrpModelRenderPrefs;
  395. _wrpWorldRenderPrefs.SetShadowsType( pPerspectiveView->GetChildFrame()->m_stShadowType);
  396. _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject);
  397. _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject);
  398. _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject);
  399. _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture1, 0);
  400. _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture2, 1);
  401. _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture3, 2);
  402. _wrpWorldRenderPrefs.DisableVisTweaks(FALSE);
  403. _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject);
  404. _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject);
  405. _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject);
  406. // prepare test game view/draw ports
  407. CViewPort *pvp = pPerspectiveView->m_pvpViewPort;
  408. CDrawPort *pdp = pPerspectiveView->m_pdpDrawPort;
  409. pdp->SetOverlappedRendering(FALSE); // we are not rendering scene over already rendered scene (used for CSG layer)
  410. // if full screen mode is required
  411. HWND hWndFullScreen=NULL;
  412. HINSTANCE hInstanceFullScreen;
  413. WNDCLASSEX wcFullScreen;
  414. char achWindowTitle[256]; // current window title
  415. if( bFullScreen)
  416. {
  417. // get full screen display mode info
  418. const PIX pixSizeI = theApp.m_dmFullScreen.dm_pixSizeI;
  419. const PIX pixSizeJ = theApp.m_dmFullScreen.dm_pixSizeJ;
  420. const DisplayDepth dd = theApp.m_dmFullScreen.dm_ddDepth;
  421. const GfxAPIType gat = theApp.m_gatFullScreen;
  422. // set OpenGL fullscreen (before window)
  423. if( gat==GAT_OGL) {
  424. const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd);
  425. if( !bRes) {
  426. WarningMessage( "Unable to setup full screen display.");
  427. return;
  428. }
  429. } // register the window class
  430. hInstanceFullScreen = AfxGetInstanceHandle();
  431. ASSERT( hInstanceFullScreen!=NULL);
  432. wcFullScreen.cbSize = sizeof(wcFullScreen);
  433. wcFullScreen.style = CS_HREDRAW | CS_VREDRAW;
  434. wcFullScreen.lpfnWndProc = ::DefWindowProc;
  435. wcFullScreen.cbClsExtra = 0;
  436. wcFullScreen.cbWndExtra = 0;
  437. wcFullScreen.hInstance = hInstanceFullScreen;
  438. wcFullScreen.hIcon = LoadIcon( hInstanceFullScreen, (LPCTSTR)IDR_MAINFRAME );
  439. wcFullScreen.hCursor = NULL;
  440. wcFullScreen.hbrBackground = NULL;
  441. wcFullScreen.lpszMenuName = CString(APPLICATION_NAME);
  442. wcFullScreen.lpszClassName = CString(APPLICATION_NAME);
  443. wcFullScreen.hIconSm = NULL;
  444. RegisterClassEx(&wcFullScreen);
  445. // create a window, invisible initially
  446. hWndFullScreen = CreateWindowExA(
  447. WS_EX_TOPMOST,
  448. APPLICATION_NAME,
  449. "Serious Editor - Full Screen Test Game", // title
  450. WS_POPUP,
  451. 0,0,
  452. pixSizeI, pixSizeJ, // window size
  453. NULL,
  454. NULL,
  455. hInstanceFullScreen,
  456. NULL);
  457. // didn't make it?
  458. ASSERT( hWndFullScreen!=NULL);
  459. if( hWndFullScreen==NULL) {
  460. if( gat==GAT_OGL) _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi);
  461. WarningMessage( "Unable to setup window for full screen display.");
  462. return;
  463. }
  464. // set windows for engine
  465. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  466. SE_UpdateWindowHandle( hWndFullScreen);
  467. // set window title and show it
  468. sprintf( achWindowTitle, "Serious Editor - Test Game (FullScreen %dx%d)", pixSizeI, pixSizeJ);
  469. ::SetWindowTextA( hWndFullScreen, achWindowTitle);
  470. ::ShowWindow( hWndFullScreen, SW_SHOWNORMAL);
  471. // set Direct3D full screen (after window)
  472. #ifdef SE1_D3D
  473. if( gat==GAT_D3D) {
  474. const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd);
  475. if( !bRes) {
  476. WarningMessage( "Unable to setup full screen display.");
  477. ::DestroyWindow( hWndFullScreen);
  478. SE_UpdateWindowHandle( pMainFrame->m_hWnd);
  479. return;
  480. }
  481. }
  482. #endif // SE1_D3D
  483. // create canvas
  484. _pGfx->CreateWindowCanvas( hWndFullScreen, &pvp, &pdp);
  485. // initial screen fill and swap, just to get context running
  486. BOOL bSuccess = FALSE;
  487. if( pdp!=NULL && pdp->Lock()) {
  488. pdp->Fill(C_dGREEN|CT_OPAQUE);
  489. pdp->Unlock();
  490. pvp->SwapBuffers();
  491. bSuccess = TRUE;
  492. }
  493. // must succeed!
  494. ASSERT( bSuccess);
  495. if( !bSuccess) {
  496. _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi);
  497. WarningMessage( "Unable to setup canvas for full screen display.");
  498. return;
  499. }
  500. }
  501. // enable sound
  502. snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16);
  503. _pSound->SetFormat( (enum CSoundLibrary::SoundFormat)snd_iFormat, TRUE);
  504. // run quick test game
  505. extern BOOL _bInOnDraw;
  506. _bInOnDraw = TRUE;
  507. _pGameGUI->QuickTest( fnmWorldToPlay, pdp, pvp);
  508. _bInOnDraw = FALSE;
  509. // disable sound
  510. _pSound->SetFormat( CSoundLibrary::SF_NONE);
  511. // restore default display mode and close test full screen window
  512. if( hWndFullScreen!=NULL) {
  513. _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi);
  514. ::DestroyWindow( hWndFullScreen);
  515. SE_UpdateWindowHandle( pMainFrame->m_hWnd);
  516. }
  517. // redraw all views
  518. pDoc->UpdateAllViews( NULL);
  519. pPerspectiveView->EnableToolTips( TRUE);
  520. }
  521. void CChildFrame::OnTestGameWindowed()
  522. {
  523. m_bTestGameOn = TRUE;
  524. // run test game in perspective window
  525. TestGame( FALSE);
  526. m_bTestGameOn = FALSE;
  527. }
  528. void CChildFrame::OnTestGameFullScreen()
  529. {
  530. m_bTestGameOn = TRUE;
  531. // run test game in full screen
  532. TestGame( TRUE);
  533. m_bTestGameOn = FALSE;
  534. }
  535. void CChildFrame::OnUpdateTestGame(CCmdUI* pCmdUI)
  536. {
  537. CWorldEditorView *pPerspectiveView = GetPerspectiveView();
  538. pCmdUI->Enable( pPerspectiveView != NULL);
  539. }
  540. void CChildFrame::OnKeyG()
  541. {
  542. OnRenderTargets();
  543. }
  544. void CChildFrame::OnUpdateKeyG(CCmdUI* pCmdUI)
  545. {
  546. pCmdUI->SetCheck( TRUE);
  547. }
  548. void CChildFrame::OnRenderTargets()
  549. {
  550. m_bShowTargets = !m_bShowTargets;
  551. Invalidate( FALSE);
  552. }
  553. void CChildFrame::OnUpdateRenderTargets(CCmdUI* pCmdUI)
  554. {
  555. pCmdUI->SetCheck( m_bShowTargets);
  556. }
  557. void CChildFrame::DeleteViewsExcept( CWnd *pwndViewToLeave)
  558. {
  559. // delete all rows
  560. INDEX iRowToDelete = 0;
  561. while( iRowToDelete<GetVSplitters())
  562. {
  563. BOOL bCanDeleteRow = TRUE;
  564. // for all collumns
  565. for( INDEX iColumn=0; iColumn<GetHSplitters(); iColumn++)
  566. {
  567. if( m_wndSplitter.GetPane( iRowToDelete, iColumn) == pwndViewToLeave)
  568. {
  569. bCanDeleteRow = FALSE;
  570. break;
  571. }
  572. }
  573. if( bCanDeleteRow)
  574. {
  575. m_wndSplitter.DeleteRow( iRowToDelete);
  576. }
  577. else
  578. {
  579. iRowToDelete++;
  580. }
  581. }
  582. // delete all columns
  583. INDEX iColumnToDelete = 0;
  584. while( iColumnToDelete<GetHSplitters())
  585. {
  586. BOOL bCanDeleteColumn = TRUE;
  587. // for all collumns
  588. for( INDEX iRow=0; iRow<GetVSplitters(); iRow++)
  589. {
  590. if( m_wndSplitter.GetPane( iRow, iColumnToDelete) == pwndViewToLeave)
  591. {
  592. bCanDeleteColumn = FALSE;
  593. break;
  594. }
  595. }
  596. if( bCanDeleteColumn)
  597. {
  598. m_wndSplitter.DeleteColumn( iColumnToDelete);
  599. }
  600. else
  601. {
  602. iColumnToDelete++;
  603. }
  604. }
  605. // activate view that we want to leave
  606. SetActiveView( (CView*)pwndViewToLeave, FALSE);
  607. }
  608. void CChildFrame::OnSceneRenderingTime()
  609. {
  610. m_bSceneRenderingTime = !m_bSceneRenderingTime;
  611. Invalidate( FALSE);
  612. }
  613. void CChildFrame::OnUpdateSceneRenderingTime(CCmdUI* pCmdUI)
  614. {
  615. pCmdUI->SetCheck( m_bSceneRenderingTime);
  616. }
  617. void CChildFrame::OnMoveAnchored()
  618. {
  619. m_bAncoredMovingAllowed = !m_bAncoredMovingAllowed;
  620. m_iAnchoredResetTimerID = SetTimer( 1, 60000*5, NULL);
  621. }
  622. void CChildFrame::OnUpdateMoveAnchored(CCmdUI* pCmdUI)
  623. {
  624. pCmdUI->SetCheck( m_bAncoredMovingAllowed);
  625. }
  626. void CChildFrame::OnTimer(UINT nIDEvent)
  627. {
  628. // if anchored reset happend
  629. if( nIDEvent == m_iAnchoredResetTimerID)
  630. {
  631. m_bAncoredMovingAllowed = FALSE;
  632. // refresh "enable anchored moving" tool button
  633. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  634. pMainFrame->RecalcLayout();
  635. KillTimer( m_iAnchoredResetTimerID);
  636. }
  637. CMDIChildWnd::OnTimer(nIDEvent);
  638. }
  639. void CChildFrame::OnAutoMipLeveling()
  640. {
  641. // remember current time as time when last mip brushing option has been used
  642. _fLastMipBrushingOptionUsed = _pTimer->GetRealTimeTick();
  643. // get view
  644. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  645. m_bAutoMipBrushingOn = !m_bAutoMipBrushingOn;
  646. pWEDView->SetEditingDataPaneInfo( TRUE);
  647. Invalidate( FALSE);
  648. }
  649. void CChildFrame::OnUpdateAutoMipLeveling(CCmdUI* pCmdUI)
  650. {
  651. if( theApp.GetDocument()->GetEditingMode() == CSG_MODE)
  652. {
  653. pCmdUI->Enable( FALSE);
  654. }
  655. pCmdUI->SetCheck( m_bAutoMipBrushingOn);
  656. }
  657. void CChildFrame::OnWindowClose()
  658. {
  659. OnClose();
  660. }
  661. void CChildFrame::OnViewSelection()
  662. {
  663. // get document
  664. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  665. ASSERT( pWEDView != NULL);
  666. CWorldEditorDoc* pDoc = pWEDView->GetDocument();
  667. ASSERT_VALID(pDoc);
  668. m_bSelectionVisible = !m_bSelectionVisible;
  669. pDoc->UpdateAllViews( NULL);
  670. }
  671. void CChildFrame::OnUpdateViewSelection(CCmdUI* pCmdUI)
  672. {
  673. pCmdUI->SetCheck( m_bSelectionVisible);
  674. }
  675. void CChildFrame::OnToggleVisibilityTweaks()
  676. {
  677. // get document
  678. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  679. ASSERT( pWEDView != NULL);
  680. CWorldEditorDoc* pDoc = pWEDView->GetDocument();
  681. ASSERT_VALID(pDoc);
  682. m_bShowVisibilityTweaks = !m_bShowVisibilityTweaks;
  683. // auto turn off disabling of visibility tweaks
  684. m_bDisableVisibilityTweaks = FALSE;
  685. pDoc->UpdateAllViews( NULL);
  686. }
  687. void CChildFrame::OnUpdateToggleVisibilityTweaks(CCmdUI* pCmdUI)
  688. {
  689. pCmdUI->SetCheck( m_bShowVisibilityTweaks);
  690. }
  691. void CChildFrame::OnMaximizeView()
  692. {
  693. // look for numbers of horizontal splitter windows
  694. if( (m_wndSplitter.GetRowCount()+m_wndSplitter.GetColumnCount() ) == 4)
  695. {
  696. // remember child configuration into temporary buffer
  697. RememberChildConfiguration( CHILD_CONFIGURATIONS_CT+1);
  698. // get active view
  699. CWorldEditorView *pWorldEditorView = theApp.GetActiveView();
  700. // delete all other views
  701. DeleteViewsExcept( pWorldEditorView);
  702. }
  703. else
  704. {
  705. // restore child configuration
  706. SetChildConfiguration( CHILD_CONFIGURATIONS_CT+1);
  707. }
  708. }
  709. void CChildFrame::OnToggleViewPictures()
  710. {
  711. m_bRenderViewPictures = !m_bRenderViewPictures;
  712. Invalidate( FALSE);
  713. }
  714. void CChildFrame::OnUpdateToggleViewPictures(CCmdUI* pCmdUI)
  715. {
  716. pCmdUI->SetCheck( m_bRenderViewPictures);
  717. }
  718. void CChildFrame::OnViewFromEntity()
  719. {
  720. m_bViewFromEntity = !m_bViewFromEntity;
  721. Invalidate( FALSE);
  722. }
  723. void CChildFrame::OnUpdateViewFromEntity(CCmdUI* pCmdUI)
  724. {
  725. /*
  726. CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
  727. pCmdUI->Enable(
  728. (pDoc != NULL) &&
  729. (pDoc->GetEditingMode() == ENTITY_MODE) &&
  730. (pDoc->m_selEntitySelection.Count() == 1) &&
  731. GetPerspectiveView() != NULL);
  732. */
  733. pCmdUI->SetCheck( m_bViewFromEntity);
  734. }
  735. #define APPLY_SHADOW_TYPE( stNewShadowType) \
  736. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);\
  737. CWorldEditorDoc* pDoc = pWEDView->GetDocument();\
  738. ASSERT_VALID(pDoc);\
  739. m_stShadowType = stNewShadowType;\
  740. pDoc->UpdateAllViews( NULL);\
  741. void CChildFrame::OnViewShadowsOnoff()
  742. {
  743. CWorldRenderPrefs::ShadowsType stNew;
  744. m_bShadowsVisible = !m_bShadowsVisible;
  745. // if shadows are now visible
  746. if( m_bShadowsVisible)
  747. {
  748. // if shadows are calculating
  749. if( m_bShadowsCalculate)
  750. {
  751. stNew = CWorldRenderPrefs::SHT_FULL;
  752. }
  753. // if shadows are not calculating
  754. else
  755. {
  756. stNew = CWorldRenderPrefs::SHT_NOAUTOCALCULATE;
  757. }
  758. }
  759. // if shadows should become visible
  760. else
  761. {
  762. stNew = CWorldRenderPrefs::SHT_NONE;
  763. }
  764. APPLY_SHADOW_TYPE( stNew);
  765. }
  766. void CChildFrame::OnUpdateViewShadowsOnoff(CCmdUI* pCmdUI)
  767. {
  768. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  769. UINT nIDView, nStyleView;
  770. int iViewImage;
  771. pMainFrame->m_wndShadowsAndTexture.GetButtonInfo( 3, nIDView, nStyleView, iViewImage);
  772. // if shadows are visible
  773. if( m_bShadowsVisible)
  774. {
  775. pMainFrame->m_wndShadowsAndTexture.SetButtonInfo( 3, nIDView, nStyleView, 3);
  776. pCmdUI->SetCheck( TRUE);
  777. }
  778. // if shadows are not visible
  779. else
  780. {
  781. pMainFrame->m_wndShadowsAndTexture.SetButtonInfo( 3, nIDView, nStyleView, 5);
  782. pCmdUI->SetCheck( FALSE);
  783. }
  784. }
  785. void CChildFrame::OnCalculateShadowsOnoff()
  786. {
  787. CWorldRenderPrefs::ShadowsType stNew;
  788. m_bShadowsCalculate = !m_bShadowsCalculate;
  789. // if shadows should now calculate
  790. if( m_bShadowsCalculate)
  791. {
  792. // if shadows are visible
  793. if( m_bShadowsVisible)
  794. {
  795. stNew = CWorldRenderPrefs::SHT_FULL;
  796. }
  797. // if shadows are not visible
  798. else
  799. {
  800. stNew = CWorldRenderPrefs::SHT_NONE;
  801. }
  802. }
  803. // if shadows should stop calculating
  804. else
  805. {
  806. // if shadows are visible
  807. if( m_bShadowsVisible)
  808. {
  809. stNew = CWorldRenderPrefs::SHT_NOAUTOCALCULATE;
  810. }
  811. // if shadows are not visible
  812. else
  813. {
  814. stNew = CWorldRenderPrefs::SHT_NONE;
  815. }
  816. }
  817. APPLY_SHADOW_TYPE( stNew);
  818. }
  819. void CChildFrame::OnUpdateCalculateShadowsOnoff(CCmdUI* pCmdUI)
  820. {
  821. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  822. UINT nIDCalculate, nStyleCalculate;
  823. int iCalculateImage;
  824. pMainFrame->m_wndShadowsAndTexture.GetButtonInfo( 4, nIDCalculate, nStyleCalculate, iCalculateImage);
  825. // if shadows are calculating
  826. if( m_bShadowsCalculate)
  827. {
  828. // if shadows are visible
  829. if( m_bShadowsVisible)
  830. {
  831. pMainFrame->m_wndShadowsAndTexture.SetButtonInfo( 4, nIDCalculate, nStyleCalculate, 4);
  832. }
  833. // if shadows are not visible
  834. else
  835. {
  836. pMainFrame->m_wndShadowsAndTexture.SetButtonInfo( 4, nIDCalculate, nStyleCalculate, 7);
  837. }
  838. pCmdUI->SetCheck( TRUE);
  839. }
  840. // if shadows are not visible
  841. else
  842. {
  843. // if shadows are visible
  844. if( m_bShadowsVisible)
  845. {
  846. pMainFrame->m_wndShadowsAndTexture.SetButtonInfo( 4, nIDCalculate, nStyleCalculate, 5);
  847. }
  848. // if shadows are not visible
  849. else
  850. {
  851. pMainFrame->m_wndShadowsAndTexture.SetButtonInfo( 4, nIDCalculate, nStyleCalculate, 8);
  852. }
  853. pCmdUI->SetCheck( FALSE);
  854. }
  855. }
  856. void CChildFrame::OnStorePosition01()
  857. {
  858. wo_plStored01 = m_mvViewer.mv_plViewer;
  859. wo_fStored01 = m_mvViewer.mv_fTargetDistance;
  860. }
  861. void CChildFrame::OnStorePosition02()
  862. {
  863. wo_plStored02 = m_mvViewer.mv_plViewer;
  864. wo_fStored02 = m_mvViewer.mv_fTargetDistance;
  865. }
  866. void CChildFrame::OnStorePosition03()
  867. {
  868. wo_plStored03 = m_mvViewer.mv_plViewer;
  869. wo_fStored03 = m_mvViewer.mv_fTargetDistance;
  870. }
  871. void CChildFrame::OnStorePosition04()
  872. {
  873. wo_plStored04 = m_mvViewer.mv_plViewer;
  874. wo_fStored04 = m_mvViewer.mv_fTargetDistance;
  875. }
  876. void CChildFrame::OnRestorePosition01()
  877. {
  878. m_mvViewer.mv_plViewer = wo_plStored01;
  879. m_mvViewer.mv_fTargetDistance = wo_fStored01;
  880. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  881. ASSERT( pWEDView != NULL);
  882. CWorldEditorDoc* pDoc = pWEDView->GetDocument();
  883. ASSERT_VALID(pDoc);
  884. pDoc->UpdateAllViews( NULL);
  885. }
  886. void CChildFrame::OnRestorePosition02()
  887. {
  888. m_mvViewer.mv_plViewer = wo_plStored02;
  889. m_mvViewer.mv_fTargetDistance = wo_fStored02;
  890. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  891. ASSERT( pWEDView != NULL);
  892. CWorldEditorDoc* pDoc = pWEDView->GetDocument();
  893. ASSERT_VALID(pDoc);
  894. pDoc->UpdateAllViews( NULL);
  895. }
  896. void CChildFrame::OnRestorePosition03()
  897. {
  898. m_mvViewer.mv_plViewer = wo_plStored03;
  899. m_mvViewer.mv_fTargetDistance = wo_fStored03;
  900. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  901. ASSERT( pWEDView != NULL);
  902. CWorldEditorDoc* pDoc = pWEDView->GetDocument();
  903. ASSERT_VALID(pDoc);
  904. pDoc->UpdateAllViews( NULL);
  905. }
  906. void CChildFrame::OnRestorePosition04()
  907. {
  908. m_mvViewer.mv_plViewer = wo_plStored04;
  909. m_mvViewer.mv_fTargetDistance = wo_fStored04;
  910. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  911. ASSERT( pWEDView != NULL);
  912. CWorldEditorDoc* pDoc = pWEDView->GetDocument();
  913. ASSERT_VALID(pDoc);
  914. pDoc->UpdateAllViews( NULL);
  915. }
  916. void CChildFrame::OnKeyCtrlG()
  917. {
  918. if( theApp.GetDocument()->GetEditingMode() == TERRAIN_MODE)
  919. {
  920. GenerateLayerDistribution(-1);
  921. }
  922. else
  923. {
  924. OnToggleEntityNames();
  925. }
  926. }
  927. void CChildFrame::OnUpdateKeyCtrlG(CCmdUI* pCmdUI)
  928. {
  929. if( theApp.GetDocument()->GetEditingMode() == TERRAIN_MODE)
  930. {
  931. pCmdUI->SetCheck(TRUE);
  932. }
  933. else
  934. {
  935. OnUpdateToggleEntityNames(pCmdUI);
  936. }
  937. }
  938. void CChildFrame::OnToggleEntityNames()
  939. {
  940. m_bShowEntityNames = !m_bShowEntityNames;
  941. Invalidate( FALSE);
  942. }
  943. void CChildFrame::OnUpdateToggleEntityNames(CCmdUI* pCmdUI)
  944. {
  945. pCmdUI->SetCheck( m_bShowEntityNames);
  946. }
  947. void CChildFrame::OnEnableVisibilityTweaks()
  948. {
  949. // get document
  950. CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0);
  951. ASSERT( pWEDView != NULL);
  952. CWorldEditorDoc* pDoc = pWEDView->GetDocument();
  953. ASSERT_VALID(pDoc);
  954. m_bDisableVisibilityTweaks = !m_bDisableVisibilityTweaks;
  955. pDoc->UpdateAllViews( NULL);
  956. }
  957. void CChildFrame::OnUpdateEnableVisibilityTweaks(CCmdUI* pCmdUI)
  958. {
  959. pCmdUI->SetCheck( m_bDisableVisibilityTweaks);
  960. }
  961. void CChildFrame::OnKeyB()
  962. {
  963. if( theApp.GetDocument()->GetEditingMode() == TERRAIN_MODE)
  964. {
  965. INDEX iNewMode=(INDEX(theApp.m_iTerrainBrushMode)+1)%CT_BRUSH_MODES;
  966. theApp.m_iTerrainBrushMode=iNewMode;
  967. theApp.m_ctTerrainPageCanvas.MarkChanged();
  968. theApp.GetDocument()->SetStatusLineModeInfoMessage();
  969. }
  970. else
  971. {
  972. OnAutoMipLeveling();
  973. }
  974. }
  975. void CChildFrame::OnUpdateKeyB(CCmdUI* pCmdUI)
  976. {
  977. if( theApp.GetDocument()->GetEditingMode() == TERRAIN_MODE)
  978. {
  979. pCmdUI->SetCheck(TRUE);
  980. }
  981. else
  982. {
  983. OnUpdateAutoMipLeveling(pCmdUI);
  984. }
  985. }
  986. void CChildFrame::OnKeyY()
  987. {
  988. CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
  989. if( pDoc->GetEditingMode() == TERRAIN_MODE)
  990. {
  991. theApp.m_iTerrainBrushMode=TBM_CONTINOUS_NOISE;
  992. theApp.m_ctTerrainPageCanvas.MarkChanged();
  993. pDoc->SetStatusLineModeInfoMessage();
  994. return;
  995. }
  996. else
  997. {
  998. OnViewFromEntity();
  999. }
  1000. }
  1001. void CChildFrame::OnUpdateKeyY(CCmdUI* pCmdUI)
  1002. {
  1003. CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
  1004. if( pDoc->GetEditingMode() == TERRAIN_MODE)
  1005. {
  1006. pCmdUI->SetCheck(TRUE);
  1007. }
  1008. else
  1009. {
  1010. OnUpdateViewFromEntity(pCmdUI);
  1011. }
  1012. }