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

📄 3dsimpleobserverdlg.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// 3DSimpleObserverDlg.cpp : implementation file
//

#include "stdafx.h"
#include "3DSimpleObserver.h"
#include "3DSimpleObserverDlg.h"
#include "Nd_bitmap.h"
#include "GameDataSet.h"
#include "3DRoleData.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMy3DSimpleObserverDlg dialog

CMy3DSimpleObserverDlg::CMy3DSimpleObserverDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMy3DSimpleObserverDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMy3DSimpleObserverDlg)
	m_bHair = FALSE;
	m_bRW = FALSE;
	m_bLW = FALSE;
	m_bSingleAction = FALSE;
	m_strFI = _T("");
	m_strLook = _T("");
	m_bLoop = FALSE;
	m_bMantel = FALSE;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	g_objGameDataSet.Init();
	g_obj3DRoleData.Init();
	m_nZoom = 100;
}

void CMy3DSimpleObserverDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMy3DSimpleObserverDlg)
	DDX_Control(pDX, IDC_COMBO_ACTION, m_ctrlAction);
	DDX_Control(pDX, IDC_PIC_MAIN, m_ctrlPic);
	DDX_Check(pDX, IDC_CHECK_HAIR, m_bHair);
	DDX_Check(pDX, IDC_CHECK_RW, m_bRW);
	DDX_Check(pDX, IDC_CHECK_LW, m_bLW);
	DDX_Check(pDX, IDC_CHECK_SINGLE_ACTION, m_bSingleAction);
	DDX_Text(pDX, IDC_EDIT_FI, m_strFI);
	DDX_Text(pDX, IDC_EDIT_LOOK, m_strLook);
	DDX_Check(pDX, IDC_CHECK_LOOP, m_bLoop);
	DDX_Check(pDX, IDC_CHECKMANTEL, m_bMantel);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMy3DSimpleObserverDlg, CDialog)
	//{{AFX_MSG_MAP(CMy3DSimpleObserverDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_EXIT, OnButtonExit)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_CHECK_HAIR, OnCheckHair)
	ON_BN_CLICKED(IDC_CHECK_RW, OnCheckRw)
	ON_BN_CLICKED(IDC_CHECK_LW, OnCheckLw)
	ON_WM_MOUSEWHEEL()
	ON_CBN_SETFOCUS(IDC_COMBO_ACTION, OnSetfocusComboAction)
	ON_CBN_SELCHANGE(IDC_COMBO_ACTION, OnSelchangeComboAction)
	ON_BN_CLICKED(IDC_CHECK_SINGLE_ACTION, OnCheckSingleAction)
	ON_BN_CLICKED(IDC_BUTTON_RELOAD_ACTION, OnButtonReloadAction)
	ON_BN_CLICKED(IDC_BUTTON_SETLOOK, OnButtonSetlook)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
	ON_BN_CLICKED(IDC_BUTTON_IN, OnButtonIn)
	ON_BN_CLICKED(IDC_BUTTON_OUT, OnButtonOut)
	ON_BN_CLICKED(IDC_BUTTON_OUT2, OnButtonOut2)
	ON_BN_CLICKED(IDC_CHECKMANTEL, OnCheckmantel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMy3DSimpleObserverDlg message handlers

BOOL CMy3DSimpleObserverDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	extern BOOL GameInit(HWND hWnd);
	GameInit(this->m_ctrlPic.GetSafeHwnd());
	CMyBitmap::GameCameraCreate();
	this->UpdateData(true);

	m_p3DMotion = new C3DMotion;
	m_pBmp = new CMyBitmap;
	MYASSERT(m_p3DMotion);
	MYASSERT(m_pBmp);
	m_p3DMotion->Create("动作/1.c3");
	m_pBmp->Load("背景.BMP");

	this->CreateActionInfo();
	m_obj3DRole.SetLook(2);
	m_obj3DRole.SetArmor(2000000);
	//m_obj3DRole.SetAction(100);
	m_nDir = 0;

	//m_bHair = true;
	//m_obj3DRole.SetArmet(2119310);
	m_bRW = true;
	m_obj3DRole.SetRWeapon(50000);
	m_bLW = true;
	m_obj3DRole.SetLWeapon(500000);
	m_bMantel = false;
	
	m_obj3DRole.SetAction(_ACTION_STANDBY);

	m_dwTimeBegin = ::TimeGet();
	this->m_ctrlAction.SetCurSel(0);
	MyActionInfo* pInfo = this->GetActionInfoByIndex(0);
	if(pInfo)
	{
		m_nCurrentAction = pInfo->nActionIndex;
		m_nCurrentAction = pInfo->nActionIndex;
		m_nFrameAmount = m_obj3DRole.SetAction(m_nCurrentAction);
	}
	
	strcpy(m_szCurrentAction, "ERROR");
	m_strFI="33";
	m_strLook="2";
	//m_nLook = 1;
	this->UpdateData(false);
	this->SetTimer(WM_TIMER, 30, NULL);
	m_dwFrameIndex = 0;
	m_dwFrameTime = ::TimeGet();
	m_bPlay = true;
	m_bSlowPlay = false;
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMy3DSimpleObserverDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMy3DSimpleObserverDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMy3DSimpleObserverDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CMy3DSimpleObserverDlg::OnButtonExit() 
{
	// TODO: Add your control notification handler code here
	SAFE_DELETE(m_pBmp);
	SAFE_DELETE(m_p3DMotion);
	CMyBitmap::GameFontDestroy();
	g_objGameDataSet.Destroy();
	this->DestroyActionInfo();
	this->EndDialog(0);
}

//------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::Main()
{
	CMyBitmap::Begin3D ();
	CMyBitmap::ClearBuffer (true, true, D3DCOLOR_XRGB(0, 0, 0xff));

	CMySize sizeScr;
	sizeScr.iWidth = _SCR_WIDTH;
	sizeScr.iHeight = _SCR_HEIGHT;
	CMyBitmap::GameCameraBuild(sizeScr);
	CMyBitmap::GameCameraSet(_SCR_WIDTH/2, _SCR_HEIGHT/2);
	
	this->UpdateData();
//--------------------------------------------------------------
	m_pBmp->Show(0, 0);
	this->ProcessAction();
	float fScale = 1.0f*m_nZoom/100.0f;
	int nRotate	= -45*m_nDir-45;
	m_obj3DRole.SetPos(_SCR_WIDTH/2, _SCR_HEIGHT/2+100, 0, nRotate, fScale);
	m_obj3DRole.SetLightOffset(2, 300, -300, -1000, 0.8f, 0.1f, 0.1f, 0.1f);
	
	m_obj3DRole.Draw(_SCR_WIDTH/2, _SCR_HEIGHT/2);
	this->ShowInfo();
//--------------------------------------------------------------
	CMyBitmap::End3D ();
	CMyBitmap::Flip ();

	g_objGameDataSet.Process();
	::MouseProcess();
}
//------------------------------------------------------------------------
BOOL GameInit(HWND hWnd)
{
//	g_hMyWnd	=hWnd;
	
	// init 3D graphic
	if (!CMyBitmap::Init3DEx (	hWnd,
								_SCR_WIDTH,
								_SCR_HEIGHT,
								1,			// 1 - window mode  0 - full screen
								1))			// back buffer count
		return false;				                  
	
	MYASSERT (CMyBitmap::GameFontCreate());
	return true;
}
//------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	Main();
	CDialog::OnTimer(nIDEvent);
}
//------------------------------------------------------------------------
void CMy3DSimpleObserverDlg::CreateActionInfo()
{
	this->DestroyActionInfo();
	char szIniFile[]="ini/Action.ini";
	char szTitle[64], szSubTitle[64];

	int nAmount;
	// header...
	strcpy(szTitle, "Header");
	strcpy(szSubTitle, "Amount");
	MYASSERT(::IniDataGet(szIniFile, szTitle, szSubTitle, nAmount));
	
	int nData;

	// ActionInfo
	char szInfo[128];
	for(int i = 0; i < nAmount; i++)
	{
		MyActionInfo* pInfo = new MyActionInfo;
		MYASSERT(pInfo);

		sprintf(szTitle, "Action%d", i);
		sprintf(szSubTitle, "Index");
		MYASSERT(::IniDataGet(szIniFile, szTitle, szSubTitle, pInfo->nActionIndex));

		sprintf(szSubTitle, "TimeInterval");
		MYASSERT(::IniDataGet(szIniFile, szTitle, szSubTitle, nData));

⌨️ 快捷键说明

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