// ClientSetupDlg.cpp : 구현 파일
//

#include "stdafx.h"
#include "ClientSetup.h"
#include "ClientSetupDlg.h"

#include "..\\..\\Engine\\zalla3d scene class\\InitValue.h"
#include "..\\..\\Engine\\zalla3d scene class\\RenderOption.h"
#include "SystemInfo.h"
#include ".\clientsetupdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


#define TAB_SYSTEM 0
#define TAB_GENERAL 1
#define TAB_ADVANCE 2
#define TAB_SPECIAL 3

using namespace SystemInfo;

// CClientSetupDlg 대화 상자
CSystemInfo *g_pSystemInfo = NULL;



CClientSetupDlg::CClientSetupDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CClientSetupDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_bInitWindow = FALSE;
}

void CClientSetupDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO_VIDEOCARD, m_cbVideoCard);
	DDX_Control(pDX, IDC_COMBO_MODE, m_cbResolution);
	DDX_Control(pDX, IDC_COMBO_COLOR, m_cbColor);
	DDX_Control(pDX, IDC_COMBO_REFRESH, m_cbRefresh);
	DDX_Control(pDX, IDC_COMBO_CHARSHADOW, m_cbCharShadow);
	DDX_Control(pDX, IDC_COMBO_SCREENFILTER, m_cbScreenEffect);
	DDX_Control(pDX, IDC_COMBO_LIGHTMAP, m_cbHouseShadow);
	DDX_Control(pDX, IDC_COMBO_ABLETEXTURE, m_cbTextureQuailty);
	DDX_Control(pDX, IDC_COMBO_RANGE, m_cbViewRange);
	DDX_Control(pDX, IDC_COMBO_GRASSRENDERING, m_cbGrass);
	DDX_Control(pDX, IDC_COMBO_QUALITY, m_cbQuality);
	DDX_Control(pDX, IDC_CONTROLTAB, m_tcControlTab);
	DDX_Control(pDX, IDC_COMBO_WATEREFFECT, m_cbWaterEffect);
	DDX_Control(pDX, IDC_COMBO_GLOWEFFECT, m_cbGlowEffect);
	DDX_Control(pDX, IDC_COMBO_WEATHEREFFECT, m_cbWeatherEffect);
	DDX_Control(pDX, IDC_COMBO_WINDOWMODE, m_cbWindowMode);
	DDX_Control(pDX, IDC_COMBO_LANGUAGE, m_cbLanguage);
	DDX_Control(pDX, IDC_MULTISUPPORT, m_btMultiSupport);
}

BEGIN_MESSAGE_MAP(CClientSetupDlg, CDialog)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_WM_DESTROY()
//	ON_WM_CREATE()
ON_WM_MOUSEMOVE()
//ON_WM_NCMOUSEMOVE()
ON_CBN_SELCHANGE(IDC_COMBO_VIDEOCARD, OnCbnSelchangeComboVideocard)
ON_CBN_SELCHANGE(IDC_COMBO_MODE, OnCbnSelchangeComboMode)
//ON_CBN_SELCHANGE(IDC_COMBO2, OnCbnSelchangeCombo2)
ON_CBN_SELCHANGE(IDC_COMBO_COLOR, OnCbnSelchangeComboColor)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
//ON_CBN_SELCHANGE(IDC_COMBO_QUALITY, OnCbnSelchangeComboQuality)
ON_CBN_SELCHANGE(IDC_COMBO_REFRESH, OnCbnSelchangeComboRefresh)
ON_NOTIFY(TCN_SELCHANGE, IDC_CONTROLTAB, OnTcnSelchangeControltab)
ON_CBN_SELCHANGE(IDC_COMBO_ABLETEXTURE, OnCbnSelchangeComboAbletexture)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
ON_CBN_SELCHANGE(IDC_COMBO_WINDOWMODE, OnCbnSelchangeComboWindowmode)
ON_STN_CLICKED(IDC_STATIC_WINDOWMODE, OnStnClickedStaticWindowmode)
END_MESSAGE_MAP()


extern HRESULT GetDXVersion( DWORD* pdwDirectXVersion, TCHAR* strDirectXVersion, int cchDirectXVersion );


