Itsa me, quake3io!

This commit is contained in:
Zachary Slater 2005-08-26 04:48:05 +00:00
parent dbe4ddb103
commit 5b755058f5
1409 changed files with 798983 additions and 798983 deletions

124
code/ui/Conscript Normal file → Executable file
View file

@ -1,62 +1,62 @@
# TA ui building
# qvm building against native:
# only native has ui_syscalls.c
# qvm uses a custom ui_syscalls.asm with equ stubs
# qvm has additional bg_lib.c
Import qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
$env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#ui',
CC => $CC,
CXX => $CXX,
LINK => $LINK,
ENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },
CFLAGS => $BASE_CFLAGS . '-DMISSIONPACK -fPIC',
LDFLAGS => '-shared -ldl -lm'
);
# qvm building
# we heavily customize the cons environment
$vm_env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#ui',
CC => 'q3lcc',
CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',
SUFOBJ => '.asm',
LINK => 'q3asm',
CFLAGS => '-DQ3_VM -DMISSIONPACK -S -Wf-target=bytecode -Wf-g',
# need to know where to find the compiler tools
ENV => { PATH => $ENV{PATH} . ":./qvmtools", },
);
# the file with vmMain function MUST be the first one of the list
@FILES = qw(
ui_main.c
ui_atoms.c
ui_gameinfo.c
ui_players.c
ui_util.c
ui_shared.c
../game/bg_misc.c
../game/q_math.c
../game/q_shared.c
);
$FILESREF = \@FILES;
if ($NO_SO eq 0)
{
Program $env 'uii386.so', @$FILESREF, 'ui_syscalls.c';
Install $env $INSTALL_DIR, 'uii386.so';
}
if ($NO_VM eq 0)
{
Depends $vm_env 'ui.qvm', '#qvmtools/q3lcc';
Depends $vm_env 'ui.qvm', '#qvmtools/q3asm';
Program $vm_env 'ui.qvm', @$FILESREF, '../game/bg_lib.c', 'ui_syscalls.asm';
Install $vm_env $INSTALL_DIR . '/vm', 'ui.qvm';
}
# TA ui building
# qvm building against native:
# only native has ui_syscalls.c
# qvm uses a custom ui_syscalls.asm with equ stubs
# qvm has additional bg_lib.c
Import qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
$env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#ui',
CC => $CC,
CXX => $CXX,
LINK => $LINK,
ENV => { PATH => $ENV{PATH}, HOME => $ENV{HOME} },
CFLAGS => $BASE_CFLAGS . '-DMISSIONPACK -fPIC',
LDFLAGS => '-shared -ldl -lm'
);
# qvm building
# we heavily customize the cons environment
$vm_env = new cons(
# the code has the very bad habit of doing things like #include "../ui/ui_shared.h"
# this seems to confuse the dependency analysis, explicit toplevel includes seem to fix
CPPPATH => '#cgame:#game:#ui',
CC => 'q3lcc',
CCCOM => '%CC %CFLAGS %_IFLAGS -c %< -o %>',
SUFOBJ => '.asm',
LINK => 'q3asm',
CFLAGS => '-DQ3_VM -DMISSIONPACK -S -Wf-target=bytecode -Wf-g',
# need to know where to find the compiler tools
ENV => { PATH => $ENV{PATH} . ":./qvmtools", },
);
# the file with vmMain function MUST be the first one of the list
@FILES = qw(
ui_main.c
ui_atoms.c
ui_gameinfo.c
ui_players.c
ui_util.c
ui_shared.c
../game/bg_misc.c
../game/q_math.c
../game/q_shared.c
);
$FILESREF = \@FILES;
if ($NO_SO eq 0)
{
Program $env 'uii386.so', @$FILESREF, 'ui_syscalls.c';
Install $env $INSTALL_DIR, 'uii386.so';
}
if ($NO_VM eq 0)
{
Depends $vm_env 'ui.qvm', '#qvmtools/q3lcc';
Depends $vm_env 'ui.qvm', '#qvmtools/q3asm';
Program $vm_env 'ui.qvm', @$FILESREF, '../game/bg_lib.c', 'ui_syscalls.asm';
Install $vm_env $INSTALL_DIR . '/vm', 'ui.qvm';
}

4
code/ui/compile.bat Normal file → Executable file
View file

@ -1,2 +1,2 @@
lcc -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1
lcc -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1

326
code/ui/keycodes.h Normal file → Executable file
View file

@ -1,163 +1,163 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#ifndef __KEYCODES_H__
#define __KEYCODES_H__
//
// these are the key numbers that should be passed to KeyEvent
//
// normal keys should be passed as lowercased ascii
typedef enum {
K_TAB = 9,
K_ENTER = 13,
K_ESCAPE = 27,
K_SPACE = 32,
K_BACKSPACE = 127,
K_COMMAND = 128,
K_CAPSLOCK,
K_POWER,
K_PAUSE,
K_UPARROW,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
K_ALT,
K_CTRL,
K_SHIFT,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_F13,
K_F14,
K_F15,
K_KP_HOME,
K_KP_UPARROW,
K_KP_PGUP,
K_KP_LEFTARROW,
K_KP_5,
K_KP_RIGHTARROW,
K_KP_END,
K_KP_DOWNARROW,
K_KP_PGDN,
K_KP_ENTER,
K_KP_INS,
K_KP_DEL,
K_KP_SLASH,
K_KP_MINUS,
K_KP_PLUS,
K_KP_NUMLOCK,
K_KP_STAR,
K_KP_EQUALS,
K_MOUSE1,
K_MOUSE2,
K_MOUSE3,
K_MOUSE4,
K_MOUSE5,
K_MWHEELDOWN,
K_MWHEELUP,
K_JOY1,
K_JOY2,
K_JOY3,
K_JOY4,
K_JOY5,
K_JOY6,
K_JOY7,
K_JOY8,
K_JOY9,
K_JOY10,
K_JOY11,
K_JOY12,
K_JOY13,
K_JOY14,
K_JOY15,
K_JOY16,
K_JOY17,
K_JOY18,
K_JOY19,
K_JOY20,
K_JOY21,
K_JOY22,
K_JOY23,
K_JOY24,
K_JOY25,
K_JOY26,
K_JOY27,
K_JOY28,
K_JOY29,
K_JOY30,
K_JOY31,
K_JOY32,
K_AUX1,
K_AUX2,
K_AUX3,
K_AUX4,
K_AUX5,
K_AUX6,
K_AUX7,
K_AUX8,
K_AUX9,
K_AUX10,
K_AUX11,
K_AUX12,
K_AUX13,
K_AUX14,
K_AUX15,
K_AUX16,
K_LAST_KEY // this had better be <256!
} keyNum_t;
// The menu code needs to get both key and char events, but
// to avoid duplicating the paths, the char events are just
// distinguished by or'ing in K_CHAR_FLAG (ugly)
#define K_CHAR_FLAG 1024
#endif
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#ifndef __KEYCODES_H__
#define __KEYCODES_H__
//
// these are the key numbers that should be passed to KeyEvent
//
// normal keys should be passed as lowercased ascii
typedef enum {
K_TAB = 9,
K_ENTER = 13,
K_ESCAPE = 27,
K_SPACE = 32,
K_BACKSPACE = 127,
K_COMMAND = 128,
K_CAPSLOCK,
K_POWER,
K_PAUSE,
K_UPARROW,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
K_ALT,
K_CTRL,
K_SHIFT,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_F13,
K_F14,
K_F15,
K_KP_HOME,
K_KP_UPARROW,
K_KP_PGUP,
K_KP_LEFTARROW,
K_KP_5,
K_KP_RIGHTARROW,
K_KP_END,
K_KP_DOWNARROW,
K_KP_PGDN,
K_KP_ENTER,
K_KP_INS,
K_KP_DEL,
K_KP_SLASH,
K_KP_MINUS,
K_KP_PLUS,
K_KP_NUMLOCK,
K_KP_STAR,
K_KP_EQUALS,
K_MOUSE1,
K_MOUSE2,
K_MOUSE3,
K_MOUSE4,
K_MOUSE5,
K_MWHEELDOWN,
K_MWHEELUP,
K_JOY1,
K_JOY2,
K_JOY3,
K_JOY4,
K_JOY5,
K_JOY6,
K_JOY7,
K_JOY8,
K_JOY9,
K_JOY10,
K_JOY11,
K_JOY12,
K_JOY13,
K_JOY14,
K_JOY15,
K_JOY16,
K_JOY17,
K_JOY18,
K_JOY19,
K_JOY20,
K_JOY21,
K_JOY22,
K_JOY23,
K_JOY24,
K_JOY25,
K_JOY26,
K_JOY27,
K_JOY28,
K_JOY29,
K_JOY30,
K_JOY31,
K_JOY32,
K_AUX1,
K_AUX2,
K_AUX3,
K_AUX4,
K_AUX5,
K_AUX6,
K_AUX7,
K_AUX8,
K_AUX9,
K_AUX10,
K_AUX11,
K_AUX12,
K_AUX13,
K_AUX14,
K_AUX15,
K_AUX16,
K_LAST_KEY // this had better be <256!
} keyNum_t;
// The menu code needs to get both key and char events, but
// to avoid duplicating the paths, the char events are just
// distinguished by or'ing in K_CHAR_FLAG (ugly)
#define K_CHAR_FLAG 1024
#endif

66
code/ui/ui.bat Normal file → Executable file
View file

@ -1,33 +1,33 @@
rem make sure we have a safe environement
set LIBRARY=
set INCLUDE=
mkdir vm
cd vm
set cc=lcc -DMISSIONPACK -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1
%cc% ../ui_main.c
@if errorlevel 1 goto quit
%cc% ../../game/bg_misc.c
@if errorlevel 1 goto quit
%cc% ../../game/bg_lib.c
@if errorlevel 1 goto quit
%cc% ../../game/q_math.c
@if errorlevel 1 goto quit
%cc% ../../game/q_shared.c
@if errorlevel 1 goto quit
%cc% ../ui_atoms.c
@if errorlevel 1 goto quit
%cc% ../ui_players.c
@if errorlevel 1 goto quit
%cc% ../ui_util.c
@if errorlevel 1 goto quit
%cc% ../ui_shared.c
@if errorlevel 1 goto quit
%cc% ../ui_gameinfo.c
@if errorlevel 1 goto quit
q3asm -f ../ui
:quit
cd ..
rem make sure we have a safe environement
set LIBRARY=
set INCLUDE=
mkdir vm
cd vm
set cc=lcc -DMISSIONPACK -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1
%cc% ../ui_main.c
@if errorlevel 1 goto quit
%cc% ../../game/bg_misc.c
@if errorlevel 1 goto quit
%cc% ../../game/bg_lib.c
@if errorlevel 1 goto quit
%cc% ../../game/q_math.c
@if errorlevel 1 goto quit
%cc% ../../game/q_shared.c
@if errorlevel 1 goto quit
%cc% ../ui_atoms.c
@if errorlevel 1 goto quit
%cc% ../ui_players.c
@if errorlevel 1 goto quit
%cc% ../ui_util.c
@if errorlevel 1 goto quit
%cc% ../ui_shared.c
@if errorlevel 1 goto quit
%cc% ../ui_gameinfo.c
@if errorlevel 1 goto quit
q3asm -f ../ui
:quit
cd ..

6
code/ui/ui.def Normal file → Executable file
View file

@ -1,3 +1,3 @@
EXPORTS
vmMain
dllEntry
EXPORTS
vmMain
dllEntry

24
code/ui/ui.q3asm Normal file → Executable file
View file

@ -1,12 +1,12 @@
-o "\quake3\missionpack\vm\ui"
ui_main
..\ui_syscalls
ui_atoms
ui_players
ui_util
ui_shared
ui_gameinfo
bg_misc
bg_lib
q_math
q_shared
-o "\quake3\missionpack\vm\ui"
ui_main
..\ui_syscalls
ui_atoms
ui_players
ui_util
ui_shared
ui_gameinfo
bg_misc
bg_lib
q_math
q_shared

2016
code/ui/ui.vcproj Normal file → Executable file

File diff suppressed because it is too large Load diff

1040
code/ui/ui_atoms.c Normal file → Executable file

File diff suppressed because it is too large Load diff

648
code/ui/ui_gameinfo.c Normal file → Executable file
View file

