hu_lib.h 4.5 KB

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