1020 lines
27 KiB
C++
1020 lines
27 KiB
C++
//---------------------------------------------------------------------------
|
|
|
|
#include <vcl.h>
|
|
#pragma hdrstop
|
|
|
|
#include "TableUnit.h"
|
|
#include "GlobalUnit.h"
|
|
#include "UtilityUnit.h"
|
|
#include "ChipsFormUnit.h"
|
|
#include "TableIPFormUnit.h"
|
|
|
|
//---------------------------------------------------------------------------
|
|
#pragma package(smart_init)
|
|
#pragma resource "*.dfm"
|
|
|
|
#define COLOR_OVEN TColor(0x00FFFCF2)
|
|
#define COLOR_BETTING TColor(0x00CDFAFF) //F5F0FF
|
|
#define COLOR_BETTED TColor(0x00E1E4FF)
|
|
#define COLOR_RESULT TColor(0x00D7B95C) //2FFFAD 5CB9D7
|
|
#define RD_6B 0 //六珠路
|
|
#define RD_BIG 1 //大路
|
|
#define RD_EYE 2 //大眼路
|
|
#define RD_LIT 3 //小路
|
|
#define RD_COC 4 //小强路
|
|
|
|
#define TIP_TYPE_BET 0
|
|
#define TIP_TYPE_RES 1
|
|
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TTableFrame::TTableFrame(TComponent* Owner)
|
|
: TFrame(Owner)
|
|
{
|
|
m_sgBets->Canvas->Font = m_sgBets->Font;
|
|
m_sgBets->Cells[0][0] = "序号";
|
|
m_sgBets->Cells[1][0] = "下注";
|
|
m_sgBets->Cells[2][0] = "金额";
|
|
m_sgBets->Cells[3][0] = "输赢";
|
|
m_sgBets->Cells[4][0] = "赢利";
|
|
m_sgBets->ColWidths[0] = 32;//DPIX(32);
|
|
m_sgBets->ColWidths[1] = 32;//DPIX(32);
|
|
m_sgBets->ColWidths[2] = 36;//DPIX(36);
|
|
m_sgBets->ColWidths[3] = 40;//DPIX(40);
|
|
m_sgBets->ColWidths[4] = 45;//DPIX(45);
|
|
|
|
m_pTipTimer = m_pPauseTimer = NULL;
|
|
m_bCursorOnRoad = m_bCursorOnLog = false;
|
|
m_logRows = 0;
|
|
|
|
memset(m_aManChips, 0, sizeof(m_aManChips));
|
|
memset(m_aBetChips, 0, sizeof(m_aBetChips));
|
|
m_pManChipLabels[0] = m_lblManChip0;
|
|
m_pManChipLabels[1] = m_lblManChip1;
|
|
m_pManChipLabels[2] = m_lblManChip2;
|
|
m_pBetChipLabels[0] = m_lblBetChip0;
|
|
m_pBetChipLabels[1] = m_lblBetChip1;
|
|
m_pBetChipLabels[2] = m_lblBetChip2;
|
|
|
|
for(int i=0; i<3; i++){
|
|
m_imgOps[i] = new TPngImage();
|
|
TResourceStream * pResStream = new TResourceStream(int(HInstance),
|
|
i==0 ? L"PNG_OP_0"
|
|
: i==1 ? L"PNG_OP_1"
|
|
: L"PNG_OP_2",
|
|
RT_RCDATA);
|
|
m_imgOps[i]->LoadFromStream(pResStream);
|
|
delete pResStream;
|
|
}
|
|
|
|
m_bSel = false;
|
|
// m_fmMask = NULL;
|
|
|
|
m_fmMask = new TForm((HWND)NULL);
|
|
m_fmMask->Parent = this;
|
|
m_fmMask->Position = poDesigned;
|
|
m_fmMask->BorderStyle = bsNone;
|
|
m_fmMask->AlphaBlend = true;
|
|
m_fmMask->AlphaBlendValue = 40;
|
|
m_fmMask->Color = clBlack;
|
|
m_fmMask->ParentDoubleBuffered = false;
|
|
m_fmMask->DoubleBuffered = true;
|
|
m_fmMask->SetBounds(0, 0, TFWIDTH, TFHEIGHT);
|
|
m_fmMask->OnMouseDown = TableMouseDown;
|
|
m_fmMask->OnMouseUp = TableMouseUp;
|
|
m_fmMask->OnMouseMove = FormMouseMove;
|
|
//
|
|
// m_fmMask->Visible = m_bSel = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
__fastcall TTableFrame::~TTableFrame()
|
|
{
|
|
ClearTipTimer();
|
|
ClearPauseTimer();
|
|
|
|
for(int i=0; i<3; i++)
|
|
delete m_imgOps[i];
|
|
|
|
if(m_fmMask)
|
|
delete m_fmMask;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
|
|
{
|
|
ResetIdle();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::SetGame(TGame* pGame)
|
|
{
|
|
if(m_pGame && !pGame){
|
|
m_pGame->hTable = NULL;
|
|
m_imgIP->Picture->Assign(m_imgOps[0]);
|
|
}
|
|
else if(!m_pGame || m_pGame!=pGame){
|
|
m_pGame = pGame;
|
|
pGame->hTable = Handle;
|
|
m_stVid->Caption = pGame->vid;
|
|
|
|
UpdateStatus();
|
|
UpdateIP();
|
|
UpdateLogs();
|
|
|
|
TGridRect noSel = {-1,-1,-1,-1};
|
|
m_dgRoad->Selection = noSel;
|
|
m_sgBets->Selection = noSel;
|
|
}
|
|
|
|
m_imgIP->Enabled = pGame!=NULL;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::UpdateRoad()
|
|
{
|
|
int iRoad = m_pGame->iRoad>=0 ? m_pGame->iRoad : g_iRoad;
|
|
|
|
int cols = (iRoad==RD_6B ? m_pGame->aRes.size() / 6 : m_pGame->aMap[iRoad-1].aCols.size()) + 1;
|
|
m_dgRoad->ColCount = cols>10 ? cols : 10;
|
|
|
|
if(!m_bCursorOnRoad){
|
|
m_dgRoad->LeftCol = cols>10 ? m_dgRoad->ColCount - 10 : 0;
|
|
}
|
|
|
|
m_dgRoad->Invalidate();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::UpdateLogs()
|
|
{
|
|
if(m_logRows<6)
|
|
m_sgBets->RowCount = 6;
|
|
else
|
|
m_sgBets->RowCount = m_logRows + 1;
|
|
|
|
if(!m_bCursorOnLog && m_logRows>5)
|
|
m_sgBets->TopRow = m_sgBets->RowCount - 5;
|
|
|
|
m_sgBets->Invalidate();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::UpdateStatus()
|
|
{
|
|
if(!m_pGame) return;
|
|
|
|
if(m_pGame->gmstatus==1){
|
|
memset(m_aBetChips, 0, sizeof(m_aBetChips));
|
|
for(int i=0; i<3; i++)
|
|
m_pBetChipLabels[i]->Hide();
|
|
|
|
if(m_panBet->Visible && !m_pTipTimer){
|
|
m_panBet->Enabled = true;
|
|
}
|
|
|
|
m_lbCards->Caption = "开始下注 ";
|
|
m_lbTimeout->Caption = IntToStr(m_pGame->timeout);
|
|
}
|
|
else if(m_pGame->gmstatus==11 || m_pGame->gmstatus==12){
|
|
memset(m_aBetChips, 0, sizeof(m_aBetChips));
|
|
for(int i=0; i<3; i++){
|
|
m_pBetChipLabels[i]->Hide();
|
|
}
|
|
|
|
m_lbCards->Caption = m_pGame->gmstatus==11 ? "洗牌中..." : "维护中...";
|
|
}
|
|
else if(m_pGame->gmstatus==2){
|
|
if(m_pGame->bcard.IsEmpty() && m_pGame->pcard.IsEmpty()){
|
|
m_lbCards->Caption = "开牌中...";
|
|
|
|
memset(m_aManChips, 0, sizeof(m_aManChips));
|
|
for(int i=0; i<3; i++)
|
|
m_pManChipLabels[i]->Hide();
|
|
|
|
m_panBet->Enabled = false;
|
|
m_btnBetOk->Enabled = false;
|
|
m_btnBetCancel->Enabled = false;
|
|
|
|
if(m_panBet->Visible){
|
|
ShowTip("停止下注", TIP_TYPE_BET);
|
|
}
|
|
}
|
|
else{
|
|
char c[16];
|
|
sprintf(c, "%s - %s", ((AnsiString)m_pGame->pcard).c_str(),
|
|
((AnsiString)m_pGame->bcard).c_str());
|
|
m_lbCards->Caption = c;
|
|
}
|
|
}
|
|
else if(m_pGame->gmstatus==0){
|
|
memset(m_aBetChips, 0, sizeof(m_aBetChips));
|
|
for(int i=0; i<3; i++)
|
|
m_pBetChipLabels[i]->Hide();
|
|
|
|
if(g_iPlatform==PF_DB && !m_pGame->bcard.IsEmpty()){
|
|
char c[16];
|
|
sprintf(c, "%s - %s", ((AnsiString)m_pGame->pcard).c_str(),
|
|
((AnsiString)m_pGame->bcard).c_str());
|
|
m_lbCards->Caption = c;
|
|
}
|
|
else
|
|
m_lbCards->Caption = "结算中...";
|
|
}
|
|
|
|
m_lbRCount->Caption = IntToStr(m_pGame->winCount[0]);
|
|
m_lbBCount->Caption = IntToStr(m_pGame->winCount[1]);
|
|
m_lbGCount->Caption = IntToStr(m_pGame->winCount[2]);
|
|
m_shpS->Visible = m_pGame->gmstatus==1;
|
|
m_lbTimeout->Visible = m_shpS->Visible;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::RoadDrawCell(TObject *Sender, System::LongInt ACol, System::LongInt ARow, TRect &Rect, TGridDrawState State)
|
|
{
|
|
if(m_pGame->aRes.empty())
|
|
return;
|
|
|
|
char c;
|
|
char t = 0;
|
|
int iRoad = m_pGame->iRoad>=0 ? m_pGame->iRoad : g_iRoad;
|
|
|
|
if(iRoad==RD_6B){
|
|
int ind = ACol*6 + ARow;
|
|
if(ind>=m_pGame->aRes.size())
|
|
return;
|
|
|
|
c = m_pGame->aRes[ind];
|
|
}
|
|
else{
|
|
if(ACol >= m_pGame->aMap[iRoad-1].aCols.size())
|
|
return;
|
|
c = m_pGame->aMap[iRoad-1].aCols[ACol][ARow];
|
|
if(c==0)
|
|
return;
|
|
|
|
if(c>3){
|
|
t = (c & 0x7C)>>2;
|
|
c &= 0x03;
|
|
}
|
|
}
|
|
|
|
int dpi3 = DPIX(3), dpi7 = DPIX(7);
|
|
TRect rc = Rect;
|
|
if(iRoad!=RD_6B){
|
|
rc.left += iRoad==RD_COC ? dpi3 : 1;
|
|
rc.right -= iRoad==RD_COC ? dpi3 : 1;
|
|
rc.top += iRoad==RD_COC ? dpi3 : 1;
|
|
rc.bottom -= iRoad==RD_COC ? dpi3 : 1;
|
|
}
|
|
|
|
TDrawGrid* pDG = (TDrawGrid*)Sender;
|
|
TCanvas* canvas = pDG->Canvas;
|
|
TBrush* brush = canvas->Brush;
|
|
TPen* pen = canvas->Pen;
|
|
TColor rBC = brush->Color;
|
|
TColor rPC = pen->Color;
|
|
int rPW = pen->Width;
|
|
|
|
if(iRoad==RD_6B || iRoad==RD_LIT){ //珠仔路/小路为实心圆
|
|
if( c==1 )
|
|
brush->Color = clRed;
|
|
else if( c==2 )
|
|
brush->Color = clBlue;
|
|
else if( c==3 )
|
|
brush->Color = clWebLightSeaGreen;
|
|
}
|
|
else{ //大路/大眼路/小强路
|
|
pen->Width = iRoad==RD_COC ? dpi7 : dpi3;
|
|
if( c==1 )
|
|
pen->Color = clRed;
|
|
else if( c==2 )
|
|
pen->Color = clBlue;
|
|
else if( c==3 )
|
|
pen->Color = clWebLightSeaGreen;
|
|
}
|
|
|
|
if(iRoad!=RD_COC && c>0)
|
|
canvas->Ellipse(rc);
|
|
|
|
if(t>0)
|
|
pen->Color = clWebLightSeaGreen;
|
|
|
|
if(iRoad==RD_COC || t>0){ //绘制斜条
|
|
canvas->MoveTo(rc.left, rc.bottom);
|
|
canvas->LineTo(rc.right, rc.top);
|
|
}
|
|
|
|
brush->Color = rBC;
|
|
pen->Color = rPC;
|
|
pen->Width = rPW;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::RoadMouseWheelDown(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
|
|
{
|
|
if( m_dgRoad->LeftCol + m_dgRoad->VisibleColCount < m_dgRoad->ColCount )
|
|
m_dgRoad->LeftCol++;
|
|
|
|
Handled = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::RoadMouseWheelUp(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
|
|
{
|
|
if( m_dgRoad->LeftCol>0 )
|
|
m_dgRoad->LeftCol--;
|
|
|
|
Handled = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::RoadSelectCell(TObject *Sender, System::LongInt ACol, System::LongInt ARow, bool &CanSelect)
|
|
{
|
|
CanSelect = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetsMouseWheelDown(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
|
|
{
|
|
if( m_sgBets->TopRow + m_sgBets->VisibleRowCount < m_sgBets->RowCount )
|
|
m_sgBets->TopRow++;
|
|
|
|
Handled = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetsMouseWheelUp(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
|
|
{
|
|
if(m_sgBets->TopRow>1)
|
|
m_sgBets->TopRow--;
|
|
|
|
Handled = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetsSelectCell(TObject *Sender, System::LongInt ACol, System::LongInt ARow, bool &CanSelect)
|
|
{
|
|
CanSelect = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetsDrawCell(TObject *Sender, System::LongInt ACol, System::LongInt ARow, TRect &Rect, TGridDrawState State)
|
|
{
|
|
TStringGrid* pSG = (TStringGrid*)Sender;
|
|
String strText = pSG->Cells[ACol][ARow];
|
|
int x=Rect.left,y=Rect.top;
|
|
TSize szTxt = pSG->Canvas->TextExtent(strText);
|
|
|
|
if( ARow==0 ){ //画下框线
|
|
x += (Rect.Width() - szTxt.cx) / 2; // -- 水平居中
|
|
y += (Rect.Height() - szTxt.cy) / 2;// -- 垂直居中
|
|
|
|
TBrushStyle rBS = pSG->Canvas->Brush->Style;
|
|
TColor rCl = pSG->Canvas->Brush->Color;
|
|
pSG->Canvas->Brush->Style = bsSolid;
|
|
pSG->Canvas->Brush->Color = clBtnFace;
|
|
pSG->Canvas->FillRect(Rect);
|
|
pSG->Canvas->TextOut(x,y,strText);
|
|
pSG->Canvas->Brush->Style = rBS;
|
|
pSG->Canvas->Brush->Color = rCl;
|
|
|
|
TPenStyle rPS = pSG->Canvas->Pen->Style;
|
|
pSG->Canvas->Pen->Style = psSolid;
|
|
rCl = pSG->Canvas->Pen->Color;
|
|
pSG->Canvas->Pen->Color = clGray;
|
|
|
|
pSG->Canvas->MoveTo( Rect.left-5, Rect.bottom );
|
|
pSG->Canvas->LineTo( Rect.right, Rect.bottom );
|
|
|
|
pSG->Canvas->Pen->Color = clBtnFace;
|
|
pSG->Canvas->MoveTo( Rect.left-5, Rect.top );
|
|
pSG->Canvas->LineTo( Rect.right, Rect.top );
|
|
|
|
pSG->Canvas->Pen->Color = rCl;
|
|
pSG->Canvas->Pen->Style = rPS;
|
|
}
|
|
else{
|
|
if(ACol==1 || ACol==3)//水平居中
|
|
x += (Rect.Width() - szTxt.cx) / 2;
|
|
else //水平靠右
|
|
x += (Rect.Width() - szTxt.cx) - DPIX(4);
|
|
|
|
y += (Rect.Height() - szTxt.cy) / 2;// -- 垂直居中
|
|
|
|
bool bEven = ARow % 2;
|
|
|
|
TBrushStyle rBS = pSG->Canvas->Brush->Style;
|
|
TColor rBC = pSG->Canvas->Brush->Color;
|
|
TColor rFC = pSG->Canvas->Font->Color;
|
|
|
|
int iState = m_pGame->iState;
|
|
pSG->Canvas->Brush->Style = bsSolid;
|
|
|
|
if(ARow==m_logRows){
|
|
if(iState==ST_BETTING||iState==ST_BETSET)
|
|
pSG->Canvas->Brush->Color = COLOR_BETTING;
|
|
else if(iState==ST_BETTED || iState==ST_EXPIRED)
|
|
pSG->Canvas->Brush->Color = COLOR_BETTED;
|
|
else if(iState==ST_PAID || iState==ST_NOBET)// || iState==ST_QUASH)
|
|
pSG->Canvas->Brush->Color = COLOR_RESULT;
|
|
else
|
|
pSG->Canvas->Brush->Color = bEven ? clWhite : COLOR_OVEN;
|
|
}
|
|
else
|
|
pSG->Canvas->Brush->Color = bEven ? clWhite : COLOR_OVEN;
|
|
|
|
if(ACol==0){
|
|
if(strText=="爆缆")
|
|
pSG->Canvas->Font->Color = clRed;
|
|
else if(strText=="新局")
|
|
pSG->Canvas->Font->Color = clGreen;
|
|
}
|
|
else if(ACol==3){
|
|
if(strText=="赢")
|
|
pSG->Canvas->Font->Color = clRed;
|
|
else if(strText=="输")
|
|
pSG->Canvas->Font->Color = clBlue;
|
|
else if(strText=="和")
|
|
pSG->Canvas->Font->Color = clGreen;
|
|
}
|
|
|
|
pSG->Canvas->FillRect(Rect);
|
|
|
|
pSG->Canvas->TextOut(x,y,strText);
|
|
|
|
pSG->Canvas->Brush->Style = rBS;
|
|
pSG->Canvas->Brush->Color = rBC;
|
|
pSG->Canvas->Font->Color = rFC;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::RoadMouseEnter(TObject *Sender)
|
|
{
|
|
m_bCursorOnRoad = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::RoadMouseLeave(TObject *Sender)
|
|
{
|
|
m_bCursorOnRoad = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetsMouseEnter(TObject *Sender)
|
|
{
|
|
m_bCursorOnLog = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetsMouseLeave(TObject *Sender)
|
|
{
|
|
m_bCursorOnLog = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TTableFrame::RunClick(TObject *Sender)
|
|
{
|
|
TCheckBox* pCB = (TCheckBox*)Sender;
|
|
if(m_pGame && m_pGame->bRun!=pCB->Checked ){
|
|
m_pGame->bRun = pCB->Checked;
|
|
|
|
m_pGame->Pause(false);
|
|
ClearPauseTimer();
|
|
|
|
if(g_bGameOn){
|
|
if(m_pGame->bRun)
|
|
m_pGame->GameOn();
|
|
else{
|
|
m_pGame->AutoBetOff();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::RevClick(TObject *Sender)
|
|
{
|
|
if(m_pGame)
|
|
m_pGame->bRev = m_cbRun->Checked;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::SetRun(bool bRun)
|
|
{
|
|
if(m_cbRun->Checked!=bRun){
|
|
m_cbRun->Checked = bRun;
|
|
RunClick(m_cbRun);
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::SetSel(bool bSel)
|
|
{
|
|
if(m_bSel!=bSel){
|
|
m_bSel = bSel;
|
|
|
|
if(bSel){
|
|
m_fmMask->Show();
|
|
}
|
|
else{
|
|
m_fmMask->Hide();
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::UMChangeRoad(TMessage &msg)
|
|
{
|
|
UpdateRoad();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::UMLogUpdate(TMessage &msg)
|
|
{
|
|
int iState = msg.WParam;
|
|
if(iState==-1){
|
|
ClearLogsClick(NULL);
|
|
}
|
|
else if(iState==ST_INIT){
|
|
m_sgBets->Invalidate();
|
|
}
|
|
else if(iState==ST_ROUND){
|
|
if(g_settings.bInitLogByGame)
|
|
ClearLogsClick(NULL);
|
|
|
|
m_logRows++;
|
|
m_sgBets->Cells[0][m_logRows] = "新局";
|
|
UpdateLogs();
|
|
}
|
|
else if(iState==ST_NOBET){
|
|
m_logRows++;
|
|
m_sgBets->Cells[0][m_logRows] = m_pGame->iBetSeq & 0xFFFF;
|
|
m_sgBets->Cells[1][m_logRows] = m_pGame->iBet==4 ? "Z" : "X";
|
|
UpdateLogs();
|
|
}
|
|
else if(iState==ST_BETSET||iState==ST_BETTING){
|
|
m_logRows++;
|
|
m_sgBets->Cells[0][m_logRows] = m_pGame->iBetSeq & 0xFFFF;
|
|
m_sgBets->Cells[1][m_logRows] = m_pGame->iBet==1 ? "庄"
|
|
: m_pGame->iBet==2 ? "闲"
|
|
: "和";
|
|
m_sgBets->Cells[2][m_logRows] = m_pGame->nChip;
|
|
UpdateLogs();
|
|
}
|
|
else if(iState==ST_BETTED||iState==ST_EXPIRED){
|
|
// m_sgBets->Cells[2][m_logRows] = m_pGame->nChip;
|
|
m_sgBets->Invalidate();
|
|
}
|
|
else if(iState==ST_FAILED){// || iState==ST_QUASH){
|
|
// m_sgBets->Cells[2][m_logRows] = m_pGame->nChip;
|
|
|
|
int res = msg.LParam;
|
|
m_sgBets->Cells[3][m_logRows] = "X";
|
|
|
|
// if(iState==ST_QUASH) //注单撤销
|
|
// m_sgBets->Cells[4][m_logRows] = "撤销";
|
|
// else
|
|
if(res==26)
|
|
m_sgBets->Cells[4][m_logRows] = "余额";
|
|
else if(res==25)
|
|
m_sgBets->Cells[4][m_logRows] = "超时";
|
|
else if(res==10 || res==11)
|
|
m_sgBets->Cells[4][m_logRows] = "限红";
|
|
else if(res==2)
|
|
m_sgBets->Cells[4][m_logRows] = "维护";
|
|
else if(res==3)
|
|
m_sgBets->Cells[4][m_logRows] = "网络";
|
|
else if(res==4)
|
|
m_sgBets->Cells[4][m_logRows] = "违规";
|
|
else{
|
|
m_sgBets->Cells[4][m_logRows] = "未知";
|
|
DebugPrint("%s 下注失败 %d", ((AnsiString)m_pGame->vid).c_str(), res);
|
|
}
|
|
|
|
m_sgBets->Invalidate();
|
|
}
|
|
else if((iState==ST_CANCELED || iState==ST_QUASH) && m_logRows>0){ //注单取消或撤销
|
|
for(int i=0; i<5; i++)
|
|
m_sgBets->Cells[i][m_logRows] = "";
|
|
m_logRows--;
|
|
UpdateLogs();
|
|
}
|
|
else if(iState==ST_PAID){ //显示输赢结果日志
|
|
int ret = msg.LParam & 0xFFFF;
|
|
int dead = (msg.LParam >> 16) & 0xFF;
|
|
int stop = msg.LParam >> 24;
|
|
|
|
if(ret==0){ //有错误发生
|
|
m_sgBets->Cells[3][m_logRows] = "X";
|
|
m_sgBets->Cells[4][m_logRows] = "结算";
|
|
}
|
|
else{
|
|
m_sgBets->Cells[3][m_logRows] = ret==1 ? "赢" : ret==2 ? "输" : "和";
|
|
m_sgBets->Cells[4][m_logRows] = FormatFloat("0", m_pGame->profit);
|
|
}
|
|
|
|
if(g_bGameOn && (dead || stop)){
|
|
int pause = 0;
|
|
if(dead && (m_pGame->bIndPolicy || !g_aGames.pRankChip)){ //独立策略或非全局注码
|
|
m_logRows++;
|
|
m_sgBets->Cells[0][m_logRows] = "爆缆";
|
|
if(dead==3){
|
|
int iCP = m_pGame->bIndPolicy ? m_pGame->iChipPolicy : g_iChipPolicy;
|
|
TChipPolicy* pCP = (TChipPolicy*)g_aChipPolicies[iCP];
|
|
m_sgBets->Cells[1][m_logRows] = pCP->deadPause ? "暂停" : "重启";
|
|
|
|
if(pause<pCP->deadPause)
|
|
pause = pCP->deadPause;
|
|
}
|
|
else if(dead==2)
|
|
m_sgBets->Cells[1][m_logRows] = "局停";
|
|
else if(dead==1)
|
|
m_sgBets->Cells[1][m_logRows] = "停止";
|
|
}
|
|
|
|
if(stop){
|
|
m_logRows++;
|
|
m_sgBets->Cells[0][m_logRows] = ret==1 ? "止赢" : "止损";
|
|
if(stop==3){
|
|
int nPause = ret==1 ? g_settings.nTableWinPause : g_settings.nTableLosPause;
|
|
m_sgBets->Cells[1][m_logRows] = nPause ? "暂停" : "重启";
|
|
|
|
if(pause<nPause)
|
|
pause = nPause;
|
|
}
|
|
else if(stop==2)
|
|
m_sgBets->Cells[1][m_logRows] = "局停";
|
|
else if(stop==1)
|
|
m_sgBets->Cells[1][m_logRows] = "停止";
|
|
}
|
|
|
|
UpdateLogs();
|
|
|
|
if(dead==1 && (m_pGame->bIndPolicy || !g_aGames.pRankChip) || stop==1){ //本桌停止
|
|
SetRun(false);
|
|
}
|
|
else if(pause){ //暂停
|
|
m_pGame->Pause(true);
|
|
|
|
ClearPauseTimer();
|
|
|
|
m_pPauseTimer = new TTimer(NULL);
|
|
m_pPauseTimer->OnTimer = PauseTimerProc;
|
|
m_pPauseTimer->Interval = pause * 60000;
|
|
m_pPauseTimer->Enabled = true;
|
|
}
|
|
}
|
|
else
|
|
m_sgBets->Invalidate();
|
|
|
|
if(!g_aGames.bFloat){
|
|
if(ret==1)
|
|
m_lbSeq->Caption = "连赢:" + IntToStr(m_pGame->seqCount[0]);
|
|
else if(ret==2)
|
|
m_lbSeq->Caption = "连输:" + IntToStr(m_pGame->seqCount[1]);
|
|
}
|
|
|
|
m_lbProfit->Caption = "赢利: " + FormatFloat("0", m_pGame->profit);
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::UMUpdate(TMessage &msg)
|
|
{
|
|
if (!m_pGame )
|
|
return;
|
|
|
|
int type = msg.WParam;
|
|
|
|
if(type==UPDATE_STATUS){
|
|
UpdateStatus();
|
|
}
|
|
else if(type==UPDATE_ROAD){
|
|
UpdateRoad();
|
|
UpdateStatus();
|
|
}
|
|
else if(type==UPDATE_TIME){
|
|
m_lbTimeout->Caption = IntToStr(m_pGame->timeout);
|
|
}
|
|
else if(type==UPDATE_MANBET){
|
|
int res = msg.LParam;
|
|
|
|
if(m_panBet->Visible){
|
|
String tip = res==0 ? "下注成功" : res==26 ? "余额不足" : "下注失败";
|
|
ShowTip(tip, TIP_TYPE_BET);
|
|
}
|
|
|
|
if(res==0){
|
|
for(int i=0; i<3; i++){
|
|
m_aBetChips[i] += m_aManChips[i];
|
|
if(m_aBetChips[i]>0){
|
|
m_pBetChipLabels[i]->Caption = IntToStr(m_aBetChips[i]);
|
|
m_pBetChipLabels[i]->Show();
|
|
}
|
|
|
|
m_aManChips[i] = 0;
|
|
m_pManChipLabels[i]->Hide();
|
|
}
|
|
|
|
m_btnBetOk->Enabled = false;
|
|
m_btnBetCancel->Enabled = false;
|
|
}
|
|
}
|
|
else if(type==UPDATE_MANRES){
|
|
double res = msg.LParam;
|
|
|
|
for(int i=0; i<3; i++){
|
|
m_aBetChips[i] = 0;
|
|
m_pBetChipLabels[i]->Hide();
|
|
}
|
|
|
|
if(m_panBet->Visible){
|
|
String tip;
|
|
if(res>=0)
|
|
tip += "+ ";
|
|
if(res==0)
|
|
tip += "0";
|
|
else
|
|
tip += FormatFloat("#.##", res);
|
|
|
|
ShowTip(tip, TIP_TYPE_RES);
|
|
}
|
|
}
|
|
else if(type==UPDATE_RESET){
|
|
int type = msg.LParam;
|
|
if(type==0)
|
|
m_lbProfit->Caption = "赢利: ";
|
|
else if(type==1)
|
|
m_lbSeq->Caption = "连赢:";
|
|
else if(type==2)
|
|
m_lbSeq->Caption = "连输:";
|
|
else if(type==3)
|
|
ClearPauseTimer();
|
|
}
|
|
else if(type==UPDATE_IP){
|
|
UpdateIP();
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::UMSetManual(TMessage &msg)
|
|
{
|
|
bool bManual = msg.WParam;
|
|
if(m_panBet->Visible!=bManual){
|
|
m_sgBets->Visible = !bManual;
|
|
m_panBet->Visible = bManual;
|
|
|
|
m_lblBetTip->Hide();
|
|
ClearTipTimer();
|
|
|
|
m_panBet->Enabled = bManual && m_pGame->gmstatus==1;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
|
|
{
|
|
if(Y>DPIY(80))
|
|
return;
|
|
|
|
int ind = X<=DPIX(63) ? 1 : X<=DPIX(126) ? 2 : 0;
|
|
AddChip(ind);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::ManChipClick(TObject *Sender)
|
|
{
|
|
TLabel* pL = (TLabel*)Sender;
|
|
int ind = pL->Tag;
|
|
|
|
AddChip(ind);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::AddChip(int ind)
|
|
{
|
|
int lmtL = g_MinOnBet,
|
|
lmtH = g_MaxOnBet;
|
|
|
|
if(ind==2){
|
|
if(g_iPlatform==PF_PA){
|
|
lmtH = g_MaxOnBet / 10;
|
|
}
|
|
else if(g_iPlatform==PF_AB){
|
|
lmtL = g_MinOnBet==20 ? 3
|
|
: g_MinOnBet==50 ? 10
|
|
: g_MinOnBet==100 ? 15
|
|
: g_MinOnBet==500 ? 62
|
|
: g_MinOnBet / 8 + ((g_MinOnBet % 8) ? 1 : 0);
|
|
lmtH = g_MaxOnBet==10000 ? 1250
|
|
: g_MaxOnBet==5000 ? 625
|
|
: lmtL * 100;
|
|
}
|
|
else if(g_iPlatform==PF_DB){
|
|
lmtL = 5;
|
|
lmtH = 6500;
|
|
}
|
|
}
|
|
|
|
m_aManChips[ind] += ChipsForm->m_nSelChip;
|
|
if(m_aManChips[ind]<lmtL)
|
|
m_aManChips[ind] = lmtL;
|
|
else if(m_aManChips[ind]>lmtH)
|
|
m_aManChips[ind] = lmtH;
|
|
|
|
m_pManChipLabels[ind]->Caption = IntToStr(m_aManChips[ind]);
|
|
m_pManChipLabels[ind]->Show();
|
|
|
|
m_btnBetOk->Enabled = true;
|
|
m_btnBetCancel->Enabled = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetCancelClick(TObject *Sender)
|
|
{
|
|
memset(m_aManChips, 0, sizeof(m_aManChips));
|
|
for(int i=0; i<3; i++)
|
|
m_pManChipLabels[i]->Hide();
|
|
|
|
m_btnBetOk->Enabled = false;
|
|
m_btnBetCancel->Enabled = false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::BetOkClick(TObject *Sender)
|
|
{
|
|
m_panBet->Enabled = false;
|
|
|
|
int tot = 0;
|
|
for(int i=0; i<3; i++){
|
|
tot += m_aManChips[i];
|
|
}
|
|
|
|
if(!g_bTesting && tot>g_fBalance)
|
|
ShowTip("余额不足", TIP_TYPE_BET);
|
|
else if(tot>g_MaxOnBet)
|
|
ShowTip("超出限红", TIP_TYPE_BET);
|
|
else if(tot>0 && m_pGame)
|
|
m_pGame->ManualBetOn(m_aManChips);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::ShowTip(String tip, int type)
|
|
{
|
|
m_panBet->Enabled = false;
|
|
|
|
m_lblBetTip->Caption = tip;
|
|
m_lblBetTip->Show();
|
|
|
|
ClearTipTimer();
|
|
|
|
m_pTipTimer = new TTimer(NULL);
|
|
m_pTipTimer->OnTimer = TipTimerProc;
|
|
m_pTipTimer->Tag = type;
|
|
m_pTipTimer->Interval = 2000;
|
|
m_pTipTimer->Enabled = true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::TipTimerProc(TObject* Sender)
|
|
{
|
|
m_lblBetTip->Hide();
|
|
|
|
if(m_pGame->gmstatus==1)
|
|
m_panBet->Enabled = true;
|
|
|
|
ClearTipTimer();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::ClearTipTimer()
|
|
{
|
|
if(m_pTipTimer){
|
|
delete m_pTipTimer;
|
|
m_pTipTimer = NULL;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::PauseTimerProc(TObject* Sender)
|
|
{
|
|
if(m_pGame->bPause){
|
|
m_pGame->Pause(false);
|
|
m_pGame->AutoBetOn(true);
|
|
}
|
|
|
|
ClearPauseTimer();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::ClearPauseTimer()
|
|
{
|
|
if(m_pPauseTimer){
|
|
delete m_pPauseTimer;
|
|
m_pPauseTimer = NULL;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::ClearLogsClick(TObject *Sender)
|
|
{
|
|
TStringGrid* pSG = m_sgBets;
|
|
|
|
int start = 1;
|
|
if(m_pGame->iState>=ST_BETSET && m_pGame->iState<=ST_EXPIRED && m_logRows>0)
|
|
pSG->Rows[start++] = pSG->Rows[m_logRows];
|
|
|
|
int end = m_logRows+1;
|
|
for(int i=start; i<end; i++)
|
|
pSG->Rows[i]->Clear();
|
|
|
|
pSG->RowCount = 6;
|
|
pSG->TopRow = 1;
|
|
m_logRows = start-1;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::IPMouseEnter(TObject *Sender)
|
|
{
|
|
m_imgIP->Picture->Assign(m_imgOps[2]);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::IPMouseLeave(TObject *Sender)
|
|
{
|
|
m_imgIP->Picture->Assign(m_imgOps[m_pGame && m_pGame->bIndPolicy ? 1 : 0]);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::IPClick(TObject *Sender)
|
|
{
|
|
TTableIPForm * pForm = new TTableIPForm(this, m_pGame);
|
|
TPoint pt = TPoint(Left, Top);
|
|
pt = Parent->ClientToScreen(pt);
|
|
pForm->Top = pt.y + m_dgRoad->Top;
|
|
pForm->Left = pt.x + 2;
|
|
|
|
if(mrOk == pForm->ShowModal()){
|
|
UpdateIP();
|
|
|
|
if(m_pGame->bIndPolicy)
|
|
g_aIPGames.AddGame(m_pGame);
|
|
else
|
|
g_aIPGames.DelGame(m_pGame);
|
|
}
|
|
delete pForm;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
char* u_sRoad[5] = {"六珠路","大路","大眼路","小路","小强路"}; //路珠名称
|
|
void __fastcall TTableFrame::UpdateIP()
|
|
{
|
|
String hint;
|
|
if(m_pGame->bIndPolicy){
|
|
hint = "独立策略(点击修改设置)";
|
|
|
|
if(m_pGame->iBetPolicy<0)
|
|
hint += "\n打法:全局策略";
|
|
else
|
|
hint += "\n打法:" + g_aBetPolicies[m_pGame->iBetPolicy]->name;
|
|
|
|
hint += "\n路单:" + String(u_sRoad[m_pGame->iRoad<0 ? g_iRoad : m_pGame->iRoad]);
|
|
|
|
if(m_pGame->iChipPolicy<0)
|
|
hint += "\n注码:全局策略";
|
|
else{
|
|
TBasePolicy* pPolicy = g_aChipPolicies[m_pGame->iChipPolicy];
|
|
hint += "\n注码:" + pPolicy->name;
|
|
|
|
if(pPolicy->kind!=KIND_CHIP_COM)
|
|
hint += "\n倍数:" + IntToStr(m_pGame->nChipMul);
|
|
}
|
|
}
|
|
else{
|
|
hint = "全局策略(点击设置独立策略)";
|
|
if(m_pGame->iRoad>=0){
|
|
hint += "\n路单:" + String(u_sRoad[m_pGame->iRoad]);
|
|
}
|
|
}
|
|
|
|
m_imgIP->Hint = hint;
|
|
m_imgIP->Picture->Assign(m_imgOps[m_pGame && m_pGame->bIndPolicy ? 1 : 0]);
|
|
UpdateRoad();
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::TableMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
|
|
{
|
|
if(Parent)
|
|
((TPanel*)Parent)->OnMouseDown(Sender, Button, Shift, X, Y);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TTableFrame::TableMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
|
|
{
|
|
if(Parent)
|
|
((TPanel*)Parent)->OnMouseUp(Sender, Button, Shift, X, Y);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|