// ViewMapSettings.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù.
|
//
|
|
#include "stdafx.h"
|
#include "ENRIT.h"
|
#include "ViewMapSettings.h"
|
#include "afxdialogex.h"
|
|
#define GRID_FIX_COLOR RGB(144,200,246)
|
#define GRID_COLOR RGB(242,242,242)
|
#define GRID_TEXT_COLOR RGB(255,255,255)
|
#define GRID_LINE_COLOR GRID_FIX_COLOR
|
// CViewMapSettings ´ëÈ »óÀÚÀÔ´Ï´Ù.
|
|
IMPLEMENT_DYNAMIC(CViewMapSettings, CDialogEx)
|
|
CViewMapSettings::CViewMapSettings(CWnd* pParent /*=NULL*/)
|
: CDialogEx(CViewMapSettings::IDD, pParent)
|
{
|
|
}
|
|
CViewMapSettings::~CViewMapSettings()
|
{
|
}
|
|
void CViewMapSettings::DoDataExchange(CDataExchange* pDX)
|
{
|
DDX_Control(pDX,IDC_GRD_CF_MAPSETTINGS,m_MapGrid[0]);
|
DDX_Control(pDX,IDC_GRD_TFT_MAPSETTINGS,m_MapGrid[1]);
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CViewMapSettings, CDialogEx)
|
ON_WM_SHOWWINDOW()
|
END_MESSAGE_MAP()
|
|
BEGIN_EVENTSINK_MAP(CViewMapSettings, CDialogEx)
|
ON_EVENT(CViewMapSettings, IDC_BTN_MAPSETTINGS_SAVE, DISPID_CLICK, CViewMapSettings::ClickMapSettinsSave, VTS_NONE)
|
ON_EVENT(CViewMapSettings, IDC_BTN_MAPSETTINGS_CLOSE, DISPID_CLICK, CViewMapSettings::OnClickMapSettinsClose, VTS_NONE)
|
END_EVENTSINK_MAP()
|
|
BOOL CViewMapSettings::OnInitDialog()
|
{
|
UpdateData(FALSE);
|
|
Init_Grid();
|
|
ZeroMemory(&m_MapsSettings,sizeof(_ST_MAPSETTINGS));
|
|
return TRUE;
|
}
|
|
void CViewMapSettings::OnShowWindow(BOOL bShow, UINT nStatus)
|
{
|
if(bShow == TRUE)
|
{
|
LoadMapSettings(m_MapsSettings);
|
Fill_Grid(TRUE);
|
}
|
}
|
|
void CViewMapSettings::LoadMapSettings(_ST_MAPSETTINGS &MapSettings)
|
{
|
CString strTaget = _T("C:\\RCutProject\\Config\\MapSettings.cfg");
|
|
CFileFind findFile;
|
BOOL bFind = findFile.FindFile(strTaget);
|
if(bFind == FALSE)
|
return;
|
|
CConfig Config;
|
CString str;
|
|
if (!Config.SetRegiConfig(NULL, NULL, (TCHAR*)(LPCTSTR)strTaget, FileMap_Mode))
|
return;
|
|
for(int k=0;k<2;k++)
|
{
|
for(int i=0;i<5;i++)
|
{
|
for(int j=0;j<4;j++)
|
{
|
str.Format(_T("MAP_%d_%d_%d"),k,i,j);
|
Config.GetItemValue((TCHAR*)(LPCTSTR)str, MapSettings.m_nMapIndex[k].m_nIndex[i][j]);
|
}
|
}
|
}
|
}
|
|
void CViewMapSettings::SaveMapSettings(_ST_MAPSETTINGS MapSettings)
|
{
|
CConfig Config;
|
CString str;
|
|
CString strTaget = _T("C:\\RCutProject\\Config\\MapSettings.cfg");
|
|
Config.SetRegiConfig(NULL, NULL, (TCHAR*)(LPCTSTR)strTaget, FileMap_Mode);
|
|
Config.SetRewriteMode(FALSE);
|
|
for(int k=0;k<2;k++)
|
{
|
for(int i=0;i<5;i++)
|
{
|
for(int j=0;j<4;j++)
|
{
|
str.Format(_T("MAP_%d_%d_%d"),k,i,j);
|
Config.SetItemValue((TCHAR*)(LPCTSTR)str, MapSettings.m_nMapIndex[k].m_nIndex[i][j]);
|
}
|
}
|
}
|
|
Config.WriteToFile();
|
}
|
|
void CViewMapSettings::ClickMapSettinsSave()
|
{
|
Fill_Grid(FALSE);
|
|
SaveMapSettings(m_MapsSettings);
|
|
CDialogEx::OnOK();
|
}
|
|
void CViewMapSettings::OnClickMapSettinsClose()
|
{
|
CDialogEx::OnCancel();
|
}
|
|
BOOL CViewMapSettings::PreTranslateMessage(MSG* pMsg)
|
{
|
if( pMsg->message == WM_KEYDOWN )
|
{
|
if(pMsg->wParam == VK_RETURN
|
|| pMsg->wParam == VK_ESCAPE )
|
{
|
::TranslateMessage(pMsg);
|
::DispatchMessage(pMsg);
|
return TRUE; // DO NOT process further
|
}
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
}
|
|
// CViewMapSettings ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù.
|
void CViewMapSettings::Init_Grid()
|
{
|
for(int i=0;i<2;i++)
|
{
|
if(m_MapGrid[i].GetSafeHwnd() == NULL)
|
continue;
|
|
m_MapGrid[i].GetDefaultCell(TRUE, FALSE)->SetBackClr(GRID_FIX_COLOR);
|
m_MapGrid[i].GetDefaultCell(FALSE, TRUE)->SetBackClr(GRID_FIX_COLOR);
|
m_MapGrid[i].GetDefaultCell(FALSE, FALSE)->SetBackClr(GRID_COLOR);
|
m_MapGrid[i].SetFixedBkColor(GRID_FIX_COLOR);
|
m_MapGrid[i].SetGridLines(GVL_BOTH);
|
|
m_MapGrid[i].SetColumnCount(5);
|
m_MapGrid[i].SetRowCount(6);
|
m_MapGrid[i].SetFixedRowCount(1);
|
m_MapGrid[i].SetFixedColumnCount(1);
|
m_MapGrid[i].ExpandColumnsToFit();
|
|
CFont *pFont = m_MapGrid[i].GetFont();
|
if (!pFont)
|
return;
|
|
LOGFONT lf;
|
pFont->GetLogFont(&lf);
|
lf.lfItalic = 0;
|
lf.lfHeight = 14;
|
lf.lfWeight = FW_BOLD;
|
_tcscpy(lf.lfFaceName, _T("Arial"));
|
|
m_MapGrid[i].GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
|
m_MapGrid[i].GetDefaultCell(FALSE, TRUE)->SetFont(&lf);
|
m_MapGrid[i].GetDefaultCell(TRUE, TRUE)->SetFont(&lf);
|
m_MapGrid[i].SetEditable(TRUE);
|
m_MapGrid[i].EnableSelection(TRUE);
|
|
Init_GridHeader(&m_MapGrid[i]);
|
}
|
}
|
|
void CViewMapSettings::Init_GridHeader(CGridCtrl *pGrid)
|
{
|
CString str;
|
GV_ITEM Item;
|
int nCol = 0;
|
int iLoop;
|
|
Item.mask = GVIF_TEXT;
|
Item.row = 0;
|
Item.col = 0;
|
|
Item.strText = _T("Side");
|
pGrid->SetItem(&Item);
|
|
nCol = 1;
|
for(iLoop=0;iLoop<5;iLoop++)
|
{
|
Item.col = nCol++;
|
Item.strText.Format(_T("%d"),iLoop+1);
|
pGrid->SetItem(&Item);
|
}
|
|
Item.col = 0;
|
Item.row = 1;
|
Item.strText.Format(_T("A"));
|
pGrid->SetItem(&Item);
|
|
Item.row = 2;
|
Item.strText.Format(_T("B"));
|
pGrid->SetItem(&Item);
|
|
Item.row = 3;
|
Item.strText.Format(_T("C"));
|
pGrid->SetItem(&Item);
|
|
Item.row = 4;
|
Item.strText.Format(_T("D"));
|
pGrid->SetItem(&Item);
|
|
Item.row = 5;
|
Item.strText.Format(_T("RCut"));
|
pGrid->SetItem(&Item);
|
|
pGrid->Invalidate();
|
}
|
|
void CViewMapSettings::Fill_Grid(BOOL bWrite)
|
{
|
int iRow,iCol;
|
int *pIndex;
|
CString str;
|
|
if(bWrite == TRUE)
|
{
|
for(int i=0;i<2;i++)
|
{
|
if(m_MapGrid[i].GetSafeHwnd() == NULL)
|
continue;
|
|
iRow = 1;
|
for(int k=0;k<5;k++)
|
{
|
pIndex = m_MapsSettings.m_nMapIndex[i].m_nIndex[k];
|
|
iCol = 1;
|
for(int j=0;j<4;j++)
|
{
|
str.Format(_T("%d"),pIndex[j]);
|
m_MapGrid[i].SetItemText(iRow,iCol,str);
|
iCol++;
|
}
|
iRow++;
|
}
|
|
m_MapGrid[i].Invalidate();
|
}
|
}
|
else
|
{
|
for(int i=0;i<2;i++)
|
{
|
if(m_MapGrid[i].GetSafeHwnd() == NULL)
|
continue;
|
|
iRow = 1;
|
for(int k=0;k<5;k++)
|
{
|
pIndex = m_MapsSettings.m_nMapIndex[i].m_nIndex[k];
|
|
iCol = 1;
|
for(int j=0;j<4;j++)
|
{
|
str = m_MapGrid[i].GetItemText(iRow,iCol);
|
pIndex[j] = _ttoi(str);
|
iCol++;
|
}
|
iRow++;
|
}
|
}
|
}
|
}
|