#define UI_MOUSEBUTTONS 3
-static int ui_alive, ui_active;
-static float ui_mouse_x, ui_mouse_y;
-static int ui_mousebutton[UI_MOUSEBUTTONS], ui_mouseclick;
-static int ui_keyui, ui_keyitem;
-static ui_item_t *ui_keyrealitem;
+static int ui_alive, ui_active;
+static float ui_mouse_x, ui_mouse_y;
+static int ui_mousebutton[UI_MOUSEBUTTONS], ui_mouseclick;
+static int ui_keyui, ui_keyitem;
+static ui_item_t *ui_keyrealitem;
static ui_t *ui_list[MAX_UI_COUNT];
-//static qpic_t *ui_mousepointer;
-static rtexture_t *ui_mousepointertexture;
-
-static byte pointerimage[256] =
-{
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x02, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x02, 0x06, 0x05, 0x05, 0x05, 0x04, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x02, 0x06, 0x05, 0x05, 0x04, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x02, 0x06, 0x05, 0x04, 0x05, 0x06, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x02, 0x06, 0x04, 0x01, 0x04, 0x05, 0x06, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x02, 0x05, 0x01, 0xFF, 0x01, 0x04, 0x05, 0x06, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x02, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0x04, 0x05, 0x06, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x04, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-};
-
-void ui_start(void)
+static void ui_start(void)
{
-// ui_mousepointer = Draw_CachePic("ui/mousepointer.lmp");
- ui_mousepointertexture = R_LoadTexture("mousepointer", 16, 16, pointerimage, TEXF_ALPHA | TEXF_PRECACHE);
ui_mouse_x = vid.conwidth * 0.5;
ui_mouse_y = vid.conheight * 0.5;
ui_alive = true;
}
-void ui_shutdown(void)
+static void ui_shutdown(void)
{
-// ui_mousepointer = NULL;
- ui_mousepointertexture = NULL;
ui_alive = false;
}
-void ui_newmap(void)
+static void ui_newmap(void)
{
}
+static mempool_t *uimempool;
+
void ui_init(void)
{
+ uimempool = Mem_AllocPool("UI");
+
Cvar_RegisterVariable(&ui_showname);
R_RegisterModule("UI", ui_start, ui_shutdown, ui_newmap);
}
ui_t *ui_create(void)
{
ui_t *ui;
- ui = qmalloc(sizeof(*ui));
+ ui = Mem_Alloc(uimempool, sizeof(*ui));
if (ui == NULL)
Sys_Error("ui_create: unable to allocate memory for new ui\n");
memset(ui, 0, sizeof(*ui));
void ui_free(ui_t *ui)
{
if (ui)
- qfree(ui);
+ Mem_Free(ui);
}
void ui_clear(ui_t *ui)
void ui_item
(
ui_t *ui, char *basename, int number,
- float x, float y, qpic_t *pic, char *string,
+ float x, float y, char *picname, char *string,
float left, float top, float width, float height,
void(*leftkey)(void *nativedata1, void *nativedata2, float data1, float data2),
void(*rightkey)(void *nativedata1, void *nativedata2, float data1, float data2),
memset(it, 0, sizeof(ui_item_t));
strncpy(it->name, itemname, 32);
it->flags = 0;
- if (pic || string)
+ if (picname || string)
{
it->flags |= ITEM_DRAWABLE;
- it->draw_pic = pic;
+ it->draw_picname = picname;
it->draw_string = string;
it->draw_x = x;
it->draw_y = y;
}
#define UI_QUEUE_SIZE 256
-static byte ui_keyqueue[UI_QUEUE_SIZE];
+static qbyte ui_keyqueue[UI_QUEUE_SIZE];
static int ui_keyqueuepos = 0;
void ui_leftkeyupdate(int pressed)
for (i = 0, it = ui->items;i < ui->item_count;i++, it++)
if (it->flags & ITEM_DRAWABLE)
{
- if (it->draw_pic)
- Draw_Pic(it->draw_x, it->draw_y, it->draw_pic);
+ if (it->draw_picname)
+ DrawQ_Pic(it->draw_x, it->draw_y, it->draw_picname, 0, 0, 1, 1, 1, 1, 0);
if (it->draw_string)
- Draw_String(it->draw_x, it->draw_y, it->draw_string, 9999);
+ DrawQ_String(it->draw_x, it->draw_y, it->draw_string, 0, 8, 8, 1, 1, 1, 1, 0);
}
if ((it = ui_hititem(ui_mouse_x, ui_mouse_y)))
{
- if (it->draw_pic)
- Draw_AdditivePic(it->draw_x, it->draw_y, it->draw_pic);
+ if (it->draw_picname)
+ DrawQ_Pic(it->draw_x, it->draw_y, it->draw_picname, 0, 0, 1, 1, 1, 1, DRAWFLAG_ADDITIVE);
if (it->draw_string)
- Draw_AdditiveString(it->draw_x, it->draw_y, it->draw_string, 9999);
- if (ui_showname.value)
- Draw_String(ui_mouse_x, ui_mouse_y + 16, it->name, 9999);
+ DrawQ_String(it->draw_x, it->draw_y, it->draw_string, 0, 8, 8, 1, 1, 1, 1, DRAWFLAG_ADDITIVE);
+ if (ui_showname.integer)
+ DrawQ_String(ui_mouse_x, ui_mouse_y + 16, it->name, 0, 8, 8, 1, 1, 1, 1, 0);
}
it = ui_keyrealitem;
- if (it->draw_pic)
- Draw_AdditivePic(it->draw_x, it->draw_y, it->draw_pic);
+ if (it->draw_picname)
+ DrawQ_Pic(it->draw_x, it->draw_y, it->draw_picname, 0, 0, 1, 1, 1, 1, DRAWFLAG_ADDITIVE);
if (it->draw_string)
- Draw_AdditiveString(it->draw_x, it->draw_y, it->draw_string, 9999);
+ DrawQ_String(it->draw_x, it->draw_y, it->draw_string, 0, 8, 8, 1, 1, 1, 1, DRAWFLAG_ADDITIVE);
-// Draw_Pic(ui_mouse_x, ui_mouse_y, ui_mousepointer);
- Draw_GenericPic(ui_mousepointertexture, 1, 1, 1, 1, ui_mouse_x, ui_mouse_y, 16, 16);
+ DrawQ_Pic(ui_mouse_x, ui_mouse_y, "ui/mousepointer.tga", 0, 0, 1, 1, 1, 1, 0);
}
}
+