DUDES.CPP
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:21k
源码类别:

游戏

开发平台:

Visual C++

  1. // dudes.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "3dwrap.h"
  5. #include "dudes.h"
  6. #include "personal.h"
  7. #include "MainFrm.h"
  8. #include "dudeDoc.h"
  9. #include "dudeView.h"
  10. #include "editfile.h"
  11. #include "detail.h"
  12. #include "gateway.h"
  13. #include "dudehold.h"
  14. #include "weaphold.h"
  15. #include "levels.h"
  16. #include "teleport.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. // DudesApp
  19. #ifdef EDITOR
  20. BEGIN_MESSAGE_MAP(DudesApp, CWinApp)
  21. //{{AFX_MSG_MAP(DudesApp)
  22. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  23. ON_COMMAND(ID_PAUSE, OnPause)
  24. ON_COMMAND(ID_OPEN_FILE, OnOpenFile)
  25. ON_COMMAND(ID_SAVE, OnSave)
  26. ON_COMMAND(ID_SAVEAS, OnSaveas)
  27. ON_COMMAND(ID_EDIT, OnEdit)
  28. ON_COMMAND(ID_HELP, OnHelp)
  29. ON_COMMAND(ID_VIEW_AERIAL, OnViewAerial)
  30. ON_COMMAND(ID_VIEW_CIRCLING, OnViewCircling)
  31. ON_COMMAND(ID_VIEW_DUDEVIEW, OnViewDudeview)
  32. ON_COMMAND(ID_VIEW_LEFTSIDE, OnViewLeftside)
  33. ON_COMMAND(ID_VIEW_RIGHTSIDE, OnViewRightside)
  34. ON_COMMAND(ID_VIEW_HIGHANGLE, OnViewHighangle)
  35. ON_COMMAND(ID_DETAIL_CHANGEDETAIL, OnDetailChangedetail)
  36. ON_COMMAND(ID_EDIT_ADDSHAPE, OnEditAddshape)
  37. ON_COMMAND(ID_EDIT_SELECTCLOSESTSHAPE, OnEditSelectclosestshape)
  38. ON_COMMAND(ID_EDIT_MOVESELECTIONBACKWARD, OnEditMoveselectionbackward)
  39. ON_COMMAND(ID_EDIT_MOVESELECTIONDOWN, OnEditMoveselectiondown)
  40. ON_COMMAND(ID_EDIT_MOVESELECTIONFOWARD, OnEditMoveselectionfoward)
  41. ON_COMMAND(ID_EDIT_MOVESELECTIONLEFT, OnEditMoveselectionleft)
  42. ON_COMMAND(ID_EDIT_MOVESELECTIONRIGHT, OnEditMoveselectionright)
  43. ON_COMMAND(ID_EDIT_MOVESELECTIONUP, OnEditMoveselectionup)
  44. ON_COMMAND(ID_EDIT_ROTATESELECTION45DEGREESLEFT, OnEditRotateselection45degreesleft)
  45. ON_COMMAND(ID_EDIT_ROTATESELECTION45DEGREESRIGHT, OnEditRotateselection45degreesright)
  46. ON_COMMAND(ID_EDIT_ROTATESELECTION90DEGREESLEFT, OnEditRotateselection90degreesleft)
  47. ON_COMMAND(ID_EDIT_ROTATESELECTION90DEGREESRIGHT, OnEditRotateselection90degreesright)
  48. ON_COMMAND(ID_EDIT_DELETESELECTION, OnEditDeleteselection)
  49. ON_COMMAND(ID_FILE_OPENLANDSCAPE, OnFileOpenlandscape)
  50. ON_COMMAND(ID_FILE_SAVELANDSCAPE, OnFileSavelandscape)
  51. ON_COMMAND(ID_FILE_SAVELANDSCAPEAS, OnFileSavelandscapeas)
  52. ON_COMMAND(ID_EDIT_CHANGECOLORFORSELECTION, OnEditChangecolorforselection)
  53. ON_COMMAND(ID_EDIT_UNSELECTTHESELECTION, OnEditUnselecttheselection)
  54. ON_COMMAND(ID_EDIT_ADDNEWMAP, OnEditAddnewmap)
  55. ON_COMMAND(ID_VIEW_HIGHDUDEVIEW, OnViewHighdudeview)
  56. ON_COMMAND(ID_VIEW_LOWDUDEVIEW, OnViewLowdudeview)
  57. ON_COMMAND(ID_EDIT_ADDDUDE, OnEditAdddude)
  58. ON_COMMAND(ID_EDIT_ADDNEXTLEVELTELEPORTER, OnEditAddnextlevelteleporter)
  59. ON_COMMAND(ID_EDIT_ADDHANDHELDWEAPON_KNIFE, OnEditAddhandheldweaponKnife)
  60. ON_COMMAND(ID_EDIT_ADDHANDHELDWEAPON_SHIELD, OnEditAddhandheldweaponShield)
  61. ON_COMMAND(ID_EDIT_ADDHANDHELDWEAPON_SWORD, OnEditAddhandheldweaponSword)
  62. ON_COMMAND(ID_VIEW_BACKSIDE, OnViewBackside)
  63. ON_COMMAND(ID_VIEW_FRONTSIDE, OnViewFrontside)
  64. //}}AFX_MSG_MAP
  65. // Standard file based document commands
  66. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  67. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  68. END_MESSAGE_MAP()
  69. #else
  70. BEGIN_MESSAGE_MAP(DudesApp, CWinApp)                                //
  71. //{{AFX_MSG_MAP(DudesApp)                                       //
  72. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)                            //
  73. ON_COMMAND(ID_PAUSE, OnPause)                                   //
  74. ON_COMMAND(ID_OPEN_FILE, OnOpenFile)                            //
  75. ON_COMMAND(ID_SAVE, OnSave)                                     //
  76. ON_COMMAND(ID_SAVEAS, OnSaveas)                                 //
  77. ON_COMMAND(ID_EDIT, OnEdit)                                     //
  78. ON_COMMAND(ID_HELP, OnHelp)                                     //
  79. ON_COMMAND(ID_VIEW_AERIAL, OnViewAerial)                        //
  80. ON_COMMAND(ID_VIEW_CIRCLING, OnViewCircling)                    //
  81. ON_COMMAND(ID_VIEW_DUDEVIEW, OnViewDudeview)                    //
  82. ON_COMMAND(ID_VIEW_LEFTSIDE, OnViewLeftside)                    //
  83. ON_COMMAND(ID_VIEW_RIGHTSIDE, OnViewRightside)                  //
  84. ON_COMMAND(ID_VIEW_HIGHANGLE, OnViewHighangle)                  //
  85. ON_COMMAND(ID_DETAIL_CHANGEDETAIL, OnDetailChangedetail)        //
  86. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)                     //
  87. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)                   //
  88. ON_COMMAND(ID_VIEW_BACKSIDE, OnViewBackside)                    //
  89. ON_COMMAND(ID_VIEW_FRONTSIDE, OnViewFrontside)                  //
  90. //}}AFX_MSG_MAP                                                 //
  91. // Standard file based document commands                        //
  92. ON_COMMAND(ID_VIEW_HIGHDUDEVIEW, OnViewHighdudeview)            //
  93. ON_COMMAND(ID_VIEW_LOWDUDEVIEW, OnViewLowdudeview)              //
  94. END_MESSAGE_MAP()                                                   //
  95. #endif
  96. /////////////////////////////////////////////////////////////////////////////
  97. // DudesApp construction
  98. DudesApp::DudesApp()
  99. {
  100.     srand((unsigned)time(NULL));
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // The one and only DudesApp object
  104. DudesApp theApp;
  105. /////////////////////////////////////////////////////////////////////////////
  106. // DudesApp initialization
  107. BOOL DudesApp::InitInstance()
  108. {
  109. // Standard initialization
  110. // If you are not using these features and wish to reduce the size
  111. //  of your final executable, you should remove from the following
  112. //  the specific initialization routines you do not need.
  113. #ifdef _AFXDLL
  114. Enable3dControls(); // Call this when using MFC in a shared DLL
  115. #else
  116. Enable3dControlsStatic(); // Call this when linking to MFC statically
  117. #endif
  118. LoadStdProfileSettings(0);  // Load standard INI file options (including MRU)
  119. // Register the application's document templates.  Document templates
  120. //  serve as the connection between documents, frame windows and views.
  121. CSingleDocTemplate* pDocTemplate;
  122. pDocTemplate = new CSingleDocTemplate(
  123. IDR_MAINFRAME,
  124. RUNTIME_CLASS(DudeDoc),
  125. RUNTIME_CLASS(MainFrm),       // main SDI frame window
  126. RUNTIME_CLASS(DudeView));
  127. AddDocTemplate(pDocTemplate);
  128. // Parse command line for standard shell commands, DDE, file open
  129. CCommandLineInfo cmdInfo;
  130. ParseCommandLine(cmdInfo);
  131. // Dispatch commands specified on the command line
  132. if (!ProcessShellCommand(cmdInfo))
  133. return FALSE;
  134. return TRUE;
  135. }
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CPauseDlg dialog used for App About
  138. class CPauseDlg : public CDialog
  139. {
  140. public:
  141. CPauseDlg();
  142. // Dialog Data
  143. //{{AFX_DATA(CPauseDlg)
  144. enum { IDD = IDD_PAUSE };
  145. //}}AFX_DATA
  146. // ClassWizard generated virtual function overrides
  147. //{{AFX_VIRTUAL(CPauseDlg)
  148. protected:
  149. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  150. //}}AFX_VIRTUAL
  151. // Implementation
  152. protected:
  153. //{{AFX_MSG(CPauseDlg)
  154. //}}AFX_MSG
  155. DECLARE_MESSAGE_MAP()
  156. };
  157. CPauseDlg::CPauseDlg() : CDialog(CPauseDlg::IDD)
  158. {
  159. //{{AFX_DATA_INIT(CPauseDlg)
  160. //}}AFX_DATA_INIT
  161. }
  162. void CPauseDlg::DoDataExchange(CDataExchange* pDX)
  163. {
  164. CDialog::DoDataExchange(pDX);
  165. //{{AFX_DATA_MAP(CPauseDlg)
  166. //}}AFX_DATA_MAP
  167. }
  168. BEGIN_MESSAGE_MAP(CPauseDlg, CDialog)
  169. //{{AFX_MSG_MAP(CPauseDlg)
  170. //}}AFX_MSG_MAP
  171. END_MESSAGE_MAP()
  172. // App command to run the dialog
  173. void DudesApp::OnAppAbout()
  174. {
  175.    CDialog aboutDlg(IDD_ABOUTBOX);
  176.    aboutDlg.DoModal();
  177. }
  178. /////////////////////////////////////////////////////////////////////////////
  179. // DudesApp commands
  180. void DudesApp::OnPause() 
  181. {
  182. CPauseDlg pauseDlg;
  183.     Game->PauseOn();
  184. pauseDlg.DoModal();
  185.     Game->PauseOff();
  186. }
  187. void DudesApp::OnOpenFile() 
  188. {
  189.     CFileDialog dialog(TRUE, "DUD", "dudes\*.dud",
  190.         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  191.         NULL, NULL);
  192.     Game->PauseOn();
  193.     dialog.m_ofn.Flags |= OFN_NOCHANGEDIR;
  194.     if (dialog.DoModal() == IDOK)
  195.     {
  196.         Game->Hero()->load(dialog.GetPathName());
  197.         Game->NewGame();
  198.     }
  199.     Game->PauseOff();
  200. }
  201. void DudesApp::OnSave() 
  202. {
  203.     Game->Hero()->save();
  204. }
  205. void DudesApp::OnSaveas() 
  206. {
  207.     CFileDialog dialog(FALSE, "DUD", Game->Hero()->filepath(),
  208.         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  209.         NULL, NULL);
  210.     Game->PauseOn();
  211.     dialog.m_ofn.Flags |= OFN_NOCHANGEDIR;
  212.     if (dialog.DoModal() == IDOK)
  213.         Game->Hero()->saveas(dialog.GetPathName());
  214.     Game->PauseOff();
  215. }
  216. void DudesApp::OnEdit() 
  217. {
  218.     CEditFile dialog;
  219.     Game->PauseOn();
  220.     if (dialog.DoModal() == IDOK)
  221.     {
  222.         Game->SetHero(dialog.getvalues());
  223.         Game->NewGame();
  224.     }
  225.     Game->PauseOff();
  226. }
  227. void DudesApp::OnHelp() 
  228. {
  229.     ::WinHelp(NULL, "3ddudes.hlp", HELP_FORCEFILE, 0);
  230. }
  231. void DudesApp::OnViewAerial() 
  232. {
  233.     Game->SetViewmode(AERIAL);
  234. }
  235. void DudesApp::OnViewCircling() 
  236. {
  237.     Game->SetViewmode(CIRCLING);
  238. }
  239. void DudesApp::OnViewDudeview() 
  240. {
  241.     Game->SetViewmode(DUDEVIEW);
  242. }
  243. void DudesApp::OnViewHighdudeview() 
  244. {
  245.     Game->SetViewmode(DUDEVIEWHIGH);
  246. }
  247. void DudesApp::OnViewLowdudeview() 
  248. {
  249.     Game->SetViewmode(DUDEVIEWLOW);
  250. }
  251. void DudesApp::OnViewLeftside() 
  252. {
  253.     Game->SetViewmode(LEFTSIDE);
  254. }
  255. void DudesApp::OnViewRightside() 
  256. {
  257.     Game->SetViewmode(RIGHTSIDE);
  258. }
  259. void DudesApp::OnViewHighangle() 
  260. {
  261.     Game->SetViewmode(HIGHANGLE);
  262. }
  263. void DudesApp::OnDetailChangedetail() 
  264. {
  265.     ChangeDetail dialog;
  266.     Game->PauseOn();
  267.     if (dialog.DoModal() == IDOK)
  268.         Game->NewGame();
  269.     Game->PauseOff();
  270. }
  271. void DudesApp::OnViewBackside() 
  272. {
  273.     Game->SetViewmode(BACKSIDE);
  274. }
  275. void DudesApp::OnViewFrontside() 
  276. {
  277.     Game->SetViewmode(FRONTSIDE);
  278. }
  279. #ifdef EDITOR
  280. void DudesApp::OnEditAddshape() 
  281. {
  282.     CFileDialog dialog(TRUE, "IMG", (CString)"landscpe\*.img",
  283.         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  284.         NULL, NULL);
  285.     Game->PauseOn();
  286.     dialog.m_ofn.Flags |= OFN_NOCHANGEDIR;
  287.     if (dialog.DoModal() == IDOK)
  288.     {
  289.         if (Game->LevelPtr()->selection)
  290.         {
  291.             Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  292.             Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  293.             Game->LevelPtr()->selection = 0;
  294.         }
  295.         Game->NewLandscape((CString) dialog.GetPathName());
  296.         coordinate ctmp = Game->Aim();
  297.         ctmp.sety(0.0f);
  298.         Game->LastLandscape()->setto(ctmp);
  299.     }
  300.     Game->PauseOff();
  301. }
  302. void DudesApp::OnEditSelectclosestshape() 
  303. {
  304.     qentry *tmp;
  305.     view    tmploc;
  306.     float   tmpval;
  307.     float   tmpdist = 100.0f;
  308.     qentry *newsel = 0;
  309.     tmp = (qentry *) Game->DrawQueue()->first(LANDSCAPE |
  310.                                      DUDEHOLDER |
  311.                                      WEAPONHOLDER |
  312.                                      TELEPORTER);
  313.     if (Game->LevelPtr()->selection)
  314.     {
  315.         Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  316.         Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  317.         Game->LevelPtr()->selection = 0;
  318.     }
  319.     while (tmp)
  320.     {
  321.         tmploc = ((landscape *)tmp)->location();
  322.         tmpval = tmploc.distanceto(Game->Aim());
  323.         if (tmpval < tmpdist)
  324.         {
  325.             tmpdist = tmpval;
  326.             newsel = tmp;
  327.         }
  328.         tmp = (qentry *) Game->DrawQueue()->next(LANDSCAPE |
  329.                                         DUDEHOLDER |
  330.                                         WEAPONHOLDER |
  331.                                         TELEPORTER);
  332.     }
  333.     if (newsel)
  334.     {
  335.         Game->LevelPtr()->selectioncolor = ((landscape *)newsel)->getcolor();
  336.         Game->LevelPtr()->selection = (landscape *) newsel;
  337.         Game->LevelPtr()->selection->RemoveLSEntry();
  338.     }
  339. }
  340. void DudesApp::OnEditMoveselectionbackward() 
  341. {
  342.     if (!Game->LevelPtr()->selection)
  343.         return;
  344.     view tmp = Game->LevelPtr()->selection->location();
  345.     tmp.setx(tmp.x()+tcsin(tmp.ydirection(),-Game->LevelPtr()->selectionstep));
  346.     tmp.setz(tmp.z()+tccos(tmp.ydirection(),-Game->LevelPtr()->selectionstep));
  347.     Game->LevelPtr()->selection->setto(tmp);
  348. }
  349. void DudesApp::OnEditMoveselectiondown() 
  350. {
  351.     if (!Game->LevelPtr()->selection)
  352.         return;
  353.     view tmp = Game->LevelPtr()->selection->location();
  354.     tmp.sety(tmp.y()-Game->LevelPtr()->selectionstep);
  355.     Game->LevelPtr()->selection->setto(tmp);
  356. }
  357. void DudesApp::OnEditMoveselectionfoward() 
  358. {
  359.     if (!Game->LevelPtr()->selection)
  360.         return;
  361.     view tmp = Game->LevelPtr()->selection->location();
  362.     tmp.setx(tmp.x()+tcsin(tmp.ydirection(),Game->LevelPtr()->selectionstep));
  363.     tmp.setz(tmp.z()+tccos(tmp.ydirection(),Game->LevelPtr()->selectionstep));
  364.     Game->LevelPtr()->selection->setto(tmp);
  365. }
  366. void DudesApp::OnEditMoveselectionleft() 
  367. {
  368.     if (!Game->LevelPtr()->selection)
  369.         return;
  370.     view tmp = Game->LevelPtr()->selection->location();
  371.     tmp.setx(tmp.x()+tcsin(tmp.ydirection()+(direction)TC_PI_2,Game->LevelPtr()->selectionstep));
  372.     tmp.setz(tmp.z()+tccos(tmp.ydirection()+(direction)TC_PI_2,Game->LevelPtr()->selectionstep));
  373.     Game->LevelPtr()->selection->setto(tmp);
  374. }
  375. void DudesApp::OnEditMoveselectionright() 
  376. {
  377.     if (!Game->LevelPtr()->selection)
  378.         return;
  379.     view tmp = Game->LevelPtr()->selection->location();
  380.     tmp.setx(tmp.x()+tcsin(tmp.ydirection()-(direction)TC_PI_2,Game->LevelPtr()->selectionstep));
  381.     tmp.setz(tmp.z()+tccos(tmp.ydirection()-(direction)TC_PI_2,Game->LevelPtr()->selectionstep));
  382.     Game->LevelPtr()->selection->setto(tmp);
  383. }
  384. void DudesApp::OnEditChangecolorforselection() 
  385. {
  386.     if (!Game->LevelPtr()->selection)
  387.         return;
  388.     CColorDialog dialog(Game->LevelPtr()->selection->getcolor(), NULL, NULL);
  389.     if (dialog.DoModal() == IDOK)
  390.     {
  391.         view tmploc = Game->LevelPtr()->selection->location();
  392.         LSEntryType *tmpls = Game->Landscapes()->GetLSEntry(tmploc);
  393.         Game->LevelPtr()->selectioncolor = dialog.GetColor();
  394.         if (tmpls)
  395.             tmpls->Color = dialog.GetColor();
  396.     }
  397. }
  398. void DudesApp::OnEditMoveselectionup() 
  399. {
  400.     if (!Game->LevelPtr()->selection)
  401.         return;
  402.     view tmp = Game->LevelPtr()->selection->location();
  403.     tmp.sety(tmp.y()+Game->LevelPtr()->selectionstep);
  404.     Game->LevelPtr()->selection->setto(tmp);
  405. }
  406. void DudesApp::OnEditRotateselection45degreesleft() 
  407. {
  408.     if (!Game->LevelPtr()->selection)
  409.         return;
  410.     view tmp = Game->LevelPtr()->selection->location();
  411.     tmp.setydir(tmp.ydirection()+(direction)TC_PI_4);
  412.     Game->LevelPtr()->selection->setto(tmp);
  413. }
  414. void DudesApp::OnEditRotateselection45degreesright() 
  415. {
  416.     if (!Game->LevelPtr()->selection)
  417.         return;
  418.     view tmp = Game->LevelPtr()->selection->location();
  419.     tmp.setydir(tmp.ydirection()-(direction)TC_PI_4);
  420.     Game->LevelPtr()->selection->setto(tmp);
  421. }
  422. void DudesApp::OnEditRotateselection90degreesleft() 
  423. {
  424.     if (!Game->LevelPtr()->selection)
  425.         return;
  426.     view tmp = Game->LevelPtr()->selection->location();
  427.     tmp.setydir(tmp.ydirection()+(direction)TC_PI_2);
  428.     Game->LevelPtr()->selection->setto(tmp);
  429. }
  430. void DudesApp::OnEditRotateselection90degreesright() 
  431. {
  432.     if (!Game->LevelPtr()->selection)
  433.         return;
  434.     view tmp = Game->LevelPtr()->selection->location();
  435.     tmp.setydir(tmp.ydirection()-(direction)TC_PI_2);
  436.     Game->LevelPtr()->selection->setto(tmp);
  437. }
  438. void DudesApp::OnEditDeleteselection() 
  439. {
  440.     if (!Game->LevelPtr()->selection)
  441.         return;
  442.     Game->LevelPtr()->selection->DeleteEntryAlso();
  443.     delete Game->LevelPtr()->selection;
  444.     Game->LevelPtr()->selection = 0;
  445. }
  446. void DudesApp::OnFileOpenlandscape() 
  447. {
  448.     CFileDialog dialog(TRUE, "MAP", "*.map",
  449.         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  450.         NULL, NULL);
  451.     Game->PauseOn();
  452.     dialog.m_ofn.Flags |= OFN_NOCHANGEDIR;
  453.     if (dialog.DoModal() == IDOK)
  454.     {
  455.         OnFileSavelandscape();
  456.         Game->NewGame();
  457.         Game->Landscapes()->load((CString)dialog.GetPathName());
  458.         Game->LevelPtr()->selection = NULL;
  459.         view ctmp = Game->Landscapes()->GeneralArea();
  460.         Game->LevelPtr()->SetGuyTo(ctmp);
  461.     }
  462.     Game->PauseOff();
  463. }
  464. void DudesApp::OnFileSavelandscape() 
  465. {
  466.     OnEditUnselecttheselection();
  467.     Game->Landscapes()->save();
  468. }
  469. void DudesApp::OnFileSavelandscapeas() 
  470. {
  471.     OnEditUnselecttheselection();
  472.     CFileDialog dialog(FALSE, "MAP", getpath((CString)"landscpe.map"),
  473.         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  474.         NULL, NULL);
  475.     Game->PauseOn();
  476.     dialog.m_ofn.Flags |= OFN_NOCHANGEDIR;
  477.     if (dialog.DoModal() == IDOK)
  478.     {
  479.         Game->LevelPtr()->landscapemap = (CString)dialog.GetPathName();
  480.         OnFileSavelandscape();
  481.     }
  482.     Game->PauseOff();
  483. }
  484. void DudesApp::OnEditUnselecttheselection() 
  485. {
  486.     if (!Game->LevelPtr()->selection)
  487.         return;
  488.     Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  489.     Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  490.     Game->LevelPtr()->selection = NULL;
  491. }
  492. void DudesApp::OnEditAddnewmap() 
  493. {
  494.     CFileDialog dialog(FALSE, "MAP", getpath((CString)"landscpe.map"),
  495.         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  496.         NULL, NULL);
  497.     Game->PauseOn();
  498.     dialog.m_ofn.Flags |= OFN_NOCHANGEDIR;
  499.     if (dialog.DoModal() == IDOK)
  500.     {
  501.         if (Game->LevelPtr()->selection)
  502.         {
  503.             Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  504.             Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  505.             Game->LevelPtr()->selection = 0;
  506.         }
  507.         Game->NewGateway((CString)dialog.GetPathName());
  508.         coordinate ctmp = Game->Aim();
  509.         ctmp.sety(0.0f);
  510.         Game->LastLandscape()->setto(ctmp);
  511.     }
  512.     Game->PauseOff();
  513. }
  514. void DudesApp::OnEditAdddude() 
  515. {
  516.     CFileDialog dialog(TRUE, "DUD", (CString)"dudes\*.dud",
  517.         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
  518.         NULL, NULL);
  519.     Game->PauseOn();
  520.     dialog.m_ofn.Flags |= OFN_NOCHANGEDIR;
  521.     if (dialog.DoModal() == IDOK)
  522.     {
  523.         if (Game->LevelPtr()->selection)
  524.         {
  525.             Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  526.             Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  527.             Game->LevelPtr()->selection = 0;
  528.         }
  529.         Game->NewDudeholder((CString)dialog.GetPathName());
  530.         coordinate ctmp = Game->Aim();
  531.         ctmp.sety(0.0f);
  532.         Game->LastLandscape()->setto(ctmp);
  533.         SpeedDiag dialog;
  534.         if (dialog.DoModal() == IDOK)
  535.         {
  536.         short sptmp = (short)dialog.Position();
  537.             sptmp = (short) (10.0f * ((float) sptmp / 100.0f));
  538.             sptmp = (short) (10 - sptmp);
  539.             personal ptmp;
  540.             dudeholder *tmp = (dudeholder *) Game->LastLandscape();
  541.             ptmp.load(tmp->dudename());
  542.             if (ptmp.gender() == MALE)
  543.                 sptmp += 10;
  544.             tmp->setspeed(sptmp);
  545.         }
  546.     }
  547.     Game->PauseOff();
  548. }
  549. void DudesApp::OnEditAddnextlevelteleporter() 
  550. {
  551.     CTeleportDiag dialog;
  552.     Game->PauseOn();
  553.     if (dialog.DoModal() == IDOK)
  554.     {
  555.         if (Game->LevelPtr()->selection)
  556.         {
  557.             Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  558.             Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  559.             Game->LevelPtr()->selection = 0;
  560.         }
  561.         Game->NewTeleporter((short)(dialog.m_LevelNum));
  562.         coordinate ctmp = Game->Aim();
  563.         ctmp.sety(0.0f);
  564.         Game->LastLandscape()->setto(ctmp);
  565.     }
  566.     Game->PauseOff();
  567. }
  568. void DudesApp::OnEditAddhandheldweaponKnife() 
  569. {
  570.     if (Game->LevelPtr()->selection)
  571.     {
  572.         Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  573.         Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  574.         Game->LevelPtr()->selection = 0;
  575.     }
  576.     Game->NewWeaponholder(KNIFE);
  577.     coordinate ctmp = Game->Aim();
  578.     ctmp.sety(0.0f);
  579.     Game->LastLandscape()->setto(ctmp);
  580. }
  581. void DudesApp::OnEditAddhandheldweaponShield() 
  582. {
  583.     if (Game->LevelPtr()->selection)
  584.     {
  585.         Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  586.         Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  587.         Game->LevelPtr()->selection = 0;
  588.     }
  589.     Game->NewWeaponholder(SHIELD);
  590.     coordinate ctmp = Game->Aim();
  591.     ctmp.sety(0.0f);
  592.     Game->LastLandscape()->setto(ctmp);
  593. }
  594. void DudesApp::OnEditAddhandheldweaponSword() 
  595. {
  596.     if (Game->LevelPtr()->selection)
  597.     {
  598.         Game->LevelPtr()->selection->setcolor(Game->LevelPtr()->selectioncolor);
  599.         Game->Landscapes()->AddLSEntry(Game->LevelPtr()->selection);
  600.         Game->LevelPtr()->selection = 0;
  601.     }
  602.     Game->NewWeaponholder(SWORD);
  603.     coordinate ctmp = Game->Aim();
  604.     ctmp.sety(0.0f);
  605.     Game->LastLandscape()->setto(ctmp);
  606. }
  607. #endif
  608. CWnd* DudesApp::GetMainWnd() 
  609. {
  610.     switch(keyboardcontrol)
  611.     {
  612.     case V1:
  613.         OnViewCircling();
  614.         break;
  615.     case V2:
  616.         OnViewDudeview();
  617.         break;
  618.     case V3:
  619.         OnViewHighdudeview();
  620.         break;
  621.     case V4:
  622.         OnViewLowdudeview();
  623.         break;
  624.     case V5:
  625.         OnViewAerial();
  626.         break;
  627.     case V6:
  628.         OnViewHighangle();
  629.         break;
  630.     case V7:
  631.         OnViewRightside();
  632.         break;
  633.     case V8:
  634.         OnViewLeftside();
  635.         break;
  636.     case V9:
  637.         OnViewFrontside();
  638.         break;
  639.     case V0:
  640.         OnViewBackside();
  641.         break;
  642.     }
  643. return CWinApp::GetMainWnd();
  644. }