1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
6 // Copyright (C) 1993-1996 by id Software, Inc.
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
18 // Revision 1.1 2000/02/29 18:21:04 stegerg
19 // Doom port based on ADoomPPC. Read README.AROS!
22 // DESCRIPTION: heads-up text and input code
24 //-----------------------------------------------------------------------------
41 // boolean : whether the screen is always erased
42 #define noterased viewwindowx
44 extern boolean automapactive
; // in AM_map.c
45 extern int maponhu
; // checkparm of -maponhu
51 void HUlib_clearTextLine(hu_textline_t
* t
)
55 t
->needsupdate
= true;
70 HUlib_clearTextLine(t
);
74 HUlib_addCharToTextLine
79 if (t
->len
== HU_MAXLINELENGTH
)
91 boolean
HUlib_delCharFromTextLine(hu_textline_t
* t
)
94 if (!t
->len
) return false;
115 // draw the new stuff
117 for (i
=0;i
<l
->len
;i
++)
119 c
= toupper(l
->l
[i
]);
124 w
= SWAPSHORT(l
->f
[c
- l
->sc
]->width
);
125 if (x
+w
> SCREENWIDTH
)
127 V_DrawPatchDirect(x
, l
->y
, FG
, l
->f
[c
- l
->sc
]);
133 if (x
>= SCREENWIDTH
)
138 // draw the cursor if requested
140 && x
+ SWAPSHORT(l
->f
['_' - l
->sc
]->width
) <= SCREENWIDTH
)
142 V_DrawPatchDirect(x
, l
->y
, FG
, l
->f
['_' - l
->sc
]);
147 // sorta called by HU_Erase and just better darn get things straight
148 void HUlib_eraseTextLine(hu_textline_t
* l
)
153 static boolean lastautomapactive
= true;
155 // Only erases when NOT in automap and the screen is reduced,
156 // and the text must either need updating or refreshing
157 // (because of a recent change back from the automap)
159 if ((!automapactive
|| maponhu
) &&
160 viewwindowx
&& l
->needsupdate
)
162 lh
= SWAPSHORT(l
->f
[0]->height
) + 1;
163 for (y
=l
->y
,yoffset
=y
*SCREENWIDTH
; y
<l
->y
+lh
; y
++,yoffset
+=SCREENWIDTH
)
165 if (y
< viewwindowy
|| y
>= viewwindowy
+ viewheight
)
166 R_VideoErase(yoffset
, SCREENWIDTH
); // erase entire line
169 R_VideoErase(yoffset
, viewwindowx
); // erase left border
170 R_VideoErase(yoffset
+ viewwindowx
+ viewwidth
, viewwindowx
);
171 // erase right border
176 lastautomapactive
= automapactive
;
177 if (l
->needsupdate
) l
->needsupdate
--;
199 HUlib_initTextLine(&s
->l
[i
],
200 x
, y
- i
*(SWAPSHORT(font
[0]->height
)+1),
205 void HUlib_addLineToSText(hu_stext_t
* s
)
213 HUlib_clearTextLine(&s
->l
[s
->cl
]);
215 // everything needs updating
216 for (i
=0 ; i
<s
->h
; i
++)
217 s
->l
[i
].needsupdate
= 4;
222 HUlib_addMessageToSText
227 HUlib_addLineToSText(s
);
230 HUlib_addCharToTextLine(&s
->l
[s
->cl
], *(prefix
++));
233 HUlib_addCharToTextLine(&s
->l
[s
->cl
], *(msg
++));
236 void HUlib_drawSText(hu_stext_t
* s
)
242 return; // if not on, don't draw
245 for (i
=0 ; i
<s
->h
; i
++)
249 idx
+= s
->h
; // handle queue of lines
253 // need a decision made here on whether to skip the draw
254 HUlib_drawTextLine(l
, false); // no cursor, please
259 void HUlib_eraseSText(hu_stext_t
* s
)
264 for (i
=0 ; i
<s
->h
; i
++)
266 if (s
->laston
&& !*s
->on
)
267 s
->l
[i
].needsupdate
= 4;
268 HUlib_eraseTextLine(&s
->l
[i
]);
283 it
->lm
= 0; // default left margin is start of text
286 HUlib_initTextLine(&it
->l
, x
, y
, font
, startchar
);
290 // The following deletion routines adhere to the left margin restriction
291 void HUlib_delCharFromIText(hu_itext_t
* it
)
293 if (it
->l
.len
!= it
->lm
)
294 HUlib_delCharFromTextLine(&it
->l
);
297 void HUlib_eraseLineFromIText(hu_itext_t
* it
)
299 while (it
->lm
!= it
->l
.len
)
300 HUlib_delCharFromTextLine(&it
->l
);
303 // Resets left margin as well
304 void HUlib_resetIText(hu_itext_t
* it
)
307 HUlib_clearTextLine(&it
->l
);
311 HUlib_addPrefixToIText
316 HUlib_addCharToTextLine(&it
->l
, *(str
++));
320 // wrapper function for handling general keyed input.
321 // returns true if it ate the key
328 if (ch
>= ' ' && ch
<= '_')
329 HUlib_addCharToTextLine(&it
->l
, (char) ch
);
331 if (ch
== KEY_BACKSPACE
)
332 HUlib_delCharFromIText(it
);
335 return false; // did not eat key
337 return true; // ate the key
341 void HUlib_drawIText(hu_itext_t
* it
)
344 hu_textline_t
*l
= &it
->l
;
348 HUlib_drawTextLine(l
, true); // draw the line w/ cursor
352 void HUlib_eraseIText(hu_itext_t
* it
)
354 if (it
->laston
&& !*it
->on
)
355 it
->l
.needsupdate
= 4;
356 HUlib_eraseTextLine(&it
->l
);
357 it
->laston
= *it
->on
;