@ -1,324 +1,324 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// gameinfo.c
//
#include "ui_local.h"
//
// arena and bot info
//
int ui_numBots;
static char *ui_botInfos[MAX_BOTS];
static int ui_numArenas;
static char *ui_arenaInfos[MAX_ARENAS];
#ifndef MISSIONPACK // bk001206
static int ui_numSinglePlayerArenas;
static int ui_numSpecialSinglePlayerArenas;
#endif
/*
===============
UI_ParseInfos
===============
*/
int UI_ParseInfos( char *buf, int max, char *infos[] ) {
char *token;
int count;
char key[MAX_TOKEN_CHARS];
char info[MAX_INFO_STRING];
count = 0;
while ( 1 ) {
token = COM_Parse( &buf );
if ( !token[0] ) {
break;
}
if ( strcmp( token, "{" ) ) {
Com_Printf( "Missing { in info file\n" );
break;
}
if ( count == max ) {
Com_Printf( "Max infos exceeded\n" );
break;
}
info[0] = '\0';
while ( 1 ) {
token = COM_ParseExt( &buf, qtrue );
if ( !token[0] ) {
Com_Printf( "Unexpected end of info file\n" );
break;
}
if ( !strcmp( token, "}" ) ) {
break;
}
Q_strncpyz( key, token, sizeof( key ) );
token = COM_ParseExt( &buf, qfalse );
if ( !token[0] ) {
strcpy( token, "<NULL>" );
}
Info_SetValueForKey( info, key, token );
}
//NOTE: extra space for arena number
infos[count] = UI_Alloc(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1);
if (infos[count]) {
strcpy(infos[count], info);
count++;
}
}
return count;
}
/*
===============
UI_LoadArenasFromFile
===============
*/
static void UI_LoadArenasFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[MAX_ARENAS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
if ( len >= MAX_ARENAS_TEXT ) {
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
ui_numArenas += UI_ParseInfos( buf, MAX_ARENAS - ui_numArenas, &ui_arenaInfos[ui_numArenas] );
}
/*
===============
UI_LoadArenas
===============
*/
void UI_LoadArenas( void ) {
int numdirs;
vmCvar_t arenasFile;
char filename[128];
char dirlist[1024];
char* dirptr;
int i, n;
int dirlen;
char *type;
ui_numArenas = 0;
uiInfo.mapCount = 0;
trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
if( *arenasFile.string ) {
UI_LoadArenasFromFile(arenasFile.string);
}
else {
UI_LoadArenasFromFile("scripts/arenas.txt");
}
// get all arenas from .arena files
numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024 );
dirptr = dirlist;
for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
dirlen = strlen(dirptr);
strcpy(filename, "scripts/");
strcat(filename, dirptr);
UI_LoadArenasFromFile(filename);
}
trap_Print( va( "%i arenas parsed\n", ui_numArenas ) );
if (UI_OutOfMemory()) {
trap_Print(S_COLOR_YELLOW"WARNING: not anough memory in pool to load all arenas\n");
}
for( n = 0; n < ui_numArenas; n++ ) {
// determine type
uiInfo.mapList[uiInfo.mapCount].cinematic = -1;
uiInfo.mapList[uiInfo.mapCount].mapLoadName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "map"));
uiInfo.mapList[uiInfo.mapCount].mapName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "longname"));
uiInfo.mapList[uiInfo.mapCount].levelShot = -1;
uiInfo.mapList[uiInfo.mapCount].imageName = String_Alloc(va("levelshots/%s", uiInfo.mapList[uiInfo.mapCount].mapLoadName));
uiInfo.mapList[uiInfo.mapCount].typeBits = 0;
type = Info_ValueForKey( ui_arenaInfos[n], "type" );
// if no type specified, it will be treated as "ffa"
if( *type ) {
if( strstr( type, "ffa" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);
}
if( strstr( type, "tourney" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_TOURNAMENT);
}
if( strstr( type, "ctf" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_CTF);
}
if( strstr( type, "oneflag" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_1FCTF);
}
if( strstr( type, "overload" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_OBELISK);
}
if( strstr( type, "harvester" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_HARVESTER);
}
} else {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);
}
uiInfo.mapCount++;
if (uiInfo.mapCount >= MAX_MAPS) {
break;
}
}
}
/*
===============
UI_LoadBotsFromFile
===============
*/
static void UI_LoadBotsFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[MAX_BOTS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
if ( len >= MAX_BOTS_TEXT ) {
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_BOTS_TEXT ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
COM_Compress(buf);
ui_numBots += UI_ParseInfos( buf, MAX_BOTS - ui_numBots, &ui_botInfos[ui_numBots] );
}
/*
===============
UI_LoadBots
===============
*/
void UI_LoadBots( void ) {
vmCvar_t botsFile;
int numdirs;
char filename[128];
char dirlist[1024];
char* dirptr;
int i;
int dirlen;
ui_numBots = 0;
trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM );
if( *botsFile.string ) {
UI_LoadBotsFromFile(botsFile.string);
}
else {
UI_LoadBotsFromFile("scripts/bots.txt");
}
// get all bots from .bot files
numdirs = trap_FS_GetFileList("scripts", ".bot", dirlist, 1024 );
dirptr = dirlist;
for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
dirlen = strlen(dirptr);
strcpy(filename, "scripts/");
strcat(filename, dirptr);
UI_LoadBotsFromFile(filename);
}
trap_Print( va( "%i bots parsed\n", ui_numBots ) );
}
/*
===============
UI_GetBotInfoByNumber
===============
*/
char *UI_GetBotInfoByNumber( int num ) {
if( num < 0 || num >= ui_numBots ) {
trap_Print( va( S_COLOR_RED "Invalid bot number: %i\n", num ) );
return NULL;
}
return ui_botInfos[num];
}
/*
===============
UI_GetBotInfoByName
===============
*/
char *UI_GetBotInfoByName( const char *name ) {
int n;
char *value;
for ( n = 0; n < ui_numBots ; n++ ) {
value = Info_ValueForKey( ui_botInfos[n], "name" );
if ( !Q_stricmp( value, name ) ) {
return ui_botInfos[n];
}
}
return NULL;
}
int UI_GetNumBots() {
return ui_numBots;
}
char *UI_GetBotNameByNumber( int num ) {
char *info = UI_GetBotInfoByNumber(num);
if (info) {
return Info_ValueForKey( info, "name" );
}
return "Sarge";
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
//
// gameinfo.c
//
#include "ui_local.h"
//
// arena and bot info
//
int ui_numBots;
static char *ui_botInfos[MAX_BOTS];
static int ui_numArenas;
static char *ui_arenaInfos[MAX_ARENAS];
#ifndef MISSIONPACK // bk001206
static int ui_numSinglePlayerArenas;
static int ui_numSpecialSinglePlayerArenas;
#endif
/*
===============
UI_ParseInfos
===============
*/
int UI_ParseInfos( char *buf, int max, char *infos[] ) {
char *token;
int count;
char key[MAX_TOKEN_CHARS];
char info[MAX_INFO_STRING];
count = 0;
while ( 1 ) {
token = COM_Parse( &buf );
if ( !token[0] ) {
break;
}
if ( strcmp( token, "{" ) ) {
Com_Printf( "Missing { in info file\n" );
break;
}
if ( count == max ) {
Com_Printf( "Max infos exceeded\n" );
break;
}
info[0] = '\0';
while ( 1 ) {
token = COM_ParseExt( &buf, qtrue );
if ( !token[0] ) {
Com_Printf( "Unexpected end of info file\n" );
break;
}
if ( !strcmp( token, "}" ) ) {
break;
}
Q_strncpyz( key, token, sizeof( key ) );
token = COM_ParseExt( &buf, qfalse );
if ( !token[0] ) {
strcpy( token, "<NULL>" );
}
Info_SetValueForKey( info, key, token );
}
//NOTE: extra space for arena number
infos[count] = UI_Alloc(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1);
if (infos[count]) {
strcpy(infos[count], info);
count++;
}
}
return count;
}
/*
===============
UI_LoadArenasFromFile
===============
*/
static void UI_LoadArenasFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[MAX_ARENAS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
if ( len >= MAX_ARENAS_TEXT ) {
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
ui_numArenas += UI_ParseInfos( buf, MAX_ARENAS - ui_numArenas, &ui_arenaInfos[ui_numArenas] );
}
/*
===============
UI_LoadArenas
===============
*/
void UI_LoadArenas( void ) {
int numdirs;
vmCvar_t arenasFile;
char filename[128];
char dirlist[1024];
char* dirptr;
int i, n;
int dirlen;
char *type;
ui_numArenas = 0;
uiInfo.mapCount = 0;
trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
if( *arenasFile.string ) {
UI_LoadArenasFromFile(arenasFile.string);
}
else {
UI_LoadArenasFromFile("scripts/arenas.txt");
}
// get all arenas from .arena files
numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024 );
dirptr = dirlist;
for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
dirlen = strlen(dirptr);
strcpy(filename, "scripts/");
strcat(filename, dirptr);
UI_LoadArenasFromFile(filename);
}
trap_Print( va( "%i arenas parsed\n", ui_numArenas ) );
if (UI_OutOfMemory()) {
trap_Print(S_COLOR_YELLOW"WARNING: not anough memory in pool to load all arenas\n");
}
for( n = 0; n < ui_numArenas; n++ ) {
// determine type
uiInfo.mapList[uiInfo.mapCount].cinematic = -1;
uiInfo.mapList[uiInfo.mapCount].mapLoadName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "map"));
uiInfo.mapList[uiInfo.mapCount].mapName = String_Alloc(Info_ValueForKey(ui_arenaInfos[n], "longname"));
uiInfo.mapList[uiInfo.mapCount].levelShot = -1;
uiInfo.mapList[uiInfo.mapCount].imageName = String_Alloc(va("levelshots/%s", uiInfo.mapList[uiInfo.mapCount].mapLoadName));
uiInfo.mapList[uiInfo.mapCount].typeBits = 0;
type = Info_ValueForKey( ui_arenaInfos[n], "type" );
// if no type specified, it will be treated as "ffa"
if( *type ) {
if( strstr( type, "ffa" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);
}
if( strstr( type, "tourney" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_TOURNAMENT);
}
if( strstr( type, "ctf" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_CTF);
}
if( strstr( type, "oneflag" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_1FCTF);
}
if( strstr( type, "overload" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_OBELISK);
}
if( strstr( type, "harvester" ) ) {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_HARVESTER);
}
} else {
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_FFA);
}
uiInfo.mapCount++;
if (uiInfo.mapCount >= MAX_MAPS) {
break;
}
}
}
/*
===============
UI_LoadBotsFromFile
===============
*/
static void UI_LoadBotsFromFile( char *filename ) {
int len;
fileHandle_t f;
char buf[MAX_BOTS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
if ( len >= MAX_BOTS_TEXT ) {
trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_BOTS_TEXT ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
COM_Compress(buf);
ui_numBots += UI_ParseInfos( buf, MAX_BOTS - ui_numBots, &ui_botInfos[ui_numBots] );
}
/*
===============
UI_LoadBots
===============
*/
void UI_LoadBots( void ) {
vmCvar_t botsFile;
int numdirs;
char filename[128];
char dirlist[1024];
char* dirptr;
int i;
int dirlen;
ui_numBots = 0;
trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM );
if( *botsFile.string ) {
UI_LoadBotsFromFile(botsFile.string);
}
else {
UI_LoadBotsFromFile("scripts/bots.txt");
}
// get all bots from .bot files
numdirs = trap_FS_GetFileList("scripts", ".bot", dirlist, 1024 );
dirptr = dirlist;
for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
dirlen = strlen(dirptr);
strcpy(filename, "scripts/");
strcat(filename, dirptr);
UI_LoadBotsFromFile(filename);
}
trap_Print( va( "%i bots parsed\n", ui_numBots ) );
}
/*
===============
UI_GetBotInfoByNumber
===============
*/
char *UI_GetBotInfoByNumber( int num ) {
if( num < 0 || num >= ui_numBots ) {
trap_Print( va( S_COLOR_RED "Invalid bot number: %i\n", num ) );
return NULL;
}
return ui_botInfos[num];
}
/*
===============
UI_GetBotInfoByName
===============
*/
char *UI_GetBotInfoByName( const char *name ) {
int n;
char *value;
for ( n = 0; n < ui_numBots ; n++ ) {
value = Info_ValueForKey( ui_botInfos[n], "name" );
if ( !Q_stricmp( value, name ) ) {
return ui_botInfos[n];
}
}
return NULL;
}
int UI_GetNumBots() {
return ui_numBots;
}
char *UI_GetBotNameByNumber( int num ) {
char *info = UI_GetBotInfoByNumber(num);
if (info) {
return Info_ValueForKey( info, "name" );
}
return "Sarge";
}

2272
code/ui/ui_local.h Normal file → Executable file

