home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / blank / gblanker / source / blankers / star / prefs.c < prev    next >
C/C++ Source or Header  |  1994-10-08  |  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 "Star.h"
  19. #include "Star_rev.h"
  20. #include "/main.h"
  21. #include "//defs.h"
  22.  
  23. struct ModulePrefs
  24. {
  25.     LONG Mode;
  26.     LONG Stars;
  27.     LONG Speed;
  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( StarWnd, &nP.Mode, 0L );
  56.     
  57.     return OK;
  58. }
  59.  
  60. int BT_CANCELClicked( VOID )
  61. {
  62.     OldPrefs = 0L;
  63.     
  64.     return QUIT;
  65. }
  66.  
  67. int SL_STARSClicked( VOID )
  68. {
  69.     nP.Stars = StarMsg.Code;
  70.  
  71.     return OK;
  72. }
  73.  
  74. int SL_SPEEDClicked( VOID )
  75. {
  76.     nP.Speed = StarMsg.Code;
  77.  
  78.     return OK;
  79. }
  80.  
  81. #define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( StarGadgets[Gad], StarWnd, 0L, Tag, Val, TAG_END )
  82.  
  83. int StarVanillaKey( VOID )
  84. {
  85.     switch( StarMsg.Code ) {
  86.     case 's':
  87.         return BT_SAVEClicked();
  88.     case 't':
  89.         return BT_TESTClicked();
  90.     case 'd':
  91.         return BT_SCREENClicked();
  92.     case 'c':
  93.         return QUIT;
  94.     case 'a':
  95.         BL_SetGadgetAttrs( GD_SL_STARS, GTSL_Level, Inc( nP.Stars, 1, 150 ));
  96.         return OK;
  97.     case 'A':
  98.         BL_SetGadgetAttrs( GD_SL_STARS, GTSL_Level, Dec( nP.Stars, 1, 10 ));
  99.         return OK;
  100.     case 'p':
  101.         BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, Inc( nP.Speed, 1, 20 ));
  102.         return OK;
  103.     case 'P':
  104.         BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, Dec( nP.Speed, 1, 2 ));
  105.         return OK;
  106.     default:
  107.         return OK;
  108.     }
  109. }
  110.  
  111. VOID DoPrefs( LONG command, VOID *Prefs )
  112. {
  113.     switch( command )
  114.     {
  115.     case STARTUP:
  116.         OldPrefs = Prefs;
  117.         CopyMem( Prefs, &nP, sizeof( struct ModulePrefs ));
  118.         if( !SetupScreen())
  119.         {
  120.             StarLeft = ( Scr->Width - ComputeX( StarWidth ))/2 - Scr->WBorRight;
  121.             StarTop = ( Scr->Height - ComputeY( StarHeight ) - Font->ta_YSize )/2 - Scr->WBorBottom;
  122.             if( !OpenStarWindow())
  123.             {
  124.                 BL_SetGadgetAttrs( GD_SL_STARS, GTSL_Level, nP.Stars );
  125.                 BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, nP.Speed );
  126.             }
  127.             CloseDownScreen();
  128.         }
  129.         break;
  130.     case IDCMP:
  131.         if( HandleStarIDCMP() != QUIT )
  132.             break;
  133.     case KILL:
  134.         CloseStarWindow();
  135.         break;
  136.     }
  137. }
  138.  
  139. LONG WndSignal( VOID )
  140. {
  141.     return StarWnd ? 1L << StarWnd->UserPort->mp_SigBit : 0L;
  142. }
  143.  
  144. VOID FillDefaults( VOID *Prefs )
  145. {
  146.     struct ModulePrefs mPO = { 0L, 10L, 16 };
  147.  
  148.     mPO.Mode = getTopScreenMode();
  149.     CopyMem( &mPO, Prefs, sizeof( struct ModulePrefs ));
  150. }
  151.