SCR_CheckDrawCenterString();
}
MR_Draw();
+ UI_Callback_Draw();
CL_DrawVideo();
- ui_draw();
+ //ui_draw();
if (cls.signon == SIGNONS)
{
R_TimeReport("2d");
R_Light_Init();
R_Particles_Init();
R_Explosion_Init();
- ui_init();
+ //ui_init();
+ UI_Init();
Sbar_Init();
R_LightningBeams_Init();
}
CL_ReadFromServer();
}
- ui_update();
+ //ui_update();
CL_VideoFrame();
MR_ToggleMenu_f ();
break;
default:
- Sys_Error ("Bad key_dest");
+ if(UI_Callback_IsSlotUsed(key_dest - 3))
+ UI_Callback_KeyDown (key, ascii);
+ else
+ Sys_Error ("Bad key_dest");
}
return;
}
Key_Console (key, ascii);
break;
default:
- Sys_Error ("Bad key_dest");
+ if(UI_Callback_IsSlotUsed(key_dest - 3))
+ UI_Callback_KeyDown (key, ascii);
+ else
+ Sys_Error ("Bad key_dest");
}
}
}
0 darkplaces: check for out of bounds lump data ranges in maps (FrikaC)
0 darkplaces: check for truncated sound files (FrikaC)
0 darkplaces: cl_particles_maximum cvar (default 32768) which would change number of particles allowed at once (TheBeast)
-0 darkplaces: clean up the DrawQ_ blendfunc handling, instead of taking DRAWFLAG_ADDITIVE they should take blendfunc values (Black)
0 darkplaces: client colors are being reset to "15 15" each level in prydon gate? (FrikaC)
0 darkplaces: darkplaces-glx -path transfusion crashes, fix the crash even though it's not going to work anyway (Todd)
0 darkplaces: delay "connect" and "playdemo" and "timedemo" until after video init to cause quicker video startup (KrimZon)
4 darkplaces: figure out what is wrong with dedicated server console on win32 and fix it (and tell willis@deathmask.net)
4 darkplaces: ingame mod switching
4 darkplaces: make hqbsp save mip textures to bsp if tga textures are found
-4 darkplaces: memory pool nesting, allowing pools of pools to be batch freed (Vicious)
+-n darkplaces: memory pool nesting, allowing pools of pools to be batch freed (Vicious)
+4 darkplaces: use the memory pool nesting feature ! (Black[,Vicious])
4 darkplaces: rewrite sound system! (FrikaC, Static_Fiend, SeienAbunae)
4 darkplaces: use getaddrinfo to support ipv6, add support for winsock2 (or require it), check if winsock2 has ipv6 functions (getaddrinfo)... (|Rain|)
4 dpzoo: a drivable vehicle (using same technique as remote cameras, plus DP_SV_READCLIENTINPUT)
#include "quakedef.h"
-cvar_t ui_showname = {0, "ui_showname", "0"};
+/*cvar_t ui_showname = {0, "ui_showname", "0"};
#define ITEM_CLICKABLE 1
#define ITEM_DRAWABLE 2
DrawQ_Pic(ui_mouse_x, ui_mouse_y, "ui/mousepointer.tga", 0, 0, 1, 1, 1, 1, 0);
}
+}*/
+
+#define FRAME_THICKNESS 2
+#define FRAME_COLOR1 0.2, 0.2, 0.5, 0, 0
+#define FRAME_COLOR2 0, 0, 0, 0.6, 0
+#define TEXT_FONTSIZE 10, 10
+
+static void UIG_DrawFrame(float x, float y, float w, float h)
+{
+ // bottom
+ DrawQ_Fill(x - FRAME_THICKNESS, y - FRAME_THICKNESS, w + 2 * FRAME_THICKNESS, FRAME_THICKNESS, FRAME_COLOR1);
+ // top
+ DrawQ_Fill(x - FRAME_THICKNESS, y + h, w + 2 * FRAME_THICKNESS, FRAME_THICKNESS, FRAME_COLOR1);
+ // left
+ DrawQ_Fill(x - FRAME_THICKNESS, y, FRAME_THICKNESS, h, FRAME_COLOR1);
+ // right
+ DrawQ_Fill(x + w, y, FRAME_THICKNESS, h, FRAME_COLOR1);
+ // area
+ DrawQ_Fill(x, y, w, h, FRAME_COLOR2);
+}
+
+static void UIG_DrawText(const char *text, float x, float y, float w, float h, float r, float g, float b, float a, float f)
+{
+ if(w != 0 && h != 0)
+ DrawQ_SetClipArea(x, y, w, h);
+ DrawQ_String(x, y, text, 0, TEXT_FONTSIZE, r, g, b, a , f);
+ if(w != 0 && h != 0)
+ DrawQ_ResetClipArea();
+}
+
+void UI_Init(void)
+{
+}
+
+void UI_Key(ui_itemlist_t list, int key, int ascii)
+{
+}
+
+void UI_Draw(ui_itemlist_t list)
+{
+}
+
+void UI_SetFocus(ui_itemlist_t list, ui_item_t item)
+{
+}
+
+void UI_SetNeighbors(ui_item_t left, ui_item_t right, ui_item_t up, ui_item_t down)
+{
+}
+
+// item stuff
+ui_item_t UI_CreateButton(const char *caption, float x, float y, void(*action)(ui_item_t))
+{
+ return NULL;
+}
+
+ui_item_t UI_CreateLabel(const char *caption, float x, float y)
+{
+ return NULL;
+}
+
+ui_item_t UI_CreateText(const char *caption, float x, float y, const char *allowed, int maxlen, int scrolllen)
+{
+ return NULL;
+}
+
+void UI_FreeItem(ui_item_t item)
+{
+}
+
+const char* UI_GetCaption(ui_item_t item)
+{
}
+void UI_SetCaption(ui_item_t item, const char * caption)
+{
+}
+
+// itemlist stuff
+ui_itemlist_t UI_CreateItemList(float x, float y)
+{
+ return NULL;
+}
+
+void UI_FreeItemList(ui_itemlist_t list)
+{
+}
+
+void UI_AddItem(ui_itemlist_t list, ui_item_t item)
+{
+}
+
+// AK: callback system stuff
+static ui_callback_t ui_callback_list[UI_MAX_CALLBACK_COUNT];
+
+void UI_Callback_Init(void)
+{
+ memset(ui_callback_list, 0, sizeof(ui_callback_list));
+}
+
+int UI_Callback_GetFreeSlot(void)
+{
+ int i;
+ for(i = 0; ui_callback_list[i].flag & UI_SLOTUSED && i < UI_MAX_CALLBACK_COUNT; i++);
+
+ if(i == UI_MAX_CALLBACK_COUNT)
+ return -1;
+ else
+ return i;
+}
+
+int UI_Callback_IsSlotUsed(int slotnr)
+{
+ if(slotnr < 0 || slotnr >= UI_MAX_CALLBACK_COUNT)
+ return false;
+ return (ui_callback_list[slotnr].flag & UI_SLOTUSED);
+}
+
+void UI_Callback_SetupSlot(int slotnr, void(*keydownf)(int num, char ascii), void(*drawf)(void))
+{
+ ui_callback_list[slotnr].flag = UI_SLOTUSED;
+ ui_callback_list[slotnr].draw = drawf;
+ ui_callback_list[slotnr].keydown = keydownf;
+}
+
+void UI_Callback_ResetSlot(int slotnr)
+{
+ ui_callback_list[slotnr].flag = 0;
+}
+
+void UI_Callback_Draw(void)
+{
+ int i;
+ for(i = 0; i < UI_MAX_CALLBACK_COUNT; i++)
+ if(ui_callback_list[i].flag & UI_SLOTUSED && ui_callback_list[i].draw)
+ ui_callback_list[i].draw();
+}
+
+void UI_Callback_KeyDown(int num, char ascii)
+{
+ if(ui_callback_list[key_dest - 3].flag & UI_SLOTUSED && ui_callback_list[key_dest - 3].keydown)
+ ui_callback_list[key_dest - 3].keydown(num, ascii);
+}
\ No newline at end of file
#ifndef UI_H
#define UI_H
-
+/*
// these defines and structures are for internal use only
// (ui_t is passed around by users of the system, but should not be altered)
#define MAX_UI_COUNT 16
// checks if a panel is enabled
int ui_uiactive(ui_t *ui);
// enables/disables a panel on the screen
-void ui_activate(ui_t *ui, int yes);
+void ui_activate(ui_t *ui, int yes);*/
+
+// AK: new passive ui (like the menu stuff)
+#define UI_TEXT_DEFAULT_LENGTH 255
+typedef void * ui_item_t;
+typedef void * ui_itemlist_t;
+
+void UI_Init(void);
+
+void UI_Key(ui_itemlist_t, int key, int ascii);
+void UI_Draw(ui_itemlist_t);
+
+void UI_SetFocus(ui_itemlist_t, ui_item_t);
+void UI_SetNeighbors(ui_item_t left, ui_item_t right, ui_item_t up, ui_item_t down);
+
+// item stuff
+ui_item_t UI_CreateButton(const char *caption, float x, float y, void(*action)(ui_item_t));
+ui_item_t UI_CreateLabel(const char *caption, float x, float y);
+ui_item_t UI_CreateText(const char *caption, float x, float y, const char *allowed, int maxlen, int scrolllen);
+void UI_FreeItem(ui_item_t);
+
+const char* UI_GetCaption(ui_item_t);
+void UI_SetCaption(ui_item_t, const char *);
+
+// itemlist stuff
+ui_itemlist_t UI_CreateItemList(float x, float y);
+void UI_FreeItemList(ui_itemlist_t);
+
+void UI_AddItem(ui_itemlist_t, ui_item_t);
+
+// AK: new callback system
+#define UI_MAX_CALLBACK_COUNT 10
+
+#define UI_SLOTUSED 1
+typedef struct ui_callback_s
+{
+ unsigned int flag;
+ void (*keydown) (int num, char ascii);
+ void (*draw) (void);
+} ui_callback_t;
+
+// functions which should be used
+void UI_Callback_Init(void);
+void UI_Callback_Reset(void);
+
+void UI_Callback_SetupSlot(int slotnr, void(*keydownf)(int num, char ascii), void(*drawf)(void));
+void UI_Callback_ResetSlot(int slotnr);
+int UI_Callback_GetFreeSlot(void);
+int UI_Callback_IsSlotUsed(int slotnr);
+
+void UI_Callback_Draw(void);
+void UI_Callback_KeyDown(int num, char ascii);
#endif
p_mouse_y = event.xmotion.y;
}
}
- else
- ui_mouseupdate(event.xmotion.x, event.xmotion.y);
+ //else
+ // ui_mouseupdate(event.xmotion.x, event.xmotion.y);
break;
case ButtonPress:
if (!mouseactive)
{
GetCursorPos (¤t_pos);
- ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
+ //ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
in_mouse_x = in_mouse_y = 0;
return;
}
#endif
}
-mempool_t *_Mem_AllocPool(const char *name, const char *filename, int fileline)
+mempool_t *_Mem_AllocPool(const char *name, mempool_t *parent, const char *filename, int fileline)
{
mempool_t *pool;
pool = malloc(sizeof(mempool_t));
pool->totalsize = 0;
pool->realsize = sizeof(mempool_t);
strlcpy (pool->name, name, sizeof (pool->name));
+ pool->parent = parent;
pool->next = poolchain;
poolchain = pool;
return pool;
void _Mem_FreePool(mempool_t **pool, const char *filename, int fileline)
{
- mempool_t **chainaddress;
+ mempool_t **chainaddress, *iter, *temp;
+
if (*pool)
{
if ((*pool)->sentinel1 != MEMHEADER_SENTINEL1)
while ((*pool)->chain)
Mem_Free((void *)((qbyte *) (*pool)->chain + sizeof(memheader_t)));
+ // free child pools, too
+ for(iter = poolchain; iter; temp = iter = iter->next)
+ if(iter->parent == *pool)
+ _Mem_FreePool(&temp, filename, fileline);
+
// free the pool itself
memset(*pool, 0xBF, sizeof(mempool_t));
free(*pool);
void _Mem_EmptyPool(mempool_t *pool, const char *filename, int fileline)
{
+ mempool_t *chainaddress;
+
if (pool == NULL)
Sys_Error("Mem_EmptyPool: pool == NULL (emptypool at %s:%i)", filename, fileline);
if (pool->sentinel1 != MEMHEADER_SENTINEL1)
// free memory owned by the pool
while (pool->chain)
Mem_Free((void *)((qbyte *) pool->chain + sizeof(memheader_t)));
+
+ // empty child pools, too
+ for(chainaddress = poolchain; chainaddress; chainaddress = chainaddress->next)
+ if(chainaddress->parent == pool)
+ _Mem_EmptyPool(chainaddress, filename, fileline);
+
}
void _Mem_CheckSentinels(void *data, const char *filename, int fileline)
{
tempmempool = Mem_AllocPool("Temporary Memory");
zonemempool = Mem_AllocPool("Zone");
+ poolchain = NULL;
}
void Memory_Init_Commands (void)
char name[POOLNAMESIZE];
// linked into global mempool list
struct mempool_s *next;
+ // parent object (used for nested memory pools)
+ struct mempool_s *parent;
// file name and line where Mem_AllocPool was called
const char *filename;
int fileline;
#define Mem_Free(mem) _Mem_Free(mem, __FILE__, __LINE__)
#define Mem_CheckSentinels(data) _Mem_CheckSentinels(data, __FILE__, __LINE__)
#define Mem_CheckSentinelsGlobal() _Mem_CheckSentinelsGlobal(__FILE__, __LINE__)
-#define Mem_AllocPool(name) _Mem_AllocPool(name, __FILE__, __LINE__)
+#define Mem_AllocPool(name) _Mem_AllocPool(name, NULL, __FILE__, __LINE__)
+#define Mem_AllocNestedPool(name, parent) _Mem_AllocPool(name, (parent), __FILE__, __LINE__)
#define Mem_FreePool(pool) _Mem_FreePool(pool, __FILE__, __LINE__)
#define Mem_EmptyPool(pool) _Mem_EmptyPool(pool, __FILE__, __LINE__)
void *_Mem_Alloc(mempool_t *pool, int size, const char *filename, int fileline);
void _Mem_Free(void *data, const char *filename, int fileline);
-mempool_t *_Mem_AllocPool(const char *name, const char *filename, int fileline);
+mempool_t *_Mem_AllocPool(const char *name, mempool_t *parent, const char *filename, int fileline);
void _Mem_FreePool(mempool_t **pool, const char *filename, int fileline);
void _Mem_EmptyPool(mempool_t *pool, const char *filename, int fileline);
void _Mem_CheckSentinels(void *data, const char *filename, int fileline);