www.pudn.com > 3D_OnlineGame_Humen.rar > MainScreen.cpp


// MainScreen.cpp: implementation of the CMainScreen class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "XMudClient.h" 
#include "MainScreen.h" 
#include "FacePlate.h" 
#include "D3DRMScreen.h" 
#include "alpha.h" 
#include "MapInfo.h" 
#include "MenuCreateNew.h" 
#include "InitInternet.h" 
#include  
#include "MyDInput.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
extern BOOL g_Show555; 
extern BOOL g_Redraw2dFace[2]; 
RECT rc3DMainFace; 
 
extern LPDIRECT3DRM3 g_lpD3DRM; 
extern LPDIRECT3DRMFRAME3 g_lpplayer; 
extern rmfullglobals myglobs; 
extern D3DAppInfo* d3dapp; 
 
extern CRITICAL_SECTION csAnimation; 
extern CList  animationlist; 
extern animationCallbackArgs *cb; 
extern CListplayerlist; 
extern CPlayerInfo * lpPlayerInfo; 
extern CList  maplist; 
extern CListskilllist; 
extern CListequiplist; 
extern CListequiprentlist; 
extern CStringList g_equiprentlist; 
extern CMapInfo * lpMapInfo; 
 
extern BOOL bInsertState;	//插入覆蓋狀態 
extern CString g_szInputMsg; 
extern int	g_nInputMsgPos; 
extern int g_nSelStart; 
extern int g_nSelEnd; 
extern HFONT g_MessagehFont; 
 
extern CList  chatchannellist; 
//extern CStringList g_strlistSelfMsg; 
 
extern char g_tszPathName[256]; 
 
#define EFFANDMAXWIDTH  24 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CMainScreen::CMainScreen() 
{ 
} 
 
CMainScreen::~CMainScreen() 
{ 
} 
 