// CClientSetupDlg 메시지 처리기
BOOL CClientSetupDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
	// 프레임워크가 이 작업을 자동으로 수행합니다.
	SetIcon(m_hIcon, TRUE);			// 큰 아이콘을 설정합니다.
	SetIcon(m_hIcon, FALSE);		// 작은 아이콘을 설정합니다.

	// TODO: 여기에 추가 초기화 작업을 추가합니다.
	m_hResource = LoadLibrary("Resource.dll");
	if(NULL == m_hResource)
	{
		CWnd::MessageBox("Load failed Resource Library.");

		return FALSE;
	}

	m_iOldResolution = 0;

	TCHAR strNation[MAX_PATH];
	ZeroMemory(strNation, sizeof(strNation));
	LoadString(m_hResource, IDS_LANGUAGE, strNation, 255);

	// 일단은 말레이시아만 예외처리를 합니다. 이 형태가 바뀔 경우 클라이언트와 런처도 수정이 필요합니다. (2004-11-30 by 로딘)
	strncpy(m_strRegRoot, "Software\\ROW\\MP-Client", MAX_PATH);

	g_pSystemInfo = new CSystemInfo;

	// 시스템 정보 얻어오기	
	{
		TCHAR strText[100];
		// Depth Bits 세팅
		LoadString(GetModuleHandle(NULL), IDS_MINDEPTHBITS, strText, 100);
		g_pSystemInfo->SetDepthBits((unsigned long)atoi(strText));
		// Stencil Bits 세팅
		LoadString(GetModuleHandle(NULL), IDS_MINSTENCILBITS, strText, 100);
		g_pSystemInfo->SetStencilBits((unsigned long)atoi(strText));

		g_pSystemInfo->GetWindowInfo();
		g_pSystemInfo->GetMemoryInfo();
		g_pSystemInfo->GetCPUInfo();
		g_pSystemInfo->GetDiskInfo();
		g_pSystemInfo->GetSoundCardInfo();
		g_pSystemInfo->GetVideoCardInfo();

		// 다이렉트 버젼 검사
		DWORD dwDirectXVersion = 0;
		TCHAR strDirectXVersion[10];

		HRESULT hr = GetDXVersion( &dwDirectXVersion, strDirectXVersion, 10 );
		if(dwDirectXVersion < 0x00080001)
		{
			MessageBox(IDS_ERR_NOTDX8);
			SendMessage(WM_CLOSE);

			return FALSE;
		}

		g_pSystemInfo->EnumulationD3D();
		g_pSystemInfo->GetAvailableDevice(800, 600);

		CString szText;
		// 윈도우 버젼
//		szText.Format("%s %s", g_pSystemInfo->m_strWindowName, g_pSystemInfo->m_strServiceVersion);
		GetDlgItem(IDC_OS)->SetWindowText(g_pSystemInfo->GetWindowName());

		// 메모리 용량
		szText.Format("%d MB (%d MB Free, %d MB FreePage)", (unsigned long)ceil(g_pSystemInfo->GetTotalPhysMem()),
			g_pSystemInfo->GetAvailPhysMem(), g_pSystemInfo->GetAvailPages());
		GetDlgItem(IDC_MEMORY)->SetWindowText(szText);

		// CPU 속도
		GetDlgItem(IDC_CPUSPEED)->SetWindowText(g_pSystemInfo->GetCPUInfo(0));

		// 디스크 정보
		szText.Format("%5.2f GB", g_pSystemInfo->GetHDDFreeSpace());
		GetDlgItem(IDC_HDDCAP)->SetWindowText(szText);

		// 다이렉트 버젼
		if( SUCCEEDED(hr) )
		{
			if( dwDirectXVersion > 0 )
				szText.Format("DirectX %s", strDirectXVersion);
			else
				szText.Format("DirectX not installed");
		} else
		{
			szText.Format("Unknown version of DirectX installed");
		}
		GetDlgItem(IDC_DIRECTVERSION)->SetWindowText(szText);
//		GetDlgItem(IDC_DIRECTVERSION)->SetWindowText(g_pDxDiagInfo->m_pSysInfo->m_szDirectXVersionLongEnglish);

		// 사운드 카드
		GetDlgItem(IDC_SOUNDCARD)->SetWindowText(g_pSystemInfo->GetSoundCardName());
	}

	// 설정 초기화
	{
		InitString();

		// 그림 컨트롤
		srand((unsigned)time(NULL));
		m_ctrlImage.Create(_T("my static"), WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE,
			CRect(12,11,170,311), this);
		m_ctrlImage.SetBitmap( ::LoadBitmap(m_hResource, MAKEINTRESOURCE(IDC_IMAGE01 + (rand() % 4))) );

		// 옵션초기화
		m_cbCharShadow.SetCurSel(1);
		m_cbHouseShadow.SetCurSel(1);
		m_cbViewRange.SetCurSel(1);
		m_cbTextureQuailty.SetCurSel(1);
		m_cbGrass.SetCurSel(1);

		m_cbScreenEffect.SetCurSel(1);
		m_cbWaterEffect.SetCurSel(1);
		m_cbWeatherEffect.SetCurSel(1);

		m_cbGlowEffect.SetCurSel(0);
		m_cbQuality.SetCurSel(0);
		m_cbWindowMode.SetCurSel(0);

#ifdef _RYL_LANGUAGE
		m_cbLanguage.SetCurSel(0);

		m_btMultiSupport.SetCheck(TRUE);
#endif

		SetGraphicCard();
		m_cbVideoCard.SetCurSel(0);

		SetResolution();
		m_cbResolution.SetCurSel(1);

		SetColor();
		m_cbColor.SetCurSel(1);

		SetRefresh();
		m_cbRefresh.SetCurSel(0);


		m_bInitWindow = FALSE;

		m_tcControlTab.SetCurSel(1);
		SetTabControl();

		UpdateData(FALSE);
	}

	// 자동 검색
	AutoDetect();

	// 레지에서 읽어서 셋팅
	{
		HKEY hMPClientReg;
		unsigned lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, m_strRegRoot, 0, KEY_READ, &hMPClientReg);
		if(ERROR_SUCCESS == lResult)
		{
			unsigned long dwReadType, dwReadLens;
			char strText[MAX_PATH] = "";
			unsigned long dwWidth, dwHeight, dwRefresh, dwColor, dwWindowMode, dwLanguage, dwMultiSupport;
			D3DFORMAT d3dFormat;
			dwReadLens = MAX_PATH;
			RegQueryValueEx(hMPClientReg, "Adapter", 0, &dwReadType, reinterpret_cast<unsigned char *>(strText), &dwReadLens);

			dwReadLens = sizeof(unsigned long);
			if(0 != RegQueryValueEx(hMPClientReg, "Width", 0, NULL, (LPBYTE)&dwWidth, &dwReadLens))
			{
				m_bInitWindow = TRUE;
			}

			if(0 != RegQueryValueEx(hMPClientReg, "Height", 0, NULL, (LPBYTE)&dwHeight, &dwReadLens))
			{
				m_bInitWindow = TRUE;
			}

			RegQueryValueEx(hMPClientReg, "Refresh", 0, NULL, (LPBYTE)&dwRefresh, &dwReadLens);

			RegQueryValueEx(hMPClientReg, "WindowMode", 0, NULL, (LPBYTE)&dwWindowMode, &dwReadLens);
			RegQueryValueEx(hMPClientReg, "Language", 0, NULL, (LPBYTE)&dwLanguage, &dwReadLens);
			RegQueryValueEx(hMPClientReg, "MLSupport", 0, NULL, (LPBYTE)&dwMultiSupport, &dwReadLens);

//			dwReadLens = sizeof(D3DFORMAT);

			RegQueryValueEx(hMPClientReg, "Depth", 0, NULL, (LPBYTE)&dwColor, &dwReadLens);
			d3dFormat = g_pSystemInfo->GetFormat(dwColor);

			for(unsigned long i = 0; i < g_pSystemInfo->GetNumAdapters(); ++i)
			{
				if(!strcmp(strText, g_pSystemInfo->GetGraphicCardName(i)))
				{
					g_pSystemInfo->m_dwCurrentVideoCard = i;
					m_cbVideoCard.SetCurSel(i);

					g_pSystemInfo->GetAvailableDevice(800, 600);

					break;
				}
			}

			char strResolution[MAX_PATH], strColor[MAX_PATH], strRefresh[MAX_PATH];
			unsigned dwNumRes, dwNumColor, dwNumRefresh;
			g_pSystemInfo->SetSetting(dwWidth, dwHeight, d3dFormat, dwRefresh);
			dwNumRes = g_pSystemInfo->m_dwCurrentResolution;
			dwNumColor = g_pSystemInfo->m_dwCurrentColor;
			dwNumRefresh = g_pSystemInfo->m_dwCurrentRefresh;

			// 레지에서 읽어서 해상도 설정
			SetResolution();
			g_pSystemInfo->m_dwCurrentResolution = dwNumRes;
			g_pSystemInfo->GetResolutionByString("%d x %d", strResolution);
			m_cbResolution.SetCurSel(m_cbResolution.FindString(0, strResolution));
			m_iOldResolution = m_cbResolution.GetCurSel();


			SetColor();
			g_pSystemInfo->m_dwCurrentColor = dwNumColor;
			g_pSystemInfo->GetColorByString("%d", strColor);
			m_cbColor.SetCurSel(m_cbColor.FindString(0, strColor));
			SetRefresh();
			g_pSystemInfo->m_dwCurrentRefresh = dwNumRefresh;
			g_pSystemInfo->GetRefreshByString("%d", strRefresh);
			m_cbRefresh.SetCurSel(m_cbRefresh.FindString(0, strRefresh));
			m_cbWindowMode.SetCurSel( dwWindowMode ) ;
#ifdef _RYL_LANGUAGE
			m_cbLanguage.SetCurSel( dwLanguage );

			m_btMultiSupport.SetCheck((int)dwMultiSupport);
#endif

			if(CRenderOption::Load(hMPClientReg) == true)
			{
				m_cbCharShadow.SetCurSel(CRenderOption::m_CharacterProjectShadowTerrain);
				m_cbHouseShadow.SetCurSel(CRenderOption::m_BuildingLightmap);
				m_cbViewRange.SetCurSel(CRenderOption::m_ObjectLOD - 1);
				m_cbTextureQuailty.SetCurSel(CRenderOption::m_TextureMethod);
				m_cbGrass.SetCurSel(CRenderOption::m_GrassRendering);

				m_cbScreenEffect.SetCurSel(CRenderOption::m_ScreenFilter);
				m_cbWaterEffect.SetCurSel(CRenderOption::m_WaterBumpEnvRendering);
				m_cbGlowEffect.SetCurSel(CRenderOption::m_bFullSceneEffect);
				m_cbWeatherEffect.SetCurSel(CRenderOption::m_bWeather);
			}
			
			RegCloseKey(hMPClientReg);

			UpdateData(FALSE);
		}
	}

	m_cbQuality.SetCurSel(GetQualityBySetting());

	m_dwOldWidth = g_pSystemInfo->GetCurrentWidth();
	m_dwOldHeight = g_pSystemInfo->GetCurrentHeight();

	return TRUE;  // 컨트롤에 대한 포커스를 설정하지 않을 경우 TRUE를 반환합니다.
}

void CClientSetupDlg::MessageBox(UINT nID)
{
	TCHAR strText[MAX_PATH];
	ZeroMemory(strText, sizeof(strText));
	LoadString(m_hResource, nID, strText, 255);
	CWnd::MessageBox(strText);
}

