#include "cRender.h"
#include "stdafx.h"
cRender::cRender(void)
{
show = true;
}
int Button_Mass[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
Button_Number = 0,
Button_Max = 0,
LButtonState = 0;
void cRender::Draw_Text(int x, int y, DWORD color, const char* text, DWORD ST) {
RECT rect, rect2;
SetRect( &rect, x, y, x, y );
SetRect( &rect2, x - 0.1, y + 0.2, x - 0.1, y + 0.1 );
pFont->DrawTextA(NULL,text,-1,&rect2, ST, 0xff000000 );
pFont->DrawTextA(NULL,text,-1,&rect, ST, color );
}
void cRender::Draw_Box(int x, int y, int w, int h, D3DCOLOR Color, IDirect3DDevice9* mDevice)
{
D3DRECT rec;
rec.x1 = x;
rec.x2 = x + w;
rec.y1 = y;
rec.y2 = y + h;
mDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
mDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, D3DPT_TRIANGLESTRIP);
mDevice->Clear(1, &rec, D3DCLEAR_TARGET, Color, 1, 1);
}
void cRender::Draw_Border(int x, int y, int w, int h, int s, D3DCOLOR Color, IDirect3DDevice9* mDevice)
{
Draw_Box(x, y, s, h, Color, mDevice);
Draw_Box(x, y + h, w, s, Color, mDevice);
Draw_Box(x, y, w, s, Color, mDevice);
Draw_Box(x + w, y, s, h + s, Color, mDevice);
}
BOOL cRender::IsInBox(int x, int y, int w, int h)
{
POINT MousePosition;
GetCursorPos(&MousePosition);
ScreenToClient(GetForegroundWindow(), &MousePosition);
return(MousePosition.x >= x && MousePosition.x <= x + w && MousePosition.y >= y && MousePosition.y <= y + h);
}
static struct _Keys
{
bool bPressed;
DWORD dwStartTime;
}kPressingKeys[256];
BOOL cRender::State_Key(int Key, DWORD dwTimeOut)
{
if (HIWORD(GetKeyState(Key)))
{
if (!kPressingKeys[Key].bPressed || (kPressingKeys[Key].dwStartTime && (kPressingKeys[Key].dwStartTime + dwTimeOut) <= GetTickCount()))
{
kPressingKeys[Key].bPressed = TRUE;
if (dwTimeOut > NULL)
kPressingKeys[Key].dwStartTime = GetTickCount();
return TRUE;
}
}
else
kPressingKeys[Key].bPressed = FALSE;
return FALSE;
}
void cRender::Draw_Menu_But(stMenu *pos_Menu, const char* text, IDirect3DDevice9* pDevice)
{
int x = (*pos_Menu).x,
y = (*pos_Menu).y,
h = 22,
w = 101;
D3DCOLOR Bord_text = 0xff00ffff;
D3DCOLOR text_Activ = 0xff00ffff;
if (IsInBox(x, y, w, h))
{
//если наведен курсор
Bord_text = 0xFF8FBC8B;
if (!GetAsyncKeyState(VK_LBUTTON))
LButtonState = 0;
else if (GetAsyncKeyState(VK_LBUTTON))
if (LButtonState == 0){
//if (Button_Mass[Button_Number] != 1)
Button_Mass[Button_Number] = !Button_Mass[Button_Number];
LButtonState = 1;
}
}
Draw_Box(x, y, w, h, 0xFF8B0000, pDevice);
Draw_Border(x, y, w, h, 1, Bord_text, pDevice);
if (Button_Mass[Button_Number])
{
//Если активна
text_Activ = 0xFF9400D3;
//for (int i = 0; i < 20; i++)
//if (i != Button_Number)
//Button_Mass[i] = 0;
}
Draw_Text(x + (w / 2), y + 3, text_Activ, text, C_Text);
Button_Number = Button_Number + 1;
if (Button_Max < Button_Number)
//Button_Max = Button_Number;
(*pos_Menu).y = y + 24;
}
void cRender::Init_PosMenu(int x, int y, DWORD KEY, stMenu* pos_Menu, IDirect3DDevice9* m_pD3Ddev)
{
(*pos_Menu).x = x;
(*pos_Menu).y = y;
if (!pFont)
pFont->OnLostDevice();
else
{
if (State_Key(KEY, 3000))show = !show;
if (show)SHOW_MENU(m_pD3Ddev);
Draw_Text(3, 5, D3DCOLOR_ARGB(255, 000, 255, 000), "Cheat created\n by Alien ", L_Text);
pFont->OnLostDevice();
pFont->OnResetDevice();
}
}