1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
Copyright (C) 2000-2006 Tim Angus
This file is part of Tremulous.
Tremulous is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Tremulous is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Tremulous; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/**********************************************************************
UI_ATOMS.C
User interface building blocks and support functions.
**********************************************************************/
#include "ui_local.h"
qboolean m_entersound; // after a frame, so caching won't disrupt the sound
void QDECL Com_Error( int level, const char *error, ... )
{
va_list argptr;
char text[1024];
va_start ( argptr, error );
vsprintf ( text, error, argptr );
va_end ( argptr );
trap_Error( va( "%s", text ) );
}
void QDECL Com_Printf( const char *msg, ... )
{
va_list argptr;
char text[1024];
va_start ( argptr, msg );
vsprintf ( text, msg, argptr );
va_end ( argptr );
trap_Print( va( "%s", text ) );
}
/*
=================
UI_ClampCvar
=================
*/
float UI_ClampCvar( float min, float max, float value )
{
if( value < min ) return min;
if( value > max ) return max;
return value;
}
/*
=================
UI_StartDemoLoop
=================
*/
void UI_StartDemoLoop( void )
{
trap_Cmd_ExecuteText( EXEC_APPEND, "d1\n" );
}
char *UI_Argv( int arg )
{
static char buffer[MAX_STRING_CHARS];
trap_Argv( arg, buffer, sizeof( buffer ) );
return buffer;
}
char *UI_Cvar_VariableString( const char *var_name )
{
static char buffer[MAX_STRING_CHARS];
trap_Cvar_VariableStringBuffer( var_name, buffer, sizeof( buffer ) );
return buffer;
}
static void UI_Cache_f( void )
{
Display_CacheAll();
}
/*
=================
UI_ConsoleCommand
FIXME: lookup table
=================
*/
qboolean UI_ConsoleCommand( int realTime )
{
char * cmd;
char *arg1;
uiInfo.uiDC.frameTime = realTime - uiInfo.uiDC.realTime;
uiInfo.uiDC.realTime = realTime;
cmd = UI_Argv( 0 );
// ensure minimum menu data is available
//Menu_Cache();
if( Q_stricmp ( cmd, "ui_report" ) == 0 )
{
UI_Report();
return qtrue;
}
if( Q_stricmp ( cmd, "ui_load" ) == 0 )
{
UI_Load();
return qtrue;
}
if( Q_stricmp ( cmd, "remapShader" ) == 0 )
{
if( trap_Argc() == 4 )
{
char shader1[MAX_QPATH];
char shader2[MAX_QPATH];
Q_strncpyz( shader1, UI_Argv( 1 ), sizeof( shader1 ) );
Q_strncpyz( shader2, UI_Argv( 2 ), sizeof( shader2 ) );
trap_R_RemapShader( shader1, shader2, UI_Argv( 3 ) );
return qtrue;
}
}
if( Q_stricmp ( cmd, "ui_cache" ) == 0 )
{
UI_Cache_f();
return qtrue;
}
if( Q_stricmp ( cmd, "ui_teamOrders" ) == 0 )
{
//UI_TeamOrdersMenu_f();
return qtrue;
}
if( Q_stricmp( cmd, "ui_messagemode" ) == 0 )
{
trap_Cvar_Set( "ui_sayBuffer", "" );
uiInfo.chatTeam = qfalse;
trap_Key_SetCatcher( KEYCATCH_UI );
Menus_CloseByName( "say" );
Menus_CloseByName( "say_team" );
Menus_ActivateByName( "say" );
return qtrue;
}
if( Q_stricmp( cmd, "ui_messagemode2" ) == 0 )
{
trap_Cvar_Set( "ui_sayBuffer", "" );
uiInfo.chatTargetClientNum = -1;
uiInfo.chatTeam = qtrue;
trap_Key_SetCatcher( KEYCATCH_UI );
Menus_CloseByName( "say" );
Menus_CloseByName( "say_team" );
Menus_ActivateByName( "say_team" );
return qtrue;
}
if( Q_stricmp ( cmd, "menu" ) == 0 )
{
arg1 = UI_Argv( 1 );
if( Menu_Count( ) > 0 )
{
trap_Key_SetCatcher( KEYCATCH_UI );
Menus_ActivateByName( arg1 );
return qtrue;
}
}
if( Q_stricmp ( cmd, "closemenus" ) == 0 )
{
if( Menu_Count( ) > 0 )
{
Menus_CloseAll( qfalse );
if( Menu_Count( ) == 0 )
{
trap_Key_SetCatcher( trap_Key_GetCatcher( ) & ~KEYCATCH_UI );
trap_Key_ClearStates( );
trap_Cvar_Set( "cl_paused", "0" );
}
}
return qtrue;
}
return qfalse;
}
void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname )
{
qhandle_t hShader;
hShader = trap_R_RegisterShaderNoMip( picname );
UI_AdjustFrom640( &x, &y, &width, &height );
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
}
void UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader )
{
float s0;
float s1;
float t0;
float t1;
if( w < 0 )
{ // flip about vertical
w = -w;
s0 = 1;
s1 = 0;
}
else
{
s0 = 0;
s1 = 1;
}
if( h < 0 )
{ // flip about horizontal
h = -h;
t0 = 1;
t1 = 0;
}
else
{
t0 = 0;
t1 = 1;
}
UI_AdjustFrom640( &x, &y, &w, &h );
trap_R_DrawStretchPic( x, y, w, h, s0, t0, s1, t1, hShader );
}
/*
================
UI_FillRect
Coordinates are 640*480 virtual values
=================
*/
void UI_FillRect( float x, float y, float width, float height, const float *color )
{
trap_R_SetColor( color );
UI_AdjustFrom640( &x, &y, &width, &height );
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
trap_R_SetColor( NULL );
}
void UI_SetColor( const float *rgba )
{
trap_R_SetColor( rgba );
}
|