diff --git a/doc/hud.txt b/doc/hud.txt new file mode 100644 index 000000000..cccb33feb --- /dev/null +++ b/doc/hud.txt @@ -0,0 +1,49 @@ +{ + common = { + textureHighlightColor = "0.7 0.7 0.1"; // pickup color flash + themeName = "Scout"; + }; + ammo = { + gravity = southeast; + texSize = (24, 12); + textGrav = east; + items = ({ + name = shells; + texture = sb_shells; + location = (-24, 12); + }, + { + name = nails; + texture = sb_nails; + location = (-24, 24); + }); + }; + crosshair = { + gravity = center; + texSize = (12, 12); + texture = crosshair; + }; + items = { + gravity = west; + texSize = (12, 12); + items = ({ + name = quad; + texture = sb_quad; + location = (0, 0); + }); + }; + weapons = { + gravity = northeast; + texSize = (24, 8); + items = ({ + name = shotgun; + texture = sb_shot; + location = (-24, 0); + }, + { + name = sshotgun; + texture = sb_sshot; + location = (-24, 8); + }); + }; +} diff --git a/include/QF/view.h b/include/QF/view.h new file mode 100644 index 000000000..2abd03573 --- /dev/null +++ b/include/QF/view.h @@ -0,0 +1,69 @@ +/* + view.h + + console view object + + Copyright (C) 2003 Bill Currie + + Author: Bill Currie + Date: 2003/5/5 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + + $Id$ +*/ + +#ifndef __qf_view_h +#define __qf_view_h + +typedef enum { + grav_center, + grav_north, + grav_northeast, + grav_east, + grav_southeast, + grav_south, + grav_southwest, + grav_west, + grav_northwest, +} grav_t; + +typedef struct view_s view_t; +struct view_s { + int xpos, ypos; + int xlen, ylen; + int xabs, yabs; + int xrel, yrel; + grav_t gravity; + view_t *parent; + view_t **children; + int num_children; + int max_children; + void (*draw)(view_t *view); + unsigned enabled:1; +}; + + +view_t *view_new (int xp, int yp, int xl, int yl, grav_t grav); +void view_add (view_t *par, view_t *view); +void view_remove (view_t *par, view_t *view); +void view_delete (view_t *view); +void view_draw (view_t *view); + +#endif//__qf_view_h diff --git a/libs/console/Makefile.am b/libs/console/Makefile.am index 910a1ba0e..b8dfa130c 100644 --- a/libs/console/Makefile.am +++ b/libs/console/Makefile.am @@ -13,7 +13,7 @@ noinst_PROGRAMS= @SERVER_PLUGIN_STATIC@ @CLIENT_PLUGIN_STATIC@ EXTRA_PROGRAMS= console_server.la console_client.la common_sources= buffer.c complete.c console.c inputline.c list.c filelist.c -client_sources= client.c menu.c +client_sources= client.c menu.c view.c server_sources= server.c libQFconsole_la_LDFLAGS= -version-info 1:0:0 -rpath $(libdir) diff --git a/libs/console/view.c b/libs/console/view.c new file mode 100644 index 000000000..eb6b6011e --- /dev/null +++ b/libs/console/view.c @@ -0,0 +1,148 @@ +/* + view.c + + console view object + + Copyright (C) 2003 Bill Currie + + Author: Bill Currie + Date: 2003/5/5 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +static __attribute__ ((unused)) const char rcsid[] = + "$Id$"; + +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + +#include "QF/view.h" + +view_t * +view_new (int xp, int yp, int xl, int yl, grav_t grav) +{ + view_t *view = calloc (1, sizeof (view_t)); + view->xpos = xp; + view->ypos = yp; + view->xlen = xl; + view->ylen = yl; + view->gravity = grav; + return view; +} + +void +view_add (view_t *par, view_t *view) +{ + switch (view->gravity) { + case grav_center: + view->xrel = view->xpos + (par->xlen - view->xlen) / 2; + view->yrel = view->ypos + (par->ylen - view->ylen) / 2; + break; + case grav_north: + view->xrel = view->xpos + (par->xlen - view->xlen) / 2; + view->yrel = view->ypos; + break; + case grav_northeast: + view->xrel = par->xlen - view->xpos - view->xlen; + view->yrel = view->ypos; + break; + case grav_east: + view->xrel = par->xlen - view->xpos - view->xlen; + view->yrel = view->ypos + (par->ylen - view->ylen) / 2; + break; + case grav_southeast: + view->xrel = par->xlen - view->xpos - view->xlen; + view->yrel = par->ylen - view->ypos - view->ylen; + break; + case grav_south: + view->xrel = view->xpos + (par->xlen - view->xlen) / 2; + view->yrel = par->ylen - view->ypos - view->ylen; + break; + case grav_southwest: + view->xrel = view->xpos; + view->yrel = par->ylen - view->ypos - view->ylen; + break; + case grav_west: + view->xrel = view->xpos; + view->yrel = view->ypos + (par->ylen - view->ylen) / 2; + break; + case grav_northwest: + view->xrel = view->xpos; + view->yrel = view->ypos; + break; + } + view->xabs = par->xabs + view->xrel; + view->yabs = par->yabs + view->yrel; + view->parent = par; + if (par->num_children == par->max_children) { + par->max_children += 8; + par->children = realloc (par->children, + par->max_children * sizeof (view_t *)); + memset (par->children + par->num_children, 0, + (par->max_children - par->num_children) * sizeof (view_t *)); + } + par->children[par->max_children++] = view; +} + +void +view_remove (view_t *par, view_t *view) +{ + int i; + + for (i = 0; i < par->num_children; i++) { + if (par->children[i] == view) { + memcpy (par->children + i, par->children + i + 1, + (par->num_children - i - 1) * sizeof (view_t *)); + par->children [par->num_children--] = 0; + break; + } + } +} + +void +view_delete (view_t *view) +{ + if (view->parent) + view_remove (view->parent, view); + while (view->num_children) + view_delete (view->children[0]); + free (view); +} + +void +view_draw (view_t *view) +{ + int i; + + for (i = 0; i < view->num_children; i++) { + view_t *v = view->children[i]; + if (v->enabled && v->draw) + v->draw (v); + } +}