DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

hu_lib.h (4626B)


      1 /*
      2 ===========================================================================
      3 
      4 Doom 3 BFG Edition GPL Source Code
      5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 
      6 
      7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").  
      8 
      9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
     10 it under the terms of the GNU General Public License as published by
     11 the Free Software Foundation, either version 3 of the License, or
     12 (at your option) any later version.
     13 
     14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
     15 but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 GNU General Public License for more details.
     18 
     19 You should have received a copy of the GNU General Public License
     20 along with Doom 3 BFG Edition Source Code.  If not, see <http://www.gnu.org/licenses/>.
     21 
     22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code.  If not, please request a copy in writing from id Software at the address below.
     23 
     24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
     25 
     26 ===========================================================================
     27 */
     28 
     29 #ifndef __HULIB__
     30 #define __HULIB__
     31 
     32 // We are referring to patches.
     33 #include "r_defs.h"
     34 
     35 // font stuff
     36 #define HU_CHARERASE	KEY_BACKSPACE
     37 
     38 #define HU_MAXLINES		4
     39 #define HU_MAXLINELENGTH	80
     40 
     41 //
     42 // Typedefs of widgets
     43 //
     44 
     45 // Text Line widget
     46 //  (parent of Scrolling Text and Input Text widgets)
     47 typedef struct
     48 {
     49     // left-justified position of scrolling text window
     50     int		x;
     51     int		y;
     52     
     53     patch_t**	f;			// font
     54     int		sc;			// start character
     55     char	l[HU_MAXLINELENGTH+1];	// line of text
     56     int		len;		      	// current line length
     57 
     58     // whether this line needs to be udpated
     59     int		needsupdate;	      
     60 
     61 } hu_textline_t;
     62 
     63 
     64 
     65 // Scrolling Text window widget
     66 //  (child of Text Line widget)
     67 typedef struct
     68 {
     69     hu_textline_t	l[HU_MAXLINES];	// text lines to draw
     70     int			h;		// height in lines
     71     int			cl;		// current line number
     72 
     73     // pointer to qboolean stating whether to update window
     74     qboolean*		on;
     75     qboolean		laston;		// last value of *->on.
     76 
     77 } hu_stext_t;
     78 
     79 
     80 
     81 // Input Text Line widget
     82 //  (child of Text Line widget)
     83 typedef struct
     84 {
     85     hu_textline_t	l;		// text line to input on
     86 
     87      // left margin past which I am not to delete characters
     88     int			lm;
     89 
     90     // pointer to qboolean stating whether to update window
     91     qboolean*		on; 
     92     qboolean		laston; // last value of *->on;
     93 
     94 } hu_itext_t;
     95 
     96 
     97 //
     98 // Widget creation, access, and update routines
     99 //
    100 
    101 // initializes heads-up widget library
    102 void HUlib_init(void);
    103 
    104 //
    105 // textline code
    106 //
    107 
    108 // clear a line of text
    109 void	HUlib_clearTextLine(hu_textline_t *t);
    110 
    111 void	HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc);
    112 
    113 // returns success
    114 qboolean HUlib_addCharToTextLine(hu_textline_t *t, char ch);
    115 
    116 // returns success
    117 qboolean HUlib_delCharFromTextLine(hu_textline_t *t);
    118 
    119 // draws tline
    120 void	HUlib_drawTextLine(hu_textline_t *l, qboolean drawcursor);
    121 
    122 // erases text line
    123 void	HUlib_eraseTextLine(hu_textline_t *l); 
    124 
    125 
    126 //
    127 // Scrolling Text window widget routines
    128 //
    129 
    130 // ?
    131 void
    132 HUlib_initSText
    133 ( hu_stext_t*	s,
    134   int		x,
    135   int		y,
    136   int		h,
    137   patch_t**	font,
    138   int		startchar,
    139   qboolean*	on );
    140 
    141 // add a new line
    142 void HUlib_addLineToSText(hu_stext_t* s);  
    143 
    144 // ?
    145 void
    146 HUlib_addMessageToSText
    147 ( hu_stext_t*	s,
    148   const char*		prefix,
    149   const char*		msg );
    150 
    151 // draws stext
    152 void HUlib_drawSText(hu_stext_t* s);
    153 
    154 // erases all stext lines
    155 void HUlib_eraseSText(hu_stext_t* s); 
    156 
    157 // Input Text Line widget routines
    158 void
    159 HUlib_initIText
    160 ( hu_itext_t*	it,
    161   int		x,
    162   int		y,
    163   patch_t**	font,
    164   int		startchar,
    165   qboolean*	on );
    166 
    167 // enforces left margin
    168 void HUlib_delCharFromIText(hu_itext_t* it);
    169 
    170 // enforces left margin
    171 void HUlib_eraseLineFromIText(hu_itext_t* it);
    172 
    173 // resets line and left margin
    174 void HUlib_resetIText(hu_itext_t* it);
    175 
    176 // left of left-margin
    177 void
    178 HUlib_addPrefixToIText
    179 ( hu_itext_t*	it,
    180   char*		str );
    181 
    182 // whether eaten
    183 qboolean
    184 HUlib_keyInIText
    185 ( hu_itext_t*	it,
    186   unsigned char ch );
    187 
    188 void HUlib_drawIText(hu_itext_t* it);
    189 
    190 // erases all itext lines
    191 void HUlib_eraseIText(hu_itext_t* it); 
    192 
    193 #endif
    194