function DrawButton(var x, var y, var alpha, STRING *caption, STRING *functionName)
{
var w = 187;
var h = 40;
static int wasPressed = 0;
draw_textmode("Arial", 1, 18, alpha);
if(mouse_pos.x >= x && mouse_pos.x <= x+w && mouse_pos.y >= y && mouse_pos.y <= y+h)
{
if(mouse_left)
{
draw_quad(button_bmap, vector(x, y, 0), nullvector, vector(w, h, 0), NULL, COLOR_YELLOW_DARK, alpha, 0);
draw_text(caption, x + (w / 2) - (str_width(caption, arialMenu_font) / 2) + 2, y + (h / 2) - 6, COLOR_YELLOW_DARK);
if(wasPressed == 0)
{
pButtonCallback = engine_getscript(_chr(functionName));
if(ValidPointer(pButtonCallback))
{
pButtonCallback();
}
}
wasPressed = 1;
}
else
{
wasPressed = 0;
draw_quad(button_bmap, vector(x, y, 0), nullvector, vector(w, h, 0), NULL, COLOR_YELLOW, alpha, 0);
draw_text(caption, x + (w / 2) - (str_width(caption, arialMenu_font) / 2), y + (h / 2) - 8, COLOR_YELLOW);
}
}
else
{
draw_quad(button_bmap, vector(x, y, 0), nullvector, vector(w, h, 0), NULL, COLOR_WHITE, alpha, 0);
draw_text(caption, x + (w / 2) - (str_width(caption, arialMenu_font) / 2), y + (h / 2) - 8, COLOR_WHITE);
}
draw_textmode("Arial", 0, 16, 100);
}
void ExitFunc()
{
error("LOL");
}
DrawButton(50, 50, 100, "Quit the Game", "ExitFunc"); //HowTo