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

📄 munpainfo.cpp

📁 墨香最新私服
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// MunpaInfo.cpp : implementation file
//
#include "stdafx.h"
#include "DS_RMTool.h"
#include "MunpaInfo.h"
#include "MunpaDoc.h"

#include "RMNetwork.h"
#include "ChangeValue.h"
//#include "GameResourceManager.h"
#include "ItemDlg.h"
#include "MasInfoManager.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMunpaInfo property page

IMPLEMENT_DYNCREATE(CMunpaInfo, CLDPropPage)

CMunpaInfo::CMunpaInfo() : CLDPropPage(CMunpaInfo::IDD)
{
	//{{AFX_DATA_INIT(CMunpaInfo)
	//}}AFX_DATA_INIT

	m_pDocument = NULL;
	m_pItemDlg = NULL;
	m_wPower = eOperPower_Max;
}

CMunpaInfo::~CMunpaInfo()
{
	SAFE_DELETE(m_pItemDlg);
}

void CMunpaInfo::DoDataExchange(CDataExchange* pDX)
{
	CLDPropPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMunpaInfo)
	DDX_Control(pDX, IDC_MUNPA_SAVE, m_btnSave);
	DDX_Control(pDX, IDC_SEARCH_MUNPA, m_etMunpaSearch);
	DDX_Control(pDX, IDC_MUNPA_CBTAB, m_cbTab);
	DDX_Control(pDX, IDC_MUNPA_NAMELIST, m_MunpaWonList);
	//}}AFX_DATA_MAP

	int i = 0;
	//////////////////////////////////////////////////////////////////////
	//// 沥焊芒 包访 函荐
	for(i=0;i< eMunpaTemp_MAX;++i)
		DDX_Control(pDX, IDC_MUNPA_NAME+i, m_StatusEdit[i]);
	//////////////////////////////////////////////////////////////////////	

	//////////////////////////////////////////////////////////////////////
	//// 巩颇 芒绊
	for(i = 0;i<TABCELL_MUNPAWAREHOUSE_NUM;++i)
		DDX_Control(pDX, IDC_BTN_MUNPA1+i, m_MunpaItem[i]);
	//////////////////////////////////////////////////////////////////////
}

BEGIN_MESSAGE_MAP(CMunpaInfo, CLDPropPage)
	//{{AFX_MSG_MAP(CMunpaInfo)
	ON_BN_CLICKED(IDC_BUTTON_SEARCH, OnButtonSearch)
	ON_CBN_SELCHANGE(IDC_MUNPA_CBTAB, OnSelchangeMunpaCbtab)
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_MUNPA_SAVE, OnMunpaSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMunpaInfo message handlers

