24 Nov 2007

This commit is contained in:
g-cont 2007-11-24 00:00:00 +03:00 committed by Alibek Omarov
parent d1652e8c45
commit bad531734c
58 changed files with 1071 additions and 1015 deletions

View File

@ -26,7 +26,8 @@ scroll = visible_offset
Имплементация нового меню
1. перенести все ресурсы из версии 0.4
2. разобраться с short->word конверсией VM
2. разобраться с short->word конверсией VM OK
3. разобраться с кастомной загрузкой эдиктов в меню
//==================================================
// то, что уже готово

View File

@ -464,10 +464,9 @@ word PR_WriteProgdefs (char *filename)
}
ADD1("} entvars_t;\n\n");
// prvm_fieldvars_t struct
ADD2("\ntypedef struct prvm_fieldvars_s\n{\n\tint\t\tofs;\n\tint\t\ttype;\n\tconst char\t*name;\n} prvm_fieldvars_t;\n");
ADD2("\n#define REQFIELDS (sizeof(reqfields) / sizeof(prvm_fieldvars_t))\n");
ADD2("\nstatic prvm_fieldvars_t reqfields[] = \n{\n");
// begin custom fields
ADD2("\n#define REQFIELDS (sizeof(reqfields) / sizeof(fields_t))\n");
ADD2("\nstatic fields_t reqfields[] = \n{\n");
// write fields
for (d = pr.def_head.next; d; d = d->next)

View File

@ -353,7 +353,7 @@ void CG_DrawCenterString( void )
w = cl.centerPrintCharWidth * ColorStrlen( linebuffer );
x = ( SCREEN_WIDTH - w )>>1;
SCR_DrawStringExt( x, y, cl.centerPrintCharWidth, linebuffer, color, false );
SCR_DrawStringExt( x, y, cl.centerPrintCharWidth, BIGCHAR_HEIGHT, linebuffer, color, false );
y += cl.centerPrintCharWidth * 1.5;
while ( *start && ( *start != '\n' )) start++;

15
engine/client/cl_edict.h Normal file
View File

@ -0,0 +1,15 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// cl_edict.h - client prvm edict
//=======================================================================
#ifndef CL_EDICT_H
#define CL_EDICT_H
#endif//CL_EDICT_H

View File

@ -1112,14 +1112,14 @@ void Key_Event(int key, bool down, uint time)
switch (cls.key_dest)
{
case key_message:
Key_Message(key);
Key_Message( key );
break;
case key_game:
case key_console:
M_Menu_Main_f();
break;
case key_menu:
M_Keydown(key);
M_Keydown( key );
break;
default:
MsgWarn("Key_Event: bad cls.key_dest\n");

View File

@ -88,29 +88,25 @@ SCR_DrawChar
chars are drawn at 640*480 virtual screen size
================
*/
static void SCR_DrawChar( int x, int y, float size, int ch )
void SCR_DrawChar( int x, int y, float w, float h, int ch )
{
int row, col;
float frow, fcol;
float size, frow, fcol;
float ax, ay, aw, ah;
ch &= 255;
if( ch == ' ' )return;
if(y < -size) return;
if(y < -h) return;
ax = x;
ay = y;
aw = size;
ah = size;
aw = w;
ah = h;
SCR_AdjustSize( &ax, &ay, &aw, &ah );
row = ch>>4;
col = ch&15;
frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;
frow = (ch >> 4)*0.0625f + (0.5f / 256.0f);
fcol = (ch & 15)*0.0625f + (0.5f / 256.0f);
size = 0.0625f - (1.0f / 256.0f);
re->DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size, "fonts/conchars" );
}
@ -124,22 +120,17 @@ small chars are drawn at native screen resolution
*/
void SCR_DrawSmallChar( int x, int y, int ch )
{
int row, col;
float frow, fcol;
float size;
ch &= 255;
if( ch == ' ' )return;
if(y < -SMALLCHAR_HEIGHT) return;
row = ch>>4;
col = ch&15;
frow = row*0.0625;
fcol = col*0.0625;
size = 0.0625;
frow = (ch >> 4)*0.0625f + (0.5f / 256.0f);
fcol = (ch & 15)*0.0625f + (0.5f / 256.0f);
size = 0.0625f - (1.0f / 256.0f);
re->DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, fcol, frow, fcol + size, frow + size, "fonts/conchars" );
}
@ -154,7 +145,7 @@ to a fixed color.
Coordinates are at 640 by 480 virtual resolution
==================
*/
void SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, bool forceColor )
void SCR_DrawStringExt( int x, int y, float w, float h, const char *string, float *setColor, bool forceColor )
{
vec4_t color;
const char *s;
@ -173,8 +164,8 @@ void SCR_DrawStringExt( int x, int y, float size, const char *string, float *set
s += 2;
continue;
}
SCR_DrawChar( xx + 2, y + 2, size, *s );
xx += size;
SCR_DrawChar( xx + 2, y + 2, w, h, *s );
xx += w;
s++;
}
@ -195,8 +186,8 @@ void SCR_DrawStringExt( int x, int y, float size, const char *string, float *set
s += 2;
continue;
}
SCR_DrawChar( xx, y, size, *s );
xx += size;
SCR_DrawChar( xx, y, w, h, *s );
xx += w;
s++;
}
re->SetColor( NULL );
@ -207,12 +198,12 @@ void SCR_DrawBigString( int x, int y, const char *s, float alpha )
float color[4];
Vector4Set( color, 1.0f, 1.0f, 1.0f, alpha );
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, false );
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, s, color, false );
}
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color )
{
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, s, color, true );
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, s, color, true );
}
/*

View File

@ -89,8 +89,9 @@ void SCR_AdjustSize( float *x, float *y, float *w, float *h );
void SCR_DrawPic( float x, float y, float width, float height, char *picname );
void SCR_FillRect( float x, float y, float width, float height, const float *color );
void SCR_DrawSmallChar( int x, int y, int ch );
void SCR_DrawChar( int x, int y, float w, float h, int ch );
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, bool forceColor );
void SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, bool forceColor );
void SCR_DrawStringExt( int x, int y, float w, float h, const char *string, float *setColor, bool forceColor );
void SCR_DrawBigString( int x, int y, const char *s, float alpha );
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color );
void SCR_DrawFPS( void );

View File

@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "./" /I "prvm" /I "common" /I "server" /I "client" /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "./" /I "uimenu" /I "server" /I "client" /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -80,7 +80,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "prvm" /I "common" /I "server" /I "client" /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "uimenu" /I "server" /I "client" /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -114,7 +114,7 @@ SOURCE="$(InputPath)"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\client\cg_user.c
SOURCE=.\cg_user.c
# End Source File
# Begin Source File
@ -174,11 +174,11 @@ SOURCE=.\client\cl_view.c
# End Source File
# Begin Source File
SOURCE=.\common\cmd.c
SOURCE=.\cmd.c
# End Source File
# Begin Source File
SOURCE=.\common\cmodel.c
SOURCE=.\cmodel.c
# End Source File
# Begin Source File
@ -186,7 +186,7 @@ SOURCE=.\common.c
# End Source File
# Begin Source File
SOURCE=.\common\cvar.c
SOURCE=.\cvar.c
# End Source File
# Begin Source File
@ -194,31 +194,31 @@ SOURCE=.\host.c
# End Source File
# Begin Source File
SOURCE=.\common\md4.c
SOURCE=.\md4.c
# End Source File
# Begin Source File
SOURCE=.\menu.c
SOURCE=.\uimenu\menu.c
# End Source File
# Begin Source File
SOURCE=.\common\net_chan.c
SOURCE=.\net_chan.c
# End Source File
# Begin Source File
SOURCE=.\common\net_msg.c
SOURCE=.\net_msg.c
# End Source File
# Begin Source File
SOURCE=.\common\net_wins.c
SOURCE=.\net_wins.c
# End Source File
# Begin Source File
SOURCE=.\common\pmove.c
SOURCE=.\pmove.c
# End Source File
# Begin Source File
SOURCE=.\qmenu.c
SOURCE=.\uimenu\qmenu.c
# End Source File
# Begin Source File
@ -298,23 +298,23 @@ SOURCE=.\system.c
# End Source File
# Begin Source File
SOURCE=.\ui_cmds.c
SOURCE=.\uimenu\ui_cmds.c
# End Source File
# Begin Source File
SOURCE=.\ui_main.c
SOURCE=.\uimenu\ui_main.c
# End Source File
# Begin Source File
SOURCE=.\common\vm_cmds.c
SOURCE=.\vm_cmds.c
# End Source File
# Begin Source File
SOURCE=.\common\vm_edict.c
SOURCE=.\vm_edict.c
# End Source File
# Begin Source File
SOURCE=.\common\vm_exec.c
SOURCE=.\vm_exec.c
# End Source File
# End Group
# Begin Group "Header Files"
@ -330,10 +330,6 @@ SOURCE=.\client\client.h
# End Source File
# Begin Source File
SOURCE=..\public\common.h
# End Source File
# Begin Source File
SOURCE=.\common\const.h
# End Source File
# Begin Source File
@ -342,7 +338,7 @@ SOURCE=.\engine.h
# End Source File
# Begin Source File
SOURCE=.\common\net_msg.h
SOURCE=.\net_msg.h
# End Source File
# Begin Source File
@ -350,11 +346,11 @@ SOURCE=.\progdefs.h
# End Source File
# Begin Source File
SOURCE=.\common\progsvm.h
SOURCE=.\progsvm.h
# End Source File
# Begin Source File
SOURCE=.\qmenu.h
SOURCE=.\uimenu\qmenu.h
# End Source File
# Begin Source File
@ -374,7 +370,11 @@ SOURCE=.\sound.h
# End Source File
# Begin Source File
SOURCE=.\common\vm_cmds.h
SOURCE=.\uimenu\uimenu.h
# End Source File
# Begin Source File
SOURCE=.\vm_cmds.h
# End Source File
# End Group
# End Target

View File

@ -1,238 +0,0 @@
// progdefs.h
// generated by Xash3D QuakeC compiler
#ifndef PROGDEFS_H
#define PROGDEFS_H
typedef struct globalvars_s
{
int pad[28];
int pev;
int other;
int world;
float time;
float frametime;
string_t mapname;
string_t startspot;
vec3_t spotoffset;
float deathmatch;
float coop;
float teamplay;
float serverflags;
float total_secrets;
float total_monsters;
float found_secrets;
float killed_monsters;
vec3_t v_forward;
vec3_t v_right;
vec3_t v_up;
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vec3_t trace_endpos;
vec3_t trace_plane_normal;
float trace_plane_dist;
float trace_hitgroup;
float trace_contents;
int trace_ent;
float trace_flags;
func_t main;
func_t StartFrame;
func_t EndFrame;
func_t PlayerPreThink;
func_t PlayerPostThink;
func_t ClientKill;
func_t ClientConnect;
func_t PutClientInServer;
func_t ClientDisconnect;
func_t ClientCommand;
} globalvars_t;
typedef struct entvars_s
{
string_t classname;
string_t globalname;
float modelindex;
vec3_t origin;
vec3_t angles;
vec3_t old_origin;
vec3_t old_angles;
vec3_t velocity;
vec3_t avelocity;
vec3_t post_origin;
vec3_t post_angles;
vec3_t post_velocity;
vec3_t post_avelocity;
vec3_t origin_offset;
vec3_t angles_offset;
float ltime;
float bouncetype;
float movetype;
float solid;
vec3_t absmin;
vec3_t absmax;
vec3_t mins;
vec3_t maxs;
vec3_t size;
int chain;
string_t model;
float frame;
float sequence;
float renderfx;
float effects;
float skin;
float body;
string_t weaponmodel;
float weaponframe;
func_t use;
func_t touch;
func_t think;
func_t blocked;
func_t activate;
func_t walk;
func_t jump;
func_t duck;
float flags;
float aiflags;
float spawnflags;
int groundentity;
float nextthink;
float takedamage;
float health;
float frags;
float weapon;
float items;
string_t target;
string_t parent;
string_t targetname;
int aiment;
int goalentity;
vec3_t punchangle;
float deadflag;
vec3_t view_ofs;
float button0;
float button1;
float button2;
float impulse;
float fixangle;
vec3_t v_angle;
float idealpitch;
string_t netname;
int enemy;
float alpha;
float team;
float max_health;
float teleport_time;
float armortype;
float armorvalue;
float waterlevel;
float watertype;
float ideal_yaw;
float yaw_speed;
float dmg_take;
float dmg_save;
int dmg_inflictor;
int owner;
vec3_t movedir;
string_t message;
float sounds;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
float jumpup;
float jumpdn;
int movetarget;
float mass;
float density;
float gravity;
float dmg;
float dmgtime;
float speed;
} entvars_t;
typedef struct prvm_fieldvars_s
{
int ofs;
int type;
const char *name;
} prvm_fieldvars_t;
#define REQFIELDS (sizeof(reqfields) / sizeof(prvm_fieldvars_t))
static prvm_fieldvars_t reqfields[] =
{
{141, 6, "th_stand"},
{142, 6, "th_walk"},
{143, 6, "th_run"},
{144, 6, "th_pain"},
{145, 6, "th_die"},
{146, 6, "th_missile"},
{147, 6, "th_melee"},
{148, 1, "wad"},
{149, 1, "map"},
{150, 1, "landmark"},
{151, 2, "worldtype"},
{152, 2, "delay"},
{153, 2, "wait"},
{154, 2, "lip"},
{155, 2, "light_lev"},
{156, 2, "style"},
{157, 2, "skill"},
{158, 1, "killtarget"},
{159, 3, "pos1"},
{162, 3, "pos2"},
{165, 3, "mangle"},
{168, 2, "pain_finished"},
{169, 2, "air_finished"},
{170, 3, "camview"},
{173, 2, "aflag"},
{174, 4, "trigger_field"},
{175, 2, "anim_time"},
{176, 2, "anim_end"},
{177, 2, "anim_priority"},
{178, 2, "anim_run"},
{179, 2, "showhelp"},
{180, 2, "touched"},
{181, 1, "name"},
{182, 4, "triggerer"},
{183, 1, "targ"},
{184, 1, "targ[1]"},
{185, 1, "targ[2]"},
{186, 1, "targ[3]"},
{187, 1, "targ[4]"},
{188, 1, "targ[5]"},
{189, 1, "targ[6]"},
{190, 1, "targ[7]"},
{191, 1, "oldtarg"},
{192, 1, "oldtarg[1]"},
{193, 1, "oldtarg[2]"},
{194, 1, "oldtarg[3]"},
{195, 1, "oldtarg[4]"},
{196, 1, "oldtarg[5]"},
{197, 1, "oldtarg[6]"},
{198, 1, "oldtarg[7]"},
{199, 2, "twait"},
{200, 2, "twait[1]"},
{201, 2, "twait[2]"},
{202, 2, "twait[3]"},
{203, 2, "twait[4]"},
{204, 2, "twait[5]"},
{205, 2, "twait[6]"},
{206, 2, "twait[7]"},
{207, 2, "olddelay"},
{208, 1, "message1"},
{209, 1, "message2"},
{210, 2, "count"},
{211, 2, "state"},
{212, 2, "used"},
{213, 3, "dest"},
{216, 1, "target_dest"},
{217, 1, "oldmodel"}
};
#define PROG_CRC_SERVER 64081
#endif//PROGDEFS_H

View File

@ -30,14 +30,14 @@ The code uses void pointers instead.
#define PROGSVM_H
#include "vprogs.h" // defs shared with qcc
#include "progdefs.h" // generated by program cdefs
#include "sv_edict.h"
#include "sv_edict.h" // server progs
#include "cl_edict.h" // client progs
#include "ui_edict.h" // uimenu progs
typedef struct prvm_stack_s
{
int s;
mfunction_t *f;
} prvm_stack_t;
// virtual typedef
@ -66,13 +66,15 @@ struct edict_s
vm_edict_t *ed; // vm edict state
void *vp; // generic edict
sv_edict_t *sv; // sv edict state
ui_edict_t *ui; // ui edict state
} priv;
// QuakeC prog fields (stored in dynamically resized array)
union
{
void *vp; // generic entvars
entvars_t *sv; // server entvars
sv_entvars_t *sv; // server entvars
ui_entvars_t *ui; // uimenu entvars
} progs;
};
@ -116,7 +118,8 @@ typedef struct prvm_prog_s
union
{
float *gp;
globalvars_t *sv;
sv_globalvars_t *sv;
ui_globalvars_t *ui;
} globals;
int maxknownstrings;
@ -332,13 +335,14 @@ PRVM_ERROR("runaway loop counter hit limit of %d jumps\n", jumpcount, PRVM_NAME)
}
//============================================================================
// get arguments from progs
#define PRVM_G_FLOAT(o) (prog->globals.gp[o])
#define PRVM_G_INT(o) (*(int *)&prog->globals.gp[o])
#define PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(*(int *)&prog->globals.gp[o]))
#define PRVM_G_EDICTNUM(o) PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(o))
#define PRVM_G_VECTOR(o) (&prog->globals.gp[o])
#define PRVM_G_STRING(o) (PRVM_GetString(*(string_t *)&prog->globals.gp[o]))
//#define PRVM_G_FUNCTION(o) (*(func_t *)&prog->globals.gp[o])
#define PRVM_G_FUNCTION(o) (*(func_t *)&prog->globals.gp[o])
// FIXME: make these go away?
#define PRVM_E_FLOAT(e,o) (((float*)e->progs.vp)[o])
@ -381,7 +385,7 @@ Load a program with LoadProgs
*/
void PRVM_InitProg(int prognr);
// LoadProgs expects to be called right after InitProg
void PRVM_LoadProgs (const char *filename, int numrequiredfunc, char **required_func, int numrequiredfields, prvm_fieldvars_t *required_field);
void PRVM_LoadProgs (const char *filename, int numrequiredfunc, char **required_func, int numrequiredfields, fields_t *required_field);
void PRVM_ResetProg(void);
bool PRVM_ProgLoaded(int prognr);

