home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / blank / gblanker / source / blankers / rain / prefs.c < prev    next >
C/C++ Source or Header  |  1994-10-08  |  2KB  |  135 lines

  1. /*
  2.  *  Copyright (c) 1994 Michael D. Bayne.
  3.  *  All rights reserved.
  4.  *
  5.  *  Please see the documentation accompanying the distribution for distribution
  6.  *  and disclaimer information.
  7.  */
  8.  
  9. #include <libraries/gadtools.h>
  10.  
  11. #include <clib/exec_protos.h>
  12. #include <clib/intuition_protos.h>
  13. #include <clib/gadtools_protos.h>
  14.  
  15. #include "/Garshnelib/Garshnelib_protos.h"
  16. #include "/Garshnelib/Garshnelib_pragmas.h"
  17.  
  18. #include "Rain.h"
  19. #include "Rain_rev.h"
  20. #include "/main.h"
  21. #include "//defs.h"
  22.  
  23. struct ModulePrefs
  24. {
  25.     LONG Mode;
  26.     LONG Depth;
  27.     LONG Drops;
  28. };
  29.  
  30. struct ModulePrefs nP;
  31. VOID *OldPrefs = 0L;
  32. STATIC const UBYTE VersTag[] = VERSTAG;
  33.  
  34. int BT_SAVEClicked( VOID )
  35. {
  36.     if( OldPrefs )
  37.     {
  38.         CopyMem( &nP, OldPrefs, sizeof( struct ModulePrefs ));
  39.         SavePrefs( OldPrefs );
  40.         OldPrefs = 0L;
  41.     }
  42.     
  43.     return QUIT;
  44. }
  45.  
  46. int BT_TESTClicked( VOID )
  47. {
  48.     MessageServer( BM_SENDBLANK );
  49.  
  50.     return OK;
  51. }
  52.  
  53. int BT_SCREENClicked( VOID )
  54. {
  55.     ScreenModeRequest( RainWnd, &nP.Mode, &nP.Depth );
  56.     
  57.     return OK;
  58. }
  59.  
  60. int BT_CANCELClicked( VOID )
  61. {
  62.     OldPrefs = 0L;
  63.     
  64.     return QUIT;
  65. }
  66.  
  67. int SL_DROPSClicked( VOID )
  68. {
  69.     nP.Drops = RainMsg.Code;
  70.  
  71.     return OK;
  72. }
  73.  
  74. #define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( RainGadgets[Gad], RainWnd, 0L, Tag, Val, TAG_END )
  75.  
  76. int RainVanillaKey( VOID )
  77. {
  78.     switch( RainMsg.Code ) {
  79.     case 's':
  80.         return BT_SAVEClicked();
  81.     case 't':
  82.         return BT_TESTClicked();
  83.     case 'd':
  84.         return BT_SCREENClicked();
  85.     case 'c':
  86.         return QUIT;
  87.     case 'r':
  88.         BL_SetGadgetAttrs( GD_SL_DROPS, GTSL_Level, Inc( nP.Drops, 1, 150 ));
  89.         return OK;
  90.     case 'R':
  91.         BL_SetGadgetAttrs( GD_SL_DROPS, GTSL_Level, Dec( nP.Drops, 1, 10 ));
  92.         return OK;
  93.     default:
  94.         return OK;
  95.     }
  96. }
  97.  
  98. VOID DoPrefs( LONG command, VOID *Prefs )
  99. {
  100.     switch( command )
  101.     {
  102.     case STARTUP:
  103.         OldPrefs = Prefs;
  104.         CopyMem( Prefs, &nP, sizeof( struct ModulePrefs ));
  105.         if( !SetupScreen())
  106.         {
  107.             RainLeft = ( Scr->Width - ComputeX( RainWidth ))/2;
  108.             RainTop = ( Scr->Height - ComputeY( RainHeight ) - Font->ta_YSize )/2;
  109.             if( !OpenRainWindow())
  110.                 BL_SetGadgetAttrs( GD_SL_DROPS, GTSL_Level, nP.Drops );
  111.             CloseDownScreen();
  112.         }
  113.         break;
  114.     case IDCMP:
  115.         if( HandleRainIDCMP() != QUIT )
  116.             break;
  117.     case KILL:
  118.         CloseRainWindow();
  119.         break;
  120.     }
  121. }
  122.  
  123. LONG WndSignal( VOID )
  124. {
  125.     return RainWnd ? 1L << RainWnd->UserPort->mp_SigBit : 0L;
  126. }
  127.  
  128. VOID FillDefaults( VOID *Prefs )
  129. {
  130.     struct ModulePrefs mPO = { 0L, 2L, 25 };
  131.  
  132.     mPO.Mode = getTopScreenMode();
  133.     CopyMem( &mPO, Prefs, sizeof( struct ModulePrefs ));
  134. }
  135.