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

📄 dlghero.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
字号:
// DlgHero.cpp : implementation file
//

#include "stdafx.h"
#include "TerrainEffectEditor.h"
#include "DlgHero.h"
#include "Hero.h"
#include <vector>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgHero dialog


CDlgHero::CDlgHero(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgHero::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgHero)
	//}}AFX_DATA_INIT
}


void CDlgHero::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgHero)
	DDX_Control(pDX, IDC_LIST_ARMOR, m_ctlArmor);
	DDX_Control(pDX, IDC_LIST_ACTION, m_ctlAction);
	DDX_Control(pDX, IDC_LIST_WEAPON, m_ctlWeapon);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgHero, CDialog)
	//{{AFX_MSG_MAP(CDlgHero)
	ON_LBN_SELCHANGE(IDC_LIST_WEAPON, OnSelchangeListWeapon)
	ON_LBN_SELCHANGE(IDC_LIST_ACTION, OnSelchangeListAction)
	ON_LBN_SELCHANGE(IDC_LIST_ARMOR, OnSelchangeListArmor)
	ON_BN_CLICKED(IDC_BUTTON_MAN, OnButtonMan)
	ON_BN_CLICKED(IDC_BUTTON_WOMAN, OnButtonWoman)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgHero message handlers

void CDlgHero::OnOK() 
{
	// TODO: Add extra validation here
	return;
	CDialog::OnOK();
}

BOOL CDlgHero::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//---------------------------------------
	{
		FILE* fp = fopen("ini/weapon.ini", "r");
		if(!fp)
			return true;
		
		char szLine[1024];
		char szTitle[1024];
		
		DWORD dwOldMesh = 0;
		
		m_ctlWeapon.InsertString(0, "000000");
		while(true)
		{
			// scan title
			if(EOF == fscanf(fp, "%s\n", szLine))
			{
				fclose(fp);
				break;
			}
			if(1 != sscanf(szLine, "[Weapon%s]", szTitle))
				continue;
			szTitle[strlen(szTitle)-1] = '\0';
			// get info ...
			DWORD idMesh=0, idTexture=0;
			fscanf(fp, "Mesh=%u\n", &idMesh);
			fscanf(fp, "Texture=%u\n", &idTexture);
			if(dwOldMesh != idMesh)
			{
				dwOldMesh = idMesh;
				m_ctlWeapon.InsertString(m_ctlWeapon.GetCount(), szTitle);
				
			}
		}
		fclose(fp);
	}
	{
		FILE* fp = fopen("ini/armor.ini", "r");
		if(!fp)
			return true;
		
		char szLine[1024];
		char szTitle[1024];
		
		DWORD dwOldMesh = 0;
		
		while(true)
		{
			// scan title
			if(EOF == fscanf(fp, "%s\n", szLine))
			{
				fclose(fp);
				break;
			}
			if(1 != sscanf(szLine, "[Armor%s]", szTitle))
				continue;
			szTitle[strlen(szTitle)-1] = '\0';
			// get info ...
			DWORD idMesh=0, idTexture=0;
			fscanf(fp, "Mesh=%u\n", &idMesh);
			fscanf(fp, "Texture=%u\n", &idTexture);
			if(dwOldMesh != idMesh)
			{
				dwOldMesh = idMesh;
				m_ctlArmor.InsertString(m_ctlArmor.GetCount(), szTitle);
				
			}
		}
		fclose(fp);
	}


	this->FlashAction();
	this->UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgHero::FlashAction()
{
	int nLook = g_objHero.GetLook();
	FILE* fp = fopen("ini/3DMotion.ini", "r");
	if(!fp)
		return; 
	std::vector<DWORD> setAction;
	while(true)
	{
		char szLine[1024] = "";
		if (EOF == fscanf(fp, "%s\n", szLine))
			break;
		DWORD id = ID_NONE;
		char szFile[256]	= "";
		if (2 == sscanf(szLine, "%u=%s", &id, szFile))
		{
			if(id/1000000 == nLook)
			{
				int i = 0;
				for(i = 0; i < setAction.size(); i ++)
				{
					if(setAction[i] == id%1000)
						break;
				}
				if(i == setAction.size())
				{
					setAction.push_back(id%1000);
				}
			}
		}
	}
	fclose(fp);
	m_ctlAction.ResetContent();
	for(int i = 0; i < setAction.size(); i ++)
	{
		char szAction[256];
		sprintf(szAction, "%d", setAction[i]);
		m_ctlAction.InsertString(m_ctlAction.GetCount(), szAction);
	}
}

void CDlgHero::OnSelchangeListWeapon() 
{
	// TODO: Add your control notification handler code here
	CString str;
	m_ctlWeapon.GetText(m_ctlWeapon.GetCurSel(), str);
	DWORD dwWeapon = 0;
	sscanf(str, "%u", &dwWeapon);
	g_objHero.SetRWeapon(dwWeapon);
}

void CDlgHero::OnSelchangeListAction() 
{
	// TODO: Add your control notification handler code here
	CString str;
	m_ctlAction.GetText(m_ctlAction.GetCurSel(), str);
	DWORD dwAction = 0;
	sscanf(str, "%u", &dwAction);
	//g_objHero.Emotion(dwAction);
	g_objHero.SetActionCmd(dwAction);
}

void CDlgHero::OnSelchangeListArmor() 
{
	// TODO: Add your control notification handler code here
	CString str;
	m_ctlArmor.GetText(m_ctlArmor.GetCurSel(), str);
	DWORD dwArmor = 0;
	sscanf(str, "%u", &dwArmor);
	if(g_objHero.GetLook() != dwArmor/1000000)
	{
		g_objHero.SetLook(dwArmor/1000000);
		this->FlashAction();
	}
	g_objHero.SetArmor(dwArmor);
}

void CDlgHero::OnButtonMan() 
{
	// TODO: Add your control notification handler code here
	g_objHero.SetLook(1);
	this->FlashAction();
}

void CDlgHero::OnButtonWoman() 
{
	// TODO: Add your control notification handler code here
	g_objHero.SetLook(2);
	this->FlashAction();
}

void CDlgHero::OnButtonNoweapon() 
{
	// TODO: Add your control notification handler code here
	g_objHero.SetRWeapon(0);
}

void CDlgHero::OnCancel() 
{
	// TODO: Add extra cleanup here
	return;
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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