250 lines
6.9 KiB
C++
250 lines
6.9 KiB
C++
//---------------------------------------------------------------------------
|
|
|
|
#include <vcl.h>
|
|
#pragma hdrstop
|
|
|
|
#include "GlobalUnit.h"
|
|
#include "GameUnit.h"
|
|
#include "TableIPFormUnit.h"
|
|
//---------------------------------------------------------------------------
|
|
#pragma package(smart_init)
|
|
#pragma resource "*.dfm"
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TTableIPForm::TTableIPForm(TComponent* Owner, TGame* pG)
|
|
: TForm(Owner)
|
|
{
|
|
m_pGame = pG;
|
|
|
|
m_cbIndPolicy->Hint = "启用独立策略后,台桌将按自己的打法和注码进行投注\n"
|
|
"同时,将不参与注码的总体计算,也不参与游台下注";
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::FormCreate(TObject *Sender)
|
|
{
|
|
for(int i=0; i<g_aBetPolicies.size(); i++){
|
|
TBasePolicy* pPolicy = g_aBetPolicies[i];
|
|
m_cbBets->AddItem(pPolicy->name,NULL);
|
|
}
|
|
m_cbBets->ItemIndex = m_iBet = m_pGame->bIndPolicy ? m_pGame->iBetPolicy : g_iBetPolicy;
|
|
|
|
m_cbRoad->ItemIndex = m_pGame->iRoad<0 ? g_iRoad : m_pGame->iRoad;
|
|
|
|
for(int i=0; i<g_aChipPolicies.size(); i++){
|
|
TBasePolicy* pPolicy = g_aChipPolicies[i];
|
|
m_cbChips->AddItem(pPolicy->name,NULL);
|
|
}
|
|
m_cbChips->ItemIndex = m_iChip = m_pGame->bIndPolicy ? m_pGame->iChipPolicy : g_iChipPolicy;
|
|
|
|
m_nMul = m_pGame->bIndPolicy ? m_pGame->nChipMul : g_nChipMul;
|
|
if(m_nMul>0){
|
|
m_leChipMul->Text = m_nMul;
|
|
m_leChipMul->Enabled = true;
|
|
}
|
|
|
|
m_cbIndPolicy->Checked = m_pGame->bIndPolicy;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::OkClick(TObject *Sender)
|
|
{
|
|
if(m_cbIndPolicy->Checked){
|
|
if(m_iBet<0){
|
|
ShowMessage("请选择打法策略");
|
|
m_cbBets->SetFocus();
|
|
return;
|
|
}
|
|
|
|
if(m_iChip<0){
|
|
ShowMessage("请选择注码策略");
|
|
m_cbChips->SetFocus();
|
|
return;
|
|
}
|
|
|
|
m_pGame->bIndPolicy = true;
|
|
m_pGame->iBetPolicy = m_iBet;
|
|
m_pGame->iChipPolicy = m_iChip;
|
|
m_pGame->nChipMul = m_nMul;
|
|
}
|
|
else{
|
|
m_pGame->bIndPolicy = false;
|
|
m_pGame->iBetPolicy = m_pGame->iChipPolicy = m_pGame->nChipMul = -1;
|
|
}
|
|
|
|
m_pGame->iRoad = m_cbRoad->ItemIndex==g_iRoad ? -1 : m_cbRoad->ItemIndex;
|
|
|
|
ModalResult = mrOk;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::PolicyChange(TObject *Sender)
|
|
{
|
|
TComboBox* pCB = (TComboBox*)Sender;
|
|
int ind = pCB->ItemIndex;
|
|
int& iPolicy = Sender==m_cbBets ? m_iBet : m_iChip;
|
|
|
|
if( ind != iPolicy ){
|
|
iPolicy = ind;
|
|
|
|
if(ind<0){
|
|
pCB->Text = pCB->Hint;
|
|
|
|
if(pCB==m_cbChips){
|
|
m_nMul = 0;
|
|
m_leChipMul->Text = "";
|
|
m_leChipMul->Enabled = false;
|
|
}
|
|
else{
|
|
m_cbRoad->ItemIndex = g_iRoad;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if(pCB==m_cbChips){
|
|
if(g_aChipPolicies[ind]->kind==KIND_CHIP_COM){
|
|
m_leChipMul->Text = "";
|
|
m_leChipMul->Enabled = false;
|
|
m_nMul = -1;
|
|
}
|
|
else{
|
|
int minChip = MinChipOfPolicy(ind);
|
|
if(minChip>0){
|
|
int mul = g_MinOnBet / minChip;
|
|
if(g_MinOnBet % minChip) mul++;
|
|
|
|
if(m_nMul<mul){
|
|
m_nMul = mul;
|
|
m_leChipMul->Text = IntToStr(mul);
|
|
m_leChipMul->Enabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
m_cbRoad->ItemIndex = ((TBetPolicy*)g_aBetPolicies[ind])->road;
|
|
}
|
|
}
|
|
|
|
SetChanged();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::ChipMulExit(TObject *Sender)
|
|
{
|
|
int mul = m_leChipMul->Text.ToInt();
|
|
if(mul<=0){
|
|
ShowMessage("请输入投注倍数");
|
|
m_leChipMul->SetFocus();
|
|
|
|
return;
|
|
}
|
|
else{
|
|
int minChip = MinChipOfPolicy(m_iChip);
|
|
if(minChip * mul < g_MinOnBet){
|
|
int multi = g_MinOnBet / minChip;
|
|
if(g_MinOnBet % minChip) multi++;
|
|
|
|
m_nMul = multi;
|
|
m_leChipMul->Text = IntToStr(multi);
|
|
}
|
|
else
|
|
m_nMul = mul;
|
|
}
|
|
|
|
SetChanged();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::ChipMulKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
|
|
{
|
|
if( Key==13 )
|
|
m_btnOk->SetFocus();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::SetChanged()
|
|
{
|
|
if(m_iBet>=0 && m_iChip>=0 && (m_iBet!=g_iBetPolicy || m_iChip!=g_iChipPolicy
|
|
|| m_nMul!=g_nChipMul)){
|
|
m_cbIndPolicy->Checked = true;
|
|
m_btnOk->SetFocus();
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
|
|
{
|
|
if(X < 0 || Y < 0 || X > Width || Y > Height)
|
|
ModalResult = mrCancel;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
|
|
{
|
|
// DebugPrint("mouse move");
|
|
if(!m_bMouseOver && X>10 && X<Width-10 && Y>10 && Y<Height-10){
|
|
m_bMouseOver = true;
|
|
if(MouseCapture){
|
|
MouseCapture = false;
|
|
// DebugPrint("discaptured %d - %d", X, Y);
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::FormShow(TObject *Sender)
|
|
{
|
|
TPoint cPos = ScreenToClient(Mouse->CursorPos);
|
|
if(cPos.X>=0 && cPos.Y>=0 && cPos.X<=Width && cPos.Y<=Height){
|
|
m_bMouseOver = true;
|
|
MouseCapture = false;
|
|
}
|
|
else{
|
|
m_bMouseOver = false;
|
|
MouseCapture = true;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::FormMouseEnter(TObject *Sender)
|
|
{
|
|
TPoint cPos = ScreenToClient(Mouse->CursorPos);
|
|
// DebugPrint("mouse enter %d - %d", cPos.X, cPos.Y);
|
|
if(cPos.X>=0 && cPos.Y>=0 && cPos.X<=Width && cPos.Y<=Height){
|
|
m_bMouseOver = true;
|
|
if(MouseCapture){
|
|
MouseCapture = false;
|
|
// DebugPrint("discaptured");
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::FormMouseLeave(TObject *Sender)
|
|
{
|
|
TPoint cPos = ScreenToClient(Mouse->CursorPos);
|
|
// DebugPrint("mouse leave %d - %d of %d - %d", cPos.X, cPos.Y);
|
|
if((cPos.X<=10 || cPos.Y<=10 || cPos.X>=Width-10 || cPos.Y>=Height-10)){
|
|
m_bMouseOver = false;
|
|
if(!MouseCapture){
|
|
MouseCapture = true;
|
|
// DebugPrint("captured");
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::WMKillFocus(TWMKillFocus &Message)
|
|
{
|
|
if(!m_bMouseOver)
|
|
ModalResult = mrCancel;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::ComboCloseUp(TObject *Sender)
|
|
{
|
|
TComboBox* pCB = (TComboBox*)Sender;
|
|
TPoint cPos = ScreenToClient(Mouse->CursorPos);
|
|
if((cPos.X<=10 || cPos.Y<=10 || cPos.X>=Width-10 || cPos.Y>=Height-10)){
|
|
cPos = pCB->ClientToScreen(TPoint(pCB->Width-10, pCB->Height/2));
|
|
SetCursorPos(cPos.X, cPos.Y);
|
|
m_bMouseOver = true;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableIPForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
|
|
{
|
|
if(Key==VK_ESCAPE)
|
|
ModalResult = mrCancel;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|