hu_lib.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 HU_BG 0
  40. #define HU_FG 0
  41. /* font stuff
  42. * #define HU_CHARERASE KEYD_BACKSPACE / not used / phares
  43. */
  44. #define HU_MAXLINES 1
  45. #define HU_MAXLINELENGTH 31
  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 1
  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 patch_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. // killough 1/23/98: Support multiple lines:
  64. #define MAXLINES 1
  65. int linelen;
  66. char l[HU_MAXLINELENGTH*MAXLINES+1]; // line of text
  67. int len; // current line length
  68. // whether this line needs to be udpated
  69. int needsupdate;
  70. } hu_textline_t;
  71. // Scrolling Text window widget
  72. // (child of Text Line widget)
  73. typedef struct
  74. {
  75. hu_textline_t l[HU_MAXLINES]; // text lines to draw
  76. int h; // height in lines
  77. int cl; // current line number
  78. // pointer to boolean stating whether to update window
  79. boolean* on;
  80. boolean laston; // last value of *->on.
  81. } hu_stext_t;
  82. //jff 2/26/98 new widget to display last hud_msg_lines of messages
  83. // Message refresh window widget
  84. typedef struct
  85. {
  86. hu_textline_t l[HU_MAXMESSAGES]; // text lines to draw
  87. int nl; // height in lines
  88. int nr; // total height in rows
  89. int cl; // current line number
  90. int x,y,w,h; // window position and size
  91. const patch_t *bg; // patches for background
  92. // pointer to boolean stating whether to update window
  93. boolean* on;
  94. boolean laston; // last value of *->on.
  95. } hu_mtext_t;
  96. // Input Text Line widget
  97. // (child of Text Line widget)
  98. typedef struct
  99. {
  100. hu_textline_t l; // text line to input on
  101. // left margin past which I am not to delete characters
  102. int lm;
  103. // pointer to boolean stating whether to update window
  104. boolean* on;
  105. boolean laston; // last value of *->on;
  106. } hu_itext_t;
  107. //
  108. // Widget creation, access, and update routines
  109. //
  110. //
  111. // textline code
  112. //
  113. // clear a line of text
  114. void HUlib_clearTextLine(hu_textline_t *t);
  115. void HUlib_initTextLine
  116. (hu_textline_t *t,
  117. int x,
  118. int y,
  119. const patch_t *f,
  120. int sc);
  121. // returns success
  122. boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch);
  123. // draws tline
  124. void HUlib_drawTextLine(hu_textline_t *l);
  125. // erases text line
  126. void HUlib_eraseTextLine(hu_textline_t *l);
  127. //
  128. // Scrolling Text window widget routines
  129. //
  130. // initialize an stext widget
  131. void HUlib_initSText
  132. (hu_stext_t* s,
  133. int x,
  134. int y,
  135. int h,
  136. const patch_t *font,
  137. int startchar, //jff 2/16/98 add color range parameter
  138. boolean* on );
  139. // add a text message to an stext widget
  140. void HUlib_addMessageToSText(hu_stext_t* s, const char* prefix, const char* msg);
  141. // draws stext
  142. void HUlib_drawSText(hu_stext_t* s);
  143. // erases all stext lines
  144. void HUlib_eraseSText(hu_stext_t* s);
  145. #endif