File diff suppressed because it is too large Load diff

11994
code/ui/ui_main.c Normal file → Executable file

File diff suppressed because it is too large Load diff

2756
code/ui/ui_players.c Normal file → Executable file

File diff suppressed because it is too large Load diff

382
code/ui/ui_public.h Normal file → Executable file
View file

@ -1,191 +1,191 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#ifndef __UI_PUBLIC_H__
#define __UI_PUBLIC_H__
#define UI_API_VERSION 6
typedef struct {
connstate_t connState;
int connectPacketCount;
int clientNum;
char servername[MAX_STRING_CHARS];
char updateInfoString[MAX_STRING_CHARS];
char messageString[MAX_STRING_CHARS];
} uiClientState_t;
typedef enum {
UI_ERROR,
UI_PRINT,
UI_MILLISECONDS,
UI_CVAR_SET,
UI_CVAR_VARIABLEVALUE,
UI_CVAR_VARIABLESTRINGBUFFER,
UI_CVAR_SETVALUE,
UI_CVAR_RESET,
UI_CVAR_CREATE,
UI_CVAR_INFOSTRINGBUFFER,
UI_ARGC,
UI_ARGV,
UI_CMD_EXECUTETEXT,
UI_FS_FOPENFILE,
UI_FS_READ,
UI_FS_WRITE,
UI_FS_FCLOSEFILE,
UI_FS_GETFILELIST,
UI_R_REGISTERMODEL,
UI_R_REGISTERSKIN,
UI_R_REGISTERSHADERNOMIP,
UI_R_CLEARSCENE,
UI_R_ADDREFENTITYTOSCENE,
UI_R_ADDPOLYTOSCENE,
UI_R_ADDLIGHTTOSCENE,
UI_R_RENDERSCENE,
UI_R_SETCOLOR,
UI_R_DRAWSTRETCHPIC,
UI_UPDATESCREEN,
UI_CM_LERPTAG,
UI_CM_LOADMODEL,
UI_S_REGISTERSOUND,
UI_S_STARTLOCALSOUND,
UI_KEY_KEYNUMTOSTRINGBUF,
UI_KEY_GETBINDINGBUF,
UI_KEY_SETBINDING,
UI_KEY_ISDOWN,
UI_KEY_GETOVERSTRIKEMODE,
UI_KEY_SETOVERSTRIKEMODE,
UI_KEY_CLEARSTATES,
UI_KEY_GETCATCHER,
UI_KEY_SETCATCHER,
UI_GETCLIPBOARDDATA,
UI_GETGLCONFIG,
UI_GETCLIENTSTATE,
UI_GETCONFIGSTRING,
UI_LAN_GETPINGQUEUECOUNT,
UI_LAN_CLEARPING,
UI_LAN_GETPING,
UI_LAN_GETPINGINFO,
UI_CVAR_REGISTER,
UI_CVAR_UPDATE,
UI_MEMORY_REMAINING,
UI_GET_CDKEY,
UI_SET_CDKEY,
UI_R_REGISTERFONT,
UI_R_MODELBOUNDS,
UI_PC_ADD_GLOBAL_DEFINE,
UI_PC_LOAD_SOURCE,
UI_PC_FREE_SOURCE,
UI_PC_READ_TOKEN,
UI_PC_SOURCE_FILE_AND_LINE,
UI_S_STOPBACKGROUNDTRACK,
UI_S_STARTBACKGROUNDTRACK,
UI_REAL_TIME,
UI_LAN_GETSERVERCOUNT,
UI_LAN_GETSERVERADDRESSSTRING,
UI_LAN_GETSERVERINFO,
UI_LAN_MARKSERVERVISIBLE,
UI_LAN_UPDATEVISIBLEPINGS,
UI_LAN_RESETPINGS,
UI_LAN_LOADCACHEDSERVERS,
UI_LAN_SAVECACHEDSERVERS,
UI_LAN_ADDSERVER,
UI_LAN_REMOVESERVER,
UI_CIN_PLAYCINEMATIC,
UI_CIN_STOPCINEMATIC,
UI_CIN_RUNCINEMATIC,
UI_CIN_DRAWCINEMATIC,
UI_CIN_SETEXTENTS,
UI_R_REMAP_SHADER,
UI_VERIFY_CDKEY,
UI_LAN_SERVERSTATUS,
UI_LAN_GETSERVERPING,
UI_LAN_SERVERISVISIBLE,
UI_LAN_COMPARESERVERS,
// 1.32
UI_FS_SEEK,
UI_SET_PBCLSTATUS,
UI_MEMSET = 100,
UI_MEMCPY,
UI_STRNCPY,
UI_SIN,
UI_COS,
UI_ATAN2,
UI_SQRT,
UI_FLOOR,
UI_CEIL
} uiImport_t;
typedef enum {
UIMENU_NONE,
UIMENU_MAIN,
UIMENU_INGAME,
UIMENU_NEED_CD,
UIMENU_BAD_CD_KEY,
UIMENU_TEAM,
UIMENU_POSTGAME
} uiMenuCommand_t;
#define SORT_HOST 0
#define SORT_MAP 1
#define SORT_CLIENTS 2
#define SORT_GAME 3
#define SORT_PING 4
#define SORT_PUNKBUSTER 5
typedef enum {
UI_GETAPIVERSION = 0, // system reserved
UI_INIT,
// void UI_Init( void );
UI_SHUTDOWN,
// void UI_Shutdown( void );
UI_KEY_EVENT,
// void UI_KeyEvent( int key );
UI_MOUSE_EVENT,
// void UI_MouseEvent( int dx, int dy );
UI_REFRESH,
// void UI_Refresh( int time );
UI_IS_FULLSCREEN,
// qboolean UI_IsFullscreen( void );
UI_SET_ACTIVE_MENU,
// void UI_SetActiveMenu( uiMenuCommand_t menu );
UI_CONSOLE_COMMAND,
// qboolean UI_ConsoleCommand( int realTime );
UI_DRAW_CONNECT_SCREEN,
// void UI_DrawConnectScreen( qboolean overlay );
UI_HASUNIQUECDKEY
// if !overlay, the background will be drawn, otherwise it will be
// overlayed over whatever the cgame has drawn.
// a GetClientState syscall will be made to get the current strings
} uiExport_t;
#endif
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#ifndef __UI_PUBLIC_H__
#define __UI_PUBLIC_H__
#define UI_API_VERSION 6
typedef struct {
connstate_t connState;
int connectPacketCount;
int clientNum;
char servername[MAX_STRING_CHARS];
char updateInfoString[MAX_STRING_CHARS];
char messageString[MAX_STRING_CHARS];
} uiClientState_t;
typedef enum {
UI_ERROR,
UI_PRINT,
UI_MILLISECONDS,
UI_CVAR_SET,
UI_CVAR_VARIABLEVALUE,
UI_CVAR_VARIABLESTRINGBUFFER,
UI_CVAR_SETVALUE,
UI_CVAR_RESET,
UI_CVAR_CREATE,
UI_CVAR_INFOSTRINGBUFFER,
UI_ARGC,
UI_ARGV,
UI_CMD_EXECUTETEXT,
UI_FS_FOPENFILE,
UI_FS_READ,
UI_FS_WRITE,
UI_FS_FCLOSEFILE,
UI_FS_GETFILELIST,
UI_R_REGISTERMODEL,
UI_R_REGISTERSKIN,
UI_R_REGISTERSHADERNOMIP,
UI_R_CLEARSCENE,
UI_R_ADDREFENTITYTOSCENE,
UI_R_ADDPOLYTOSCENE,
UI_R_ADDLIGHTTOSCENE,
UI_R_RENDERSCENE,
UI_R_SETCOLOR,
UI_R_DRAWSTRETCHPIC,
UI_UPDATESCREEN,
UI_CM_LERPTAG,
UI_CM_LOADMODEL,
UI_S_REGISTERSOUND,
UI_S_STARTLOCALSOUND,
UI_KEY_KEYNUMTOSTRINGBUF,
UI_KEY_GETBINDINGBUF,
UI_KEY_SETBINDING,
UI_KEY_ISDOWN,
UI_KEY_GETOVERSTRIKEMODE,
UI_KEY_SETOVERSTRIKEMODE,
UI_KEY_CLEARSTATES,
UI_KEY_GETCATCHER,
UI_KEY_SETCATCHER,
UI_GETCLIPBOARDDATA,
UI_GETGLCONFIG,
UI_GETCLIENTSTATE,
UI_GETCONFIGSTRING,
UI_LAN_GETPINGQUEUECOUNT,
UI_LAN_CLEARPING,
UI_LAN_GETPING,
UI_LAN_GETPINGINFO,
UI_CVAR_REGISTER,
UI_CVAR_UPDATE,
UI_MEMORY_REMAINING,
UI_GET_CDKEY,
UI_SET_CDKEY,
UI_R_REGISTERFONT,
UI_R_MODELBOUNDS,
UI_PC_ADD_GLOBAL_DEFINE,
UI_PC_LOAD_SOURCE,
UI_PC_FREE_SOURCE,
UI_PC_READ_TOKEN,
UI_PC_SOURCE_FILE_AND_LINE,
UI_S_STOPBACKGROUNDTRACK,
UI_S_STARTBACKGROUNDTRACK,
UI_REAL_TIME,
UI_LAN_GETSERVERCOUNT,
UI_LAN_GETSERVERADDRESSSTRING,
UI_LAN_GETSERVERINFO,
UI_LAN_MARKSERVERVISIBLE,
UI_LAN_UPDATEVISIBLEPINGS,
UI_LAN_RESETPINGS,
UI_LAN_LOADCACHEDSERVERS,
UI_LAN_SAVECACHEDSERVERS,
UI_LAN_ADDSERVER,
UI_LAN_REMOVESERVER,
UI_CIN_PLAYCINEMATIC,
UI_CIN_STOPCINEMATIC,
UI_CIN_RUNCINEMATIC,
UI_CIN_DRAWCINEMATIC,
UI_CIN_SETEXTENTS,
UI_R_REMAP_SHADER,
UI_VERIFY_CDKEY,
UI_LAN_SERVERSTATUS,
UI_LAN_GETSERVERPING,
UI_LAN_SERVERISVISIBLE,
UI_LAN_COMPARESERVERS,
// 1.32
UI_FS_SEEK,
UI_SET_PBCLSTATUS,
UI_MEMSET = 100,
UI_MEMCPY,
UI_STRNCPY,
UI_SIN,
UI_COS,
UI_ATAN2,
UI_SQRT,
UI_FLOOR,
UI_CEIL
} uiImport_t;
typedef enum {
UIMENU_NONE,
UIMENU_MAIN,
UIMENU_INGAME,
UIMENU_NEED_CD,
UIMENU_BAD_CD_KEY,
UIMENU_TEAM,
UIMENU_POSTGAME
} uiMenuCommand_t;
#define SORT_HOST 0
#define SORT_MAP 1
#define SORT_CLIENTS 2
#define SORT_GAME 3
#define SORT_PING 4
#define SORT_PUNKBUSTER 5
typedef enum {
UI_GETAPIVERSION = 0, // system reserved
UI_INIT,
// void UI_Init( void );
UI_SHUTDOWN,
// void UI_Shutdown( void );
UI_KEY_EVENT,
// void UI_KeyEvent( int key );
UI_MOUSE_EVENT,
// void UI_MouseEvent( int dx, int dy );
UI_REFRESH,
// void UI_Refresh( int time );
UI_IS_FULLSCREEN,
// qboolean UI_IsFullscreen( void );
UI_SET_ACTIVE_MENU,
// void UI_SetActiveMenu( uiMenuCommand_t menu );
UI_CONSOLE_COMMAND,
// qboolean UI_ConsoleCommand( int realTime );
UI_DRAW_CONNECT_SCREEN,
// void UI_DrawConnectScreen( qboolean overlay );
UI_HASUNIQUECDKEY
// if !overlay, the background will be drawn, otherwise it will be
// overlayed over whatever the cgame has drawn.
// a GetClientState syscall will be made to get the current strings
} uiExport_t;
#endif

11570
code/ui/ui_shared.c Normal file → Executable file

File diff suppressed because it is too large Load diff

900
code/ui/ui_shared.h Normal file → Executable file
View file