void CClientSetupDlg::AutoDetect(void)
{
	unsigned long dwPerformance = g_pSystemInfo->GetPerformance();

	// 사양
	m_cbQuality.SetCurSel(dwPerformance);

	// 캐릭터 그림자 : 사양
	switch(dwPerformance)
	{
		case 2:
		case 3:
			m_cbCharShadow.SetCurSel(1);
			break;

		default:
			m_cbCharShadow.SetCurSel(0);
			break;
	}

	// 화면효과 : Vertex Shader 1.1 이상, Pixel Shader 1.1 이상
	if(!g_pSystemInfo->GetAvailableShader(D3DPS_VERSION(1, 1), D3DVS_VERSION(1, 1)))
	{
//		m_cbScreenEffect.SetCurSel(0);
//		m_cbWaterEffect.SetCurSel(0);
		m_cbScreenEffect.SetCurSel(1);
		m_cbWaterEffect.SetCurSel(1);
	} 
	else
	{
		m_cbScreenEffect.SetCurSel(0);
		m_cbWaterEffect.SetCurSel(0);
	}

	// 글로우, 기후 효과 : 사양
	switch(dwPerformance)
	{
		case 2:
		case 3:
//			m_cbGlowEffect.SetCurSel(0);
//			m_cbWeatherEffect.SetCurSel(0);
			m_cbGlowEffect.SetCurSel(1);
			m_cbWeatherEffect.SetCurSel(1);
			break;

		default:
			m_cbGlowEffect.SetCurSel(0);
			m_cbWeatherEffect.SetCurSel(0);
			break;
	}

	// 집 그림자 : 사양, 메모리 용량
	if(g_pSystemInfo->IsAblePages(400))
	{
		switch(dwPerformance)
		{
			case 2:
			case 3:
				m_cbHouseShadow.SetCurSel(1);
				break;

			default:
				m_cbHouseShadow.SetCurSel(0);
				break;
		}
	} else
	{
		m_cbHouseShadow.SetCurSel(0);
	}

	// 텍스쳐 퀄리티 : DXT3, 메모리 용량
	if(g_pSystemInfo->GetAvailableHiResTexture(256, 256) &&
		g_pSystemInfo->GetAvailableCompressTexture(D3DFMT_DXT3) &&
		g_pSystemInfo->IsAblePages(400))
	{
		m_cbTextureQuailty.SetCurSel(1);
	} else
	{
		m_cbTextureQuailty.SetCurSel(0);
	}

	// 시야 범위 : 사양
	switch(dwPerformance)
	{
		case 2:
			m_cbViewRange.SetCurSel(1);
			break;
		case 3:
			m_cbViewRange.SetCurSel(2);
			break;

		default:
			m_cbViewRange.SetCurSel(0);
			break;
	}

	CRenderOption::m_GrassRenderRange = 9;

	// 풀 : 사양
	switch(dwPerformance)
	{
		case 2:
		case 3:
			CRenderOption::m_GrassRenderRange = 13;
			m_cbGrass.SetCurSel(1);
			break;

		default:
			m_cbGrass.SetCurSel(1);
			break;
	}
}

// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면 
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는
// 프레임워크에서 이 작업을 자동으로 수행합니다.

void CClientSetupDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
		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;

		// 아이콘을 그립니다.
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
//  이 함수를 호출합니다. 
HCURSOR CClientSetupDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CClientSetupDlg::OnDestroy()
{
	CDialog::OnDestroy();

	// TODO: 여기에 메시지 처리기 코드를 추가합니다.
	if(m_hResource)
	{
		FreeLibrary(m_hResource);
		m_hResource = NULL;
	}

    delete g_pSystemInfo;
}

void CClientSetupDlg::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.

	RECT rcRect;
	CPoint pPoint;
	GetWindowRect(&rcRect);
	pPoint.x = point.x + rcRect.left + 3;
	pPoint.y = point.y + rcRect.top + 29;

	static unsigned long dwOldFocus = 0;
	unsigned long dwNewFocus = 0;

	TCHAR strText[256];

	CWnd *pWnd;
	for(unsigned long i = 1000; i < 1023; ++i)
	{
		pWnd = GetDlgItem(i);
		if(pWnd && pWnd->IsWindowVisible())
		{
			pWnd->GetWindowRect(&rcRect);

			if(rcRect.left <= pPoint.x && pPoint.x <= rcRect.right && rcRect.top <= pPoint.y && pPoint.y <= rcRect.bottom)
			{
				dwNewFocus = i - 999;
				break;
			}
		}

		pWnd = GetDlgItem(i + 50);
		if(pWnd && pWnd->IsWindowVisible())
		{
			pWnd->GetWindowRect(&rcRect);

			if(rcRect.left <= pPoint.x && pPoint.x <= rcRect.right && rcRect.top <= pPoint.y && pPoint.y <= rcRect.bottom)
			{
				dwNewFocus = i - 999;
				break;
			}
		}
	}

	if(dwNewFocus != dwOldFocus)
	{
		ZeroMemory(strText, sizeof(strText));

		switch(dwNewFocus)
		{
			case 1:		// 운영체제
				switch(g_pSystemInfo->GetAbleWindowVersion())
				{
					case 1:
						LoadString(m_hResource, IDS_OS_WIN98, strText, 255);
						break;

					case 2:
						LoadString(m_hResource, IDS_OS_WINME, strText, 255);
						break;

					case 3:
						LoadString(m_hResource, IDS_OS_WIN2000, strText, 255);
						break;

					case 4:
						LoadString(m_hResource, IDS_OS_WINXP, strText, 255);
						break;

					default:
						LoadString(m_hResource, IDS_OS_ERROR, strText, 255);
						break;
				}
				break;

			case 2:		// 메모리
				if(g_pSystemInfo->IsTotalPhysMem(256))
				{
					LoadString(m_hResource, IDS_MEM_OK, strText, 255);
				} else
				{
					LoadString(m_hResource, IDS_MEM_ERROR, strText, 255);
				}
				break;

			case 3:		// CPU
				LoadString(m_hResource, IDS_CPU_DESC, strText, 255);
				break;

			case 4:		// 하드
				{
					if(g_pSystemInfo->GetHDDFreeSpace() > 2.0f)
					{
						LoadString(m_hResource, IDS_HDD_OK, strText, 255);
					} else
					{
						LoadString(m_hResource, IDS_HDD_ERROR, strText, 255);
					}
				}
				break;

			case 5:		// 다이렉트 버젼
				{
					DWORD dwDirectXVersion = 0;
					TCHAR strDirectXVersion[10];

					HRESULT hr = GetDXVersion( &dwDirectXVersion, strDirectXVersion, 10 );
					if(dwDirectXVersion < 0x00080001)
					{
						LoadString(m_hResource, IDS_DIRECTX_OK, strText, 255);
					} else
					{
						LoadString(m_hResource, IDS_DIRECTX_ERROR, strText, 255);
					}
				}
				break;

			case 6:		// 사운드카드
				if(strcmp("", g_pSystemInfo->GetSoundCardName()))
				{
					LoadString(m_hResource, IDS_SOUND_OK, strText, 255);
				} else
				{
					LoadString(m_hResource, IDS_SOUND_ERROR, strText, 255);
				}
				break;


			case 7:		// 비디오카드
				LoadString(m_hResource, IDS_VIDEO_DESC, strText, 255);
				break;

			case 8:		// 해상도
				LoadString(m_hResource, IDS_RESOLUTION_DESC, strText, 255);
				break;

			case 9:		// 칼라
				LoadString(m_hResource, IDS_COLOR_DESC, strText, 255);
				break;

			case 10:	// 주파수
				LoadString(m_hResource, IDS_FREQ_DESC, strText, 255);
				break;

			case 11:	// 옵션
				LoadString(m_hResource, IDS_GRAPHICOPTION_DESC, strText, 255);
				break;

			case 12:	// 게임포트
				LoadString(m_hResource, IDS_GAMEPORT_DESC, strText, 255);
				break;


			case 13:	// 캐릭터 그림자
				LoadString(m_hResource, IDS_CHARSHADOW_DESC, strText, 255);
				break;

			case 14:	// 집그림자
				if(g_pSystemInfo->IsAblePages(400))
				{
					LoadString(m_hResource, IDS_HOUSESHADOW_DESC, strText, 255);
				} else
				{
					LoadString(m_hResource, IDS_HOUSESHADOW_ERROR, strText, 255);
				}
				break;

			case 15:	// 시야범위
				LoadString(m_hResource, IDS_VIEWRANGE_DESC, strText, 255);
				break;

			case 16:	// 텍스쳐 퀄리티
				if(g_pSystemInfo->GetAvailableHiResTexture(256, 256) &&
					g_pSystemInfo->GetAvailableCompressTexture(D3DFMT_DXT3) &&
					g_pSystemInfo->IsAblePages(400))
				{
					LoadString(m_hResource, IDS_TEXTURE_DESC, strText, 255);
				} else
				{
					LoadString(m_hResource, IDS_TEXTURE_ERROR, strText, 255);
				}
				break;

			case 17:	// 풀
				LoadString(m_hResource, IDS_GRASS_DESC, strText, 255);
				break;


			case 18:	// 화면효과
				if(!g_pSystemInfo->GetAvailableShader(D3DPS_VERSION(1, 1), D3DVS_VERSION(1, 1)))
				{
					LoadString(m_hResource, IDS_SCREENEFFECT_DESC, strText, 255);
				} else
				{
					LoadString(m_hResource, IDS_SCREENEFFECT_ERROR, strText, 255);
				}
				break;

			case 19:	// 물효과
				if(!g_pSystemInfo->GetAvailableShader(D3DPS_VERSION(1, 1), D3DVS_VERSION(1, 1)))
				{
					LoadString(m_hResource, IDS_WATEREFFECT_DESC, strText, 255);
				} else
				{
					LoadString(m_hResource, IDS_WATEREFFECT_ERROR, strText, 255);
				}
				break;

			case 20:	// 글로우효과
				LoadString(m_hResource, IDS_GLOWEFFECT_DESC, strText, 255);
				break;

			case 21:	// 기후효과
				LoadString(m_hResource, IDS_WEATHEREFFECT_DESC, strText, 255);
				break;

			case 22:	// 윈도우모드
				LoadString(m_hResource, IDS_SCREEN_DESC, strText, 255);
				break;

			case 23:	// 언어
				LoadString(m_hResource, IDS_LANGUAGE_DESC, strText, 255);
				break;
		}

		GetDlgItem(IDC_DESC)->SetWindowText(strText);

		dwOldFocus = dwNewFocus;
	}

	CDialog::OnMouseMove(nFlags, point);
}

