示例#1
0
//----默认的窗口非客户区绘制消息处理函数------------------------------------------
//描述: 该函数为内部函数,在DefWindowPorc的MSG_NCPAINT中被调用.
//参数:pMsg: 消息指针.
//返回:无.
//------------------------------------------------------------------------------
static void DefWindowProc_NCPAINT(MSG *pMsg)
{
    HWND hwnd=pMsg->hwnd;
    HDC hdc;
    RECT rc;

    if(HWND_Lock(hwnd))
    {
        hdc =GetWindowDC(hwnd);
        if(NULL!=hdc)
        {
            _GetWindowRect(hwnd,&rc);
            _ScreenToWindow(hwnd,(POINT*)&rc,2);

            if(hwnd->Style&WS_BORDER)
            {
                SetDrawColor(hdc,WINDOW_BORDER_COLOR);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);
            }

            if(hwnd->Style&WS_DLGFRAME)
            {
                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR1);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR2);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

                SetDrawColor(hdc,WINDOW_DLGFRAME_COLOR3);
                DrawRect(hdc,&rc);
                InflateRect(&rc,-1,-1);

            }

            if(hwnd->Style&WS_CAPTION)
            {
                rc.bottom =rc.top+hwnd->CaptionSize;

                GradientFillRect(hdc,&rc,RGB(180,180,200),RGB(0,0,180),GFILL_U_D);

                SetTextColor(hdc,WINDOW_CAPTION_TEXT_COLOR);
                InflateRect(&rc,-1,-1);
                DrawText(hdc,hwnd->Text,-1,&rc,DT_LEFT|DT_VCENTER);
            }

            ReleaseDC(hwnd,hdc);
        }

        HWND_Unlock(hwnd);
    }


}
示例#2
0
//----获得窗口矩形区-----------------------------------------------------------
//描述: 获得窗口矩形区,矩形为屏幕坐标.
//参数:hwnd:窗口句柄
//      prc:用于保存矩形数据的指针.
//返回:TRUE:成功; FALSE:失败.
//------------------------------------------------------------------------------
BOOL    GetWindowRect(HWND hwnd,RECT *prc)
{
    if(NULL!=prc)
    if(HWND_Lock(hwnd))
    {
        _GetWindowRect(hwnd,prc);
        HWND_Unlock(hwnd);
        return TRUE;
    }
    return FALSE;
}
/// <summary>Does the formatting and drawing of the champion cooldown
/// interface for a single champion, based on what is in the cache
/// at the time of calling.</summary>
/// <param name="pDevice">LPDIRECT3DDEVICE9 to render to.</param>
/// <param name="cacheIndex">Index within the cache storage of the hero
/// data to be rendered.</param>
/// <param name="numHeroOnTeam">The number specifying this champion's
/// order within its team. For example, if we've drawn 2 other champions
/// already for this hero's team, then this number should be 3 for proper
/// display formatting.</param>
/// <returns>0 for success, 1 for fail.</returns>
HRESULT D3DDisplayManager::DoDrawChampionCooldownsFromCache(LPDIRECT3DDEVICE9 pDevice,
		size_t cacheIndex, BYTE numHeroOnTeam) {
	RECT* pWindowRect = _GetWindowRect(pDevice);
	ObjAIAccessor* pHero = mCachedHeroes[cacheIndex];

	DWORD team = pHero->GetTeam();
	if (team != RIOT_TEAM_ORDER && team != RIOT_TEAM_CHAOS)
		return 1; // invalid team for display purposes

	// Order on the left, chaos on the right - might change this to
	// always being the player team on a particular side sometime
	LONG x, y;
	if (team == RIOT_TEAM_ORDER) {
		x = mDisplayParams.insetFromLeft;
	}
	else {
		// go far enough in from the right to have space for 2 columns plus the inset
		x = (pWindowRect->right - mDisplayParams.insetFromRight -
			(2 * mDisplayParams.backdropWidth) - mDisplayParams.columnSpacing);
	}
	y = ((numHeroOnTeam / 2) * (mDisplayParams.backdropHeight +
		mDisplayParams.rowSpacing)) + mDisplayParams.insetFromTop;

	// two columns of display per team
	if (numHeroOnTeam % 2 == 1)
		x += mDisplayParams.columnSpacing + mDisplayParams.backdropWidth;

	// Different colour for the different teams
	BYTE colorR = (team == RIOT_TEAM_ORDER) ? 0 : 220;
	BYTE colorG = (team == RIOT_TEAM_ORDER) ? 220 : 0;
	BYTE colorB = (team == RIOT_TEAM_ORDER) ? 0 : 0;

	// Draw the backdrop
	gpDisplayManager->DrawRectToScreen(pDevice, (float)x, (float)y,
		(float)mDisplayParams.backdropWidth, (float)mDisplayParams.backdropHeight,
		180, 0, 0, 0);
	y += mDisplayParams.backdropHeight / 10;

	// Draw the champ name
	DrawCooldownTextToScreen(pDevice, x, y, 220, colorR, colorG, colorB,
		pHero->GetSkinName(), FontType::TITLE);
	y += 35;

	// Draw the ability text
	DrawCooldownTextToScreen(pDevice, x, y, 220, colorR, colorG, colorB,
		mCachedCooldownText[cacheIndex]->c_str());
	return 0;
}
/// <summary>Draws a UI to the screen that shows all of the cooldowns for
/// the supplied champion.</summary>
/// <param name="pDevice">The D3D device to do render with.</param>
/// <param name="pHero">The obj_AI_Hero accessor object.</param>
/// <param name="numHeroOnTeam">The number specifying this champion's
/// order within its team. For example, if we've drawn 2 other champions
/// already for this hero's team, then this number should be 3 for proper
/// display formatting.</param>
/// <returns>1 if failed, 0 otherwise.</summary>
HRESULT D3DDisplayManager::DoDrawChampionCooldowns(LPDIRECT3DDEVICE9 pDevice,
	ObjAIAccessor* pHero, BYTE numHeroOnTeam) {
	DWORD team = pHero->GetTeam();
	if (team != RIOT_TEAM_ORDER && team != RIOT_TEAM_CHAOS)
		return 1; // invalid team for display purposes

	RECT* pWindowRect = _GetWindowRect(pDevice);
	float simulationTime = DataAccessor::GetInstance()->GetSimulationTime();

	// we are assuming here that a spell name will not be absolutely massive
	char outputBuf[100];

	// Order on the left, chaos on the right - might change this to
	// always being the player team on the left some time
	LONG x, y;
	if (team == RIOT_TEAM_ORDER) {
		x = mDisplayParams.insetFromLeft;
	}
	else {
		// go far enough in from the right to have space for 2 columns plus the inset
		x = (pWindowRect->right - mDisplayParams.insetFromRight -
			(2 * mDisplayParams.backdropWidth) - mDisplayParams.columnSpacing);
	}
	y = ((numHeroOnTeam / 2) * (mDisplayParams.backdropHeight +
		mDisplayParams.rowSpacing)) + mDisplayParams.insetFromTop;

	// two columns of display per team
	if (numHeroOnTeam % 2 == 1)
		x += mDisplayParams.columnSpacing + mDisplayParams.backdropWidth;

	// Different colour for the different teams
	BYTE colorR = (team == RIOT_TEAM_ORDER) ? 0 : 220;
	BYTE colorG = (team == RIOT_TEAM_ORDER) ? 220 : 0;
	BYTE colorB = (team == RIOT_TEAM_ORDER) ? 0 : 0;

	// Draw the backdrop
	gpDisplayManager->DrawRectToScreen(pDevice, (float)x, (float)y,
		(float)mDisplayParams.backdropWidth, (float)mDisplayParams.backdropHeight,
		180, 0, 0, 0);
	y += mDisplayParams.backdropHeight / 10;

	// Draw the champ name
	DrawCooldownTextToScreen(pDevice, x, y, 220, colorR, colorG, colorB,
		pHero->GetSkinName(), FontType::TITLE);
	y += 35;

	// String to hold our data before drawing
	std::string abilitiesString;

	// Draw their regular abilities
	SpellbookAccessor spellbook = pHero->GetSpellbook();
	for (DWORD i = 0; i < 4; i++) {
		SpellDataInstAccessor spellDataInst = spellbook.GetSpellDataInstForSlot(i);
		float cooldownSecs = spellDataInst.GetCooldownExpires() - simulationTime;

		if (cooldownSecs <= 0)
			sprintf_s(outputBuf, "%c: UP\n", mAbilityKey[i]);
		else
			sprintf_s(outputBuf, "%c: %3.1f sec\n", mAbilityKey[i], cooldownSecs);
		abilitiesString.append(outputBuf);
	}

	// Draw their summoners
	spellbook = pHero->GetSummonerSpellbookByVtable();
	for (DWORD i = 0; i < 2; i++) {
		SpellDataInstAccessor spellDataInst = spellbook.GetSpellDataInstForSlot(i);
		float cooldownSecs = spellDataInst.GetCooldownExpires() - simulationTime;
		const char* summonerSpellName =
			mSummonerSpellMap[
				StringHolder_GetCString(
					spellDataInst.GetSpellData().GetSpellName())
			].c_str();

		if (cooldownSecs <= 0)
			sprintf_s(outputBuf, "%s: UP\n", summonerSpellName);
		else
			sprintf_s(outputBuf, "%s: %3.1f sec\n", summonerSpellName, cooldownSecs);
		abilitiesString.append(outputBuf);
	}

	// Draw the text
	DrawCooldownTextToScreen(pDevice, x, y, 220, colorR, colorG, colorB, abilitiesString.c_str());
	return 0;
}