@ -1,450 +1,450 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_SHARED_H
#define __UI_SHARED_H
#include "../game/q_shared.h"
#include "../cgame/tr_types.h"
#include "keycodes.h"
#include "../../ui/menudef.h"
#define MAX_MENUNAME 32
#define MAX_ITEMTEXT 64
#define MAX_ITEMACTION 64
#define MAX_MENUDEFFILE 4096
#define MAX_MENUFILE 32768
#define MAX_MENUS 64
#define MAX_MENUITEMS 96
#define MAX_COLOR_RANGES 10
#define MAX_OPEN_MENUS 16
#define WINDOW_MOUSEOVER 0x00000001 // mouse is over it, non exclusive
#define WINDOW_HASFOCUS 0x00000002 // has cursor focus, exclusive
#define WINDOW_VISIBLE 0x00000004 // is visible
#define WINDOW_GREY 0x00000008 // is visible but grey ( non-active )
#define WINDOW_DECORATION 0x00000010 // for decoration only, no mouse, keyboard, etc..
#define WINDOW_FADINGOUT 0x00000020 // fading out, non-active
#define WINDOW_FADINGIN 0x00000040 // fading in
#define WINDOW_MOUSEOVERTEXT 0x00000080 // mouse is over it, non exclusive
#define WINDOW_INTRANSITION 0x00000100 // window is in transition
#define WINDOW_FORECOLORSET 0x00000200 // forecolor was explicitly set ( used to color alpha images or not )
#define WINDOW_HORIZONTAL 0x00000400 // for list boxes and sliders, vertical is default this is set of horizontal
#define WINDOW_LB_LEFTARROW 0x00000800 // mouse is over left/up arrow
#define WINDOW_LB_RIGHTARROW 0x00001000 // mouse is over right/down arrow
#define WINDOW_LB_THUMB 0x00002000 // mouse is over thumb
#define WINDOW_LB_PGUP 0x00004000 // mouse is over page up
#define WINDOW_LB_PGDN 0x00008000 // mouse is over page down
#define WINDOW_ORBITING 0x00010000 // item is in orbit
#define WINDOW_OOB_CLICK 0x00020000 // close on out of bounds click
#define WINDOW_WRAPPED 0x00040000 // manually wrap text
#define WINDOW_AUTOWRAPPED 0x00080000 // auto wrap text
#define WINDOW_FORCED 0x00100000 // forced open
#define WINDOW_POPUP 0x00200000 // popup
#define WINDOW_BACKCOLORSET 0x00400000 // backcolor was explicitly set
#define WINDOW_TIMEDVISIBLE 0x00800000 // visibility timing ( NOT implemented )
// CGAME cursor type bits
#define CURSOR_NONE 0x00000001
#define CURSOR_ARROW 0x00000002
#define CURSOR_SIZER 0x00000004
#ifdef CGAME
#define STRING_POOL_SIZE 128*1024
#else
#define STRING_POOL_SIZE 384*1024
#endif
#define MAX_STRING_HANDLES 4096
#define MAX_SCRIPT_ARGS 12
#define MAX_EDITFIELD 256
#define ART_FX_BASE "menu/art/fx_base"
#define ART_FX_BLUE "menu/art/fx_blue"
#define ART_FX_CYAN "menu/art/fx_cyan"
#define ART_FX_GREEN "menu/art/fx_grn"
#define ART_FX_RED "menu/art/fx_red"
#define ART_FX_TEAL "menu/art/fx_teal"
#define ART_FX_WHITE "menu/art/fx_white"
#define ART_FX_YELLOW "menu/art/fx_yel"
#define ASSET_GRADIENTBAR "ui/assets/gradientbar2.tga"
#define ASSET_SCROLLBAR "ui/assets/scrollbar.tga"
#define ASSET_SCROLLBAR_ARROWDOWN "ui/assets/scrollbar_arrow_dwn_a.tga"
#define ASSET_SCROLLBAR_ARROWUP "ui/assets/scrollbar_arrow_up_a.tga"
#define ASSET_SCROLLBAR_ARROWLEFT "ui/assets/scrollbar_arrow_left.tga"
#define ASSET_SCROLLBAR_ARROWRIGHT "ui/assets/scrollbar_arrow_right.tga"
#define ASSET_SCROLL_THUMB "ui/assets/scrollbar_thumb.tga"
#define ASSET_SLIDER_BAR "ui/assets/slider2.tga"
#define ASSET_SLIDER_THUMB "ui/assets/sliderbutt_1.tga"
#define SCROLLBAR_SIZE 16.0
#define SLIDER_WIDTH 96.0
#define SLIDER_HEIGHT 16.0
#define SLIDER_THUMB_WIDTH 12.0
#define SLIDER_THUMB_HEIGHT 20.0
#define NUM_CROSSHAIRS 10
typedef struct {
const char *command;
const char *args[MAX_SCRIPT_ARGS];
} scriptDef_t;
typedef struct {
float x; // horiz position
float y; // vert position
float w; // width
float h; // height;
} rectDef_t;
typedef rectDef_t Rectangle;
// FIXME: do something to separate text vs window stuff
typedef struct {
Rectangle rect; // client coord rectangle
Rectangle rectClient; // screen coord rectangle
const char *name; //
const char *group; // if it belongs to a group
const char *cinematicName; // cinematic name
int cinematic; // cinematic handle
int style; //
int border; //
int ownerDraw; // ownerDraw style
int ownerDrawFlags; // show flags for ownerdraw items
float borderSize; //
int flags; // visible, focus, mouseover, cursor
Rectangle rectEffects; // for various effects
Rectangle rectEffects2; // for various effects
int offsetTime; // time based value for various effects
int nextTime; // time next effect should cycle
vec4_t foreColor; // text color
vec4_t backColor; // border color
vec4_t borderColor; // border color
vec4_t outlineColor; // border color
qhandle_t background; // background asset
} windowDef_t;
typedef windowDef_t Window;
typedef struct {
vec4_t color;
float low;
float high;
} colorRangeDef_t;
// FIXME: combine flags into bitfields to save space
// FIXME: consolidate all of the common stuff in one structure for menus and items
// THINKABOUTME: is there any compelling reason not to have items contain items
// and do away with a menu per say.. major issue is not being able to dynamically allocate
// and destroy stuff.. Another point to consider is adding an alloc free call for vm's and have
// the engine just allocate the pool for it based on a cvar
// many of the vars are re-used for different item types, as such they are not always named appropriately
// the benefits of c++ in DOOM will greatly help crap like this
// FIXME: need to put a type ptr that points to specific type info per type
//
#define MAX_LB_COLUMNS 16
typedef struct columnInfo_s {
int pos;
int width;
int maxChars;
} columnInfo_t;
typedef struct listBoxDef_s {
int startPos;
int endPos;
int drawPadding;
int cursorPos;
float elementWidth;
float elementHeight;
int elementStyle;
int numColumns;
columnInfo_t columnInfo[MAX_LB_COLUMNS];
const char *doubleClick;
qboolean notselectable;
} listBoxDef_t;
typedef struct editFieldDef_s {
float minVal; // edit field limits
float maxVal; //
float defVal; //
float range; //
int maxChars; // for edit fields
int maxPaintChars; // for edit fields
int paintOffset; //
} editFieldDef_t;
#define MAX_MULTI_CVARS 32
typedef struct multiDef_s {
const char *cvarList[MAX_MULTI_CVARS];
const char *cvarStr[MAX_MULTI_CVARS];
float cvarValue[MAX_MULTI_CVARS];
int count;
qboolean strDef;
} multiDef_t;
typedef struct modelDef_s {
int angle;
vec3_t origin;
float fov_x;
float fov_y;
int rotationSpeed;
} modelDef_t;
#define CVAR_ENABLE 0x00000001
#define CVAR_DISABLE 0x00000002
#define CVAR_SHOW 0x00000004
#define CVAR_HIDE 0x00000008
typedef struct itemDef_s {
Window window; // common positional, border, style, layout info
Rectangle textRect; // rectangle the text ( if any ) consumes
int type; // text, button, radiobutton, checkbox, textfield, listbox, combo
int alignment; // left center right
int textalignment; // ( optional ) alignment for text within rect based on text width
float textalignx; // ( optional ) text alignment x coord
float textaligny; // ( optional ) text alignment x coord
float textscale; // scale percentage from 72pts
int textStyle; // ( optional ) style, normal and shadowed are it for now
const char *text; // display text
void *parent; // menu owner
qhandle_t asset; // handle to asset
const char *mouseEnterText; // mouse enter script
const char *mouseExitText; // mouse exit script
const char *mouseEnter; // mouse enter script
const char *mouseExit; // mouse exit script
const char *action; // select script
const char *onFocus; // select script
const char *leaveFocus; // select script
const char *cvar; // associated cvar
const char *cvarTest; // associated cvar for enable actions
const char *enableCvar; // enable, disable, show, or hide based on value, this can contain a list
int cvarFlags; // what type of action to take on cvarenables
sfxHandle_t focusSound;
int numColors; // number of color ranges
colorRangeDef_t colorRanges[MAX_COLOR_RANGES];
float special; // used for feeder id's etc.. diff per type
int cursorPos; // cursor position in characters
void *typeData; // type specific data ptr's
} itemDef_t;
typedef struct {
Window window;
const char *font; // font
qboolean fullScreen; // covers entire screen
int itemCount; // number of items;
int fontIndex; //
int cursorItem; // which item as the cursor
int fadeCycle; //
float fadeClamp; //
float fadeAmount; //
const char *onOpen; // run when the menu is first opened
const char *onClose; // run when the menu is closed
const char *onESC; // run when the menu is closed
const char *soundName; // background loop sound for menu
vec4_t focusColor; // focus color for items
vec4_t disableColor; // focus color for items
itemDef_t *items[MAX_MENUITEMS]; // items this menu contains
} menuDef_t;
typedef struct {
const char *fontStr;
const char *cursorStr;
const char *gradientStr;
fontInfo_t textFont;
fontInfo_t smallFont;
fontInfo_t bigFont;
qhandle_t cursor;
qhandle_t gradientBar;
qhandle_t scrollBarArrowUp;
qhandle_t scrollBarArrowDown;
qhandle_t scrollBarArrowLeft;
qhandle_t scrollBarArrowRight;
qhandle_t scrollBar;
qhandle_t scrollBarThumb;
qhandle_t buttonMiddle;
qhandle_t buttonInside;
qhandle_t solidBox;
qhandle_t sliderBar;
qhandle_t sliderThumb;
sfxHandle_t menuEnterSound;
sfxHandle_t menuExitSound;
sfxHandle_t menuBuzzSound;
sfxHandle_t itemFocusSound;
float fadeClamp;
int fadeCycle;
float fadeAmount;
float shadowX;
float shadowY;
vec4_t shadowColor;
float shadowFadeClamp;
qboolean fontRegistered;
// player settings
qhandle_t fxBasePic;
qhandle_t fxPic[7];
qhandle_t crosshairShader[NUM_CROSSHAIRS];
} cachedAssets_t;
typedef struct {
const char *name;
void (*handler) (itemDef_t *item, char** args);
} commandDef_t;
typedef struct {
qhandle_t (*registerShaderNoMip) (const char *p);
void (*setColor) (const vec4_t v);
void (*drawHandlePic) (float x, float y, float w, float h, qhandle_t asset);
void (*drawStretchPic) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void (*drawText) (float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style );
int (*textWidth) (const char *text, float scale, int limit);
int (*textHeight) (const char *text, float scale, int limit);
qhandle_t (*registerModel) (const char *p);
void (*modelBounds) (qhandle_t model, vec3_t min, vec3_t max);
void (*fillRect) ( float x, float y, float w, float h, const vec4_t color);
void (*drawRect) ( float x, float y, float w, float h, float size, const vec4_t color);
void (*drawSides) (float x, float y, float w, float h, float size);
void (*drawTopBottom) (float x, float y, float w, float h, float size);
void (*clearScene) ();
void (*addRefEntityToScene) (const refEntity_t *re );
void (*renderScene) ( const refdef_t *fd );
void (*registerFont) (const char *pFontname, int pointSize, fontInfo_t *font);
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);
float (*getValue) (int ownerDraw);
qboolean (*ownerDrawVisible) (int flags);
void (*runScript)(char **p);
void (*getTeamColor)(vec4_t *color);
void (*getCVarString)(const char *cvar, char *buffer, int bufsize);
float (*getCVarValue)(const char *cvar);
void (*setCVar)(const char *cvar, const char *value);
void (*drawTextWithCursor)(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style);
void (*setOverstrikeMode)(qboolean b);
qboolean (*getOverstrikeMode)();
void (*startLocalSound)( sfxHandle_t sfx, int channelNum );
qboolean (*ownerDrawHandleKey)(int ownerDraw, int flags, float *special, int key);
int (*feederCount)(float feederID);
const char *(*feederItemText)(float feederID, int index, int column, qhandle_t *handle);
qhandle_t (*feederItemImage)(float feederID, int index);
void (*feederSelection)(float feederID, int index);
void (*keynumToStringBuf)( int keynum, char *buf, int buflen );
void (*getBindingBuf)( int keynum, char *buf, int buflen );
void (*setBinding)( int keynum, const char *binding );
void (*executeText)(int exec_when, const char *text );
void (*Error)(int level, const char *error, ...);
void (*Print)(const char *msg, ...);
void (*Pause)(qboolean b);
int (*ownerDrawWidth)(int ownerDraw, float scale);
sfxHandle_t (*registerSound)(const char *name, qboolean compressed);
void (*startBackgroundTrack)( const char *intro, const char *loop);
void (*stopBackgroundTrack)();
int (*playCinematic)(const char *name, float x, float y, float w, float h);
void (*stopCinematic)(int handle);
void (*drawCinematic)(int handle, float x, float y, float w, float h);
void (*runCinematicFrame)(int handle);
float yscale;
float xscale;
float bias;
int realTime;
int frameTime;
int cursorx;
int cursory;
qboolean debug;
cachedAssets_t Assets;
glconfig_t glconfig;
qhandle_t whiteShader;
qhandle_t gradientImage;
qhandle_t cursor;
float FPS;
} displayContextDef_t;
const char *String_Alloc(const char *p);
void String_Init();
void String_Report();
void Init_Display(displayContextDef_t *dc);
void Display_ExpandMacros(char * buff);
void Menu_Init(menuDef_t *menu);
void Item_Init(itemDef_t *item);
void Menu_PostParse(menuDef_t *menu);
menuDef_t *Menu_GetFocused();
void Menu_HandleKey(menuDef_t *menu, int key, qboolean down);
void Menu_HandleMouseMove(menuDef_t *menu, float x, float y);
void Menu_ScrollFeeder(menuDef_t *menu, int feeder, qboolean down);
qboolean Float_Parse(char **p, float *f);
qboolean Color_Parse(char **p, vec4_t *c);
qboolean Int_Parse(char **p, int *i);
qboolean Rect_Parse(char **p, rectDef_t *r);
qboolean String_Parse(char **p, const char **out);
qboolean Script_Parse(char **p, const char **out);
qboolean PC_Float_Parse(int handle, float *f);
qboolean PC_Color_Parse(int handle, vec4_t *c);
qboolean PC_Int_Parse(int handle, int *i);
qboolean PC_Rect_Parse(int handle, rectDef_t *r);
qboolean PC_String_Parse(int handle, const char **out);
qboolean PC_Script_Parse(int handle, const char **out);
int Menu_Count();
void Menu_New(int handle);
void Menu_PaintAll();
menuDef_t *Menus_ActivateByName(const char *p);
void Menu_Reset();
qboolean Menus_AnyFullScreenVisible();
void Menus_Activate(menuDef_t *menu);
displayContextDef_t *Display_GetContext();
void *Display_CaptureItem(int x, int y);
qboolean Display_MouseMove(void *p, int x, int y);
int Display_CursorType(int x, int y);
qboolean Display_KeyBindPending();
void Menus_OpenByName(const char *p);
menuDef_t *Menus_FindByName(const char *p);
void Menus_ShowByName(const char *p);
void Menus_CloseByName(const char *p);
void Display_HandleKey(int key, qboolean down, int x, int y);
void LerpColor(vec4_t a, vec4_t b, vec4_t c, float t);
void Menus_CloseAll();
void Menu_Paint(menuDef_t *menu, qboolean forcePaint);
void Menu_SetFeederSelection(menuDef_t *menu, int feeder, int index, const char *name);
void Display_CacheAll();
void *UI_Alloc( int size );
void UI_InitMemory( void );
qboolean UI_OutOfMemory();
void Controls_GetConfig( void );
void Controls_SetConfig(qboolean restart);
void Controls_SetDefaults( void );
int trap_PC_AddGlobalDefine( char *define );
int trap_PC_LoadSource( const char *filename );
int trap_PC_FreeSource( int handle );
int trap_PC_ReadToken( int handle, pc_token_t *pc_token );
int trap_PC_SourceFileAndLine( int handle, char *filename, int *line );
#endif
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __UI_SHARED_H
#define __UI_SHARED_H
#include "../game/q_shared.h"
#include "../cgame/tr_types.h"
#include "keycodes.h"
#include "../../ui/menudef.h"
#define MAX_MENUNAME 32
#define MAX_ITEMTEXT 64
#define MAX_ITEMACTION 64
#define MAX_MENUDEFFILE 4096
#define MAX_MENUFILE 32768
#define MAX_MENUS 64
#define MAX_MENUITEMS 96
#define MAX_COLOR_RANGES 10
#define MAX_OPEN_MENUS 16
#define WINDOW_MOUSEOVER 0x00000001 // mouse is over it, non exclusive
#define WINDOW_HASFOCUS 0x00000002 // has cursor focus, exclusive
#define WINDOW_VISIBLE 0x00000004 // is visible
#define WINDOW_GREY 0x00000008 // is visible but grey ( non-active )
#define WINDOW_DECORATION 0x00000010 // for decoration only, no mouse, keyboard, etc..
#define WINDOW_FADINGOUT 0x00000020 // fading out, non-active
#define WINDOW_FADINGIN 0x00000040 // fading in
#define WINDOW_MOUSEOVERTEXT 0x00000080 // mouse is over it, non exclusive
#define WINDOW_INTRANSITION 0x00000100 // window is in transition
#define WINDOW_FORECOLORSET 0x00000200 // forecolor was explicitly set ( used to color alpha images or not )
#define WINDOW_HORIZONTAL 0x00000400 // for list boxes and sliders, vertical is default this is set of horizontal
#define WINDOW_LB_LEFTARROW 0x00000800 // mouse is over left/up arrow
#define WINDOW_LB_RIGHTARROW 0x00001000 // mouse is over right/down arrow
#define WINDOW_LB_THUMB 0x00002000 // mouse is over thumb
#define WINDOW_LB_PGUP 0x00004000 // mouse is over page up
#define WINDOW_LB_PGDN 0x00008000 // mouse is over page down
#define WINDOW_ORBITING 0x00010000 // item is in orbit
#define WINDOW_OOB_CLICK 0x00020000 // close on out of bounds click
#define WINDOW_WRAPPED 0x00040000 // manually wrap text
#define WINDOW_AUTOWRAPPED 0x00080000 // auto wrap text
#define WINDOW_FORCED 0x00100000 // forced open
#define WINDOW_POPUP 0x00200000 // popup
#define WINDOW_BACKCOLORSET 0x00400000 // backcolor was explicitly set
#define WINDOW_TIMEDVISIBLE 0x00800000 // visibility timing ( NOT implemented )
// CGAME cursor type bits
#define CURSOR_NONE 0x00000001
#define CURSOR_ARROW 0x00000002
#define CURSOR_SIZER 0x00000004
#ifdef CGAME
#define STRING_POOL_SIZE 128*1024
#else
#define STRING_POOL_SIZE 384*1024
#endif
#define MAX_STRING_HANDLES 4096
#define MAX_SCRIPT_ARGS 12
#define MAX_EDITFIELD 256
#define ART_FX_BASE "menu/art/fx_base"
#define ART_FX_BLUE "menu/art/fx_blue"
#define ART_FX_CYAN "menu/art/fx_cyan"
#define ART_FX_GREEN "menu/art/fx_grn"
#define ART_FX_RED "menu/art/fx_red"
#define ART_FX_TEAL "menu/art/fx_teal"
#define ART_FX_WHITE "menu/art/fx_white"
#define ART_FX_YELLOW "menu/art/fx_yel"
#define ASSET_GRADIENTBAR "ui/assets/gradientbar2.tga"
#define ASSET_SCROLLBAR "ui/assets/scrollbar.tga"
#define ASSET_SCROLLBAR_ARROWDOWN "ui/assets/scrollbar_arrow_dwn_a.tga"
#define ASSET_SCROLLBAR_ARROWUP "ui/assets/scrollbar_arrow_up_a.tga"
#define ASSET_SCROLLBAR_ARROWLEFT "ui/assets/scrollbar_arrow_left.tga"
#define ASSET_SCROLLBAR_ARROWRIGHT "ui/assets/scrollbar_arrow_right.tga"
#define ASSET_SCROLL_THUMB "ui/assets/scrollbar_thumb.tga"
#define ASSET_SLIDER_BAR "ui/assets/slider2.tga"
#define ASSET_SLIDER_THUMB "ui/assets/sliderbutt_1.tga"
#define SCROLLBAR_SIZE 16.0
#define SLIDER_WIDTH 96.0
#define SLIDER_HEIGHT 16.0
#define SLIDER_THUMB_WIDTH 12.0
#define SLIDER_THUMB_HEIGHT 20.0
#define NUM_CROSSHAIRS 10
typedef struct {
const char *command;
const char *args[MAX_SCRIPT_ARGS];
} scriptDef_t;
typedef struct {
float x; // horiz position
float y; // vert position
float w; // width
float h; // height;
} rectDef_t;
typedef rectDef_t Rectangle;
// FIXME: do something to separate text vs window stuff
typedef struct {
Rectangle rect; // client coord rectangle
Rectangle rectClient; // screen coord rectangle
const char *name; //
const char *group; // if it belongs to a group
const char *cinematicName; // cinematic name
int cinematic; // cinematic handle
int style; //
int border; //
int ownerDraw; // ownerDraw style
int ownerDrawFlags; // show flags for ownerdraw items
float borderSize; //
int flags; // visible, focus, mouseover, cursor
Rectangle rectEffects; // for various effects
Rectangle rectEffects2; // for various effects
int offsetTime; // time based value for various effects
int nextTime; // time next effect should cycle
vec4_t foreColor; // text color
vec4_t backColor; // border color
vec4_t borderColor; // border color
vec4_t outlineColor; // border color
qhandle_t background; // background asset
} windowDef_t;
typedef windowDef_t Window;
typedef struct {
vec4_t color;
float low;
float high;
} colorRangeDef_t;
// FIXME: combine flags into bitfields to save space
// FIXME: consolidate all of the common stuff in one structure for menus and items
// THINKABOUTME: is there any compelling reason not to have items contain items
// and do away with a menu per say.. major issue is not being able to dynamically allocate
// and destroy stuff.. Another point to consider is adding an alloc free call for vm's and have
// the engine just allocate the pool for it based on a cvar
// many of the vars are re-used for different item types, as such they are not always named appropriately
// the benefits of c++ in DOOM will greatly help crap like this
// FIXME: need to put a type ptr that points to specific type info per type
//
#define MAX_LB_COLUMNS 16
typedef struct columnInfo_s {
int pos;
int width;
int maxChars;
} columnInfo_t;
typedef struct listBoxDef_s {
int startPos;
int endPos;
int drawPadding;
int cursorPos;
float elementWidth;
float elementHeight;
int elementStyle;
int numColumns;
columnInfo_t columnInfo[MAX_LB_COLUMNS];
const char *doubleClick;
qboolean notselectable;
} listBoxDef_t;
typedef struct editFieldDef_s {
float minVal; // edit field limits
float maxVal; //
float defVal; //
float range; //
int maxChars; // for edit fields
int maxPaintChars; // for edit fields
int paintOffset; //
} editFieldDef_t;
#define MAX_MULTI_CVARS 32
typedef struct multiDef_s {
const char *cvarList[MAX_MULTI_CVARS];
const char *cvarStr[MAX_MULTI_CVARS];
float cvarValue[MAX_MULTI_CVARS];
int count;
qboolean strDef;
} multiDef_t;
typedef struct modelDef_s {
int angle;
vec3_t origin;
float fov_x;
float fov_y;
int rotationSpeed;
} modelDef_t;
#define CVAR_ENABLE 0x00000001
#define CVAR_DISABLE 0x00000002
#define CVAR_SHOW 0x00000004
#define CVAR_HIDE 0x00000008
typedef struct itemDef_s {
Window window; // common positional, border, style, layout info
Rectangle textRect; // rectangle the text ( if any ) consumes
int type; // text, button, radiobutton, checkbox, textfield, listbox, combo
int alignment; // left center right
int textalignment; // ( optional ) alignment for text within rect based on text width
float textalignx; // ( optional ) text alignment x coord
float textaligny; // ( optional ) text alignment x coord
float textscale; // scale percentage from 72pts
int textStyle; // ( optional ) style, normal and shadowed are it for now
const char *text; // display text
void *parent; // menu owner
qhandle_t asset; // handle to asset
const char *mouseEnterText; // mouse enter script
const char *mouseExitText; // mouse exit script
const char *mouseEnter; // mouse enter script
const char *mouseExit; // mouse exit script
const char *action; // select script
const char *onFocus; // select script
const char *leaveFocus; // select script
const char *cvar; // associated cvar
const char *cvarTest; // associated cvar for enable actions
const char *enableCvar; // enable, disable, show, or hide based on value, this can contain a list
int cvarFlags; // what type of action to take on cvarenables
sfxHandle_t focusSound;
int numColors; // number of color ranges
colorRangeDef_t colorRanges[MAX_COLOR_RANGES];
float special; // used for feeder id's etc.. diff per type
int cursorPos; // cursor position in characters
void *typeData; // type specific data ptr's
} itemDef_t;
typedef struct {
Window window;
const char *font; // font
qboolean fullScreen; // covers entire screen
int itemCount; // number of items;
int fontIndex; //
int cursorItem; // which item as the cursor
int fadeCycle; //
float fadeClamp; //
float fadeAmount; //
const char *onOpen; // run when the menu is first opened
const char *onClose; // run when the menu is closed
const char *onESC; // run when the menu is closed
const char *soundName; // background loop sound for menu
vec4_t focusColor; // focus color for items
vec4_t disableColor; // focus color for items
itemDef_t *items[MAX_MENUITEMS]; // items this menu contains
} menuDef_t;
typedef struct {
const char *fontStr;
const char *cursorStr;
const char *gradientStr;
fontInfo_t textFont;
fontInfo_t smallFont;
fontInfo_t bigFont;
qhandle_t cursor;
qhandle_t gradientBar;
qhandle_t scrollBarArrowUp;
qhandle_t scrollBarArrowDown;
qhandle_t scrollBarArrowLeft;
qhandle_t scrollBarArrowRight;
qhandle_t scrollBar;
qhandle_t scrollBarThumb;
qhandle_t buttonMiddle;
qhandle_t buttonInside;
qhandle_t solidBox;
qhandle_t sliderBar;
qhandle_t sliderThumb;
sfxHandle_t menuEnterSound;
sfxHandle_t menuExitSound;
sfxHandle_t menuBuzzSound;
sfxHandle_t itemFocusSound;
float fadeClamp;
int fadeCycle;
float fadeAmount;
float shadowX;
float shadowY;
vec4_t shadowColor;
float shadowFadeClamp;
qboolean fontRegistered;
// player settings
qhandle_t fxBasePic;
qhandle_t fxPic[7];
qhandle_t crosshairShader[NUM_CROSSHAIRS];
} cachedAssets_t;
typedef struct {
const char *name;
void (*handler) (itemDef_t *item, char** args);
} commandDef_t;
typedef struct {
qhandle_t (*registerShaderNoMip) (const char *p);
void (*setColor) (const vec4_t v);
void (*drawHandlePic) (float x, float y, float w, float h, qhandle_t asset);
void (*drawStretchPic) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void (*drawText) (float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style );
int (*textWidth) (const char *text, float scale, int limit);
int (*textHeight) (const char *text, float scale, int limit);
qhandle_t (*registerModel) (const char *p);
void (*modelBounds) (qhandle_t model, vec3_t min, vec3_t max);
void (*fillRect) ( float x, float y, float w, float h, const vec4_t color);
void (*drawRect) ( float x, float y, float w, float h, float size, const vec4_t color);
void (*drawSides) (float x, float y, float w, float h, float size);
void (*drawTopBottom) (float x, float y, float w, float h, float size);
void (*clearScene) ();
void (*addRefEntityToScene) (const refEntity_t *re );
void (*renderScene) ( const refdef_t *fd );
void (*registerFont) (const char *pFontname, int pointSize, fontInfo_t *font);
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);
float (*getValue) (int ownerDraw);
qboolean (*ownerDrawVisible) (int flags);
void (*runScript)(char **p);
void (*getTeamColor)(vec4_t *color);
void (*getCVarString)(const char *cvar, char *buffer, int bufsize);
float (*getCVarValue)(const char *cvar);
void (*setCVar)(const char *cvar, const char *value);
void (*drawTextWithCursor)(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style);
void (*setOverstrikeMode)(qboolean b);
qboolean (*getOverstrikeMode)();
void (*startLocalSound)( sfxHandle_t sfx, int channelNum );
qboolean (*ownerDrawHandleKey)(int ownerDraw, int flags, float *special, int key);
int (*feederCount)(float feederID);
const char *(*feederItemText)(float feederID, int index, int column, qhandle_t *handle);
qhandle_t (*feederItemImage)(float feederID, int index);
void (*feederSelection)(float feederID, int index);
void (*keynumToStringBuf)( int keynum, char *buf, int buflen );
void (*getBindingBuf)( int keynum, char *buf, int buflen );
void (*setBinding)( int keynum, const char *binding );
void (*executeText)(int exec_when, const char *text );
void (*Error)(int level, const char *error, ...);
void (*Print)(const char *msg, ...);
void (*Pause)(qboolean b);
int (*ownerDrawWidth)(int ownerDraw, float scale);
sfxHandle_t (*registerSound)(const char *name, qboolean compressed);
void (*startBackgroundTrack)( const char *intro, const char *loop);
void (*stopBackgroundTrack)();
int (*playCinematic)(const char *name, float x, float y, float w, float h);
void (*stopCinematic)(int handle);
void (*drawCinematic)(int handle, float x, float y, float w, float h);
void (*runCinematicFrame)(int handle);
float yscale;
float xscale;
float bias;
int realTime;
int frameTime;
int cursorx;
int cursory;
qboolean debug;
cachedAssets_t Assets;
glconfig_t glconfig;
qhandle_t whiteShader;
qhandle_t gradientImage;
qhandle_t cursor;
float FPS;
} displayContextDef_t;
const char *String_Alloc(const char *p);
void String_Init();
void String_Report();
void Init_Display(displayContextDef_t *dc);
void Display_ExpandMacros(char * buff);
void Menu_Init(menuDef_t *menu);
void Item_Init(itemDef_t *item);
void Menu_PostParse(menuDef_t *menu);
menuDef_t *Menu_GetFocused();
void Menu_HandleKey(menuDef_t *menu, int key, qboolean down);
void Menu_HandleMouseMove(menuDef_t *menu, float x, float y);
void Menu_ScrollFeeder(menuDef_t *menu, int feeder, qboolean down);
qboolean Float_Parse(char **p, float *f);
qboolean Color_Parse(char **p, vec4_t *c);
qboolean Int_Parse(char **p, int *i);
qboolean Rect_Parse(char **p, rectDef_t *r);
qboolean String_Parse(char **p, const char **out);
qboolean Script_Parse(char **p, const char **out);
qboolean PC_Float_Parse(int handle, float *f);
qboolean PC_Color_Parse(int handle, vec4_t *c);
qboolean PC_Int_Parse(int handle, int *i);
qboolean PC_Rect_Parse(int handle, rectDef_t *r);
qboolean PC_String_Parse(int handle, const char **out);
qboolean PC_Script_Parse(int handle, const char **out);
int Menu_Count();
void Menu_New(int handle);
void Menu_PaintAll();
menuDef_t *Menus_ActivateByName(const char *p);
void Menu_Reset();
qboolean Menus_AnyFullScreenVisible();
void Menus_Activate(menuDef_t *menu);
displayContextDef_t *Display_GetContext();
void *Display_CaptureItem(int x, int y);
qboolean Display_MouseMove(void *p, int x, int y);
int Display_CursorType(int x, int y);
qboolean Display_KeyBindPending();
void Menus_OpenByName(const char *p);
menuDef_t *Menus_FindByName(const char *p);
void Menus_ShowByName(const char *p);
void Menus_CloseByName(const char *p);
void Display_HandleKey(int key, qboolean down, int x, int y);
void LerpColor(vec4_t a, vec4_t b, vec4_t c, float t);
void Menus_CloseAll();
void Menu_Paint(menuDef_t *menu, qboolean forcePaint);
void Menu_SetFeederSelection(menuDef_t *menu, int feeder, int index, const char *name);
void Display_CacheAll();
void *UI_Alloc( int size );
void UI_InitMemory( void );
qboolean UI_OutOfMemory();
void Controls_GetConfig( void );
void Controls_SetConfig(qboolean restart);
void Controls_SetDefaults( void );
int trap_PC_AddGlobalDefine( char *define );
int trap_PC_LoadSource( const char *filename );
int trap_PC_FreeSource( int handle );
int trap_PC_ReadToken( int handle, pc_token_t *pc_token );
int trap_PC_SourceFileAndLine( int handle, char *filename, int *line );
#endif

