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>
228 lines
5.0 KiB
C++
228 lines
5.0 KiB
C++
// ServerSelectDlg.cpp : 구현 파일
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "ServerSelect.h"
|
|
#include "ServerSelectDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
|
|
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
|
|
|
|
class CAboutDlg : public CDialog
|
|
{
|
|
public:
|
|
CAboutDlg();
|
|
|
|
// 대화 상자 데이터
|
|
enum { IDD = IDD_ABOUTBOX };
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원
|
|
|
|
// 구현
|
|
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()
|
|
|
|
|
|
// CServerSelectDlg 대화 상자
|
|
|
|
|
|
|
|
CServerSelectDlg::CServerSelectDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CServerSelectDlg::IDD, pParent)
|
|
, m_ServerURL(_T(""))
|
|
{
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
}
|
|
|
|
void CServerSelectDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_SERVER_URL, m_ServerURL);
|
|
DDX_Control(pDX, IDC_SERVER_SELECT, m_ServerSelect);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CServerSelectDlg, CDialog)
|
|
ON_WM_SYSCOMMAND()
|
|
ON_WM_PAINT()
|
|
ON_WM_QUERYDRAGICON()
|
|
//}}AFX_MSG_MAP
|
|
ON_BN_CLICKED(IDC_OK, OnBnClickedOk)
|
|
ON_CBN_SELCHANGE(IDC_SERVER_SELECT, OnCbnSelchangeServerSelect)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CServerSelectDlg 메시지 처리기
|
|
#define KEY_RYL "Software\\ROW\\MP-Client"
|
|
#define SUBKEY_URL "Server"
|
|
|
|
const unsigned short LoginServerListNum = 3;
|
|
const char* LoginServerList[LoginServerListNum][2] =
|
|
{
|
|
{ "정식 서버", "" },
|
|
|
|
{ "사내 TSP2", "222.122.158.84" },
|
|
{ "사내 임시1", "192.168.0.2" },
|
|
};
|
|
|
|
BOOL CServerSelectDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// 시스템 메뉴에 "정보..." 메뉴 항목을 추가합니다.
|
|
|
|
// IDM_ABOUTBOX는 시스템 명령 범위에 있어야 합니다.
|
|
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);
|
|
}
|
|
}
|
|
|
|
// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
|
|
// 프레임워크가 이 작업을 자동으로 수행합니다.
|
|
SetIcon(m_hIcon, TRUE); // 큰 아이콘을 설정합니다.
|
|
SetIcon(m_hIcon, FALSE); // 작은 아이콘을 설정합니다.
|
|
|
|
// TODO: 여기에 추가 초기화 작업을 추가합니다.
|
|
for(int Count = 0; Count < LoginServerListNum; ++Count)
|
|
{
|
|
m_ServerSelect.InsertString(Count, LoginServerList[Count][0]);
|
|
}
|
|
|
|
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_RYL, 0, KEY_READ | KEY_SET_VALUE, &m_hKey) != ERROR_SUCCESS )
|
|
{
|
|
MessageBox( "MPClient의 키를 찾을 수 없습니다." );
|
|
PostQuitMessage( 0 );
|
|
}
|
|
|
|
DWORD Type, nReadData = 256;
|
|
char ServerURL[256] = "";
|
|
if(RegQueryValueEx(m_hKey, SUBKEY_URL, NULL, &Type, (LPBYTE)ServerURL, &nReadData) != ERROR_SUCCESS)
|
|
{
|
|
m_ServerSelect.SetCurSel(0);
|
|
}
|
|
else
|
|
{
|
|
for(int Count = 0; Count < LoginServerListNum; ++Count)
|
|
{
|
|
if(strcmp(ServerURL, LoginServerList[Count][1]) == 0)
|
|
{
|
|
m_ServerSelect.SetCurSel(Count);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
m_ServerURL = ServerURL;
|
|
UpdateData(FALSE);
|
|
return TRUE; // 컨트롤에 대한 포커스를 설정하지 않을 경우 TRUE를 반환합니다.
|
|
}
|
|
|
|
void CServerSelectDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
{
|
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
|
{
|
|
CAboutDlg dlgAbout;
|
|
dlgAbout.DoModal();
|
|
}
|
|
else
|
|
{
|
|
CDialog::OnSysCommand(nID, lParam);
|
|
}
|
|
}
|
|
|
|
// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면
|
|
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는
|
|
// 프레임워크에서 이 작업을 자동으로 수행합니다.
|
|
|
|
void CServerSelectDlg::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 CServerSelectDlg::OnQueryDragIcon()
|
|
{
|
|
return static_cast<HCURSOR>(m_hIcon);
|
|
}
|
|
|
|
void CServerSelectDlg::OnBnClickedOk()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
UpdateData();
|
|
|
|
RegDeleteKey(m_hKey, "PatchServer");
|
|
|
|
if(0 == m_ServerURL.GetLength())
|
|
{
|
|
if(RegDeleteValue(m_hKey, SUBKEY_URL) != ERROR_SUCCESS)
|
|
{
|
|
MessageBox("서버 URL 삭제 실패.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(RegSetValueEx(m_hKey, SUBKEY_URL, 0, REG_SZ, (CONST BYTE*)m_ServerURL.GetBuffer(0), m_ServerURL.GetLength()) != ERROR_SUCCESS)
|
|
{
|
|
MessageBox("서버 URL 저장 실패.");
|
|
}
|
|
}
|
|
}
|
|
|
|
void CServerSelectDlg::OnCbnSelchangeServerSelect()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
UpdateData();
|
|
|
|
m_ServerURL = LoginServerList[m_ServerSelect.GetCurSel()][1];
|
|
|
|
UpdateData(FALSE);
|
|
}
|