Example #1
0
bool CharacterDisplay::SetRenderTarget(HRENDERTARGET hRenderTarget)
{

	HATTRIBUTE hAttrib = DATABASE_CATEGORY( CharacterDisplayDB ).GetAttribute( m_hDisplayRecord, "MaterialParameter" );
	const char* pszParam = DATABASE_CATEGORY( CharacterDisplayDB ).GetString( hAttrib,0,szEmissiveParam);

	m_hRenderTarget = hRenderTarget;
	if (!SetMaterial())
	{
		ReleaseRenderTarget();
		return false;
	}

	//and now install it on the associated material
	LTRESULT lr = g_pLTClient->GetRenderer()->SetInstanceParamRenderTarget( m_hMaterial, pszParam, m_hRenderTarget);

	m_bRenderTargetBound = (lr == LT_OK);
	if (!m_bRenderTargetBound)
	{
		return false;
	}


	return true;

}
Example #2
0
void SHotKeyCtrl::UpdateCaret()
{
    SStringT str=FormatHotkey();
    IRenderTarget *pRT=GetRenderTarget(NULL,OLEDC_NODRAW);
    CAutoRefPtr<IFont> oldFont;
    pRT->SelectObject(m_curFont,(IRenderObj**)&oldFont);
    SIZE szTxt;
    pRT->MeasureText(str,str.GetLength(),&szTxt);
    pRT->SelectObject(oldFont);
    ReleaseRenderTarget(pRT);
    
    CRect rcClient;
    GetClientRect(&rcClient);
    GetContainer()->SwndSetCaretPos(rcClient.left+EDIT_INSET+szTxt.cx,rcClient.top+(rcClient.Height()-szTxt.cy)/2);
}
Example #3
0
void SListBoxEx::RedrawItem(int iItem)
{
    if(!IsVisible(TRUE)) return;
    CRect rcClient;
    GetClientRect(&rcClient);
    CRect rcItem=GetItemRect(iItem);
    CRect rcInter;
    rcInter.IntersectRect(&rcClient,&rcItem);
    if(rcInter.IsRectEmpty()) return;

    IRenderTarget * pRT=GetRenderTarget(&rcItem,OLEDC_PAINTBKGND);

    SSendMessage(WM_ERASEBKGND,(WPARAM)pRT);
    DrawItem(pRT,rcItem,iItem);

    ReleaseRenderTarget(pRT);
}
Example #4
0
void SHotKeyCtrl::OnSetFocus()
{
    IRenderTarget *pRT=GetRenderTarget(NULL,OLEDC_NODRAW);
    CAutoRefPtr<IFont> oldFont;
    pRT->SelectObject(m_curFont,(IRenderObj**)&oldFont);
    SIZE szTxt;
    pRT->MeasureText(_T("A"),1,&szTxt);
    pRT->SelectObject(oldFont);
    ReleaseRenderTarget(pRT);
    GetContainer()->SwndCreateCaret(NULL,1,szTxt.cy);

    CRect rcClient;
    GetClientRect(&rcClient);
    OnSetCaretValidateRect(&rcClient);

    UpdateCaret();
    GetContainer()->SwndShowCaret(TRUE);
}
Example #5
0
void SListBox::RedrawItem(int iItem)
{
    if(!IsVisible(TRUE)) return;

    CRect rcClient;
    GetClientRect(&rcClient);
    int iFirstVisible = GetTopIndex();
    int nPageItems=(rcClient.Height()+m_nItemHei-1)/m_nItemHei+1;

    if(iItem>=iFirstVisible && iItem<GetCount() && iItem<iFirstVisible+nPageItems)
    {
        CRect rcItem(0,0,rcClient.Width(),m_nItemHei);
        rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y);
        rcItem.OffsetRect(rcClient.TopLeft());
        IRenderTarget *pRT=GetRenderTarget(&rcItem,OLEDC_PAINTBKGND);

        SSendMessage(WM_ERASEBKGND,(WPARAM)(HDC)pRT);
        DrawItem(pRT,rcItem,iItem);

        ReleaseRenderTarget(pRT);
    }
}
Example #6
0
bool CharacterDisplay::Init(CCharacterFX* pParent, HRECORD hDisplay, const LTVector2n& sz, ClientDisplayData* pData )
{
	//if it's the same we shouldn't have to do anything...
	if ( m_pParent == pParent && 
		 m_hDisplayRecord == hDisplay &&
		 m_hRenderTarget == pData->hNameTarget &&
		 m_vSize.x == (float)sz.x &&
		 m_vSize.y == (float)sz.y &&
		 m_hMaterial == pData->hNameMaterial
		)
	{
		return true;
	}
	m_pParent = pParent;
	m_vSize = LTVector2((float)sz.x,(float)sz.y);

	if (!m_pParent || !m_pParent->GetModel())
	{
		return false;
	}


	m_hDisplayRecord = hDisplay;
	if (!m_hDisplayRecord)
	{
		LTERROR( "Invalid CharacterDisplay" );
		return false;
	}

	// Get the layout record from the localized database.
	m_hLayoutRecord = DATABASE_CATEGORY( CharacterDisplayDB ).GetRecordLinkToLocalizedDB( g_pLTDatabase->GetAttribute( m_hDisplayRecord, "Layout" ),
		0, DATABASE_CATEGORY( CharacterDisplayLayoutDB ).GetCategory( ));
	if( !m_hLayoutRecord )
	{
		LTERROR_PARAM1( "Invalid CharacterDisplayLayout %s", g_pLTDatabase->GetRecordName( m_hDisplayRecord ));
		return false;
	}

	ReleaseRenderTarget();

	char const* pszMaterial = DATABASE_CATEGORY( CharacterDisplayDB ).GETRECORDATTRIB( m_hDisplayRecord, Material );
	//check to see if we're using the same base material
	if (pData->hNameMaterial && !LTStrIEquals(pData->sNameMaterialFile.c_str(),pszMaterial) )
	{
		g_pLTClient->GetRenderer()->ReleaseMaterialInstance(pData->hNameMaterial);
		pData->hNameMaterial = NULL;
	}

	//hNameMaterial is a reference to the material stored in a client info record, if this is null
	// we need to clone a material for this client to use
	if (!pData->hNameMaterial)
	{
		HMATERIAL hBaseMat = g_pLTClient->GetRenderer()->CreateMaterialInstance( pszMaterial );
		if (!hBaseMat) return false;
		
		pData->hNameMaterial = g_pLTClient->GetRenderer()->CloneMaterialInstance(hBaseMat);
		pData->sNameMaterialFile = pszMaterial;
		g_pLTClient->GetRenderer()->ReleaseMaterialInstance(hBaseMat);

	}
	if (m_hMaterial != pData->hNameMaterial)
	{
		if (m_hMaterial)
		{
			g_pLTClient->GetRenderer()->ReleaseMaterialInstance(m_hMaterial);
		}
		m_hMaterial = pData->hNameMaterial;

		g_pLTClient->GetRenderer()->AddRefMaterialInstance(m_hMaterial);
	}
	
	if (m_hMaterial == NULL) 
	{
		return false;
	}

	if (!SetRenderTarget(pData->hNameTarget))
	{
		return false;
	}

	LTVector2 vPos = DATABASE_CATEGORY( CharacterDisplayLayoutDB ).GETRECORDATTRIB( m_hLayoutRecord, TextOffset );
	m_Text.SetPos(LTVector2n(uint32(vPos.x),uint32(vPos.y)));
	m_Text.SetAlignment(kCenter);
	m_Text.SetDropShadow(1);

	for (uint8 n = 0; n < 3; ++n)
	{
		m_nTextSize[n] = DATABASE_CATEGORY( CharacterDisplayLayoutDB ).GETRECORDATTRIBINDEX( m_hLayoutRecord, TextSize, n);
	}

	HRECORD hFont = DATABASE_CATEGORY( CharacterDisplayLayoutDB ).GETRECORDATTRIB( m_hLayoutRecord, Font );
	char const* pszFont = DATABASE_CATEGORY( CharacterDisplayLayoutDB ).GetString( hFont, "Face" );
	CFontInfo textFont(pszFont,m_nTextSize[2]);
	m_Text.SetFont(textFont);
	m_Text.SetColor(DATABASE_CATEGORY( CharacterDisplayDB ).GETRECORDATTRIB( m_hDisplayRecord, TextColor));

	m_cTextBackColor = DATABASE_CATEGORY( CharacterDisplayDB ).GETRECORDATTRIB( m_hDisplayRecord, TextBackColor);
	LTVector4 vTextBackRect = DATABASE_CATEGORY( CharacterDisplayDB ).GETRECORDATTRIB( m_hDisplayRecord, TextBackRect );
	m_rTextBackRect.Init(( int32 )vTextBackRect.x, ( int32 )vTextBackRect.y, ( int32 )vTextBackRect.z, ( int32 )vTextBackRect.w );

	return true;
}
Example #7
0
void CharacterDisplay::Term( )
{
	//this will release our texture as well
	ReleaseRenderTarget();

}