home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff374.lzh / PopArt / sorcery / input.c < prev    next >
C/C++ Source or Header  |  1990-10-08  |  11KB  |  307 lines

  1.  
  2.  
  3.  /*  input   ---   find out what that annoying user wants and deal with it  */
  4.  
  5.  
  6. #include "stuff.h"
  7.  
  8. #define SMP     struct IntuiMessage *
  9.  
  10.  
  11.     extern struct Screen   *scr      ;
  12.     extern struct Window   *win, *seqwin, *clipWin;
  13.     extern ST SW            SuperWindows [];  /*  cheap storage for dots    */
  14.     extern  int             no_help  ;        /*  turn that thing off!      */
  15.     extern USHORT           izDn     ;        /*  the mouse's pen condition */
  16.     extern USHORT           Mx, My   ;        /*  My mouse Ex Yy'z here!    */
  17.     extern ULONG            thisCol  ;        /*  where points the ">"?     */
  18.     extern  int             bloking  ;
  19.     extern  int             popping  ;
  20.           ULONG             msgclass ;        /*  I only program for the    */
  21.            USHORT           msgcode  ;        /*  mouse fetish...           */
  22.            int              gadcode  ;
  23.            UWORD            mrQ      ;
  24.            int              picking  ;        /*  mousepen???               */
  25.  
  26.                         struct helperizer helps []
  27.                                     =
  28.  {
  29.   {  0,  -1, 13, 11,(UB)  "-+*-!-|>  No Last Chance!  <|-!-*+-",    3 },
  30.   { 33, 19,227,141,(UB)  "Draw Here",                              2 },
  31.   {  1, 13, 33,127,(UB)  "Colors!  Also Use Pick or Arrow keys",   1 },
  32.   { 42,161, 80,187,(UB)  "Hit Alternate Alternate Spots  ",        1 },
  33.   {  4,161, 42,187,(UB)  "Only Hit Alternate Spots ",              1 },
  34.   {281,162,319,188,(UB)  "Blast Current Color Everywhere",      0 },
  35.   { 80,161,118,187,(UB)  "Select Color From Screen (anywhere)",    1 },
  36.   {  1,188,999,999,(UB)  "User Befuddlement Enhancer ",            2 },
  37.   {  4,144, 42,170,(UB)  "F; Fill a 3 x 3 Area (Ctrl == 9 x 9)",   1 },
  38.   {204,161,242,187,(UB)  "S; Write a C Declaration",   1 },
  39.   {242,161,280,187,(UB)  "L; Search File for DataName",   1 },
  40.   {156,161,194,187,(UB)  "I; Add 1 to Name && FileName..try it!",     1 },
  41.   {194,143,315,160,(UB)  "Name of the ImageData Declaration",      1 },
  42.   {156,144,194,161,(UB)  "Save All or NorthWest Corner?",          1 },
  43.   {276,121,311,141,(UB)  "C; Copy Into a New Little Window",     1 },
  44.   {234,122,264,141,(UB)  "R; Flip thru All the Windows' Images",      1 },
  45.   {194,161,204,161+26,(UB)  "Inc && Save (no stupid animations)",      1 },
  46.   {118,161,118+38,161+26,(UB)  "F; Fill a Zone (Auto-BackUp)",             1 },
  47.   {231,100,248,119,(UB)  "U; Jam This Back into Working Areas",       1 },
  48.   {231, 81,248,100,(UB)  "Z; Copy Image Here where It's Safe",        1 },
  49.   {250, 80,316,119,(UB)  "BackUp Copy for Dangerous Actions",      0 },
  50.   {243, 22,307, 62,(UB)  "Your Favorite Little Picture",           0 },
  51.   { 18,  -1, 39,  9,(UB)  "PopArt - art movement of 1950-60s...",   2 },
  52.   { 40,  -1, 60,  9,(UB)  "...that used media symbols && common",    2 },
  53.   { 61,  -1, 80,  9,(UB)  "...objects in exaggerated contexts",     2 },
  54.   {126,  -1,145,  9,(UB)  "SciFi author, artist, programmer...",    2 },
  55.   {146,  -1,165,  9,(UB)  "...from behind the Orange Curtain...",   2 },
  56.   {166,  -1,185,  9,(UB)  "...at 714 641 7525 or 682 3783",         2 },
  57.   {267,121,272,145,(UB)  "T; Put All Images under \"It\"",            1 },
  58.   {227,121,233,145,(UB)  "Set Sequence of Images to Roll",         1 },
  59.   {118,144,156,161,(UB)  "Clone && Load (no stupid animations)",1 },
  60.   {80,144,80+38,161,(UB)  "Save w/ File Editing /* Comment? */",1 },
  61.  
  62.   {42,144,50,149,(UB)  "Ctrl-Save == Inc && Save",2 },
  63.   {42,150,50,155,(UB)  "Click Window Image to Select",2 },
  64.   {42,156,50,161,(UB)  "Ctrl-ColorTweaker == Save ColorMap",2 },
  65.  
  66.   {51,144,58,149,(UB)  "Ctrl-Load == Clone && Load",2 },
  67.   {51,150,58,155,(UB)  "X; == KeyBoard Short-Cut",2 },
  68.   {51,156,58,161,(UB)  "Alt-ColorTweaker == Load ColorMap",2 },
  69.  
  70.   {59,144,64,149,(UB)  "Right-Mouse == Pick Color",2 },
  71.   {59,150,64,155,(UB)  "Ctrl-Click Image == See-Thru",2 },
  72.   {59,156,64,161,(UB)  "Ctrl-Color == Search && Replace",2 },
  73.  
  74.   {65,144,71,149,(UB)  "L-Amiga-ColorTweaker == Default",2 },
  75.   {65,150,71,155,(UB)  "Shift-Drag == Copy Area to ClipBoard",2 },
  76.   {65,156,71,161,(UB)  "Click-Clip == Paste Clipped Area",2 },
  77.  
  78.   {72,144,80,149,(UB)  "Shift-Clip == All but Current Color",2 },
  79.   {72,150,80,155,(UB)  "Alt-Clip == Only Current Color",2 },
  80.   {72,156,80,161,(UB)  "Ctrl-Clip == Kill Clip Window",2 },
  81.  
  82.   {201, 10,233, 19,(UB)  "O; Toggle See-Thru Mode",   1 },
  83.   {169, 10,200, 19,(UB)  "P; Toggle Pop-Thru Mode",   1 },
  84.   {137, 10,168, 19,(UB)  "Close WorkBench && Free Memory",1 },
  85.   {104, 10,135, 19,(UB)  "Write \"0xffff\" or \"65535\" in Array?",1 },
  86.   {  2,128, 12,128+16,(UB)  "<Red> World's Smallest ColorTweaker",1 },
  87.   { 13,128, 21,128+16,(UB)  "<Grn> World's Smallest ColorTweaker",1 },
  88.   { 22,128, 34,128+16,(UB)  "<Blu> World's Smallest ColorTweaker",1 },
  89.  
  90.                          /*  add new help here  */
  91.  
  92.   {  0,  -1,999,999,(UB)  "no action",                              0}, {0}};
  93.  
  94.  
  95.         void
  96. help ()                                /*  Annoy All the Profficient Users  */
  97. {
  98.     extern struct Window *win;
  99.     static UB lastHelp;
  100.     REG SHORT  Mx = win->MouseX,  My = win->MouseY;
  101.     REG int i = 0;
  102.  
  103.  
  104.     if (My < -1)  My = -1;
  105.  
  106.     LOOP (;  helps [i].help;  ++i)
  107.         IF (   Mx >= helps [i].xx  &&  Mx <= helps [i].xxx  &&
  108.                My >= helps [i].yy  &&  My <= helps [i].yyy    )  {
  109.              if (lastHelp == helps [i].help)  return;
  110.              hotHelp ( lastHelp = helps [i].help, helps [i].heat, 0 );
  111.              return;  }
  112.  
  113.     quit ("bug in program data arrays");
  114.  
  115. }
  116.  
  117.  
  118.             UB
  119. widen (flub)
  120.  char *flub;
  121. {
  122.         static char stub [ 150 ];
  123.  
  124.           stub [ 0 ] = ' ';
  125.           stub [ 1 ] =  0 ;
  126.         strcat ( stub, flub );
  127.         strcat ( stub, "                                   ");
  128.           stub [ 37 ] = 0;
  129.         return ( UB ) stub;
  130.  
  131. }                       /*  I thought "rpad ()" would be a little tacky...  */
  132.  
  133.  
  134.                                    void
  135. hotHelp (squeak, heat, persistence)   UB  squeak;
  136. {
  137.     extern ST RastPort *reep;
  138.     extern ST Gadget TGads [];
  139.     static long heats [] = { 3, 28, 1, 2 };
  140.     static int lastpersistence;
  141.     SS IntuiText blank = { 0, 0, JAM1 };
  142.     UB god;
  143.     long wasmode = reep->DrawMode, x;
  144.  
  145.  
  146.     if (persistence == 0 && lastpersistence--)  return;
  147.     lastpersistence = persistence;
  148.     SetAPen (reep, heat == HHalert? 1L: 24L);
  149.     SetDrMd (reep, JAM1);
  150.     RectFill (reep, 0L, 187L, 319L, 199L);
  151.     god = widen (squeak);
  152.  
  153.     if (heat != HHalert)  {  x = strlen (god);
  154.         SetAPen (reep, 23L);  Move (reep,  7L, 199L);  Text (reep, god, x);
  155.         SetAPen (reep, 22L);  Move (reep,  8L, 198L);  Text (reep, god, x);
  156.         SetAPen (reep, 21L);  Move (reep,  9L, 197L);  Text (reep, god, x);
  157.         SetAPen (reep, 20L);  Move (reep, 10L, 196L);  Text (reep, god, x);  }
  158.  
  159.     SetAPen (reep, heats [heat]);
  160.     Move (reep,  11L, 195L);
  161.     Text (reep, god, x);
  162.     SetAPen (reep, thisCol);
  163.     SetDrMd (reep, wasmode);
  164.  
  165. }
  166.  
  167.  
  168.      /*  this stuff is here because art.c and init.c were too big  */
  169.  
  170. tweakColors ()
  171. {
  172.     int updn = My < 136? 1: -1;
  173.     REG USHORT jack;
  174.         USHORT rr, gg, bb;
  175.  
  176.  
  177.     if izCtrl (mrQ)  {  saveColors ();  return;  }
  178.     if izAlt  (mrQ)  {  loadColors ();  return;  }
  179.  
  180.     if (mrQ == LCOM)  {  extern UWORD ni_colCMAP [];
  181.         Mess ("Default Colors Restored");
  182.         LoadRGB4 (&(scr->ViewPort), ni_colCMAP, 32L);
  183.         return;  }
  184.  
  185.     jack = GetRGB4 (scr->ViewPort.ColorMap, thisCol);
  186.     rr =  jack >> 8;
  187.     gg = (jack >> 4) & 0x000f;
  188.     bb = (jack     ) & 0x000f;
  189.  
  190.     switch (Mx < 13? 0: Mx < 22? 1: 2)  {
  191.         case 0:  if (tweak (&rr, updn))  return;  break;
  192.         case 1:  if (tweak (&gg, updn))  return;  break;
  193.         case 2:  if (tweak (&bb, updn))  return;  break;  }
  194.  
  195.     SetRGB4 (&(scr->ViewPort), thisCol, (long) rr, (long) gg, (long) bb);
  196.  
  197. }
  198.  
  199.  
  200. tweak (victim, assassin)  USHORT *victim;
  201. {
  202.  
  203.     *victim += assassin;
  204.  
  205.     if (*victim > 15 || *victim < 0)  {
  206.         Mess ("Color Register at Limit");
  207.         return 1;  }
  208.  
  209.     Mess ("Color Tweaked");
  210.     return 0;
  211.  
  212. }
  213.  
  214.  
  215.          unsigned int
  216. input ()
  217. {
  218.     REG struct IntuiMessage *massage;
  219.     ULONG signal;
  220.     void clipWinput ();
  221.  
  222.  
  223.     msgclass = msgcode = 0;
  224.     if (massage = (SMP) GetMsg (win->UserPort))  goto splashdown;
  225.  
  226.     ifn (izDn)  {
  227.         ifn (win->Flags & WINDOWACTIVE)  Delay (2L);
  228.         smallinput ();
  229.         if (seqwin)  if (GetMsg (seqwin->UserPort))  closeSeqWin ();
  230.         if (clipWin)  clipWinput ();
  231.  
  232.         if (win->Flags & WINDOWACTIVE)  {
  233.             extern int webefillin, CurrentWindow, curOnion;
  234.             int boolshit;
  235.  
  236.  
  237.             ifn (no_help)  help ();
  238.  
  239.             boolshit = ((bloking && !webefillin) || (popping && curOnion !=
  240.                                                     CurrentWindow))&& !picking;
  241.  
  242.             if (boolshit)  flash_blok ();
  243.             Wait (1L << win->UserPort->mp_SigBit);
  244.             if (boolshit)  flash_blok ();  }
  245.         else
  246.             Delay (3L);        /*  okay, it's not a busy loop!  satisfied?  */
  247.  
  248.     }
  249.  
  250.     while (massage = (SMP) GetMsg (win->UserPort))  {
  251. splashdown:
  252.         msgclass   = massage->Class;
  253.         msgcode    = massage->Code;
  254.         Mx         = massage->MouseX;
  255.         My         = massage->MouseY;
  256.         mrQ        = massage->Qualifier & Qmask;
  257.  
  258.         gadcode    =  (msgclass == GADGETUP) ? ((struct Gadget *)
  259.                         (massage->IAddress))->GadgetID : 0 ;
  260.  
  261.         ReplyMsg (massage);
  262.         if (izDn && !bloking)  return 1;
  263.         if (msgclass == MOUSEBUTTONS || msgclass == RAWKEY)  return 1;
  264.  
  265.     }
  266.  
  267.     return  msgclass != CLOSEWINDOW;
  268.  
  269. }                                            /*  end of life as we know it  */
  270.  
  271.  
  272. smallinput ()
  273. {
  274.     REG int k = maxsupwin;
  275.     REG ST IntuiMessage *msg;
  276.  
  277.  
  278.     while (k--)
  279.         if (swin (k))
  280.             while (msg = (SMP) GetMsg (swin (k)->UserPort))  {
  281.                 dealwithit (k, msg);
  282.                 if (msg->Class == CLOSEWINDOW)  break;
  283.                 ReplyMsg (msg);  }
  284.  
  285. }                                       /*  end of life as we know it also  */
  286.  
  287.  
  288.               void
  289. clipWinput ()
  290. {
  291.     REG ST IntuiMessage *msg;
  292.  
  293.  
  294.     while (msg = (SMP) GetMsg (clipWin->UserPort))  {  UWORD clipQ;
  295.         clipQ = msg->Qualifier & Qmask;
  296.  
  297.         if izCtrl (clipQ)  {
  298.             clozeClipWin ();  Mess ("Killed ClipBoard");  RET;  }
  299.  
  300.         if (msg->Class == MOUSEBUTTONS && msg->Code == SELECTUP)
  301.             clipAction (clipQ);
  302.  
  303.         ReplyMsg (msg);  }
  304.  
  305. }                                 /*  REALLY the end of life as we know it  */
  306.  
  307.