View File

@ -80,4 +80,227 @@ struct sv_edict_s
entity_state_t s;
struct gclient_s *client; //get rid of this
};
typedef struct sv_globalvars_s
{
int pad[28];
int pev;
int other;
int world;
float time;
float frametime;
string_t mapname;
string_t startspot;
vec3_t spotoffset;
float deathmatch;
float coop;
float teamplay;
float serverflags;
float total_secrets;
float total_monsters;
float found_secrets;
float killed_monsters;
vec3_t v_forward;
vec3_t v_right;
vec3_t v_up;
float trace_allsolid;
float trace_startsolid;
float trace_fraction;
vec3_t trace_endpos;
vec3_t trace_plane_normal;
float trace_plane_dist;
float trace_hitgroup;
float trace_contents;
int trace_ent;
float trace_flags;
func_t main;
func_t StartFrame;
func_t EndFrame;
func_t PlayerPreThink;
func_t PlayerPostThink;
func_t ClientKill;
func_t ClientConnect;
func_t PutClientInServer;
func_t ClientDisconnect;
func_t ClientCommand;
} sv_globalvars_t;
typedef struct sv_entvars_s
{
string_t classname;
string_t globalname;
float modelindex;
vec3_t origin;
vec3_t angles;
vec3_t old_origin;
vec3_t old_angles;
vec3_t velocity;
vec3_t avelocity;
vec3_t post_origin;
vec3_t post_angles;
vec3_t post_velocity;
vec3_t post_avelocity;
vec3_t origin_offset;
vec3_t angles_offset;
float ltime;
float bouncetype;
float movetype;
float solid;
vec3_t absmin;
vec3_t absmax;
vec3_t mins;
vec3_t maxs;
vec3_t size;
int chain;
string_t model;
float frame;
float sequence;
float renderfx;
float effects;
float skin;
float body;
string_t weaponmodel;
float weaponframe;
func_t use;
func_t touch;
func_t think;
func_t blocked;
func_t activate;
func_t walk;
func_t jump;
func_t duck;
float flags;
float aiflags;
float spawnflags;
int groundentity;
float nextthink;
float takedamage;
float health;
float frags;
float weapon;
float items;
string_t target;
string_t parent;
string_t targetname;
int aiment;
int goalentity;
vec3_t punchangle;
float deadflag;
vec3_t view_ofs;
float button0;
float button1;
float button2;
float impulse;
float fixangle;
vec3_t v_angle;
float idealpitch;
string_t netname;
int enemy;
float alpha;
float team;
float max_health;
float teleport_time;
float armortype;
float armorvalue;
float waterlevel;
float watertype;
float ideal_yaw;
float yaw_speed;
float dmg_take;
float dmg_save;
int dmg_inflictor;
int owner;
vec3_t movedir;
string_t message;
float sounds;
string_t noise;
string_t noise1;
string_t noise2;
string_t noise3;
float jumpup;
float jumpdn;
int movetarget;
float mass;
float density;
float gravity;
float dmg;
float dmgtime;
float speed;
} sv_entvars_t;
#define SV_NUM_REQFIELDS (sizeof(sv_reqfields) / sizeof(fields_t))
static fields_t sv_reqfields[] =
{
{141, 6, "th_stand"},
{142, 6, "th_walk"},
{143, 6, "th_run"},
{144, 6, "th_pain"},
{145, 6, "th_die"},
{146, 6, "th_missile"},
{147, 6, "th_melee"},
{148, 1, "wad"},
{149, 1, "map"},
{150, 1, "landmark"},
{151, 2, "worldtype"},
{152, 2, "delay"},
{153, 2, "wait"},
{154, 2, "lip"},
{155, 2, "light_lev"},
{156, 2, "style"},
{157, 2, "skill"},
{158, 1, "killtarget"},
{159, 3, "pos1"},
{162, 3, "pos2"},
{165, 3, "mangle"},
{168, 2, "pain_finished"},
{169, 2, "air_finished"},
{170, 3, "camview"},
{173, 2, "aflag"},
{174, 4, "trigger_field"},
{175, 2, "anim_time"},
{176, 2, "anim_end"},
{177, 2, "anim_priority"},
{178, 2, "anim_run"},
{179, 2, "showhelp"},
{180, 2, "touched"},
{181, 1, "name"},
{182, 4, "triggerer"},
{183, 1, "targ"},
{184, 1, "targ[1]"},
{185, 1, "targ[2]"},
{186, 1, "targ[3]"},
{187, 1, "targ[4]"},
{188, 1, "targ[5]"},
{189, 1, "targ[6]"},
{190, 1, "targ[7]"},
{191, 1, "oldtarg"},
{192, 1, "oldtarg[1]"},
{193, 1, "oldtarg[2]"},
{194, 1, "oldtarg[3]"},
{195, 1, "oldtarg[4]"},
{196, 1, "oldtarg[5]"},
{197, 1, "oldtarg[6]"},
{198, 1, "oldtarg[7]"},
{199, 2, "twait"},
{200, 2, "twait[1]"},
{201, 2, "twait[2]"},
{202, 2, "twait[3]"},
{203, 2, "twait[4]"},
{204, 2, "twait[5]"},
{205, 2, "twait[6]"},
{206, 2, "twait[7]"},
{207, 2, "olddelay"},
{208, 1, "message1"},
{209, 1, "message2"},
{210, 2, "count"},
{211, 2, "state"},
{212, 2, "used"},
{213, 3, "dest"},
{216, 1, "target_dest"},
{217, 1, "oldmodel"}
};
#define PROG_CRC_SERVER 64081
#endif//SV_EDICT_H

