Replacements and stuff

This commit is contained in:
Andrei Drexler 2003-03-31 00:23:18 +00:00
parent 8e78110528
commit 5d216907fd
8 changed files with 710 additions and 100 deletions

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.11 2003/03/31 00:23:18 makro
// Replacements and stuff
//
// Revision 1.10 2002/12/09 00:58:49 makro
// Items are now disabled from the weapon/item menus in teamplay
// games if they are banned from the server
@ -104,6 +107,8 @@
#define FEEDER_INGAME_SERVERINFO 0x10
//Makro - for the captains' ingame menu
#define FEEDER_MMHEADS 0x11
//Makro - replacements
#define FEEDER_REPLACEMENTS 0x12
// display flags
#define CG_SHOW_BLUE_TEAM_HAS_REDFLAG 0x00000001
@ -158,6 +163,8 @@
#define UI_SHOW_ITEM6 0x02000000
//Makro - toggle
#define UI_SHOW_TOGGLE 0x04000000
//Makro - hack !
#define UI_SHOW_REPLACEMENT 0x08000000
// owner draw types
@ -260,6 +267,13 @@
#define UI_RQ3_JOINTEAM1 161
#define UI_RQ3_JOINTEAM2 162
//Makro - replacement model info
#define UI_RQ3_REPLACEMENTINFO 163
#define UI_RQ3_REPLACEMENTNAME 164
#define UI_RQ3_REPLACEMENTMODEL 165
#define UI_RQ3_REPLACEMENTTYPE 166
#define UI_RQ3_REPLACEMENTSUBTYPE 167
#define UI_OWNERDRAW_BASE 200
#define UI_HANDICAP 200
#define UI_EFFECTS 201

View file

@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UI_EXPORTS" /YX /FD /c
# ADD CPP /nologo /G6 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UI_EXPORTS" /YX /FD /c
# ADD CPP /nologo /G6 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UI_EXPORTS" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"

View file

