1
0
Fork 0
forked from fte/fteqw

small bug fix, part way through adding plugin stuff for menu support.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@247 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2004-09-26 00:30:42 +00:00
parent 0fc540cac4
commit f25bf204a9
8 changed files with 123 additions and 26 deletions

View file

@ -2252,19 +2252,40 @@ void CL_NewTranslation (int slot)
if (player->skin && !stricmp(s, player->skin->name)) if (player->skin && !stricmp(s, player->skin->name))
player->skin = NULL; player->skin = NULL;
if (player->_topcolor != player->topcolor || top = player->topcolor;
player->_bottomcolor != player->bottomcolor || !player->skin) { bottom = player->bottomcolor;
player->_topcolor = player->topcolor; if (!cl.splitclients && !(cl.fpd & FPD_NO_FORCE_COLOR)) //no colour/skin forcing in splitscreen.
player->_bottomcolor = player->bottomcolor; {
if (cl.teamplay && !strcmp(player->team, cl.players[cl.playernum[0]].team))
{
if (cl_teamtopcolor>=0)
top = cl_teamtopcolor;
if (cl_teambottomcolor>=0)
bottom = cl_teambottomcolor;
}
else
{
if (cl_enemytopcolor>=0)
top = cl_enemytopcolor;
if (cl_enemybottomcolor>=0)
bottom = cl_enemybottomcolor;
}
}
if (player->_topcolor != top ||
player->_bottomcolor != bottom || !player->skin) {
player->_topcolor = top;
player->_bottomcolor = bottom;
dest = player->translations; dest = player->translations;
source = vid.colormap; source = vid.colormap;
memcpy (dest, vid.colormap, sizeof(player->translations)); memcpy (dest, vid.colormap, sizeof(player->translations));
top = player->topcolor; // top = player->topcolor;
if (top > 13 || top < 0) if (top > 13 || top < 0)
top = 13; top = 13;
top *= 16; top *= 16;
bottom = player->bottomcolor; // bottom = player->bottomcolor;
if (bottom > 13 || bottom < 0) if (bottom > 13 || bottom < 0)
bottom = 13; bottom = 13;
bottom *= 16; bottom *= 16;

View file

@ -365,6 +365,7 @@ typedef struct {
// //
typedef struct typedef struct
{ {
int fpd;
int servercount; // server identification for prespawns int servercount; // server identification for prespawns
char serverinfo[MAX_SERVERINFO_STRING]; char serverinfo[MAX_SERVERINFO_STRING];
@ -502,6 +503,15 @@ typedef struct
int deathmatch; int deathmatch;
} client_state_t; } client_state_t;
extern int cl_teamtopcolor;
extern int cl_teambottomcolor;
extern int cl_enemytopcolor;
extern int cl_enemybottomcolor;
//FPD values
//(commented out ones are ones that we don't support)
#define FPD_NO_FORCE_COLOR 512
// //
// cvars // cvars

View file

@ -909,6 +909,10 @@ void M_Draw (int uimenu)
case m_complex: case m_complex:
M_Complex_Draw (); M_Complex_Draw ();
break; break;
case m_plugin:
Plug_Menu_Event (0, (int)(realtime*1000));
break;
} }
if (m_entersound) if (m_entersound)
@ -954,6 +958,10 @@ void M_Keydown (int key)
case m_complex: case m_complex:
M_Complex_Key (key); M_Complex_Key (key);
return; return;
case m_plugin:
Plug_Menu_Event (1, key);
return;
} }
} }
@ -965,6 +973,9 @@ void M_Keyup (int key)
case m_xwindows: case m_xwindows:
XWindows_Keyup(key); XWindows_Keyup(key);
return; return;
case m_plugin:
Plug_Menu_Event (2, key);
return;
default: default:
break; break;
} }

View file