BOOL CMunpaInfo::OnInitDialog() 
{
	CLDPropPage::OnInitDialog();

	CDS_RMToolApp* pApp = (CDS_RMToolApp*)AfxGetApp();
	m_wPower = pApp->GetCurOperatorPower();

	////////////////////////////////////////////
	// Control 檬扁拳
	InitMemberListControl();
	////////////////////////////////////////////	
	
	m_TTctrl.Create(this);
	m_TTctrl.SetMaxTipWidth(200);

	int i;
	for(i=0;i<TABCELL_MUNPAWAREHOUSE_NUM;++i)
		m_TTctrl.AddTool(&m_MunpaItem[i]);

	EnableToolTips(TRUE);

	EnableWareHouse(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CMunpaInfo::InitMunpaInfo( BOOL bEnable )
{
	for(int i=0;i<eMunpaTemp_MAX;++i)
	{
		m_StatusEdit[i].SetWindowText("");
		m_StatusEdit[i].ResetEditTextColor();
	}

	for(i = 0;i<TABCELL_MUNPAWAREHOUSE_NUM;++i)
	{
		m_MunpaItem[i].SetWindowText("");
		m_MunpaItem[i].SetData(0);
		m_MunpaItem[i].ReSetColorText();
	}

	if( !bEnable )
		m_MunpaWonList.DeleteAllItems();

	m_etMunpaSearch.SetWindowText("");
	EnableWareHouse(bEnable);
}

void CMunpaInfo::InitMemberListControl()
{
	LV_COLUMN lvcolumn;

	lvcolumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
	lvcolumn.fmt = LVCFMT_CENTER;

//	某腐疙, 饭骇, 流氓, 殿废 朝楼

	for(int i = 1 ; i <= 4 ; ++i)
	{
		lvcolumn.iSubItem = i;
		switch(i)
		{
		case 1:
			{
				lvcolumn.cx = 80;
				lvcolumn.pszText = "ID";
			}
			break;
		case 2:
			{
				lvcolumn.cx = 50;
				lvcolumn.pszText = "Level";
			}
			break;
		case 3:
			{
				lvcolumn.cx = 80;
				lvcolumn.pszText = "Position";
			}
			break;
		case 4:
			{
				lvcolumn.cx = 140;
				lvcolumn.pszText = "Date";
			}
			break;
		}
		m_MunpaWonList.InsertColumn(i, &lvcolumn);
	}


	DWORD dwExStyle = m_MunpaWonList.GetExtendedStyle();

	dwExStyle |= LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT;
	m_MunpaWonList.SetExtendedStyle( dwExStyle );		
}

void CMunpaInfo::InsertMemberList(char* strName, LEVELTYPE level, BYTE position, char* strRegDate)
{
	LV_ITEM	lvitem;

	lvitem.iItem = m_MunpaWonList.GetItemCount();
	lvitem.mask = LVIF_TEXT | LVIF_STATE;
	lvitem.iSubItem = 0;
	lvitem.stateMask = LVIS_SELECTED;
	lvitem.state = INDEXTOSTATEIMAGEMASK(1);
	char buff[256] = {0,};


#define MUNPA_MEMBER		2	//巩颇盔
#define MUNPA_SENIOR		3	//厘肺
#define MUNPA_VICE_MASTER	10	//何巩林

	for(int i=0;i<4;++i)
	{
		switch(i)
		{
		case 0: // 酒捞叼
			{
				// 府家胶俊辑 单捞磐甫 啊廉客辑 捞抚阑 持绢霖促.
				lvitem.pszText = strName;
			}
			break;
		case 1:	// 饭骇
			{
				sprintf(buff, "%d", level);
				lvitem.pszText = buff;
			}
			break;
		case 2:	// 流氓..
			{
				switch(position)
				{
				case MUNPA_MASTER: sprintf(buff, "%s", "Master"); break;
				case MUNPA_VICE_MASTER: sprintf(buff, "%s", "Sub Master"); break;
				case MUNPA_SENIOR: sprintf(buff, "%s", "Senior"); break;
				case MUNPA_MEMBER: sprintf(buff, "%s", "Member"); break;
				case MUNPA_SEMIMEMBER: sprintf(buff, "%s", "Volunteer"); break;
				default: sprintf(buff, "%d", position); break;
				}
				lvitem.pszText = buff;
			}
			break;
		case 3: // 殿废 朝楼
			{
				lvitem.pszText = strRegDate;
			}
			break;
		}
		if( i == 0 )
			m_MunpaWonList.InsertItem((&lvitem));
		else
			m_MunpaWonList.SetItemText(lvitem.iItem, i, lvitem.pszText);
	}	

}

void CMunpaInfo::OnButtonSearch() 
{
	// TODO: Add your control notification handler code here
	CString str;
	int nSearchType = -1;

	if( m_etMunpaSearch.GetWindowTextLength() != 0 )
	{
		nSearchType = 0;
		m_etMunpaSearch.GetWindowText(str);
	}

	if( nSearchType == -1 )
	{
		// 八祸绢 涝仿 俊矾 皋技瘤
		MessageBox("Input Name!!", "Error", MB_OK);
		return;
	}

	// 辑滚俊 八祸 夸没

	TMSG_MUNPASEARCH MunpaSearch;
	MunpaSearch.Category = MP_RMTOOL_MUNPA;
	MunpaSearch.Protocol = MP_RMTOOL_MUNPASEARCH_SYN;
	MunpaSearch.dwTemplateIdx = m_pDocument->GetDocumentIdx();
//	MunpaSearch.wServer = (WORD)m_cbServer.GetItemData(m_cbServer.GetCurSel());
	MunpaSearch.wServer = MASINFOMGR->GetCurMasInfo()->nServerSet;
	strcpy(MunpaSearch.strSearch, str.GetBuffer(0));

	NETWORK->Send(&MunpaSearch, sizeof(MunpaSearch));

	InitMunpaInfo();
}

BOOL CMunpaInfo::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( nID == (UINT)m_etMunpaSearch.GetDlgCtrlID() && nCode == 1281 )
	{
		if( &m_etMunpaSearch == GetFocus() )
			OnButtonSearch();
	}
	else
	{
		if( m_pDocument )
		if( m_pDocument->IsReadOnly() )
		{
			m_btnSave.EnableWindow( FALSE );
		}
		else
		{
			if( m_wPower == eOperPower_Master )
				m_btnSave.EnableWindow( TRUE );
			else
				m_btnSave.EnableWindow( FALSE );
		}
		
		switch( nCode )
		{
		case BN_CLICKED:
			{
				ButtonControlCommand(nID);
			}
			break;
		case EN_KILLFOCUS:
			{
				EditControlCommand(nID);
			}
			break;
		case EN_CHANGE:
			{
				if( (nID >= IDC_MUNPA_NAME && nID < IDC_MUNPA_LEVEL+1) )
				{
					CMREdit* pEdit = (CMREdit*)GetDlgItem(nID);
					if( pEdit) pEdit->SetChanged(TRUE);
				}
			}
			break;
		default:
			break;
		}		
	}

	return CLDPropPage::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

void CMunpaInfo::SetMunpaBaseInfo()
{
	CString str;

	m_StatusEdit[eMunpaTemp_NAME].SetWindowTextEx(m_pDocument->m_pBaseInfo->strMunpaName);

	m_StatusEdit[eMunpaTemp_MUNJU].SetWindowTextEx(m_pDocument->m_pBaseInfo->strMunjuName);

	m_StatusEdit[eMunpaTemp_BIRTH].SetWindowTextEx(m_pDocument->m_pBaseInfo->strRegDate);

	str.Format("%d", m_pDocument->m_pBaseInfo->wMemberNum);
	m_StatusEdit[eMunpaTemp_COUNT].SetWindowTextEx(str.GetBuffer(0));

	str.Format("%d", m_pDocument->m_pBaseInfo->dwFamous);
	m_StatusEdit[eMunpaTemp_FAME].SetWindowTextEx(str.GetBuffer(0));

	str.Format("%d", m_pDocument->m_pBaseInfo->dwMoney);
	m_StatusEdit[eMunpaTemp_MONEY].SetMaxValue(3000000000);
	m_StatusEdit[eMunpaTemp_MONEY].SetWindowTextEx(str.GetBuffer(0), 1);

	str.Format("%d", m_pDocument->m_pBaseInfo->wLocation);
	m_StatusEdit[eMunpaTemp_LOCATION].SetWindowTextEx(str.GetBuffer(0));

	str.Format("%d", m_pDocument->m_pBaseInfo->bKind);
	m_StatusEdit[eMunpaTemp_KIND].SetWindowTextEx(str.GetBuffer(0));

	str.Format("%d", m_pDocument->m_pBaseInfo->bMunpaLevel);
	m_StatusEdit[eMunpaTemp_LEVEL].SetWindowTextEx(str.GetBuffer(0));
}

void CMunpaInfo::SetMunpaItemInfo()
{
	char buff[256] = {0,};
	int i;
	ITEM_INFO* pInfo;

	EnableWareHouse(TRUE);

	// Combo Init
	for(i=0;i<TAB_MUNPAWAREHOUSE_NUM;++i)
	{
		sprintf(buff,"Tab%d", i+1);
		m_cbTab.InsertString(m_cbTab.GetCount(), buff);
	}
	m_cbTab.SetCurSel(0);

	// Item Setting
	for(i=0;i<TABCELL_MUNPAWAREHOUSE_NUM;++i)
	{
		if( m_pDocument->m_pWareHouse->WareHouse[i].wIconIdx != 0)
		{
			pInfo = GAMERESRCMNGR->GetItemInfo(m_pDocument->m_pWareHouse->WareHouse[i].wIconIdx);
			if( pInfo )
				sprintf(buff, pInfo->ItemName);
			else
				sprintf(buff, "%d", m_pDocument->m_pWareHouse->WareHouse[i].wIconIdx);
		}
		else
			sprintf(buff, "");

		m_MunpaItem[i].SetWindowText(buff);
		m_MunpaItem[i].SetData(m_pDocument->m_pWareHouse->WareHouse[i].wIconIdx);
	}
}

CMRButton* CMunpaInfo::CheckButtonEvent(HWND hWnd, POSTYPE& pos)
{
	for(int i=0;i<TABCELL_MUNPAWAREHOUSE_NUM;++i)
	{
		if(m_MunpaItem[i].m_hWnd == hWnd)
		{
			pos = i;
			return &m_MunpaItem[i];
		}
	}

	return NULL;
}

void CMunpaInfo::MakeToolTip(POSTYPE pos, WORD idx, char* str)
{
	CString buff;
	BOOL bOption = FALSE;
	WORD OptionIdx = 0;

	if( idx == 0 ) return;

	ITEM_INFO* pInfo = GAMERESRCMNGR->GetItemInfo(idx);
	if( !pInfo ) return;
	
	buff.Format("\n");
	strcat(str, buff.GetBuffer(0));
	
	buff.Format("酒捞袍 : %s(%d)", pInfo->ItemName, pInfo->ItemIdx);
	strcat(str, buff.GetBuffer(0));

	if( GAMERESRCMNGR->IsOptionItem(pInfo->ItemIdx, m_pDocument->m_pWareHouse->WareHouse[pos].Durability) )
	{
		bOption = TRUE;
		OptionIdx = m_pDocument->m_pWareHouse->WareHouse[pos].Durability;
		
		buff.Format("\n可记锅龋 : %d", m_pDocument->m_pWareHouse->WareHouse[pos].Durability);
		strcat(str, buff.GetBuffer(0));
	}
	else
	{
		if( GAMERESRCMNGR->IsDupItem(pInfo->ItemIdx) )
		{
			buff.Format("\n俺   荐 : %d俺", m_pDocument->m_pWareHouse->WareHouse[pos].Durability);
			strcat(str, buff.GetBuffer(0));
		}
	}
	
	if( bOption )
	{
		ITEM_OPTION_INFO* pOptionInfo = m_pDocument->GetItemOptionInfo(OptionIdx);
		if(pOptionInfo)
		{
			char OptionBuff[40] = {0,};

			if( pOptionInfo->GenGol != 0 )
			{
				sprintf(OptionBuff, "\n%s : +%d", "辟榜", pOptionInfo->GenGol);
				strcat(str, OptionBuff);
			}

			if( pOptionInfo->MinChub != 0 )
			{
				sprintf(OptionBuff, "\n%s : +%d", "刮酶", pOptionInfo->MinChub);
				strcat(str, OptionBuff);
			}

			if( pOptionInfo->CheRyuk != 0 )
			{
				sprintf(OptionBuff, "\n%s : +%d", "眉仿", pOptionInfo->CheRyuk);
				strcat(str, OptionBuff);
			}

			if( pOptionInfo->SimMek != 0 )
			{
				sprintf(OptionBuff, "\n%s : +%d", "缴钙", pOptionInfo->SimMek);
				strcat(str, OptionBuff);
			}

			if( pOptionInfo->Life != 0 )
			{
				sprintf(OptionBuff, "\n%s : +%d", "积疙仿", pOptionInfo->Life);
				strcat(str, OptionBuff);
			}

			if( pOptionInfo->NaeRyuk != 0 )
			{
				sprintf(OptionBuff, "\n%s : +%d", "郴仿", pOptionInfo->NaeRyuk);

⌨️ 快捷键说明

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