| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef __UI_SHARED_H |
| 23 |
#define __UI_SHARED_H |
| 24 |
|
| 25 |
|
| 26 |
#include "../qcommon/q_shared.h" |
| 27 |
#include "../renderercommon/tr_types.h" |
| 28 |
#include "../client/keycodes.h" |
| 29 |
|
| 30 |
#include "../../ui/menudef.h" |
| 31 |
|
| 32 |
#define MAX_MENUNAME 32 |
| 33 |
#define MAX_ITEMTEXT 64 |
| 34 |
#define MAX_ITEMACTION 64 |
| 35 |
#define MAX_MENUDEFFILE 4096 |
| 36 |
#define MAX_MENUFILE 32768 |
| 37 |
#define MAX_MENUS 64 |
| 38 |
#define MAX_MENUITEMS 96 |
| 39 |
#define MAX_COLOR_RANGES 10 |
| 40 |
#define MAX_OPEN_MENUS 16 |
| 41 |
|
| 42 |
#define WINDOW_MOUSEOVER 0x00000001 // mouse is over it, non exclusive |
| 43 |
#define WINDOW_HASFOCUS 0x00000002 // has cursor focus, exclusive |
| 44 |
#define WINDOW_VISIBLE 0x00000004 // is visible |
| 45 |
#define WINDOW_GREY 0x00000008 // is visible but grey ( non-active ) |
| 46 |
#define WINDOW_DECORATION 0x00000010 // for decoration only, no mouse, keyboard, etc.. |
| 47 |
#define WINDOW_FADINGOUT 0x00000020 // fading out, non-active |
| 48 |
#define WINDOW_FADINGIN 0x00000040 // fading in |
| 49 |
#define WINDOW_MOUSEOVERTEXT 0x00000080 // mouse is over it, non exclusive |
| 50 |
#define WINDOW_INTRANSITION 0x00000100 // window is in transition |
| 51 |
#define WINDOW_FORECOLORSET 0x00000200 // forecolor was explicitly set ( used to color alpha images or not ) |
| 52 |
#define WINDOW_HORIZONTAL 0x00000400 // for list boxes and sliders, vertical is default this is set of horizontal |
| 53 |
#define WINDOW_LB_LEFTARROW 0x00000800 // mouse is over left/up arrow |
| 54 |
#define WINDOW_LB_RIGHTARROW 0x00001000 // mouse is over right/down arrow |
| 55 |
#define WINDOW_LB_THUMB 0x00002000 // mouse is over thumb |
| 56 |
#define WINDOW_LB_PGUP 0x00004000 // mouse is over page up |
| 57 |
#define WINDOW_LB_PGDN 0x00008000 // mouse is over page down |
| 58 |
#define WINDOW_ORBITING 0x00010000 // item is in orbit |
| 59 |
#define WINDOW_OOB_CLICK 0x00020000 // close on out of bounds click |
| 60 |
#define WINDOW_WRAPPED 0x00040000 // manually wrap text |
| 61 |
#define WINDOW_AUTOWRAPPED 0x00080000 // auto wrap text |
| 62 |
#define WINDOW_FORCED 0x00100000 // forced open |
| 63 |
#define WINDOW_POPUP 0x00200000 // popup |
| 64 |
#define WINDOW_BACKCOLORSET 0x00400000 // backcolor was explicitly set |
| 65 |
#define WINDOW_TIMEDVISIBLE 0x00800000 // visibility timing ( NOT implemented ) |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
#define CURSOR_NONE 0x00000001 |
| 70 |
#define CURSOR_ARROW 0x00000002 |
| 71 |
#define CURSOR_SIZER 0x00000004 |
| 72 |
|
| 73 |
#ifdef CGAME |
| 74 |
#define STRING_POOL_SIZE 128*1024 |
| 75 |
#else |
| 76 |
#define STRING_POOL_SIZE 384*1024 |
| 77 |
#endif |
| 78 |
#define MAX_STRING_HANDLES 4096 |
| 79 |
|
| 80 |
#define MAX_SCRIPT_ARGS 12 |
| 81 |
#define MAX_EDITFIELD 256 |
| 82 |
|
| 83 |
#define ART_FX_BASE "menu/art/fx_base" |
| 84 |
#define ART_FX_BLUE "menu/art/fx_blue" |
| 85 |
#define ART_FX_CYAN "menu/art/fx_cyan" |
| 86 |
#define ART_FX_GREEN "menu/art/fx_grn" |
| 87 |
#define ART_FX_RED "menu/art/fx_red" |
| 88 |
#define ART_FX_TEAL "menu/art/fx_teal" |
| 89 |
#define ART_FX_WHITE "menu/art/fx_white" |
| 90 |
#define ART_FX_YELLOW "menu/art/fx_yel" |
| 91 |
|
| 92 |
#define ASSET_GRADIENTBAR "ui/assets/gradientbar2.tga" |
| 93 |
#define ASSET_SCROLLBAR "ui/assets/scrollbar.tga" |
| 94 |
#define ASSET_SCROLLBAR_ARROWDOWN "ui/assets/scrollbar_arrow_dwn_a.tga" |
| 95 |
#define ASSET_SCROLLBAR_ARROWUP "ui/assets/scrollbar_arrow_up_a.tga" |
| 96 |
#define ASSET_SCROLLBAR_ARROWLEFT "ui/assets/scrollbar_arrow_left.tga" |
| 97 |
#define ASSET_SCROLLBAR_ARROWRIGHT "ui/assets/scrollbar_arrow_right.tga" |
| 98 |
#define ASSET_SCROLL_THUMB "ui/assets/scrollbar_thumb.tga" |
| 99 |
#define ASSET_SLIDER_BAR "ui/assets/slider2.tga" |
| 100 |
#define ASSET_SLIDER_THUMB "ui/assets/sliderbutt_1.tga" |
| 101 |
#define SCROLLBAR_SIZE 16.0 |
| 102 |
#define SLIDER_WIDTH 96.0 |
| 103 |
#define SLIDER_HEIGHT 16.0 |
| 104 |
#define SLIDER_THUMB_WIDTH 12.0 |
| 105 |
#define SLIDER_THUMB_HEIGHT 20.0 |
| 106 |
#define NUM_CROSSHAIRS 10 |
| 107 |
|
| 108 |
typedef struct { |
| 109 |
const char *command; |
| 110 |
const char *args[MAX_SCRIPT_ARGS]; |
| 111 |
} scriptDef_t; |
| 112 |
|
| 113 |
|
| 114 |
typedef struct { |
| 115 |
float x; |
| 116 |
float y; |
| 117 |
float w; |
| 118 |
float h; |
| 119 |
} rectDef_t; |
| 120 |
|
| 121 |
typedef rectDef_t Rectangle; |
| 122 |
|
| 123 |
|
| 124 |
typedef struct { |
| 125 |
Rectangle rect; |
| 126 |
Rectangle rectClient; |
| 127 |
const char *name; |
| 128 |
const char *group; |
| 129 |
const char *cinematicName; |
| 130 |
int cinematic; |
| 131 |
int style; |
| 132 |
int border; |
| 133 |
int ownerDraw; |
| 134 |
int ownerDrawFlags; |
| 135 |
float borderSize; |
| 136 |
int flags; |
| 137 |
Rectangle rectEffects; |
| 138 |
Rectangle rectEffects2; |
| 139 |
int offsetTime; |
| 140 |
int nextTime; |
| 141 |
vec4_t foreColor; |
| 142 |
vec4_t backColor; |
| 143 |
vec4_t borderColor; |
| 144 |
vec4_t outlineColor; |
| 145 |
qhandle_t background; |
| 146 |
} windowDef_t; |
| 147 |
|
| 148 |
typedef windowDef_t Window; |
| 149 |
|
| 150 |
typedef struct { |
| 151 |
vec4_t color; |
| 152 |
float low; |
| 153 |
float high; |
| 154 |
} colorRangeDef_t; |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
#define MAX_LB_COLUMNS 16 |
| 167 |
|
| 168 |
typedef struct columnInfo_s { |
| 169 |
int pos; |
| 170 |
int width; |
| 171 |
int maxChars; |
| 172 |
} columnInfo_t; |
| 173 |
|
| 174 |
typedef struct listBoxDef_s { |
| 175 |
int startPos; |
| 176 |
int endPos; |
| 177 |
int drawPadding; |
| 178 |
int cursorPos; |
| 179 |
float elementWidth; |
| 180 |
float elementHeight; |
| 181 |
int elementStyle; |
| 182 |
int numColumns; |
| 183 |
columnInfo_t columnInfo[MAX_LB_COLUMNS]; |
| 184 |
const char *doubleClick; |
| 185 |
qboolean notselectable; |
| 186 |
} listBoxDef_t; |
| 187 |
|
| 188 |
typedef struct editFieldDef_s { |
| 189 |
float minVal; |
| 190 |
float maxVal; |
| 191 |
float defVal; |
| 192 |
float range; |
| 193 |
int maxChars; |
| 194 |
int maxPaintChars; |
| 195 |
int paintOffset; |
| 196 |
} editFieldDef_t; |
| 197 |
|
| 198 |
#define MAX_MULTI_CVARS 32 |
| 199 |
|
| 200 |
typedef struct multiDef_s { |
| 201 |
const char *cvarList[MAX_MULTI_CVARS]; |
| 202 |
const char *cvarStr[MAX_MULTI_CVARS]; |
| 203 |
float cvarValue[MAX_MULTI_CVARS]; |
| 204 |
int count; |
| 205 |
qboolean strDef; |
| 206 |
qboolean videoMode; |
| 207 |
} multiDef_t; |
| 208 |
|
| 209 |
typedef struct modelDef_s { |
| 210 |
int angle; |
| 211 |
vec3_t origin; |
| 212 |
float fov_x; |
| 213 |
float fov_y; |
| 214 |
int rotationSpeed; |
| 215 |
} modelDef_t; |
| 216 |
|
| 217 |
#define CVAR_ENABLE 0x00000001 |
| 218 |
#define CVAR_DISABLE 0x00000002 |
| 219 |
#define CVAR_SHOW 0x00000004 |
| 220 |
#define CVAR_HIDE 0x00000008 |
| 221 |
|
| 222 |
typedef struct itemDef_s { |
| 223 |
Window window; |
| 224 |
Rectangle textRect; |
| 225 |
int type; |
| 226 |
int alignment; |
| 227 |
int textalignment; |
| 228 |
float textalignx; |
| 229 |
float textaligny; |
| 230 |
float textscale; |
| 231 |
int textStyle; |
| 232 |
const char *text; |
| 233 |
void *parent; |
| 234 |
qhandle_t asset; |
| 235 |
const char *mouseEnterText; |
| 236 |
const char *mouseExitText; |
| 237 |
const char *mouseEnter; |
| 238 |
const char *mouseExit; |
| 239 |
const char *action; |
| 240 |
const char *onFocus; |
| 241 |
const char *leaveFocus; |
| 242 |
const char *cvar; |
| 243 |
const char *cvarTest; |
| 244 |
const char *enableCvar; |
| 245 |
int cvarFlags; |
| 246 |
sfxHandle_t focusSound; |
| 247 |
int numColors; |
| 248 |
colorRangeDef_t colorRanges[MAX_COLOR_RANGES]; |
| 249 |
float special; |
| 250 |
int cursorPos; |
| 251 |
void *typeData; |
| 252 |
} itemDef_t; |
| 253 |
|
| 254 |
typedef struct { |
| 255 |
Window window; |
| 256 |
const char *font; |
| 257 |
qboolean fullScreen; |
| 258 |
int itemCount; |
| 259 |
int fontIndex; |
| 260 |
int cursorItem; |
| 261 |
int fadeCycle; |
| 262 |
float fadeClamp; |
| 263 |
float fadeAmount; |
| 264 |
const char *onOpen; |
| 265 |
const char *onClose; |
| 266 |
const char *onESC; |
| 267 |
const char *soundName; |
| 268 |
|
| 269 |
vec4_t focusColor; |
| 270 |
vec4_t disableColor; |
| 271 |
itemDef_t *items[MAX_MENUITEMS]; |
| 272 |
} menuDef_t; |
| 273 |
|
| 274 |
typedef struct { |
| 275 |
const char *fontStr; |
| 276 |
const char *cursorStr; |
| 277 |
const char *gradientStr; |
| 278 |
fontInfo_t textFont; |
| 279 |
fontInfo_t smallFont; |
| 280 |
fontInfo_t bigFont; |
| 281 |
qhandle_t cursor; |
| 282 |
qhandle_t gradientBar; |
| 283 |
qhandle_t scrollBarArrowUp; |
| 284 |
qhandle_t scrollBarArrowDown; |
| 285 |
qhandle_t scrollBarArrowLeft; |
| 286 |
qhandle_t scrollBarArrowRight; |
| 287 |
qhandle_t scrollBar; |
| 288 |
qhandle_t scrollBarThumb; |
| 289 |
qhandle_t buttonMiddle; |
| 290 |
qhandle_t buttonInside; |
| 291 |
qhandle_t solidBox; |
| 292 |
qhandle_t sliderBar; |
| 293 |
qhandle_t sliderThumb; |
| 294 |
sfxHandle_t menuEnterSound; |
| 295 |
sfxHandle_t menuExitSound; |
| 296 |
sfxHandle_t menuBuzzSound; |
| 297 |
sfxHandle_t itemFocusSound; |
| 298 |
float fadeClamp; |
| 299 |
int fadeCycle; |
| 300 |
float fadeAmount; |
| 301 |
float shadowX; |
| 302 |
float shadowY; |
| 303 |
vec4_t shadowColor; |
| 304 |
float shadowFadeClamp; |
| 305 |
qboolean fontRegistered; |
| 306 |
|
| 307 |
|
| 308 |
qhandle_t fxBasePic; |
| 309 |
qhandle_t fxPic[7]; |
| 310 |
qhandle_t crosshairShader[NUM_CROSSHAIRS]; |
| 311 |
|
| 312 |
} cachedAssets_t; |
| 313 |
|
| 314 |
typedef struct { |
| 315 |
const char *name; |
| 316 |
void (*handler) (itemDef_t *item, char** args); |
| 317 |
} commandDef_t; |
| 318 |
|
| 319 |
typedef struct { |
| 320 |
qhandle_t (*registerShaderNoMip) (const char *p); |
| 321 |
void (*setColor) (const vec4_t v); |
| 322 |
void (*drawHandlePic) (float x, float y, float w, float h, qhandle_t asset); |
| 323 |
void (*drawStretchPic) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); |
| 324 |
void (*drawText) (float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style ); |
| 325 |
int (*textWidth) (const char *text, float scale, int limit); |
| 326 |
int (*textHeight) (const char *text, float scale, int limit); |
| 327 |
qhandle_t (*registerModel) (const char *p); |
| 328 |
void (*modelBounds) (qhandle_t model, vec3_t min, vec3_t max); |
| 329 |
void (*fillRect) ( float x, float y, float w, float h, const vec4_t color); |
| 330 |
void (*drawRect) ( float x, float y, float w, float h, float size, const vec4_t color); |
| 331 |
void (*drawSides) (float x, float y, float w, float h, float size); |
| 332 |
void (*drawTopBottom) (float x, float y, float w, float h, float size); |
| 333 |
void (*clearScene) ( void ); |
| 334 |
void (*addRefEntityToScene) (const refEntity_t *re ); |
| 335 |
void (*renderScene) ( const refdef_t *fd ); |
| 336 |
void (*registerFont) (const char *pFontname, int pointSize, fontInfo_t *font); |
| 337 |
void (*ownerDrawItem) (float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle); |
| 338 |
float (*getValue) (int ownerDraw); |
| 339 |
qboolean (*ownerDrawVisible) (int flags); |
| 340 |
void (*runScript)(char **p); |
| 341 |
void (*getTeamColor)(vec4_t *color); |
| 342 |
void (*getCVarString)(const char *cvar, char *buffer, int bufsize); |
| 343 |
float (*getCVarValue)(const char *cvar); |
| 344 |
void (*setCVar)(const char *cvar, const char *value); |
| 345 |
void (*drawTextWithCursor)(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style); |
| 346 |
void (*setOverstrikeMode)(qboolean b); |
| 347 |
qboolean (*getOverstrikeMode)( void ); |
| 348 |
void (*startLocalSound)( sfxHandle_t sfx, int channelNum ); |
| 349 |
qboolean (*ownerDrawHandleKey)(int ownerDraw, int flags, float *special, int key); |
| 350 |
int (*feederCount)(float feederID); |
| 351 |
const char *(*feederItemText)(float feederID, int index, int column, qhandle_t *handle); |
| 352 |
qhandle_t (*feederItemImage)(float feederID, int index); |
| 353 |
void (*feederSelection)(float feederID, int index); |
| 354 |
void (*keynumToStringBuf)( int keynum, char *buf, int buflen ); |
| 355 |
void (*getBindingBuf)( int keynum, char *buf, int buflen ); |
| 356 |
void (*setBinding)( int keynum, const char *binding ); |
| 357 |
void (*executeText)(int exec_when, const char *text ); |
| 358 |
void (*Error)(int level, const char *error, ...) Q_NO_RETURN Q_PRINTF_FUNC(2, 3); |
| 359 |
void (*Print)(const char *msg, ...) Q_PRINTF_FUNC(1, 2); |
| 360 |
void (*Pause)(qboolean b); |
| 361 |
int (*ownerDrawWidth)(int ownerDraw, float scale); |
| 362 |
sfxHandle_t (*registerSound)(const char *name, qboolean compressed); |
| 363 |
void (*startBackgroundTrack)( const char *intro, const char *loop); |
| 364 |
void (*stopBackgroundTrack)( void ); |
| 365 |
int (*playCinematic)(const char *name, float x, float y, float w, float h); |
| 366 |
void (*stopCinematic)(int handle); |
| 367 |
void (*drawCinematic)(int handle, float x, float y, float w, float h); |
| 368 |
void (*runCinematicFrame)(int handle); |
| 369 |
|
| 370 |
float yscale; |
| 371 |
float xscale; |
| 372 |
float bias; |
| 373 |
int realTime; |
| 374 |
int frameTime; |
| 375 |
int cursorx; |
| 376 |
int cursory; |
| 377 |
qboolean debug; |
| 378 |
|
| 379 |
cachedAssets_t Assets; |
| 380 |
|
| 381 |
glconfig_t glconfig; |
| 382 |
qhandle_t whiteShader; |
| 383 |
qhandle_t gradientImage; |
| 384 |
qhandle_t cursor; |
| 385 |
float FPS; |
| 386 |
|
| 387 |
} displayContextDef_t; |
| 388 |
|
| 389 |
const char *String_Alloc(const char *p); |
| 390 |
void String_Init( void ); |
| 391 |
void String_Report( void ); |
| 392 |
void Init_Display(displayContextDef_t *dc); |
| 393 |
void Display_ExpandMacros(char * buff); |
| 394 |
void Menu_Init(menuDef_t *menu); |
| 395 |
void Item_Init(itemDef_t *item); |
| 396 |
void Menu_PostParse(menuDef_t *menu); |
| 397 |
menuDef_t *Menu_GetFocused( void ); |
| 398 |
void Menu_HandleKey(menuDef_t *menu, int key, qboolean down); |
| 399 |
void Menu_HandleMouseMove(menuDef_t *menu, float x, float y); |
| 400 |
void Menu_ScrollFeeder(menuDef_t *menu, int feeder, qboolean down); |
| 401 |
qboolean Float_Parse(char **p, float *f); |
| 402 |
qboolean Color_Parse(char **p, vec4_t *c); |
| 403 |
qboolean Int_Parse(char **p, int *i); |
| 404 |
qboolean Rect_Parse(char **p, rectDef_t *r); |
| 405 |
qboolean String_Parse(char **p, const char **out); |
| 406 |
qboolean Script_Parse(char **p, const char **out); |
| 407 |
qboolean PC_Float_Parse(int handle, float *f); |
| 408 |
qboolean PC_Color_Parse(int handle, vec4_t *c); |
| 409 |
qboolean PC_Int_Parse(int handle, int *i); |
| 410 |
qboolean PC_Rect_Parse(int handle, rectDef_t *r); |
| 411 |
qboolean PC_String_Parse(int handle, const char **out); |
| 412 |
qboolean PC_Script_Parse(int handle, const char **out); |
| 413 |
int Menu_Count( void ); |
| 414 |
void Menu_New(int handle); |
| 415 |
void Menu_PaintAll( void ); |
| 416 |
menuDef_t *Menus_ActivateByName(const char *p); |
| 417 |
void Menu_Reset( void ); |
| 418 |
qboolean Menus_AnyFullScreenVisible( void ); |
| 419 |
void Menus_Activate(menuDef_t *menu); |
| 420 |
|
| 421 |
int UI_SelectForKey(int key); |
| 422 |
displayContextDef_t *Display_GetContext( void ); |
| 423 |
void *Display_CaptureItem(int x, int y); |
| 424 |
qboolean Display_MouseMove(void *p, int x, int y); |
| 425 |
int Display_CursorType(int x, int y); |
| 426 |
qboolean Display_KeyBindPending( void ); |
| 427 |
void Menus_OpenByName(const char *p); |
| 428 |
menuDef_t *Menus_FindByName(const char *p); |
| 429 |
void Menus_ShowByName(const char *p); |
| 430 |
void Menus_CloseByName(const char *p); |
| 431 |
void Display_HandleKey(int key, qboolean down, int x, int y); |
| 432 |
void LerpColor(vec4_t a, vec4_t b, vec4_t c, float t); |
| 433 |
void Menus_CloseAll( void ); |
| 434 |
void Menu_Paint(menuDef_t *menu, qboolean forcePaint); |
| 435 |
void Menu_SetFeederSelection(menuDef_t *menu, int feeder, int index, const char *name); |
| 436 |
void Display_CacheAll( void ); |
| 437 |
|
| 438 |
void *UI_Alloc( int size ); |
| 439 |
void UI_InitMemory( void ); |
| 440 |
qboolean UI_OutOfMemory( void ); |
| 441 |
|
| 442 |
void Controls_GetConfig( void ); |
| 443 |
void Controls_SetConfig(qboolean restart); |
| 444 |
void Controls_SetDefaults( void ); |
| 445 |
|
| 446 |
int trap_PC_AddGlobalDefine( char *define ); |
| 447 |
int trap_PC_LoadSource( const char *filename ); |
| 448 |
int trap_PC_FreeSource( int handle ); |
| 449 |
int trap_PC_ReadToken( int handle, pc_token_t *pc_token ); |
| 450 |
int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ); |
| 451 |
|
| 452 |
#endif |