📄 dialogresource.cpp
字号:
// CDialogResource.cpp : implementation file
//
#include "stdafx.h"
#include "Architect.h"
#include "DialogResource.h"
#include "ArchitectDlg.h"
#include "3dgamemap.h"
#include <map>
#include <string>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogResource dialog
std::map<DWORD, std::string> g_setResMap;
CDialogResource::CDialogResource(CWnd* pParent /*=NULL*/)
: CDialog(CDialogResource::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogResource)
m_strSql = _T("");
//}}AFX_DATA_INIT
}
void CDialogResource::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogResource)
DDX_Control(pDX, IDC_RESOURCE_LIST, m_ResList);
DDX_Text(pDX, IDC_EDIT_SQL, m_strSql);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogResource, CDialog)
//{{AFX_MSG_MAP(CDialogResource)
ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
ON_BN_CLICKED(IDC_BTN_CLEAR, OnBtnClear)
ON_BN_CLICKED(IDC_BTN_SQL, OnBtnSql)
ON_LBN_SELCHANGE(IDC_RESOURCE_LIST, OnSelchangeResourceList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogResource message handlers
LRESULT CDialogResource::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if (message == WM_COMMAND)
{
if (wParam == 1|| wParam == 2)
{
return true;
}
}
return CDialog::WindowProc(message, wParam, lParam);
}
void CDialogResource::OnBtnAdd()
{
// TODO: Add your control notification handler code here
int nIndex = this->m_ResList.GetCurSel();
if(nIndex < 0)
return;
extern CArchitectDlg* g_pDialog;
g_pDialog->m_nMouseOperate = 21;
CMyPos posWorld={0, 0};
char strIndex[128];
m_ResList.GetText(nIndex, strIndex);
sscanf (strIndex,"%s %d",&m_szResName,&m_idResTmp);
}
void CDialogResource::OnBtnClear()
{
// TODO: Add your control notification handler code here
extern CArchitectDlg* g_pDialog;
g_pDialog->m_nMouseOperate = 22;
}
void CDialogResource::LoadResIni()
{
g_setResMap.clear();
char szTitle[255];
char szSubTitle[255];
char szFile[]="Mapresource.ini";
strcpy(szTitle, "资源信息");
strcpy(szSubTitle, "模版数量");
int nAmount;
if(!IniDataGet(szFile, szTitle, szSubTitle, nAmount))
return;
for(int i=0;i<nAmount;i++)
{
sprintf (szTitle,"TMP%d",i);
strcpy (szSubTitle, "NAME");
char szName[32]="";
IniStrGet(szFile, szTitle, szSubTitle, szName);
strcpy (szSubTitle, "ID");
int idTmp;
IniDataGet (szFile,szTitle,szSubTitle,idTmp);
char szInfo[64]="";
sprintf(szInfo,"%s %d",szName,idTmp);
m_ResList.InsertString(i, szInfo);
g_setResMap[idTmp] = szName;
}
}
BOOL CDialogResource::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
this->LoadResIni ();
m_strSql = _T("INSERT INTO cq_mapres VALUES(1000, %u, %u, %u);");
this->UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialogResource::OnBtnSql()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
char szTemp[1024];
sprintf(szTemp, "%s\n", m_strSql);
g_objGameMap.BuildMapResSql("res.sql", szTemp);
}
void CDialogResource::OnSelchangeResourceList()
{
// TODO: Add your control notification handler code here
int nIndex = this->m_ResList.GetCurSel();
if(nIndex < 0)
return;
CString m_strIndex;
m_ResList.GetText(nIndex, m_strIndex);
sscanf (m_strIndex,"%s %d",&m_szResName,&m_idResTmp);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -