2008-10-16 22:00:54 +00:00
|
|
|
float inmenu;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ME_KEYDOWN,
|
|
|
|
ME_KEYUP,
|
|
|
|
ME_MOUSEMOVE,
|
|
|
|
ME_DRAW = 200
|
|
|
|
};
|
|
|
|
|
2009-04-14 21:39:15 +00:00
|
|
|
nonstatic void(void(float, float, float, float) fnc) Menu_Activate =
|
2008-10-16 22:00:54 +00:00
|
|
|
{
|
|
|
|
inmenu = TRUE;
|
|
|
|
MenuEventFunc = fnc;
|
|
|
|
};
|
|
|
|
|
2009-04-14 21:39:15 +00:00
|
|
|
noref vector mousepos; //z is not set
|
2011-05-20 04:10:59 +00:00
|
|
|
float (float event, float parama, float paramb) Menu_InputEvent =
|
2008-10-16 22:00:54 +00:00
|
|
|
{
|
|
|
|
if (!inmenu)
|
|
|
|
return false; //let the engine do what it wants.
|
|
|
|
|
|
|
|
if (event == INPUT_MOUSEMOVE)
|
|
|
|
{
|
|
|
|
mousepos_x += parama;
|
|
|
|
if (mousepos_x < 0)
|
|
|
|
mousepos_x = 0;
|
|
|
|
if (mousepos_x >= 640)
|
|
|
|
mousepos_x = 640;
|
|
|
|
mousepos_y += paramb;
|
|
|
|
if (mousepos_y < 0)
|
|
|
|
mousepos_y = 0;
|
|
|
|
if (mousepos_y >= 480)
|
|
|
|
mousepos_y = 480;
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuEventFunc(event, parama, mousepos_x, mousepos_y);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2009-04-14 21:39:15 +00:00
|
|
|
nonstatic void() Menu_Think =
|
2008-10-16 22:00:54 +00:00
|
|
|
{
|
|
|
|
if (!inmenu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
MenuEventFunc(ME_MOUSEMOVE, 0, mousepos_x, mousepos_y);
|
|
|
|
|
|
|
|
MenuEventFunc(ME_DRAW, 0, mousepos_x, mousepos_y);
|
|
|
|
};
|
|
|
|
|
|
|
|
//We don't have a main menu for the csqc yet, so just pop it instead, so submenus can close properly.
|
2009-04-14 21:39:15 +00:00
|
|
|
nonstatic void() Menu_Main =
|
2008-10-16 22:00:54 +00:00
|
|
|
{
|
|
|
|
inmenu = FALSE;
|
|
|
|
};
|