Complate code, by myself.
bool gBuffCollapsed = false;
DWORD LastToggleTime = 0;
bool IsMousePressed()
{
static bool previousLButtonState = false;
bool currentLButtonState = (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0;
bool result = currentLButtonState && !previousLButtonState;
previousLButtonState = currentLButtonState;
return result;
}
void SEASON3B::CNewUIBuffWindow::RenderBuffStatus(BUFF_RENDER renderstate)
{
OBJECT* pHeroObject = &Hero->Object;
float frameX = 0.0f;
float frameY = GetWindowsY(640) - 110;
float x = 0.0f, y = 0.0f;
int buffwidthcount = 0;
std::list<eBuffState> buffstate;
BuffSort(buffstate);
int totalBuffs = buffstate.size();
int visibleBuffs = totalBuffs;
std::list<eBuffState>::iterator iter;
int IndexTime = 0;
float spacingX = gBuffCollapsed ? 10.0f : (BUFF_IMG_WIDTH + BUFF_IMG_SPACE);
for (iter = buffstate.begin(); iter != buffstate.end(); )
{
if (IndexTime >= visibleBuffs)
break;
std::list<eBuffState>::iterator tempiter = iter;
++iter;
eBuffState buff = (*tempiter);
x = m_Pos.x + (buffwidthcount * spacingX) + frameX;
y = m_Pos.y + frameY;
if (renderstate == BUFF_RENDER_ICON)
{
RenderBuffIcon(buff, x, y, BUFF_IMG_WIDTH, BUFF_IMG_HEIGHT);
const BuffInfo& bi = TheBuffInfo().GetBuffinfo(buff);
if (bi.s_BuffIndex != 0)
{
if (buff != static_cast<eBuffState>(81))
{
DWORD curTime = TheBuffTimeControl().GetBuffTime(static_cast<DWORD>(buff));
DWORD maxTime = TheBuffTimeControl().GetBuffMaxTime(buff, curTime);
int pBuffHp = 100;
if (maxTime > 0 && curTime > 0) {
pBuffHp = (curTime * 100) / maxTime;
}
EnableAlphaTest();
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
RenderColor(
x,
y + BUFF_IMG_HEIGHT,
(BUFF_IMG_WIDTH * pBuffHp / 100.0f),
2.0f, 0.0f, 0);
::EnableAlphaTest();
::glColor4f(1, 1, 1, 1);
}
}
}
else if (renderstate == BUFF_RENDER_TOOLTIP)
{
if (!gBuffCollapsed && SEASON3B::CheckMouseIn(x, y, BUFF_IMG_WIDTH, BUFF_IMG_HEIGHT))
{
float fTooltip_x = x + (BUFF_IMG_WIDTH / 2);
float fTooltip_y = y + (BUFF_IMG_HEIGHT / 2) - 50;
eBuffClass buffclass = g_IsBuffClass(buff);
RenderBuffTooltip(buffclass, buff, fTooltip_x, fTooltip_y);//, IndexTime);
}
}
IndexTime++;
++buffwidthcount;
}
if (totalBuffs > 1)
{
float arrowX = x + 7;
float arrowY = y - 5;
if (gBuffCollapsed)
{
SEASON3B::RenderImage(IMAGE_BUFF_arrow_1, arrowX, arrowY, 10, 10, 0.0f, 0.0f, 0.6f, 0.6f);
}
else
{
SEASON3B::RenderImage(IMAGE_BUFF_arrow, arrowX, arrowY, 10, 10, 0.0f, 0.0f, 0.6f, 0.6f);
}
if (SEASON3B::CheckMouseIn(arrowX, arrowY, 10, 10))
{
if (GetTickCount() - LastToggleTime > 500)
{
gBuffCollapsed = !gBuffCollapsed;
LastToggleTime = GetTickCount();
}
}
}
}
void SEASON3B::CNewUIBuffWindow::LoadImages()
{
LoadBitmap("Interface\\newui_statusicon.jpg", IMAGE_BUFF_STATUS, GL_LINEAR);
LoadBitmap("Interface\\newui_statusicon2.jpg", IMAGE_BUFF_STATUS2, GL_LINEAR);
LoadBitmap("Interface\\Custom\\Pegasus_BUFFICON.tga", IMAGE_BUFF_arrow, GL_LINEAR);
LoadBitmap("Interface\\Custom\\Pegasus_BUFFICON_01.tga", IMAGE_BUFF_arrow_1, GL_LINEAR);
}
void SEASON3B::CNewUIBuffWindow::UnloadImages()
{
DeleteBitmap(IMAGE_BUFF_STATUS2);
DeleteBitmap(IMAGE_BUFF_STATUS);
DeleteBitmap(IMAGE_BUFF_arrow);
DeleteBitmap(IMAGE_BUFF_arrow_1);
}