BOOL CClientSetupDlg::SetGraphicCard(void)
{
	m_cbVideoCard.ResetContent();

	g_pSystemInfo->m_dwCurrentVideoCard = 0xFFFFFFFF;

	for(unsigned int i = 0; i < g_pSystemInfo->GetNumAdapters(); ++i)
	{
		m_cbVideoCard.AddString(g_pSystemInfo->GetGraphicCardName(i));
		if(g_pSystemInfo->m_dwCurrentVideoCard == 0xFFFFFFFF) g_pSystemInfo->m_dwCurrentVideoCard = i;
	}

	return TRUE;
}

BOOL CClientSetupDlg::SetResolution(void)
{
	m_cbResolution.ResetContent();

	unsigned int i;
	for(i = 0; i < g_pSystemInfo->m_Adapters[g_pSystemInfo->m_dwCurrentVideoCard].dwNumDevices; ++i)
	{
		if(g_pSystemInfo->m_d3dAvailableDevices[i].DeviceType == D3DDEVTYPE_HAL) break;
	}

	if(i == g_pSystemInfo->m_Adapters[g_pSystemInfo->m_dwCurrentVideoCard].dwNumDevices)
	{
		MessageBox(IDS_ERR_NOHW);

		return FALSE;
	} else
	{
		g_pSystemInfo->m_dwCurrentDevice = i;
	}

	g_pSystemInfo->m_dwCurrentResolution = 0xFFFFFFFF;

	CString strText;
	for(i = 0; i < g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].dwNumModes; i++)
	{
		strText.Format("%d x %d", g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[i].Width,
			g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[i].Height);
		m_cbResolution.AddString(strText);

		if(g_pSystemInfo->m_dwCurrentResolution == 0xFFFFFFFF) g_pSystemInfo->m_dwCurrentResolution = i;
	}

	return TRUE;
}

BOOL CClientSetupDlg::SetColor(void)
{
	m_cbColor.ResetContent();

	g_pSystemInfo->m_dwCurrentColor = 0xFFFFFFFF;

	for(unsigned int i = 0; i < 10; ++i)
	{
		if(g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[g_pSystemInfo->m_dwCurrentResolution].Format[i].Format != 0)
		{
			switch(g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[g_pSystemInfo->m_dwCurrentResolution].Format[i].Format)
			{
				case D3DFMT_R5G6B5:
				case D3DFMT_X1R5G5B5:
				case D3DFMT_A1R5G5B5:
				case D3DFMT_A4R4G4B4:
				case D3DFMT_A8L8:
					if(m_cbColor.FindString(0, "16") < 0)
						m_cbColor.AddString("16");
					break;

				case D3DFMT_R8G8B8:
					if(m_cbColor.FindString(0, "24") < 0)
						m_cbColor.AddString("24");
					break;

				case D3DFMT_A8R8G8B8:
				case D3DFMT_X8R8G8B8:
				case D3DFMT_A8R3G3B2:
				case D3DFMT_X4R4G4B4:
				case D3DFMT_A2B10G10R10:
				case D3DFMT_G16R16:
					if(m_cbColor.FindString(0, "32") < 0)
						m_cbColor.AddString("32");
					break;
			}

			if(g_pSystemInfo->m_dwCurrentColor == 0xFFFFFFFF) g_pSystemInfo->m_dwCurrentColor = i;
		}
	}

	return TRUE;
}

BOOL CClientSetupDlg::SetRefresh(void)
{
	m_cbRefresh.ResetContent();

	g_pSystemInfo->m_dwCurrentRefresh = 0xFFFFFFFF;

	CString strText;
	for(unsigned long i = 0; i < 50; ++i)
	{
		if(g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[g_pSystemInfo->m_dwCurrentResolution].Format[g_pSystemInfo->m_dwCurrentColor].dwRefresh[i] != 0)
		{
			strText.Format("%d Hz", g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[g_pSystemInfo->m_dwCurrentResolution].Format[g_pSystemInfo->m_dwCurrentColor].dwRefresh[i]);
			m_cbRefresh.AddString(strText);

			if(g_pSystemInfo->m_dwCurrentRefresh == 0xFFFFFFFF) g_pSystemInfo->m_dwCurrentRefresh = i;
		}
	}

	return TRUE;
}
void CClientSetupDlg::OnCbnSelchangeComboVideocard()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	CString strCurrent;

	m_cbVideoCard.GetLBText(m_cbVideoCard.GetCurSel(), strCurrent);

	for(unsigned int i = 0; i < g_pSystemInfo->GetNumAdapters(); ++i)
	{
		if(!strCurrent.Compare(g_pSystemInfo->GetGraphicCardName(i)))
		{
			g_pSystemInfo->m_dwCurrentVideoCard = i;
			break;
		}
	}

	g_pSystemInfo->GetAvailableDevice(800, 600);

	SetResolution();
	m_cbResolution.SetCurSel(0);
	m_iOldResolution = 0;

	SetColor();
	m_cbColor.SetCurSel(0);
	SetRefresh();
	m_cbRefresh.SetCurSel(0);

	m_cbQuality.SetCurSel(GetQualityBySetting());
}

void CClientSetupDlg::OnCbnSelchangeComboMode()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	CString strText, strCurrent;

	m_cbResolution.GetLBText(m_cbResolution.GetCurSel(), strCurrent);

	for(unsigned long i = 0; i < g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].dwNumModes; i++)
	{
		strText.Format("%d x %d", g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[i].Width,
			g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[i].Height);
		if(!strCurrent.Compare(strText))
		{
			g_pSystemInfo->m_dwCurrentResolution = i;
			break;
		}
	}

	SetColor();
	m_cbColor.SetCurSel(0);
	SetRefresh();
	m_cbRefresh.SetCurSel(0);

	m_cbQuality.SetCurSel(GetQualityBySetting());
}

