📄 objectdetaildialog.cpp
字号:
// OjectDetailDialog.cpp : implementation file
//
#include "stdafx.h"
#include "SoccerDoctor.h"
#include "ObjectDetailDialog.h"
#include "Displayer.h"
#include "Utils.h"
// CObjectDetailDialog dialog
IMPLEMENT_DYNAMIC(CObjectDetailDialog, CDialog)
CObjectDetailDialog::CObjectDetailDialog(CDisplayer* pDisplayer,CWnd* pParent /*=NULL*/)
: CDialog(CObjectDetailDialog::IDD, pParent)
, _BodyAngle(_T("BodyAngle"))
, _DeltaX(_T("DeltaX"))
, _DeltaY(_T("DeltaY"))
, _Effort(_T("Effort"))
, _HeadAngle(_T("HeadAngle"))
, _Mode(_T("Mode"))
, _Recovery(_T("Recovery"))
, _Stamina(_T("Stamina"))
, _Type(_T("Type"))
, _ViewQuality(_T("ViewQuality"))
, _ViewWidth(_T("ViewWidth"))
, _X(_T("X"))
, _Y(_T("Y"))
, _Commands(_T("Commands"))
, _pDisplayer(pDisplayer)
, _BallRelDeltaX(_T("BallRelDeltaX"))
, _BallRelDeltaY(_T("BallRelDeltaY"))
, _BallRelX(_T("BallRelX"))
, _BallRelY(_T("BallRelY"))
, _pCycleInfo(NULL)
{
}
CObjectDetailDialog::~CObjectDetailDialog()
{
}
void CObjectDetailDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_DETAILBODYANG, _BodyAngle);
DDX_Text(pDX, IDC_DETAILDELTAX, _DeltaX);
DDX_Text(pDX, IDC_DETAILDELTAY, _DeltaY);
DDX_Text(pDX, IDC_DETAILEFFORT, _Effort);
DDX_Text(pDX, IDC_DETAILHEADANG, _HeadAngle);
DDX_Text(pDX, IDC_DETAILMODE, _Mode);
DDX_Text(pDX, IDC_DETAILRECOVERY, _Recovery);
DDX_Text(pDX, IDC_DETAILSTAMINA, _Stamina);
DDX_Text(pDX, IDC_DETAILTYPE, _Type);
DDX_Text(pDX, IDC_DETAILVIEWQUAL, _ViewQuality);
DDX_Text(pDX, IDC_DETAILVIEWWIDTH, _ViewWidth);
DDX_Text(pDX, IDC_DETAILX, _X);
DDX_Text(pDX, IDC_DETAILY, _Y);
DDX_Text(pDX, IDC_DETAILCOMMANDS, _Commands);
DDX_Text(pDX, IDC_DETAILBALLRELDELTAX, _BallRelDeltaX);
DDX_Text(pDX, IDC_DETAILBALLRELDELTAY, _BallRelDeltaY);
DDX_Text(pDX, IDC_DETAILBALLRELX, _BallRelX);
DDX_Text(pDX, IDC_DETAILBALLRELY, _BallRelY);
}
BEGIN_MESSAGE_MAP(CObjectDetailDialog, CDialog)
// ON_WM_KEYDOWN()
END_MESSAGE_MAP()
// CObjectDetailDialog message handlers
void CObjectDetailDialog::ShowDetail()
{
if( _pCycleInfo = _pDisplayer->getCycleInfo() ){
restoreTexts(); // 清除显示的内容
if( _pCycleInfo->bSight ){
_X.Format("X:%.2f",_pCycleInfo->sight.my_x);
_Y.Format("Y:%.2f",_pCycleInfo->sight.my_y);
_DeltaX.Format("Speed:%.2f",_pCycleInfo->sight.my_speed);
_DeltaY.Format("VelConf:%.2f",_pCycleInfo->sight.my_velconf);
_BodyAngle.Format("BodyAngle:%.2f",CUtils::Rad2Deg(_pCycleInfo->sight.body_ang));
_HeadAngle.Format("HeadAngle:%.2f",CUtils::Rad2Deg(_pCycleInfo->sight.head_ang));
_BallRelX.Format("BallX:%.2f",_pCycleInfo->sight.ball_x);
_BallRelY.Format("BallY:%.2f",_pCycleInfo->sight.ball_y);
_BallRelDeltaX.Format("BallSpeed:%.2f",_pCycleInfo->sight.ball_speed);
_BallRelDeltaY.Format("BallVelConf:%.2f",_pCycleInfo->sight.ball_velconf);
_Mode.Format("MyConf:%.2f",_pCycleInfo->sight.my_conf);
_Type.Format("BallConf:%.2f",_pCycleInfo->sight.ball_conf);
UpdateData(FALSE);
return;
}
int side = _pDisplayer->getSelectedSide();
double ballx = (double)(long)ntohl(_pCycleInfo->show.ball.x)/SHOWINFO_SCALE2;
double bally = (double)(long)ntohl(_pCycleInfo->show.ball.y)/SHOWINFO_SCALE2;
double balldeltax = (double)(long)ntohl(_pCycleInfo->show.ball.deltax)/SHOWINFO_SCALE2;
double balldeltay = (double)(long)ntohl(_pCycleInfo->show.ball.deltay)/SHOWINFO_SCALE2;
if( side == NEUTRAL ) { // 球
_X.Format("X:%.2f",ballx);
_Y.Format("Y:%.2f",bally);
_DeltaX.Format("DeltaX:%.2f",balldeltax);
_DeltaY.Format("DeltaY:%.2f",balldeltay);
}else {
UINT num = _pDisplayer->getSelectedNum();
// Commands
CString sKey;
sKey.Format("Recv %s_%d: (",(LEFT == side) ? _pCycleInfo->show.team[0].name : _pCycleInfo->show.team[1].name , num);
const char* strMsg = _pCycleInfo->msg;
int dist2point = 0; // 距离小数点的距离
bool afterpoint;
while( strMsg = strstr(strMsg,sKey) ){
strMsg += sKey.GetLength() - 1; // 留下左括号
_Commands += "\r\n"; // 换行
afterpoint = false;
while( strMsg && *strMsg != '\n' ){
// 过滤掉小数点后多余的位数,只保留两位
if ( '.' == *strMsg ){
dist2point = 0;
afterpoint = true;
}else if ( !isdigit(*strMsg) ){
afterpoint = false;
}else {
dist2point++;
}
if( !afterpoint || dist2point <= 2 ){
_Commands += *strMsg;
}
strMsg++; // 下一个
}
}
if( side == RIGHT ){
num += MAX_PLAYER;
}
num -= 1; // 队员是从1开始的,数组是从0开始的
if( _pCycleInfo->show.pos[num].mode == DISABLE ){
return; // 无此队员
}
double x = (double)(long)ntohl(_pCycleInfo->show.pos[num].x)/SHOWINFO_SCALE2;
double y = (double)(long)ntohl(_pCycleInfo->show.pos[num].y)/SHOWINFO_SCALE2;
double deltax = (double)(long)ntohl(_pCycleInfo->show.pos[num].deltax)/SHOWINFO_SCALE2;
double deltay = (double)(long)ntohl(_pCycleInfo->show.pos[num].deltay)/SHOWINFO_SCALE2;
_X.Format("X:%.2f",x);
_Y.Format("Y:%.2f",y);
_DeltaX.Format("DeltaX:%.2f",deltax);
_DeltaY.Format("DeltaY:%.2f",deltay);
_BallRelX.Format("BallRelX:%.2f",ballx - x);
_BallRelY.Format("BallRelY:%.2f",bally - y);
_BallRelDeltaX.Format("BallRDX:%.2f",balldeltax - deltax);
_BallRelDeltaY.Format("BallRDY:%.2f",balldeltay - deltay);
// Body Angle
_BodyAngle.Format("BodyAngle:%.2f",CUtils::Rad2Deg((double)(long)ntohl(_pCycleInfo->show.pos[num].body_angle)/SHOWINFO_SCALE2));
// Head Angle
_HeadAngle.Format("HeadAngle:%.2f",CUtils::Rad2Deg((double)(long)ntohl(_pCycleInfo->show.pos[num].head_angle)/SHOWINFO_SCALE2));
// Stamina
_Stamina.Format("Stamina:%.2f",(double)(long)ntohl(_pCycleInfo->show.pos[num].stamina)/SHOWINFO_SCALE2);
// Recovery
_Recovery.Format("Recovery:%.2f",(double)(long)ntohl(_pCycleInfo->show.pos[num].recovery)/SHOWINFO_SCALE2);
// Recovery
_Effort.Format("Effort:%.2f",(double)(long)ntohl(_pCycleInfo->show.pos[num].effort)/SHOWINFO_SCALE2);
// View Width
_ViewWidth.Format("ViewWidth:%.2f",(double)(long)ntohl(_pCycleInfo->show.pos[num].view_width)/SHOWINFO_SCALE2);
// View Quality
_ViewQuality.Format("ViewQuality:%d",ntohs(_pCycleInfo->show.pos[num].view_quality));
// Type
_Type.Format("Type:%d",ntohs(_pCycleInfo->show.pos[num].type));
// Mode
_Mode.Format("Mode:%d",ntohs(_pCycleInfo->show.pos[num].mode));
}
UpdateData(FALSE);
}
}
void CObjectDetailDialog::OnOK()
{
// TODO: Add your specialized code here and/or call the base class
// CDialog::OnOK();
}
void CObjectDetailDialog::OnCancel()
{
// TODO: Add your specialized code here and/or call the base class
ShowWindow(SW_HIDE);
// CDialog::OnCancel();
}
void CObjectDetailDialog::restoreTexts()
{
_BodyAngle = _T("BodyAngle") ;
_DeltaX = _T("DeltaX") ;
_DeltaY = _T("DeltaY") ;
_Effort = _T("Effort") ;
_HeadAngle = _T("HeadAngle") ;
_Mode = _T("Mode") ;
_Recovery = _T("Recovery") ;
_Stamina = _T("Stamina") ;
_Type = _T("Type") ;
_ViewQuality = _T("ViewQuality") ;
_ViewWidth = _T("ViewWidth") ;
_X = _T("X") ;
_Y = _T("Y") ;
_Commands = _T("Commands") ;
}
BOOL CObjectDetailDialog::OnInitDialog()
{
CDialog::OnInitDialog();
typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)(HWND hWnd, COLORREF crKey,
BYTE bAlpha, DWORD dwFlags);
lpfnSetLayeredWindowAttributes m_pSetLayeredWindowAttributes;
HMODULE hUser32 = GetModuleHandle("USER32.DLL");
m_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32,
"SetLayeredWindowAttributes");
if (NULL != m_pSetLayeredWindowAttributes){ // support SetLayeredWindowAttributes
::SetWindowLong(m_hWnd,GWL_EXSTYLE, WS_EX_LAYERED | GetExStyle());
m_pSetLayeredWindowAttributes(m_hWnd, 0, 128, LWA_ALPHA);
}
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CObjectDetailDialog::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if( _pDisplayer->DeliverMessage(pMsg) )
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -