home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / MODS / ALLMODS.ZIP / FMD-13B.ZIP / FMD-13B.MOD < prev    next >
Encoding:
Text File  |  1995-06-01  |  12.9 KB  |  502 lines

  1.  
  2.    ┌┬─── ──  ─   ─  ── ───────────────────────────────────────────────────┬─ ∙∙
  3.    ││                    Alternative Worlds Presents                      │
  4.    └┼─────────────────────────────────────────────────────────────────────┐
  5.    ││ Mod Name       » FMD-13b.MOD                                        │∙
  6.    ││ Difficulty     » █▒▒▒▒▒▒▒▒▒▒ (1/10)                                 │:
  7.    ││ WWIV Version   » 4.24                                               ││
  8.    ││ Date Affected  » 06/01/95                                           ││
  9.    :│ Files Affected » COM.C                                              ││
  10.    ∙│ Description    » Multilingual Question Prompts Toggable With Space  ││
  11.     └─────────────────────────────────────────────────────────────────────┼┐
  12.     │       A French Mod Division Release - (C) 1995 FMD Software         ││
  13. ∙∙ ─┴─────────────────────────────────────────────────── ──  ─   ─  ── ───└┘
  14.  
  15.        => CERTIFIED MOD OF THE MONTH IN WWIVNEWS FOR MAY-JUNE 1994 <=
  16.  
  17.  ┌┬══════════════════┐
  18.  ││ Long Description ││
  19.   └══════════════════┴┘
  20.  
  21.     This modification will give you question prompts when prompting you
  22. for a yes, no or quit. You will be able to select your option by pressing
  23. the letter directly or by pressing SPACE to toggle to the next option available
  24. and it supports multi-languages, it will fit with EVERY language you may have
  25. on your system. This will replace yes/no prompts and yes/no/quit prompts on
  26. your system.
  27.  
  28. Revision A:
  29.  
  30.   Bugs fixed:
  31.  
  32.   - Y/N/Q prompt was moving the wrong way, now moves forward.
  33.   - 424 version has problem to redraw the prompts due to RIP code, this is
  34.     now fixed.
  35.  
  36.   Improvements:
  37.  
  38.   - Arrow Keys support, can now use the arrow keys to toggle the prompt, as
  39.     long as the usual space bar. (Partial code done by JAFO)
  40.   - Ascii prompts now put the selection in upper case, last version showed no
  41.     change between the selections. (Idea from Natas)
  42.   - Implantation of a function called GetAllKeys, that will allow you to use
  43.     the arrow keys and Home/End/Esc key ANYWHERE in WWIV if you replace
  44.     "getkey" by this function.
  45.  
  46. Revision B:
  47.  
  48.   - Updating for WWIV v4.24
  49.   - Fixed the problem with the "ENTER" call.
  50.  
  51.  ┌┬═══════┐
  52.  ││ Tests ││
  53.   └═══════┴┘
  54.  
  55.   This modification has been tested on a virgin WWIV v4.24 source using
  56.   Borland C++ v4.5
  57.  
  58. ──────────────────────────────────────────────────────────────────────────────
  59.                                    Legend
  60.                           ╔═══╤══════════════════┐
  61.                           │ + │ Add This Line    │
  62.                           │ - │ Delete This Line │
  63.                           │ * │ Modify This Line │
  64.                           │ = │ Existing Line    │
  65.                           └═══╧══════════════════╝
  66. ───[Step 1]────────────────────────────────────────────────────────────────────
  67.  
  68. Load COM.C and add those functions before int yn(..) :
  69.  
  70. void RedrawPrompt(int pos, int redo)
  71. {
  72.  char s[81], s1[81];
  73.  int i, i2;
  74.  
  75.  i2=(strlen(str_yes)+strlen(str_no)+5);
  76.  if (!okansi())
  77.  {
  78.    strcpy(s, str_yes);
  79.    strcpy(s1, str_no);
  80.    strupr(s);
  81.    strupr(s1);
  82.  }
  83.  if (redo)
  84.    for (i=0;i<i2;i++)
  85.      backspace();
  86.    switch (pos)
  87.    {
  88.      case 0:
  89.        npr("7[3%s/4%s7]9: ", str_yes, (okansi())?str_no:s1);
  90.      break;
  91.      case 1:
  92.        npr("7[4%s3/%s7]9: ", (okansi())?str_yes:s, str_no);
  93.      break;
  94.    }
  95. }
  96.  
  97. void RedrawPrompt_ynq(int pos, int redo)
  98. {
  99.  char s[81],s1[81],s2[81];
  100.  int i, i2;
  101.  
  102.  i2=(strlen(str_yes)+strlen(str_no)+strlen(str_quit)+6);
  103.  
  104.  if (!okansi())
  105.  {
  106.    strcpy(s, str_yes);
  107.    strcpy(s1, str_no);
  108.    strcpy(s2, str_quit);
  109.    strupr(s);
  110.    strupr(s1);
  111.    strupr(s2);
  112.  }
  113.  if (redo)
  114.    for (i=0;i<i2;i++)
  115.      backspace();
  116.    switch (pos)
  117.    {
  118.      case 0:
  119.        npr("7[3%s/4%s3/%s7]9: ", str_yes, okansi()?str_no:s1, str_quit);
  120.        break;
  121.      case 1:
  122.        npr("7[4%s3/%s/3%s7]9: ", okansi()?str_yes:s, str_no, str_quit);
  123.        break;
  124.      case 2:
  125.        npr("7[3%s3/%s/4%s7]9: ", str_yes, str_no, okansi()?str_quit:s2);
  126.        break;
  127.    }
  128. }
  129.  
  130. ───[Step 2]────────────────────────────────────────────────────────────────────
  131.  
  132. Replace the following 3 functions:
  133.  
  134. int yn(void)
  135. /* The keyboard is checked for either a Y, N, or C/R to be hit.  C/R is
  136.  * assumed to be the same as a N.  Yes or No is output, and yn is set to
  137.  * zero if No was returned, and yn() is non-zero if Y was hit.
  138.  */
  139. {
  140.   char ch=0, pos=0, done=0;
  141.  
  142.   if (menu_on() && rip_popup && (!rip_subset))
  143.   {
  144.     outstr("s\r");
  145.     printmenu(330);
  146.   } else
  147.     RedrawPrompt(pos,0);
  148.   do
  149.   {
  150.     ch=GetAllKeys();
  151.     if (ch==*str_yes)
  152.       done=1;
  153.     else if (ch==*str_no)
  154.       done=1;
  155.     else if (ch==32)
  156.     {
  157.       if (pos==0)
  158.         ch=*str_no;
  159.       else
  160.         ch=*str_yes;
  161.       done=1;
  162.     }
  163.     else if ((ch==72) || (ch==75) || (ch=='8') || (ch=='4'))
  164.     {
  165.       pos--;
  166.       if (pos<0)
  167.         pos=1;
  168.       if (!(menu_on() && rip_popup && (!rip_subset)))
  169.         RedrawPrompt(pos,1);
  170.     }
  171.     else if ((ch==80) || (ch==77) || (ch=='2') || (ch=='6') || (ch==32))
  172.     {
  173.       pos++;
  174.       if (pos>1)
  175.         pos=0;
  176.       if (!(menu_on() && rip_popup && (!rip_subset)))
  177.         RedrawPrompt(pos,1);
  178.     }
  179.   } while((!done) && (!hangup));
  180.   if (menu_on() && rip_popup && (!rip_subset))
  181.   {
  182.     printmenu(335);
  183.     outstr("u");
  184.   }
  185.   ansic(1);
  186.   if (ch==*str_yes)
  187.     print_yn(2);
  188.   else
  189.     print_yn(3);
  190.   return(ch == *str_yes);
  191. }
  192.  
  193. /****************************************************************************/
  194.  
  195. int ny(void)
  196. /* This is the same as yn(), except C/R is assumed to be "Y" */
  197. {
  198.   char ch=0,pos=1,done=0;
  199.  
  200.   if (menu_on() && rip_popup && (!rip_subset))
  201.   {
  202.     outstr("s\r");
  203.     printmenu(330);
  204.   } else
  205.     RedrawPrompt(pos,0);
  206.   do
  207.   {
  208.     ch=GetAllKeys();
  209.     if (ch==*str_yes)
  210.       done=1;
  211.     else if (ch==*str_no)
  212.       done=1;
  213.     if ((ch==72) || (ch==75) || (ch=='8') || (ch=='4'))
  214.     {
  215.       pos--;
  216.       if (pos<0)
  217.         pos=1;
  218.       if (!(menu_on() && rip_popup && (!rip_subset)))
  219.         RedrawPrompt(pos,1);
  220.     }
  221.     else if ((ch==80) || (ch==77) || (ch=='2') || (ch=='6') || (ch==32))
  222.     {
  223.       pos++;
  224.       if (pos>1)
  225.         pos=0;
  226.       if (!(menu_on() && rip_popup && (!rip_subset)))
  227.         RedrawPrompt(pos,1);
  228.     }
  229.     else if (ch==13)
  230.     {
  231.       if (pos==0)
  232.         ch=*str_no;
  233.       else
  234.         ch=*str_yes;
  235.       done=1;
  236.     }
  237.  
  238.   } while((!done) && (!hangup));
  239.   if (menu_on() && rip_popup && (!rip_subset))
  240.   {
  241.     printmenu(335);
  242.     outstr("u");
  243.   }
  244.   ansic(1);
  245.   if (ch==*str_no)
  246.     print_yn(3);
  247.   else
  248.     print_yn(2);
  249.   return((ch == *str_yes) || (ch==13));
  250. }
  251.  
  252. /****************************************************************************/
  253.  
  254. char ynq(void)
  255. {
  256.   char ch=0,pos=0, done=0;
  257.  
  258.   if (menu_on() && rip_popup && (!rip_subset))
  259.   {
  260.     outstr("s\r");
  261.     printmenu(331);
  262.   } else
  263.     RedrawPrompt_ynq(pos,0);
  264.   do
  265.   {
  266.     ch=GetAllKeys();
  267.     if (ch==*str_yes)
  268.       done=1;
  269.     else if (ch==*str_quit)
  270.       done=1;
  271.     else if (ch==*str_no)
  272.       done=1;
  273.     else if ((ch==72) || (ch==75) || (ch=='8') || (ch=='4'))
  274.     {
  275.       pos++;
  276.       if (pos>2)
  277.         pos=0;
  278.       if (!(menu_on() && rip_popup && (!rip_subset)))
  279.         RedrawPrompt_ynq(pos,1);
  280.     }
  281.     else if ((ch==80) || (ch==77) || (ch=='2') || (ch=='6'))
  282.     {
  283.       pos--;
  284.       if (pos<0)
  285.         pos=2;
  286.       if (!(menu_on() && rip_popup && (!rip_subset)))
  287.         RedrawPrompt_ynq(pos,1);
  288.     }
  289.     else if (ch==13)
  290.     {
  291.       switch (pos)
  292.       {
  293.         case 0: ch=*str_no; break;
  294.         case 1: ch=*str_yes; break;
  295.         case 2: ch=*str_quit; break;
  296.       }
  297.       done=1;
  298.     }
  299.     else if (ch==32)
  300.     {
  301.       pos--;
  302.       if (pos<0)
  303.         pos=2;
  304.       if (!(menu_on() && rip_popup && (!rip_subset)))
  305.         RedrawPrompt_ynq(pos, 1);
  306.       done=0;
  307.     }
  308.   } while((!done) && (!hangup));
  309.   if (menu_on() && rip_popup && (!rip_subset))
  310.   {
  311.     printmenu(335);
  312.     outstr("u");
  313.   }
  314.   ansic(1);
  315.   if (ch==*str_yes)
  316.   {
  317.     ch='Y';
  318.     print_yn(2);
  319.   } else if (ch==*str_quit) {
  320.     ch='Q';
  321.     pl(str_quit);
  322.   } else {
  323.     ch='N';
  324.     print_yn(3);
  325.   }
  326.   return(ch);
  327. }
  328.  
  329. ───[Step 3]────────────────────────────────────────────────────────────────────
  330.  
  331. Add the following functions at the end of COM.C
  332.  
  333. unsigned char InKey(void)
  334. /* This function is the same than inkey(), but it is done to work with the
  335.  * GetAllKeys() function.
  336.  */
  337. {
  338.   unsigned char ch=0;
  339.  
  340.   if (x_only)
  341.     return(0);
  342.  
  343.   if (charbufferpointer) {
  344.     if (!charbuffer[charbufferpointer]) {
  345.       charbufferpointer = charbuffer[0] = 0;
  346.     } else {
  347.       if ((charbuffer[charbufferpointer])==3)
  348.         charbuffer[charbufferpointer]=16;
  349.       return(charbuffer[charbufferpointer++]);
  350.     }
  351.   }
  352.   if (kbhitb() || (in_extern == 2)) {
  353.     ch = getchd1();
  354.     lastcon = 1;
  355.     if (!(g_flags & g_flag_allow_extended)) {
  356.       if (!ch) {
  357.         if (in_extern)
  358.           in_extern = 2;
  359.         else {
  360.           ch = getchd1();
  361.           skey(ch);
  362.         if ((ch!=72) // UP
  363.             && (ch!=75) // LEFT
  364.             && (ch!=80) // DOWN
  365.             && (ch!=77) // RIGHT
  366.             && (ch!=71) // HOME
  367.             && (ch!=79)) // END
  368.           ch=0;
  369.         }
  370.       } else if (in_extern)
  371.         in_extern = 1;
  372.     }
  373.     timelastchar1=timer1();
  374.   } else if (incom && comhit()) {
  375.     ch = (get1c() & andwith);
  376.     lastcon = 0;
  377.   }
  378.   if (!(g_flags & g_flag_allow_extended))
  379.     skey1(&ch);
  380.  
  381.   return(ch);
  382. }
  383.  
  384. unsigned char GetAllKeys(void)
  385. /* This function is the same that getkey(), but it allows you to use the
  386.  * arrow keys (remote and locally) and the home/end keys. You can easily
  387.  * add any other extended keys as long as you know its ANSI and Scan code
  388.  * for this key.
  389.  */
  390. {
  391.   unsigned char ch;
  392.   int beepyet,done=0,pass=0;
  393.   long dd,tv,tv1;
  394.  
  395.   beepyet = 0;
  396.   timelastchar1=timer1();
  397.  
  398.   if (so())
  399.     tv=10920L;
  400.   else
  401.     tv=3276L;
  402.  
  403.   tv1=tv/2;
  404.  
  405.   if (!tagging || (thisuser.sysstatus & sysstatus_no_tag))
  406.     lines_listed = 0;
  407.   do
  408.   {
  409.     switch (pass)
  410.     {
  411.       case 0: if ((ch>31) && (ch<123)) done=1; break;
  412.       case 1:
  413.         if ((incom) && (ch!=255))
  414.           done=1;
  415.         if ((incom) && (ch!='\x1b'))
  416.         {
  417.           switch (ch)
  418.           {
  419.             case 71: return(71); // HOME
  420.             case 72: return(72); // UP
  421.             case 75: return(75); // LEFT
  422.             case 77: return(77); // RIGHT
  423.             case 79: return(79); // END
  424.             case 80: return(80); // DOWN
  425.             default: return(27); // ESC
  426.           }
  427.         }
  428.       break;
  429.       case 2:
  430.         switch(ch)
  431.         {
  432.           case 'A': return(72); // UP
  433.           case 'B': return(80); // DOWN
  434.           case 'C': return(77); // RIGHT
  435.           case 'D': return(75); // LEFT
  436.           case 'K': return(79); // END
  437.           case 'H': return(71); // HOME
  438.           default:  return(27); // ESC
  439.         }
  440.       default: done=1;
  441.     }
  442.     do
  443.     {
  444.       while (empty() && !hangup)
  445.       {
  446.         giveup_timeslice();
  447.         dd = timer1();
  448.         if ((dd<timelastchar1) && ((dd+1000)>timelastchar1))
  449.           timelastchar1=dd;
  450.         if (labs(dd - timelastchar1) > 65536L)
  451.           timelastchar1 -= 1572480L;
  452.         if (((dd - timelastchar1) > tv1) && (!beepyet))
  453.         {
  454.           beepyet = 1;
  455.           outchr(7);
  456.         }
  457.         if (labs(dd - timelastchar1) > tv)
  458.         {
  459.           nl();
  460.           if (!in_extern)
  461.             outstr(get_string(924));
  462.           nl();
  463.           hangup = 1;
  464.         }
  465.         checkhangup();
  466.       }
  467.       ch = InKey();
  468.     } while (!ch && !in_extern && !hangup);
  469.     pass++;
  470.   } while (!done && !hangup);
  471.   if (checkit && (ch > 127)) {
  472.     checkit = 0;
  473.     ch = ch & (andwith = 0x7F);
  474.   }
  475.   return(upcase(ch));
  476. }
  477.  
  478. ───[Step 4]────────────────────────────────────────────────────────────────────
  479.  
  480. Do a MAKE FCNS and compile back the BBS, you should be able to see the prompts
  481. everywhere you want to. You should check your strings files for possible
  482. (Y/N) or (Y/N/Q) prompts there, and delete them (use the free WWIVsys' string
  483. editor to do that).
  484.  
  485. French Proverb: Un tien vaut mieux que deux tu l'auras.
  486.  
  487. For comments, bug report and suggestion, e-mail at the following address:
  488.  
  489. Nicolas LeBlanc  2@20302.WWIVnet (aka Spotnick)
  490.                  -> spotnick@gamemaster.qc.ca
  491. Martin Bourdages 242@20306 / 3@20302.WWIVnet (aka Dark Shadow)
  492.                  -> martin.bourdages@radio.magicnet.com
  493.  
  494.                  =>   French Mod Division Support Sub   <=
  495.                                 SubType: FMD
  496.                            Host: @20302 (WWIVnet)
  497.                       Scan sublist for other networks
  498.  
  499.         Read PRODUCTS.FMD for the full list of our support systems.
  500.  
  501. ───[EOF]──────────────────────────────────────────────────────────────────────
  502.