@ -50,7 +50,7 @@ void XWindows_Init(void);
typedef enum {m_none, m_complex, m_help, m_keys, m_slist, m_media, m_xwindows} m_state_t; typedef enum {m_none, m_complex, m_help, m_keys, m_slist, m_media, m_xwindows, m_plugin} m_state_t;
extern m_state_t m_state; extern m_state_t m_state;
typedef enum {mt_childwindow, mt_button, mt_buttonbigfont, mt_box, mt_colouredbox, mt_line, mt_edit, mt_text, mt_slider, mt_combo, mt_bind, mt_checkbox, mt_picture, mt_menudot, mt_custom} menutype_t; typedef enum {mt_childwindow, mt_button, mt_buttonbigfont, mt_box, mt_colouredbox, mt_line, mt_edit, mt_text, mt_slider, mt_combo, mt_bind, mt_checkbox, mt_picture, mt_menudot, mt_custom} menutype_t;

View file

@ -824,14 +824,14 @@ void R_InitParticles (void)
pt_gunshot = AllocateParticleType("te_gunshot"); pt_gunshot = AllocateParticleType("te_gunshot");
pt_lavasplash = AllocateParticleType("te_lavasplash"); pt_lavasplash = AllocateParticleType("te_lavasplash");
pt_teleportsplash = AllocateParticleType("te_teleportsplash"); pt_teleportsplash = AllocateParticleType("te_teleportsplash");
rt_blastertrail = AllocateParticleType("te_blastertrail"); rt_blastertrail = AllocateParticleType("t_blastertrail");
pt_blasterparticles = AllocateParticleType("te_blasterparticles"); pt_blasterparticles = AllocateParticleType("te_blasterparticles");
pt_wizspike = AllocateParticleType("te_wizspike"); pt_wizspike = AllocateParticleType("te_wizspike");
pt_knightspike = AllocateParticleType("te_knightspike"); pt_knightspike = AllocateParticleType("te_knightspike");
pt_spike = AllocateParticleType("te_spike"); pt_spike = AllocateParticleType("te_spike");
pt_superspike = AllocateParticleType("te_superspike"); pt_superspike = AllocateParticleType("te_superspike");
rt_railtrail = AllocateParticleType("te_railtrail"); rt_railtrail = AllocateParticleType("t_railtrail");
rt_bubbletrail = AllocateParticleType("te_bubbletrail"); rt_bubbletrail = AllocateParticleType("t_bubbletrail");
rt_rocket = AllocateParticleType("t_rocket"); rt_rocket = AllocateParticleType("t_rocket");
pt_superbullet = AllocateParticleType("te_superbullet"); pt_superbullet = AllocateParticleType("te_superbullet");

View file

