home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Games 3 / cd.iso / os2 / pmgnuchs / initmenu.c < prev    next >
Text File  |  1994-04-20  |  5KB  |  163 lines

  1. //
  2. //  Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  3. //  Copyright (c) 1988, 1989, 1990  John Stanback
  4. //
  5. //  Project:    OS/2 PM Port of GNU CHESS 4.0 (PmChess)
  6. //
  7. //  Version:    1994-4-17
  8. //
  9. //   Porter:    Ported to Windows 3.0 by Darly Baker
  10. //
  11. //   Porter:    Ported to OS/2 1.2+ by Kent Cedola
  12. //
  13. //   Porter:    Revised and ported to OS/2 2.1 by Yibing Fan
  14. //
  15. //   System:    OS2 2.1 using emx0.8g 
  16. //
  17. //  Remarks:    This code modified to change menu logic
  18. //
  19. //
  20.  
  21. #define INCL_DOS
  22. #define INCL_PM
  23. #include <os2.h>
  24. #include "PmChess.h"
  25. #include "GnuChess.h"
  26. #include "Resource.h"
  27.  
  28. extern int coords;
  29. extern int UseBook;
  30. extern int User_Move;
  31. extern BOOL fHelpEnabled;     /* flag to determine if help is enabled, declared in help.c */
  32.  
  33. void EnableMenuItem(HWND hwndMenu, USHORT idItem, BOOL bEnable)
  34.   {
  35.   if (bEnable)
  36.     WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(idItem, TRUE),
  37.                MPFROM2SHORT(MIA_DISABLED, 0));
  38.   else
  39.     WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(idItem, TRUE),
  40.                MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
  41.   }
  42.  
  43.  
  44. void CheckMenuItem(HWND hwndMenu, USHORT idItem, BOOL bCheck)
  45.   {
  46.   if (bCheck)
  47.     WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(idItem, TRUE),
  48.                MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED));
  49.   else
  50.     WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(idItem, TRUE),
  51.                MPFROM2SHORT(MIA_CHECKED, 0));
  52.   }
  53.  
  54.  
  55. void Init_Menus(HWND hWnd, MPARAM mp1, MPARAM mp2)
  56.   {
  57.   HWND   hwndMenu;
  58.   USHORT Status;
  59.  
  60.  
  61.   hwndMenu = HWNDFROMMP(mp2);
  62.  
  63.   switch (SHORT1FROMMP(mp1))
  64.     {
  65.     case IDM_FILE:
  66.       EnableMenuItem(hwndMenu, IDM_FILE_NEW,
  67.                              (!flag.bothsides ? TRUE : FALSE) );
  68.     case IDM_EDIT:
  69.       EnableMenuItem(hwndMenu, IDM_EDIT_GAME,
  70.                              (GameCnt>0 ? TRUE : FALSE) );
  71.       EnableMenuItem(hwndMenu, IDM_EDIT_UNDO,
  72.                              (flag.easy&flag.timeout&!flag.bothsides&GameCnt>0 ? TRUE : FALSE) );
  73.       EnableMenuItem(hwndMenu, IDM_EDIT_REMOVE,
  74.                              (flag.easy&flag.timeout&!flag.bothsides&GameCnt>1 ? TRUE : FALSE) );
  75.       if ( flag.force == false)  Status = FALSE; else Status = TRUE;
  76.       CheckMenuItem ( hwndMenu, IDM_EDIT_FORCE, Status);
  77.       break;
  78.  
  79.     case IDM_OPTIONS:
  80.       if ( flag.hash == false)  Status = FALSE; else Status = TRUE;
  81.       CheckMenuItem ( hwndMenu, IDM_OPTIONS_HASH, Status);
  82.  
  83.       if ( coords == false)  Status = FALSE; else Status = TRUE;
  84.       CheckMenuItem ( hwndMenu, IDM_OPTIONS_COOR, Status);
  85.       EnableMenuItem(hwndMenu, IDM_OPTIONS_COOR,
  86.                              (flag.bothsides|!User_Move|!flag.easy ? FALSE : TRUE) );
  87.  
  88.       if ( flag.beep == false)  Status = FALSE; else Status = TRUE;
  89.       CheckMenuItem ( hwndMenu, IDM_OPTIONS_TONE, Status);
  90.  
  91.       if ( flag.bothsides == false)  Status = FALSE; else Status = TRUE;
  92.       CheckMenuItem ( hwndMenu, IDM_OPTIONS_BOTH, Status);
  93.  
  94.       if ( !UseBook )  Status = FALSE; else Status = TRUE;
  95.       CheckMenuItem ( hwndMenu, IDM_OPTIONS_BOOK, Status);
  96.  
  97.       if ( flag.post == false)  Status = FALSE; else Status = TRUE;
  98.       CheckMenuItem ( hwndMenu, IDM_OPTIONS_STATS, Status);
  99.       break;
  100.  
  101.     case IDM_SKILL:
  102.       if ( dither == 0)
  103.         Status = FALSE; else Status = TRUE;
  104.       CheckMenuItem ( hwndMenu, IDM_SKILL_RANDOM, Status);
  105.   
  106.       if ( flag.easy == false)
  107.         Status = TRUE; else Status = FALSE;
  108.       CheckMenuItem ( hwndMenu, IDM_SKILL_EASY, Status);
  109.  
  110.       EnableMenuItem(hwndMenu, IDM_SKILL_EASY,
  111.                              (flag.bothsides ? FALSE : TRUE) );
  112.  
  113.       break;
  114.  
  115.     case IDM_SIDE:
  116.       if ( flag.reverse == false)
  117.         Status = FALSE; else Status = TRUE;
  118.        CheckMenuItem ( hwndMenu, IDM_SIDE_REVERSE, Status);
  119.  
  120.       EnableMenuItem(hwndMenu, IDM_SIDE_REVERSE,
  121.                              (flag.bothsides|!User_Move|!flag.easy  ? FALSE : TRUE) );
  122.  
  123.       if (computer == black)
  124.         {
  125.         CheckMenuItem(hwndMenu, IDM_SIDE_BLACK, TRUE);
  126.         CheckMenuItem(hwndMenu, IDM_SIDE_WHITE, FALSE);
  127.         }
  128.       else
  129.         {
  130.         CheckMenuItem(hwndMenu, IDM_SIDE_WHITE, TRUE);
  131.         CheckMenuItem(hwndMenu, IDM_SIDE_BLACK, FALSE);
  132.         }
  133.  
  134.       EnableMenuItem(hwndMenu, IDM_SIDE_SWITCH,
  135.                              (flag.bothsides|!User_Move|!flag.easy ? FALSE : TRUE) );
  136.  
  137.       EnableMenuItem(hwndMenu, IDM_SIDE_WHITE,
  138.                              (flag.bothsides|!User_Move|!flag.easy ? FALSE : TRUE) );
  139.  
  140.       EnableMenuItem(hwndMenu, IDM_SIDE_BLACK,
  141.                              (flag.bothsides|!User_Move|!flag.easy  ? FALSE : TRUE) );
  142.  
  143.       break;
  144.  
  145.      case IDM_HELP:
  146.             /*
  147.              * Enable or disable the Help menu depending upon whether the
  148.              * help manager has been enabled
  149.              */
  150.         EnableMenuItem(hwndMenu, IDM_HELP_DISPLAY, fHelpEnabled);
  151.         EnableMenuItem(hwndMenu, IDM_HELP_EXT, fHelpEnabled);
  152.         EnableMenuItem(hwndMenu, IDM_HELP_KEYS, fHelpEnabled);
  153.         EnableMenuItem(hwndMenu, IDM_HELP_INDEX, fHelpEnabled);
  154.  
  155.          /*  REMEMBER: add a case for IDM_HELPTUTORIAL if you include
  156.           *  the Tutorial menu item.
  157.           */
  158.  
  159.        break;
  160.  
  161.     }
  162.   }
  163.