CharacterProcess.cpp
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:21k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. // CharacterProcess.cpp: implementation of the CCharacterProcess class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. ////////////////////////////////////////////////
  6. ////////////////////////////////////////////////
  7. // Positio of Edit box
  8. #define POS_NAME_X 300
  9. #define POS_NAME_Y 460
  10. //////////////////////////////////////////////////////////////////////
  11. // Construction/Destruction
  12. //////////////////////////////////////////////////////////////////////
  13. CCharacterProcess::CCharacterProcess()
  14. {
  15. Init();
  16. }
  17. CCharacterProcess::~CCharacterProcess()
  18. {
  19. // if(m_pBtn)
  20. // {
  21. // delete[] m_pBtn;
  22. // m_pBtn = NULL;
  23. // }
  24. }
  25. VOID CCharacterProcess::Init()
  26. {
  27. m_Progress=PRG_CHAR_SELE;
  28. m_ConnectionState=CONNECT_FAIL;
  29. ZeroMemory(m_szErrorMsg,512);
  30. // m_pBtn = new CMirButton[sizeof(g_CharProcBtnInfo)/sizeof(BUTTONINFO)];
  31. }
  32. VOID CCharacterProcess::Load()
  33. {
  34. WSAStartup(MAKEWORD(2, 2), &m_wsd);
  35. m_Image.NewLoad(".\Data\interface1c.wil", TRUE, TRUE);
  36. m_Image2.NewLoad(".\Data\interfacec2.wil", TRUE, TRUE);
  37. // 烙矫
  38. //
  39. m_ConnectionState = CONNECT_FAIL;
  40. g_xClientSocket.ConnectToServer(g_xMainWnd.GetSafehWnd(), g_szServerIP, g_nServerPort);
  41. g_xChatEditBox.SetLimitText(20);
  42. SendMessage(g_xChatEditBox.GetSafehWnd(),EM_SETPASSWORDCHAR,NULL,0);
  43. m_ChrCount =0;
  44. m_nMessage = 0;
  45. // m_xMsgBox.Load(&m_Image2);
  46. m_xMsgBox.CreateWnd(&m_Image2,TRUE,219,110,362,180); // 侩扁
  47. m_Progress = PRG_CHAR_SELE; // Character Selection
  48. m_xBGround.Create(&m_Image);
  49. m_xBGround.OpenWnd();
  50. }
  51. VOID CCharacterProcess::SetNextProc()
  52. {
  53. D3DMATRIX matProj;
  54. DeleteProc();
  55.   g_xClientSocket.m_pxDefProc = g_xMainWnd.m_pxDefProcess = &g_xGameProc;
  56. g_xGameProc.Load();
  57. g_xChatEditBox.SetLimitText(90);
  58. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
  59. D3DUtil_SetProjectionMatrix(matProj, g_PI/2, float(600.0f/800.0f), -1.0f, 1.0f);
  60.     g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);
  61. g_bProcState = _GAME_PROC; 
  62. }
  63. VOID CCharacterProcess::DeleteProc()
  64. {
  65. WSACleanup();
  66. m_Image.Destroy();
  67. m_Image2.Destroy();
  68. // 烙矫
  69. m_CRectList.ClearAllNodes();
  70. m_CList.ClearAllNodes();
  71. }
  72. LRESULT CCharacterProcess::DefMainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  73. {
  74. switch ( uMsg )
  75. {
  76. case WM_LBUTTONDOWN:
  77. OnLButtonDown(wParam, lParam);
  78. break;
  79. case WM_LBUTTONUP:
  80. OnLButtonUp(wParam, lParam);
  81. break;
  82. case ID_SOCKCLIENT_EVENT_MSG:
  83. g_xClientSocket.OnSocketMessage(wParam, lParam);
  84. break;
  85. case WM_KEYDOWN:
  86. OnKeyDown(wParam, lParam);
  87. break;
  88. case WM_MOUSEON:
  89. OnMouseOn(wParam,lParam);
  90. break;
  91. case WM_MOVE:
  92. OnWindowMove(wParam,lParam);
  93. break;
  94. case WM_MOUSEMOVE:
  95. OnMouseMove(wParam,lParam);
  96. break;
  97. default:
  98. break;
  99. }
  100. return CWHDefProcess::DefMainWndProc(hWnd, uMsg, wParam, lParam);
  101. }
  102. LRESULT CCharacterProcess::OnKeyDown(WPARAM wParam, LPARAM lParam)
  103. {
  104. switch ( wParam )
  105. {
  106. case VK_F1:
  107. m_Progress=PRG_CHAR_SELE;
  108. break;
  109. case VK_F2:
  110. m_Progress=PRG_CREATE_CHAR;
  111. break;
  112. }
  113. return 0L;
  114. }
  115. LRESULT CCharacterProcess::OnMouseMove(WPARAM wParam, LPARAM lParam)
  116. {
  117. int i;
  118. BOOL fOnButton = FALSE;
  119. if(m_xMsgBox.IsActive())
  120. {
  121. POINT  tPos;
  122. tPos.x = LOWORD(lParam);
  123. tPos.y = HIWORD(lParam);
  124. m_xMsgBox.MoveWnd(tPos); // Moon
  125. return 0l;
  126. }
  127. if(!m_fIsLButtonClicked)//m_fIsConnected && !m_fIsLButtonClicked)
  128. {
  129. switch(m_Progress)
  130. {
  131. case PRG_CHAR_SELE:
  132. m_xSelectChr.OnMouseMove(wParam, lParam);
  133. break;
  134. case PRG_CREATE_CHAR:
  135. {
  136. for(i = 5; i < 9; i++)
  137. {
  138. /* if (m_pBtn[i].CheckMouseOn(LOWORD(lParam), HIWORD(lParam)))
  139. {
  140. m_pBtn[i].m_nState = BUTTON_STATE_ON;
  141. fOnButton = TRUE;
  142. }
  143. else
  144. m_pBtn[i].m_nState = BUTTON_STATE_UP;*/
  145. }
  146. break;
  147. }
  148. }
  149. if(fOnButton)
  150. {
  151. HCURSOR hCursor;
  152. hCursor = LoadCursor(g_xMainWnd.GetSafehInstance(),MAKEINTRESOURCE(IDC_ARROW));
  153. SetCursor(hCursor);
  154. DestroyCursor(hCursor); 
  155. }
  156. // else
  157. // g_xMainWnd.OnSetCursor(IDC_ARROW);
  158. }
  159. return 0L;
  160. }
  161. LRESULT CCharacterProcess::OnLButtonDown(WPARAM wParam, LPARAM lParam)
  162. {
  163. m_fIsLButtonClicked = FALSE;
  164. if(m_xMsgBox.IsActive())
  165. {
  166. POINT ptMouse;
  167. ptMouse.x = LOWORD(lParam);
  168. ptMouse.y = HIWORD(lParam);
  169. m_xMsgBox.OnButtonDown(ptMouse);
  170. }
  171. else
  172. {
  173. if(m_Progress==PRG_CHAR_SELE)
  174. m_xSelectChr.OnButtonDown(wParam, lParam);
  175. if (m_Progress == PRG_CREATE_CHAR)
  176. {
  177. for (int i = ID_CREATE_CHR_OK_BTN; i <= ID_CREATE_CHR_TAO_BTN; i++)
  178. {
  179. /* if (m_pBtn[i].CheckMouseOn(LOWORD(lParam), HIWORD(lParam)))
  180. {
  181. m_pBtn[i].m_nState = BUTTON_STATE_DOWN;
  182. m_fIsLButtonClicked = TRUE;
  183. }
  184. else
  185. m_pBtn[i].m_nState = BUTTON_STATE_UP;
  186. */ }
  187. }
  188. }
  189. return 0L;
  190. }
  191. LRESULT CCharacterProcess::OnLButtonUp(WPARAM wParam, LPARAM lParam)
  192. {
  193. INT nRecieve;
  194. m_ptMousePos.x = LOWORD(lParam);
  195. m_ptMousePos.y = HIWORD(lParam);
  196. m_fIsLButtonClicked = FALSE;
  197. if(m_xMsgBox.IsActive()) // Message Box Process
  198. {
  199. MessageBoxProcess(lParam);
  200. }
  201. else
  202. {
  203. switch(m_Progress)
  204. {
  205. case PRG_CHAR_SELE:
  206. {
  207. nRecieve = m_xSelectChr.OnButtonUp(wParam, lParam);
  208. switch(nRecieve)
  209. {
  210. case RETURN_SELECT_NEW_BTN:
  211. {
  212. break;
  213. }
  214. case RETURN_SELECT_NEW_ERR:
  215. {
  216. m_nMessage = 3;
  217. SetErrorMessage(m_nMessage,m_szErrorMsg);
  218. m_xMsgBox.ShowMessageBox(m_szErrorMsg,MSG_BTN_OK,_WNDIMGINDX_MSGBOX1);
  219. break;
  220. }
  221. case RETURN_SELECT_DEL_BTN:
  222. {
  223. m_nMessage = 5;
  224. SetErrorMessage(m_nMessage,m_szErrorMsg);
  225. m_xMsgBox.ShowMessageBox(m_szErrorMsg,MSG_BTN_YESNO,_WNDIMGINDX_MSGBOX1);
  226. break;
  227. }
  228. case RETURN_SELECT_DEL_ERR:
  229. {
  230. m_nMessage = 8;
  231. SetErrorMessage(m_nMessage,m_szErrorMsg);
  232. m_xMsgBox.ShowMessageBox(m_szErrorMsg,MSG_BTN_OK,_WNDIMGINDX_MSGBOX1);
  233. break;
  234. }
  235. case RETURN_SELECT_START_BTN:
  236. {
  237. break;
  238. }
  239. case RETURN_SELECT_START_ERR:
  240. {
  241. m_nMessage = 7;
  242. SetErrorMessage(m_nMessage,m_szErrorMsg);
  243. m_xMsgBox.ShowMessageBox(m_szErrorMsg,MSG_BTN_OK,_WNDIMGINDX_MSGBOX1);
  244. break;
  245. }
  246. }
  247. break;
  248. }
  249. case PRG_CREATE_CHAR:
  250. {
  251. /*
  252. for(i = ID_CREATE_CHR_OK_BTN; i <= ID_CREATE_CHR_TAO_BTN; i++)
  253. {
  254. m_pBtn[i].m_nState = BUTTON_STATE_UP;
  255. if (m_pBtn[i].CheckMouseOn(LOWORD(lParam), HIWORD(lParam)))
  256. {
  257. switch(i)
  258. {
  259. case ID_CREATE_CHR_WAR_BTN:
  260. m_SelectJob = _JOB_JUNSA;
  261. break;
  262. case ID_CREATE_CHR_SOR_BTN:
  263. m_SelectJob = _JOB_SULSA;
  264. break;
  265. case ID_CREATE_CHR_TAO_BTN:
  266. m_SelectJob = _JOB_DOSA;
  267. break;
  268. case ID_CREATE_CHR_OK_BTN:
  269. {
  270. int Lens;
  271. GetWindowText(g_xChatEditBox.GetSafehWnd(),m_szChrName,sizeof(m_szChrName));
  272. Lens = strlen(m_szChrName);
  273. if(Lens!=0)
  274. {
  275. CHRINFO ChrInfo;
  276. strcpy(ChrInfo.ChrName,m_szChrName);
  277. ChrInfo.Class=m_SelectJob;
  278. ChrInfo.Gender=m_SelectSex;
  279. ChrInfo.Level = 1;
  280. m_ChrCount = 0;
  281. m_xBGround.SetRenderState(_RENDER_AVI_OUT);
  282. g_xSound.PlayMp3(MP3_TOSELECTCHAR,FALSE); 
  283. m_Progress = PRG_CREA_TO_SEL; // 烙矫
  284. g_xClientSocket.OnQueryChar(); // 烙矫
  285. }
  286. else
  287. {
  288. m_nMessage = 2;
  289. SetErrorMessage(m_nMessage,m_szErrorMsg);
  290. m_xMsgBox.ShowMessageBox(m_szErrorMsg,1,_WNDIMGINDX_MSGBOX1);
  291. }
  292. }
  293. }
  294. }
  295. }*/
  296. m_Progress = PRG_CREA_TO_SEL;
  297. m_xBGround.SetRenderState(_RENDER_AVI_OUT);
  298. break;
  299. }
  300. }
  301. }
  302. return 0L;
  303. }
  304. LRESULT CCharacterProcess::OnMouseOn(WPARAM wParam, LPARAM lParam)
  305. {
  306. /* UINT t_ID;
  307. t_ID=(UINT)wParam;
  308. m_ButtonID = t_ID; // Upon Mouse*/
  309. return 0L;
  310. }
  311. LRESULT CCharacterProcess::OnWindowMove(WPARAM wParam,LPARAM lParam)
  312. {
  313. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
  314. g_xMainWnd.OnMove(wParam, lParam);
  315. return 0L;
  316. }
  317. // **************************************************************************************
  318. //
  319. // Socket
  320. //
  321. // **************************************************************************************
  322. VOID CCharacterProcess::OnConnectToServer()
  323. {
  324. m_ConnectionState = CONNECT_SUCCESS;// Connection Success
  325. g_xClientSocket.OnQueryChar();
  326. }
  327. char* CCharacterProcess::OnMessageReceive(CHAR* pszMessage)
  328. {
  329. char *pszFirst = pszMessage;
  330. char *pszEnd;
  331. while (pszEnd = strchr(pszFirst, '!'))
  332. {
  333. *pszEnd = '';
  334. OnSocketMessageRecieve(pszFirst + 1);
  335. if (*(pszEnd + 1) == '#')
  336. pszFirst = pszEnd + 1;
  337. else
  338. return NULL;
  339. }
  340. return pszFirst;
  341. }
  342. void CCharacterProcess::OnSocketMessageRecieve(char* pszMsg)
  343. {
  344. _TDEFAULTMESSAGE tdm;
  345. INT nChrPos[] = { 350, 280, 350, 250, 320, 390 };
  346. fnDecodeMessage(&tdm, pszMsg);
  347. switch(tdm.wIdent)
  348. {
  349. case SM_QUERYCHR:
  350. {
  351. m_SelectChr = SELECT_NONE;
  352. if (tdm.nRecog)
  353. {
  354. char szDecodeMsg[512];
  355. char *pszID = NULL, *pszJob = NULL, *pszFace = NULL, *pszLevel = NULL, *pszSex = NULL, *pszNext = NULL;
  356. int nPos = 0;
  357. m_SelectChr = SELECT_FIRST;
  358. m_CRectList.ClearAllNodes();
  359. ZeroMemory(szDecodeMsg, sizeof(szDecodeMsg));
  360. fnDecode6BitBuf((pszMsg + DEFBLOCKSIZE), szDecodeMsg, sizeof(szDecodeMsg));
  361. m_ChrCount = tdm.nRecog;
  362. for (int i = 0; i < tdm.nRecog; i++)
  363. {
  364. CHRINFO* pxChInfo = new CHRINFO;
  365. if (szDecodeMsg[nPos] == '*')
  366. {
  367. pszID = &szDecodeMsg[nPos + 1];
  368. m_SelectChr = i;
  369. }
  370. else
  371. pszID = &szDecodeMsg[nPos];
  372. if (pszJob = strchr(pszID, '/'))
  373. {
  374. *pszJob = '';
  375. pszJob++;
  376. strcpy(pxChInfo->ChrName, pszID);
  377. pxChInfo->Class = atoi(pszJob);
  378. if (pszFace = strchr(pszJob, '/'))
  379. {
  380. *pszFace = '';
  381. pszFace++;
  382. if (pszLevel = strchr(pszFace, '/'))
  383. {
  384. *pszLevel = '';
  385. pszLevel++;
  386. pxChInfo->Level = atoi(pszLevel);
  387. if (pszSex = strchr(pszLevel, '/'))
  388. {
  389. *pszSex = '';
  390. pszSex++;
  391. pxChInfo->Gender = atoi(pszSex);
  392. m_CList.AddNode(pxChInfo);
  393.  
  394. m_Image.NewSetIndex(IDX_IMG_MALE_WAR + m_CList.GetCurrentData()->Gender + (m_CList.GetCurrentData()->Class * 2)) ;
  395. CHRRECT* pxChRect = new CHRRECT;
  396. pxChRect->nLeft = nChrPos[i + tdm.nRecog - 1];
  397. pxChRect->nTop = 280;
  398. pxChRect->nWidth = m_Image.m_lpstNewCurrWilImageInfo->shWidth;
  399. pxChRect->nHeight = m_Image.m_lpstNewCurrWilImageInfo->shHeight;
  400. m_CRectList.AddNode(pxChRect);
  401. if (pszNext = strchr(pszSex, '/'))
  402. {
  403. pszNext++;
  404. if (*pszNext != '')
  405. nPos = pszNext - &szDecodeMsg[0];
  406. }
  407. }
  408. }
  409. }
  410. } // For
  411. m_xSelectChr.Create(&m_Image,&m_CList,&m_CRectList,tdm.nRecog);
  412. m_xSelectChr.OpenWnd ();
  413. }
  414. }
  415. break;
  416. }
  417. case SM_NEWCHR_SUCCESS: // New character Create Success
  418. {
  419. m_Progress = PRG_CREA_TO_SEL;
  420. g_xClientSocket.OnQueryChar();
  421. break;
  422. }
  423. case SM_STARTPLAY: // Start Game
  424. {
  425. char szDecodeMsg[512];
  426. char *pszIP = &szDecodeMsg[0], *pszPort;
  427. ZeroMemory(szDecodeMsg, sizeof(szDecodeMsg));
  428. fnDecode6BitBuf((pszMsg + DEFBLOCKSIZE), szDecodeMsg, sizeof(szDecodeMsg));
  429. if (pszPort = strchr(pszIP, '/'))
  430. {
  431. *pszPort = '';
  432. pszPort++;
  433. strcpy(g_szServerIP, pszIP);
  434. g_nServerPort = atoi(pszPort);
  435. g_xClientSocket.DisconnectToServer();
  436. m_xSelectChr.m_nRenderState = 2; // Set Select Renderstaet to Ready startgame
  437. }
  438. break;
  439. }
  440. }
  441. /* _TDEFAULTMESSAGE tdm;
  442. char szDecodeMsg[256];
  443. char szTmpDecodeMsg[512];
  444. ZeroMemory(szTmpDecodeMsg, 512);
  445. strcpy(szTmpDecodeMsg, pszMsg);
  446. char *pszData = &szTmpDecodeMsg[1];
  447. fnDecodeMessage(&tdm, pszData);
  448. if(lstrlen(szTmpDecodeMsg) >= DEFBLOCKSIZE + 1)
  449. fnDecode6BitBuf((szTmpDecodeMsg + DEFBLOCKSIZE + 1), szDecodeMsg, sizeof(szDecodeMsg));
  450. switch(tdm.wIdent)
  451. {
  452. case SM_QUERYCHR: // Getting character List
  453. {
  454. pCHRINFO ChrInfo;
  455. pCHRRECT tChRect;
  456. m_CRectList.ClearAllNodes();
  457. m_CList.ClearAllNodes();
  458. if(tdm.wParam!=0) // 纳腐磐啊 粮犁 且版快
  459. {
  460. ChrInfo = new CHRINFO[tdm.wParam]; // 罐酒柯 百荐父怒 纳腐磐 沥焊 甫 父电促.
  461. m_SelectChr = SELECT_FIRST;
  462. m_ChrCount = tdm.wParam;
  463. fnDecode6BitBuf((szTmpDecodeMsg + DEFBLOCKSIZE + 1), (char*)ChrInfo, sizeof(CHRINFO)*(tdm.wParam));
  464. pCHRINFO  tChInfo;
  465. for(int i = 0 ;i<tdm.wParam;i++)
  466. {
  467. // 纳腐磐啊 粮犁 窍瘤 臼阑版快?
  468. // 纳腐磐 Info
  469. tChInfo = new CHRINFO;
  470. strcpy(tChInfo->ChrName,ChrInfo[i].ChrName);
  471. tChInfo->Class=ChrInfo[i].Class;
  472. tChInfo->Gender=ChrInfo[i].Gender;
  473. tChInfo->Level=ChrInfo[i].Level;
  474. m_CList.AddNode(tChInfo);
  475. // 纳腐磐 Rect 荐沥 且巴  // 烙矫
  476. tChRect = new CHRRECT;
  477. m_tImage1.NewSetIndex((2-(INT)(tChInfo->Class)));
  478. switch(tdm.wParam)
  479. {
  480. case 1:
  481. tChRect->nLeft = 350;
  482. break;
  483. case 2:
  484. {
  485. switch(i)
  486. {
  487. case 0:
  488. tChRect->nLeft = 280;
  489. break;
  490. case 1:
  491. tChRect->nLeft = 420;
  492. break;
  493. }
  494. break;
  495. }
  496. case 3:
  497. {
  498. switch(i)
  499. {
  500. case 0:
  501. tChRect->nLeft = 180;
  502. break;
  503. case 1:
  504. tChRect->nLeft = 350;
  505. break;
  506. case 2:
  507. tChRect->nLeft  = 480;
  508. break;
  509. }
  510. break;
  511. }
  512. }
  513. tChRect->nTop  = 250+((2-tChInfo->Class)/2)*30;
  514. tChRect->nWidth = m_tImage1.m_lpstNewCurrWilImageInfo->shWidth;
  515. tChRect->nHeight = m_tImage1.m_lpstNewCurrWilImageInfo->shHeight;
  516. m_CRectList.AddNode(tChRect);
  517. }
  518. delete ChrInfo;
  519. }
  520. else
  521. { // 纳腐磐啊 粮犁 窍瘤 臼阑版快绰?
  522. m_SelectChr = SELECT_NONE;
  523. }
  524. break;
  525. }
  526. case SM_NEWCHR_SUCCESS: // New character Create Success
  527. {
  528. m_Progress = PRG_CREA_TO_SEL;
  529. g_xClientSocket.OnQueryChar();
  530. break;
  531. }
  532. case SM_NEWCHR_FAIL: // New character Create Fail
  533. {
  534. m_nMessage = tdm.wParam; // Message Parameter 傈崔
  535. SetErrorMessage(m_nMessage,m_szErrorMsg);
  536. m_xMsgBox.ShowMessageBox(m_szErrorMsg,1,_WNDIMGINDX_MSGBOX1);
  537. m_Progress = PRG_CREATE_CHAR; // Create New Character
  538. }
  539. break; 
  540. case SM_DELCHR_SUCCESS: // Delete character Success
  541. g_xClientSocket.OnQueryChar();
  542. m_Progress = PRG_CHAR_SELE; // Character Selection
  543. break;
  544. case SM_DELCHR_FAIL: // Delete character Fail
  545. {
  546. m_nMessage = tdm.wParam;
  547. SetErrorMessage(m_nMessage,m_szErrorMsg);
  548. m_xMsgBox.ShowMessageBox(m_szErrorMsg,1,_WNDIMGINDX_MSGBOX1);
  549. // 1. 粮犁窍瘤 臼绰 纳腐磐甫 瘤匡版快
  550. // 2. 舅荐 绝绰 Error
  551. // 3. 
  552. m_Progress = PRG_CHAR_SELE; // Character Selection
  553. }
  554. break;
  555. case SM_STARTPLAY: // Start Game
  556. {
  557. int Count;
  558. Count = strlen(szDecodeMsg);
  559. for(int i = 0 ; i< Count ; i++)
  560. {
  561. if(szDecodeMsg[i]==':')
  562. {
  563. strncpy(g_szServerIP,szDecodeMsg,i);
  564. g_nServerPort = atoi(szDecodeMsg+i+1);
  565. }
  566. }
  567. g_xClientSocket.DisconnectToServer(); // Char sever客狼 楷搬 辆丰
  568. m_Progress=PRG_SEL_TO_GAME;
  569. break;
  570. }
  571. case SM_STARTFAIL:
  572. { // Fail to start game
  573. m_Progress = PRG_QUIT; // Quit for Some Reason
  574. SendMessage(g_xMainWnd.GetSafehWnd(), WM_DESTROY, NULL, NULL);
  575. }
  576. break;
  577. case SM_QUERYCHR_FAIL:
  578. { // Getting character List Fail
  579. m_Progress = PRG_QUIT; // Quit for Some Reason
  580. SendMessage(g_xMainWnd.GetSafehWnd(), WM_DESTROY, NULL, NULL);
  581. }
  582. break;
  583. case SM_OUTOFCONNECTION:
  584. { // Connection Lost(close Connection)
  585. m_Progress = PRG_QUIT; // Quit for Some Reason
  586. SendMessage(g_xMainWnd.GetSafehWnd(), WM_DESTROY, NULL, NULL);
  587. }
  588. break;
  589. }
  590. return 0L; */
  591. }
  592. /**/
  593. VOID CCharacterProcess::RenderScene(INT nLoopTime)
  594. {
  595. m_xBGround.Render(nLoopTime);
  596. switch(m_Progress)
  597. {
  598. case PRG_CHAR_SELE:
  599. {
  600. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
  601. switch(m_xSelectChr.m_nRenderState)
  602. {
  603. case 11: // Zoom in
  604. {
  605. m_xBGround.SetRenderState(_RENDER_AVI_IN);
  606. m_Progress = PRG_SEL_TO_CREA;
  607. m_xSelectChr.CloseWnd();
  608. break;
  609. }
  610. case 12: // Zoom Out
  611. {
  612. m_xBGround.SetRenderState(_RENDER_AVI_START);
  613. m_Progress = PRG_SEL_TO_GAME;
  614. m_xSelectChr.CloseWnd();
  615. break;
  616. }
  617. case 19: // Select;
  618. {
  619. m_xSelectChr.m_nRenderState = 0;
  620. }
  621. }
  622. m_xSelectChr.Render(nLoopTime);
  623. break;
  624. }
  625. case PRG_SEL_TO_CREA:
  626. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
  627. if(m_xBGround.GetRenderState()==_RENDER_STILL_2)
  628. m_Progress = PRG_CREATE_CHAR;
  629. break;
  630. case PRG_CREATE_CHAR:
  631. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_SHOW);
  632. RenderCharCreate(nLoopTime);
  633. break;
  634. case PRG_CREA_TO_SEL:
  635. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
  636. if(m_xBGround.GetRenderState() == _RENDER_STILL_1)
  637. { m_Progress = PRG_CHAR_SELE;
  638. m_xSelectChr.OpenWnd();
  639. }
  640. break;
  641. case PRG_SEL_TO_GAME:
  642. ShowWindow(g_xChatEditBox.GetSafehWnd(), SW_HIDE);
  643. if(m_xBGround.GetRenderState()==_RENDER_STARTGAME)
  644. { m_Progress = PRG_PLAY_GAME; // Play Game
  645. SetNextProc();
  646. }
  647. break;
  648. }
  649. m_xMsgBox.RenderMessageBox(0);
  650. }
  651. VOID CCharacterProcess::ShowStatus(INT nStartX, INT nStartY)
  652. {
  653. /* TCHAR szBuff[MAX_PATH];
  654. sprintf(szBuff, "Character Procedure");*/
  655. CWHDefProcess::ShowStatus(nStartX, nStartY+20);
  656. }
  657. VOID CCharacterProcess::RenderCharCreate(INT nLoopTime)
  658. {
  659. POINT nPos[] = { {120, 88}, {120, 85}, {150, 108}};
  660. // int i ;
  661. MoveWindow(g_xChatEditBox.GetSafehWnd(), 
  662.    g_xMainWnd.m_rcWindow.left+POS_NAME_X,
  663.    g_xMainWnd.m_rcWindow.top+POS_NAME_Y, 75, 15, TRUE);
  664. /* for (i = ID_CREATE_CHR_OK_BTN ; i <= ID_CREATE_CHR_TAO_BTN; i++)
  665. {
  666. m_Image.NewSetIndex(m_pBtn[i].m_nButtonID + m_pBtn[i].m_nState -1);
  667. g_xMainWnd.DrawWithImageForComp(m_pBtn[i].m_Rect.left, m_pBtn[i].m_Rect.top,
  668. m_Image.m_lpstNewCurrWilImageInfo->shWidth,
  669. m_Image.m_lpstNewCurrWilImageInfo->shHeight
  670. , (WORD*)(m_Image.m_pbCurrImage));
  671. }
  672. */
  673. // 烙矫~!
  674. m_Image.NewSetIndex(IMG_IDX_WAR_MALE_CREATE + m_SelectSex + m_SelectJob * 2);
  675. g_xMainWnd.DrawWithImageForComp(nPos[m_SelectJob].x,nPos[m_SelectJob].y
  676. ,m_Image.m_lpstNewCurrWilImageInfo->shWidth,m_Image.m_lpstNewCurrWilImageInfo->shHeight
  677. ,(WORD*)(m_Image.m_pbCurrImage));
  678. }
  679. VOID CCharacterProcess::SetErrorMessage(INT nMsg,CHAR* szMgs)
  680. {
  681. HINSTANCE hLib;
  682. hLib = LoadLibrary(MESSAGE_DLL_1); // Load Dll
  683. if(nMsg!=99 && nMsg!=0)
  684. {
  685. LoadString(hLib,(nMsg+199),szMgs,512);
  686. }
  687. else 
  688. {
  689. if(nMsg!=0)
  690. LoadString(hLib,9999,szMgs,512);
  691. else
  692. ZeroMemory(szMgs,512);
  693. }
  694. FreeLibrary(hLib);
  695. }
  696. BOOL CCharacterProcess::MessageBoxProcess(LPARAM lParam)
  697. {
  698. HRESULT hResult;
  699. POINT ptMouse;
  700. ptMouse.x = LOWORD(lParam);
  701. ptMouse.y = HIWORD(lParam);
  702. hResult  = m_xMsgBox.OnButtonUp(ptMouse);
  703. if((hResult&HAVE_EDITOBOX)==HAVE_EDITOBOX)
  704. {
  705. // edit box exist
  706. switch(hResult^HAVE_EDITOBOX)
  707. {
  708. case CLICK_OK:
  709. {
  710. m_xMsgBox.HideMessageBox();
  711. /* switch(m_nMessage)
  712. {
  713. }*/
  714. break;
  715. }
  716. case CLICK_YES:
  717. {
  718. m_xMsgBox.HideMessageBox();
  719. /* switch(m_nMessage)
  720. {
  721. }*/
  722. break;
  723. }
  724. case CLICK_NO:
  725. {
  726. m_xMsgBox.HideMessageBox();
  727. /* switch(m_nMessage)
  728. {
  729. }*/
  730. break;
  731. }
  732. case CLICK_CANCLE:
  733. {
  734. m_xMsgBox.HideMessageBox();
  735. /* switch(m_nMessage)
  736. {
  737. }*/
  738. break;
  739. }
  740. }
  741. }
  742. else
  743. {
  744. // edit box not exist
  745. switch(hResult)
  746. {
  747. case CLICK_OK:
  748. {
  749. m_xMsgBox.HideMessageBox();
  750. switch(m_nMessage)
  751. {
  752. case 103: //
  753. {
  754. PostQuitMessage(NULL);
  755. m_nMessage = 0;
  756. break;
  757. }
  758. }
  759. break;
  760. }
  761. case CLICK_YES:
  762. {
  763. m_xMsgBox.HideMessageBox();
  764. switch(m_nMessage)
  765. {
  766. case 5:
  767. {
  768. m_CList.MoveCurrentToTop();
  769. m_CList.MoveNode(m_xSelectChr.m_nSelectChr);
  770. g_xClientSocket.OnDelChar(m_CList.GetCurrentData()->ChrName);
  771. g_xClientSocket.OnQueryChar();
  772. m_ChrCount =0 ;
  773. break;
  774. }
  775. }
  776. break;
  777. }
  778. case CLICK_NO:
  779. {
  780. m_xMsgBox.HideMessageBox();
  781. /* switch(m_nMessage)
  782. {
  783. }*/
  784. break;
  785. }
  786. case CLICK_CANCLE:
  787. {
  788. m_xMsgBox.HideMessageBox();
  789. /* switch(m_nMessage)
  790. {
  791. }*/
  792. break;
  793. }
  794. }
  795. }
  796. return TRUE;
  797. }