View File

@ -443,9 +443,7 @@ void SV_VM_Setup( void )
prog->init_cmd = VM_Cmd_Init;
prog->reset_cmd = VM_Cmd_Reset;
prog->error_cmd = VM_Error;
// TODO: add a requiredfuncs list (ask LH if this is necessary at all)
PRVM_LoadProgs( "server.dat", 0, NULL, REQFIELDS, reqfields );
PRVM_LoadProgs( "server.dat", 0, NULL, SV_NUM_REQFIELDS, sv_reqfields );
PRVM_End;
}

View File

@ -440,7 +440,6 @@ const char *M_Main_Key(int key)
void M_Menu_Main_f (void)
{
M_PushMenu (M_Main_Draw, M_Main_Key);
UI_ToggleMenu_f();
}
/*
@ -3418,6 +3417,7 @@ void M_Init (void)
Cmd_AddCommand ("menu_options", M_Menu_Options_f, "opens main options menu");
Cmd_AddCommand ("menu_keys", M_Menu_Keys_f, "opens redefinition keys menu" );
Cmd_AddCommand ("menu_quit", M_Menu_Quit_f, "show quit dialog" );
Cmd_AddCommand ("menu_toggle", UI_ToggleMenu_f, "enable progs menu(test)" );
UI_Init();
}
@ -3433,7 +3433,7 @@ void M_Draw (void)
if (cls.key_dest != key_menu) return;
if(m_drawfunc) m_drawfunc();
UI_Draw();
if(ui_active) UI_Draw();
// delay playing the enter sound until after the
// menu has been drawn, to avoid delay while
@ -3460,6 +3460,5 @@ void M_Keydown (int key)
if(( s = m_keyfunc( key )) != 0 )
S_StartLocalSound(( char * )s);
}
}
UI_KeyEvent( key );
}

View File

@ -492,15 +492,12 @@ void Slider_Draw( menuslider_s *s )
s->range = ( s->curvalue - s->minvalue ) / ( float ) ( s->maxvalue - s->minvalue );
if ( s->range < 0)
s->range = 0;
if ( s->range > 1)
s->range = 1;
s->range = bound( 0, s->range, 1 );
SCR_DrawSmallChar( s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET, s->generic.y + s->generic.parent->y, 128);
for ( i = 0; i < SLIDER_RANGE; i++ )
SCR_DrawSmallChar( RCOLUMN_OFFSET + s->generic.x + i*8 + s->generic.parent->x + 8, s->generic.y + s->generic.parent->y, 129);
SCR_DrawSmallChar( RCOLUMN_OFFSET + s->generic.x + i*8 + s->generic.parent->x + 8, s->generic.y + s->generic.parent->y, 130);
SCR_DrawSmallChar( ( int ) ( 8 + RCOLUMN_OFFSET + s->generic.parent->x + s->generic.x + (SLIDER_RANGE-1)*8 * s->range ), s->generic.y + s->generic.parent->y, 131);
SCR_DrawSmallChar(( int )( 8 + RCOLUMN_OFFSET + s->generic.parent->x + s->generic.x + (SLIDER_RANGE-1)*8 * s->range ), s->generic.y + s->generic.parent->y, 131);
}
void SpinControl_DoEnter( menulist_s *s )

View File

@ -66,8 +66,6 @@ setmousetarget(float target)
void VM_M_setmousetarget(void)
{
VM_SAFEPARMCOUNT(1, VM_M_setmousetarget);
Msg("VM_M_setmousetarget: called\n" );
}
/*
@ -102,12 +100,10 @@ void VM_M_setkeydest(void)
case key_game:
// key_game
cls.key_dest = key_game;
Msg("Set key_dest = key_game\n");
break;
case key_menu:
// key_menu
cls.key_dest = key_menu;
Msg("Set key_dest = key_menu\n");
break;
case key_message:
// key_message
@ -155,37 +151,32 @@ VM_M_callfunction
Extension: pass
=========
*/
mfunction_t *PRVM_ED_FindFunction (const char *name);
void VM_M_callfunction(void)
void VM_M_callfunction( void )
{
mfunction_t *func;
const char *s;
if(prog->argc == 0)
PRVM_ERROR("VM_M_callfunction: 1 parameter is required !");
if(prog->argc == 0) PRVM_ERROR("VM_M_callfunction: 1 parameter is required !");
s = PRVM_G_STRING(OFS_PARM0 + (prog->argc - 1));
if(!s)
PRVM_ERROR("VM_M_callfunction: null string !");
if(!s) PRVM_ERROR("VM_M_callfunction: null string !");
VM_CheckEmptyString(s);
func = PRVM_ED_FindFunction(s);
if(!func)
if(!func)
{
PRVM_ERROR("VM_M_callfunciton: function %s not found !", s);
else if (func->first_statement < 0)
}
else if(func->first_statement < 0)
{
// negative statements are built in functions
int builtinnumber = -func->first_statement;
prog->xfunction->builtinsprofile++;
if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber])
prog->builtins[builtinnumber]();
else
PRVM_ERROR("No such builtin #%i in %s", builtinnumber, PRVM_NAME);
else PRVM_ERROR("No such builtin #%i in %s", builtinnumber, PRVM_NAME);
}
else if(func > 0)
else if(func - prog->functions > 0)
{
prog->argc--;
PRVM_ExecuteProgram(func - prog->functions,"");
@ -200,7 +191,6 @@ VM_M_isfunction
float isfunction(string function_name)
=========
*/
mfunction_t *PRVM_ED_FindFunction (const char *name);
void VM_M_isfunction(void)
{
mfunction_t *func;
@ -210,17 +200,13 @@ void VM_M_isfunction(void)
s = PRVM_G_STRING(OFS_PARM0);
if(!s)
PRVM_ERROR("VM_M_isfunction: null string !");
if(!s) PRVM_ERROR("VM_M_isfunction: null string !");
VM_CheckEmptyString(s);
func = PRVM_ED_FindFunction(s);
if(!func)
PRVM_G_FLOAT(OFS_RETURN) = false;
else
PRVM_G_FLOAT(OFS_RETURN) = true;
if(!func) PRVM_G_FLOAT(OFS_RETURN) = false;
else PRVM_G_FLOAT(OFS_RETURN) = true;
}
/*
@ -282,7 +268,7 @@ void VM_M_findkeysforcommand(void)
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(ret);
}
prvm_builtin_t vm_m_builtins[] =
prvm_builtin_t vm_ui_builtins[] =
{
0, // to be consistent with the old vm
// common builtings (mostly)
@ -427,4 +413,4 @@ prvm_builtin_t vm_m_builtins[] =
VM_stringtokeynum, // 614
};
const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
const int vm_ui_numbuiltins = sizeof(vm_ui_builtins) / sizeof(prvm_builtin_t);

110
engine/uimenu/ui_edict.h Normal file
View File

@ -0,0 +1,110 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// ui_edict.h - uimenu prvm edict
//=======================================================================
#ifndef UI_EDICT_H
#define UI_EDICT_H
typedef struct ui_globalvars_s
{
int pad[28];
int pev;
func_t m_init;
func_t m_shutdown;
func_t m_keydown;
func_t m_draw;
func_t m_toggle;
} ui_globalvars_t;
typedef struct ui_entvars_s
{
string_t type;
string_t parent;
string_t name;
int _parent;
int _next;
int _prev;
int _child;
} ui_entvars_t;
struct ui_edict_s
{
// generic_edict_t (don't move these fields!)
bool free;
float freetime; // sv.time when the object was freed
// ui_private_edict_t starts here
};
#define UI_NUM_REQFIELDS (sizeof(ui_reqfields) / sizeof(fields_t))
static fields_t ui_reqfields[] =
{
{7, 3, "click_pos"},
{10, 3, "click_size"},
{13, 2, "orderpos"},
{14, 2, "flag"},
{15, 3, "clip_pos"},
{18, 3, "clip_size"},
{21, 3, "origin"},
{24, 6, "init"},
{25, 6, "reinit"},
{26, 6, "destroy"},
{27, 6, "mouse_enter"},
{28, 6, "mouse_leave"},
{29, 6, "refresh"},
{30, 6, "action"},
{31, 6, "draw"},
{32, 6, "key"},
{33, 6, "_reinit"},
{34, 6, "_destroy"},
{35, 6, "_mouse_enter"},
{36, 6, "_mouse_leave"},
{37, 6, "_refresh"},
{38, 6, "_action"},
{39, 6, "_draw"},
{40, 6, "_key"},
{41, 3, "color"},
{44, 2, "alpha"},
{45, 2, "drawflag"},
{46, 1, "link"},
{47, 1, "picture"},
{48, 3, "pos"},
{51, 3, "size"},
{54, 1, "text"},
{55, 3, "font_size"},
{58, 2, "alignment"},
{59, 1, "picture_selected"},
{60, 1, "picture_pressed"},
{61, 1, "sound_selected"},
{62, 1, "sound_pressed"},
{63, 3, "color_selected"},
{66, 3, "color_pressed"},
{69, 2, "alpha_selected"},
{70, 2, "alpha_pressed"},
{71, 2, "drawflag_selected"},
{72, 2, "drawflag_pressed"},
{73, 2, "_press_time"},
{74, 2, "hold_pressed"},
{75, 2, "_button_state"},
{76, 2, "style"},
{77, 1, "picture_bar"},
{78, 1, "sound_changed"},
{79, 2, "min_value"},
{80, 2, "max_value"},
{81, 2, "value"},
{82, 2, "step"},
{83, 3, "slider_size"},
{86, 6, "slidermove"},
{87, 6, "switchchange"},
{88, 1, "cvarname"},
{89, 2, "cvartype"},
{90, 4, "_link"},
{91, 2, "maxlen"},
{92, 4, "find1"},
{93, 2, "find2"}
};
#define PROG_CRC_UIMENU 31295
#endif//UI_EDICT_H

View File

@ -5,26 +5,7 @@
#include "uimenu.h"
#define M_F_INIT "m_init"
#define M_F_KEYDOWN "m_keydown"
#define M_F_KEYUP "m_keyup"
#define M_F_DRAW "m_draw"
#define M_F_TOGGLE "m_toggle"
#define M_F_SHUTDOWN "m_shutdown"
static char *m_required_func[] =
{
M_F_INIT,
M_F_KEYDOWN,
M_F_DRAW,
M_F_TOGGLE,
M_F_SHUTDOWN,
};
static int m_numrequiredfunc = sizeof(m_required_func) / sizeof(char*);
static func_t m_draw, m_keydown;
static mfunction_t *m_keyup;
bool ui_active = false;
void UI_Error(const char *format, ...)
{
@ -53,20 +34,28 @@ void UI_Error(const char *format, ...)
Host_AbortCurrentFrame();
}
void UI_KeyEvent(menuframework_s *m, int key)
void UI_KeyEvent( int key )
{
const char *ascii = Key_KeynumToString(key);
PRVM_Begin;
PRVM_SetProg( PRVM_MENUPROG );
// set time
*prog->time = cls.realtime;
// pass key
prog->globals.gp[OFS_PARM0] = (float)key;
prog->globals.gp[OFS_PARM1] = (string_t)PRVM_SetEngineString(Key_KeynumToString(key));
PRVM_ExecuteProgram(m_keydown, M_F_KEYDOWN"(menuframework_s *m, int key) required\n");
// setup args
PRVM_G_FLOAT(OFS_PARM0) = key;
PRVM_G_INT(OFS_PARM1) = PRVM_SetEngineString(ascii);
PRVM_ExecuteProgram (prog->globals.ui->m_keydown, "QC function m_keydown is missing");
PRVM_End;
switch (key)
{
case K_ESCAPE:
UI_ToggleMenu_f();
break;
}
}
void UI_Draw( void )
@ -77,7 +66,7 @@ void UI_Draw( void )
// set time
*prog->time = cls.realtime;
PRVM_ExecuteProgram( m_draw, "" );
PRVM_ExecuteProgram (prog->globals.ui->m_draw, "QC function m_draw is missing");
PRVM_End;
}
@ -88,8 +77,9 @@ void UI_ToggleMenu_f( void )
// set time
*prog->time = cls.realtime;
ui_active = !ui_active;
PRVM_ExecuteProgram((func_t)(PRVM_ED_FindFunction(M_F_TOGGLE) - prog->functions), "" );
PRVM_ExecuteProgram (prog->globals.ui->m_toggle, "QC function m_toggle is missing");
PRVM_End;
}
@ -101,7 +91,7 @@ void UI_Shutdown( void )
// set time
//*prog->time = cls.realtime;
PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_SHUTDOWN) - prog->functions),"");
PRVM_ExecuteProgram (prog->globals.ui->m_shutdown, "QC function m_shutdown is missing");
// reset key_dest
cls.key_dest = key_game;
@ -117,30 +107,22 @@ void UI_Init( void )
PRVM_Begin;
PRVM_InitProg( PRVM_MENUPROG );
prog->edictprivate_size = 0; // no private struct used
prog->name = M_NAME;
prog->progs_mempool = Mem_AllocPool( "Uimenu Progs" );
prog->builtins = vm_ui_builtins;
prog->numbuiltins = vm_ui_numbuiltins;
prog->edictprivate_size = sizeof(ui_edict_t);
prog->limit_edicts = UI_MAX_EDICTS;
prog->name = "uimenu";
prog->num_edicts = 1;
prog->limit_edicts = M_MAX_EDICTS;
prog->extensionstring = "";
prog->builtins = vm_m_builtins;
prog->numbuiltins = vm_m_numbuiltins;
prog->loadintoworld = false;
prog->init_cmd = VM_Cmd_Init;
prog->reset_cmd = VM_Cmd_Reset;
prog->error_cmd = UI_Error;
// allocate the mempools
prog->progs_mempool = Mem_AllocPool( M_PROG_FILENAME );
PRVM_LoadProgs( M_PROG_FILENAME, m_numrequiredfunc, m_required_func, 0, NULL);
// set m_draw and m_keydown
m_draw = (func_t)(PRVM_ED_FindFunction(M_F_DRAW) - prog->functions);
m_keydown = (func_t)(PRVM_ED_FindFunction(M_F_KEYDOWN) - prog->functions);
m_keyup = PRVM_ED_FindFunction(M_F_KEYUP);
// set time
PRVM_LoadProgs( "uimenu.dat", 0, NULL, UI_NUM_REQFIELDS, ui_reqfields );
*prog->time = cls.realtime;
// call the prog init
PRVM_ExecuteProgram((func_t)(PRVM_ED_FindFunction(M_F_INIT) - prog->functions),"");
PRVM_ExecuteProgram (prog->globals.ui->m_init, "QC function m_init is missing");
PRVM_End;
}

View File

@ -27,39 +27,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "progsvm.h"
#include "vm_cmds.h"
#define M_PROG_FILENAME "uimenu.dat"
#define M_NAME "menu"
#define M_MAX_EDICTS (1 << 12) // should be enough for a menu
#define UI_MAX_EDICTS (1 << 12) // should be enough for a menu
enum m_state_e {
m_none,
m_main,
m_demo,
m_singleplayer,
m_transfusion_episode,
m_transfusion_skill,
m_load,
m_save,
m_multiplayer,
m_setup,
m_options,
m_video,
m_keys,
m_help,
m_credits,
m_quit,
m_lanconfig,
m_gameoptions,
m_slist,
m_options_effects,
m_options_graphics,
m_options_colorcontrol,
m_reset
};
extern enum m_state_e m_state;
extern bool ui_active;
extern const int vm_ui_numbuiltins;
extern prvm_builtin_t vm_ui_builtins[];
void UI_Init( void );
void UI_KeyEvent(menuframework_s *m, int key);
void UI_KeyEvent( int key );
void UI_ToggleMenu_f( void );
void UI_Shutdown( void );
void UI_Draw( void );

View File

@ -779,8 +779,7 @@ void VM_find (void)
if (ed->priv.ed->free)
continue;
t = PRVM_E_STRING(ed,f);
if (!t)
t = "";
if (!t) t = "";
if (!strcmp(t,s))
{
VM_RETURN_EDICT(ed);
@ -1157,7 +1156,7 @@ VM_nextent
entity nextent(entity)
=============
*/
void VM_nextent (void)
void VM_nextent( void )
{
int i;
edict_t *ent;
@ -1981,7 +1980,7 @@ void VM_loadfromfile(void)
// not conform with VM_fopen
data = (char *)FS_LoadFile(filename, NULL);
if (data == NULL) PRVM_G_FLOAT(OFS_RETURN) = -1;
PRVM_ED_LoadFromFile(data);
PRVM_ED_LoadFromFile( data );
}
@ -2225,10 +2224,10 @@ float drawcharacter(vector position, float character, vector scale, vector rgb,
*/
void VM_drawcharacter(void)
{
float *pos, *rgb;
char character;
VM_SAFEPARMCOUNT(3, VM_drawcharacter);
float *pos, *rgb, *scale, alpha;
VM_SAFEPARMCOUNT(5, VM_drawcharacter);
character = (char)PRVM_G_FLOAT(OFS_PARM1);
if(character == 0)
{
@ -2238,12 +2237,15 @@ void VM_drawcharacter(void)
}
pos = PRVM_G_VECTOR(OFS_PARM0);
scale = PRVM_G_VECTOR(OFS_PARM2);
rgb = PRVM_G_VECTOR(OFS_PARM3);
alpha = PRVM_G_FLOAT(OFS_PARM4);
if(pos[2]) Msg("VM_drawcharacter: z value from \"pos\" discarded\n" );
if(scale[2]) Msg("VM_drawcharacter: z value from \"scale\" discarded\n" );
re->SetColor( GetRGBA(rgb[0], rgb[1], rgb[2], 1.0f));
SCR_DrawSmallChar( pos[0], pos[1], character );
re->SetColor( GetRGBA(rgb[0], rgb[1], rgb[2], alpha ));
SCR_DrawChar( pos[0], pos[1], scale[0], scale[1], character );
re->SetColor( NULL );
PRVM_G_FLOAT(OFS_RETURN) = 1;
}
@ -2276,7 +2278,7 @@ void VM_drawstring(void)
alpha = PRVM_G_FLOAT(OFS_PARM4);
flag = (int)PRVM_G_FLOAT(OFS_PARM5);
SCR_DrawBigString( pos[0], pos[1], string, alpha );
SCR_DrawStringExt( pos[0], pos[1], scale[0], scale[1], string, GetRGBA(rgb[0], rgb[1], rgb[2], alpha ), true );
PRVM_G_FLOAT(OFS_RETURN) = 1;
}
@ -2349,20 +2351,18 @@ float drawfill(vector position, vector size, vector rgb, float alpha, float flag
*/
void VM_drawfill(void)
{
float *size, *pos, *rgb;
float *size, *pos, *rgb, alpha;
int flag;
vec4_t color;
VM_SAFEPARMCOUNT(5, VM_drawfill);
pos = PRVM_G_VECTOR(OFS_PARM0);
size = PRVM_G_VECTOR(OFS_PARM1);
rgb = PRVM_G_VECTOR(OFS_PARM2);
alpha = PRVM_G_FLOAT(OFS_PARM3);
flag = (int)PRVM_G_FLOAT(OFS_PARM4);
Vector4Set( color, rgb[0], rgb[1], rgb[2], 1.0f );
SCR_FillRect( pos[0], pos[1], size[0], size[1], color );
SCR_FillRect( pos[0], pos[1], size[0], size[1], GetRGBA( rgb[0], rgb[1], rgb[2], alpha ));
PRVM_G_FLOAT(OFS_RETURN) = 1;
}

View File

@ -168,7 +168,6 @@ float getserverlistindexforkey(string key)
#include "engine.h"
#include "server.h"
#include "progdefs.h"
#include "progsvm.h"
//============================================================================

View File

@ -1211,7 +1211,7 @@ void PRVM_ED_LoadFromFile (const char *data)
spawned++;
if (ent->priv.ed->free) died++;
}
MsgDev(D_INFO, "%s: %i new entities parsed, %i new inhibited, %i (%i new) spawned (whereas %i removed self, %i stayed)\n", PRVM_NAME, parsed, inhibited, prog->num_edicts, spawned, died, spawned - died);
MsgDev(D_NOTE, "%s: %i new entities parsed, %i new inhibited, %i (%i new) spawned (whereas %i removed self, %i stayed)\n", PRVM_NAME, parsed, inhibited, prog->num_edicts, spawned, died, spawned - died);
}
/*
@ -1280,7 +1280,7 @@ void PRVM_LoadLNO( const char *progname )
PRVM_LoadProgs
===============
*/
void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int numedfields, prvm_fieldvars_t *ed_field)
void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int numedfields, fields_t *ed_field)
{
dstatement_t *st;
ddef_t *infielddefs;
@ -1326,8 +1326,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
switch(prog->progs->crc)
{
case PROG_CRC_SERVER:
break;
case 35063:
case PROG_CRC_UIMENU:
break;
default:
PRVM_ERROR("%s: %s system vars have been modified, progdefs.h is out of date", PRVM_NAME, filename);

View File

@ -460,7 +460,7 @@ void Sys_CloseLog( void )
fprintf(logfile, "\n");
fprintf(logfile, "=======================================================================");
fprintf(logfile, "\n\t%s stopped at %s\n", Sys.caption, com_timestamp(TIME_FULL));
fprintf(logfile, "\n\t%s %sed at %s\n", Sys.caption, Sys.crash ? "crash" : "stopp", com_timestamp(TIME_FULL));
fprintf(logfile, "=======================================================================");
fclose(logfile);

View File

@ -1,9 +1,9 @@
=======================================================================
Xash3D QuakeC Compiler started at Nov22 2007 [21:57.08]
Xash3D QuakeC Compiler started at Nov24 2007 [22:28.22]
=======================================================================
------------Configuration: ../temp/uimenu - Vm16 Release------------
------------Configuration: ../temp/uimenu - Vm16 Debug------------
Compiling...
msys.c
entvars.h
mbuiltin.c
menu.h
cursor.h
@ -21,13 +21,14 @@ mfuncs.c
sound.c
graphic.c
mcustom.c
Custom progs crc 35063
writing progdefs.h
Custom progs crc 31295
Linking...
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
../temp/uimenu.dat - 0 error(s), 0 warning(s)
0.381 seconds elapsed
0.639 seconds elapsed
=======================================================================
Xash3D QuakeC Compiler stopped at Nov22 2007 [21:57.08]
Xash3D QuakeC Compiler stopped at Nov24 2007 [22:28.22]
=======================================================================

View File

@ -62,14 +62,16 @@ void(void) cursor_frame =
// update cursor animations
if(cursor_type > CT_LAST_PULSE || cursor_type < CT_FIRST_PULSE)
{
cursor_last_frame_time = time;
}
else if(cursor_last_frame_time + CA_PULSE_SPEED <= time)
{
{
cursor_type = CT_FIRST_PULSE +
mod((time - cursor_last_frame_time) / CA_PULSE_SPEED, CT_LAST_PULSE - CT_FIRST_PULSE +1);
cursor_last_frame_time += rint((time - cursor_last_frame_time) / CA_PULSE_SPEED) * CA_PULSE_SPEED;
}
}
// update cursor position
cursor_rel = getmousepos();

186
pr_uimenu/entvars.h Normal file
View File

@ -0,0 +1,186 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// entvars.h - menu edicts
//=======================================================================
entity pev;
void m_init( void );
void m_shutdown( void );
void m_keydown( float keynr, string ascii );
void m_draw( void );
void m_toggle( void );
void end_sys_globals;
.string type; // ITEM_* type
.string parent;
.string name; // item name (for linking)
.entity _parent; // pointer to parent entity
.entity _next; // point to the next, respectively, the previous item
.entity _prev;
.entity _child; // points to the first child
void end_sys_fields;
// these are the key numbers that should be passed to Key_Event
enum
{
// keyboard
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,
// mouse
K_MOUSE1,
K_MOUSE2,
K_MOUSE3,
K_MOUSE4,
K_MOUSE5,
K_MWHEELDOWN,
K_MWHEELUP,
K_LAST_KEY // this had better be < 256!
};
///////////////////////////
// key dest constants
enum
{
KEY_GAME,
KEY_CONSOLE,
KEY_MESSAGE,
KEY_MENU
};
///////////////////////////
// file constants
float FILE_READ = 0;
float FILE_APPEND = 1;
float FILE_WRITE = 2;
///////////////////////////
// logical constants (just for completeness)
float TRUE = 1;
float FALSE = 0;
///////////////////////////
// boolean constants
float true = 1;
float false = 0;
///////////////////////////
// msg constants
float MSG_BROADCAST = 0; // unreliable to all
float MSG_ONE = 1; // reliable to one (msg_entity)
float MSG_ALL = 2; // reliable to all
float MSG_INIT = 3; // write to the init string
/////////////////////////////
// mouse target constants
float MT_MENU = 1;
float MT_CLIENT = 2;
/////////////////////////
// client state constants
float CS_DEDICATED = 0;
float CS_DISCONNECTED = 1;
float CS_CONNECTED = 2;
///////////////////////////
// blend flags
float DRAWFLAG_NORMAL = 0;
float DRAWFLAG_ADDITIVE = 1;
float DRAWFLAG_MODULATE = 2;
float DRAWFLAG_2XMODULATE = 3;
///////////////////////////
// null entity (actually it is the same like the world entity)
entity null_entity;
///////////////////////////
// error constants
// file handling
float ERR_CANNOTOPEN = -1; // fopen
float ERR_NOTENOUGHFILEHANDLES = -2; // fopen
float ERR_INVALIDMODE = -3; // fopen
float ERR_BADFILENAME = -4; // fopen
// drawing functions
float ERR_NULLSTRING = -1;
float ERR_BADDRAWFLAG = -2;
float ERR_BADSCALE = -3;
float ERR_BADSIZE = ERR_BADSCALE;
float ERR_NOTCACHED = -4;
/* not supported at the moment
///////////////////////////
// os constants
float OS_WINDOWS = 0;
float OS_LINUX = 1;
float OS_MAC = 2;
*/

View File

@ -21,7 +21,7 @@ void(void) gfx_toggle =
{
};
void(float keynr, float ascii) gfx_keydown =
void(float keynr, string ascii) gfx_keydown =
{
};
@ -63,7 +63,7 @@ gfx_drawchar =
if(scale == '0 0 0')
return;
ret = drawcharacter(position, character, scale, rgb, alpha, flag);
ret = drawcharacter(position, character, scale, rgb, alpha );
if(ret == 1)
return;
@ -121,25 +121,19 @@ gfx_drawpic =
error("Unknown error code !\n");
};
void(vector position, vector size, vector rgb, float alpha, float flag)
gfx_fillarea =
void gfx_fillarea (vector position, vector size, vector rgb, float alpha, float flag)
{
float ret;
position = gfx_converttocon(position);
size = gfx_converttocon(size);
if(size == '0 0 0')
return;
if(size == '0 0 0') return;
ret = drawfill(position, size, rgb, alpha, flag);
if(ret == 1)
return;
if(ret == 1) return;
if(ret == ERR_BADDRAWFLAG)
error("Bad draw flag !\n");
error("Unknown error code !\n");
};
}
void(vector position, vector size) gfx_setcliparea =
{
@ -149,12 +143,11 @@ void(void) gfx_resetcliparea =
{
};
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
menu_drawchar =
void menu_drawchar (vector position, float character, vector scale, vector rgb, float alpha, float flag)
{
position = gfx_conmentogfx(position);
gfx_drawchar(position, character, scale, rgb, alpha, flag);
};
}
void(vector position, string str, vector scale, vector rgb, float alpha, float flag)
menu_drawstring =
@ -197,19 +190,13 @@ vector(string pic_name) gfx_getimagesize =
vector(vector vec) gfx_converttogfx =
{
vector v;
v_x = vec_x * (vid_conwidth / SCR_WIDTH );
v_y = vec_y * (vid_conheight / SCR_HEIGHT);
return v;
return vec;
};
vector(vector vec) gfx_converttocon =
vector gfx_converttocon (vector vec)
{
vector v;
v_x = vec_x * (vid_conwidth / SCR_WIDTH);
v_y = vec_y * (vid_conheight / SCR_HEIGHT);
return v;
};
return vec;
}
vector(vector vec) gfx_conmentogfx =
{

View File

@ -18,7 +18,7 @@ float vid_conheight;
void(void) gfx_init;
void(void) gfx_frame;
void(void) gfx_toggle;
void(float keynr, float ascii) gfx_keydown;// perhaps we want to do some special fx for specail keys
void(float keynr, string ascii) gfx_keydown;// perhaps we want to do some special fx for specail keys
void(void) gfx_draw;
void(void) gfx_shutdown;

View File

@ -110,7 +110,7 @@ void localsound(string sample) = #65;
vector getmousepos(void) = #66;
float gettime(void) = #67;
void loadfromdata(string data) = #68;
void loadfromfile(string file) = #69;
float loadfromfile(string file) = #69;
float mod(float val, float m) = #70;
@ -141,7 +141,7 @@ float iscachedpic(string name) = #451;
string precache_pic(string name) = #452;
void freepic(string name) = #453;
float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454;
float drawcharacter(vector position, float character, vector scale, vector rgb, float scale ) = #454;
float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;

View File

@ -78,8 +78,18 @@ void(void) ITEM_CUSTOM =
// ITEM_PICTURE has a special draw function
void(void) ITEM_PICTURE_DRAW =
{
menu_drawpic(pev.pos, pev.picture, pev.size, pev.color, pev.alpha, pev.drawflag);
// align to the rect pos - (pos + size)
vector alignpos;
// now check the alignement
if(pev.alignment & TEXT_ALIGN_CENTER)
{
alignpos_x = pev.pos_x + (pev.pos_x - pev.size_x) / 2;
alignpos_y = pev.pos_y + (pev.pos_y - pev.size_y) / 2;
}
else alignpos = pev.pos;
menu_drawpic(alignpos, pev.picture, pev.size, pev.color, pev.alpha, pev.drawflag);
ctcall_draw();
};
@ -100,13 +110,10 @@ void(void) ITEM_PICTURE =
gfx_loadpic(pev.picture, MENU_ENFORCELOADING);
// if flag wasnt set yet, then set it to FLAG_DRAWONLY
if(pev.flag == 0)
pev.flag = FLAG_DRAWONLY;
if(pev.flag == 0) pev.flag = FLAG_DRAWONLY;
if(pev.color == '0 0 0')
pev.color = ITEM_PICTURE_NORMAL_COLOR;
if(pev.alpha == 0)
pev.alpha = ITEM_PICTURE_NORMAL_ALPHA;
if(pev.color == '0 0 0') pev.color = ITEM_PICTURE_NORMAL_COLOR;
if(pev.alpha == 0) pev.alpha = ITEM_PICTURE_NORMAL_ALPHA;
item_init(
defct_reinit,
@ -265,8 +272,8 @@ void(float keynr, float ascii) ITEM_BUTTON_KEY =
if(keynr == K_ENTER || keynr == K_MOUSE1)
{
pev._action();
} else
def_keyevent(keynr, ascii);
}
else def_keyevent(keynr, ascii);
};
void(void) ITEM_BUTTON_ACTION =
@ -362,10 +369,11 @@ void(void) ITEM_TEXTBUTTON_REFRESH =
pev.size_x = pev.font_size_x * strlen(pev.text);
pev.size_y = pev.font_size_y;
} else if(pev.font_size == '0 0 0')
}
else if(pev.font_size == '0 0 0')
{
pev.font_size_x = pev.size_x / strlen(pev.text);
pev.font_size_y = pev.size_y;
pev.font_size_x = pev.size_x / strlen(pev.text);
pev.font_size_y = pev.size_y;
}
if((pev.hold_pressed + pev._press_time < time && pev._button_state == BUTTON_PRESSED) || (menu_selected != pev && pev._button_state == BUTTON_SELECTED))
@ -395,9 +403,9 @@ void(void) ITEM_TEXTBUTTON_DRAW =
alignpos_x = pev.pos_x + (pev.size_x - strlen(pev.text) * pev.font_size_x) / 2;
else if(pev.alignment & TEXT_ALIGN_RIGHT)
alignpos_x = pev.pos_x + pev.size_x - strlen(pev.text) * pev.font_size_x;
else
alignpos_x = pev.pos_x;
alignpos_y = pev.pos_y;
else alignpos_x = pev.pos_x;
alignpos_y = pev.pos_y;
if(pev.style == TEXTBUTTON_STYLE_OUTLINE && pev._button_state != BUTTON_NORMAL)
{
@ -454,7 +462,8 @@ void(void) ITEM_TEXTBUTTON_DRAW =
{
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
}
} else if(pev.style == TEXTBUTTON_STYLE_BOX)
}
else if(pev.style == TEXTBUTTON_STYLE_BOX)
{
if(pev._button_state == BUTTON_PRESSED)
{
@ -570,7 +579,8 @@ void(void) ITEM_TEXTBUTTON =
void(void) ITEM_SLIDER_DRAW =
{
vector slider_pos;
vector slider_pos, temp;
float i, slider_range;
// draw the bar
if(pev.picture_bar != "")
@ -579,20 +589,26 @@ void(void) ITEM_SLIDER_DRAW =
}
else
{
menu_fillarea(pev.pos, pev.size, pev.color, pev.alpha, pev.drawflag);
// Quake-Style slider
menu_drawchar( pev.pos, 128, pev.slider_size, pev.color, pev.alpha, pev.drawflag );
for ( i = 1; i < 10; i++ )
{
temp = pev.pos;
temp_x = pev.pos_x + (i * pev.slider_size_x);
temp_y = pev.pos_y;
menu_drawchar( temp, 129, pev.slider_size, pev.color, pev.alpha, pev.drawflag );
}
menu_drawchar( temp, 130, pev.slider_size, pev.color, pev.alpha, pev.drawflag );
}
slider_range = (pev.value - pev.min_value) / (pev.max_value - pev.min_value);
slider_range = bound( 0, slider_range, 1 ); // bound range
// draw the slider
slider_pos = pev.pos;
slider_pos_x = slider_pos_x + ((pev.size_x - pev.slider_size_x) / (pev.max_value - pev.min_value)) * (pev.value - pev.min_value);
if(pev.picture != "")
{
menu_drawpic(slider_pos, pev.picture, pev.slider_size, pev.color, pev.alpha, pev.drawflag);
}
else
{
menu_fillarea(slider_pos, pev.slider_size, pev.color + ITEM_SLIDER_BAR_COLOR_DELTA, pev.alpha, pev.drawflag);
}
slider_pos = pev.pos;
slider_pos_x = pev.pos_x + pev.slider_size_x + pev.slider_size_x * (slider_range * 7);//FIXME
if(pev.picture != "") menu_drawpic(slider_pos, pev.picture, pev.slider_size, pev.color, pev.alpha, pev.drawflag);
else menu_drawchar( slider_pos, 131, pev.slider_size, pev.color, pev.alpha, pev.drawflag );
};
void(void) ITEM_SLIDER_UPDATESLIDER =
@ -840,7 +856,8 @@ void(string text, vector pos, vector size, float alignment, float style, float s
{
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
}
} else if(style == TEXTBUTTON_STYLE_BOX)
}
else if(style == TEXTBUTTON_STYLE_BOX)
{
if(state == BUTTON_PRESSED)
{

View File

@ -37,7 +37,7 @@ ITEM_TEXTSWITCH
const vector ITEM_TEXT_NORMAL_COLOR = '1 1 1';
const float ITEM_TEXT_NORMAL_ALPHA = 1;
const vector ITEM_TEXT_SELECTED_COLOR = '0.5 0 0';
const vector ITEM_TEXT_SELECTED_COLOR = '1 0.6 0';
const float ITEM_TEXT_SELECTED_ALPHA = 1;
const vector ITEM_TEXT_PRESSED_COLOR = '1 0 0';
@ -77,7 +77,7 @@ const float TEXTBUTTON_STYLE_TEXT = 0;
const float TEXTBUTTON_OUTLINE_WIDTH = 1.0;
//ITEM_TEXT
const vector ITEM_TEXT_FONT_SIZE = '8 8 0';
const vector ITEM_TEXT_FONT_SIZE = '10 10 0';
const float TEXT_ALIGN_LEFT = 0;
const float TEXT_ALIGN_CENTER = 1;

View File

@ -43,9 +43,9 @@ void(void) _dpmod_slidertext_refresh =
pev.size = '0 0 0';
};
float(float keynr, float ascii) dpmod_redirect_key =
float(float keynr, string ascii) dpmod_redirect_key =
{
if(keynr == K_ENTER || keynr == K_LEFTARROW || keynr == K_RIGHTARROW || (keynr >= K_MOUSE1 && keynr <= K_MOUSE10))
if(keynr == K_ENTER || keynr == K_LEFTARROW || keynr == K_RIGHTARROW || (keynr >= K_MOUSE1 && keynr <= K_MOUSE3))
{
raise_key(pev._child, keynr, ascii);
return true;
@ -98,59 +98,42 @@ void(void) dpmod_display_options =
menu_jumptowindow(ent, true);
};
// quit menu
// display the options menu
void(void) dpmod_display_video =
{
entity ent;
ent = menu_getitem("video");
menu_jumptowindow(ent, true);
};
void vid_apply_changes( void )
{
cmd( "vid_restart\n" );
menu_selectup();
}
void vid_cancel_changes( void )
{
menu_selectup();
}
// quit menu
void(void) dpmod_quit_choose =
{
entity e;
// because of the missing support for real array, we have to do it the stupid way
// (we also have to use strzone for the text, cause it the temporary strings wont work
// for it)
if(dpmod_quitrequest == 0)
{
e = menu_getitem("quit_msg_0");
e.text = getaltstring(0, dpmod_quitmsg[0]);
}
if(dpmod_quitrequest == 1)
{
e = menu_getitem("quit_msg_0");
e.text = getaltstring(0, dpmod_quitmsg[1]);
}
if(dpmod_quitrequest == 2)
{
e = menu_getitem("quit_msg_0");
e.text = getaltstring(0, dpmod_quitmsg[2]);
}
if(dpmod_quitrequest == 3)
{
e = menu_getitem("quit_msg_0");
e.text = getaltstring(0, dpmod_quitmsg[3]);
}
e = menu_getitem("quit_msg_0");
e.text = getaltstring(0, dpmod_quitmsg[dpmod_quitrequest]);
e.text = strzone(e.text);
if(dpmod_quitrequest == 0)
{
e = menu_getitem("quit_msg_1");
e.text = getaltstring(1, dpmod_quitmsg[0]);
}
if(dpmod_quitrequest == 1)
{
e = menu_getitem("quit_msg_1");
e.text = getaltstring(1, dpmod_quitmsg[1]);
}
if(dpmod_quitrequest == 2)
{
e = menu_getitem("quit_msg_1");
e.text = getaltstring(1, dpmod_quitmsg[2]);
}
if(dpmod_quitrequest == 3)
{
e = menu_getitem("quit_msg_1");
e.text = getaltstring(1, dpmod_quitmsg[3]);
}
e = menu_getitem("quit_msg_1");
e.text = getaltstring(1, dpmod_quitmsg[dpmod_quitrequest]);
e.text = strzone(e.text);
dpmod_quitrequest = dpmod_quitrequest + 1;
dpmod_quitrequest++;
if(dpmod_quitrequest == DPMOD_QUIT_MSG_COUNT)
dpmod_quitrequest = 0;
};
@ -191,7 +174,7 @@ void(void) dpmod_quit_no =
menu_selectup();
};
float(float keynr, float ascii) dpmod_quit_key =
float(float keynr, string ascii) dpmod_quit_key =
{
if(keynr == K_LEFTARROW)
return false;
@ -201,9 +184,9 @@ float(float keynr, float ascii) dpmod_quit_key =
return false;
if(keynr == K_MOUSE1)
return false;
if(ascii == 'Y' || ascii == 'y')
if(ascii == "Y" || ascii == "y")
dpmod_quit_yes();
if(ascii == 'N' || ascii == 'n' || keynr == K_ESCAPE)
if(ascii == "N" || ascii == "n" || keynr == K_ESCAPE)
dpmod_quit_no();
return true;
};
@ -287,7 +270,7 @@ void(void) dpmod_main_exit_yes =
cmd("quit\n");
};
float(float keynr, float ascii) dpmod_main_exit_key =
float(float keynr, string ascii) dpmod_main_exit_key =
{
if(keynr == K_ESCAPE)
{

View File

@ -119,7 +119,7 @@ void(void) dpmod_cvar_slider; // set reinit to this
void(void) _dpmod_cvar_slider_refresh;
void(void) _dpmod_cvar_slider;
float(float keynr, float ascii) dpmod_redirect_key;
float(float keynr, string ascii) dpmod_redirect_key;
void(void) dpmod_slidertext;
void(void) _dpmod_slidertext_refresh;
@ -148,4 +148,4 @@ void(void) dpmod_quit_choose;
void(void) dpmod_quit;
void(void) dpmod_quit_yes;
void(void) dpmod_quit_no;
float(float keynr, float ascii) dpmod_quit_key;
float(float keynr, string ascii) dpmod_quit_key;

View File

@ -24,7 +24,7 @@ void(void) m_init =
};
// required menu functions
void(float keynr, float ascii) m_keydown =
void(float keynr, string ascii) m_keydown =
{
if(!menu_active)
return;

View File

@ -45,7 +45,7 @@ void(entity ent) raise_destroy =
pev = old;
};
void(entity ent, float keynr, float ascii) raise_key =
void(entity ent, float keynr, string ascii) raise_key =
{
entity old;
if(!ent._key)

View File

@ -1,64 +1,64 @@
///////////////////////////////////////////////
// Functions Header File
///////////////////////
// This file belongs to dpmod/darkplaces
// AK contains all menu controlling stuff (sub-menus)
///////////////////////////////////////////////
////////////////
// prototypes
///
// some gfx helper functions
float(float tfactor) getflicker;
void(void) def_refresh;
void(float keynr, float ascii) def_keyevent;
// default control functions - assign only to the _* event functions
// (assigning to the 'normal' event functions will crash the vm !)
// are used by ITEM_CUSTOM and can be used to test new ITEMs easily
void(void) defct_reinit;
void(void) defct_destroy;
void(float keynr, float ascii) defct_key;
void(void) defct_draw;
void(void) defct_mouse_enter;
void(void) defct_mouse_leave;
void(void) defct_action;
void(void) defct_refresh;
// use this to raise an event from another item or function
void(entity ent) raise_reinit;
void(entity ent) raise_destroy;
void(entity ent, float keynr, float ascii) raise_key;
void(entity ent) raise_draw;
void(entity ent) raise_mouse_enter;
void(entity ent) raise_mouse_leave;
void(entity ent) raise_action;
void(entity ent) raise_refresh;
// safe call the normal control functions (only used by the mcontrols function)
void(void) ctcall_init;
void(void) ctcall_reinit;
void(void) ctcall_destroy;
float(float keynr, float ascii) ctcall_key;
void(void) ctcall_draw;
void(void) ctcall_mouse_enter;
void(void) ctcall_mouse_leave;
void(void) ctcall_action;
void(void) ctcall_refresh;
// control event function initializer
void(void(void) reinitevent, void(void) destroyevent, void(float key, float ascii) keyevent, void(void) drawevent, void(void) mouse_enterevent, void(void) mouse_leaveevent, void(void) actionevent, void(void) refreshevent)
item_init;
float(vector point, vector r_xy, vector r_size) inrect;
// clips are rectangle against a clip area
// cliprectsize returns '0 0 0' if it is clipped totally
vector(vector r_pos, vector r_size, vector c_pos, vector c_size) cliprectpos;
vector(vector r_pos, vector r_size, vector c_pos, vector c_size) cliprectsize;
// used to extract 'string' strings from a normal string
float(string s) getaltstringcount;
string(float c, string s) getaltstring;
///////////////////////////////////////////////
// Functions Header File
///////////////////////
// This file belongs to dpmod/darkplaces
// AK contains all menu controlling stuff (sub-menus)
///////////////////////////////////////////////
////////////////
// prototypes
///
// some gfx helper functions
float(float tfactor) getflicker;
void(void) def_refresh;
void(float keynr, float ascii) def_keyevent;
// default control functions - assign only to the _* event functions
// (assigning to the 'normal' event functions will crash the vm !)
// are used by ITEM_CUSTOM and can be used to test new ITEMs easily
void(void) defct_reinit;
void(void) defct_destroy;
void(float keynr, float ascii) defct_key;
void(void) defct_draw;
void(void) defct_mouse_enter;
void(void) defct_mouse_leave;
void(void) defct_action;
void(void) defct_refresh;
// use this to raise an event from another item or function
void(entity ent) raise_reinit;
void(entity ent) raise_destroy;
void(entity ent, float keynr, string ascii) raise_key;
void(entity ent) raise_draw;
void(entity ent) raise_mouse_enter;
void(entity ent) raise_mouse_leave;
void(entity ent) raise_action;
void(entity ent) raise_refresh;
// safe call the normal control functions (only used by the mcontrols function)
void(void) ctcall_init;
void(void) ctcall_reinit;
void(void) ctcall_destroy;
float(float keynr, float ascii) ctcall_key;
void(void) ctcall_draw;
void(void) ctcall_mouse_enter;
void(void) ctcall_mouse_leave;
void(void) ctcall_action;
void(void) ctcall_refresh;
// control event function initializer
void(void(void) reinitevent, void(void) destroyevent, void(float key, float ascii) keyevent, void(void) drawevent, void(void) mouse_enterevent, void(void) mouse_leaveevent, void(void) actionevent, void(void) refreshevent)
item_init;
float(vector point, vector r_xy, vector r_size) inrect;
// clips are rectangle against a clip area
// cliprectsize returns '0 0 0' if it is clipped totally
vector(vector r_pos, vector r_size, vector c_pos, vector c_size) cliprectpos;
vector(vector r_pos, vector r_size, vector c_pos, vector c_size) cliprectsize;
// used to extract 'string' strings from a normal string
float(string s) getaltstringcount;
string(float c, string s) getaltstring;

View File

@ -17,10 +17,9 @@ void(void) menu_load =
// load the menu files
float i;
for(i = 0; i < 2; i++ )
for(i = 0; i < NUM_RESFILES; i++ )
{
menu_loadmenu(MENU_FILENAME_LIST[i]);
dprint(MENU_FILENAME_LIST[i], " loaded !\n");
}
menu_linkwindows();
};
@ -97,10 +96,13 @@ void(void) menu_restart =
}
}
};
void(string file) menu_loadmenu =
void menu_loadmenu (string file)
{
loadfromfile(file);
};
if(loadfromfile(file) == -1)
{
dprint("^3Warning:^7 couldn't load ", file, "\n");
}
}
entity(entity start, .entity find1, entity match, .float find2, float match2) findef =
{
@ -126,7 +128,7 @@ void(void) menu_linkwindows =
entity ent;
float x, opos;
ent = findstring(null_entity,name, MENU_NORMAL_NAME);
ent = findstring(null_entity, name, MENU_NORMAL_NAME);
if(ent == null_entity) loadfromdata(MENU_NORMAL_DEFAULT);
// verify again if MENI_INGAME_NAME is there now
@ -137,7 +139,7 @@ void(void) menu_linkwindows =
if(ent == null_entity) loadfromdata(MENU_INGAME_DEFAULT);
// verify again if MENI_INGAME_NAME is there now
ent = findstring(null_entity,name, MENU_INGAME_NAME);
ent = findstring(null_entity, name, MENU_INGAME_NAME);
if(ent == null_entity) error("Bad MENU_INGAME_DEFAULT !\n");
// verify that every name is only used *once*
@ -490,7 +492,6 @@ void(void) menu_draw =
// if menu_activewindow is visible loop though it
if(menu_isvisible(menu_activewindow))
{
//menu_setcliparea('100 100 0', '400 400 0');
menu_drawwindow(menu_activewindow);
menu_localorigin = '0 0 0';
menu_clip_pos = '0 0 0';
@ -554,13 +555,13 @@ void(void) menu_shutdown =
}
};
void(float keynr, float ascii) menu_keydown =
void(float keynr, string ascii) menu_keydown =
{
// before calling the current keydown functions, process the mouse again
// so only the correct item is called
// (except mouse wheel up and down)
// if the mouse doesnt point to an item, there wont be a reaction on the clicking
if(K_MOUSE1 <= keynr && keynr <= K_MOUSE10)
if(K_MOUSE1 <= keynr && keynr <= K_MOUSE3)
{
entity key_selected;
key_selected = menu_selected;

View File

@ -30,11 +30,15 @@ const string MENU_INGAME_DEFAULT =
" \"name\" \"ingame\"\n"
"}";
#define NUM_RESFILES 4
// insert the files here
string MENU_FILENAME_LIST[2] =
string MENU_FILENAME_LIST[NUM_RESFILES] =
{
"scripts/menu/main.txt",
"scripts/menu/options.txt"
"scripts/menu/main.res",
"scripts/menu/game.res",
"scripts/menu/options.res",
"scripts/menu/video.res"
};
const float MENU_ALLOWINGAME = FALSE;
@ -57,22 +61,6 @@ vector menu_cursor;
///////////
// fields
///
// controly type
.string type;
// managing stuff
.entity _parent;
.string parent;
//.entity _history; // used to set up the history -> selectdown prefers _history over _parent
.string name;
.entity _next, _prev; // point to the next, respectively, the previous item
.entity _child; // points to the first child
// updating stuff
.vector click_pos, click_size;
@ -106,7 +94,7 @@ vector menu_cursor;
.void(void) _refresh;
.void(void) _action;
.void(void) _draw;
.void(float keynr, float ascii) _key;
.void(float keynr, string ascii) _key;
///////////////
// prototypes
@ -132,7 +120,7 @@ void(void) menu_linkwindows;
void(void) menu_frame;
void(void) menu_draw;
void(float keynr, float ascii) menu_keydown;
void(float keynr, string ascii) menu_keydown;
void(void) menu_shutdown;
// used for menu handling

View File

@ -1,256 +0,0 @@
//////////////////////////////////////////////////////////
// sys globals
entity pev;
/////////////////////////////////////////////////////////
void end_sys_globals;
/////////////////////////////////////////////////////////
// sys fields
/////////////////////////////////////////////////////////
void end_sys_fields;
/////////////////////////////////////////////////////////
// sys functions
void() m_init;
void(float keynr, float ascii) m_keydown;
void() m_draw;
void() m_toggle;
void() m_shutdown;
/////////////////////////////////////////////////////////
// sys constants
///////////////////////////
// key constants
//
// these are the key numbers that should be passed to Key_Event
//
float K_TAB = 9;
float K_ENTER = 13;
float K_ESCAPE = 27;
float K_SPACE = 32;
// normal keys should be passed as lowercased ascii
float K_BACKSPACE = 127;
float K_UPARROW = 128;
float K_DOWNARROW = 129;
float K_LEFTARROW = 130;
float K_RIGHTARROW = 131;
float K_ALT = 132;
float K_CTRL = 133;
float K_SHIFT = 134;
float K_F1 = 135;
float K_F2 = 136;
float K_F3 = 137;
float K_F4 = 138;
float K_F5 = 139;
float K_F6 = 140;
float K_F7 = 141;
float K_F8 = 142;
float K_F9 = 143;
float K_F10 = 144;
float K_F11 = 145;
float K_F12 = 146;
float K_INS = 147;
float K_DEL = 148;
float K_PGDN = 149;
float K_PGUP = 150;
float K_HOME = 151;
float K_END = 152;
float K_PAUSE = 153;
float K_NUMLOCK = 154;
float K_CAPSLOCK = 155;
float K_SCROLLLOCK = 156;
float K_KP_0 = 157;
float K_KP_INS = K_KP_0;
float K_KP_1 = 158;
float K_KP_END = K_KP_1;
float K_KP_2 = 159;
float K_KP_DOWNARROW = K_KP_2;
float K_KP_3 = 160;
float K_KP_PGDN = K_KP_3;
float K_KP_4 = 161;
float K_KP_LEFTARROW = K_KP_4;
float K_KP_5 = 162;
float K_KP_6 = 163;
float K_KP_RIGHTARROW = K_KP_6;
float K_KP_7 = 164;
float K_KP_HOME = K_KP_7;
float K_KP_8 = 165;
float K_KP_UPARROW = K_KP_8;
float K_KP_9 = 166;
float K_KP_PGUP = K_KP_9;
float K_KP_PERIOD = 167;
float K_KP_DEL = K_KP_PERIOD;
float K_KP_DIVIDE = 168;
float K_KP_SLASH = K_KP_DIVIDE;
float K_KP_MULTIPLY = 169;
float K_KP_MINUS = 170;
float K_KP_PLUS = 171;
float K_KP_ENTER = 172;
float K_KP_EQUALS = 173;
// mouse buttons generate virtual keys
float K_MOUSE1 = 512;
float K_MOUSE2 = 513;
float K_MOUSE3 = 514;
float K_MOUSE4 = 515;
float K_MWHEELUP = K_MOUSE4;
float K_MOUSE5 = 516;
float K_MWHEELDOWN = K_MOUSE5;
float K_MOUSE6 = 517;
float K_MOUSE7 = 518;
float K_MOUSE8 = 519;
float K_MOUSE9 = 520;
float K_MOUSE10 = 521;
float K_MOUSE11 = 522;
float K_MOUSE12 = 523;
float K_MOUSE13 = 524;
float K_MOUSE14 = 525;
float K_MOUSE15 = 526;
float K_MOUSE16 = 527;
//
// joystick buttons
//
float K_JOY1 = 768;
float K_JOY2 = 769;
float K_JOY3 = 770;
float K_JOY4 = 771;
//
//
// aux keys are for multi-buttoned joysticks to generate so they can use
// the normal binding process
//
float K_AUX1 = 772;
float K_AUX2 = 773;
float K_AUX3 = 774;
float K_AUX4 = 775;
float K_AUX5 = 776;
float K_AUX6 = 777;
float K_AUX7 = 778;
float K_AUX8 = 779;
float K_AUX9 = 780;
float K_AUX10 = 781;
float K_AUX11 = 782;
float K_AUX12 = 783;
float K_AUX13 = 784;
float K_AUX14 = 785;
float K_AUX15 = 786;
float K_AUX16 = 787;
float K_AUX17 = 788;
float K_AUX18 = 789;
float K_AUX19 = 790;
float K_AUX20 = 791;
float K_AUX21 = 792;
float K_AUX22 = 793;
float K_AUX23 = 794;
float K_AUX24 = 795;
float K_AUX25 = 796;
float K_AUX26 = 797;
float K_AUX27 = 798;
float K_AUX28 = 799;
float K_AUX29 = 800;
float K_AUX30 = 801;
float K_AUX31 = 802;
float K_AUX32 = 803;
///////////////////////////
// key dest constants
enum
{
KEY_GAME,
KEY_CONSOLE,
KEY_MESSAGE,
KEY_MENU
};
///////////////////////////
// file constants
float FILE_READ = 0;
float FILE_APPEND = 1;
float FILE_WRITE = 2;
///////////////////////////
// logical constants (just for completeness)
float TRUE = 1;
float FALSE = 0;
///////////////////////////
// boolean constants
float true = 1;
float false = 0;
///////////////////////////
// msg constants
float MSG_BROADCAST = 0; // unreliable to all
float MSG_ONE = 1; // reliable to one (msg_entity)
float MSG_ALL = 2; // reliable to all
float MSG_INIT = 3; // write to the init string
/////////////////////////////
// mouse target constants
float MT_MENU = 1;
float MT_CLIENT = 2;
/////////////////////////
// client state constants
float CS_DEDICATED = 0;
float CS_DISCONNECTED = 1;
float CS_CONNECTED = 2;
///////////////////////////
// blend flags
float DRAWFLAG_NORMAL = 0;
float DRAWFLAG_ADDITIVE = 1;
float DRAWFLAG_MODULATE = 2;
float DRAWFLAG_2XMODULATE = 3;
///////////////////////////
// null entity (actually it is the same like the world entity)
entity null_entity;
///////////////////////////
// error constants
// file handling
float ERR_CANNOTOPEN = -1; // fopen
float ERR_NOTENOUGHFILEHANDLES = -2; // fopen
float ERR_INVALIDMODE = -3; // fopen
float ERR_BADFILENAME = -4; // fopen
// drawing functions
float ERR_NULLSTRING = -1;
float ERR_BADDRAWFLAG = -2;
float ERR_BADSCALE = -3;
float ERR_BADSIZE = ERR_BADSCALE;
float ERR_NOTCACHED = -4;
/* not supported at the moment
///////////////////////////
// os constants
float OS_WINDOWS = 0;
float OS_LINUX = 1;
float OS_MAC = 2;
*/

102
pr_uimenu/progdefs.h Normal file
View File

@ -0,0 +1,102 @@
// progdefs.h
// generated by Xash3D QuakeC compiler
#ifndef PROGDEFS_H
#define PROGDEFS_H
typedef struct globalvars_s
{
int pad[28];
int pev;
func_t m_init;
func_t m_shutdown;
func_t m_keydown;
func_t m_draw;
func_t m_toggle;
} globalvars_t;
typedef struct entvars_s
{
string_t type;
string_t parent;
string_t name;
int _parent;
int _next;
int _prev;
int _child;
} entvars_t;
#define REQFIELDS (sizeof(reqfields) / sizeof(fields_t))
static fields_t reqfields[] =
{
{7, 3, "click_pos"},
{10, 3, "click_size"},
{13, 2, "orderpos"},
{14, 2, "flag"},
{15, 3, "clip_pos"},
{18, 3, "clip_size"},
{21, 3, "origin"},
{24, 6, "init"},
{25, 6, "reinit"},
{26, 6, "destroy"},
{27, 6, "mouse_enter"},
{28, 6, "mouse_leave"},
{29, 6, "refresh"},
{30, 6, "action"},
{31, 6, "draw"},
{32, 6, "key"},
{33, 6, "_reinit"},
{34, 6, "_destroy"},
{35, 6, "_mouse_enter"},
{36, 6, "_mouse_leave"},
{37, 6, "_refresh"},
{38, 6, "_action"},
{39, 6, "_draw"},
{40, 6, "_key"},
{41, 3, "color"},
{44, 2, "alpha"},
{45, 2, "drawflag"},
{46, 1, "link"},
{47, 1, "picture"},
{48, 3, "pos"},
{51, 3, "size"},
{54, 1, "text"},
{55, 3, "font_size"},
{58, 2, "alignment"},
{59, 1, "picture_selected"},
{60, 1, "picture_pressed"},
{61, 1, "sound_selected"},
{62, 1, "sound_pressed"},
{63, 3, "color_selected"},
{66, 3, "color_pressed"},
{69, 2, "alpha_selected"},
{70, 2, "alpha_pressed"},
{71, 2, "drawflag_selected"},
{72, 2, "drawflag_pressed"},
{73, 2, "_press_time"},
{74, 2, "hold_pressed"},
{75, 2, "_button_state"},
{76, 2, "style"},
{77, 1, "picture_bar"},
{78, 1, "sound_changed"},
{79, 2, "min_value"},
{80, 2, "max_value"},
{81, 2, "value"},
{82, 2, "step"},
{83, 3, "slider_size"},
{86, 6, "slidermove"},
{87, 6, "switchchange"},
{88, 1, "cvarname"},
{89, 2, "cvartype"},
{90, 4, "_link"},
{91, 2, "maxlen"},
{92, 4, "find1"},
{93, 2, "find2"}
};
#define PROG_CRC_UIMENU 31295
#endif//PROGDEFS_H

View File

@ -5,7 +5,7 @@
../temp/uimenu.dat
msys.c
entvars.h
mbuiltin.c
menu.h
cursor.h

View File

@ -1 +1 @@
qcclib -log /V7
qcclib -log /V7 /Od -progdefs

View File

@ -1,55 +1,55 @@
///////////////////////////////////////////////
// Sound Source File
///////////////////////
// This file belongs to dpmod/darkplaces
// AK contains all manager constants, etc.
///////////////////////////////////////////////
void(void) snd_init =
{
snd_loadsound(SOUND_SELECT, SOUND_ENFORCELOADING);
snd_loadsound(SOUND_CHANGE, SOUND_ENFORCELOADING);
snd_loadsound(SOUND_ACTION, SOUND_ENFORCELOADING);
};
void(void) snd_frame =
{
};
void(void) snd_toggle =
{
};
void(float keynr, float ascii) snd_keydown =
{
};
void(void) snd_shutdown =
{
snd_unloadsound(SOUND_SELECT);
snd_unloadsound(SOUND_CHANGE);
snd_unloadsound(SOUND_ACTION);
};
void(string sound_name) snd_play =
{
localsound(sound_name);
};
string(string sound_name, float complain) snd_loadsound =
{
string c;
c = precache_sound(sound_name);
if(c == "" && complain)
error("Couldn't load ", sound_name, " !\n");
return c;
};
void(string sound_name) snd_unloadsound =
{
// FIXME: there is now free/unload sound at the moment
// at least non that works the way it should
};
///////////////////////////////////////////////
// Sound Source File
///////////////////////
// This file belongs to dpmod/darkplaces
// AK contains all manager constants, etc.
///////////////////////////////////////////////
void(void) snd_init =
{
snd_loadsound(SOUND_SELECT, SOUND_ENFORCELOADING);
snd_loadsound(SOUND_CHANGE, SOUND_ENFORCELOADING);
snd_loadsound(SOUND_ACTION, SOUND_ENFORCELOADING);
};
void(void) snd_frame =
{
};
void(void) snd_toggle =
{
};
void(float keynr, string ascii) snd_keydown =
{
};
void(void) snd_shutdown =
{
snd_unloadsound(SOUND_SELECT);
snd_unloadsound(SOUND_CHANGE);
snd_unloadsound(SOUND_ACTION);
};
void(string sound_name) snd_play =
{
localsound(sound_name);
};
string(string sound_name, float complain) snd_loadsound =
{
string c;
c = precache_sound(sound_name);
if(c == "" && complain)
error("Couldn't load ", sound_name, " !\n");
return c;
};
void(string sound_name) snd_unloadsound =
{
// FIXME: there is now free/unload sound at the moment
// at least non that works the way it should
};

View File

@ -1,29 +1,29 @@
///////////////////////////////////////////////
// Sound Header File
///////////////////////
// This file belongs to dpmod/darkplaces
// AK contains all manager constants, etc.
///////////////////////////////////////////////
// constants
// complain if the vm is unable to load a file ?
const float SOUND_ENFORCELOADING = false;
// file names
const string SOUND_SELECT = "misc/menu1.wav";
const string SOUND_CHANGE = "misc/menu2.wav";
const string SOUND_ACTION = "misc/menu3.wav";
// prototypes
void(void) snd_init;
void(void) snd_toggle;
void(float keynr, float ascii)snd_keydown;
void(void) snd_frame;
void(void) snd_shutdown;
void(string sound_name) snd_play;
string(string sound_name, float complain) snd_loadsound;
void(string sound_name) snd_unloadsound;
///////////////////////////////////////////////
// Sound Header File
///////////////////////
// This file belongs to dpmod/darkplaces
// AK contains all manager constants, etc.
///////////////////////////////////////////////
// constants
// complain if the vm is unable to load a file ?
const float SOUND_ENFORCELOADING = false;
// file names
const string SOUND_SELECT = "misc/menu1.wav";
const string SOUND_CHANGE = "misc/menu2.wav";
const string SOUND_ACTION = "misc/menu3.wav";
// prototypes
void(void) snd_init;
void(void) snd_toggle;
void(float keynr, string ascii)snd_keydown;
void(void) snd_frame;
void(void) snd_shutdown;
void(string sound_name) snd_play;
string(string sound_name, float complain) snd_loadsound;
void(string sound_name) snd_unloadsound;

View File

@ -66,6 +66,7 @@ typedef void (*xcommand_t) (void);
typedef struct gclient_s gclient_t;
typedef struct sv_edict_s sv_edict_t;
typedef struct cl_edict_s cl_edict_t;
typedef struct ui_edict_s ui_edict_t;
typedef int progsnum_t;
typedef struct progfuncs_s progfuncs_t;
typedef float vec_t;
@ -83,12 +84,13 @@ typedef struct physragdoll_s NewtonRagDoll;
typedef struct physmaterial_s NewtonMaterial;
typedef struct physcolision_s NewtonCollision;
typedef struct physragbone_s NewtonRagDollBone;
typedef struct { int fileofs; int filelen; } lump_t;
typedef struct { int type; char *name; } activity_map_t;
typedef struct { int fileofs; int filelen; } lump_t; // many formats use lumps to store blocks
typedef struct { int type; char *name; } activity_map_t; // studio activity map conversion
typedef struct { uint b:5; uint g:6; uint r:5; } color16;
typedef struct { byte r:8; byte g:8; byte b:8; } color24;
typedef struct { byte r; byte g; byte b; byte a; } color32;
typedef struct { const char *name; void **func; } dllfunc_t;
typedef struct { const char *name; void **func; } dllfunc_t; // Sys_LoadLibrary stuff
typedef struct { int ofs; int type; const char *name; } fields_t; // prvm custom fields
static vec4_t g_color_table[8] =
{

View File

@ -142,7 +142,6 @@ void Draw_StretchPic (float x, float y, float w, float h, float s1, float t1, fl
GL_EnableBlend();
GL_TexEnv( GL_MODULATE );
if(gl_state.draw_color[3] != 1.0f )
{
GL_DisableAlphaTest();
@ -150,21 +149,23 @@ void Draw_StretchPic (float x, float y, float w, float h, float s1, float t1, fl
}
else
{
GL_EnableAlphaTest();
qglBlendFunc(GL_ONE, GL_ZERO);
}
qglColor4fv( gl_state.draw_color );
qglBegin (GL_QUADS);
qglTexCoord2f (s1, t1);
qglVertex2f (x, y);
qglTexCoord2f (s2, t1);
qglVertex2f (x+w, y);
qglTexCoord2f (s2, t2);
qglVertex2f (x+w, y+h);
qglTexCoord2f (s1, t2);
qglVertex2f (x, y+h);
qglEnd ();
VA_SetElem2(tex_array[0], s1, t1);
VA_SetElem2(vert_array[0], x, y);
VA_SetElem2(tex_array[1], s2, t1);
VA_SetElem2(vert_array[1], x+w, y);
VA_SetElem2(tex_array[2], s2, t2);
VA_SetElem2(vert_array[2], x+w, y+h);
VA_SetElem2(tex_array[3], s1, t2);
VA_SetElem2(vert_array[3], x, y+h);
GL_LockArrays( 4 );
qglDrawArrays(GL_QUADS, 0, 4);
GL_UnlockArrays();
GL_DisableBlend();
GL_EnableAlphaTest();
@ -248,6 +249,7 @@ void Draw_Fill(float x, float y, float w, float h)
qglVertex2f(x + w, y + h);
qglVertex2f(x, y + h);
qglEnd();
GL_DisableBlend();
qglEnable (GL_TEXTURE_2D);
}