void CClientSetupDlg::OnCbnSelchangeComboColor()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	CString strText, strCurrent;

	m_cbColor.GetLBText(m_cbColor.GetCurSel(), strCurrent);

	for(unsigned int i = 0; i < 10; ++i)
	{
		if(g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[g_pSystemInfo->m_dwCurrentResolution].Format[i].Format != 0)
		{
			switch(g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[g_pSystemInfo->m_dwCurrentResolution].Format[i].Format)
			{
				case D3DFMT_R5G6B5:
				case D3DFMT_X1R5G5B5:
				case D3DFMT_A1R5G5B5:
				case D3DFMT_A4R4G4B4:
				case D3DFMT_A8L8:
					strText = "16";
					break;

				case D3DFMT_R8G8B8:
					strText = "24";
					break;

				case D3DFMT_A8R8G8B8:
				case D3DFMT_X8R8G8B8:
				case D3DFMT_A8R3G3B2:
				case D3DFMT_X4R4G4B4:
				case D3DFMT_A2B10G10R10:
				case D3DFMT_G16R16:
					strText = "32";
					break;
			}

			if(!strCurrent.Compare(strText))
			{
				g_pSystemInfo->m_dwCurrentColor = i;
				break;
			}
		}
	}

	SetRefresh();
	m_cbRefresh.SetCurSel(0);

	m_cbQuality.SetCurSel(GetQualityBySetting());
}

void CClientSetupDlg::WriteError(unsigned long dwErrorCode)
{
	LPVOID lpMsgBuf;
	CString strCaption;
	if(!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
		NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
		(LPTSTR) &lpMsgBuf, 0, NULL ))
	{
		// Handle the error.
		strCaption.Format("ClientSetup Error (Code = %d)", GetLastError());
		TCHAR strText[MAX_PATH];
		ZeroMemory(strText, sizeof(strText));
		LoadString(m_hResource, IDS_ERR_HANDLE, strText, 255);
		CWnd::MessageBox(strText, strCaption);
	} else
	{
		strCaption.Format("ClientSetup Error (Code = %d)", dwErrorCode);
		CWnd::MessageBox((LPCTSTR)lpMsgBuf, strCaption);
	}

	LocalFree(lpMsgBuf);
}

BOOL CClientSetupDlg::CreateReg(HKEY hReg)
{
	TCHAR strFile[MAX_PATH];
	TCHAR strPath[MAX_PATH], strTemp[MAX_PATH];

	strcpy(strFile, AfxGetApp()->m_pszExeName);
	strcat(strFile, ".exe");
	strcpy(strTemp, strdup(strFile));
	strcpy(strFile, strlwr(strTemp));

	GetModuleFileName(NULL, strPath, sizeof(strPath));
	strcpy(strTemp, strPath);
	strcpy(strTemp, strlwr(strTemp));

	TCHAR *strCmp;
	strCmp = strstr(strTemp, strFile);
	int nResult = (int)(strCmp - strTemp - 1);

	TCHAR strFolderValue[MAX_PATH];
	strncpy(strFolderValue, strPath, nResult);
	strFolderValue[nResult] = '\0';

	TCHAR strFolder[100];
	LoadString(m_hResource, IDS_FOLDER, strFolder, 100);

	long lResult = RegSetValueEx(hReg, strFolder, 0, REG_SZ, (LPBYTE)strFolderValue, (unsigned long)strlen(strFolderValue));
	if(ERROR_SUCCESS != lResult)
	{
		WriteError(lResult);
		return FALSE;
	}

	return TRUE;
}

void CClientSetupDlg::OnBnClickedOk()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	UpdateData(TRUE);

	HKEY hMPClientReg;
	long lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, m_strRegRoot, 0, KEY_ALL_ACCESS, &hMPClientReg);

	if(ERROR_SUCCESS != lResult)
	{
		if(ERROR_FILE_NOT_FOUND == lResult)
		{
			unsigned long dwDisp = 0;
			lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, m_strRegRoot, 0, NULL, REG_OPTION_NON_VOLATILE,
				KEY_ALL_ACCESS, NULL, &hMPClientReg, &dwDisp);
			if(ERROR_SUCCESS != lResult)
			{
				WriteError(lResult);
				return;
			}

			if(FALSE == CreateReg(hMPClientReg))
			{
				RegCloseKey(hMPClientReg);
				return;
			} else
			{
				m_bInitWindow = TRUE;
			}
		} else
		{
			WriteError(lResult);
			return;
		}
	}

	// 비디오카드
	char *strText;
	strText = g_pSystemInfo->GetGraphicCardName(g_pSystemInfo->m_dwCurrentVideoCard);
	RegSetValueEx(hMPClientReg, "Adapter", 0, REG_SZ, (LPBYTE)strText, (unsigned long)strlen(strText));

	unsigned long dwValue;

	// 해상도
	dwValue = g_pSystemInfo->GetCurrentWidth();
	RegSetValueEx(hMPClientReg, "Width", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
	dwValue = g_pSystemInfo->GetCurrentHeight();
	RegSetValueEx(hMPClientReg, "Height", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));

	if(m_iOldResolution != g_pSystemInfo->m_dwCurrentResolution)
	{
		RegDeleteValue(hMPClientReg, "DlgControl");
		RegDeleteValue(hMPClientReg, "SiegeTime");
		RegDeleteValue(hMPClientReg, "QuickSlot");
		RegDeleteValue(hMPClientReg, "Status");
		RegDeleteValue(hMPClientReg, "Enchant");
		RegDeleteValue(hMPClientReg, "Chat");
  	}

	// 색상
//	dwValue = g_pSystemInfo->GetCurrentColor();
	switch(g_pSystemInfo->GetCurrentColor())
	{
		case D3DFMT_R5G6B5:
		case D3DFMT_X1R5G5B5:
		case D3DFMT_A1R5G5B5:
		case D3DFMT_A4R4G4B4:
		case D3DFMT_A8L8:
			dwValue = 16;
			break;

		case D3DFMT_R8G8B8:
			dwValue = 24;
			break;

		case D3DFMT_A8R8G8B8:
		case D3DFMT_X8R8G8B8:
		case D3DFMT_A8R3G3B2:
		case D3DFMT_X4R4G4B4:
		case D3DFMT_A2B10G10R10:
		case D3DFMT_G16R16:
			dwValue = 32;
			break;

		default:
			dwValue = 16;
			break;
	}
	RegSetValueEx(hMPClientReg, "Depth", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));

	// 주파수
	dwValue = g_pSystemInfo->GetCurrentRefresh();
	RegSetValueEx(hMPClientReg, "Refresh", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));

	// 원도우 모드
	dwValue = m_cbWindowMode.GetCurSel() ;
	RegSetValueEx(hMPClientReg, "WindowMode", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));

