home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / game / think / chaos / src / playersami.c < prev    next >
C/C++ Source or Header  |  1994-11-19  |  26KB  |  770 lines

  1. /*  Chaos:            The Chess HAppening Organisation System    V5.3
  2.     Copyright (C)   1993    Jochen Wiedmann
  3.  
  4.     This program is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19.     $RCSfile: PlayersAmi.c,v $
  20.     $Revision: 3.2 $
  21.     $Date: 1994/11/19 19:32:01 $
  22.  
  23.     This file contains the system dependent functions for the Players menu.
  24.  
  25.     Computer:    Amiga 1200            Compiler:    Dice 2.07.54 (3.0)
  26.  
  27.     Author:    Jochen Wiedmann
  28.         Am Eisteich 9
  29.       72555 Metzingen
  30.         Tel. 07123 / 14881
  31.         Internet: wiedmann@mailserv.zdv.uni-tuebingen.de
  32. */
  33.  
  34.  
  35. #ifndef CHAOS_H
  36. #include "chaos.h"
  37. #endif
  38.  
  39.  
  40.  
  41.  
  42. /*
  43.     AskExtContinue() brings up a requester asking a question and lets the
  44.     user select between different possibilities.
  45.  
  46.     Inputs: str     a printf()-like format string
  47.         buttons a string containing the different choices, separated by
  48.             a '|', for example "Yes|No|Cancel"
  49.         Other arguments may follow. These are used in the format string.
  50.  
  51.     Results: 0 for the rightmost choice and 1, 2, 3, ... for the other
  52.          choices. (In the "Yes|No|Cancel" example this would be 1 for
  53.          "Yes", 2 for "No" and 0 for "Cancel".
  54. */
  55. int AskExtContinue(char *str, char *buttons, ...)
  56.  
  57. #ifdef AMIGA
  58. { return(MUI_RequestA(App, MainWnd, 0, (char *) GetChaosString(MSG_ATTENTION),
  59.               buttons, str, (APTR) ((&buttons)+1)));
  60. }
  61. #endif
  62.  
  63.  
  64.  
  65.  
  66. /*
  67.     The AskContinue() function brings up a requester asking a Yes/No
  68.     question like "Do you really want to delete player p?"
  69.  
  70.     Inputs: a printf()-like format string, possibly followed by
  71.         the corresponding arguments.
  72.  
  73.     Results: TRUE, if the user selected Ok, FALSE otherwise
  74. */
  75. int AskContinue(char *str, ...)
  76.  
  77. #ifdef AMIGA
  78. { return(MUI_RequestA(App, MainWnd, 0,
  79.               (char *) GetChaosString(MSG_ATTENTION),
  80.               (char *) GetChaosString(MSG_YES_NO),
  81.               str, (APTR) ((&str)+1)));
  82. }
  83. #endif    /*  AMIGA   */
  84.  
  85.  
  86.  
  87.  
  88. /*
  89.     The TerminatePlrWnd() function deletes the window that allows to edit
  90.     players.
  91. */
  92. #ifdef AMIGA
  93. static APTR PlrWnd = NULL;  /*    Player window                */
  94. static APTR PlrOkGad;        /*    Ok gadget (player window)           */
  95. static APTR PlrCancelGad;   /*    Cancel gadget (player window)       */
  96. static APTR NameGad;        /*    Name gadget                */
  97. static APTR StreetGad;        /*    Street gadget                */
  98. static APTR VillageGad;     /*    Village gadget                */
  99. static APTR ChessClubGad;   /*    Chess club gadget            */
  100. static APTR PhoneGad;        /*    Phone gadget                */
  101. static APTR BirthdayGad;    /*    Birthday gadget             */
  102. static APTR DWZGad;        /*    DWZ gadget                */
  103. static APTR ELOGad;        /*    ELO gadget                */
  104. static APTR SeniorGad;        /*    Senior gadget                */
  105. static APTR JuniorGad;        /*    Junior gadget                */
  106. static APTR WomanGad;        /*    Woman gadget                */
  107. static APTR JuniorAGad;     /*    Junior (A) gadget                   */
  108. static APTR JuniorBGad;     /*    Junior (B) gadget                   */
  109. static APTR JuniorCGad;     /*    Junior (C) gadget                   */
  110. static APTR JuniorDGad;     /*    Junior (D) gadget                   */
  111. static APTR JuniorEGad;     /*    Junior (E) gadget                   */
  112. void TerminatePlrWnd(void)
  113.  
  114. { if (PlrWnd != NULL)
  115.   { set(PlrWnd, MUIA_Window_Open, FALSE);
  116.     DoMethod(App, OM_REMMEMBER, PlrWnd);
  117.     MUI_DisposeObject(PlrWnd);
  118.     PlrWnd = NULL;
  119.   }
  120. }
  121. #endif    /*  AMIGA   */
  122.  
  123.  
  124.  
  125.  
  126. /*
  127.     The InitPlrWnd() function creates the window that allows to edit
  128.     a player.
  129.  
  130.     Inputs:    title    the windows title
  131.  
  132.     Results:    TRUE, if successful, FALSE otherwise
  133. */
  134. #define ID_PlrWnd_Cancel    303
  135. #define ID_PlrWnd_Ok        304
  136. int InitPlrWnd(char *title)
  137.  
  138. #ifdef AMIGA
  139. { int Ok_SC = *GetChaosString(MSG_OK_SC);
  140.   int Cancel_SC = *GetChaosString(MSG_CANCEL_SC);
  141.  
  142.   PlrWnd = WindowObject,
  143.         MUIA_Window_ID, MAKE_ID('P','L','R','I'),
  144.         MUIA_Window_Width, MUIV_Window_Width_MinMax(50),
  145.         MUIA_Window_Title, title,
  146.         WindowContents, VGroup,
  147.         Child, HGroup,
  148.             Child, VGroup,
  149.             MUIA_Weight, 300,
  150.             Child, ColGroup(2),
  151.                 Child, Label2(GetChaosString(MSG_NAME_INPUT)),
  152.                 Child, NameGad = StringObject,
  153.                 StringFrame,
  154.                 MUIA_String_MaxLen, NAMELEN+1,
  155.                 End,
  156.                 Child, Label2(GetChaosString(MSG_STREET_INPUT)),
  157.                 Child, StreetGad = StringObject,
  158.                 StringFrame,
  159.                 MUIA_String_MaxLen, NAMELEN+1,
  160.                 End,
  161.                 Child, Label2(GetChaosString(MSG_VILLAGE_INPUT)),
  162.                 Child, VillageGad = StringObject,
  163.                 StringFrame,
  164.                 MUIA_String_MaxLen, NAMELEN+1,
  165.                 End,
  166.                 Child, Label2(GetChaosString(MSG_CHESS_CLUB_INPUT)),
  167.                 Child, ChessClubGad = StringObject,
  168.                 StringFrame,
  169.                 MUIA_String_MaxLen, NAMELEN+1,
  170.                 End,
  171.                 Child, Label2(GetChaosString(MSG_PHONE_INPUT)),
  172.                 Child, PhoneGad = StringObject,
  173.                 StringFrame,
  174.                 MUIA_String_MaxLen, PHONENRLEN+1,
  175.                 End,
  176.                 Child, Label2(GetChaosString(MSG_BIRTHDAY_INPUT)),
  177.                 Child, BirthdayGad = StringObject,
  178.                 StringFrame,
  179.                 MUIA_String_MaxLen, BIRTHDAYLEN+1,
  180.                 End,
  181.             End,
  182.             Child, HGroup,
  183.                 Child, Label2(GetChaosString(MSG_DWZ_INPUT)),
  184.                 Child, DWZGad = StringObject, StringFrame,
  185.                 MUIA_String_MaxLen, DWZLEN+1,
  186.                 MUIA_String_Accept, "0123456789-",
  187.                 End,
  188.                 Child, HSpace(0),
  189.                 Child, Label2(GetChaosString(MSG_ELO_INPUT)),
  190.                 Child, ELOGad = StringObject, StringFrame,
  191.                 MUIA_String_MaxLen, DWZLEN+1,
  192.                 MUIA_String_Accept, "0123456789",
  193.                 End,
  194.             End,
  195.             End,
  196.             Child, MUI_NewObject(MUIC_Rectangle,
  197.             MUIA_Weight, 50,
  198.             End,
  199.             Child, ColGroup(2),
  200.             Child, SeniorGad = CheckMark(FALSE),
  201.             Child, Label2(GetChaosString(MSG_SENIORS_INPUT)),
  202.             Child, JuniorGad = CheckMark(FALSE),
  203.             Child, Label2(GetChaosString(MSG_JUNIORS_INPUT)),
  204.             Child, WomanGad = CheckMark(FALSE),
  205.             Child, Label2(GetChaosString(MSG_WOMEN_INPUT)),
  206.             Child, JuniorAGad = CheckMark(FALSE),
  207.             Child, Label2(GetChaosString(MSG_JUNIORSA_INPUT)),
  208.             Child, JuniorBGad = CheckMark(FALSE),
  209.             Child, Label2(GetChaosString(MSG_JUNIORSB_INPUT)),
  210.             Child, JuniorCGad = CheckMark(FALSE),
  211.             Child, Label2(GetChaosString(MSG_JUNIORSC_INPUT)),
  212.             Child, JuniorDGad = CheckMark(FALSE),
  213.             Child, Label2(GetChaosString(MSG_JUNIORSD_INPUT)),
  214.             Child, JuniorEGad = CheckMark(FALSE),
  215.             Child, Label2(GetChaosString(MSG_JUNIORSE_INPUT)),
  216.             End,
  217.         End,
  218.         Child, HGroup,
  219.             MUIA_Group_SameSize, TRUE,
  220.             Child, PlrOkGad = KeyButton(GetChaosString(MSG_OK), Ok_SC),
  221.             Child, HSpace(0),
  222.             Child, HSpace(0),
  223.             Child, PlrCancelGad = KeyButton(GetChaosString(MSG_CANCEL_INPUT), Cancel_SC),
  224.         End,
  225.         End,
  226.     End;
  227.  
  228.   if (!PlrWnd)
  229.   { return(FALSE);
  230.   }
  231.   DoMethod(App, OM_ADDMEMBER, PlrWnd);
  232.  
  233.   /*
  234.       Setting up the notification events for the player input window
  235.   */
  236.   DoMethod(PlrWnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
  237.        MUIM_Application_ReturnID, ID_PlrWnd_Cancel);
  238.   DoMethod(PlrWnd, MUIM_Notify, MUIA_Window_InputEvent, "ctrl return",
  239.        App, 2, MUIM_Application_ReturnID, ID_PlrWnd_Ok);
  240.   DoMethod(PlrOkGad, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  241.        MUIM_Application_ReturnID, ID_PlrWnd_Ok);
  242.   DoMethod(PlrCancelGad, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
  243.        MUIM_Application_ReturnID, ID_PlrWnd_Cancel);
  244.  
  245.   /*
  246.       Setting up the cycle chain in the player input window
  247.   */
  248.   DoMethod(PlrWnd, MUIM_Window_SetCycleChain,
  249.        NameGad, StreetGad, VillageGad, ChessClubGad, PhoneGad,
  250.        BirthdayGad, DWZGad, ELOGad, PlrOkGad, PlrCancelGad,
  251.        SeniorGad, JuniorGad, WomanGad, JuniorAGad, JuniorBGad,
  252.        JuniorCGad, JuniorDGad, JuniorEGad, NULL);
  253.   DoMethod(NameGad, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
  254.        PlrWnd, 3