60b14c1f6b12c38b485691b6dc483d51a4e646d3
1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../../../shared/a_modes.inc}
20 procedure r_Console_Initialize
;
21 procedure r_Console_Finalize
;
23 procedure r_Console_Load
;
24 procedure r_Console_Free
;
26 procedure r_Console_Update
;
27 procedure r_Console_Draw (MessagesOnly
: Boolean);
33 g_game
, g_options
, g_console
,
34 r_draw
, r_textures
, r_fonts
, r_common
38 Background
: TGLTexture
;
44 ConsoleHeight
: Single;
46 Cons_Shown
: Boolean; // draw console
48 procedure r_Console_Initialize
;
50 Cons_Y
:= Round(-Floor(gScreenHeight
* ConsoleHeight
));
53 procedure r_Console_Finalize
;
57 procedure r_Console_Load
;
59 Background
:= r_Textures_LoadFromFile(GameWad
+ ':TEXTURES/CONSOLE');
62 procedure r_Console_Free
;
67 procedure r_Console_Update
;
68 var step
, miny
: Integer;
70 step
:= MAX(1, Round(Floor(gScreenHeight
* ConsoleHeight
) * ConsoleStep
));
71 miny
:= Round(-Floor(gScreenHeight
* ConsoleHeight
));
73 Cons_Y
:= Cons_Y
+ step
75 Cons_Y
:= Cons_Y
- step
;
76 Cons_Y
:= MIN(MAX(Cons_Y
, miny
), 0);
77 Cons_Shown
:= Cons_Y
> miny
;
80 procedure r_Console_DrawLog
;
81 var cw
, ch
, ty
, skip
: Integer; sp
, ep
: LongWord;
83 procedure PutLine (sp
, ep
: LongWord);
84 var p
: LongWord; w
, chw
: Integer;
86 p
:= sp
; w
:= 0; chw
:= 0;
87 while (p
<> ep
) and (w
+ chw
<= gScreenWidth
- 8) do
89 chw
:= stdfont
.GetWidth(cbufAt(p
));
97 ep
:= p
; p
:= sp
; w
:= 2;
100 r_Draw_Text(cbufAt(p
), w
, ty
, 255, 255, 255, 255, stdfont
);
101 chw
:= stdfont
.GetWidth(cbufAt(p
));
114 cw
:= stdfont
.GetMaxWidth();
115 ch
:= stdfont
.GetMaxHeight();
116 ty
:= Floor(gScreenHeight
* ConsoleHeight
) - 4 - 2 * ch
- Abs(Cons_Y
);
117 skip
:= conSkipLines
;
118 cbufLastLine(sp
, ep
);
121 until (ty
+ ch
<= 0) or (cbufLineUp(sp
, ep
) = false);
124 procedure r_Console_Draw (MessagesOnly
: Boolean);
125 var cw
, ch
, y
, i
: Integer; s
: AnsiString;
127 cw
:= stdfont
.GetMaxWidth();
128 ch
:= stdfont
.GetMaxHeight();
130 if ChatTop
and gChatShow
then y
:= ch
else y
:= 0;
132 for i
:= 0 to High(MsgArray
) do
133 if MsgArray
[i
].time
> 0 then
134 r_Draw_Text(MsgArray
[i
].msg
, 0, y
+ ch
* i
, 255, 255, 255, 255, stdfont
);
136 if MessagesOnly
= false then
140 if ChatTop
then y
:= 0 else y
:= gScreenHeight
- ch
- 1;
141 if gChatTeam
then s
:= 'say team> ' else s
:= 'say> ';
142 r_Draw_Text(s
+ Line
, 0, y
, 255, 255, 255, 255, stdfont
);
143 r_Draw_Text('_', (CPos
+ 4) * cw
, y
, 255, 255, 255, 255, stdfont
);
150 // TODO draw debug string
153 if Background
<> nil then
154 r_Draw_Texture(Background
, 0, Cons_Y
, gScreenWidth
, Floor(gScreenHeight
* ConsoleHeight
), false, 255, 255, 255, Round((1.0 - ConsoleTrans
) * 255), false);
158 r_Draw_Text('> ' + Line
, 0, Cons_Y
+ Floor(gScreenHeight
* ConsoleHeight
) - ch
- 4, 255, 255, 255, 255, stdfont
);
159 r_Draw_Text('_', (CPos
+ 1) * cw
, Cons_Y
+ Floor(gScreenHeight
* ConsoleHeight
) - 21, 255, 255, 255, 255, stdfont
);
165 conRegVar('chat_at_top', @ChatTop
, 'draw chat at top border', 'draw chat at top border');
166 conRegVar('console_height', @ConsoleHeight
, 0.0, 1.0, 'set console size', 'set console size');
167 conRegVar('console_step', @ConsoleStep
, 0.0, 1.0, 'set console animation speed', 'set console animation speed');
168 conRegVar('console_trans', @ConsoleTrans
, 0.0, 1.0, 'set console transparency', 'set console transparency');
171 ConsoleHeight
:= 0.35;
174 ConsoleHeight
:= 0.5;