#ifdef _RYL_LANGUAGE

	// 언어 모드
	dwValue = m_cbLanguage.GetCurSel() ;
	RegSetValueEx(hMPClientReg, "Language", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
	
	// 멀티 랭귀지
	dwValue = m_btMultiSupport.GetCheck();
	RegSetValueEx(hMPClientReg, "MLSupport", 0, NULL, (LPBYTE)&dwValue, sizeof(unsigned long));
#endif

	// InitValue 저장
	{
		CInitValue pInit;
		pInit.m_lScreenX = g_pSystemInfo->GetCurrentWidth();
		pInit.m_lScreenY = g_pSystemInfo->GetCurrentHeight();

		CString strColor;
		m_cbColor.GetLBText(m_cbColor.GetCurSel(), strColor);
		pInit.m_lScreenColorDepth = atoi(strColor);

		if(pInit.Save(hMPClientReg) == false)
		{
			MessageBox(IDS_ERR_INITVALUE);
		}
	}

	// RenderOption 저장
	{
		CRenderOption::m_TerrainMultiDetalTexture = m_cbTextureQuailty.GetCurSel();
		CRenderOption::m_GrassRendering = m_cbGrass.GetCurSel();
		CRenderOption::m_RangeGrassRender = 0;

		switch (m_cbViewRange.GetCurSel())
		{
			case 0:
				CRenderOption::m_TerrainRange = 3;
				CRenderOption::m_ObjectLOD = 1;
				break;

			case 1:	
				CRenderOption::m_TerrainRange = 5;
				CRenderOption::m_ObjectLOD = 2;
				break;

			case 2:	
				CRenderOption::m_TerrainRange = 7;
				CRenderOption::m_ObjectLOD = 3;
				break;
		}	

		CRenderOption::m_BuildingLightmap = m_cbHouseShadow.GetCurSel();
		CRenderOption::m_CharacterProjectShadowTerrain = m_cbCharShadow.GetCurSel();
		CRenderOption::m_CharacterProjectShadowBuilding = m_cbCharShadow.GetCurSel();		
		CRenderOption::m_TextureMethod = m_cbTextureQuailty.GetCurSel();			

		if(!g_pSystemInfo->GetAvailableShader(D3DPS_VERSION(1, 1), D3DVS_VERSION(1, 1)))
		{
			CRenderOption::m_ScreenFilter = m_cbScreenEffect.GetCurSel();
			CRenderOption::m_WaterBumpEnvRendering = m_cbWaterEffect.GetCurSel();
//			CRenderOption::m_bFullSceneEffect = m_cbGlowEffect.GetCurSel();
			CRenderOption::m_bFullSceneEffect = 0;
		} else
		{
			CRenderOption::m_ScreenFilter = 0;
			CRenderOption::m_WaterBumpEnvRendering = 0;
			CRenderOption::m_bFullSceneEffect = 0;
		}

		CRenderOption::m_bWeather = m_cbWeatherEffect.GetCurSel();

		// ----------------------------------------------------------------------------------
		// GeForce3 Option 

		CRenderOption::m_CharacterPerPixelLighting = 0;
		CRenderOption::m_CharacterPerPixelSpecularLighting = 0;	
		CRenderOption::m_GrassAnimationUseVertexShader = 0;


		CRenderOption::m_FullSceneAnti = 0;
		CRenderOption::m_FullSceneSpecularGlare = 0;
		CRenderOption::m_TreeAnimation = 1;
		CRenderOption::m_CharacterPerPixelLighting = 0;
		CRenderOption::m_CharacterPerPixelSpecularLighting = 0;
		CRenderOption::m_CharacterSelfShadow = 0;
		CRenderOption::m_DepthOfField = 0;
		CRenderOption::m_FullSceneGlare = 0;

		if(CRenderOption::Save(hMPClientReg) == false)
		{
			MessageBox(IDS_ERR_RENDEROPTION);
		}
	}

	// 게임 인터페이스 초기화
	{
		if(m_dwOldWidth != g_pSystemInfo->GetCurrentWidth() || m_dwOldHeight != g_pSystemInfo->GetCurrentHeight())
			m_bInitWindow = TRUE;

		if(m_bInitWindow)
		{
			unsigned long dwValue = 0;

			RegSetValueEx(hMPClientReg, "Vertical", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
			
			dwValue = 1;
			RegSetValueEx(hMPClientReg, "ChatDlgType", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));

			dwValue = RYLMAINWINDOW::ALL_WINDOW;
			RegSetValueEx(hMPClientReg, "VisibleFlag", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
/*
			switch(g_pSystemInfo->GetCurrentWidth())
			{
				case 800:
					{
						dwValue = MAKELONG(555, 559);	RegSetValueEx(hMPClientReg, "DlgControl", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(238, 560);	RegSetValueEx(hMPClientReg, "QuickSlot", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 559);		RegSetValueEx(hMPClientReg, "Status", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 116);		RegSetValueEx(hMPClientReg, "Enchant", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(237, 438);	RegSetValueEx(hMPClientReg, "Chat", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
					}
					break;

				case 1024:
					{
						dwValue = MAKELONG(779, 727);	RegSetValueEx(hMPClientReg, "DlgControl", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(461, 727);	RegSetValueEx(hMPClientReg, "QuickSlot", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 727);		RegSetValueEx(hMPClientReg, "Status", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 116);		RegSetValueEx(hMPClientReg, "Enchant", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(461, 606);	RegSetValueEx(hMPClientReg, "Chat", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
					}
					break;

				case 1280:
					{
						dwValue = MAKELONG(1035, 919);	RegSetValueEx(hMPClientReg, "DlgControl", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 920);		RegSetValueEx(hMPClientReg, "QuickSlot", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 878);		RegSetValueEx(hMPClientReg, "Status", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 116);		RegSetValueEx(hMPClientReg, "Enchant", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(472, 839);	RegSetValueEx(hMPClientReg, "Chat", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
					}
					break;

				case 1600:
					{
						dwValue = MAKELONG(1355, 1159);	RegSetValueEx(hMPClientReg, "DlgControl", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(1037, 1159);	RegSetValueEx(hMPClientReg, "QuickSlot", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 1159);	RegSetValueEx(hMPClientReg, "Status", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 116);		RegSetValueEx(hMPClientReg, "Enchant", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 1079);	RegSetValueEx(hMPClientReg, "Chat", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
					}
					break;

				default:
					{
						dwValue = MAKELONG(555, 559);	RegSetValueEx(hMPClientReg, "DlgControl", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(238, 560);	RegSetValueEx(hMPClientReg, "QuickSlot", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 559);		RegSetValueEx(hMPClientReg, "Status", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(0, 116);		RegSetValueEx(hMPClientReg, "Enchant", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
						dwValue = MAKELONG(237, 438);	RegSetValueEx(hMPClientReg, "Chat", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(unsigned long));
					}
					break;
			}
*/
		}
	}

	RegCloseKey(hMPClientReg);

	OnOK();
}

void CClientSetupDlg::OnBnClickedCancel()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	// Minotaurs 처음 셋업이면 무조껀 OK~
	HKEY hKey = NULL;

	BOOL bCheckSetup = FALSE;

	if(
		RegOpenKeyEx( HKEY_LOCAL_MACHINE, STR_CLIENT_REGISTRY_SUBKEY, 0, KEY_READ, &hKey ) !=
		ERROR_SUCCESS )
	{
		MessageBox( IDS_ERR_NOTINSTALL );
		PostQuitMessage(0);
		EndDialog(0);
	}
	else
	{
		CInitValue ci;
		ci.Init();
		if( false == ci.Load( hKey ) )
		{
			bCheckSetup = TRUE;
		}

		if( false == CRenderOption::Load( hKey ) )
		{
			bCheckSetup = TRUE;
		}
	}

	if(bCheckSetup)
		OnBnClickedOk();
	else
		OnCancel();
}

//void CClientSetupDlg::OnCbnSelchangeComboQuality()
//{
//	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
//	SetSettingByQuality(m_cbQuality.GetCurSel());
//}

void CClientSetupDlg::OnCbnSelchangeComboRefresh()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	CString strText, strCurrent;

	m_cbRefresh.GetLBText(m_cbRefresh.GetCurSel(), strCurrent);

	for(unsigned int i = 0; i < 50; ++i)
	{
		strText.Format("%d Hz", g_pSystemInfo->m_d3dAvailableDevices[g_pSystemInfo->m_dwCurrentDevice].modes[g_pSystemInfo->m_dwCurrentResolution].Format[g_pSystemInfo->m_dwCurrentColor].dwRefresh[i]);
		if(!strCurrent.Compare(strText))
		{
			g_pSystemInfo->m_dwCurrentRefresh = i;
			break;
		}
	}
}

void CClientSetupDlg::OnTcnSelchangeControltab(NMHDR *pNMHDR, LRESULT *pResult)
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	SetTabControl();
	m_cbQuality.SetCurSel(GetQualityBySetting());

	*pResult = 0;
}

void CClientSetupDlg::OnCbnSelchangeComboAbletexture()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
}

