hu_lib.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /* Emacs style mode select -*- C++ -*-
  2. *-----------------------------------------------------------------------------
  3. *
  4. *
  5. * PrBoom: a Doom port merged with LxDoom and LSDLDoom
  6. * based on BOOM, a modified and improved DOOM engine
  7. * Copyright (C) 1999 by
  8. * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
  9. * Copyright (C) 1999-2000 by
  10. * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
  11. * Copyright 2005, 2006 by
  12. * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  27. * 02111-1307, USA.
  28. *
  29. * DESCRIPTION: none
  30. *
  31. *-----------------------------------------------------------------------------*/
  32. #ifndef __HULIB__
  33. #define __HULIB__
  34. // We are referring to patches.
  35. #include "r_defs.h"
  36. #include "v_video.h" //jff 2/16/52 include color range defs
  37. /* background and foreground screen numbers
  38. * different from other modules. */
  39. #define BG 1
  40. #define FG 0
  41. /* font stuff
  42. * #define HU_CHARERASE KEYD_BACKSPACE / not used / phares
  43. */
  44. #define HU_MAXLINES 4
  45. #define HU_MAXLINELENGTH 80
  46. #define HU_REFRESHSPACING 8 /*jff 2/26/98 space lines in text refresh widget*/
  47. /*jff 2/26/98 maximum number of messages allowed in refresh list */
  48. #define HU_MAXMESSAGES 16
  49. /*
  50. * Typedefs of widgets
  51. */
  52. /* Text Line widget
  53. * (parent of Scrolling Text and Input Text widgets) */
  54. typedef struct
  55. {
  56. // left-justified position of scrolling text window
  57. int x;
  58. int y;
  59. const patchnum_t* f; // font
  60. int sc; // start character
  61. //const char *cr; //jff 2/16/52 output color range
  62. // Proff - Made this an int again. Needed for OpenGL
  63. int cm; //jff 2/16/52 output color range
  64. // killough 1/23/98: Support multiple lines:
  65. #define MAXLINES 25
  66. int linelen;
  67. char l[HU_MAXLINELENGTH*MAXLINES+1]; // line of text
  68. int len; // current line length
  69. // whether this line needs to be udpated
  70. int needsupdate;
  71. } hu_textline_t;
  72. // Scrolling Text window widget
  73. // (child of Text Line widget)
  74. typedef struct
  75. {
  76. hu_textline_t l[HU_MAXLINES]; // text lines to draw
  77. int h; // height in lines
  78. int cl; // current line number
  79. // pointer to boolean stating whether to update window
  80. boolean* on;
  81. boolean laston; // last value of *->on.
  82. } hu_stext_t;
  83. //jff 2/26/98 new widget to display last hud_msg_lines of messages
  84. // Message refresh window widget
  85. typedef struct
  86. {
  87. hu_textline_t l[HU_MAXMESSAGES]; // text lines to draw
  88. int nl; // height in lines
  89. int nr; // total height in rows
  90. int cl; // current line number
  91. int x,y,w,h; // window position and size
  92. const patchnum_t *bg; // patches for background
  93. // pointer to boolean stating whether to update window
  94. boolean* on;
  95. boolean laston; // last value of *->on.
  96. } hu_mtext_t;
  97. // Input Text Line widget
  98. // (child of Text Line widget)
  99. typedef struct
  100. {
  101. hu_textline_t l; // text line to input on
  102. // left margin past which I am not to delete characters
  103. int lm;
  104. // pointer to boolean stating whether to update window
  105. boolean* on;
  106. boolean laston; // last value of *->on;
  107. } hu_itext_t;
  108. //
  109. // Widget creation, access, and update routines
  110. //
  111. //
  112. // textline code
  113. //
  114. // clear a line of text
  115. void HUlib_clearTextLine(hu_textline_t *t);
  116. void HUlib_initTextLine
  117. (
  118. hu_textline_t *t,
  119. int x,
  120. int y,
  121. const patchnum_t *f,
  122. int sc,
  123. int cm //jff 2/16/98 add color range parameter
  124. );
  125. // returns success
  126. boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch);
  127. // draws tline
  128. void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor);
  129. // erases text line
  130. void HUlib_eraseTextLine(hu_textline_t *l);
  131. //
  132. // Scrolling Text window widget routines
  133. //
  134. // initialize an stext widget
  135. void HUlib_initSText
  136. ( hu_stext_t* s,
  137. int x,
  138. int y,
  139. int h,
  140. const patchnum_t* font,
  141. int startchar,
  142. int cm, //jff 2/16/98 add color range parameter
  143. boolean* on );
  144. // add a text message to an stext widget
  145. void HUlib_addMessageToSText(hu_stext_t* s, const char* prefix, const char* msg);
  146. // draws stext
  147. void HUlib_drawSText(hu_stext_t* s);
  148. // erases all stext lines
  149. void HUlib_eraseSText(hu_stext_t* s);
  150. //jff 2/26/98 message refresh widget
  151. // initialize refresh text widget
  152. void HUlib_initMText(hu_mtext_t *m, int x, int y, int w, int h, const patchnum_t* font,
  153. int startchar, int cm, const patchnum_t* bgfont, boolean *on);
  154. //jff 2/26/98 message refresh widget
  155. // add a text message to refresh text widget
  156. void HUlib_addMessageToMText(hu_mtext_t* m, const char* prefix, const char* msg);
  157. //jff 2/26/98 new routine to display a background on which
  158. // the list of last hud_msg_lines are displayed
  159. void HUlib_drawMBg
  160. ( int x,
  161. int y,
  162. int w,
  163. int h,
  164. const patchnum_t* bgp
  165. );
  166. //jff 2/26/98 message refresh widget
  167. // draws mtext
  168. void HUlib_drawMText(hu_mtext_t* m);
  169. //jff 4/28/98 erases behind message list
  170. void HUlib_eraseMText(hu_mtext_t* m);
  171. // Input Text Line widget routines
  172. void HUlib_initIText
  173. ( hu_itext_t* it,
  174. int x,
  175. int y,
  176. const patchnum_t* font,
  177. int startchar,
  178. int cm, //jff 2/16/98 add color range parameter
  179. boolean* on );
  180. // resets line and left margin
  181. void HUlib_resetIText(hu_itext_t* it);
  182. // left of left-margin
  183. void HUlib_addPrefixToIText
  184. ( hu_itext_t* it,
  185. char* str );
  186. // whether eaten
  187. boolean HUlib_keyInIText
  188. ( hu_itext_t* it,
  189. unsigned char ch );
  190. void HUlib_drawIText(hu_itext_t* it);
  191. // erases all itext lines
  192. void HUlib_eraseIText(hu_itext_t* it);
  193. #endif