home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / chplus / cpp / 3 / hra.exe / options.cpp < prev    next >
C/C++ Source or Header  |  1998-02-09  |  2KB  |  43 lines

  1. //----------------------------------------------------------------------------
  2. //Borland C++Builder
  3. //Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
  4. //----------------------------------------------------------------------------
  5. //---------------------------------------------------------------------
  6. #include <vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include <stdlib.h>
  10. #include "options.h"
  11. #include "swatmain.h"
  12. //---------------------------------------------------------------------
  13. #pragma resource "*.dfm"
  14. TOptionsDlg *OptionsDlg;
  15. //--------------------------------------------------------------------- 
  16. __fastcall TOptionsDlg::TOptionsDlg(TComponent* AOwner)
  17.   : TForm(AOwner)
  18. {
  19. }
  20. //---------------------------------------------------------------------
  21. void __fastcall TOptionsDlg::FormShow(TObject *Sender)
  22. {
  23.     char timebuf[6];
  24.  
  25.     SpeedSet->Position = SpeedSet->Max + 1 - SwatForm->LiveTime;
  26.     PopulationSet->Position = SwatForm->Frequence;
  27.     GameTimeSet->Text = itoa(SwatForm->GameTime, timebuf, 10);
  28. }
  29. //---------------------------------------------------------------------
  30. void __fastcall TOptionsDlg::OKBtnClick(TObject *Sender)
  31. {
  32.     SwatForm->LiveTime = SpeedSet->Max + 1 - SpeedSet->Position;
  33.     SwatForm->Frequence = PopulationSet->Position;
  34.     SwatForm->GameTime = atoi(GameTimeSet->Text.c_str());
  35.  
  36.     // limit the value of GameTime to a reasonable length
  37.     if (SwatForm->GameTime < 1)
  38.         SwatForm->GameTime = 150;
  39.     if (SwatForm->GameTime > 9999)
  40.         SwatForm->GameTime = 9999;
  41. }
  42. //---------------------------------------------------------------------
  43.