void CClientSetupDlg::SetTabControl(void)
{
	// 속도에는 안 좋은 코드 switch문으로 처리하는게 더 속도가 빠르나, 속도가 필요없으므로...
	long lSel = m_tcControlTab.GetCurSel();

	// 시스템
	GetDlgItem(IDC_STATIC_OS)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_OS)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_MEMORY)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_MEMORY)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_CPUSPEED)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_CPUSPEED)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_HDDCAP)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_HDDCAP)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_DIRECTVERSION)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_DIRECTVERSION)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_SOUNDCARD)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_SOUNDCARD)->ShowWindow((lSel == TAB_SYSTEM)? SW_SHOW : SW_HIDE);

	// 기본 옵션
	GetDlgItem(IDC_STATIC_VIDEOCARD)->ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	m_cbVideoCard.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_RES)->ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	m_cbResolution.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_COLOR)->ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	m_cbColor.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_REFRESH)->ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	m_cbRefresh.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);

//	GetDlgItem(IDC_STATIC_OPTIONSIMPLE)->ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
//	m_cbQuality.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);

	GetDlgItem(IDC_STATIC_WINDOWMODE)->ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	m_cbWindowMode.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);

#ifdef _RYL_LANGUAGE
	GetDlgItem(IDC_STATIC_LANGUAGE)->ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
	m_cbLanguage.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);

	m_btMultiSupport.ShowWindow((lSel == TAB_GENERAL)? SW_SHOW : SW_HIDE);
#else
	GetDlgItem(IDC_STATIC_LANGUAGE)->ShowWindow(SW_HIDE);
	m_cbLanguage.ShowWindow(SW_HIDE);

	m_btMultiSupport.ShowWindow(SW_HIDE);
#endif

	
	// 윈도우모드 Hide 한다.
	GetDlgItem(IDC_STATIC_WINDOWMODE)->ShowWindow(SW_HIDE);
	m_cbWindowMode.ShowWindow(SW_HIDE);

	// 세부 옵션
	GetDlgItem(IDC_STATIC_CHARACTERSHADOW)->ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	m_cbCharShadow.ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_HOUSESHADOW)->ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	m_cbHouseShadow.ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_VIEWRANGE)->ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	m_cbViewRange.ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_TEXTURE)->ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	m_cbTextureQuailty.ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_GRASS)->ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);
	m_cbGrass.ShowWindow((lSel == TAB_ADVANCE)? SW_SHOW : SW_HIDE);

	// 특수 효과
	GetDlgItem(IDC_STATIC_SCREENFILTER)->ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
	m_cbScreenEffect.ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
	if(!g_pSystemInfo->GetAvailableShader(D3DPS_VERSION(1, 1), D3DVS_VERSION(1, 1)))
	{
		m_cbScreenEffect.EnableWindow();
	} else
	{
		m_cbScreenEffect.SetCurSel(0);
		m_cbScreenEffect.EnableWindow(FALSE);
	}
	GetDlgItem(IDC_STATIC_WATEREFFECT)->ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
	m_cbWaterEffect.ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
	if(!g_pSystemInfo->GetAvailableShader(D3DPS_VERSION(1, 1), D3DVS_VERSION(1, 1)))
	{
		m_cbWaterEffect.EnableWindow();
	} else
	{
		m_cbWaterEffect.SetCurSel(0);
		m_cbWaterEffect.EnableWindow(FALSE);
	}
	GetDlgItem(IDC_STATIC_GLOWEFFECT)->ShowWindow(SW_HIDE);
	m_cbGlowEffect.ShowWindow(SW_HIDE);
	if(!g_pSystemInfo->GetAvailableShader(D3DPS_VERSION(1, 1), D3DVS_VERSION(1, 1)))
	{
		m_cbGlowEffect.EnableWindow();
	} else
	{
		m_cbGlowEffect.SetCurSel(0);
		m_cbGlowEffect.EnableWindow(FALSE);
	}
//	GetDlgItem(IDC_STATIC_GLOWEFFECT)->ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
//	m_cbGlowEffect.ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
	GetDlgItem(IDC_STATIC_WEATHEREFFECT)->ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
	m_cbWeatherEffect.ShowWindow((lSel == TAB_SPECIAL)? SW_SHOW : SW_HIDE);
}

void CClientSetupDlg::InitString(void)
{
	TCHAR strText[MAX_PATH], strLanguage[MAX_PATH];

	LoadString(m_hResource, IDS_APP_TITLE, strText, 255);						// 애플리케이션 이름
	LoadString(m_hResource, IDS_LANGUAGE, strLanguage, 255);
	sprintf(strText, "%s (%s)", strText, strLanguage);
	SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_NOTEXIST, strText, 255);					// 없음
	m_cbCharShadow.AddString(strText);
	m_cbScreenEffect.AddString(strText);
	m_cbHouseShadow.AddString(strText);
	m_cbGrass.AddString(strText);
	m_cbWaterEffect.AddString(strText);
	m_cbGlowEffect.AddString(strText);
	m_cbWeatherEffect.AddString(strText);
	

	LoadString(m_hResource, IDS_LOCAL_EXIST, strText, 255);						// 있음
	m_cbCharShadow.AddString(strText);
	m_cbScreenEffect.AddString(strText);
	m_cbHouseShadow.AddString(strText);
	m_cbGrass.AddString(strText);
	m_cbWaterEffect.AddString(strText);
	m_cbGlowEffect.AddString(strText);
	m_cbWeatherEffect.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_FULLSCREEN, strText, 255);				// Full screen
	m_cbWindowMode.AddString(strText) ;

//	LoadString(m_hResource, IDS_LOCAL_WINDOWMODE, strText, 255);				// Window screen
//	m_cbWindowMode.AddString(strText) ;

#ifdef _RYL_LANGUAGE
	int iMaxLanguage = 7;

	// 언어추가
	for(int i = 0; i < iMaxLanguage; ++i)
	{
		LoadString(m_hResource, IDS_LOCAL_LANGUAGE1+i, strText, 255);					// Language1 (영어)
		m_cbLanguage.AddString(strText) ;
	}

	LoadString(m_hResource, IDS_LOCAL_MULTILANGUAGESUPPORT, strText, 255);						// 낮음
	m_btMultiSupport.SetWindowText(strText);