@ -1312,9 +1312,9 @@ char *TP_MapName (void)
*/ */
int cl_teamtopcolor = -1; int cl_teamtopcolor = -1;
int cl_teambottomcolor; int cl_teambottomcolor = -1;
int cl_enemytopcolor = -1; int cl_enemytopcolor = -1;
int cl_enemybottomcolor; int cl_enemybottomcolor = -1;
void TP_TeamColor_f (void) void TP_TeamColor_f (void)
{ {
@ -1335,6 +1335,8 @@ void TP_TeamColor_f (void)
if (!strcmp(Cmd_Argv(1), "off")) if (!strcmp(Cmd_Argv(1), "off"))
{ {
cl_teamtopcolor = -1; cl_teamtopcolor = -1;
cl_teambottomcolor = -1;
if (qrenderer) //make sure we have the renderer initialised...
for (i = 0; i < MAX_CLIENTS; i++) for (i = 0; i < MAX_CLIENTS; i++)
CL_NewTranslation(i); CL_NewTranslation(i);
return; return;
@ -1359,6 +1361,7 @@ void TP_TeamColor_f (void)
cl_teamtopcolor = top; cl_teamtopcolor = top;
cl_teambottomcolor = bottom; cl_teambottomcolor = bottom;
if (qrenderer) //make sure we have the renderer initialised...
for (i = 0; i < MAX_CLIENTS; i++) for (i = 0; i < MAX_CLIENTS; i++)
CL_NewTranslation(i); CL_NewTranslation(i);
} }
@ -1383,6 +1386,8 @@ void TP_EnemyColor_f (void)
if (!strcmp(Cmd_Argv(1), "off")) if (!strcmp(Cmd_Argv(1), "off"))
{ {
cl_enemytopcolor = -1; cl_enemytopcolor = -1;
cl_enemybottomcolor = -1;
if (qrenderer) //make sure we have the renderer initialised...
for (i = 0; i < MAX_CLIENTS; i++) for (i = 0; i < MAX_CLIENTS; i++)
CL_NewTranslation(i); CL_NewTranslation(i);
return; return;
@ -1407,6 +1412,7 @@ void TP_EnemyColor_f (void)
cl_enemytopcolor = top; cl_enemytopcolor = top;
cl_enemybottomcolor = bottom; cl_enemybottomcolor = bottom;
if (qrenderer) //make sure we have the renderer initialised...
for (i = 0; i < MAX_CLIENTS; i++) for (i = 0; i < MAX_CLIENTS; i++)
CL_NewTranslation(i); CL_NewTranslation(i);
} }

View file

@ -11,6 +11,7 @@ typedef struct plugin_s {
vm_t *vm; vm_t *vm;
int tick; int tick;
int executestring; int executestring;
int menufunction;
struct plugin_s *next; struct plugin_s *next;
} plugin_t; } plugin_t;
@ -31,6 +32,7 @@ void Plug_Shutdown(void);
static plugin_t *plugs; static plugin_t *plugs;
static plugin_t *menuplug; //plugin that has the current menu
typedef struct { typedef struct {
@ -89,7 +91,7 @@ int Plug_FindBuiltin(void *offset, unsigned int mask, const long *args)
int i; int i;
for (i = 0; i < numplugbuiltins; i++) for (i = 0; i < numplugbuiltins; i++)
if (plugbuiltins[i].name) if (plugbuiltins[i].name)
if (!strcmp(plugbuiltins[i].name, (char *)offset+args[0])) if (!strcmp(plugbuiltins[i].name, (char *)VM_POINTER(args[0])))
return -i; return -i;
return 0; return 0;
@ -190,7 +192,7 @@ int Plug_Emumerated (char *name, int size, void *param)
int Plug_Con_Print(void *offset, unsigned int mask, const long *arg) int Plug_Con_Print(void *offset, unsigned int mask, const long *arg)
{ {
Con_Print((char*)offset+arg[0]); Con_Print((char*)VM_POINTER(arg[0]));
return 0; return 0;
} }
int Plug_Sys_Error(void *offset, unsigned int mask, const long *arg) int Plug_Sys_Error(void *offset, unsigned int mask, const long *arg)
@ -200,11 +202,13 @@ int Plug_Sys_Error(void *offset, unsigned int mask, const long *arg)
} }
int Plug_ExportToEngine(void *offset, unsigned int mask, const long *arg) int Plug_ExportToEngine(void *offset, unsigned int mask, const long *arg)
{ {
char *name = (char*)offset+arg[0]; char *name = (char*)VM_POINTER(arg[0]);
if (!strcmp(name, "Tick")) if (!strcmp(name, "Tick"))
currentplug->tick = arg[1]; currentplug->tick = arg[1];
else if (!strcmp(name, "ExecuteCommand")) else if (!strcmp(name, "ExecuteCommand"))
currentplug->executestring = arg[1]; currentplug->executestring = arg[1];
else if (!strcmp(name, "MenuEvent"))
currentplug->menufunction = arg[1];
else else
return 0; return 0;
return 1; return 1;
@ -212,7 +216,7 @@ int Plug_ExportToEngine(void *offset, unsigned int mask, const long *arg)
//void(char *buffer, int buffersize) //void(char *buffer, int buffersize)
int Plug_Cmd_Args(void *offset, unsigned int mask, const long *arg) int Plug_Cmd_Args(void *offset, unsigned int mask, const long *arg)
{ {
char *buffer = (char*)offset+arg[0]; char *buffer = (char*)VM_POINTER(arg[0]);
char *args; char *args;
args = Cmd_Args(); args = Cmd_Args();
if (strlen(args)+1>arg[1]) if (strlen(args)+1>arg[1])
@ -223,7 +227,7 @@ int Plug_Cmd_Args(void *offset, unsigned int mask, const long *arg)
//void(int num, char *buffer, int buffersize) //void(int num, char *buffer, int buffersize)
int Plug_Cmd_Argv(void *offset, unsigned int mask, const long *arg) int Plug_Cmd_Argv(void *offset, unsigned int mask, const long *arg)
{ {
char *buffer = (char*)offset+arg[1]; char *buffer = (char*)VM_POINTER(arg[1]);
char *args; char *args;
args = Cmd_Argv(arg[0]); args = Cmd_Argv(arg[0]);
if (strlen(args)+1>arg[2]) if (strlen(args)+1>arg[2])
@ -236,6 +240,24 @@ int Plug_Cmd_Argc(void *offset, unsigned int mask, const long *arg)
{ {
return Cmd_Argc(); return Cmd_Argc();
} }
int Plug_Menu_Control(void *offset, unsigned int mask, const long *arg)
{
switch(VM_LONG(arg[0]))
{
case 0: //weather it's us or not.
return currentplug == menuplug && m_state == m_plugin;
case 1: //weather a menu is active
return key_dest == key_menu;
case 2: //give us menu control
menuplug = currentplug;
key_dest = key_menu;
return 1;
default:
return 0;
}
}
void Plug_Init(void) void Plug_Init(void)
{ {
Plug_RegisterBuiltin("Plug_GetEngineFunction", Plug_FindBuiltin, 0);//plugin wishes to find a builtin number. Plug_RegisterBuiltin("Plug_GetEngineFunction", Plug_FindBuiltin, 0);//plugin wishes to find a builtin number.
@ -248,7 +270,7 @@ void Plug_Init(void)
Plug_RegisterBuiltin("Cmd_Argc", Plug_Cmd_Argc, 0); Plug_RegisterBuiltin("Cmd_Argc", Plug_Cmd_Argc, 0);
Plug_RegisterBuiltin("Cmd_Argv", Plug_Cmd_Argv, 0); Plug_RegisterBuiltin("Cmd_Argv", Plug_Cmd_Argv, 0);
Plug_RegisterBuiltin("Menu_Control", Plug_Menu_Control, 0);
#ifdef _WIN32 #ifdef _WIN32
COM_EnumerateFiles("plugins/*x86.dll", Plug_Emumerated, "x86.dll"); COM_EnumerateFiles("plugins/*x86.dll", Plug_Emumerated, "x86.dll");
@ -289,6 +311,14 @@ qboolean Plugin_ExecuteString(void)
return false; return false;
} }
qboolean Plug_Menu_Event(int eventtype, int param) //eventtype = draw/keydown/keyup, param = time/key
{
if (!menuplug)
return false;
return VM_Call(menuplug->vm, menuplug->menufunction, eventtype, param);
}
void Plug_Close(plugin_t *plug) void Plug_Close(plugin_t *plug)
{ {
if (plugs == plug) if (plugs == plug)

View file

@ -441,6 +441,25 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, entity_
Skin_Find(e->scoreboard); Skin_Find(e->scoreboard);
tc = e->scoreboard->topcolor; tc = e->scoreboard->topcolor;
bc = e->scoreboard->bottomcolor; bc = e->scoreboard->bottomcolor;
//colour forcing
if (!cl.splitclients && !(cl.fpd & FPD_NO_FORCE_COLOR)) //no colour/skin forcing in splitscreen.
{
if (cl.teamplay && !strcmp(e->scoreboard->team, cl.players[cl.playernum[0]].team))
{
if (cl_teamtopcolor>=0)
tc = cl_teamtopcolor;
if (cl_teambottomcolor>=0)
bc = cl_teambottomcolor;
}
else
{
if (cl_enemytopcolor>=0)
tc = cl_enemytopcolor;
if (cl_enemybottomcolor>=0)
bc = cl_enemybottomcolor;
}
}
} }
else else
{ {