#include "StdAfx.h"
#ifdef __DROP_LOG
#include "WndDropLog.h"
static CTextureMng m_textureMng;
CWndDropLog::CWndDropLog() :
m_dwLastAddGold( 0 ),
m_qwTotalReapGold( 0 ),
m_pGoldTexture( NULL ),
m_pHead( NULL ),
m_pTail( NULL ),
m_pFreeList( NULL ),
m_pAddList( NULL ),
m_dwNextProcessAdd( 0 ),
m_nSizeofAddList( 0 )
{
*m_szTotalReapGold = 0;
}
CWndDropLog::~CWndDropLog()
{
Clear();
t_dropLog ptr;
while( m_pFreeList )
{
ptr = m_pFreeList;
m_pFreeList = m_pFreeList->next;
delete( ptr );
}
}
void CWndDropLog::InitDeviceObjects()
{
m_pGoldTexture = m_textureMng.AddTexture( g_Neuz.m_pd3dDevice, MakePath( DIR_ITEM, "itm_GolGolSeed.dds" ), 0xffff00ff );
}
void CWndDropLog:

eleteDeviceObjects()
{
Clear();
}
void CWndDropLog::Process()
{
DWORD dwTimeLeft;
DWORD dwTick = GetTickCount();
t_dropLog ptr;
if( ( dwTick >= m_dwNextProcessAdd ) && ( m_pAddList ) )
{
ptr = m_pAddList;
m_pAddList = m_pAddList->next;
--m_nSizeofAddList;
ptr->dwRemoveTime = dwTick + REMOVE_TIMEOUT;
ptr->prev = NULL;
ptr->next = m_pHead;
if( m_pHead )
m_pHead->prev = ptr;
if( m_pTail == NULL )
m_pTail = ptr;
m_pHead = ptr;
m_dwNextProcessAdd = dwTick + (DWORD)max( 50.0f, floor( 50.0f / ( 0.1f * m_nSizeofAddList ) ) );
}
ptr = m_pHead;
while( ptr )
{
if( dwTick >= ptr->dwRemoveTime )
{
t_dropLog prev = ptr->prev;
t_dropLog next = ptr->next;
if( prev )
prev->next = next;
if( next )
next->prev = prev;
if( m_pHead == ptr )
m_pHead = m_pHead->next;
if( m_pTail == ptr )
m_pTail = m_pTail->prev;
next = ptr->next;
ptr->next = m_pFreeList;
m_pFreeList = ptr;
ptr = next;
}
else
{
dwTimeLeft = ptr->dwRemoveTime - dwTick;
if( dwTimeLeft < 1000 )
{
ptr->dwAlpha = (DWORD)ceil( 255.0 * ( (DOUBLE)dwTimeLeft * 0.001 ) );
ptr->dwNameColor = D3DCOLOR_ARGB(
(BYTE)ptr->dwAlpha,
BYTE( ptr->dwNameColor >> 16 ),
BYTE( ptr->dwNameColor >> 8 ),
BYTE( ptr->dwNameColor ) );
}
else if( REMOVE_TIMEOUT - dwTimeLeft <= 500 )
{
ptr->dwAlpha = (DWORD)ceil( 255.0 * ( DOUBLE( REMOVE_TIMEOUT - dwTimeLeft ) * 0.002 ) );
ptr->dwNameColor = D3DCOLOR_ARGB(
(BYTE)ptr->dwAlpha,
BYTE( ptr->dwNameColor >> 16 ),
BYTE( ptr->dwNameColor >> 8 ),
BYTE( ptr->dwNameColor ) );
}
ptr = ptr->next;
}
}
if( ( m_qwTotalReapGold > 0 ) && ( dwTick - m_dwLastAddGold > GOLD_RESET ) )
m_qwTotalReapGold = 0;
}
void CWndDropLog::Render( C2DRender* p2DRender, const int &nWindowHeight )
{
CPoint pt;
DWORD dwTick = GetTickCount();
DWORD dwLeft;
int i = 0;
if( ( dwLeft = ( dwTick - m_dwLastAddGold ) ) < GOLD_FADEOUT + 1000 )
{
DWORD dwAlpha = 255;
if( dwLeft >= GOLD_FADEOUT )
{
dwLeft -= GOLD_FADEOUT;
DOUBLE alpha = 255.0 - ceil( 255.0 * ( (DOUBLE)dwLeft * 0.001 ) );
if( alpha < 0.0 )
dwAlpha = 0;
else if( alpha > 255.0 )
dwAlpha = 255;
else
dwAlpha = (DWORD)alpha;
}
else
{
dwLeft = min( 250, dwLeft );
dwAlpha = (DWORD)ceil( 255.0 * ( (DOUBLE)dwLeft / 250.0 ) );
}
pt.SetPoint( 5, -100 + nWindowHeight / 2 );
p2DRender->RenderTexture( pt, m_pGoldTexture, dwAlpha, 0.75f, 0.75f );
p2DRender->TextOut( 37, -100 + nWindowHeight / 2 + 7, m_szTotalReapGold, D3DCOLOR_ARGB( dwAlpha, 255, 255, 0 ) );
}
t_dropLog ptr = m_pHead;
while( ( ptr ) && ( i++ < 10 ) )
{
pt.SetPoint( 5, -100 + nWindowHeight / 2 + ( 27 * i ) );
p2DRender->RenderTexture( pt, ptr->pTexture, ptr->dwAlpha, 0.75f, 0.75f );
p2DRender->TextOut( 37, -100 + nWindowHeight / 2 + ( 27 * i ) + 7, ptr->szName, ptr->dwNameColor );
ptr = ptr->next;
}
}
void CWndDropLog::Add( const ItemProp* pProp )
{
if( pProp )
{
DWORD dwColor = D3DCOLOR_XRGB( 255, 255, 255 );
if ( pProp->dwItemKind1 == IK1_WEAPON )
{
if ( pProp->dwReferStat1 == WEAPON_UNIQUE )
dwColor = D3DCOLOR_XRGB( 153, 0, 204 );
else if ( pProp->dwReferStat1 == WEAPON_ULTIMATE )
dwColor = D3DCOLOR_XRGB( 255, 204, 0 );
else
dwColor = D3DCOLOR_XRGB( 255, 155, 137 );
}
if ( pProp->dwItemKind1 == IK1_ARMOR &&
( pProp->dwItemKind2 == IK2_ARMOR ||
pProp->dwItemKind2 == IK2_ARMORETC ) )
dwColor = D3DCOLOR_XRGB( 0, 204, 102 );
if ( pProp->dwItemKind2 == IK2_JEWELRY )
dwColor = D3DCOLOR_XRGB( 51, 204, 255 );
if ( pProp->dwItemKind2 == IK2_CLOTH ||
pProp->dwItemKind2 == IK2_CLOTHETC )
dwColor = D3DCOLOR_XRGB( 153, 84, 32 );
if( pProp->dwItemKind3 == IK3_SOCKETCARD2 ||
pProp->dwItemKind3 == IK3_SOCKETCARD )
dwColor = D3DCOLOR_XRGB( 255, 149, 79 );
if( pProp->dwItemKind3 == IK3_VIS )
dwColor = D3DCOLOR_XRGB( 255, 175, 229 );
if( pProp->dwItemKind2 == IK2_GEM ||
pProp->dwItemKind3 == IK3_GEM )
dwColor = D3DCOLOR_XRGB( 107, 102, 255 );
if( pProp->dwItemKind2 == IK2_FOOD ||
pProp->dwItemKind2 == IK2_POTION ||
pProp->dwItemKind2 == IK2_REFRESHER ||
pProp->dwItemKind3 == IK3_DRINK ||
pProp->dwItemKind3 == IK3_COOKING ||
pProp->dwItemKind3 == IK3_REFRESHER )
dwColor = D3DCOLOR_XRGB( 159, 255, 81 );
if( pProp->dwID == II_GEN_MAT_ORICHALCUM01 ||
pProp->dwID == II_GEN_MAT_ORICHALCUM02 ||
pProp->dwID == II_GEN_MAT_ORICHALCUM01_1 ||
pProp->dwID == II_SYS_SYS_SCR_SCRAPORICHALCUM ||
pProp->dwID == II_GEN_MAT_MOONSTONE ||
pProp->dwID == II_GEN_MAT_MOONSTONE_1 ||
pProp->dwID == II_SYS_SYS_SCR_SCRAPMOONSTONE )
dwColor = D3DCOLOR_XRGB( 192, 165, 255 );
t_dropLog ptr = NULL;
if( m_pFreeList )
{
ptr = m_pFreeList;
m_pFreeList = m_pFreeList->next;
}
else
ptr = new t_dropLogNew;
ptr->dwAlpha = 0;
ptr->dwNameColor = dwColor;
if( pProp->szName )
std::strcpy( ptr->szName, pProp->szName );
ptr->pTexture = CWndBase::m_textureMng.AddTexture( g_Neuz.m_pd3dDevice, MakePath( DIR_ITEM, pProp->szIcon ), 0xffff00ff );
ptr->prev = NULL;
ptr->next = m_pAddList;
m_pAddList = ptr;
++m_nSizeofAddList;
}
}
void CWndDropLog::AddGold( unsigned int nGold )
{
char szPlus[128];
std::memset( szPlus, 0, sizeof( szPlus ) );
if ( nGold == 0)
m_qwTotalReapGold = 0;
m_qwTotalReapGold += nGold;
sprintf( szPlus, "%u", m_qwTotalReapGold );
if( szPlus )
std::strcpy( m_szTotalReapGold, GetNumberFormatEx( szPlus ) );
m_dwLastAddGold = GetTickCount();
}
void CWndDropLog::Clear()
{
t_dropLog ptr;
while( m_pHead )
{
ptr = m_pHead;
m_pHead = m_pHead->next;
ptr->next = m_pFreeList;
m_pFreeList = ptr;
}
while( m_pAddList )
{
ptr = m_pAddList;
m_pAddList = m_pAddList->next;
ptr->next = m_pFreeList;
m_pFreeList = ptr;
}
m_nSizeofAddList = 0;
}
#endif //__DROP_LOG