#endif
	
	LoadString(m_hResource, IDS_LOCAL_LOW, strText, 255);						// 낮음
	m_cbTextureQuailty.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_HIGH, strText, 255);						// 높음
	m_cbTextureQuailty.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_LOWSETTING, strText, 255);				// 단거리
	m_cbViewRange.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_MEDIUMSETTING, strText, 255);				// 중거리
	m_cbViewRange.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_HIGHSETTING, strText, 255);				// 장거리
	m_cbViewRange.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_CUSTOMSETTING, strText, 255);				// 사용자 지정
	m_cbQuality.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_LOWSETTING, strText, 255);				// 최소 사양
	m_cbQuality.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_MEDIUMSETTING, strText, 255);				// 중간 사양
	m_cbQuality.AddString(strText);

	LoadString(m_hResource, IDS_LOCAL_HIGHSETTING, strText, 255);				// 최고 사양
	m_cbQuality.AddString(strText);


	LoadString(m_hResource, IDS_LOCAL_OS, strText, 255);						// 운영체제
	GetDlgItem(IDC_STATIC_OS)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_MEMORY, strText, 255);					// 메모리
	GetDlgItem(IDC_STATIC_MEMORY)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_CPU, strText, 255);						// CPU 속도
	GetDlgItem(IDC_STATIC_CPUSPEED)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_HDD, strText, 255);						// 하드 용량
	GetDlgItem(IDC_STATIC_HDDCAP)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_DIRECTX, strText, 255);					// 다이렉트 버젼
	GetDlgItem(IDC_STATIC_DIRECTVERSION)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_SOUNDCARD, strText, 255);					// 사운드 카드
	GetDlgItem(IDC_STATIC_SOUNDCARD)->SetWindowText(strText);


	LoadString(m_hResource, IDS_LOCAL_VIDEOCARD, strText, 255);					// 비디오 카드
	GetDlgItem(IDC_STATIC_VIDEOCARD)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_RESOLUTION, strText, 255);				// 해상도
	GetDlgItem(IDC_STATIC_RES)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_COLOR, strText, 255);						// 색깔
	GetDlgItem(IDC_STATIC_COLOR)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_REFRESH, strText, 255);					// 주파수
	GetDlgItem(IDC_STATIC_REFRESH)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_SCREENMODE, strText, 255);				// 스크린모드
	GetDlgItem(IDC_STATIC_WINDOWMODE)->SetWindowText(strText);
	
	LoadString(m_hResource, IDS_LOCAL_LANGUAGE, strText, 255);					// 비디오 카드
	GetDlgItem(IDC_STATIC_LANGUAGE)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_QUALITY, strText, 255);					// 그래픽 옵션
	GetDlgItem(IDC_STATIC_OPTIONSIMPLE)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_CHARSHADOW, strText, 255);				// 캐릭터 그림자
	GetDlgItem(IDC_STATIC_CHARACTERSHADOW)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_HOUSESHADOW, strText, 255);				// 집 그림자
	GetDlgItem(IDC_STATIC_HOUSESHADOW)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_VIEWRANGE, strText, 255);					// 시야 범위
	GetDlgItem(IDC_STATIC_VIEWRANGE)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_TEXQUALITY, strText, 255);				// 텍스쳐 퀄리티
	GetDlgItem(IDC_STATIC_TEXTURE)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_GRASS, strText, 255);						// 풀
	GetDlgItem(IDC_STATIC_GRASS)->SetWindowText(strText);


	LoadString(m_hResource, IDS_LOCAL_SCREENEFFECT, strText, 255);				// 화면 효과
	GetDlgItem(IDC_STATIC_SCREENFILTER)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_WATEREFFECT, strText, 255);				// 물 효과
	GetDlgItem(IDC_STATIC_WATEREFFECT)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_GLOWEFFECT, strText, 255);				// 글로우 효과
	GetDlgItem(IDC_STATIC_GLOWEFFECT)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_WEATHEREFFECT, strText, 255);				// 기후 효과
	GetDlgItem(IDC_STATIC_WEATHEREFFECT)->SetWindowText(strText);


	LoadString(m_hResource, IDS_LOCAL_SYSTEM, strText, 255);					// 시스템
	m_tcControlTab.InsertItem(TAB_SYSTEM, strText, 0);

	LoadString(m_hResource, IDS_LOCAL_GENERAL, strText, 255);					// 기본 옵션
	m_tcControlTab.InsertItem(TAB_GENERAL, strText, 0);

	LoadString(m_hResource, IDS_LOCAL_ADVANCE, strText, 255);					// 세부 옵션
	m_tcControlTab.InsertItem(TAB_ADVANCE, strText, 0);

	LoadString(m_hResource, IDS_LOCAL_SPECIAL, strText, 255);					// 특수 효과
	m_tcControlTab.InsertItem(TAB_SPECIAL, strText, 0);


	LoadString(m_hResource, IDS_LOCAL_OK, strText, 255);						// 확인 버튼
	GetDlgItem(IDOK)->SetWindowText(strText);

	LoadString(m_hResource, IDS_LOCAL_CANCEL, strText, 255);					// 취소 버튼
	GetDlgItem(IDCANCEL)->SetWindowText(strText);
}

static const unsigned long MAX_SETTING = 12;
// 해상도X, 해상도Y, 칼라, 캐릭터그림자, 집그림자, 시야범위, 텍스쳐퀄리티, 풀, 화면효과, 물효과, 글로우, 기후
static unsigned long dwSetting[3][MAX_SETTING] =
{
	{ 800, 600, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
	{ 1024, 768, 32, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
	{ 1280, 1024, 32, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
};

unsigned long CClientSetupDlg::GetQualityBySetting(void)
{
	// 해상도 탐색
	unsigned long dwPresentSetting[MAX_SETTING];
	dwPresentSetting[0] = g_pSystemInfo->GetCurrentWidth();
	dwPresentSetting[1] = g_pSystemInfo->GetCurrentHeight();

	// 색상
	CString strCurrent;
	m_cbColor.GetLBText(m_cbColor.GetCurSel(), strCurrent);
	dwPresentSetting[2] = atoi(strCurrent);

	dwPresentSetting[3] = m_cbCharShadow.GetCurSel();
	dwPresentSetting[4] = m_cbHouseShadow.GetCurSel();
	dwPresentSetting[5] = m_cbViewRange.GetCurSel();
	dwPresentSetting[6] = m_cbTextureQuailty.GetCurSel();
	dwPresentSetting[7] = m_cbGrass.GetCurSel();
	dwPresentSetting[8] = m_cbScreenEffect.GetCurSel();
	dwPresentSetting[9] = m_cbWaterEffect.GetCurSel();
	dwPresentSetting[10] = m_cbGlowEffect.GetCurSel();
	dwPresentSetting[11] = m_cbWeatherEffect.GetCurSel();

	unsigned long i, j, dwQuality = 0;	// 0은 커스텀

	for(j = 0; j < 3; ++j)
	{
		for(i = 0; i < MAX_SETTING; ++i)
		{
			if(dwSetting[j][i] != dwPresentSetting[i]) break;
		}
		if(i == MAX_SETTING)
		{
			dwQuality = j + 1;
			break;
		}
	}

	return dwQuality;
}

void CClientSetupDlg::SetSettingByQuality(unsigned long dwQuality)
{
	if(dwQuality == 0) return;

	unsigned dwRQ = dwQuality - 1;
	if(dwRQ > 2) return;

	unsigned long dwWidth = dwSetting[dwRQ][0];
	unsigned long dwHeight = dwSetting[dwRQ][1];
	unsigned long dwRefresh = g_pSystemInfo->GetCurrentRefresh();
	D3DFORMAT d3dFormat = g_pSystemInfo->GetFormat(dwSetting[dwRQ][2]);

	char strResolution[MAX_PATH], strColor[MAX_PATH], strRefresh[MAX_PATH];
	unsigned dwNumRes, dwNumColor, dwNumRefresh;
	g_pSystemInfo->SetSetting(dwWidth, dwHeight, d3dFormat, dwRefresh);
	dwNumRes = g_pSystemInfo->m_dwCurrentResolution;
	dwNumColor = g_pSystemInfo->m_dwCurrentColor;
	dwNumRefresh = g_pSystemInfo->m_dwCurrentRefresh;

	SetResolution();
	g_pSystemInfo->m_dwCurrentResolution = dwNumRes;
	g_pSystemInfo->GetResolutionByString("%d x %d", strResolution);
	m_cbResolution.SetCurSel(m_cbResolution.FindString(0, strResolution));

	SetColor();
	g_pSystemInfo->m_dwCurrentColor = dwNumColor;
	g_pSystemInfo->GetColorByString("%d", strColor);
	m_cbColor.SetCurSel(m_cbColor.FindString(0, strColor));
	SetRefresh();
	g_pSystemInfo->m_dwCurrentRefresh = dwNumRefresh;
	g_pSystemInfo->GetRefreshByString("%d", strRefresh);
	m_cbRefresh.SetCurSel(m_cbRefresh.FindString(0, strRefresh));

	m_cbCharShadow.SetCurSel(dwSetting[dwRQ][3]);
	m_cbHouseShadow.SetCurSel(dwSetting[dwRQ][4]);
	m_cbViewRange.SetCurSel(dwSetting[dwRQ][5]);
	m_cbTextureQuailty.SetCurSel(dwSetting[dwRQ][6]);
	m_cbGrass.SetCurSel(dwSetting[dwRQ][7]);
	m_cbScreenEffect.SetCurSel(dwSetting[dwRQ][8]);
	m_cbWaterEffect.SetCurSel(dwSetting[dwRQ][9]);
	m_cbGlowEffect.SetCurSel(dwSetting[dwRQ][10]);
	m_cbWeatherEffect.SetCurSel(dwSetting[dwRQ][11]);
}
void CClientSetupDlg::OnCbnSelchangeComboWindowmode()
{
	// TODO: Add your control notification handler code here
}

void CClientSetupDlg::OnStnClickedStaticWindowmode()
{
	// TODO: Add your control notification handler code here
}