202
code/ui/ui_syscalls.asm Normal file → Executable file
View file

@ -1,101 +1,101 @@
code
equ trap_Error -1
equ trap_Print -2
equ trap_Milliseconds -3
equ trap_Cvar_Set -4
equ trap_Cvar_VariableValue -5
equ trap_Cvar_VariableStringBuffer -6
equ trap_Cvar_SetValue -7
equ trap_Cvar_Reset -8
equ trap_Cvar_Create -9
equ trap_Cvar_InfoStringBuffer -10
equ trap_Argc -11
equ trap_Argv -12
equ trap_Cmd_ExecuteText -13
equ trap_FS_FOpenFile -14
equ trap_FS_Read -15
equ trap_FS_Write -16
equ trap_FS_FCloseFile -17
equ trap_FS_GetFileList -18
equ trap_R_RegisterModel -19
equ trap_R_RegisterSkin -20
equ trap_R_RegisterShaderNoMip -21
equ trap_R_ClearScene -22
equ trap_R_AddRefEntityToScene -23
equ trap_R_AddPolyToScene -24
equ trap_R_AddLightToScene -25
equ trap_R_RenderScene -26
equ trap_R_SetColor -27
equ trap_R_DrawStretchPic -28
equ trap_UpdateScreen -29
equ trap_CM_LerpTag -30
equ trap_CM_LoadModel -31
equ trap_S_RegisterSound -32
equ trap_S_StartLocalSound -33
equ trap_Key_KeynumToStringBuf -34
equ trap_Key_GetBindingBuf -35
equ trap_Key_SetBinding -36
equ trap_Key_IsDown -37
equ trap_Key_GetOverstrikeMode -38
equ trap_Key_SetOverstrikeMode -39
equ trap_Key_ClearStates -40
equ trap_Key_GetCatcher -41
equ trap_Key_SetCatcher -42
equ trap_GetClipboardData -43
equ trap_GetGlconfig -44
equ trap_GetClientState -45
equ trap_GetConfigString -46
equ trap_LAN_GetPingQueueCount -47
equ trap_LAN_ClearPing -48
equ trap_LAN_GetPing -49
equ trap_LAN_GetPingInfo -50
equ trap_Cvar_Register -51
equ trap_Cvar_Update -52
equ trap_MemoryRemaining -53
equ trap_GetCDKey -54
equ trap_SetCDKey -55
equ trap_R_RegisterFont -56
equ trap_R_ModelBounds -57
equ trap_PC_AddGlobalDefine -58
equ trap_PC_LoadSource -59
equ trap_PC_FreeSource -60
equ trap_PC_ReadToken -61
equ trap_PC_SourceFileAndLine -62
equ trap_S_StopBackgroundTrack -63
equ trap_S_StartBackgroundTrack -64
equ trap_RealTime -65
equ trap_LAN_GetServerCount -66
equ trap_LAN_GetServerAddressString -67
equ trap_LAN_GetServerInfo -68
equ trap_LAN_MarkServerVisible -69
equ trap_LAN_UpdateVisiblePings -70
equ trap_LAN_ResetPings -71
equ trap_LAN_LoadCachedServers -72
equ trap_LAN_SaveCachedServers -73
equ trap_LAN_AddServer -74
equ trap_LAN_RemoveServer -75
equ trap_CIN_PlayCinematic -76
equ trap_CIN_StopCinematic -77
equ trap_CIN_RunCinematic -78
equ trap_CIN_DrawCinematic -79
equ trap_CIN_SetExtents -80
equ trap_R_RemapShader -81
equ trap_VerifyCDKey -82
equ trap_LAN_ServerStatus -83
equ trap_LAN_GetServerPing -84
equ trap_LAN_ServerIsVisible -85
equ trap_LAN_CompareServers -86
equ trap_FS_Seek -87
equ trap_SetPbClStatus -88
equ memset -101
equ memcpy -102
equ strncpy -103
equ sin -104
equ cos -105
equ atan2 -106
equ sqrt -107
equ floor -108
equ ceil -109
code
equ trap_Error -1
equ trap_Print -2
equ trap_Milliseconds -3
equ trap_Cvar_Set -4
equ trap_Cvar_VariableValue -5
equ trap_Cvar_VariableStringBuffer -6
equ trap_Cvar_SetValue -7
equ trap_Cvar_Reset -8
equ trap_Cvar_Create -9
equ trap_Cvar_InfoStringBuffer -10
equ trap_Argc -11
equ trap_Argv -12
equ trap_Cmd_ExecuteText -13
equ trap_FS_FOpenFile -14
equ trap_FS_Read -15
equ trap_FS_Write -16
equ trap_FS_FCloseFile -17
equ trap_FS_GetFileList -18
equ trap_R_RegisterModel -19
equ trap_R_RegisterSkin -20
equ trap_R_RegisterShaderNoMip -21
equ trap_R_ClearScene -22
equ trap_R_AddRefEntityToScene -23
equ trap_R_AddPolyToScene -24
equ trap_R_AddLightToScene -25
equ trap_R_RenderScene -26
equ trap_R_SetColor -27
equ trap_R_DrawStretchPic -28
equ trap_UpdateScreen -29
equ trap_CM_LerpTag -30
equ trap_CM_LoadModel -31
equ trap_S_RegisterSound -32
equ trap_S_StartLocalSound -33
equ trap_Key_KeynumToStringBuf -34
equ trap_Key_GetBindingBuf -35
equ trap_Key_SetBinding -36
equ trap_Key_IsDown -37
equ trap_Key_GetOverstrikeMode -38
equ trap_Key_SetOverstrikeMode -39
equ trap_Key_ClearStates -40
equ trap_Key_GetCatcher -41
equ trap_Key_SetCatcher -42
equ trap_GetClipboardData -43
equ trap_GetGlconfig -44
equ trap_GetClientState -45
equ trap_GetConfigString -46
equ trap_LAN_GetPingQueueCount -47
equ trap_LAN_ClearPing -48
equ trap_LAN_GetPing -49
equ trap_LAN_GetPingInfo -50
equ trap_Cvar_Register -51
equ trap_Cvar_Update -52
equ trap_MemoryRemaining -53
equ trap_GetCDKey -54
equ trap_SetCDKey -55
equ trap_R_RegisterFont -56
equ trap_R_ModelBounds -57
equ trap_PC_AddGlobalDefine -58
equ trap_PC_LoadSource -59
equ trap_PC_FreeSource -60
equ trap_PC_ReadToken -61
equ trap_PC_SourceFileAndLine -62
equ trap_S_StopBackgroundTrack -63
equ trap_S_StartBackgroundTrack -64
equ trap_RealTime -65
equ trap_LAN_GetServerCount -66
equ trap_LAN_GetServerAddressString -67
equ trap_LAN_GetServerInfo -68
equ trap_LAN_MarkServerVisible -69
equ trap_LAN_UpdateVisiblePings -70
equ trap_LAN_ResetPings -71
equ trap_LAN_LoadCachedServers -72
equ trap_LAN_SaveCachedServers -73
equ trap_LAN_AddServer -74
equ trap_LAN_RemoveServer -75
equ trap_CIN_PlayCinematic -76
equ trap_CIN_StopCinematic -77
equ trap_CIN_RunCinematic -78
equ trap_CIN_DrawCinematic -79
equ trap_CIN_SetExtents -80
equ trap_R_RemapShader -81
equ trap_VerifyCDKey -82
equ trap_LAN_ServerStatus -83
equ trap_LAN_GetServerPing -84
equ trap_LAN_ServerIsVisible -85
equ trap_LAN_CompareServers -86
equ trap_FS_Seek -87
equ trap_SetPbClStatus -88
equ memset -101
equ memcpy -102
equ strncpy -103
equ sin -104
equ cos -105
equ atan2 -106
equ sqrt -107
equ floor -108
equ ceil -109