@ -6,42 +6,6 @@
--------------------Configuration: ui - Win32 Release TA--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP11D.tmp" with contents
[
/nologo /G6 /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UI_EXPORTS" /Fp"Release_TA/ta_ui.pch" /YX /Fo"Release_TA/" /Fd"Release_TA/" /FD /c
"C:\Games\Quake3\rq3source\reaction\ta_ui\ui_atoms.c"
"C:\Games\Quake3\rq3source\reaction\ta_ui\ui_gameinfo.c"
"C:\Games\Quake3\rq3source\reaction\ta_ui\ui_main.c"
"C:\Games\Quake3\rq3source\reaction\ta_ui\ui_players.c"
"C:\Games\Quake3\rq3source\reaction\ta_ui\ui_shared.c"
"C:\Games\Quake3\rq3source\reaction\ta_ui\ui_syscalls.c"
]
Creating command line "cl.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP11D.tmp"
Creating temporary file "D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP11E.tmp" with contents
[
/nologo /base:"0x40000000" /dll /incremental:no /pdb:"Release_TA/uix86.pdb" /map:"Release_TA/uix86.map" /machine:I386 /def:".\ui.def" /out:"../Release/uix86.dll" /implib:"Release_TA/uix86.lib"
.\Release_TA\bg_misc.obj
.\Release_TA\q_math.obj
.\Release_TA\q_shared.obj
.\Release_TA\ui_atoms.obj
.\Release_TA\ui_gameinfo.obj
.\Release_TA\ui_main.obj
.\Release_TA\ui_players.obj
.\Release_TA\ui_shared.obj
.\Release_TA\ui_syscalls.obj
.\Release_TA\ui_util.obj
]
Creating command line "link.exe @D:\DOCUME~1\Andrei\LOCALS~1\Temp\RSP11E.tmp"
<h3>Output Window</h3>
Compiling...
ui_atoms.c
ui_gameinfo.c
ui_main.c
ui_players.c
ui_shared.c
ui_syscalls.c
Linking...
Creating library Release_TA/uix86.lib and object Release_TA/uix86.exp

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.20 2003/03/31 00:23:18 makro
// Replacements and stuff
//
// Revision 1.19 2002/12/09 00:58:49 makro
// Items are now disabled from the weapon/item menus in teamplay
// games if they are banned from the server
@ -385,6 +388,7 @@ qboolean UI_RQ3_WeaponMenuAccess()
UI_ConsoleCommand
=================
*/
qboolean UI_ConsoleCommand(int realTime)
{
char *cmd;

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.24 2003/03/31 00:23:18 makro
// Replacements and stuff
//
// Revision 1.23 2003/02/13 21:19:50 makro
// no message
//
@ -869,6 +872,24 @@ typedef struct {
int numLines;
} serverStatusInfo_t;
//Makro - added
#define MAX_UI_REPLACEMENTS 256
typedef struct {
//Makro - model replacements
char Files[MAX_UI_REPLACEMENTS][128];
char Name[32];
int Model;
qhandle_t Skin;
char Cvars[MAX_UI_REPLACEMENTS][64];
char Type[64], Dir[64];
int TypeIndex, SubtypeIndex;
char Info[1024];
int Count, Index;
vec3_t origin, angles;
int speed, fovx, fovy;
} replacementInfo_t;
typedef struct {
const char *modName;
const char *modDescr;
@ -926,6 +947,8 @@ typedef struct {
int modIndex;
const char *demoList[MAX_DEMOS];
//Makro - added demoType; can be either 66, 67 or 68
int demoType[MAX_DEMOS];
int demoCount;
int demoIndex;
@ -955,6 +978,9 @@ typedef struct {
float oldMusicVol;
qboolean savedMusicVol;
//Makro - model replacements
replacementInfo_t replacements;
int startPostGameTime;
sfxHandle_t newHighScoreSound;

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.65 2003/03/31 00:23:18 makro
// Replacements and stuff
//
// Revision 1.64 2003/03/28 10:36:02 jbravo
// Tweaking the replacement system a bit. Reactionmale now the default model
//
@ -244,6 +247,56 @@ static const char *netSources[] = {
};
static const int numNetSources = sizeof(netSources) / sizeof(const char *);
//Makro - replacement types/subtypes
typedef struct {
const char *displayName, *cvarName;
} replacementSubtype_t;
static replacementSubtype_t replacementTypes[] = {
{"Weapons", "weapons2"},
{"Items", "items"},
{"Ammo", "ammo"}
};
static const int replacementTypeCount = sizeof(replacementTypes) / sizeof(replacementSubtype_t);
// WEAPONS //
static replacementSubtype_t replacementWeapons[] =
{
{"Mk23", "mk23"},
{"M3", "m3"},
{"MP5", "mp5"},
{"Handcannon", "handcannon"},
{"SSG3000", "ssg3000"},
{"M4", "m4"},
{"Grenade", "grenade"},
{"Akimbo", "akimbo"},
{"Knife", "knife"}
};
static const int replacementWeapCount = sizeof(replacementWeapons) / sizeof(replacementSubtype_t);
// ITEMS //
static replacementSubtype_t replacementItems[] =
{
{"Kevlar", "kevlar"},
{"Bandolier", "bandolier"},
{"Silencer", "silencer"},
{"Laser", "laser"},
{"Slippers", "slippers"},
{"Helmet", "helmet"}
};
static const int replacementItemCount = sizeof(replacementItems) / sizeof(replacementSubtype_t);
// AMMO //
static replacementSubtype_t replacementAmmo[] =
{
{"Mk23", "ammo_mk23"},
{"Shells", "ammo_shells"},
{"SSG3000", "ammo_ssg3000"},
{"MP5", "ammo_mp5"},
{"M4", "ammo_m4"}
};
static const int replacementAmmoCount = sizeof(replacementAmmo) / sizeof(replacementSubtype_t);
static const serverFilter_t serverFilters[] = {
//Makro - we only want Reaction servers in the server list
/* {"All", "" },
@ -2262,6 +2315,14 @@ static int UI_OwnerDrawWidth(int ownerDraw, float scale)
case UI_SERVERREFRESHDATE:
s = UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer));
break;
//Makro - replacement model name
case UI_RQ3_REPLACEMENTNAME:
s = uiInfo.replacements.Name;
break;
//Makro - replacement model info
case UI_RQ3_REPLACEMENTINFO:
s = uiInfo.replacements.Info;
break;
default:
break;
}
@ -2469,6 +2530,144 @@ void UI_BuildIngameServerInfoList()
}
/*
===============
UI_BuildReplacementList
Added by Makro
===============
*/
char *GetLine(char **buf)
{
char *p;
if (!buf || !*buf)
return NULL;
//p = strchrstr(*buf, "\n\r");
p = strchr(*buf, '\n');
if (!p)
{
p=*buf;
*buf+=strlen(p);
} else {
int i = 0;
while (*p=='\r' || *p=='\n')
{
i++;
*(p--)=0;
}
p=*buf;
*buf+=strlen(p)+i;
}
return p;
}
void UI_AddReplacement(char *filename)
{
int len;
fileHandle_t f;
char buf[4096], *text;
if (uiInfo.replacements.Count < MAX_UI_REPLACEMENTS)
{
len = trap_FS_FOpenFile(filename, &f, FS_READ);
if (!f)
return;
if (len >= sizeof(buf))
return;
trap_FS_Read(buf, len, f);
buf[len] = 0;
trap_FS_FCloseFile(f);
text = buf;
Q_strncpyz(uiInfo.replacements.Files[uiInfo.replacements.Count], filename, sizeof(uiInfo.replacements.Files[uiInfo.replacements.Count]));
/*
//line 1 - replacement name
Q_strncpyz(uiInfo.replacementNames[uiInfo.replacementCount], GetLine(&text), sizeof(uiInfo.replacementNames[uiInfo.replacementCount]));
//line 2 - cvar value
Q_strncpyz(uiInfo.replacementCvars[uiInfo.replacementCount], GetLine(&text), sizeof(uiInfo.replacementCvars[uiInfo.replacementCount]));
*/
//line 1 - replacement name
GetLine(&text);
//line 2 - cvar value
Q_strncpyz(uiInfo.replacements.Cvars[uiInfo.replacements.Count], GetLine(&text), sizeof(uiInfo.replacements.Cvars[uiInfo.replacements.Count]));
if (!Q_stricmp(UI_Cvar_VariableString(va("cg_RQ3_%s", uiInfo.replacements.Type)), text))
uiInfo.replacements.Index = uiInfo.replacements.Count;
uiInfo.replacements.Count++;
}
}
void UI_BuildReplacementList(const char *type)
{
int i, numfiles, filelen;
char filelist[2048], *fileptr;
if (!type || !*type)
return;
uiInfo.replacements.Count = 0;
uiInfo.replacements.Index = 0;
Q_strncpyz(uiInfo.replacements.Type, type, sizeof(uiInfo.replacements.Type));
numfiles = trap_FS_GetFileList("models/replacements", "cfg", filelist, sizeof(filelist));
fileptr = filelist;
for (i = 0; i < numfiles && uiInfo.replacements.Count < MAX_UI_REPLACEMENTS; i++, fileptr += filelen + 1)
{
filelen = strlen(fileptr);
if (strnicmp(fileptr, va("%s_", type), strlen(type)+1))
continue;
UI_AddReplacement(va("models/replacements/%s", fileptr));
}
//Com_Printf("Read info for %i replacement(s) of type %s\n", uiInfo.replacementCount, uiInfo.replacementType);
}
void UI_LoadReplacement(int index)
{
int len;
fileHandle_t f;
char buf[4096], *p, *text, skin[MAX_QPATH], model[MAX_QPATH];
const char *typeDir = replacementTypes[uiInfo.replacements.TypeIndex % replacementTypeCount].cvarName;
uiInfo.replacements.Info[0]=0;
uiInfo.replacements.Name[0]=0;
//Com_Printf("UI_LoadReplacement(%i) - %s\n", index, uiInfo.replacementFiles[index]);
if (index < 0 || index >= uiInfo.replacements.Count)
return;
len = trap_FS_FOpenFile(uiInfo.replacements.Files[index], &f, FS_READ);
if (!f)
return;
if (len >= sizeof(buf))
return;
//Com_Printf("Everything's ok !\n");
trap_FS_Read(buf, len, f);
buf[len] = 0;
trap_FS_FCloseFile(f);
uiInfo.replacements.Index = index;
text = buf;
//line 1 - replacement name
Q_strncpyz(uiInfo.replacements.Name, GetLine(&text), sizeof(uiInfo.replacements.Name));
//line 2 - cvar value
p=GetLine(&text);
Q_strncpyz(model, modelFromStr(p), sizeof(model));
if (!Q_stricmp(model, "default"))
Q_strncpyz(model, uiInfo.replacements.Type, sizeof(model));
Q_strncpyz(skin, skinFromStr(p), sizeof(skin));
trap_Cvar_Set(va("cg_RQ3_%s", uiInfo.replacements.Type), p);
//line 3 - co-ordinates
p = GetLine(&text);
sscanf(p, "%f %f %f %f %f %f %i %i %i", &uiInfo.replacements.origin[0], &uiInfo.replacements.origin[1], &uiInfo.replacements.origin[2],
&uiInfo.replacements.angles[0], &uiInfo.replacements.angles[1], &uiInfo.replacements.angles[2],
&uiInfo.replacements.fovx, &uiInfo.replacements.fovy, &uiInfo.replacements.speed);
//Com_Printf("Model: %s\n", va("models/%s/%s/%s.md3", p, model, uiInfo.replacementType));
//Com_Printf("Skin : %s\n", va("models/%s/%s/%s.skin", p, model, skin));
uiInfo.replacements.Model = trap_R_RegisterModel(va("models/%s/%s/%s.md3", typeDir, model, uiInfo.replacements.Type));
uiInfo.replacements.Skin = trap_R_RegisterSkin(va("models/%s/%s/%s.skin", typeDir, model, skin));
//...replacement info
Q_strncpyz(uiInfo.replacements.Info, text, sizeof(uiInfo.replacements.Info));
}
/*
===============
UI_BuildPlayerList
@ -2686,6 +2885,174 @@ static void UI_DrawGLInfo(rectDef_t * rect, float scale, vec4_t color, int textS
}
//Makro - replacement model info
static void UI_DrawReplacementInfo(rectDef_t * rect, float scale, vec4_t color, int textStyle)
{
int y = rect->y;
char buf[4096], *text = buf, *p;
Q_strncpyz(buf, uiInfo.replacements.Info, sizeof(buf));
do {
p = GetLine(&text);
Text_Paint(rect->x, y, scale, color, p, 0, 0, textStyle);
y += Text_Height(p, scale, 0) + 4;
} while (strlen(text)>0 /*&& y<rect->h*/);
}
static void UI_DrawReplacementName(rectDef_t * rect, float scale, vec4_t color, int textStyle)
{
Text_Paint(rect->x, rect->y, scale, color, uiInfo.replacements.Name, 0, 0, textStyle);
}
static void UI_DrawReplacementType(rectDef_t * rect, float scale, vec4_t color, int textStyle)
{
const char *p = replacementTypes[uiInfo.replacements.TypeIndex % replacementTypeCount].displayName;
Text_Paint(rect->x, rect->y, scale, color, p, 0, 0, textStyle);
}
static void UI_DrawReplacementSubtype(rectDef_t * rect, float scale, vec4_t color, int textStyle)
{
const char *p;
switch (uiInfo.replacements.TypeIndex)
{
case 0:
p = replacementWeapons[uiInfo.replacements.SubtypeIndex % replacementWeapCount].displayName;
break;
case 1:
p = replacementItems[uiInfo.replacements.SubtypeIndex % replacementItemCount].displayName;
break;
case 2:
p = replacementAmmo[uiInfo.replacements.SubtypeIndex % replacementAmmoCount].displayName;
break;
default:
return;
}
Text_Paint(rect->x, rect->y, scale, color, p, 0, 0, textStyle);
}
static void UI_DrawReplacementModel(rectDef_t *rect)
/*
{
refdef_t refdef;
refEntity_t model;
vec3_t mins, maxs, origin;
float x = rect->x, y = rect->y, w = rect->w, h = rect->h;
float len;
memset(&refdef, 0, sizeof(refdef));
memset(&model, 0, sizeof(model));
refdef.rdflags = RDF_NOWORLDMODEL;
AxisClear(refdef.viewaxis);
UI_AdjustFrom640(&x, &y, &w, &h);
refdef.x = x;
refdef.y = y;
refdef.width = w;
refdef.height = h;
model.hModel = uiInfo.replacementModel;
model.customSkin = uiInfo.replacementSkin;
uiInfo.uiDC.modelBounds(model.hModel, mins, maxs);
len = 0.5 * (maxs[2] - mins[2]);
origin[0] = len / 0.268;
origin[2] = -0.5 * (mins[2] + maxs[2]);
origin[1] = 0.5 * (mins[1] + maxs[1]);
refdef.fov_x = 90;
refdef.fov_y = 90;
trap_R_ClearScene();
VectorCopy(origin, model.origin);
VectorCopy(origin, model.lightingOrigin);
model.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;
VectorCopy(model.origin, model.oldorigin);
trap_R_AddRefEntityToScene(&model);
trap_R_RenderScene(&refdef);
}
*/
{
float x, y, w, h;
refdef_t refdef;
refEntity_t ent;
vec3_t mins, maxs, origin;
vec3_t angles;
if (uiInfo.replacements.Count <= 0)
return;
// setup the refdef
memset(&refdef, 0, sizeof(refdef));
refdef.rdflags = RDF_NOWORLDMODEL;
AxisClear(refdef.viewaxis);
x = rect->x + 1;
y = rect->y + 1;
w = rect->w - 2;
h = rect->h - 2;
UI_AdjustFrom640(&x, &y, &w, &h);
refdef.x = x;
refdef.y = y;
refdef.width = w;
refdef.height = h;
uiInfo.uiDC.modelBounds(uiInfo.replacements.Model, mins, maxs);
origin[2] = -0.5 * (mins[2] + maxs[2]);
origin[1] = 0.5 * (mins[1] + maxs[1]);
// calculate distance so the model nearly fills the box
if (qtrue) {
float len = 0.5 * (maxs[2] - mins[2]);
origin[0] = len / 0.268; // len / tan( fov/2 )
//origin[0] = len / tan(w/2);
}
refdef.fov_x = (uiInfo.replacements.fovx) ? uiInfo.replacements.fovx : 60;
refdef.fov_y = (uiInfo.replacements.fovy) ? uiInfo.replacements.fovy : 60;
//refdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f);
//xx = refdef.width / tan( refdef.fov_x / 360 * M_PI );
//refdef.fov_y = atan2( refdef.height, xx );
//refdef.fov_y *= ( 360 / M_PI );
uiInfo.uiDC.clearScene();
refdef.time = uiInfo.uiDC.realTime;
// add the model
memset(&ent, 0, sizeof(ent));
//adjust = 5.0 * sin( (float)uis.realtime / 500 );
//adjust = 360 % (int)((float)uis.realtime / 1000);
//VectorSet( angles, 0, 0, 1 );
VectorCopy(uiInfo.replacements.angles, angles);
// rotation
if (uiInfo.replacements.speed) {
angles[YAW] += uiInfo.replacements.speed * uiInfo.uiDC.realTime / 1000.0f;
}
AnglesToAxis(angles, ent.axis);
VectorAdd(origin, uiInfo.replacements.origin, origin);
ent.hModel = uiInfo.replacements.Model;
VectorCopy(origin, ent.origin);
VectorCopy(origin, ent.lightingOrigin);
ent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;
VectorCopy(ent.origin, ent.oldorigin);
uiInfo.uiDC.addRefEntityToScene(&ent);
uiInfo.uiDC.renderScene(&refdef);
}
// FIXME: table drive
//
static void UI_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw,
@ -2859,6 +3226,26 @@ static void UI_OwnerDraw(float x, float y, float w, float h, float text_x, float
case UI_RQ3_JOINTEAM2:
UI_RQ3_DrawJoinTeam(&rect, scale, color, (ownerDraw == UI_RQ3_JOINTEAM1) ? 1 : 2, textStyle);
break;
//Makro - replacement model info
case UI_RQ3_REPLACEMENTINFO:
UI_DrawReplacementInfo(&rect, scale, color, textStyle);
break;
//Makro - replacement model name
case UI_RQ3_REPLACEMENTNAME:
UI_DrawReplacementName(&rect, scale, color, textStyle);
break;
//Makro - replacement model
case UI_RQ3_REPLACEMENTMODEL:
UI_DrawReplacementModel(&rect);
break;
//Makro - replacement type
case UI_RQ3_REPLACEMENTTYPE:
UI_DrawReplacementType(&rect, scale, color, textStyle);
break;
//Makro - replacement subtype
case UI_RQ3_REPLACEMENTSUBTYPE:
UI_DrawReplacementSubtype(&rect, scale, color, textStyle);
break;
case UI_SELECTEDPLAYER:
UI_DrawSelectedPlayer(&rect, scale, color, textStyle);
break;
@ -3583,6 +3970,104 @@ static qboolean UI_SelectedPlayer_HandleKey(int flags, float *special, int key)
return qfalse;
}
//Makro - replacement type
static qboolean UI_ReplacementType_HandleKey(int flags, float *special, int key)
{
if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER || key == K_LEFTARROW
|| key == K_RIGHTARROW) {
int index = uiInfo.replacements.TypeIndex;
if (key == K_MOUSE2 || key == K_LEFTARROW) {
index--;
} else {
index++;
}
if (index >= replacementTypeCount) {
index = 0;
} else if (index < 0) {
index = replacementTypeCount - 1;
}
uiInfo.replacements.TypeIndex = index;
uiInfo.replacements.SubtypeIndex = 0;
switch (index)
{
case 0:
UI_BuildReplacementList(replacementWeapons[0].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
case 1:
UI_BuildReplacementList(replacementItems[0].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
case 2:
UI_BuildReplacementList(replacementAmmo[0].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
default:
break;
}
}
return qfalse;
}
static qboolean UI_ReplacementSubType_HandleKey(int flags, float *special, int key)
{
if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER || key == K_LEFTARROW
|| key == K_RIGHTARROW) {
int index = uiInfo.replacements.SubtypeIndex, max;
if (key == K_MOUSE2 || key == K_LEFTARROW) {
index--;
} else {
index++;
}
switch (uiInfo.replacements.TypeIndex%replacementTypeCount)
{
case 0:
max = replacementWeapCount;
break;
case 1:
max = replacementItemCount;
break;
case 2:
max = replacementAmmoCount;
break;
default:
max = replacementWeapCount;
break;
}
if (index >= max) {
index = 0;
} else if (index < 0) {
index = max - 1;
}
uiInfo.replacements.SubtypeIndex = index;
switch (uiInfo.replacements.TypeIndex)
{
case 0:
UI_BuildReplacementList(replacementWeapons[index].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
case 1:
UI_BuildReplacementList(replacementItems[index].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
case 2:
UI_BuildReplacementList(replacementAmmo[index].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
default:
break;
}
}
return qfalse;
}
static qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key)
{
switch (ownerDraw) {
@ -3648,10 +4133,18 @@ static qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special,
case UI_CROSSHAIR:
UI_Crosshair_HandleKey(flags, special, key);
break;
//Makro - for the SSG crosshair
//Makro - for the SSG crosshair
case UI_SSG_CROSSHAIR:
UI_SSG_Crosshair_HandleKey(flags, special, key);
break;
//Makro - replacement type
case UI_RQ3_REPLACEMENTTYPE:
UI_ReplacementType_HandleKey(flags, special, key);
break;
//Makro - replacement subtype
case UI_RQ3_REPLACEMENTSUBTYPE:
UI_ReplacementSubType_HandleKey(flags, special, key);
break;
case UI_SELECTEDPLAYER:
UI_SelectedPlayer_HandleKey(flags, special, key);
break;
@ -3828,36 +4321,94 @@ static void UI_LoadMovies()
UI_LoadDemos
===============
*/
static int q3Protocols[] = {66, 67, 68};
static char *q3Versions[] = {"1.30", "1.31", "1.32"};
static const int q3VersionCount = sizeof(q3Protocols)/sizeof(q3Protocols[0]);
char *q3VersionFromProtocol(int protocol)
{
int i;
for (i=0; i<q3VersionCount; i++)
{
if (protocol == q3Protocols[i])
return q3Versions[i];
}
return q3Versions[q3VersionCount-1];
}
int q3ProtocolFromVersion(char *version)
{
int i;
for (i=0; i<q3VersionCount; i++)
{
if (!Q_stricmp(version, q3Versions[i]))
return q3Protocols[i];
}
return q3Protocols[q3VersionCount-1];
}
void UI_SortDemoList(int start, int end)
{
int i, j;
//sort list alphabetically
for (i=start; i<end-1; i++)
for (j=i+1; j<end; j++)
if (Q_stricmp(uiInfo.demoList[i], uiInfo.demoList[j])>0)
{
int tmp;
const char *tmpstr;
tmpstr = uiInfo.demoList[i];
tmp = uiInfo.demoType[i];
uiInfo.demoList[i] = uiInfo.demoList[j];
uiInfo.demoType[i] = uiInfo.demoType[j];
uiInfo.demoList[j] = tmpstr;
uiInfo.demoType[j] = tmp;
}
}
static void UI_LoadDemos()
{
char demolist[4096];
char demoExt[32];
char *demoname;
int i, len;
int i, j, len, protocol = (int) trap_Cvar_VariableValue("protocol");
Com_sprintf(demoExt, sizeof(demoExt), "dm_%d", (int) trap_Cvar_VariableValue("protocol"));
uiInfo.demoCount = 0;
//Makro - old code was using just the "protocol" cvar; replaced with a for loop
for (j=66; j<=protocol; j++)
{
int count;
//Com_sprintf(demoExt, sizeof(demoExt), "dm_%d", (int) trap_Cvar_VariableValue("protocol"));
Com_sprintf(demoExt, sizeof(demoExt), "dm_%d", j);
uiInfo.demoCount = trap_FS_GetFileList("demos", demoExt, demolist, 4096);
count = trap_FS_GetFileList("demos", demoExt, demolist, 4096);
Com_sprintf(demoExt, sizeof(demoExt), ".dm_%d", (int) trap_Cvar_VariableValue("protocol"));
//Com_sprintf(demoExt, sizeof(demoExt), ".dm_%d", (int) trap_Cvar_VariableValue("protocol"));
Com_sprintf(demoExt, sizeof(demoExt), ".dm_%d", j);
if (uiInfo.demoCount) {
if (uiInfo.demoCount > MAX_DEMOS) {
uiInfo.demoCount = MAX_DEMOS;
}
demoname = demolist;
for (i = 0; i < uiInfo.demoCount; i++) {
len = strlen(demoname);
if (!Q_stricmp(demoname + len - strlen(demoExt), demoExt)) {
demoname[len - strlen(demoExt)] = '\0';
if (count) {
//int start = uiInfo.demoCount+1;
//uiInfo.demoList[uiInfo.demoCount++] = String_Alloc(va("*** Recorded with Quake 3 %s ***", q3VersionFromProtocol(j)));
demoname = demolist;
for (i = 0; i < count && uiInfo.demoCount <= MAX_DEMOS; i++)
{
len = strlen(demoname);
if (!Q_stricmp(demoname + len - strlen(demoExt), demoExt))
{
demoname[len - strlen(demoExt)] = '\0';
}
//Makro - bad for linux users
//Q_strupr(demoname);
uiInfo.demoType[uiInfo.demoCount] = j;
uiInfo.demoList[uiInfo.demoCount++] = String_Alloc(va("%s (%s)", demoname, q3VersionFromProtocol(j)));
demoname += len + 1;
}
//Makro - bad for linux users
//Q_strupr(demoname);
uiInfo.demoList[i] = String_Alloc(demoname);
demoname += len + 1;
}
}
UI_SortDemoList(0, uiInfo.demoCount);
}
static qboolean UI_SetNextMap(int actual, int index)
@ -4429,8 +4980,15 @@ static void UI_RunMenuScript(char **args)
trap_Cmd_ExecuteText(EXEC_APPEND, "vid_restart;");
} else if (Q_stricmp(name, "RunDemo") == 0) {
//Makro - missing check
if (uiInfo.demoIndex >= 0 && uiInfo.demoIndex < uiInfo.demoCount) {
trap_Cmd_ExecuteText(EXEC_APPEND, va("demo %s\n", uiInfo.demoList[uiInfo.demoIndex]));
if (uiInfo.demoIndex >= 0 && uiInfo.demoIndex < uiInfo.demoCount)
{
//Makro - remove version info
char demoname[128], *p;
Q_strncpyz(demoname, uiInfo.demoList[uiInfo.demoIndex], sizeof(demoname));
p = Q_strrchr(demoname, '(');
if (p)
*(p-1)=0;
trap_Cmd_ExecuteText(EXEC_APPEND, va("demo %s.dm_%d\n", demoname, uiInfo.demoType[uiInfo.demoIndex]));
}
} else if (Q_stricmp(name, "Quake3") == 0) {
trap_Cvar_Set("fs_game", "");
@ -4747,6 +5305,36 @@ static void UI_RunMenuScript(char **args)
} else if (Q_stricmp(name, "restoreMusicVolume") == 0) {
trap_Cvar_SetValue("s_musicvolume", uiInfo.oldMusicVol);
uiInfo.savedMusicVol = qfalse;
//Makro - create model replacements list
} else if (Q_stricmp(name, "buildReplacementList") == 0) {
switch (uiInfo.replacements.TypeIndex)
{
case 0:
UI_BuildReplacementList(replacementWeapons[uiInfo.replacements.SubtypeIndex % replacementWeapCount].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
case 1:
UI_BuildReplacementList(replacementItems[uiInfo.replacements.SubtypeIndex % replacementItemCount].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
case 2:
UI_BuildReplacementList(replacementAmmo[uiInfo.replacements.SubtypeIndex % replacementAmmoCount].cvarName);
UI_LoadReplacement(uiInfo.replacements.Index);
break;
default:
break;
}
//Makro - next/prev replacement
} else if (Q_stricmp(name, "nextReplacement") == 0) {
int index = uiInfo.replacements.Index, offset = 0;
if (Int_Parse(args, &offset)) {
index += offset;
if (index >= uiInfo.replacements.Count)
index = 0;
else if (index < 0)
index = uiInfo.replacements.Count-1;
UI_LoadReplacement(index);
}
} else if (Q_stricmp(name, "update") == 0) {
if (String_Parse(args, &name2)) {
UI_Update(name2);
@ -5508,6 +6096,9 @@ static int UI_FeederCount(float feederID)
//Makro - improved in-game server info list
} else if (feederID == FEEDER_INGAME_SERVERINFO) {
return uiInfo.ingameServerInfoLineCount;
//Makro - model replacements
} else if (feederID == FEEDER_REPLACEMENTS) {
return uiInfo.replacements.Count;
}
return 0;
}
@ -5714,6 +6305,13 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan
return uiInfo.ingameServerInfo[index][column];
}
}
/*
//Makro - model replacements
} else if (feederID == FEEDER_REPLACEMENTS) {
if (index >= 0 && index < uiInfo.replacementCount) {
return uiInfo.replacementNames[index];
}
*/
}
return "";
}
@ -5854,6 +6452,9 @@ static void UI_FeederSelection(float feederID, int index)
uiInfo.previewMovie = -1;
} else if (feederID == FEEDER_DEMOS) {
uiInfo.demoIndex = index;
//Makro - model replacements
} else if (feederID == FEEDER_REPLACEMENTS) {
//INSERT CODE !
}
}

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.26 2003/03/31 00:23:18 makro
// Replacements and stuff
//
// Revision 1.25 2003/02/13 21:19:51 makro
// no message
//
@ -201,42 +204,18 @@ typedef struct {
static RQ3_keyAlias_t RQ3_KeyAliases[] = {
{"", -1},
{"0", '0'},
{"1", '1'},
{"2", '2'},
{"3", '3'},
{"4", '4'},
{"5", '5'},
{"6", '6'},
{"7", '7'},
{"8", '8'},
{"9", '9'},
{"A", 'a'},
{"B", 'b'},
{"C", 'c'},
{"D", 'd'},
{"E", 'e'},
{"F", 'f'},
{"G", 'g'},
{"H", 'h'},
{"I", 'i'},
{"J", 'j'},
{"K", 'k'},
{"L", 'l'},
{"M", 'm'},
{"N", 'n'},
{"O", 'o'},
{"P", 'p'},
{"Q", 'q'},
{"R", 'r'},
{"S", 's'},
{"T", 't'},
{"U", 'u'},
{"V", 'v'},
{"W", 'w'},
{"X", 'x'},
{"Y", 'y'},
{"Z", 'z'}
{"F1", K_F1},
{"F2", K_F2},
{"F3", K_F3},
{"F4", K_F4},
{"F5", K_F5},
{"F6", K_F6},
{"F7", K_F7},
{"F8", K_F8},
{"F9", K_F9},
{"F10", K_F10},
{"F11", K_F11},
{"F12", K_F12}
};
//Makro - only check for shortcuts 20 times a second MAX
@ -1075,9 +1054,11 @@ int Menu_ItemsMatchingGroup(menuDef_t * menu, const char *name)
int i;
int count = 0;
//Makro - added subgroup
for (i = 0; i < menu->itemCount; i++) {
if (Q_stricmp(menu->items[i]->window.name, name) == 0
|| (menu->items[i]->window.group && Q_stricmp(menu->items[i]->window.group, name) == 0)) {
|| (menu->items[i]->window.group && Q_stricmp(menu->items[i]->window.group, name) == 0)
|| (menu->items[i]->window.subgroup && Q_stricmp(menu->items[i]->window.subgroup, name) == 0)) {
count++;
}
}
@ -1089,9 +1070,11 @@ itemDef_t *Menu_GetMatchingItemByNumber(menuDef_t * menu, int index, const char
int i;
int count = 0;
//Makro - added subgroup
for (i = 0; i < menu->itemCount; i++) {
if (Q_stricmp(menu->items[i]->window.name, name) == 0
|| (menu->items[i]->window.group && Q_stricmp(menu->items[i]->window.group, name) == 0)) {
|| (menu->items[i]->window.group && Q_stricmp(menu->items[i]->window.group, name) == 0)
|| (menu->items[i]->window.subgroup && Q_stricmp(menu->items[i]->window.subgroup, name) == 0)) {
if (count == index) {
return menu->items[i];
}
@ -1382,7 +1365,8 @@ void Menu_TimeFadeItemByName(menuDef_t * menu, const char *name, vec4_t endColor
//if (offset+duration > 0) {
for (i = 0; i < menu->itemCount; i++) {
if (!Q_stricmp(menu->items[i]->window.name, name)
|| !Q_stricmp(menu->items[i]->window.group, name)) {
|| !Q_stricmp(menu->items[i]->window.group, name)
|| !Q_stricmp(menu->items[i]->window.subgroup, name)) {
UI_RQ3_TimeFadeItem(menu->items[i], endColor, offset, duration, forecolor);
}
}
@ -5313,7 +5297,7 @@ qboolean ItemParse_shortcutKey(itemDef_t * item, int handle)
}
//Com_Printf(S_COLOR_BLUE "^4MDEBUG: Shortcut key read: %s\n^7", item->window.shortcutKey);
item->window.shortcutKey = UI_RQ3_KeyNumFromChar(temp);
item->window.shortcutKey = (strlen(temp) == 1) ? temp[0] : UI_RQ3_KeyNumFromChar(temp);
return qtrue;
}
@ -5356,6 +5340,16 @@ qboolean ItemParse_group(itemDef_t * item, int handle)
return qtrue;
}
//Makro - subgroup <string>
qboolean ItemParse_subgroup(itemDef_t * item, int handle)
{
if (!PC_String_Parse(handle, &item->window.subgroup)) {
return qfalse;
}
return qtrue;
}
// asset_model <string>
qboolean ItemParse_asset_model(itemDef_t * item, int handle)
{
@ -6132,6 +6126,8 @@ keywordHash_t itemParseKeywords[] = {
{"textHeight", ItemParse_textHeight, NULL},
{"text", ItemParse_text, NULL},
{"group", ItemParse_group, NULL},
//Makro - added subgroup
{"subgroup", ItemParse_subgroup, NULL},
{"asset_model", ItemParse_asset_model, NULL},
{"asset_shader", ItemParse_asset_shader, NULL},
{"model_origin", ItemParse_model_origin, NULL},

View file

@ -5,6 +5,9 @@
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.17 2003/03/31 00:23:18 makro
// Replacements and stuff
//
// Revision 1.16 2003/02/26 18:22:05 makro
// Added an option to change crosshair size in assetGlobalDef's
//
@ -167,12 +170,14 @@ typedef struct {
Rectangle rect; // client coord rectangle
Rectangle rectClient; // screen coord rectangle
const char *name; //
//Makro - adding support for shortcut keys
//Makro - adding support for shortcut keys
//const char *shortcutKey;
int shortcutKey;
//Makro - drop shadow effect
//Makro - drop shadow effect
int shadowStyle;
const char *group; // if it belongs to a group
//Makro - added
const char *subgroup; // if it belongs to a subgroup
const char *cinematicName; // cinematic name
int cinematic; // cinematic handle
int style; //