DlgEnv.cpp
资源名称:ROA3.40.rar [点击查看]
上传用户:tianheyiqi
上传日期:2010-04-16
资源大小:282k
文件大小:8k
源码类别:
外挂编程
开发平台:
Visual C++
- // DlgEnv.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ROA.h"
- #include "DlgEnv.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgEnv dialog
- enum
- {
- eTabMonster = 0,
- eTabPlayer = 1,
- eTabItem = 2
- };
- CDlgEnv::CDlgEnv(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgEnv::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgEnv)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CDlgEnv::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgEnv)
- DDX_Control(pDX, IDC_LST_ENV_PORTAL, m_lstPortals);
- DDX_Control(pDX, IDC_LST_ENV_PLAYER, m_lstPlayers);
- DDX_Control(pDX, IDC_LST_ENV_NPC, m_lstNpcs);
- DDX_Control(pDX, IDC_LST_ENV_MONSTER, m_lstMonsters);
- DDX_Control(pDX, IDC_LST_ENV_ITEM, m_lstItems);
- DDX_Control(pDX, IDC_TAB_SWITCH2, m_tabSwitch);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgEnv, CDialog)
- //{{AFX_MSG_MAP(CDlgEnv)
- ON_WM_SIZE()
- ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_SWITCH2, OnSelchangeTabSwitch2)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgEnv message handlers
- BOOL CDlgEnv::OnInitDialog()
- {
- CDialog::OnInitDialog();
- /*
- // TODO: Add extra initialization here
- m_tabSwitch.InsertItem(eTabMonster, "Monsters");
- m_tabSwitch.InsertItem(eTabPlayer, "Players");
- m_tabSwitch.InsertItem(eTabItem, "Items");
- // m_tabSwitch.InsertItem(3, "NPCs");
- // m_tabSwitch.InsertItem(4, "Portals");
- m_lstMonsters.InsertColumn( 0, _T("Id"), LVCFMT_LEFT, 50 );
- m_lstMonsters.InsertColumn( 1, _T("Name"), LVCFMT_LEFT, 50 );
- m_lstMonsters.InsertColumn( 2, _T("Attack"), LVCFMT_LEFT, 100 );
- m_lstMonsters.InsertColumn( 3, _T("Attack By"), LVCFMT_LEFT, 100 );
- m_lstMonsters.InsertColumn( 4, _T("PosTo"), LVCFMT_LEFT, 50 );
- m_lstPlayers.InsertColumn( 0, _T("Id"), LVCFMT_LEFT, 50 );
- m_lstPlayers.InsertColumn( 1, _T("Name"), LVCFMT_LEFT, 50 );
- m_lstPlayers.InsertColumn( 2, _T("Job"), LVCFMT_LEFT, 50 );
- m_lstPlayers.InsertColumn( 3, _T("Sex"), LVCFMT_LEFT, 50 );
- m_lstPlayers.InsertColumn( 4, _T("Pos"), LVCFMT_LEFT, 50 );
- m_lstPlayers.InsertColumn( 5, _T("PosTo"), LVCFMT_LEFT, 50 );
- m_lstItems.InsertColumn( 0, _T("Index"), LVCFMT_LEFT, 50 );
- m_lstItems.InsertColumn( 1, _T("Name"), LVCFMT_LEFT, 100);
- m_lstItems.InsertColumn( 2, _T("Amount"), LVCFMT_LEFT, 50 );
- m_lstItems.InsertColumn( 3, _T("Type"), LVCFMT_LEFT, 100 );
- ListView_SetExtendedListViewStyleEx(m_lstMonsters.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT, 0xFFFFFFFF);
- ListView_SetExtendedListViewStyleEx(m_lstPlayers.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT, 0xFFFFFFFF);
- ListView_SetExtendedListViewStyleEx(m_lstItems.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT, 0xFFFFFFFF);
- OnSelchangeTabSwitch2(NULL, NULL);
- */
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgEnv::OnSize(UINT nType, int cx, int cy)
- {
- if(SIZE_RESTORED == nType && ::IsWindow(m_tabSwitch.m_hWnd))
- {
- CRect rect;
- GetClientRect(rect);
- m_tabSwitch.SetWindowPos(&wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
- m_tabSwitch.GetClientRect(rect);
- rect.DeflateRect(CSize(10, 10));
- rect.top += 10;
- m_lstPortals.SetWindowPos(&wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
- m_lstNpcs.SetWindowPos(&wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
- m_lstItems.SetWindowPos(&wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
- m_lstPlayers.SetWindowPos(&wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
- m_lstMonsters.SetWindowPos(&wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
- }
- CDialog::OnSize(nType, cx, cy);
- }
- void CDlgEnv::OnSelchangeTabSwitch2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- int nIndex = m_tabSwitch.GetCurSel();
- m_lstMonsters.ShowWindow(nIndex == eTabMonster ? SW_SHOWNORMAL:SW_HIDE);
- m_lstPlayers.ShowWindow(nIndex == eTabPlayer ? SW_SHOWNORMAL:SW_HIDE);
- m_lstItems.ShowWindow(nIndex == eTabItem ? SW_SHOWNORMAL:SW_HIDE);
- switch(nIndex)
- {
- case eTabMonster:
- RefreshMonster();
- break;
- case eTabPlayer:
- RefreshPlayer();
- break;
- case eTabItem:
- RefreshItem();
- break;
- }
- if(pResult)
- *pResult = 0;
- }
- void CDlgEnv::RefreshMonster()
- {
- /* CString strValue, strTemp1, strTemp2;
- LVFINDINFO info;
- int nIndex;
- int i;
- // BOOL bAttack;
- // DWORD dwDamage, dwTemp1, dwTemp2;
- if(eTabMonster != m_tabSwitch.GetCurSel())
- return;
- info.flags = LVFI_STRING;
- for(i=0; i<monsters.GetSize(); i++)
- {
- strValue.Format("%X", monsters[i].dwId);
- info.psz = strValue.LockBuffer();
- nIndex = m_lstMonsters.FindItem(&info);
- if(-1 == nIndex)
- {
- nIndex = m_lstMonsters.InsertItem(m_lstMonsters.GetItemCount(), strValue);
- }
- strValue.UnlockBuffer();
- m_lstMonsters.SetItemText(nIndex, 1, monsters[i].cName);
- strValue.Format("(%d, %d)", monsters[i].pntTo.x, monsters[i].pntTo.y);
- m_lstMonsters.SetItemText(nIndex, 4, strValue);
- // Attacking
- // bAttack = damages.FindDamageTo(monsters[i].dwId, strTemp1, dwTemp1);
- // yourDamages.FindDamageTo(monsters[i].dwId, strTemp2, dwTemp2);
- // dwDamage = dwTemp1 + dwTemp2;
- // strValue.Format("[%d](%d):(%d)", dwDamage, dwTemp2, dwTemp1);
- // m_lstMonsters.SetItemText(nIndex, 2, strValue);
- // Attacked by
- // bAttack = damages.FindDamageFrom(monsters[i].dwId, strTemp1, dwTemp1);
- // yourDamages.FindDamageFrom(monsters[i].dwId, strTemp2, dwTemp2);
- // dwDamage = dwTemp1 + dwTemp2;
- // strValue.Format("[%d](%d):(%d)", dwDamage, dwTemp2, dwTemp1);
- // m_lstMonsters.SetItemText(nIndex, 3, strValue);
- }
- for(i=0; i<m_lstMonsters.GetItemCount(); i++)
- {
- strValue = m_lstMonsters.GetItemText(i, 0);
- if(!strValue.IsEmpty() && -1 == monsters.FindId(strValue))
- m_lstMonsters.DeleteItem(i);
- }
- m_lstMonsters.Invalidate();
- refreshReq.bMonster = false;
- */
- }
- void CDlgEnv::RefreshItem()
- {
- /*
- CString strValue;
- LVFINDINFO info;
- int nIndex;
- int i;
- if(eTabItem != m_tabSwitch.GetCurSel())
- return;
- info.flags = LVFI_STRING;
- for(i=0; i<items.GetSize(); i++)
- {
- strValue.Format("%X", items[i].dwId);
- info.psz = strValue.LockBuffer();
- nIndex = m_lstItems.FindItem(&info);
- if(-1 == nIndex)
- {
- nIndex = m_lstItems.InsertItem(m_lstItems.GetItemCount(), strValue);
- }
- strValue.UnlockBuffer();
- strValue = mapItem.FindValue(items[i].wType, eItemName);
- m_lstItems.SetItemText(nIndex, 1, strValue);
- strValue.Format("%d", items[i].wAmount);
- m_lstItems.SetItemText(nIndex, 2, strValue);
- // strValue.Format("%s", mapItemType.FindValue(items[i].wType));
- // m_lstItems.SetItemText(nIndex, 3, strValue);
- }
- for(i=0; i<m_lstItems.GetItemCount(); i++)
- {
- strValue = m_lstItems.GetItemText(i, 0);
- if(!strValue.IsEmpty() && -1 == items.FindId(strValue))
- m_lstItems.DeleteItem(i);
- }
- m_lstItems.Invalidate();
- refreshReq.bItem = false;
- */
- }
- void CDlgEnv::RefreshPlayer()
- {
- /*
- CString strValue;
- LVFINDINFO info;
- int nIndex;
- int i;
- if(eTabPlayer != m_tabSwitch.GetCurSel())
- return;
- info.flags = LVFI_STRING;
- for(i=0; i<players.GetSize(); i++)
- {
- strValue.Format("%X", players[i].dwId);
- info.psz = strValue.LockBuffer();
- nIndex = m_lstPlayers.FindItem(&info);
- if(-1 == nIndex)
- {
- nIndex = m_lstPlayers.InsertItem(m_lstPlayers.GetItemCount(), strValue);
- }
- strValue.UnlockBuffer();
- m_lstPlayers.SetItemText(nIndex, 1, players[i].cName);
- strValue.Format("%s", mapJob.FindValue(players[i].wType));
- m_lstPlayers.SetItemText(nIndex, 2, strValue);
- strValue.Format("%s", mapSex.FindValue(players[i].bySex));
- m_lstPlayers.SetItemText(nIndex, 3, strValue);
- strValue.Format("(%d, %d)", players[i].pntTo.x, players[i].pntTo.y);
- m_lstPlayers.SetItemText(nIndex, 4, strValue);
- }
- for(i=0; i<m_lstPlayers.GetItemCount(); i++)
- {
- strValue = m_lstPlayers.GetItemText(i, 0);
- if(!strValue.IsEmpty() && -1 == players.FindId(strValue))
- m_lstPlayers.DeleteItem(i);
- }
- m_lstPlayers.Invalidate();
- refreshReq.bPlayer = false;
- */
- }