]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - ui.c
rewrote memory system entirely (hunk, cache, and zone are gone, memory pools replaced...
[xonotic/darkplaces.git] / ui.c
diff --git a/ui.c b/ui.c
index 88e1c2e51f61cc999466dcbab356bc73d996ca05..9097aaf5b2c772eb55c1d9b9670a198ace63e384 100644 (file)
--- a/ui.c
+++ b/ui.c
@@ -27,46 +27,73 @@ 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, 
+       "333333332......."
+       "26777761........"
+       "2655541........."
+       "265541.........."
+       "2654561........."
+       "26414561........"
+       "251.14561......."
+       "21...14561......"
+       "1.....141......."
+       ".......1........"
+       "................"
+       "................"
+       "................"
+       "................"
+       "................"
+       "................"
 };
 
-void ui_start(void)
+static rtexturepool_t *uitexturepool;
+
+static void ui_start(void)
 {
+       int i;
+       byte buffer[256][4];
+       uitexturepool = R_AllocTexturePool();
 //     ui_mousepointer = Draw_CachePic("ui/mousepointer.lmp");
-       ui_mousepointertexture = R_LoadTexture("mousepointer", 16, 16, pointerimage, TEXF_ALPHA | TEXF_PRECACHE);
+       for (i = 0;i < 256;i++)
+       {
+               if (pointerimage[i] == '.')
+               {
+                       buffer[i][0] = 0;
+                       buffer[i][1] = 0;
+                       buffer[i][2] = 0;
+                       buffer[i][3] = 0;
+               }
+               else
+               {
+                       buffer[i][0] = (pointerimage[i] - '0') * 16;
+                       buffer[i][1] = (pointerimage[i] - '0') * 16;
+                       buffer[i][2] = (pointerimage[i] - '0') * 16;
+                       buffer[i][3] = 255;
+               }
+       }
+       ui_mousepointertexture = R_LoadTexture(uitexturepool, "mousepointer", 16, 16, &buffer[0][0], TEXTYPE_RGBA, 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;
+       R_FreeTexturePool(&uitexturepool);
 }
 
-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);
 }
@@ -94,7 +121,7 @@ void ui_mouseupdaterelative(float x, float y)
 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));
@@ -104,7 +131,7 @@ ui_t *ui_create(void)
 void ui_free(ui_t *ui)
 {
        if (ui)
-               qfree(ui);
+               Mem_Free(ui);
 }
 
 void ui_clear(ui_t *ui)
@@ -417,7 +444,7 @@ void ui_draw(void)
                                Draw_AdditivePic(it->draw_x, it->draw_y, it->draw_pic);
                        if (it->draw_string)
                                Draw_AdditiveString(it->draw_x, it->draw_y, it->draw_string, 9999);
-                       if (ui_showname.value)
+                       if (ui_showname.integer)
                                Draw_String(ui_mouse_x, ui_mouse_y + 16, it->name, 9999);
        }