802
code/ui/ui_syscalls.c Normal file → Executable file
View file

@ -1,401 +1,401 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
// this file is only included when building a dll
// syscalls.asm is included instead when building a qvm
#ifdef Q3_VM
#error "Do not use in VM build"
#endif
static int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;
void dllEntry( int (QDECL *syscallptr)( int arg,... ) ) {
syscall = syscallptr;
}
int PASSFLOAT( float x ) {
float floatTemp;
floatTemp = x;
return *(int *)&floatTemp;
}
void trap_Print( const char *string ) {
syscall( UI_PRINT, string );
}
void trap_Error( const char *string ) {
syscall( UI_ERROR, string );
}
int trap_Milliseconds( void ) {
return syscall( UI_MILLISECONDS );
}
void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {
syscall( UI_CVAR_REGISTER, cvar, var_name, value, flags );
}
void trap_Cvar_Update( vmCvar_t *cvar ) {
syscall( UI_CVAR_UPDATE, cvar );
}
void trap_Cvar_Set( const char *var_name, const char *value ) {
syscall( UI_CVAR_SET, var_name, value );
}
float trap_Cvar_VariableValue( const char *var_name ) {
int temp;
temp = syscall( UI_CVAR_VARIABLEVALUE, var_name );
return (*(float*)&temp);
}
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
syscall( UI_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
}
void trap_Cvar_SetValue( const char *var_name, float value ) {
syscall( UI_CVAR_SETVALUE, var_name, PASSFLOAT( value ) );
}
void trap_Cvar_Reset( const char *name ) {
syscall( UI_CVAR_RESET, name );
}
void trap_Cvar_Create( const char *var_name, const char *var_value, int flags ) {
syscall( UI_CVAR_CREATE, var_name, var_value, flags );
}
void trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ) {
syscall( UI_CVAR_INFOSTRINGBUFFER, bit, buffer, bufsize );
}
int trap_Argc( void ) {
return syscall( UI_ARGC );
}
void trap_Argv( int n, char *buffer, int bufferLength ) {
syscall( UI_ARGV, n, buffer, bufferLength );
}
void trap_Cmd_ExecuteText( int exec_when, const char *text ) {
syscall( UI_CMD_EXECUTETEXT, exec_when, text );
}
int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {
return syscall( UI_FS_FOPENFILE, qpath, f, mode );
}
void trap_FS_Read( void *buffer, int len, fileHandle_t f ) {
syscall( UI_FS_READ, buffer, len, f );
}
void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) {
syscall( UI_FS_WRITE, buffer, len, f );
}
void trap_FS_FCloseFile( fileHandle_t f ) {
syscall( UI_FS_FCLOSEFILE, f );
}
int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ) {
return syscall( UI_FS_GETFILELIST, path, extension, listbuf, bufsize );
}
int trap_FS_Seek( fileHandle_t f, long offset, int origin ) {
return syscall( UI_FS_SEEK, f, offset, origin );
}
qhandle_t trap_R_RegisterModel( const char *name ) {
return syscall( UI_R_REGISTERMODEL, name );
}
qhandle_t trap_R_RegisterSkin( const char *name ) {
return syscall( UI_R_REGISTERSKIN, name );
}
void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
syscall( UI_R_REGISTERFONT, fontName, pointSize, font );
}
qhandle_t trap_R_RegisterShaderNoMip( const char *name ) {
return syscall( UI_R_REGISTERSHADERNOMIP, name );
}
void trap_R_ClearScene( void ) {
syscall( UI_R_CLEARSCENE );
}
void trap_R_AddRefEntityToScene( const refEntity_t *re ) {
syscall( UI_R_ADDREFENTITYTOSCENE, re );
}
void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) {
syscall( UI_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
}
void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
syscall( UI_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
}
void trap_R_RenderScene( const refdef_t *fd ) {
syscall( UI_R_RENDERSCENE, fd );
}
void trap_R_SetColor( const float *rgba ) {
syscall( UI_R_SETCOLOR, rgba );
}
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) {
syscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
}
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {
syscall( UI_R_MODELBOUNDS, model, mins, maxs );
}
void trap_UpdateScreen( void ) {
syscall( UI_UPDATESCREEN );
}
int trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) {
return syscall( UI_CM_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );
}
void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {
syscall( UI_S_STARTLOCALSOUND, sfx, channelNum );
}
sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ) {
return syscall( UI_S_REGISTERSOUND, sample, compressed );
}
void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) {
syscall( UI_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen );
}
void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
syscall( UI_KEY_GETBINDINGBUF, keynum, buf, buflen );
}
void trap_Key_SetBinding( int keynum, const char *binding ) {
syscall( UI_KEY_SETBINDING, keynum, binding );
}
qboolean trap_Key_IsDown( int keynum ) {
return syscall( UI_KEY_ISDOWN, keynum );
}
qboolean trap_Key_GetOverstrikeMode( void ) {
return syscall( UI_KEY_GETOVERSTRIKEMODE );
}
void trap_Key_SetOverstrikeMode( qboolean state ) {
syscall( UI_KEY_SETOVERSTRIKEMODE, state );
}
void trap_Key_ClearStates( void ) {
syscall( UI_KEY_CLEARSTATES );
}
int trap_Key_GetCatcher( void ) {
return syscall( UI_KEY_GETCATCHER );
}
void trap_Key_SetCatcher( int catcher ) {
syscall( UI_KEY_SETCATCHER, catcher );
}
void trap_GetClipboardData( char *buf, int bufsize ) {
syscall( UI_GETCLIPBOARDDATA, buf, bufsize );
}
void trap_GetClientState( uiClientState_t *state ) {
syscall( UI_GETCLIENTSTATE, state );
}
void trap_GetGlconfig( glconfig_t *glconfig ) {
syscall( UI_GETGLCONFIG, glconfig );
}
int trap_GetConfigString( int index, char* buff, int buffsize ) {
return syscall( UI_GETCONFIGSTRING, index, buff, buffsize );
}
int trap_LAN_GetServerCount( int source ) {
return syscall( UI_LAN_GETSERVERCOUNT, source );
}
void trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) {
syscall( UI_LAN_GETSERVERADDRESSSTRING, source, n, buf, buflen );
}
void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ) {
syscall( UI_LAN_GETSERVERINFO, source, n, buf, buflen );
}
int trap_LAN_GetServerPing( int source, int n ) {
return syscall( UI_LAN_GETSERVERPING, source, n );
}
int trap_LAN_GetPingQueueCount( void ) {
return syscall( UI_LAN_GETPINGQUEUECOUNT );
}
int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ) {
return syscall( UI_LAN_SERVERSTATUS, serverAddress, serverStatus, maxLen );
}
void trap_LAN_SaveCachedServers() {
syscall( UI_LAN_SAVECACHEDSERVERS );
}
void trap_LAN_LoadCachedServers() {
syscall( UI_LAN_LOADCACHEDSERVERS );
}
void trap_LAN_ResetPings(int n) {
syscall( UI_LAN_RESETPINGS, n );
}
void trap_LAN_ClearPing( int n ) {
syscall( UI_LAN_CLEARPING, n );
}
void trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) {
syscall( UI_LAN_GETPING, n, buf, buflen, pingtime );
}
void trap_LAN_GetPingInfo( int n, char *buf, int buflen ) {
syscall( UI_LAN_GETPINGINFO, n, buf, buflen );
}
void trap_LAN_MarkServerVisible( int source, int n, qboolean visible ) {
syscall( UI_LAN_MARKSERVERVISIBLE, source, n, visible );
}
int trap_LAN_ServerIsVisible( int source, int n) {
return syscall( UI_LAN_SERVERISVISIBLE, source, n );
}
qboolean trap_LAN_UpdateVisiblePings( int source ) {
return syscall( UI_LAN_UPDATEVISIBLEPINGS, source );
}
int trap_LAN_AddServer(int source, const char *name, const char *addr) {
return syscall( UI_LAN_ADDSERVER, source, name, addr );
}
void trap_LAN_RemoveServer(int source, const char *addr) {
syscall( UI_LAN_REMOVESERVER, source, addr );
}
int trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) {
return syscall( UI_LAN_COMPARESERVERS, source, sortKey, sortDir, s1, s2 );
}
int trap_MemoryRemaining( void ) {
return syscall( UI_MEMORY_REMAINING );
}
void trap_GetCDKey( char *buf, int buflen ) {
syscall( UI_GET_CDKEY, buf, buflen );
}
void trap_SetCDKey( char *buf ) {
syscall( UI_SET_CDKEY, buf );
}
int trap_PC_AddGlobalDefine( char *define ) {
return syscall( UI_PC_ADD_GLOBAL_DEFINE, define );
}
int trap_PC_LoadSource( const char *filename ) {
return syscall( UI_PC_LOAD_SOURCE, filename );
}
int trap_PC_FreeSource( int handle ) {
return syscall( UI_PC_FREE_SOURCE, handle );
}
int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {
return syscall( UI_PC_READ_TOKEN, handle, pc_token );
}
int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {
return syscall( UI_PC_SOURCE_FILE_AND_LINE, handle, filename, line );
}
void trap_S_StopBackgroundTrack( void ) {
syscall( UI_S_STOPBACKGROUNDTRACK );
}
void trap_S_StartBackgroundTrack( const char *intro, const char *loop) {
syscall( UI_S_STARTBACKGROUNDTRACK, intro, loop );
}
int trap_RealTime(qtime_t *qtime) {
return syscall( UI_REAL_TIME, qtime );
}
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) {
return syscall(UI_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);
}
// stops playing the cinematic and ends it. should always return FMV_EOF
// cinematics must be stopped in reverse order of when they are started
e_status trap_CIN_StopCinematic(int handle) {
return syscall(UI_CIN_STOPCINEMATIC, handle);
}
// will run a frame of the cinematic but will not draw it. Will return FMV_EOF if the end of the cinematic has been reached.
e_status trap_CIN_RunCinematic (int handle) {
return syscall(UI_CIN_RUNCINEMATIC, handle);
}
// draws the current frame
void trap_CIN_DrawCinematic (int handle) {
syscall(UI_CIN_DRAWCINEMATIC, handle);
}
// allows you to resize the animation dynamically
void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) {
syscall(UI_CIN_SETEXTENTS, handle, x, y, w, h);
}
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) {
syscall( UI_R_REMAP_SHADER, oldShader, newShader, timeOffset );
}
qboolean trap_VerifyCDKey( const char *key, const char *chksum) {
return syscall( UI_VERIFY_CDKEY, key, chksum);
}
void trap_SetPbClStatus( int status ) {
syscall( UI_SET_PBCLSTATUS, status );
}
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "ui_local.h"
// this file is only included when building a dll
// syscalls.asm is included instead when building a qvm
#ifdef Q3_VM
#error "Do not use in VM build"
#endif
static int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;
void dllEntry( int (QDECL *syscallptr)( int arg,... ) ) {
syscall = syscallptr;
}
int PASSFLOAT( float x ) {
float floatTemp;
floatTemp = x;
return *(int *)&floatTemp;
}
void trap_Print( const char *string ) {
syscall( UI_PRINT, string );
}
void trap_Error( const char *string ) {
syscall( UI_ERROR, string );
}
int trap_Milliseconds( void ) {
return syscall( UI_MILLISECONDS );
}
void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {
syscall( UI_CVAR_REGISTER, cvar, var_name, value, flags );
}
void trap_Cvar_Update( vmCvar_t *cvar ) {
syscall( UI_CVAR_UPDATE, cvar );
}
void trap_Cvar_Set( const char *var_name, const char *value ) {
syscall( UI_CVAR_SET, var_name, value );
}
float trap_Cvar_VariableValue( const char *var_name ) {
int temp;
temp = syscall( UI_CVAR_VARIABLEVALUE, var_name );
return (*(float*)&temp);
}
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
syscall( UI_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
}
void trap_Cvar_SetValue( const char *var_name, float value ) {
syscall( UI_CVAR_SETVALUE, var_name, PASSFLOAT( value ) );
}
void trap_Cvar_Reset( const char *name ) {
syscall( UI_CVAR_RESET, name );
}
void trap_Cvar_Create( const char *var_name, const char *var_value, int flags ) {
syscall( UI_CVAR_CREATE, var_name, var_value, flags );
}
void trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ) {
syscall( UI_CVAR_INFOSTRINGBUFFER, bit, buffer, bufsize );
}
int trap_Argc( void ) {
return syscall( UI_ARGC );
}
void trap_Argv( int n, char *buffer, int bufferLength ) {
syscall( UI_ARGV, n, buffer, bufferLength );
}
void trap_Cmd_ExecuteText( int exec_when, const char *text ) {
syscall( UI_CMD_EXECUTETEXT, exec_when, text );
}
int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {
return syscall( UI_FS_FOPENFILE, qpath, f, mode );
}
void trap_FS_Read( void *buffer, int len, fileHandle_t f ) {
syscall( UI_FS_READ, buffer, len, f );
}
void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) {
syscall( UI_FS_WRITE, buffer, len, f );
}
void trap_FS_FCloseFile( fileHandle_t f ) {
syscall( UI_FS_FCLOSEFILE, f );
}
int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ) {
return syscall( UI_FS_GETFILELIST, path, extension, listbuf, bufsize );
}
int trap_FS_Seek( fileHandle_t f, long offset, int origin ) {
return syscall( UI_FS_SEEK, f, offset, origin );
}
qhandle_t trap_R_RegisterModel( const char *name ) {
return syscall( UI_R_REGISTERMODEL, name );
}
qhandle_t trap_R_RegisterSkin( const char *name ) {
return syscall( UI_R_REGISTERSKIN, name );
}
void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
syscall( UI_R_REGISTERFONT, fontName, pointSize, font );
}
qhandle_t trap_R_RegisterShaderNoMip( const char *name ) {
return syscall( UI_R_REGISTERSHADERNOMIP, name );
}
void trap_R_ClearScene( void ) {
syscall( UI_R_CLEARSCENE );
}
void trap_R_AddRefEntityToScene( const refEntity_t *re ) {
syscall( UI_R_ADDREFENTITYTOSCENE, re );
}
void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) {
syscall( UI_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
}
void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
syscall( UI_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
}
void trap_R_RenderScene( const refdef_t *fd ) {
syscall( UI_R_RENDERSCENE, fd );
}
void trap_R_SetColor( const float *rgba ) {
syscall( UI_R_SETCOLOR, rgba );
}
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) {
syscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
}
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {
syscall( UI_R_MODELBOUNDS, model, mins, maxs );
}
void trap_UpdateScreen( void ) {
syscall( UI_UPDATESCREEN );
}
int trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) {
return syscall( UI_CM_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );
}
void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {
syscall( UI_S_STARTLOCALSOUND, sfx, channelNum );
}
sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ) {
return syscall( UI_S_REGISTERSOUND, sample, compressed );
}
void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) {
syscall( UI_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen );
}
void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
syscall( UI_KEY_GETBINDINGBUF, keynum, buf, buflen );
}
void trap_Key_SetBinding( int keynum, const char *binding ) {
syscall( UI_KEY_SETBINDING, keynum, binding );
}
qboolean trap_Key_IsDown( int keynum ) {
return syscall( UI_KEY_ISDOWN, keynum );
}
qboolean trap_Key_GetOverstrikeMode( void ) {
return syscall( UI_KEY_GETOVERSTRIKEMODE );
}
void trap_Key_SetOverstrikeMode( qboolean state ) {
syscall( UI_KEY_SETOVERSTRIKEMODE, state );
}
void trap_Key_ClearStates( void ) {
syscall( UI_KEY_CLEARSTATES );
}
int trap_Key_GetCatcher( void ) {
return syscall( UI_KEY_GETCATCHER );
}
void trap_Key_SetCatcher( int catcher ) {
syscall( UI_KEY_SETCATCHER, catcher );
}
void trap_GetClipboardData( char *buf, int bufsize ) {
syscall( UI_GETCLIPBOARDDATA, buf, bufsize );
}
void trap_GetClientState( uiClientState_t *state ) {
syscall( UI_GETCLIENTSTATE, state );
}
void trap_GetGlconfig( glconfig_t *glconfig ) {
syscall( UI_GETGLCONFIG, glconfig );
}
int trap_GetConfigString( int index, char* buff, int buffsize ) {
return syscall( UI_GETCONFIGSTRING, index, buff, buffsize );
}
int trap_LAN_GetServerCount( int source ) {
return syscall( UI_LAN_GETSERVERCOUNT, source );
}
void trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) {
syscall( UI_LAN_GETSERVERADDRESSSTRING, source, n, buf, buflen );
}
void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ) {
syscall( UI_LAN_GETSERVERINFO, source, n, buf, buflen );
}
int trap_LAN_GetServerPing( int source, int n ) {
return syscall( UI_LAN_GETSERVERPING, source, n );
}
int trap_LAN_GetPingQueueCount( void ) {
return syscall( UI_LAN_GETPINGQUEUECOUNT );
}
int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ) {
return syscall( UI_LAN_SERVERSTATUS, serverAddress, serverStatus, maxLen );
}
void trap_LAN_SaveCachedServers() {
syscall( UI_LAN_SAVECACHEDSERVERS );
}
void trap_LAN_LoadCachedServers() {
syscall( UI_LAN_LOADCACHEDSERVERS );
}
void trap_LAN_ResetPings(int n) {
syscall( UI_LAN_RESETPINGS, n );
}
void trap_LAN_ClearPing( int n ) {
syscall( UI_LAN_CLEARPING, n );
}
void trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) {
syscall( UI_LAN_GETPING, n, buf, buflen, pingtime );
}
void trap_LAN_GetPingInfo( int n, char *buf, int buflen ) {
syscall( UI_LAN_GETPINGINFO, n, buf, buflen );
}
void trap_LAN_MarkServerVisible( int source, int n, qboolean visible ) {
syscall( UI_LAN_MARKSERVERVISIBLE, source, n, visible );
}
int trap_LAN_ServerIsVisible( int source, int n) {
return syscall( UI_LAN_SERVERISVISIBLE, source, n );
}
qboolean trap_LAN_UpdateVisiblePings( int source ) {
return syscall( UI_LAN_UPDATEVISIBLEPINGS, source );
}
int trap_LAN_AddServer(int source, const char *name, const char *addr) {
return syscall( UI_LAN_ADDSERVER, source, name, addr );
}
void trap_LAN_RemoveServer(int source, const char *addr) {
syscall( UI_LAN_REMOVESERVER, source, addr );
}
int trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) {
return syscall( UI_LAN_COMPARESERVERS, source, sortKey, sortDir, s1, s2 );
}
int trap_MemoryRemaining( void ) {
return syscall( UI_MEMORY_REMAINING );
}
void trap_GetCDKey( char *buf, int buflen ) {
syscall( UI_GET_CDKEY, buf, buflen );
}
void trap_SetCDKey( char *buf ) {
syscall( UI_SET_CDKEY, buf );
}
int trap_PC_AddGlobalDefine( char *define ) {
return syscall( UI_PC_ADD_GLOBAL_DEFINE, define );
}
int trap_PC_LoadSource( const char *filename ) {
return syscall( UI_PC_LOAD_SOURCE, filename );
}
int trap_PC_FreeSource( int handle ) {
return syscall( UI_PC_FREE_SOURCE, handle );
}
int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {
return syscall( UI_PC_READ_TOKEN, handle, pc_token );
}
int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {
return syscall( UI_PC_SOURCE_FILE_AND_LINE, handle, filename, line );
}
void trap_S_StopBackgroundTrack( void ) {
syscall( UI_S_STOPBACKGROUNDTRACK );
}
void trap_S_StartBackgroundTrack( const char *intro, const char *loop) {
syscall( UI_S_STARTBACKGROUNDTRACK, intro, loop );
}
int trap_RealTime(qtime_t *qtime) {
return syscall( UI_REAL_TIME, qtime );
}
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) {
return syscall(UI_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);
}
// stops playing the cinematic and ends it. should always return FMV_EOF
// cinematics must be stopped in reverse order of when they are started
e_status trap_CIN_StopCinematic(int handle) {
return syscall(UI_CIN_STOPCINEMATIC, handle);
}
// will run a frame of the cinematic but will not draw it. Will return FMV_EOF if the end of the cinematic has been reached.
e_status trap_CIN_RunCinematic (int handle) {
return syscall(UI_CIN_RUNCINEMATIC, handle);
}
// draws the current frame
void trap_CIN_DrawCinematic (int handle) {
syscall(UI_CIN_DRAWCINEMATIC, handle);
}
// allows you to resize the animation dynamically
void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) {
syscall(UI_CIN_SETEXTENTS, handle, x, y, w, h);
}
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) {
syscall( UI_R_REMAP_SHADER, oldShader, newShader, timeOffset );
}
qboolean trap_VerifyCDKey( const char *key, const char *chksum) {
return syscall( UI_VERIFY_CDKEY, key, chksum);
}
void trap_SetPbClStatus( int status ) {
syscall( UI_SET_PBCLSTATUS, status );
}

58
code/ui/ui_util.c Normal file → Executable file
View file

@ -1,29 +1,29 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// ui_util.c
//
// origin: rad
// new ui support stuff
//
// memory, string alloc
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// ui_util.c
//
// origin: rad
// new ui support stuff
//
// memory, string alloc