Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
627
Server/ToolProject/ItemViewer/ItemViewerDlg.cpp
Normal file
627
Server/ToolProject/ItemViewer/ItemViewerDlg.cpp
Normal file
@@ -0,0 +1,627 @@
|
||||
// ItemViewerDlg.cpp : <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ItemViewer.h"
|
||||
#include "ItemViewerDlg.h"
|
||||
#include ".\itemviewerdlg.h"
|
||||
|
||||
#include <Item/ItemMgr.h>
|
||||
|
||||
#include <d3dx9.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> CAboutDlg <20><>ȭ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// <20><>ȭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV <20><><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
protected:
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CItemViewerDlg <20><>ȭ <20><><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
|
||||
CItemViewerDlg::CItemViewerDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CItemViewerDlg::IDD, pParent)
|
||||
, m_szItemScriptName(_T(""))
|
||||
, m_szSpriteFolderName(_T(""))
|
||||
, m_lpD3D(0), m_lpd3dDevice(0)
|
||||
{
|
||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||
}
|
||||
|
||||
void CItemViewerDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Text(pDX, IDC_ITEMSCRIPT_PATH, m_szItemScriptName);
|
||||
DDX_Text(pDX, IDC_SPRITE_PATH, m_szSpriteFolderName);
|
||||
DDX_Control(pDX, IDC_VIEWER_LOG, m_messageDlg);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CItemViewerDlg, CDialog)
|
||||
ON_WM_SYSCOMMAND()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_QUERYDRAGICON()
|
||||
//}}AFX_MSG_MAP
|
||||
ON_BN_CLICKED(IDC_LOAD_ITEMSCRIPT, OnBnClickedLoadItemscript)
|
||||
ON_BN_CLICKED(IDC_SET_SPRITE_FOLDER, OnBnClickedSetSpriteFolder)
|
||||
ON_BN_CLICKED(IDC_SAVE_ALL_ITEM, OnBnClickedSaveAllItem)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CItemViewerDlg <20><EFBFBD><DEBD><EFBFBD> ó<><C3B3><EFBFBD><EFBFBD>
|
||||
|
||||
BOOL CItemViewerDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// <20>ý<EFBFBD><C3BD><EFBFBD> <20><EFBFBD><DEB4><EFBFBD> "<22><><EFBFBD><EFBFBD>..." <20><EFBFBD> <20><EFBFBD><D7B8><EFBFBD> <20>߰<EFBFBD><DFB0>մϴ<D5B4>.
|
||||
|
||||
// IDM_ABOUTBOX<4F><58> <20>ý<EFBFBD><C3BD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>־<EFBFBD><D6BE><EFBFBD> <20>մϴ<D5B4>.
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// <20><> <20><>ȭ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><> â<><C3A2> <20><>ȭ <20><><EFBFBD>ڰ<EFBFBD> <20>ƴ<EFBFBD> <20><><EFBFBD>쿡<EFBFBD><ECBFA1>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>ũ<EFBFBD><C5A9> <20><> <20>۾<EFBFBD><DBBE><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
SetIcon(m_hIcon, TRUE); // ū <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
SetIcon(m_hIcon, FALSE); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
|
||||
// TODO: <20><><EFBFBD> <20>߰<EFBFBD> <20>ʱ<EFBFBD>ȭ <20>۾<EFBFBD><DBBE><EFBFBD> <20>߰<EFBFBD><DFB0>մϴ<D5B4>.
|
||||
|
||||
if(NULL == (m_lpD3D = Direct3DCreate9(D3D_SDK_VERSION)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
||||
d3dpp.Windowed = TRUE;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||
|
||||
if(FAILED(m_lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetSafeHwnd(),
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &m_lpd3dDevice)))
|
||||
{
|
||||
if(m_lpD3D != 0)
|
||||
{
|
||||
m_lpD3D->Release();
|
||||
m_lpD3D = 0;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char szFileName[MAX_PATH];
|
||||
char szDir[MAX_PATH];
|
||||
char szPath[MAX_PATH];
|
||||
char szName[MAX_PATH];
|
||||
char szExtension[MAX_PATH];
|
||||
|
||||
GetModuleFileName(NULL, szFileName, MAX_PATH);
|
||||
_splitpath(szFileName, szDir, szPath, szName, szExtension);
|
||||
_snprintf(m_szRegFileName, MAX_PATH - 1, "%s%sItemViewer.ini", szDir, szPath);
|
||||
_snprintf(m_szCurrentFolderName, MAX_PATH - 1, "%s%s", szDir, szPath);
|
||||
|
||||
char szItemScriptName[MAX_PATH];
|
||||
char szDDSFilePath[MAX_PATH];
|
||||
|
||||
GetPrivateProfileString("Ryl_ItemViewer", "LastItemScriptName", "",
|
||||
szItemScriptName, MAX_PATH, m_szRegFileName);
|
||||
|
||||
GetPrivateProfileString("Ryl_ItemViewer", "LastDDSFilePath", "",
|
||||
szDDSFilePath, MAX_PATH, m_szRegFileName);
|
||||
|
||||
m_szItemScriptName = szItemScriptName;
|
||||
m_szSpriteFolderName = szDDSFilePath;
|
||||
|
||||
int nFind = m_szItemScriptName.ReverseFind('.');
|
||||
if(0 < nFind)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
if(0 == strcmp(m_szItemScriptName.GetBuffer() + nFind + 1, "gsf"))
|
||||
{
|
||||
bResult = Item::CItemMgr::GetInstance().LoadItemProtoTypeBinary(m_szItemScriptName);
|
||||
}
|
||||
else if(0 == strcmp(m_szItemScriptName.GetBuffer() + nFind + 1, "txt"))
|
||||
{
|
||||
bResult = Item::CItemMgr::GetInstance().LoadItemProtoType(m_szItemScriptName);
|
||||
}
|
||||
|
||||
if(!bResult)
|
||||
{
|
||||
m_szItemScriptName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadSurfaces();
|
||||
}
|
||||
|
||||
m_messageDlg.SetTopIndex(
|
||||
m_messageDlg.AddString(bResult ? "ItemScript load success" : "ItemScript load failed."));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szItemScriptName.Empty();
|
||||
}
|
||||
|
||||
UpdateData(false);
|
||||
return TRUE; // <20><>Ʈ<EFBFBD>ѿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> TRUE<55><45> <20><>ȯ<EFBFBD>մϴ<D5B4>.
|
||||
}
|
||||
|
||||
void CItemViewerDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
||||
{
|
||||
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
||||
{
|
||||
CAboutDlg dlgAbout;
|
||||
dlgAbout.DoModal();
|
||||
}
|
||||
else
|
||||
{
|
||||
CDialog::OnSysCommand(nID, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
// <20><>ȭ <20><><EFBFBD>ڿ<EFBFBD> <20>ּ<EFBFBD>ȭ <20><><EFBFBD>߸<EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><D7B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20>Ʒ<EFBFBD> <20>ڵ尡 <20>ʿ<EFBFBD><CABF>մϴ<D5B4>. <20><><EFBFBD><EFBFBD>/<2F><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> MFC <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD>쿡<EFBFBD><ECBFA1>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD> <20><> <20>۾<EFBFBD><DBBE><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
|
||||
void CItemViewerDlg::OnPaint()
|
||||
{
|
||||
if (IsIconic())
|
||||
{
|
||||
CPaintDC dc(this); // <20><EFBFBD><D7B8>⸦ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD> <20><><EFBFBD>ؽ<EFBFBD>Ʈ
|
||||
|
||||
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
||||
|
||||
// Ŭ<><C5AC><EFBFBD>̾<EFBFBD>Ʈ <20>簢<EFBFBD><E7B0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EEB5A5> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
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;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><D7B8>ϴ<EFBFBD>.
|
||||
dc.DrawIcon(x, y, m_hIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDialog::OnPaint();
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD> <20>ּ<EFBFBD>ȭ<EFBFBD><C8AD> â<><C3A2> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ȿ<EFBFBD> Ŀ<><C4BF><EFBFBD><EFBFBD> ǥ<>õǵ<C3B5><C7B5><EFBFBD> <20>ý<EFBFBD><C3BD>ۿ<EFBFBD><DBBF><EFBFBD>
|
||||
// <20><> <20>Լ<EFBFBD><D4BC><EFBFBD> ȣ<><C8A3><EFBFBD>մϴ<D5B4>.
|
||||
HCURSOR CItemViewerDlg::OnQueryDragIcon()
|
||||
{
|
||||
return static_cast<HCURSOR>(m_hIcon);
|
||||
}
|
||||
|
||||
void CItemViewerDlg::OnOK()
|
||||
{
|
||||
// TODO: <20><><EFBFBD> Ư<><C6AF>ȭ<EFBFBD><C8AD> <20>ڵ带 <20>߰<EFBFBD> <20><>/<2F>Ǵ<EFBFBD> <20>⺻ Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD>մϴ<D5B4>.
|
||||
|
||||
// CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CItemViewerDlg::OnBnClickedLoadItemscript()
|
||||
{
|
||||
// TODO: <20><><EFBFBD> <20><>Ʈ<EFBFBD><C6AE> <20>˸<EFBFBD> ó<><C3B3><EFBFBD><EFBFBD> <20>ڵ带 <20>߰<EFBFBD><DFB0>մϴ<D5B4>.
|
||||
|
||||
OPENFILENAME openFileName;
|
||||
|
||||
memset(&openFileName, 0, sizeof(OPENFILENAME));
|
||||
|
||||
char szFileName[MAX_PATH];
|
||||
char szFilePathName[MAX_PATH];
|
||||
|
||||
memset(szFileName, 0, sizeof(char) * MAX_PATH);
|
||||
memset(szFilePathName, 0, sizeof(char) * MAX_PATH);
|
||||
|
||||
openFileName.lStructSize = sizeof(OPENFILENAME);
|
||||
|
||||
openFileName.hwndOwner = GetSafeHwnd();
|
||||
openFileName.lpstrFilter = "ItemScript file\0*.gsf;*.txt";
|
||||
openFileName.nMaxFile = MAX_PATH;
|
||||
openFileName.nMaxFileTitle = MAX_PATH;
|
||||
openFileName.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER;
|
||||
|
||||
openFileName.lpstrFile = szFileName;
|
||||
openFileName.lpstrFileTitle = szFilePathName;
|
||||
|
||||
if(GetOpenFileName(&openFileName))
|
||||
{
|
||||
UpdateData(true);
|
||||
|
||||
m_szItemScriptName = szFileName;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9>Ʈ<EFBFBD><C6AE> <20>ε<EFBFBD><CEB5>Ѵ<EFBFBD>.
|
||||
int nFind = m_szItemScriptName.ReverseFind('.');
|
||||
if(0 < nFind)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
if(0 == strcmp(m_szItemScriptName.GetBuffer() + nFind + 1, "gsf"))
|
||||
{
|
||||
bResult = Item::CItemMgr::GetInstance().LoadItemProtoTypeBinary(m_szItemScriptName);
|
||||
}
|
||||
else if(0 == strcmp(m_szItemScriptName.GetBuffer() + nFind + 1, "txt"))
|
||||
{
|
||||
bResult = Item::CItemMgr::GetInstance().LoadItemProtoType(m_szItemScriptName);
|
||||
}
|
||||
|
||||
if(!bResult)
|
||||
{
|
||||
m_szItemScriptName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadSurfaces();
|
||||
}
|
||||
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString(
|
||||
bResult ? "ItemScript load success" : "ItemScript load failed."));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szItemScriptName.Empty();
|
||||
}
|
||||
|
||||
WritePrivateProfileString("Ryl_ItemViewer", "LastItemScriptName", m_szItemScriptName, m_szRegFileName);
|
||||
UpdateData(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CItemViewerDlg::OnBnClickedSetSpriteFolder()
|
||||
{
|
||||
// TODO: <20><><EFBFBD> <20><>Ʈ<EFBFBD><C6AE> <20>˸<EFBFBD> ó<><C3B3><EFBFBD><EFBFBD> <20>ڵ带 <20>߰<EFBFBD><DFB0>մϴ<D5B4>.
|
||||
|
||||
OPENFILENAME openFileName;
|
||||
|
||||
memset(&openFileName, 0, sizeof(OPENFILENAME));
|
||||
|
||||
char szFileName[MAX_PATH];
|
||||
char szFilePathName[MAX_PATH];
|
||||
|
||||
memset(szFileName, 0, sizeof(char) * MAX_PATH);
|
||||
memset(szFilePathName, 0, sizeof(char) * MAX_PATH);
|
||||
|
||||
openFileName.lStructSize = sizeof(OPENFILENAME);
|
||||
|
||||
openFileName.hwndOwner = GetSafeHwnd();
|
||||
openFileName.lpstrFilter = "\0";
|
||||
openFileName.nMaxFile = MAX_PATH;
|
||||
openFileName.nMaxFileTitle = MAX_PATH;
|
||||
openFileName.Flags = OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER;
|
||||
|
||||
openFileName.lpstrFile = szFileName;
|
||||
openFileName.lpstrFileTitle = szFilePathName;
|
||||
|
||||
if(GetOpenFileName(&openFileName))
|
||||
{
|
||||
UpdateData(true);
|
||||
|
||||
m_szSpriteFolderName = szFileName;
|
||||
int nFind = m_szSpriteFolderName.ReverseFind('\\');
|
||||
if(0 < nFind)
|
||||
{
|
||||
m_szSpriteFolderName.GetBuffer()[nFind + 1] = 0;
|
||||
LoadSurfaces();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szSpriteFolderName.Empty();
|
||||
}
|
||||
|
||||
WritePrivateProfileString("Ryl_ItemViewer", "LastDDSFilePath", m_szSpriteFolderName, m_szRegFileName);
|
||||
UpdateData(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CItemViewerDlg::PostNcDestroy()
|
||||
{
|
||||
// TODO: <20><><EFBFBD> Ư<><C6AF>ȭ<EFBFBD><C8AD> <20>ڵ带 <20>߰<EFBFBD> <20><>/<2F>Ǵ<EFBFBD> <20>⺻ Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD>մϴ<D5B4>.
|
||||
ClearSurfaces();
|
||||
|
||||
if(m_lpd3dDevice != 0)
|
||||
{
|
||||
m_lpd3dDevice->Release();
|
||||
m_lpd3dDevice = 0;
|
||||
}
|
||||
|
||||
if(m_lpD3D != 0)
|
||||
{
|
||||
m_lpD3D->Release();
|
||||
m_lpD3D = 0;
|
||||
}
|
||||
|
||||
CDialog::PostNcDestroy();
|
||||
}
|
||||
|
||||
bool CItemViewerDlg::LoadSurfaces()
|
||||
{
|
||||
ClearSurfaces();
|
||||
|
||||
if(m_szItemScriptName.IsEmpty() || m_szSpriteFolderName.IsEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD nBufferSize = 512 * 1024;
|
||||
char* szBuffer = new char[nBufferSize];
|
||||
|
||||
if(0 == szBuffer)
|
||||
{
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString("Insufficient memory"));
|
||||
return false;
|
||||
}
|
||||
|
||||
CString szDDSFileName;
|
||||
CString szErrorMessage;
|
||||
|
||||
std::string spriteName;
|
||||
|
||||
|
||||
for(unsigned short usID = 0; usID < USHRT_MAX; ++usID)
|
||||
{
|
||||
const Item::ItemInfo* lpItemInfo = Item::CItemMgr::GetInstance().GetItemInfo(usID);
|
||||
if(0 != lpItemInfo)
|
||||
{
|
||||
spriteName.assign(lpItemInfo->m_SpriteData.m_szSpriteName);
|
||||
szDDSFileName.Format("%s%s.dds", m_szSpriteFolderName, lpItemInfo->m_SpriteData.m_szSpriteName);
|
||||
|
||||
LPDIRECT3DSURFACE9 lpItemSprite = 0;
|
||||
|
||||
SurfaceMap::iterator pos = m_surfaceMap.find(spriteName);
|
||||
if(pos == m_surfaceMap.end())
|
||||
{
|
||||
// Surface<63><65><EFBFBD><EFBFBD> <20><> Load
|
||||
const char* szErrorReason = 0;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
HANDLE hFile = CreateFile(szDDSFileName, GENERIC_READ, FILE_SHARE_READ, 0,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
|
||||
if(INVALID_HANDLE_VALUE != hFile)
|
||||
{
|
||||
DWORD dwHighSize = 0;
|
||||
DWORD dwLowSize = GetFileSize(hFile, &dwHighSize);
|
||||
|
||||
if(0 == dwHighSize)
|
||||
{
|
||||
if(nBufferSize < dwLowSize)
|
||||
{
|
||||
nBufferSize = dwLowSize;
|
||||
delete [] szBuffer;
|
||||
|
||||
szBuffer = new char[nBufferSize];
|
||||
}
|
||||
|
||||
if(0 != szBuffer)
|
||||
{
|
||||
DWORD dwTotalReadSize = 0;
|
||||
|
||||
do
|
||||
{
|
||||
DWORD dwReadSize = 0;
|
||||
|
||||
if(ReadFile(hFile, szBuffer,
|
||||
dwLowSize - dwTotalReadSize, &dwReadSize, 0))
|
||||
{
|
||||
dwTotalReadSize += dwReadSize;
|
||||
}
|
||||
|
||||
} while(dwTotalReadSize < dwLowSize);
|
||||
|
||||
szBuffer[0] = 'D';
|
||||
szBuffer[1] = 'D';
|
||||
szBuffer[2] = 'S';
|
||||
szBuffer[3] = ' ';
|
||||
|
||||
D3DXIMAGE_INFO imageInfo;
|
||||
memset(&imageInfo, 0, sizeof(D3DXIMAGE_INFO));
|
||||
|
||||
HRESULT hr = D3DXGetImageInfoFromFileInMemory(szBuffer, dwLowSize, &imageInfo);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
hr = m_lpd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width, imageInfo.Height,
|
||||
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpItemSprite, NULL);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
RECT srcRect;
|
||||
SetRect(&srcRect, 0, 0, imageInfo.Width, imageInfo.Height);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>ε尡 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
hr = D3DXLoadSurfaceFromFileInMemory(lpItemSprite,
|
||||
NULL, NULL, szBuffer, dwLowSize, &srcRect,
|
||||
D3DX_DEFAULT, 0xFF000000, NULL);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
m_surfaceMap.insert(std::make_pair(spriteName, lpItemSprite));
|
||||
}
|
||||
else
|
||||
{
|
||||
lpItemSprite->Release();
|
||||
lpItemSprite = 0;
|
||||
|
||||
szErrorReason = "LoadSurface failed";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szErrorReason = "Create offscreenBuffer failed";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szErrorReason = "Get imageInfo failed";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szErrorReason = "Buffer is NULL";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szErrorReason = "Too large sprite file";
|
||||
}
|
||||
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
szErrorReason = "File open failed";
|
||||
}
|
||||
|
||||
if(0 != szErrorReason)
|
||||
{
|
||||
szErrorMessage.Format("%s : %s.dds (%6d : %s)",
|
||||
szErrorReason, lpItemInfo->m_SpriteData.m_szSpriteName,
|
||||
usID, lpItemInfo->m_SpriteData.m_szName);
|
||||
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString(szErrorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete [] szBuffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CItemViewerDlg::ClearSurfaces()
|
||||
{
|
||||
SurfaceMap::iterator pos = m_surfaceMap.begin();
|
||||
SurfaceMap::iterator end = m_surfaceMap.end();
|
||||
|
||||
for(; pos != end; ++pos)
|
||||
{
|
||||
pos->second->Release();
|
||||
}
|
||||
|
||||
m_surfaceMap.clear();
|
||||
}
|
||||
|
||||
|
||||
void CItemViewerDlg::OnBnClickedSaveAllItem()
|
||||
{
|
||||
// TODO: <20><><EFBFBD> <20><>Ʈ<EFBFBD><C6AE> <20>˸<EFBFBD> ó<><C3B3><EFBFBD><EFBFBD> <20>ڵ带 <20>߰<EFBFBD><DFB0>մϴ<D5B4>.
|
||||
|
||||
if(0 == m_lpd3dDevice)
|
||||
{
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString("Invalid D3D Device"));
|
||||
return;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
CString szCurrentFolderName;
|
||||
szCurrentFolderName.Format("%sSavedItems\\", m_szCurrentFolderName);
|
||||
|
||||
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(szCurrentFolderName))
|
||||
{
|
||||
if (!CreateDirectory(szCurrentFolderName, 0))
|
||||
{
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString("Folder create failed"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CString szBMPFileName;
|
||||
CString szDDSFileName;
|
||||
CString szErrorMessage;
|
||||
|
||||
std::string spriteName;
|
||||
|
||||
for(unsigned short usID = 0; usID < USHRT_MAX; ++usID)
|
||||
{
|
||||
const Item::ItemInfo* lpItemInfo = Item::CItemMgr::GetInstance().GetItemInfo(usID);
|
||||
if(0 != lpItemInfo)
|
||||
{
|
||||
spriteName.assign(lpItemInfo->m_SpriteData.m_szSpriteName);
|
||||
szBMPFileName.Format("%s%6d - %s.bmp", szCurrentFolderName, usID, lpItemInfo->m_SpriteData.m_szName);
|
||||
|
||||
SurfaceMap::iterator pos = m_surfaceMap.find(spriteName);
|
||||
if(pos != m_surfaceMap.end())
|
||||
{
|
||||
LPDIRECT3DSURFACE9 lpItemSprite = pos->second;
|
||||
|
||||
if(0 != lpItemSprite)
|
||||
{
|
||||
RECT srcRect;
|
||||
SetRect(&srcRect,
|
||||
lpItemInfo->m_SpriteData.m_nSpriteMinX,
|
||||
lpItemInfo->m_SpriteData.m_nSpriteMinY,
|
||||
lpItemInfo->m_SpriteData.m_nSpriteMaxX,
|
||||
lpItemInfo->m_SpriteData.m_nSpriteMaxY);
|
||||
|
||||
HRESULT hr = D3DXSaveSurfaceToFile(szBMPFileName, D3DXIFF_BMP, lpItemSprite, 0, &srcRect);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
szErrorMessage.Format("Save sprite failed : failed to save %6d:%s",
|
||||
usID, lpItemInfo->m_SpriteData.m_szName);
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString(szErrorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
szErrorMessage.Format("Save sprite failed : failed to find %6d:%s",
|
||||
usID, lpItemInfo->m_SpriteData.m_szName);
|
||||
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString(szErrorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_messageDlg.SetTopIndex(m_messageDlg.AddString("Save sprite complete."));
|
||||
}
|
||||
Reference in New Issue
Block a user