home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / MODS / ALLMODS.ZIP / FMD-13C.ZIP / FMD-13C.MOD < prev   
Encoding:
Text File  |  1995-06-25  |  13.2 KB  |  536 lines

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