home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / top2src.zip / SCREENS.C < prev    next >
C/C++ Source or Header  |  2000-07-13  |  9KB  |  326 lines

  1. /******************************************************************************
  2. SCREENS.C    Large displays and screen showing functions.
  3.  
  4.     Copyright 1993 - 2000 Paul J. Sidorsky
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License, version 2, as
  8.     published by the Free Software Foundation.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19. This module contains functions to display external screens.  It also contains
  20. many of TOP's large displays, such as the opening and closing credits.
  21. ******************************************************************************/
  22.  
  23. #include "top.h"
  24.  
  25. /* This macro should be defined during testing, when an internal revision
  26.    number is needed in addition to the program version. */
  27. #define USE_REVISION
  28.  
  29. /* show_file() - Displays an external screen file.
  30.    Parameters:  name - Base file name to display, with optional pass.
  31.                 tasks - Functions to perform (SCRN_ task bits).
  32.    Returns:  Nothing.
  33.    Notes:  The name parameter can contain an extension, but for normal
  34.            external files (eg. those stored in the TOP ANSI Path) it should
  35.            not contain one, which tells the door kit to determine the
  36.            proper extension based on terminal type.
  37. */
  38. void show_file(char *name, unsigned char tasks)
  39. {
  40.  
  41. /* Reset attribute before displaying. */
  42. if (tasks & SCRN_RESETCOL)
  43.     {
  44.     od_set_colour(D_GREY, D_BLACK);
  45.     }
  46. /* Clear screen before displaying. */
  47. if (tasks & SCRN_CLS)
  48.     {
  49.     od_clr_scr();
  50.     }
  51.  
  52. /* Display the file. */
  53. top_output(OUT_SCREEN, getlang("ShowFilePrefix"));
  54. sprintf(outbuf, "%s%s", cfg.topansipath, name);
  55. od_send_file(outbuf);
  56. top_output(OUT_SCREEN, getlang("ShowFileSuffix"));
  57.  
  58. /* Wait for keypress after displaying. */
  59. if (tasks & SCRN_WAITKEY)
  60.     {
  61.     top_output(OUT_SCREEN, getlang("PressAnyKey"));
  62.     od_get_key(TRUE);
  63.     top_output(OUT_SCREEN, getlang("PressAnyKeySuffix"));
  64.     }
  65.  
  66. return;
  67. }
  68.  
  69. /* minihelp() - Shows command listing.
  70.    Parameters:  None.
  71.    Returns:  Nothing.
  72. */
  73. void minihelp(void)
  74. {
  75.  
  76. /* The command listing used to be hard coded, which is why this display has
  77.    its own function.  Now, however, an external file is used. */
  78.  
  79. top_output(OUT_SCREEN, getlang("CommandListPrefix"));
  80. show_file("MINIHELP", SCRN_NONE);
  81.  
  82. }
  83.  
  84. /* welcomescreen() - Show TOP opening credits.
  85.    Parameters:  None.
  86.    Returns:  Nothing.
  87. */
  88. void welcomescreen(void)
  89. {
  90.  
  91. if (cfg.showopeningcred)
  92.     {
  93.     /* Long form. */
  94.  
  95.     top_output(OUT_SCREEN, "^o@cWelcome to The Online Pub for ");
  96. #if defined(__OS2__)
  97.     top_output(OUT_SCREEN, "OS/2");
  98. #elif defined(__WIN32__)
  99.     top_output(OUT_SCREEN, "Windows 95");
  100. #else
  101.     top_output(OUT_SCREEN, "DOS");
  102. #endif
  103.     top_output(OUT_SCREEN, "^l v@1^o, by ^lPaul Sidorsky^o.@c", ver);
  104. #ifdef USE_REVISION
  105.     top_output(OUT_SCREEN, "^oInternal revision #^l@1^o.@c", rev);
  106. #endif
  107.     top_output(OUT_SCREEN, "Copyright 1993 - 1998 ");
  108.     top_output(OUT_SCREEN, "^lISMWare(TM)^o, All Rights Reserved.@c");
  109.     top_output(OUT_SCREEN, "^oWritten using ^l");
  110. #ifdef __OS2__
  111.     top_output(OUT_SCREEN, "Doors/2 v5.00b3");
  112. #else
  113.     top_output(OUT_SCREEN, "OpenDoors v6.00");
  114. #endif
  115.     top_output(OUT_SCREEN, "^o by ^l");
  116. #ifdef __OS2__
  117.     top_output(OUT_SCREEN, "Joel Downer & Brian Pirie");
  118. #else
  119.     top_output(OUT_SCREEN, "Brian Pirie");
  120. #endif
  121.     top_output(OUT_SCREEN, "^o.@c");
  122.     top_output(OUT_SCREEN, getlang("BroughtToYouBy"), cfg.sysopname,
  123.                cfg.bbsname);
  124.     itoa(od_control.od_node, outnum[0], 10);
  125.     top_output(OUT_SCREEN, getlang("LoggedOnNode"), outnum[0]);
  126.     }
  127. else
  128.     {
  129.     /* Short form. */
  130.  
  131.     top_output(OUT_SCREEN, "@c^oThe Online Pub for ");
  132. #if defined(__OS2__)
  133.     top_output(OUT_SCREEN, "OS/2");
  134. #elif defined(__WIN32__)
  135.     top_output(OUT_SCREEN, "Windows 95");
  136. #else
  137.     top_output(OUT_SCREEN, "DOS");
  138. #endif
  139.     top_output(OUT_SCREEN, " v@1@cCopyright 1993 - 1998 Paul Sidorsky, "
  140.                "All Rights Reserved.@c", ver);
  141. #ifdef USE_REVISION
  142.     top_output(OUT_SCREEN, "^oInternal revision #^l@1^o.@c", rev);
  143. #endif
  144.     }
  145.  
  146. if (registeredtop == RK_UNREGISTERED)
  147.     {
  148.     if (cfg.showopeningcred)
  149.         {
  150.         /* Long form of unregistered message. */
  151.  
  152.         strcpy(outbuf, "@c^pThis is an ^I^mUNREGISTERED EVALUATION COPY^A^p ");
  153.         strcat(outbuf, "of The Online Pub.  Please encourage your SysOp to "
  154.                        "register!@c@c");
  155.         }
  156.     else
  157.         {
  158.         /* Short form of unregistered message. */
  159.  
  160.         strcpy(outbuf, "^I^mUNREGISTERED EVALUATION COPY^A^p.@c@c");
  161.         }
  162.     }
  163. if (registeredtop == RK_REGISTERED)
  164.     {
  165.     if (cfg.showopeningcred)
  166.         {
  167.         /* Long form of registration message. */
  168.  
  169.         sprintf(outbuf,
  170.                 "@c^pThis copy of The Online Pub is registered to ");
  171.         if (!cfg.noregname)
  172.             {
  173.             strcat(outbuf, top_output(OUT_STRINGNF, "^k@1^p", regname));
  174.             }
  175.         }
  176.     else
  177.         {
  178.         /* Short form of registration message. */
  179.         sprintf(outbuf, "^pRegistered to ");
  180.         if (!cfg.noregname)
  181.             {
  182.             strcat(outbuf, top_output(OUT_STRINGNF, "^k@1^p", regname));
  183.             }
  184.         }
  185.  
  186.     /* The remainder of the registration message is common to both the short
  187.        and long forms. */
  188.     if (!cfg.noregname)
  189.         {
  190.         strcat(outbuf, " of ");
  191.         }
  192.     strcat(outbuf, "^k");
  193.     strcat(outbuf, regsystem);
  194.     strcat(outbuf, "^p");
  195.     if (cfg.noregname)
  196.         {
  197.         /* Show serial number instead of name. */
  198.  
  199.         strcat(outbuf, " (#^k");
  200.         strcat(outbuf, regname);
  201.         strcat(outbuf, "^p)");
  202.         }
  203.     strcat(outbuf, " for ^k");
  204.     strcat(outbuf, regtype);
  205.     strcat(outbuf, "^p use");
  206.     strcat(outbuf, ".@c@c");
  207.     }
  208. top_output(OUT_SCREEN, outbuf);
  209.  
  210. return;
  211. }
  212.  
  213. /* newuserscreen() - Shows information screen to new TOP users.
  214.    Parameters:  None.
  215.    Return:  Nothing.
  216. */
  217. void newuserscreen(void)
  218. {
  219.  
  220. /* The new user screen used to be hard coded, which is why this display has
  221.    its own function.  Now, however, an external file is used. */
  222.  
  223. show_file("NEWUSER", SCRN_NONE);
  224.  
  225. return;
  226. }
  227.  
  228. /* quit_top_screen() - Show TOP closing credits.
  229.    Parameters:  None
  230.    Returns:  Nothing.
  231. */
  232. void quit_top_screen(void)
  233. {
  234.  
  235. /* Nothing is shown if the sysop has closing credits turned off, to provide
  236.    a more seamless appearance. */
  237. if (!cfg.showclosingcred)
  238.     {
  239.     return;
  240.     }
  241.  
  242. top_output(OUT_SCREEN, "@c@c^kThe Online Pub for ");
  243. #if defined(__OS2__)
  244.     top_output(OUT_SCREEN, "OS/2");
  245. #elif defined(__WIN32__)
  246.     top_output(OUT_SCREEN, "Windows 95");
  247. #else
  248.     top_output(OUT_SCREEN, "DOS");
  249. #endif
  250. sprintf(outbuf, " v%s@c", ver);
  251. top_output(OUT_SCREEN, outbuf);
  252. top_output(OUT_SCREEN, "Copyright 1993 - 1998 ISMWare(TM)@c@c");
  253. top_output(OUT_SCREEN, getlang("Goodbye"));
  254. top_output(OUT_SCREEN, getlang("ReturnToBBS"), cfg.bbsname);
  255.  
  256. return;
  257. }
  258.  
  259. /* channelsummary() - Show who's in a channel and a quick help note.
  260.    Parameters:  None.
  261.    Returns:  Nothing.
  262.    Notes:  This is the display used whenever a user first enters a new
  263.            channel or when a user presses ENTER without typing any text.
  264. */
  265. void channelsummary(void)
  266. {
  267. long xchan; /* No longer used. */
  268. char chtyp, yestop = 0; /* Channel type reference, flag if there is a topic. */
  269.  
  270. top_output(OUT_SCREEN, getlang("ChanSummaryPrefix"));
  271.  
  272. /* Determine the channel type.  The type numbers are internal to this
  273.    function only. */
  274. /* Normal channel. */
  275. if (curchannel < 4000000000UL)
  276.     {
  277.     chtyp = 0;
  278.     }
  279. /* Personal channel. */
  280. if (curchannel >= 4000000000UL && curchannel < 4001000000UL)
  281.     {
  282.     chtyp = 1;
  283.     }
  284. /* Conference. */
  285. if (curchannel > 4000999999UL)
  286.     {
  287.     chtyp = 2;
  288.     }
  289.  
  290. /* Set a flag if there is a topic defined for this channel. */
  291. if (cmibuf.topic[0] != 0)
  292.     {
  293.     yestop = 1;
  294.     }
  295.  
  296. /* Tell the user where he/she is. */
  297. switch (chtyp)
  298.     {
  299.     case 0: strcpy(outbuf, "YoureInChannel"); break;
  300.     case 1: strcpy(outbuf, "YoureInUserChannel"); break;
  301.     case 2: strcpy(outbuf, "YoureInConference"); break;
  302.     }
  303. top_output(OUT_SCREEN, getlang(outbuf), channelname(curchannel));
  304.  
  305. /* Show topic, if one exists. */
  306. if (yestop)
  307.     {
  308.     switch (chtyp)
  309.         {
  310.         case 0: strcpy(outbuf, "ChannelTopic"); break;
  311.         case 1: strcpy(outbuf, "UserChannelTopic"); break;
  312.         case 2: strcpy(outbuf, "ConferenceTopic"); break;
  313.         }
  314.     top_output(OUT_SCREEN, getlang(outbuf), cmibuf.topic);
  315.     }
  316.  
  317. /* Show who's in the channel. */
  318. whos_in_pub();
  319.  
  320. /* Show a quick message on how to get help. */
  321. top_output(OUT_SCREEN, getlang("ShortHelp"));
  322.  
  323. top_output(OUT_SCREEN, getlang("OpeningSuffix"));
  324.  
  325. }
  326.