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

  1. /*
  2.  *  Copyright (c) 1993 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 "FlyingToaster.h"
  19. #include "FlyingToaster_rev.h"
  20. #include "/main.h"
  21. #include "//defs.h"
  22.  
  23. struct ModulePrefs {
  24.     LONG Mode;
  25.     LONG Objects;
  26.     LONG Speed;
  27. };
  28.  
  29. struct ModulePrefs nP;
  30. VOID *OldPrefs = 0L;
  31. STATIC const UBYTE VersTag[] = VERSTAG;
  32.  
  33. int BT_SAVEClicked( VOID )
  34. {
  35.     if( OldPrefs )
  36.     {
  37.         CopyMem( &nP, OldPrefs, sizeof( struct ModulePrefs ));
  38.         SavePrefs( OldPrefs );
  39.         OldPrefs = 0L;
  40.     }
  41.     
  42.     return QUIT;
  43. }
  44.  
  45. int BT_TESTClicked( VOID )
  46. {
  47.     MessageServer( BM_SENDBLANK );
  48.  
  49.     return OK;
  50. }
  51.  
  52. int BT_SCREENClicked( VOID )
  53. {
  54.     ScreenModeRequest( FlyingToasterWnd, &nP.Mode, 0L );
  55.     
  56.     return OK;
  57. }
  58.  
  59. int BT_CANCELClicked( VOID )
  60. {
  61.     OldPrefs = 0L;
  62.     
  63.     return QUIT;
  64. }
  65.  
  66. int SL_OBJECTSClicked( VOID )
  67. {
  68.     nP.Objects = FlyingToasterMsg.Code;
  69.  
  70.     return OK;
  71. }
  72.  
  73. int SL_SPEEDClicked( VOID )
  74. {
  75.     nP.Speed = FlyingToasterMsg.Code;
  76.  
  77.     return OK;
  78. }
  79.  
  80. #define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( FlyingToasterGadgets[Gad], FlyingToasterWnd, 0L, Tag, Val, TAG_END )
  81.  
  82. int FlyingToasterVanillaKey( VOID )
  83. {
  84.     switch( FlyingToasterMsg.Code ) {
  85.     case 's':
  86.         return BT_SAVEClicked();
  87.     case 't':
  88.         return BT_TESTClicked();
  89.     case 'd':
  90.         return BT_SCREENClicked();
  91.     case 'c':
  92.         return QUIT;
  93.     case 'o':
  94.         BL_SetGadgetAttrs( GD_SL_OBJECTS, GTSL_Level, Inc( nP.Objects, 1, 10 ));
  95.         return OK;
  96.     case 'O':
  97.         BL_SetGadgetAttrs( GD_SL_OBJECTS, GTSL_Level, Dec( nP.Objects, 1, 1 ));
  98.         return OK;
  99.     case 'p':
  100.         BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, Inc( nP.Speed, 1, 10 ));
  101.         return OK;
  102.     case 'P':
  103.         BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, Dec( nP.Speed, 1, 1 ));
  104.         return OK;
  105.     default:
  106.         return OK;
  107.     }
  108. }
  109.  
  110. VOID DoPrefs( LONG command, VOID *Prefs )
  111. {
  112.     switch( command )
  113.     {
  114.     case STARTUP:
  115.         OldPrefs = Prefs;
  116.         CopyMem( Prefs, &nP, sizeof( struct ModulePrefs ));
  117.         if( !SetupScreen())
  118.         {
  119.             FlyingToasterLeft = ( Scr->Width - ComputeX( FlyingToasterWidth ))/2 - Scr->WBorRight;
  120.             FlyingToasterTop = ( Scr->Height - ComputeY( FlyingToasterHeight ) - Font->ta_YSize )/2 -
  121.                 Scr->WBorBottom;
  122.             if( !OpenFlyingToasterWindow())
  123.             {
  124.                 BL_SetGadgetAttrs( GD_SL_OBJECTS, GTSL_Level, nP.Objects );
  125.                 BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, nP.Speed );
  126.             }
  127.             CloseDownScreen();
  128.         }
  129.         break;
  130.     case IDCMP:
  131.         if( HandleFlyingToasterIDCMP() != QUIT )
  132.             break;
  133.     case KILL:
  134.         CloseFlyingToasterWindow();
  135.         break;
  136.     }
  137. }
  138.  
  139. LONG WndSignal( VOID )
  140. {
  141.     return FlyingToasterWnd ? 1L << FlyingToasterWnd->UserPort->mp_SigBit : 0L;
  142. }
  143.  
  144. VOID FillDefaults( VOID *Prefs )
  145. {
  146.     struct ModulePrefs mPO = { 0L, 3L, 6L };
  147.  
  148.     mPO.Mode = getTopScreenMode();
  149.     CopyMem( &mPO, Prefs, sizeof( struct ModulePrefs ));
  150. }
  151.