绘画捕鱼房间信息

来源:互联网 发布:随机森林算法看什么书 编辑:程序博客网 时间:2024/04/30 04:19


----------------------一般游戏设置框架标题的流程

//绘画背景  小游戏端游戏框架的标题(用afxmessage调试弹不出来)

BOOL CGameFrameWnd::OnEraseBkgnd(CDC * pDC)
{
//获取标题
CString strTitle;
GetWindowText(strTitle);

//获取位置
CRect rcClient;
GetClientRect(&rcClient);
rcClient.SetRect(rcClient.left,rcClient.top,m_GameFrameWidth,m_GameFrameHeight);
//框架位置
tagEncircleInfo FrameEncircleInfo;
m_FrameEncircle.GetEncircleInfo(FrameEncircleInfo);


//绘画框架
m_FrameEncircle.DrawEncircleFrame(pDC,rcClient,RGB(255,0,255));
DWORD dwVideoMode = m_pIGameFrameView->GetWindowMode();
m_TitleBack[0].TransDrawImage(pDC,24,3,RGB(255,0,255));
m_TitleBack[1].TransDrawImage(pDC,28,3,strTitle.GetLength()*11,FrameEncircleInfo.nTBorder-8,0,0,4,21,RGB(255,0,255));
m_TitleBack[2].TransDrawImage(pDC,strTitle.GetLength()*11+28,3,RGB(255,0,255));
//绘画标题
if (strTitle.IsEmpty()==false)
{
//计算区域
CRect rcTitle;
rcTitle.SetRect(40,8,rcClient.Width()-150,FrameEncircleInfo.nTBorder-8);


//变量定义
INT nXMove[8]={1,1,1,0,-1,-1,-1,0};
INT nYMove[8]={-1,0,1,1,1,0,-1,-1};


//设置环境
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(100,100,100));
pDC->SelectObject(CSkinResourceManager::GetInstance()->GetDefaultFont());


//绘画边框
for (INT i=0;i<CountArray(nXMove);i++)
{
//计算位置
CRect rcTitleFrame;
rcTitleFrame.top=rcTitle.top+nYMove[i];
rcTitleFrame.left=rcTitle.left+nXMove[i];
rcTitleFrame.right=rcTitle.right+nXMove[i];
rcTitleFrame.bottom=rcTitle.bottom+nYMove[i];


//绘画字符
pDC->DrawText(strTitle,&rcTitleFrame,DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
}


//绘画文字
pDC->SetTextColor(RGB(255,255,255));
pDC->DrawText(strTitle,&rcTitle,DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
}


return TRUE;

}



/////

//设置标题
VOID CClientKernel::SetGameFrameTitle()
{
//变量定义
TCHAR szTitle[128]=TEXT("");


//构造标题
if ((m_ServerAttribute.szServerName[0]==0)||(m_UserAttribute.dwUserID==0L))
{
if (VERSION_EFFICACY==FALSE)
{
//获取名字
TCHAR szModuleName[MAX_PATH]=TEXT("");
GetModuleFileName(AfxGetInstanceHandle(),szModuleName,CountArray(szModuleName));


//获取版本
DWORD dwClientVersion=0L;
CWHService::GetModuleVersion(szModuleName,dwClientVersion);


//构造标题
_sntprintf(szTitle,CountArray(szTitle),TEXT("%s - Build %ld.%ld.%ld.%ld"),m_GameAttribute.szGameName,GetProductVer(dwClientVersion),
GetMainVer(dwClientVersion),GetSubVer(dwClientVersion),GetBuildVer(dwClientVersion));
}
else
{
//构造标题
DWORD dwClientVersion=m_GameAttribute.dwClientVersion;
_sntprintf(szTitle,CountArray(szTitle),TEXT("%s - Build %ld.%ld.%ld.%ld"),m_GameAttribute.szGameName,GetProductVer(dwClientVersion),
GetMainVer(dwClientVersion),GetSubVer(dwClientVersion),GetBuildVer(dwClientVersion));
}
}
else
{
if (CServerRule::IsAllowAvertCheatMode(m_ServerAttribute.dwServerRule)==false&&m_UserAttribute.wTableID!=INVALID_TABLE&&((m_ServerAttribute.wServerType&(GAME_GENRE_MATCH|GAME_GENRE_CHALLENGE))==0))
{
_sntprintf(szTitle,CountArray(szTitle),TEXT("%s [ %s - 第 %d 桌 ]"),m_GameAttribute.szGameName,m_ServerAttribute.szServerName,m_UserAttribute.wTableID+1);
}
else
{
_sntprintf(szTitle,CountArray(szTitle),TEXT("%s [ %s ]"),m_GameAttribute.szGameName,m_ServerAttribute.szServerName);
}
}


//设置标题    小游戏端游戏框架的窗口指针
CWnd * pMainWnd=AfxGetMainWnd();
if ((pMainWnd!=NULL)&&(pMainWnd->m_hWnd!=NULL)) pMainWnd->SetWindowText(szTitle);
}



//游戏属性
bool CClientKernel::SetGameAttribute(WORD wKindID, WORD wPlayerCount, DWORD dwClientVersion, HICON hGameIcon, LPCTSTR pszGameName)
{
//设置图标
AfxGetMainWnd()->SetIcon(hGameIcon,TRUE);
AfxGetMainWnd()->SetIcon(hGameIcon,FALSE);


//设置变量
m_GameAttribute.wKindID=wKindID;
m_GameAttribute.wChairCount=wPlayerCount;
m_GameAttribute.dwClientVersion=dwClientVersion;
lstrcpyn(m_GameAttribute.szGameName,pszGameName,CountArray(m_GameAttribute.szGameName));


//获取进程
TCHAR szModuleName[MAX_PATH]=TEXT("");
GetModuleFileName(AfxGetInstanceHandle(),szModuleName,CountArray(szModuleName));


//版本效验
if (VERSION_EFFICACY==TRUE)
{
//获取版本
DWORD dwProcessVersion=0L;
CWHService::GetModuleVersion(szModuleName,dwProcessVersion);


//效验版本
ASSERT(m_GameAttribute.dwClientVersion==dwProcessVersion);
if (m_GameAttribute.dwClientVersion!=dwProcessVersion) throw TEXT("游戏程序版本信息被非法修改");
}


//设置标题
SetGameFrameTitle();


return true;
}


 case IPC_SUB_GF_SERVER_INFO: //房间信息
{
//效验参数
ASSERT(wDataSize==sizeof(IPC_GF_ServerInfo));
if (wDataSize!=sizeof(IPC_GF_ServerInfo)) return false;


            //处理数据
            IPC_GF_ServerInfo * pServerInfo=(IPC_GF_ServerInfo *)pIPCBuffer;
            m_wTableID=pServerInfo->wTableID;
            m_wChairID=pServerInfo->wChairID;
            m_dwUserID=pServerInfo->dwUserID;
            m_ServerAttribute.wKindID=pServerInfo->wKindID;
            m_ServerAttribute.wServerID=pServerInfo->wServerID;
            m_ServerAttribute.wServerType=pServerInfo->wServerType;
            m_ServerAttribute.dwAVServerAddr=pServerInfo->dwAVServerAddr;
//m_ServerAttribute.cbHideUserInfo=pServerInfo->cbHideUserInfo;
m_GameAttribute.wChairCount=GAME_PLAYER;
m_GameAttribute.dwClientVersion=VERSION_CLIENT;
            lstrcpyn(m_GameAttribute.szGameName,GAME_NAME,LEN_KIND);
            lstrcpyn(m_ServerAttribute.szServerName,pServerInfo->szServerName,sizeof(m_ServerAttribute.szServerName));


            //更新标题
            UpdateGameTitle();


            return true;
        }




///////////////////////捕鱼设置框架标题的流程

//更新标题
void CClientKernel::UpdateGameTitle()
{
    //变量定义
    TCHAR szTitle[MAX_PATH]=TEXT("");




#ifdef SHOW_CONSOLE
TCHAR szProcessName[MAX_PATH]=TEXT("Debug");
#else
TCHAR szProcessName[MAX_PATH]=GAME_NAME;
#endif






    //构造标题
    if ((m_ServerAttribute.szServerName[0]!=0)&&(m_wTableID!=INVALID_TABLE)/*&&(m_ServerAttribute.cbHideUserInfo==FALSE)*/)
    {
_sntprintf(szTitle,sizeof(szTitle),TEXT("%s [ %s - 第 %d 桌 ]"),szProcessName,m_ServerAttribute.szServerName,m_wTableID+1);
    }
    else
    {
        _sntprintf(szTitle,sizeof(szTitle),TEXT("%s"),szProcessName);
    }




    SetWindowText(m_hWndClient, szTitle);


    return;
}



/////e:\永荣\游戏组件\常规游戏\蛇行亿年\NetInterface\NetWorkManager.cpp

static HWND hgeHwnd = NULL;




IDteNetWorkManager*  __stdcall CreateDteNetWorkManager(HWND hwnd, const char* cmdLine_, const char* logFileName_)
{
strcpy_s(cmdLine, MAX_PATH, cmdLine_);
strcpy_s(logFileName, MAX_PATH, logFileName_);
hgeHwnd = hwnd;
CNetWorkManger* mgr = CNetWorkManger::Instance();
return mgr;
}


/////GameWorld.UpdateFunc.switch.{ 

case STATE_GAME:
{

if (g_Env&&g_Env->pNetWorkManger == NULL)
{
HWND hWnd = pHge->System_GetState(HGE_HWND);
g_Env->pNetWorkManger = CreateDteNetWorkManager(hWnd, g_Env->cmdLine, NET_LOG_FILE_PATH );
g_Env->pGameEventManager->InitNetWork(g_Env->pNetWorkManger);
GAME_LOG("InitNetWork");


pUITopLayer->GetUIObject<DteUIPictureLabel>("Frame")->SetEnable(true);
pUIBottomLayer->SetEnable(true);
pUIHelpTipLayer->SetEnable(true);
//pGameScoreUILayer->SetEnable(true);
pCursor->SetTexture(frontSight);
pCursor->SetHotSpot(pCursor->GetWidth()/2,pCursor->GetHeight()/2);


DteUILayer* settingLayer = pUITopLayer->GetUIObject<DteUILayer>("Setting");
DteUICheckBox* musicCheckBox = settingLayer->GetUIObject<DteUICheckBox>("MusicCheckBox");
musicCheckBox->SetEventListener(pSoundManager, &SoundManager::SoundOn);//加载完毕才连接这个函数
pSoundManager->SoundOn(musicCheckBox->CheckState());


DteUICheckBox* effectCheckBox = settingLayer->AddUIObject<DteUICheckBox>("EffectCheckBox");
effectCheckBox->SetEventListener(pSoundManager, &SoundManager::EffectOn);//加载完毕才连接这个函数
pSoundManager->EffectOn(effectCheckBox->CheckState());



}




HGE *pHge; // HGE 指针

--------------------------------------开始修改

//////e:\永荣\游戏组件\常规游戏\蛇行亿年\蛇行亿年客户端\Frame\gameWorld.cpp

/////GameWorld.__InitUI 

// 房间信息
// 房间信息
DteUIFont* pUIFontRoomName = pUITopLayer->AddUIObject<DteUIFont>("RoomName");
pUIFontRoomName->SetFont("宋体",14,true);
pUIFontRoomName->SetText("UnKnown");
pUIFontRoomName->SetColor(0xff000000);
pUIFontRoomName->pos.y = 0;
pUIFontRoomName->pos.x = 5;




void GameWorld::OnUserIn( EventParam p )
{
if (p.pUserData->wChairID == g_Env->pNetWorkManger->GetSelfChairID())
{
DteUIFont* playerName = pUIBottomLayer->GetUIObject<DteUIFont>("PlayerName");


char cName[500]={0};
WideCharToMultiByte(CP_ACP,0,p.pUserData->szName,-1,cName, sizeof(cName),NULL,NULL);
playerName->SetText(cName);


char szName[50]={0};
WideCharToMultiByte( CP_ACP,0,_T("PlayerGold"),-1,szName,sizeof(szName),NULL,NULL);


DteUINum* playerGold = pUIBottomLayer->GetUIObject<DteUINum>(szName);
playerGold->SetNum( p.pUserData->lScore );


DteUIFont* pUIFont = g_World->pUITopLayer->GetUIObject<DteUIFont>("RoomName");
if (pUIFont)
{
HWND hWnd = pHge->System_GetState(HGE_HWND);
if (hWnd)
{
TCHAR szTitle[MAX_PATH]=TEXT("");
GetWindowText(hWnd,szTitle,MAX_PATH);
char cName[MAX_PATH]={0};  
WideCharToMultiByte(CP_ACP,0,szTitle,-1,cName,sizeof(cName),NULL,NULL);
pUIFont->SetText(cName);
}
}


bUserEnter = true;
}
}

///e:\永荣\游戏组件\常规游戏\蛇行亿年\蛇行亿年客户端\UIFont.h

void SetColor(DWORD _color){font->SetColor(_color);}

0 0
原创粉丝点击