BOOL CMainScreen::PrepareMainScreen() 
{ 
  int i; 
  //設置各個區的位置 
  SetRect(&rcFirstField,5,189,202,363);		    //屏幕第一滾動條區(上邊) 
  SetRect(&rcSecondField,5,371,202,562);		  //屏幕第二滾動條區(下邊) 
  SetRect(&rcSysUseField,211,373,244,562);	  //功能區一(系統功能,武功、裝備等) 
  SetRect(&rcUserUseField,251,371,705,412);	  //功能區二(用戶功能,練功、拜師等) 
  SetRect(&rcInputMsgField,5,571,793,592);	  //命令輸入框區 
  SetRect(&rcTalkMessField,251,419,793,562);	//對話信息區 
  SetRect(&rc3DField,209,7,794,364);			    //3D信息區 
   
  //鼠標狀態 
  nMouseWorkField = FieldUnknown; 
  nMouseState = MouseNone; 
  //清除窗口按鈕 
  bClearScreen = FALSE; 
  bClearScrRed = 0; //鼠標是否在上邊 
  SetRect(&rcClearScreen,714,373,791,410); 
  SetRect(&rcClearScreenDownSource,528,601,605,638); 
  SetRect(&rcClearScreenOnSource,607,601,684,638); 
   
  //設置系統功能區變量 
  mSysFD.whatBtnDown = BtnNone; 
  mSysFD.BtnMoveStatus = BtnHintHide; 
  SetRect(&mSysFD.rcCommunicate,211,373,243,393);       //頻道按鈕 
  SetRect(&mSysFD.rcCommunicateDownSource,42,600,73,620); 
  SetRect(&mSysFD.rcAdventure,211,396,243,416);         //冒險按鈕 
  SetRect(&mSysFD.rcAdventureDownSource,75,600,106,620); 
  SetRect(&mSysFD.rcPractice,211,419,243,439);          //武術按鈕 
  SetRect(&mSysFD.rcPracticeDownSource,107,600,138,620); 
  SetRect(&mSysFD.rcBasicSkill,211,442,243,462);        //道具按鈕 
  SetRect(&mSysFD.rcBasicSkillDownSource,139,600,170,620); 
  SetRect(&mSysFD.rcOrganize,211,465,243,485);          //組織按鈕 
  SetRect(&mSysFD.rcOrganizeDownSource,171,600,202,620); 
  SetRect(&mSysFD.rcFamily,211,489,243,509);            //門派按鈕 
  SetRect(&mSysFD.rcFamilyDownSource,203,600,234,620); 
  SetRect(&mSysFD.rcEmotion,211,512,243,532);           //憤怒表情 
  SetRect(&mSysFD.rcEmotionDownSource,235,600,266,620); 
 
//  SetRect(&mSysFD.rcWugong,211,396,243,416);				//武功按鈕 
//  SetRect(&mSysFD.rcWugongDownSource,75,600,106,620); 
//  SetRect(&mSysFD.rcEquip,211,419,243,439);				  //裝備按鈕 
//  SetRect(&mSysFD.rcEquipDownSource,107,600,138,620); 
//  SetRect(&mSysFD.rcHappyface,211,442,243,462);			//高興表情 
//  SetRect(&mSysFD.rcHappyfaceDownSource,139,600,170,620); 
 
//  SetRect(&mSysFD.rcAngryface,211,465,243,485);			//憤怒表情 
//  SetRect(&mSysFD.rcAngryfaceDownSource,171,600,202,620); 
//  SetRect(&mSysFD.rcBuleface,211,488,243,508);			//憂傷表情 
//  SetRect(&mSysFD.rcBulefaceDownSource,203,600,235,620); 
//  SetRect(&mSysFD.rcOthereface,211,511,243,531);		//其他表情 
//  SetRect(&mSysFD.rcOtherefaceDownSource,236,600,267,620); 
 
  SetRect(&mSysFD.rcOption,211,540,243,560);				//系統按鈕 
  SetRect(&mSysFD.rcOptionDownSource,268,600,299,620); 
   
  SetRect(&mSysFD.rcHintNameField ,211,373,243,560); 
  SetRect(&mSysFD.rcHintNameSource,747,779,800,796); 
 
  //設置用戶功能區變量 
  mUserFD.nWhatBtnDown = UB_none;	//按下了那一個按鈕 
  mUserFD.nStatus = 0; 
   
  mUserFD.nSysStatus = UBS_communicate; 
  mUserFD.nCount[0] = 8; 
  mUserFD.nCount[1] = 5; 
  mUserFD.nCount[2] = 8; 
  mUserFD.nCount[3] = 8; 
  mUserFD.nCount[4] = 5; 
  mUserFD.nCount[5] = 6; 
  mUserFD.nCount[6] = 4; 
  mUserFD.nCount[7] = 7; 
  SetRect(&mUserFD.rcOrgBtn[0],  2, 736,  2+UB_XSPACE-3, 736+UB_HEIGHT); 
  SetRect(&mUserFD.rcOrgBtn[1],  2, 865,  2+UB_XSPACE-3, 865+UB_HEIGHT); 
  SetRect(&mUserFD.rcOrgBtn[2],  2, 994,  2+UB_XSPACE-3, 994+UB_HEIGHT); 
  SetRect(&mUserFD.rcOrgBtn[3],  2,1123,  2+UB_XSPACE-3,1123+UB_HEIGHT); 
  SetRect(&mUserFD.rcOrgBtn[4],434, 736,434+UB_XSPACE-3, 736+UB_HEIGHT); 
  SetRect(&mUserFD.rcOrgBtn[5],434, 865,434+UB_XSPACE-3, 865+UB_HEIGHT); 
  SetRect(&mUserFD.rcOrgBtn[6],434, 994,434+UB_XSPACE-3, 994+UB_HEIGHT); 
  SetRect(&mUserFD.rcOrgBtn[7],434,1123,434+UB_XSPACE-3,1123+UB_HEIGHT); 
  for(i=0;inKind = szTmp[0]-'0'; 
      fEmote.ReadString(lpEmote->szCEmote); 
      fEmote.ReadString(lpEmote->szEmote); 
      fEmote.ReadString(szTmp); 
      lpEmote->nType = szTmp[0]-'0'; 
      pos = listAllEmote.GetHeadPosition(); 
      while (pos != NULL) 
      { 
        lpEmote2 = listAllEmote.GetNext(pos); 
        if(lpEmote->szEmote < lpEmote2->szEmote) 
        { 
          if(pos != NULL) 
            listAllEmote.GetPrev(pos); 
          else 
            pos = listAllEmote.GetTailPosition(); 
          listAllEmote.InsertBefore(pos,lpEmote); 
          break; 
        } 
      } 
      if(pos == NULL) 
        listAllEmote.AddTail(lpEmote); 
    } 
    fEmote.Close(); 
    mSecondFD.szEndEmote = lpEmote->szEmote; 
  } 
   
  mSecondFD.nKindState = ETK_smile; 
  SetRect(&mSecondFD.rcGreenUp,470,601,527,621); 
  SetRect(&mSecondFD.rcGreenDown,171,627,228,647); 
   
  SetRect(&rcNumberSource,675,648,734,657); 
  SetRect(&rcPlayName    , 43, 15, 99, 26); 
  SetRect(&rcPlayNickName,143, 15,189, 26); 
  SetRect(&rcPlaySex     , 39, 32, 50, 43); 
  SetRect(&rcPlayShen    ,144, 96,156,107); 
 
  posPlayAge		     = CPoint( 86, 33); 
  posPlayExp		     = CPoint(137, 33); 
 
  posPlayCoin		     = CPoint( 38, 54); 
  posPlaySeliver		 = CPoint( 79, 54); 
  posPlayGold		     = CPoint(120, 54); 
  posPlayQianNeng    = CPoint(173, 54); 
 
  posPlayStr		     = CPoint( 39, 75); 
  posPlayInt		     = CPoint( 86, 75); 
  posPlayCon		     = CPoint(132, 75); 
  posPlayDex		     = CPoint(179, 75); 
 
  posPlayShen		     = CPoint(138,112); 
 
  posPlayEffNeili    = CPoint( 39, 97); 
  posPlayMaxNeili    = CPoint( 74, 97); 
  posPlayAddNeili    = CPoint(117, 97); 
  posPlayEffJinli    = CPoint( 39,112); 
  posPlayMaxJinli    = CPoint( 74,112); 
  posPlayAddJinli    = CPoint(117,112); 
 
  posPlayEffQili	   = CPoint( 39,131); 
  posPlayMaxQili	   = CPoint( 68,131); 
  posPlayEffJingshen = CPoint(144,131); 
  posPlayMaxJingshen = CPoint(173,131); 
  posPlayEffFood	   = CPoint( 39,146); 
  posPlayMaxFood	   = CPoint( 68,146); 
  posPlayEffDrink    = CPoint(144,146); 
  posPlayMaxDrink    = CPoint(173,146); 
 
  posPlayKillNpc	   = CPoint( 72,165); 
  posPlayKillPlay    = CPoint(154,165); 
 
  SetRect(&rcSelectOnePos,213,340,333,360); 
  SetRect(&rcFaceSomeOne,366,115,624,243); 
  SetRect(&rcMapTitleInfo,212,11,292,31); 
   
  SetRect(&rcMainSurfaceSource,0,0,800,600); 
  Free2DSurfaces(); 
  myglobs.view->Clear( D3DRMCLEAR_ALL ); 
  SAFE_RELEASE(myglobs.view); 
  g_lpD3DRM->CreateViewport( myglobs.dev, myglobs.camera,  
    MAINFACEXPOS, MAINFACEYPOS, 
    MAINFACEWIELD,MAINFACEHIGH, 
    &myglobs.view ); 
  rc3DMainFace.left = MAINFACEXPOS; 
  rc3DMainFace.top = MAINFACEYPOS; 
  rc3DMainFace.right = MAINFACEXPOS+MAINFACEWIELD; 
  rc3DMainFace.bottom = MAINFACEYPOS+MAINFACEHIGH; 
  myglobs.view->SetBack( 5000.0f ); 
   
  // 
  //裝入新的主遊戲圖片到surface 
  // 
  char szTmpBmpName[256]; 
  lstrcpy( szTmpBmpName, "Mainface.bmp" ); 
  myglobs.g_lpDDSGameMenu = DDLoadBitmap(d3dapp->lpDD,szTmpBmpName,0,0); 
  if( NULL != myglobs.g_lpDDSGameMenu ) 
    DDSetColorKey(myglobs.g_lpDDSGameMenu, RGB(0,255,0)); 
  else 
    return E_FAIL; 
   
  return TRUE; 
} 
 
void CMainScreen::GetStateEmote() 
{ 
  TEmote * lpEmote, *lpEmote2; 
  POSITION pos; 
   
  listCurEmote.RemoveAll(); 
   
  pos = listAllEmote.GetHeadPosition(); 
  while (pos != NULL) 
  { 
    lpEmote = listAllEmote.GetNext(pos); 
    if(lpEmote->nKind == mSecondFD.nKindState) 
    { 
      lpEmote2 = new TEmote; 
      lpEmote2->nKind = lpEmote->nKind; 
      lpEmote2->szCEmote = lpEmote->szCEmote; 
      lpEmote2->szEmote = lpEmote->szEmote; 
      lpEmote2->nType = lpEmote->nType; 
      listCurEmote.AddTail(lpEmote2); 
    } 
  } 
} 
void CMainScreen::GetStateEmote(int nState) 
{ 
  mSecondFD.nKindState = nState; 
  GetStateEmote(); 
} 
 
void CMainScreen::PrepareNewMapInfo() 
{ 
  g_Redraw2dFace[0] = TRUE; 
  g_Redraw2dFace[1] = TRUE; 
  bSelectOne = FALSE; 
  szSelectEName.Empty(); 
   
  bFaceSomeOne[0] = FALSE; 
  bFaceSomeOne[1] = FALSE; 
  szFaceShowMsg.Empty(); 
  szFaceSomeCName.Empty(); 
   
  bChangeInputMsg[0] = TRUE; 
  bChangeInputMsg[1] = TRUE; 
  bDrawPlayInfo[0] = TRUE;//初始化的時候需要畫人物的屬性數據 
  bDrawPlayInfo[1] = TRUE;//初始化的時候需要畫人物的屬性數據 
} 
 
void CMainScreen::DrawSecondField() 
{ 
  RECT rcTmp = rcSecondField; 
  int i,j; 
  POSITION posTmp; 
  TEmote * lpEmote; 
  CString szEmote; 
  static int nLastKind = 0; 
   
  if(mSecondFD.nKindState != nLastKind) 
  { 
    nLastKind = mSecondFD.nKindState; 
     
    GetStateEmote(); 
    mSecondFD.nEmoteCount = listCurEmote.GetCount(); 
     
    mSecondFD.mDragBar.ResetCount((mSecondFD.nEmoteCount + 2)/3); 
    mSecondFD.nSelect = 0;			//當前區域哪一條記錄是被選中的 
  } 
  mSecondFD.mDragBar.ReDraw(); 
  rcTmp.right -= 17; 
  bltObject(rcTmp.left, 
				rcTmp.top, 
        myglobs.g_lpDDSGameMenu, 
        &rcTmp, 
        DDBLTFAST_SRCCOLORKEY); 
   
  i = ((mSecondFD.mDragBar.nFirstPos<0)?0:mSecondFD.mDragBar.nFirstPos) * 3; 
  j = (mSecondFD.nEmoteCount > (i+27))? i+27 : mSecondFD.nEmoteCount; 
  posTmp = listCurEmote.FindIndex(i); 
  j -= i; 
  for(i=0;iszCEmote : lpEmote->szEmote; 
    //		int nWidth = GetStrWidth(szEmote, FALSE); 
    //		if ( nWidth > (SNB_WIDTH-11) ) 
    //		{ 
    //			//Msg("字串超長︰"); 
    //			//Msg((LPCSTR)lpEmote->szEmote); 
    //		} 
    //		else 
    //		{ 
    //			rcTmp.left += (SNB_WIDTH-11 - nWidth)/2; 
    //		} 
    // 畫裝備或頻道底字 
    DrawGameString((char *)(LPCSTR)szEmote 
						,&rcTmp 
            ,DT_LEFT | DT_VCENTER 
            ,RGB(0,0,0) 
            ,RGB(0,0,0),TRUE); 
    rcTmp.left --; 
    rcTmp.right --; 
    rcTmp.top --; 
    rcTmp.bottom --; 
    // 畫裝備或頻道文字 
    DrawGameString((char *)(LPCSTR)szEmote 
						,&rcTmp 
            ,DT_LEFT | DT_VCENTER 
            ,RGB(255,248,122) 
            ,RGB(0,0,0),TRUE); 
  } 
} 
 
extern long BackNo; 
HRESULT CMainScreen::Draw2DMainScreen() 
{ 
  int x,y; 
  int i,j; 
  SIZE Size; 
  D3DRMRAY rmRay; 
  D3DRMVECTOR4D v4Src; 
  RECT rcXTmp; 
  POINT xpos; 
  POINT ypos; 
  CString strtmp,strShowtmp; 
  LPSTR szbuffer,szTitle,szCName; 
   
  if(!maplist.IsEmpty()) 
  { 
    // 畫中文地圖名稱 
    lpMapInfo = maplist.GetHead(); 
    DrawGameString(lpMapInfo->m_sCNAME.GetBuffer(lpMapInfo->m_sCNAME.GetLength()) 
      ,&rcMapTitleInfo 
      ,DT_LEFT | DT_VCENTER 
      ,RGB(241,191,113) 
      ,RGB(0,0,0),TRUE); 
  } 
   
  if(myglobs.bShowFrameRate) 
  { 
//    EnterCriticalSection(&csAnimation); 
    j = animationlist.GetCount(); 
    for(i=0;iframe3obj->GetPosition(myglobs.scene, &rmRay.dvDir); 
      rmRay.dvDir.y = 1.4f; 
      myglobs.view->Transform(&v4Src, &rmRay.dvDir); 
      x = (int)(v4Src.x/v4Src.w); 
      y = (int)(v4Src.y/v4Src.w); 
      if(cb->cXFileType == "NPC") 
      { 
        strtmp=cb->cCName; 
        szTitle=NULL; 
        szCName=cb->cCName.GetBuffer(cb->cCName.GetLength()); 
        szbuffer=strtmp.GetBuffer(strtmp.GetLength()); 
      }  
      else 
      { 
        strtmp=cb->cTitle+cb->cCName; 
        szTitle=cb->cTitle.GetBuffer(cb->cTitle.GetLength()); 
        szCName=cb->cCName.GetBuffer(cb->cCName.GetLength()); 
        szbuffer=strtmp.GetBuffer(strtmp.GetLength()); 
      } 
      MyGetTextExtentPoint32(szbuffer,strlen(szbuffer),&Size,TRUE); 
      xpos.x = rcXTmp.left   = x-Size.cx/2; 
      xpos.y = rcXTmp.top    = y; 
      ypos.x = rcXTmp.right  = rcXTmp.left+Size.cx; 
      ypos.y = rcXTmp.bottom = y+15; 
      if(PtInRect(&rc3DMainFace,xpos)&&PtInRect(&rc3DMainFace,ypos)) 
      { 
        // 畫Player及NPC中文姓名 
        if(szTitle) 
        { 
          DrawGameString(szTitle 
            ,&rcXTmp 
            ,DT_LEFT | DT_VCENTER 
            ,RGB(255,171,18) 
            ,RGB(0,0,0),TRUE); 
          MyGetTextExtentPoint32(szTitle,strlen(szTitle),&Size,TRUE); rcXTmp.left+=Size.cx; 
        } 
        if(szCName) 
        { 
          if(cb->cXFileType == "NPC") 
          { 
            DrawGameString(szCName 
              ,&rcXTmp 
              ,DT_LEFT | DT_VCENTER 
              ,RGB(0,255,255) 
              ,RGB(0,0,0),TRUE); 
          } 
          else 
          { 
            DrawGameString(szCName 
              ,&rcXTmp 
              ,DT_LEFT | DT_VCENTER 
              ,RGB(68,255,34) 
              ,RGB(0,0,0),TRUE); 
          } 
        } 
      } 
    } 
  } 
   
  if(g_Redraw2dFace[BackNo])	{//在需要的時候才開始全屏幕重畫,提高一些速度 
    bltObject(0,0,myglobs.g_lpDDSGameMenu,&rcMainSurfaceSource,DDBLTFAST_SRCCOLORKEY); 
    DrawPlayInfo();//必須重畫人物的數值屬性 
    bDrawPlayInfo[BackNo] = FALSE;//只在需要的時候才需要從新畫圖 
    DrawOneField(); 
    mFirstFD.bReDraw[BackNo] = FALSE; 
    DrawSecondField(); 
    mSecondFD.bReDraw[BackNo] = FALSE; 
    DisplaySelfMessage(TRUE); 
    mTalkFD.bReDraw[BackNo] = FALSE; 
    UserFDDraw(); // 秀功能一二區系統按鈕 
    g_Redraw2dFace[BackNo] = FALSE; 
  } 
   
  if(bDrawPlayInfo[BackNo])//是否重新畫人物的數值屬性 
  { 
    DrawPlayInfo(); 
    bDrawPlayInfo[BackNo] = FALSE;//只在需要的時候才需要從新畫圖 
  } 
   
  if(mFirstFD.bReDraw[BackNo])//是否重畫第一區記錄 
  { 
    DrawOneField(); 
    mFirstFD.bReDraw[BackNo] = FALSE; 
  } 
  if(mSecondFD.bReDraw[BackNo])//是否重畫第二區記錄 
  { 
    DrawSecondField(); 
    mSecondFD.bReDraw[BackNo] = FALSE; 
  } 
  if(mTalkFD.bReDraw[BackNo])//是否重畫對話區記錄 
  { 
    DisplaySelfMessage(TRUE); 
    mTalkFD.bReDraw[BackNo] = FALSE; 
    if(mSysFD.BtnMoveStatus==BtnHintShow) 
    { 
      mSysFD.bHintNameReDraw[0]=TRUE; 
      mSysFD.bHintNameReDraw[1]=TRUE; 
    } 
  } 
  if(mUserFD.bReDraw[BackNo]) 
  { 
    UserFDDraw(); // 秀功能一二區系統按鈕 
    mUserFD.bReDraw[BackNo] = FALSE; 
    if(mSysFD.BtnMoveStatus==BtnHintShow) 
    { 
      mSysFD.bHintNameReDraw[0]=TRUE; 
      mSysFD.bHintNameReDraw[1]=TRUE; 
    } 
  } 
/* 
  if(mSysFD.BtnMoveStatus==BtnHintShow && timeGetTime()-mSysFD.LastBtnTick>=2500) 
  { 
    if(mSysFD.bHintNameReDraw[0]==FALSE && mSysFD.bHintNameReDraw[1]==FALSE) 
    { 
      mSysFD.bHintNameReDraw[0]=TRUE; 
      mSysFD.bHintNameReDraw[1]=TRUE; 
      mSysFD.BtnMoveStatus=BtnHintHide; 
    } 
  } 
*/ 
  // 目前滑鼠位置在系統按鈕上 
  if(mSysFD.ThisBtnMove!=BtnNone) 
  { 
    // 如果提示框已顯示 
    if(mSysFD.BtnMoveStatus==BtnHintShow) 
    { 
      // 如果上一滑鼠位置與目前位置不同 
      if(mSysFD.LastBtnMove!=mSysFD.ThisBtnMove) 
      { 
        if(mSysFD.bHintNameReDraw[0]==FALSE)// && (!(d3dapp && d3dapp->bFullscreen) || (d3dapp && d3dapp->bFullscreen && mSysFD.bHintNameReDraw[1]==FALSE))) 
        { 
          mSysFD.bHintNameReDraw[0]=TRUE; 
          mSysFD.bHintNameReDraw[1]=TRUE; 
          mSysFD.BtnMoveStatus=BtnHintHide; 
        } 
      } 
      // 如果上一滑鼠位置與目前位置相同等待2.5秒 
      else if(timeGetTime()-mSysFD.LastBtnTick>=2500) 
      { 
        if(mSysFD.bHintNameReDraw[0]==FALSE)// && (!(d3dapp && d3dapp->bFullscreen) || (d3dapp && d3dapp->bFullscreen && mSysFD.bHintNameReDraw[1]==FALSE))) 
        { 
          mSysFD.bHintNameReDraw[0]=TRUE; 
          mSysFD.bHintNameReDraw[1]=TRUE; 
          mSysFD.BtnMoveStatus=BtnHintHide; 
        } 
      } 
    } 
    // 如果提示框已顯示 
    if(mSysFD.bHintNameReDraw[0]==FALSE)// && (!(d3dapp && d3dapp->bFullscreen) || (d3dapp && d3dapp->bFullscreen && mSysFD.bHintNameReDraw[1]==FALSE))) 
    { 
      if(mSysFD.LastBtnMove!=mSysFD.ThisBtnMove && mSysFD.BtnMoveStatus==BtnHintHide && timeGetTime()-mSysFD.LastBtnTick>= 500) 
      { 
        mSysFD.rcBackup.left  =mSysFD.rcHintNameSource.left; 
        mSysFD.rcBackup.right =mSysFD.rcHintNameSource.right; 
        mSysFD.rcBackup.top   =mSysFD.rcHintNameSource.top-18; 
        mSysFD.rcBackup.bottom=mSysFD.rcHintNameSource.bottom-18; 
        mSysFD.rcSource.left  =mSysFD.rcHintNameSource.left; 
        mSysFD.rcSource.right =mSysFD.rcHintNameSource.right; 
        mSysFD.rcSource.top   =mSysFD.rcHintNameSource.top+18*(mSysFD.ThisBtnMove-1); 
        mSysFD.rcSource.bottom=mSysFD.rcHintNameSource.bottom+18*(mSysFD.ThisBtnMove-1); 
        switch(mSysFD.ThisBtnMove) 
        { 
        case BtnCommunicate: 
          mSysFD.rcTemp.left  =mSysFD.rcCommunicate.right; 
          mSysFD.rcTemp.right =mSysFD.rcCommunicate.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcCommunicate.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcCommunicate.bottom; 
          break; 
        case BtnAdventure: 
          mSysFD.rcTemp.left  =mSysFD.rcAdventure.right; 
          mSysFD.rcTemp.right =mSysFD.rcAdventure.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcAdventure.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcAdventure.bottom; 
          break; 
        case BtnPractice: 
          mSysFD.rcTemp.left  =mSysFD.rcPractice.right; 
          mSysFD.rcTemp.right =mSysFD.rcPractice.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcPractice.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcPractice.bottom; 
          break; 
        case BtnBasicSkill: 
          mSysFD.rcTemp.left  =mSysFD.rcBasicSkill.right; 
          mSysFD.rcTemp.right =mSysFD.rcBasicSkill.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcBasicSkill.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcBasicSkill.bottom; 
          break; 
        case BtnOrganize: 
          mSysFD.rcTemp.left  =mSysFD.rcOrganize.right; 
          mSysFD.rcTemp.right =mSysFD.rcOrganize.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcOrganize.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcOrganize.bottom; 
          break; 
        case BtnFamily: 
          mSysFD.rcTemp.left  =mSysFD.rcFamily.right; 
          mSysFD.rcTemp.right =mSysFD.rcFamily.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcFamily.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcFamily.bottom; 
          break; 
        case BtnEmotion: 
          mSysFD.rcTemp.left  =mSysFD.rcEmotion.right; 
          mSysFD.rcTemp.right =mSysFD.rcEmotion.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcEmotion.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcEmotion.bottom; 
          break; 
        case BtnOption: 
          mSysFD.rcTemp.left  =mSysFD.rcOption.right; 
          mSysFD.rcTemp.right =mSysFD.rcOption.right+53; 
          mSysFD.rcTemp.top   =mSysFD.rcOption.bottom-17; 
          mSysFD.rcTemp.bottom=mSysFD.rcOption.bottom; 
          break; 
        } 
        mSysFD.bHintNameReDraw[0]=TRUE; 
        mSysFD.bHintNameReDraw[1]=TRUE; 
        mSysFD.BtnMoveStatus=BtnHintShow; 
        getObject(mSysFD.rcBackup.left, 
          mSysFD.rcBackup.top, 
          myglobs.g_lpDDSGameMenu, 
          &mSysFD.rcTemp, 
          DDBLTFAST_NOCOLORKEY); 
        mSysFD.LastBtnMove=mSysFD.ThisBtnMove; 
        mSysFD.LastBtnTick=timeGetTime(); 
      } 
    } 
  } 
  else 
  { 
    if(mSysFD.BtnMoveStatus==BtnHintShow) 
    { 
      if(mSysFD.LastBtnMove!=mSysFD.ThisBtnMove) 
      { 
        if(mSysFD.bHintNameReDraw[0]==FALSE)// && (!(d3dapp && d3dapp->bFullscreen) || (d3dapp && d3dapp->bFullscreen && mSysFD.bHintNameReDraw[1]==FALSE))) 
        { 
          mSysFD.bHintNameReDraw[0]=TRUE; 
          mSysFD.bHintNameReDraw[1]=TRUE; 
          mSysFD.BtnMoveStatus=BtnHintHide; 
        } 
      } 
    } 
    if(mSysFD.BtnMoveStatus==BtnHintHide) 
    { 
      if(mSysFD.bHintNameReDraw[0]==FALSE)// && (!(d3dapp && d3dapp->bFullscreen) || (d3dapp && d3dapp->bFullscreen && mSysFD.bHintNameReDraw[1]==FALSE))) 
      { 
        mSysFD.LastBtnMove=BtnNone; 
      } 
    } 
  } 
  if(mSysFD.bHintNameReDraw[BackNo]) 
  { 
         if(mSysFD.BtnMoveStatus==BtnHintShow) 
    { 
      bltObject(mSysFD.rcTemp.left, 
        mSysFD.rcTemp.top, 
        myglobs.g_lpDDSGameMenu, 
        &mSysFD.rcSource, 
        DDBLTFAST_SRCCOLORKEY); 
    } 
    else if(mSysFD.BtnMoveStatus==BtnHintHide) 
    { 
      bltObject(mSysFD.rcTemp.left, 
        mSysFD.rcTemp.top, 
        myglobs.g_lpDDSGameMenu, 
        &mSysFD.rcBackup, 
        DDBLTFAST_NOCOLORKEY); 
    } 
    mSysFD.bHintNameReDraw[BackNo]=FALSE; 
  } 
 
  if(bSelectOne) 
  { 
    // 畫被選者姓名在左下角 
    DrawGameString(szSelectOneName 
						,&rcSelectOnePos 
            ,DT_LEFT | DT_VCENTER 
            ,RGB(255,0,0) 
            ,RGB(0,0,0),TRUE); 
  } 
  // 
  //顯示和其他人的對話框的信息(在3D主視口顯示) 
  // 
  //字串內檢查特定的標示符號顯示不同的顏色 
  if(myglobs.g_bShowMessage) 
  { 
    Display3DMessage(); 
  } 
 
  if(bChangeInputMsg[BackNo]){ 
    CString StrLeft,StrSel,StrRight; 
    int leftlen = 0; 
    if( g_nSelStart < 0 )  
      g_nSelStart = 0; 
    if( g_nSelStart > g_szInputMsg.GetLength() ) 
      g_nSelStart = g_szInputMsg.GetLength(); 
    if( g_nSelEnd < 0 )  
      g_nSelEnd = 0; 
    if( g_nSelEnd > g_szInputMsg.GetLength() ) 
      g_nSelEnd = g_szInputMsg.GetLength(); 
    if( g_nSelStart > g_nSelEnd ) 
    { 
      leftlen = g_nSelStart; 
      g_nSelStart = g_nSelEnd; 
      g_nSelEnd = leftlen; 
    } 
  
    if( g_nSelStart != g_nSelEnd ) 
    { 
      StrLeft = g_szInputMsg.Left(g_nSelStart); 
      StrSel = g_szInputMsg.Mid(g_nSelStart, g_nSelEnd-g_nSelStart); 
      StrRight = g_szInputMsg.Right(g_szInputMsg.GetLength() - g_nSelEnd); 
    } 
    else 
    { 
      StrLeft = g_szInputMsg; 
      StrSel.Empty(); 
      StrRight.Empty(); 
    } 
 
    SetRect(&rcXTmp,5,572,794,590); 
    bltObject(rcXTmp.left, 
      rcXTmp.top, 
      myglobs.g_lpDDSGameMenu, 
      &rcXTmp, 
      DDBLTFAST_SRCCOLORKEY); 
     
    if( ! StrLeft.IsEmpty() ) 
    { 
      strShowtmp = StrLeft; 
      DrawGameString(strShowtmp.GetBuffer(strShowtmp.GetLength()) 
        ,&rcXTmp 
        ,DT_LEFT | DT_VCENTER 
        ,RGB(255,255,0) 
        ,RGB(0,0,0),TRUE); 
    }		 
    if( ! StrSel.IsEmpty()) 
    { 
      leftlen = GetStrWidth(StrLeft, TRUE); 
      if( leftlen != -1 ) 
      { 
        strShowtmp = StrSel; 
        rcXTmp.left += leftlen; 
        DrawGameString(strShowtmp.GetBuffer(strShowtmp.GetLength()) 
          ,&rcXTmp 
          ,DT_LEFT | DT_VCENTER 
          ,RGB(255,255,255) 
          ,RGB(0,0,255),TRUE); 
      } 
    } 
    if( ! StrRight.IsEmpty()) 
    { 
      leftlen = GetStrWidth(StrSel, TRUE); 
      if( leftlen != -1 ) 
      { 
        strShowtmp = StrRight; 
        rcXTmp.left += leftlen; 
        DrawGameString(strShowtmp.GetBuffer(strShowtmp.GetLength()) 
          ,&rcXTmp 
          ,DT_LEFT | DT_VCENTER 
          ,RGB(255,255,0) 
          ,RGB(0,0,0),TRUE); 
      } 
    } 
     
  
    DrawCursor(); 
    
    bChangeInputMsg[BackNo] = FALSE; 
  } 
 
  HandleCompPaint(); 
  HandleCandPaint(); 
  return DD_OK; 
} 
 
void CMainScreen::DrawCursor() 
{ 
  CString strShowtmp; 
  int leftlen; 
  int nCursorLen; 
 
  if( g_nInputMsgPos < 0 ){ 
    g_nInputMsgPos = 0; 
    bChangeInputMsg[0] = TRUE; 
    bChangeInputMsg[1] = TRUE; 
    return; 
  } 
  if( g_nInputMsgPos > g_szInputMsg.GetLength() ) 
  { 
    g_nInputMsgPos = g_szInputMsg.GetLength(); 
    bChangeInputMsg[0] = TRUE; 
    bChangeInputMsg[1] = TRUE; 
    return; 
  } 
   
  strShowtmp = g_szInputMsg.Left(g_nInputMsgPos); 
  leftlen = GetStrWidth(strShowtmp, TRUE); 
  if( leftlen != -1 ) 
  { 
    HDC hdc; 
    HRESULT ddrval; 
    CDC *pDC; 
    int nOldRop; 
     
    if( g_szInputMsg.GetLength() > (g_nInputMsgPos+1) ) 
    { 
      if(IsDBCSLeadByte(g_szInputMsg.GetAt(g_nInputMsgPos))) 
      { 
        nCursorLen = 10; 
      } 
      else 
      { 
        strShowtmp = g_szInputMsg.GetAt(g_nInputMsgPos); 
        nCursorLen = GetStrWidth(strShowtmp, TRUE); 
        nCursorLen = nCursorLen < 3 ? 3 : nCursorLen; 
      } 
    } 
    else nCursorLen = 5; 
    while( TRUE ) 
    { 
      ddrval =d3dapp->lpBackBuffer->GetDC(&hdc); 
      if( ddrval == DD_OK ) 
      { 
        pDC = CDC::FromHandle(hdc); 
        nOldRop = pDC->SetROP2( R2_NOT ); 
        leftlen += 5; 
        if( bInsertState ){ 
          pDC->MoveTo(leftlen,	572); 
          pDC->LineTo(leftlen,	588); 
          leftlen++; 
          pDC->MoveTo(leftlen,	572); 
          pDC->LineTo(leftlen,	588); 
        }else { 
          pDC->MoveTo(leftlen,			588); 
          pDC->LineTo(leftlen+nCursorLen,	588); 
          pDC->MoveTo(leftlen,			589); 
          pDC->LineTo(leftlen+nCursorLen,	589); 
        } 
        pDC->SetROP2( nOldRop ); 
        d3dapp->lpBackBuffer->ReleaseDC(hdc); 
        break; 
      } 
      if( ddrval == DDERR_SURFACELOST ){ 
        if( !RestoreSurfaces() ) break; 
      } 
      if( ddrval != DDERR_WASSTILLDRAWING ) break; 
    } 
  } 
} 
 
int GetStrWidth(CString str, BOOL bUseMessageFont) 
{ 
  HDC hdc; 
  HRESULT ddrval; 
  CDC *pDC; 
  CSize size; 
   
  while( TRUE ) 
  { 
    ddrval =d3dapp->lpBackBuffer->GetDC(&hdc); 
    if( ddrval == DD_OK ) 
    {	 
      if(bUseMessageFont) 
      { 
        SelectObject(hdc, g_MessagehFont); 
      } 
      pDC = CDC::FromHandle(hdc); 
      size = pDC->GetOutputTextExtent(str); 
      d3dapp->lpBackBuffer->ReleaseDC(hdc); 
      return size.cx; 
    } 
    if( ddrval == DDERR_SURFACELOST ) 
      if( !RestoreSurfaces() ) 
        return -1; 
      if( ddrval != DDERR_WASSTILLDRAWING ) 
        return -1; 
  } 
} 
 
void CMainScreen::DrawMsgBar(LPRECT lpRect) 
{ 
  HDC hdc; 
  HRESULT ddrval; 
   
  while( TRUE ) 
  { 
    ddrval =d3dapp->lpBackBuffer->GetDC(&hdc); 
    if( ddrval == DD_OK ) 
    {	 
      FillRect(hdc,lpRect, (HBRUSH)GetStockObject(BLACK_BRUSH)); 
      d3dapp->lpBackBuffer->ReleaseDC(hdc); 
      return; 
    } 
    if( ddrval == DDERR_SURFACELOST ) 
      if( !RestoreSurfaces() ) 
        return; 
      if( ddrval != DDERR_WASSTILLDRAWING ) 
        return; 
  } 
} 
 
void CMainScreen::DrawPlayInfo() 
{ 
  CString tmpString; 
  RECT rcTmpRect = {36,12,198,177}; 
  bltObject(36,12,myglobs.g_lpDDSGameMenu,&rcTmpRect,DDBLTFAST_SRCCOLORKEY); 
  lpPlayerInfo = playerlist.GetHead(); 
  DrawGameString(lpPlayerInfo->m_sCNAME.GetBuffer(lpPlayerInfo->m_sCNAME.GetLength()) 
    ,&rcPlayName 
    ,DT_LEFT | DT_VCENTER 
    ,RGB(255,212,129) 
    ,RGB(10,10,10),TRUE); 
  tmpString = (lpPlayerInfo->m_sFAMILY.IsEmpty())? "平民百姓" : lpPlayerInfo->m_sFAMILY; 
  DrawGameString(tmpString.GetBuffer(tmpString.GetLength()) 
    ,&rcPlayNickName 
    ,DT_LEFT | DT_VCENTER 
    ,RGB(255,212,129) 
    ,RGB(10,10,10),TRUE); 
  tmpString  = (lpPlayerInfo->m_sSEX == "M")? "男" : "女"; 
  DrawGameString(tmpString.GetBuffer(tmpString.GetLength()) 
    ,&rcPlaySex 
    ,DT_LEFT | DT_VCENTER 
    ,RGB(255,212,129) 
    ,RGB(10,10,10),TRUE); 
  int nTmp = lpPlayerInfo->m_iSHEN; 
  tmpString = (nTmp >= 0)? "正" : "邪"; 
  DrawGameString(tmpString.GetBuffer(tmpString.GetLength()) 
    ,&rcPlayShen 
    ,DT_LEFT | DT_VCENTER 
    ,RGB(255,212,129) 
    ,RGB(10,10,10),TRUE); 
  FillANum((nTmp > 0)?nTmp:-nTmp, 9999999, &posPlayShen, (nTmp<0)?0:1); 
  FillANum(lpPlayerInfo->m_iAGE,       999,&posPlayAge,1); 
  FillANum(lpPlayerInfo->m_iEXP,2147483647,&posPlayExp,1); 
  FillANum( lpPlayerInfo->m_iMONEY/10000,    9999, &posPlayGold,    2); 
  FillANum((lpPlayerInfo->m_iMONEY%10000)/100, 99, &posPlaySeliver, 2); 
  FillANum( lpPlayerInfo->m_iMONEY%100,        99, &posPlayCoin,    2); 
  FillANum( lpPlayerInfo->m_iQIANNENG,       9999, &posPlayQianNeng,2); 
  FillANum(lpPlayerInfo->m_iSTR, 999, &posPlayStr,3); 
  FillANum(lpPlayerInfo->m_iINT, 999, &posPlayInt,3); 
  FillANum(lpPlayerInfo->m_iCON, 999, &posPlayCon,3); 
  FillANum(lpPlayerInfo->m_iDEX, 999, &posPlayDex,3); 
  FillANum(lpPlayerInfo->m_iEFFNEILI, 99999, &posPlayEffNeili,4); 
  FillANum(lpPlayerInfo->m_iMAXNEILI, 99999, &posPlayMaxNeili,4); 
  FillANum(lpPlayerInfo->m_iADDNEILI, 99999, &posPlayAddNeili,4); 
  FillANum(lpPlayerInfo->m_iEFFJINLI, 99999, &posPlayEffJinli,4); 
  FillANum(lpPlayerInfo->m_iMAXJINLI, 99999, &posPlayMaxJinli,4); 
  FillANum(lpPlayerInfo->m_iADDJINLI, 99999, &posPlayAddJinli,4); 
  FillANum(lpPlayerInfo->m_iEFFJING,	9999, &posPlayEffJingshen,(lpPlayerInfo->m_iEFFJINGm_iMAXJING/5)?0:5); 
  FillANum(lpPlayerInfo->m_iMAXJING,	9999, &posPlayMaxJingshen,5); 
  FillANum(lpPlayerInfo->m_iEFFQI,	  9999, &posPlayEffQili,        (lpPlayerInfo->m_iEFFQIm_iMAXQI/5)?0:5); 
  FillANum(lpPlayerInfo->m_iMAXQI,	  9999, &posPlayMaxQili,    5); 
  FillANum(lpPlayerInfo->m_iEAT,		  9999, &posPlayEffFood,         (lpPlayerInfo->m_iEATm_iMAXEAT/5)?0:5); 
  FillANum(lpPlayerInfo->m_iMAXEAT,	  9999, &posPlayMaxFood,    5); 
  FillANum(lpPlayerInfo->m_iDRINK,	  9999, &posPlayEffDrink,    (lpPlayerInfo->m_iDRINKm_iMAXDRINK/5)?0:5); 
  FillANum(lpPlayerInfo->m_iMAXDRINK,	9999, &posPlayMaxDrink,   5); 
  FillANum(lpPlayerInfo->m_iKILLNPC,    9999999, &posPlayKillNpc, 6); 
  FillANum(lpPlayerInfo->m_iKILLPLAYER, 9999999, &posPlayKillPlay,6); 
} 
 
void CMainScreen::FillANum(int n, int nMax, POINT * lpPoint, char Color) 
{ 
  char buf[20], *lpChar; 
  RECT rctmp = rcNumberSource; 
  rctmp.top += 9*Color; 
  rctmp.bottom += 9*Color; 
  if(n < 0) n = 0; 
  if(n > nMax) n = nMax; 
  sprintf(buf, "%d", n); 
   
  int x = lpPoint->x; 
  for(lpChar=buf; *lpChar; lpChar++) 
  { 
    rctmp.left = rcNumberSource.left + (*lpChar - '0')*6; 
    rctmp.right = rctmp.left + 6; 
    bltObject( x, lpPoint->y, myglobs.g_lpDDSGameMenu, &rctmp, DDBLTFAST_SRCCOLORKEY ); 
    x += 6; 
  } 
} 
 
HRESULT CMainScreen::DrawChangeMapScreen() 
{ 
  Draw2DMainScreen(); 
  DrawInterLace(); 
  DrawProgress( FALSE ); 
  return DD_OK; 
}