home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / v / vol1n7.zip / MENU.C < prev    next >
Text File  |  1992-10-10  |  3KB  |  80 lines

  1. /* MENU.C - Menu control functions
  2.  
  3. Copyright (c) 1992 Timur Tabi
  4. Copyright (c) 1992 Fasa Corporation
  5.  
  6. The following trademarks are the property of Fasa Corporation:
  7. BattleTech, CityTech, AeroTech, MechWarrior, BattleMech, and 'Mech.
  8. The use of these trademarks should not be construed as a challenge to these marks.
  9.  
  10. This module handles all the menu-related functions.
  11. */
  12.  
  13. #define MENU_C
  14. #define INCL_WINDIALOGS
  15. #define INCL_WINMESSAGEMGR
  16. #define INCL_WINMENUS
  17. #include <os2.h>
  18. #include "game.h"
  19. #include "dialog.h"
  20. #include "menu.h"
  21. #include "files.h"
  22.  
  23. void InitMenu(void) {
  24.   usCurTer=IDM_TER_CLEAR_GROUND; 
  25.   eMode=MODE_TARGET;
  26. }
  27.  
  28. MRESULT EXPENTRY AboutDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
  29.   if (msg == WM_COMMAND && SHORT1FROMMP(mp1) == DID_OK) {
  30.     WinDismissDlg(hwnd,TRUE);
  31.     return 0;
  32.   }
  33.   return WinDefDlgProc(hwnd,msg,mp1,mp2);
  34. }
  35.  
  36. void MainCommand(USHORT usCmd) {
  37.   extern HWND hwndFrame,hwndClient,hwndMenu;
  38.  
  39.   switch (usCmd) {
  40.     case IDM_ABOUT:
  41.       WinDlgBox(HWND_DESKTOP,hwndFrame,AboutDlgProc,NULLHANDLE,IDD_ABOUT,NULL);
  42.       break;
  43.     case IDM_FILE_LOAD:
  44.       LoadMap(hwndFrame);
  45. // Now show the new map.
  46.       WinInvalidateRect(hwndClient,NULL,FALSE);   // Make sure the old map is erased
  47.       WinPostMsg(hwndClient,WM_PAINT,0,0);        // Draws the new map
  48.       break;
  49.     case IDM_FILE_SAVE_AS:
  50.       SaveMap(hwndFrame);
  51.       break;
  52.     case IDM_TER_CLEAR_GROUND:
  53.     case IDM_TER_ROUGH_GROUND:
  54.     case IDM_TER_WATER:
  55.     case IDM_TER_LIGHT_WOODS:
  56.     case IDM_TER_HEAVY_WOODS:
  57.     case IDM_TER_PAVEMENT:
  58.     case IDM_TER_BRIDGE:
  59.     case IDM_TER_LIGHT_BLDG:
  60.     case IDM_TER_MEDIUM_BLDG:
  61.     case IDM_TER_HEAVY_BLDG:
  62.     case IDM_TER_HARD_BLDG:
  63.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(usCurTer,TRUE),MPFROM2SHORT(MIA_CHECKED,0));
  64.       usCurTer=usCmd;
  65.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(usCurTer,TRUE),MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  66.       break;
  67.     case IDM_MODE_EDIT:
  68.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(IDM_MODE_TARGET,TRUE),MPFROM2SHORT(MIA_CHECKED,0));
  69.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(IDM_MODE_EDIT,TRUE),MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  70.       eMode=MODE_EDIT;
  71.       break;
  72.     case IDM_MODE_TARGET:
  73.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(IDM_MODE_EDIT,TRUE),MPFROM2SHORT(MIA_CHECKED,0));
  74.       WinSendMsg(hwndMenu,MM_SETITEMATTR,MPFROM2SHORT(IDM_MODE_TARGET,TRUE),MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
  75.       eMode=MODE_TARGET;
  76.       break;
  77.   }
  78. }
  79.  
  80.