⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customizeform.cpp

📁 本人用BCB编写的扫雷小游戏
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Mainform.h"
#include "CustomizeForm.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

extern int GridCol,GridRow,BombCount,GameLevel;

TLevelForm *LevelForm;
//---------------------------------------------------------------------------
__fastcall TLevelForm::TLevelForm(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TLevelForm::Button_CancelClick(TObject *)
{
 Close();
}
//---------------------------------------------------------------------------
void __fastcall TLevelForm::Button_OKClick(TObject *)
{
  int col,row,mines;

  GameLevel = l_Customize;

  row = Edit_Height->Text.ToIntDef(0);
  col = Edit_Width->Text.ToIntDef(0);
  mines = Edit_Mines->Text.ToIntDef(0);

  if (row>=g_MinRow && row<=g_MaxRow) GridRow = row;
  else if (row < g_MinRow) GridRow = g_MinRow;
  else if (row > g_MaxRow) GridRow = g_MaxRow;

  if (col>=g_MinCol && col<=g_MaxCol) GridCol = col;
  else if (col < g_MinCol) GridCol = g_MinCol;
  else if (col > g_MaxCol) GridCol = g_MaxCol;

  if (mines)
  {
    BombCount = mines;
    if (BombCount < g_MinCount) BombCount = g_MinCount;
    if (BombCount > float(GridRow*GridCol)*g_MaxPer) BombCount = float(GridRow*GridCol)*g_MaxPer;
    if (BombCount > g_MaxCount) BombCount = g_MaxCount;
  }

  Close();
}
//---------------------------------------------------------------------------
void __fastcall TLevelForm::Edit_HeightKeyDown(TObject *Sender, WORD &Key,
      TShiftState )
{
  if (Key == 13) Button_OKClick(Sender);
  if (Key == 27) Button_CancelClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TLevelForm::Edit_WidthKeyDown(TObject *Sender, WORD &Key,
      TShiftState )
{
 if (Key == 13) Button_OKClick(Sender);
 if (Key == 27) Button_CancelClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TLevelForm::Edit_MinesKeyDown(TObject *Sender, WORD &Key,
      TShiftState )
{
 if (Key == 13) Button_OKClick(Sender);
 if (Key == 27) Button_CancelClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TLevelForm::Button_OKKeyDown(TObject *Sender, WORD &Key,
      TShiftState )
{
  if (Key == 27) Button_CancelClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TLevelForm::Button_CancelKeyDown(TObject *Sender,
      WORD &Key, TShiftState )
{
  if (Key == 27) Button_CancelClick(Sender);  
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -