23 Nov 2007
This commit is contained in:
parent
6a0928281c
commit
d1652e8c45
|
@ -31,6 +31,7 @@ scroll = visible_offset
|
|||
//==================================================
|
||||
// то, что уже готово
|
||||
//==================================================
|
||||
++טסןנאגכום באד ס נוךףנסטגם<D792>ל ג<>חמגמל Sys_Crash
|
||||
+добавлен Sys_Crash
|
||||
+исправлен баг с рекурсивным вызовом Sys_Error и Host_Error
|
||||
+имплементированы простейшие сохранялки
|
||||
|
|
|
@ -32,8 +32,8 @@ uint old_sys_frame_time;
|
|||
|
||||
int mouse_buttons;
|
||||
int mouse_oldbuttonstate;
|
||||
POINT current_pos;
|
||||
int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
|
||||
POINT cur_pos, old_pos;
|
||||
int mouse_x, mouse_y, mx_accum, my_accum;
|
||||
|
||||
bool mouseactive; // false when not focus app
|
||||
|
||||
|
@ -80,7 +80,7 @@ IN_ActivateMouse
|
|||
Called when the window gains focus or changes in some way
|
||||
===========
|
||||
*/
|
||||
void IN_ActivateMouse (void)
|
||||
void IN_ActivateMouse( void )
|
||||
{
|
||||
int width, height;
|
||||
|
||||
|
@ -108,7 +108,7 @@ void IN_ActivateMouse (void)
|
|||
|
||||
window_center_x = (window_rect.right + window_rect.left)/2;
|
||||
window_center_y = (window_rect.top + window_rect.bottom)/2;
|
||||
SetCursorPos (window_center_x, window_center_y);
|
||||
SetCursorPos( window_center_x, window_center_y );
|
||||
|
||||
SetCapture( host.hWnd );
|
||||
ClipCursor(&window_rect);
|
||||
|
@ -195,11 +195,11 @@ void CL_MouseMove (usercmd_t *cmd)
|
|||
if (!mouseactive) return;
|
||||
|
||||
// find mouse movement
|
||||
if (!GetCursorPos (¤t_pos))
|
||||
if (!GetCursorPos (&cur_pos))
|
||||
return;
|
||||
|
||||
mx = current_pos.x - window_center_x;
|
||||
my = current_pos.y - window_center_y;
|
||||
mx = cur_pos.x - window_center_x;
|
||||
my = cur_pos.y - window_center_y;
|
||||
|
||||
#if 0
|
||||
if (!mx && !my)
|
||||
|
@ -208,8 +208,8 @@ void CL_MouseMove (usercmd_t *cmd)
|
|||
|
||||
if (m_filter->value)
|
||||
{
|
||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||
mouse_y = (my + old_mouse_y) * 0.5;
|
||||
mouse_x = (mx + old_pos.x) * 0.5;
|
||||
mouse_y = (my + old_pos.y) * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -217,29 +217,26 @@ void CL_MouseMove (usercmd_t *cmd)
|
|||
mouse_y = my;
|
||||
}
|
||||
|
||||
old_mouse_x = mx;
|
||||
old_mouse_y = my;
|
||||
old_pos.x = mx;
|
||||
old_pos.y = my;
|
||||
|
||||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && mlooking ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
if(cls.key_dest != key_menu)
|
||||
{
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && mlooking ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if ( (mlooking || freelook->value) && !(in_strafe.state & 1))
|
||||
{
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
if((mlooking || freelook->value) && !(in_strafe.state & 1))
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
else cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
|
||||
// force the mouse to the center, so there's room to move
|
||||
if (mx || my) SetCursorPos (window_center_x, window_center_y);
|
||||
if(mx || my) SetCursorPos( window_center_x, window_center_y );
|
||||
}
|
||||
|
||||
|
||||
|
@ -287,7 +284,7 @@ void CL_UpdateMouse( void )
|
|||
return;
|
||||
}
|
||||
|
||||
if( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu )
|
||||
if( !cl.refresh_prepped || cls.key_dest == key_console )
|
||||
{
|
||||
// temporarily deactivate if in fullscreen
|
||||
if(!Cvar_VariableValue ("fullscreen"))
|
||||
|
|
|
@ -1889,7 +1889,6 @@ vector getmousepos()
|
|||
*/
|
||||
void VM_getmousepos(void)
|
||||
{
|
||||
|
||||
VM_SAFEPARMCOUNT(0, VM_getmousepos);
|
||||
|
||||
PRVM_G_VECTOR(OFS_RETURN)[0] = mouse_x;
|
||||
|
@ -2315,12 +2314,10 @@ float drawpic(vector position, string pic, vector size, vector rgb, float alpha,
|
|||
*/
|
||||
void VM_drawpic(void)
|
||||
{
|
||||
const char *picname;
|
||||
float *size, *pos, *rgb;
|
||||
int flag;
|
||||
|
||||
VM_SAFEPARMCOUNT(6,VM_drawpic);
|
||||
const char *picname;
|
||||
float *size, *pos, *rgb, alpha;
|
||||
|
||||
VM_SAFEPARMCOUNT(5, VM_drawpic);
|
||||
picname = PRVM_G_STRING(OFS_PARM1);
|
||||
|
||||
if(!picname)
|
||||
|
@ -2335,9 +2332,11 @@ void VM_drawpic(void)
|
|||
pos = PRVM_G_VECTOR(OFS_PARM0);
|
||||
size = PRVM_G_VECTOR(OFS_PARM2);
|
||||
rgb = PRVM_G_VECTOR(OFS_PARM3);
|
||||
flag = (int) PRVM_G_FLOAT(OFS_PARM5);
|
||||
alpha = PRVM_G_FLOAT(OFS_PARM4);
|
||||
|
||||
re->SetColor( GetRGBA(rgb[0], rgb[1], rgb[2], alpha ));
|
||||
SCR_DrawPic( pos[0], pos[1], size[0], size[1], (char *)picname );
|
||||
re->SetColor( NULL );
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1327,7 +1327,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
{
|
||||
case PROG_CRC_SERVER:
|
||||
break;
|
||||
case 10020:
|
||||
case 35063:
|
||||
break;
|
||||
default:
|
||||
PRVM_ERROR("%s: %s system vars have been modified, progdefs.h is out of date", PRVM_NAME, filename);
|
||||
|
@ -1557,7 +1557,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
{
|
||||
case OP_IF:
|
||||
case OP_IFNOT:
|
||||
if((word)st->a >= prog->progs->numglobals || (word)st->b + i < 0 || (word)st->b + i >= prog->progs->numstatements)
|
||||
if((word)st->a >= prog->progs->numglobals || st->b + i < 0 || st->b + i >= prog->progs->numstatements)
|
||||
PRVM_ERROR("PRVM_LoadProgs: out of bounds IF/IFNOT (statement %d) in %s", i, PRVM_NAME);
|
||||
break;
|
||||
case OP_GOTO:
|
||||
|
|
|
@ -440,6 +440,7 @@ const char *M_Main_Key(int key)
|
|||
void M_Menu_Main_f (void)
|
||||
{
|
||||
M_PushMenu (M_Main_Draw, M_Main_Key);
|
||||
UI_ToggleMenu_f();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3417,7 +3418,6 @@ 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();
|
||||
}
|
||||
|
@ -3432,7 +3432,7 @@ void M_Draw (void)
|
|||
{
|
||||
if (cls.key_dest != key_menu) return;
|
||||
|
||||
m_drawfunc();
|
||||
if(m_drawfunc) m_drawfunc();
|
||||
UI_Draw();
|
||||
|
||||
// delay playing the enter sound until after the
|
||||
|
|
|
@ -124,8 +124,8 @@ bool Field_Key( menufield_s *f, int key )
|
|||
case K_UPARROW:
|
||||
case K_KP_ENTER:
|
||||
case K_ENTER:
|
||||
case K_ESCAPE:
|
||||
case K_TAB:
|
||||
case K_ESCAPE:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ void VM_M_precache_sound( void )
|
|||
PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
|
||||
VM_CheckEmptyString( s );
|
||||
|
||||
if(!SV_SoundIndex( s ))
|
||||
// fake precaching
|
||||
if(!FS_FileExists( va("sound/%s", s )))
|
||||
{
|
||||
VM_Warning("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
|
||||
return;
|
||||
|
@ -95,18 +96,20 @@ setkeydest(float dest)
|
|||
void VM_M_setkeydest(void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(1, VM_M_setkeydest);
|
||||
|
||||
|
||||
switch((int)PRVM_G_FLOAT(OFS_PARM0))
|
||||
{
|
||||
case 0:
|
||||
case key_game:
|
||||
// key_game
|
||||
cls.key_dest = key_game;
|
||||
Msg("Set key_dest = key_game\n");
|
||||
break;
|
||||
case 2:
|
||||
case key_menu:
|
||||
// key_menu
|
||||
cls.key_dest = key_menu;
|
||||
Msg("Set key_dest = key_menu\n");
|
||||
break;
|
||||
case 1:
|
||||
case key_message:
|
||||
// key_message
|
||||
// cls.key_dest = key_message
|
||||
// break;
|
||||
|
@ -124,7 +127,7 @@ float getkeydest
|
|||
*/
|
||||
void VM_M_getkeydest(void)
|
||||
{
|
||||
VM_SAFEPARMCOUNT(0,VM_M_getkeydest);
|
||||
VM_SAFEPARMCOUNT(0, VM_M_getkeydest);
|
||||
|
||||
// key_game = 0, key_message = 1, key_menu = 2, unknown = 3
|
||||
switch(cls.key_dest)
|
||||
|
|
|
@ -89,7 +89,7 @@ void UI_ToggleMenu_f( void )
|
|||
// set time
|
||||
*prog->time = cls.realtime;
|
||||
|
||||
PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_TOGGLE) - prog->functions), "" );
|
||||
PRVM_ExecuteProgram((func_t)(PRVM_ED_FindFunction(M_F_TOGGLE) - prog->functions), "" );
|
||||
PRVM_End;
|
||||
}
|
||||
|
||||
|
@ -141,6 +141,6 @@ void UI_Init( void )
|
|||
*prog->time = cls.realtime;
|
||||
|
||||
// call the prog init
|
||||
PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_INIT) - prog->functions),"");
|
||||
PRVM_ExecuteProgram((func_t)(PRVM_ED_FindFunction(M_F_INIT) - prog->functions),"");
|
||||
PRVM_End;
|
||||
}
|
|
@ -768,18 +768,22 @@ void Sys_Error(const char *error, ...)
|
|||
long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
|
||||
{
|
||||
// save config
|
||||
Sys.crash = true;
|
||||
Sys.Free(); // prepare host to close
|
||||
Sys_FreeLibrary( Sys.linked_dll );
|
||||
|
||||
if(Sys.developer >= D_MEMORY)
|
||||
if(!Sys.crash)
|
||||
{
|
||||
// show execption in native console too
|
||||
Con_ShowConsole( true );
|
||||
Msg("Sys_Crash: call %p at address %p\n", pInfo->ExceptionRecord->ExceptionCode, pInfo->ExceptionRecord->ExceptionAddress );
|
||||
Sys_WaitForQuit();
|
||||
}
|
||||
Con_DestroyConsole();
|
||||
// check to avoid recursive call
|
||||
Sys.crash = true;
|
||||
Sys.Free(); // prepare host to close
|
||||
Sys_FreeLibrary( Sys.linked_dll );
|
||||
|
||||
if(Sys.developer >= D_MEMORY)
|
||||
{
|
||||
// show execption in native console too
|
||||
Con_ShowConsole( true );
|
||||
Msg("Sys_Crash: call %p at address %p\n", pInfo->ExceptionRecord->ExceptionCode, pInfo->ExceptionRecord->ExceptionAddress );
|
||||
Sys_WaitForQuit();
|
||||
}
|
||||
Con_DestroyConsole();
|
||||
}
|
||||
|
||||
if( Sys.oldFilter )
|
||||
return Sys.oldFilter( pInfo );
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
=======================================================================
|
||||
Xash3D QuakeC Compiler started at Nov22 2007 [21:57.08]
|
||||
=======================================================================
|
||||
------------Configuration: ../temp/uimenu - Vm16 Release------------
|
||||
Compiling...
|
||||
msys.c
|
||||
mbuiltin.c
|
||||
menu.h
|
||||
cursor.h
|
||||
mmanager.h
|
||||
mfuncs.h
|
||||
mcontrols.h
|
||||
sound.h
|
||||
graphic.h
|
||||
mcustom.h
|
||||
cursor.c
|
||||
menu.c
|
||||
mmanager.c
|
||||
mcontrols.c
|
||||
mfuncs.c
|
||||
sound.c
|
||||
graphic.c
|
||||
mcustom.c
|
||||
Custom progs crc 35063
|
||||
Linking...
|
||||
‘ª®¯¨à®¢ ® ä ©«®¢: 1.
|
||||
|
||||
../temp/uimenu.dat - 0 error(s), 0 warning(s)
|
||||
0.381 seconds elapsed
|
||||
|
||||
=======================================================================
|
||||
Xash3D QuakeC Compiler stopped at Nov22 2007 [21:57.08]
|
||||
=======================================================================
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
void(void) cursor_reset =
|
||||
{
|
||||
cursor_x = rint(GFX_WIDTH /2);
|
||||
cursor_y = rint(GFX_HEIGHT /2);
|
||||
cursor_x = rint(SCR_WIDTH / 2);
|
||||
cursor_y = rint(SCR_HEIGHT / 2);
|
||||
|
||||
cursor_rel = '0 0 0';
|
||||
|
||||
|
@ -20,8 +20,8 @@ void(void) cursor_reset =
|
|||
|
||||
void(void) cursor_toggle =
|
||||
{
|
||||
cursor_x = rint(GFX_WIDTH /2);
|
||||
cursor_y = rint(GFX_HEIGHT /2);
|
||||
cursor_x = rint(SCR_WIDTH /2);
|
||||
cursor_y = rint(SCR_HEIGHT /2);
|
||||
cursor_type = CT_NORMAL;
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,7 @@ void(void) cursor_init =
|
|||
// load the images
|
||||
if(CF_NORMAL != "") CF_NORMAL = gfx_loadpic(CF_NORMAL, CURSOR_ENFORCELOADING);
|
||||
|
||||
if(CF_NORMAL == "") CF_NORMAL = gfx_loadpic("ui/mousepointer.tga", true); // always
|
||||
if(CF_NORMAL == "") CF_NORMAL = gfx_loadpic("common/cursor", true); // always
|
||||
|
||||
if(CF_PULSE[0] != "") CF_PULSE[0] = gfx_loadpic(CF_PULSE[0], CURSOR_ENFORCELOADING);
|
||||
if(CF_PULSE[1] != "") CF_PULSE[1] = gfx_loadpic(CF_PULSE[1], CURSOR_ENFORCELOADING);
|
||||
|
@ -78,11 +78,11 @@ void(void) cursor_frame =
|
|||
cursor_rel = cursor_rel * CURSOR_SPEED;
|
||||
cursor = cursor + cursor_rel;
|
||||
|
||||
cursor_x = bound(0, cursor_x, GFX_WIDTH);
|
||||
cursor_y = bound(0, cursor_y, GFX_HEIGHT);
|
||||
cursor_x = bound(0, cursor_x, SCR_WIDTH);
|
||||
cursor_y = bound(0, cursor_y, SCR_HEIGHT);
|
||||
};
|
||||
|
||||
void(void) cursor_draw =
|
||||
void cursor_draw( void )
|
||||
{
|
||||
string pic;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ const float CT_FIRST_PULSE = 1; // pulse frames 0 - 6
|
|||
const float CT_LAST_PULSE = 7;
|
||||
const float CT_GLOW = 8;
|
||||
|
||||
const float CURSOR_SCALE = 1;
|
||||
const float CURSOR_SCALE = 1.2;
|
||||
|
||||
const vector CURSOR_COLOR = '1 1 1';
|
||||
const float CURSOR_TRANSPARENCY = 1;
|
||||
|
@ -24,7 +24,7 @@ const float CURSOR_SPEED = 0.75;
|
|||
const float CA_PULSE_SPEED = 0.14257142 ; // = 1 / 7 -> 1 secs total time
|
||||
|
||||
// cursor filenames
|
||||
var string CF_NORMAL = "ui/mousepointer.tga";
|
||||
var string CF_NORMAL = "common/cursor";
|
||||
|
||||
// enforce loading everything else qc will break
|
||||
const float CURSOR_ENFORCELOADING = false;
|
||||
|
|
|
@ -1,232 +1,222 @@
|
|||
///////////////////////////////////////////////
|
||||
// Graphic Source File
|
||||
///////////////////////
|
||||
// This file belongs to dpmod/darkplaces
|
||||
// AK contains all graphic functions
|
||||
///////////////////////////////////////////////
|
||||
|
||||
void(void) gfx_init =
|
||||
{
|
||||
vid_conwidth = cvar("vid_conwidth");
|
||||
vid_conheight = cvar("vid_conheight");
|
||||
};
|
||||
|
||||
void(void) gfx_frame =
|
||||
{
|
||||
vid_conwidth = cvar("vid_conwidth");
|
||||
vid_conheight = cvar("vid_conheight");
|
||||
};
|
||||
|
||||
void(void) gfx_toggle =
|
||||
{
|
||||
};
|
||||
|
||||
void(float keynr, float ascii) gfx_keydown =
|
||||
{
|
||||
};
|
||||
|
||||
void(void) gfx_draw =
|
||||
{
|
||||
};
|
||||
|
||||
void(void) gfx_shutdown =
|
||||
{
|
||||
};
|
||||
|
||||
string(string pic_name, float complain) gfx_loadpic =
|
||||
{
|
||||
string c;
|
||||
c = precache_pic(pic_name);
|
||||
|
||||
if(c == "" && complain)
|
||||
error("Couldnt precache ", pic_name, " !\n");
|
||||
if(c == "")
|
||||
dprint("Couldnt precache ", pic_name, " !\n");
|
||||
return c;
|
||||
};
|
||||
|
||||
void(string pic_name) gfx_unloadpic =
|
||||
{
|
||||
// FIXME: gfx_unloadpic is a bit buggy in dp at the moment - restart the menu a few times
|
||||
// and you get an access violation
|
||||
//gfx_unloadpic(pic_name);
|
||||
};
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawchar =
|
||||
{
|
||||
float ret;
|
||||
|
||||
position = gfx_converttocon(position);
|
||||
scale = gfx_converttocon(scale);
|
||||
|
||||
if(scale == '0 0 0')
|
||||
return;
|
||||
|
||||
ret = drawcharacter(position, character, scale, rgb, alpha, flag);
|
||||
|
||||
if(ret == 1)
|
||||
return;
|
||||
if(ret == ERR_NULLSTRING)
|
||||
error("Null character !\n");
|
||||
if(ret == ERR_BADDRAWFLAG)
|
||||
error("Bad draw flag !\n");
|
||||
if(ret == ERR_BADSCALE)
|
||||
error("Bad scale !\n");
|
||||
error("Unknown error code !\n");
|
||||
};
|
||||
|
||||
void(vector position, string str, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawstring =
|
||||
{
|
||||
float ret;
|
||||
|
||||
position = gfx_converttocon(position);
|
||||
scale = gfx_converttocon(scale);
|
||||
|
||||
if(scale == '0 0 0')
|
||||
return;
|
||||
|
||||
ret = drawstring(position, str, scale, rgb, alpha, flag);
|
||||
|
||||
if(ret == 1)
|
||||
return;
|
||||
if(ret == ERR_NULLSTRING)
|
||||
error("Null string !\n");
|
||||
if(ret == ERR_BADDRAWFLAG)
|
||||
error("Bad draw flag !\n");
|
||||
if(ret == ERR_BADSCALE)
|
||||
error("Bad scale !\n");
|
||||
error("Unknown error code !\n");
|
||||
};
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_drawpic =
|
||||
{
|
||||
float ret;
|
||||
|
||||
if(size == '0 0 0')
|
||||
size = gfx_getimagesize(pic_name);
|
||||
|
||||
// for FrikQCC
|
||||
position = gfx_converttocon(position);
|
||||
size = gfx_converttocon(size);
|
||||
|
||||
ret = drawpic(position, pic_name, size, rgb, alpha, flag);
|
||||
|
||||
if(ret == 1)
|
||||
return;
|
||||
if(ret == ERR_NULLSTRING)
|
||||
error("Null string !\n");
|
||||
if(ret == ERR_BADDRAWFLAG)
|
||||
error("Bad draw flag !\n");
|
||||
if(ret == ERR_BADSIZE)
|
||||
error("Bad size !\n");
|
||||
if(ret == ERR_NOTCACHED)
|
||||
error("Picture ", pic_name, " was not precached !\n");
|
||||
error("Unknown error code !\n");
|
||||
};
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_fillarea =
|
||||
{
|
||||
float ret;
|
||||
|
||||
position = gfx_converttocon(position);
|
||||
size = gfx_converttocon(size);
|
||||
|
||||
if(size == '0 0 0')
|
||||
return;
|
||||
|
||||
ret = drawfill(position, size, rgb, alpha, flag);
|
||||
|
||||
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 =
|
||||
{
|
||||
position = gfx_converttocon(position);
|
||||
size = gfx_converttocon(size);
|
||||
drawsetcliparea(position_x, position_y, size_x, size_y);
|
||||
};
|
||||
|
||||
void(void) gfx_resetcliparea =
|
||||
{
|
||||
drawresetcliparea();
|
||||
};
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
menu_drawchar =
|
||||
{
|
||||
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 =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_drawstring(position, str, scale, rgb, alpha, flag);
|
||||
}
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
menu_drawpic =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_drawpic(position, pic_name, size, rgb, alpha, flag);
|
||||
};
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
menu_fillarea =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_fillarea(position, size, rgb, alpha, flag);
|
||||
};
|
||||
|
||||
|
||||
void(vector position, vector size) menu_setcliparea =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_setcliparea(position, size);
|
||||
};
|
||||
|
||||
|
||||
void(void) menu_resetcliparea =
|
||||
{
|
||||
gfx_resetcliparea();
|
||||
};
|
||||
|
||||
vector(string pic_name) gfx_getimagesize =
|
||||
{
|
||||
return drawgetimagesize(pic_name);
|
||||
}
|
||||
|
||||
vector(vector vec) gfx_converttogfx =
|
||||
{
|
||||
vector v;
|
||||
v_x = vec_x * (GFX_WIDTH / vid_conwidth);
|
||||
v_y = vec_y * (GFX_HEIGHT / vid_conheight);
|
||||
return v;
|
||||
};
|
||||
|
||||
vector(vector vec) gfx_converttocon =
|
||||
{
|
||||
vector v;
|
||||
v_x = vec_x * (vid_conwidth / GFX_WIDTH);
|
||||
v_y = vec_y * (vid_conheight / GFX_HEIGHT);
|
||||
return v;
|
||||
};
|
||||
|
||||
vector(vector vec) gfx_conmentogfx =
|
||||
{
|
||||
return (vec + menu_localorigin);
|
||||
};
|
||||
|
||||
vector(vector vec) gfx_congfxtomen =
|
||||
{
|
||||
return (vec - menu_localorigin);
|
||||
};
|
||||
///////////////////////////////////////////////
|
||||
// Graphic Source File
|
||||
///////////////////////
|
||||
// This file belongs to dpmod/darkplaces
|
||||
// AK contains all graphic functions
|
||||
///////////////////////////////////////////////
|
||||
|
||||
void(void) gfx_init =
|
||||
{
|
||||
vid_conwidth = cvar("width");
|
||||
vid_conheight = cvar("height");
|
||||
};
|
||||
|
||||
void(void) gfx_frame =
|
||||
{
|
||||
vid_conwidth = cvar("width");
|
||||
vid_conheight = cvar("height");
|
||||
};
|
||||
|
||||
void(void) gfx_toggle =
|
||||
{
|
||||
};
|
||||
|
||||
void(float keynr, float ascii) gfx_keydown =
|
||||
{
|
||||
};
|
||||
|
||||
void(void) gfx_draw =
|
||||
{
|
||||
};
|
||||
|
||||
void(void) gfx_shutdown =
|
||||
{
|
||||
};
|
||||
|
||||
string(string pic_name, float complain) gfx_loadpic =
|
||||
{
|
||||
string c;
|
||||
c = precache_pic(pic_name);
|
||||
|
||||
if(c == "" && complain)
|
||||
error("Couldnt precache ", pic_name, " !\n");
|
||||
if(c == "")
|
||||
dprint("Couldnt precache ", pic_name, " !\n");
|
||||
return c;
|
||||
};
|
||||
|
||||
void(string pic_name) gfx_unloadpic =
|
||||
{
|
||||
// FIXME: gfx_unloadpic is a bit buggy in dp at the moment - restart the menu a few times
|
||||
// and you get an access violation
|
||||
//gfx_unloadpic(pic_name);
|
||||
};
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawchar =
|
||||
{
|
||||
float ret;
|
||||
|
||||
position = gfx_converttocon(position);
|
||||
scale = gfx_converttocon(scale);
|
||||
|
||||
if(scale == '0 0 0')
|
||||
return;
|
||||
|
||||
ret = drawcharacter(position, character, scale, rgb, alpha, flag);
|
||||
|
||||
if(ret == 1)
|
||||
return;
|
||||
if(ret == ERR_NULLSTRING)
|
||||
error("Null character !\n");
|
||||
if(ret == ERR_BADDRAWFLAG)
|
||||
error("Bad draw flag !\n");
|
||||
if(ret == ERR_BADSCALE)
|
||||
error("Bad scale !\n");
|
||||
error("Unknown error code !\n");
|
||||
};
|
||||
|
||||
void(vector position, string str, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawstring =
|
||||
{
|
||||
float ret;
|
||||
|
||||
position = gfx_converttocon(position);
|
||||
scale = gfx_converttocon(scale);
|
||||
|
||||
if(scale == '0 0 0')
|
||||
return;
|
||||
|
||||
ret = drawstring(position, str, scale, rgb, alpha, flag);
|
||||
|
||||
if(ret == 1)
|
||||
return;
|
||||
if(ret == ERR_NULLSTRING)
|
||||
error("Null string !\n");
|
||||
if(ret == ERR_BADDRAWFLAG)
|
||||
error("Bad draw flag !\n");
|
||||
if(ret == ERR_BADSCALE)
|
||||
error("Bad scale !\n");
|
||||
error("Unknown error code !\n");
|
||||
};
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_drawpic =
|
||||
{
|
||||
float ret;
|
||||
|
||||
if(size == '0 0 0') size = gfx_getimagesize(pic_name);
|
||||
|
||||
ret = drawpic(position, pic_name, size, rgb, alpha );
|
||||
|
||||
if(ret == 1) return;
|
||||
if(ret == ERR_NULLSTRING)
|
||||
error("Null string !\n");
|
||||
if(ret == ERR_BADDRAWFLAG)
|
||||
error("Bad draw flag !\n");
|
||||
if(ret == ERR_BADSIZE)
|
||||
error("Bad size !\n");
|
||||
if(ret == ERR_NOTCACHED)
|
||||
error("Picture ", pic_name, " was not precached !\n");
|
||||
error("Unknown error code !\n");
|
||||
};
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_fillarea =
|
||||
{
|
||||
float ret;
|
||||
|
||||
position = gfx_converttocon(position);
|
||||
size = gfx_converttocon(size);
|
||||
|
||||
if(size == '0 0 0')
|
||||
return;
|
||||
|
||||
ret = drawfill(position, size, rgb, alpha, flag);
|
||||
|
||||
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 =
|
||||
{
|
||||
};
|
||||
|
||||
void(void) gfx_resetcliparea =
|
||||
{
|
||||
};
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
menu_drawchar =
|
||||
{
|
||||
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 =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_drawstring(position, str, scale, rgb, alpha, flag);
|
||||
}
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
menu_drawpic =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_drawpic(position, pic_name, size, rgb, alpha, flag);
|
||||
};
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
menu_fillarea =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_fillarea(position, size, rgb, alpha, flag);
|
||||
};
|
||||
|
||||
|
||||
void(vector position, vector size) menu_setcliparea =
|
||||
{
|
||||
position = gfx_conmentogfx(position);
|
||||
gfx_setcliparea(position, size);
|
||||
};
|
||||
|
||||
|
||||
void(void) menu_resetcliparea =
|
||||
{
|
||||
gfx_resetcliparea();
|
||||
};
|
||||
|
||||
vector(string pic_name) gfx_getimagesize =
|
||||
{
|
||||
return drawgetimagesize(pic_name);
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
vector(vector vec) gfx_converttocon =
|
||||
{
|
||||
vector v;
|
||||
v_x = vec_x * (vid_conwidth / SCR_WIDTH);
|
||||
v_y = vec_y * (vid_conheight / SCR_HEIGHT);
|
||||
return v;
|
||||
};
|
||||
|
||||
vector(vector vec) gfx_conmentogfx =
|
||||
{
|
||||
return (vec + menu_localorigin);
|
||||
};
|
||||
|
||||
vector(vector vec) gfx_congfxtomen =
|
||||
{
|
||||
return (vec - menu_localorigin);
|
||||
};
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
///////////////////////////////////////////////
|
||||
// Graphic Header File
|
||||
///////////////////////
|
||||
// This file belongs to dpmod/darkplaces
|
||||
// AK contains all gfx prototypes, etc.
|
||||
///////////////////////////////////////////////
|
||||
|
||||
const float GFX_WIDTH = 800;
|
||||
const float GFX_HEIGHT = 600;
|
||||
|
||||
float vid_conwidth;
|
||||
float vid_conheight;
|
||||
|
||||
////////////////
|
||||
// prototypes
|
||||
///
|
||||
|
||||
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(void) gfx_draw;
|
||||
void(void) gfx_shutdown;
|
||||
|
||||
// convert from menu coords to gfx coords
|
||||
vector(vector vec) gfx_conmentogfx;
|
||||
// convert from gfx coords to console coords
|
||||
vector(vector vec) gfx_converttocon;
|
||||
// convert from console coords to gfx coords
|
||||
vector(vector vec) gfx_converttogfx;
|
||||
// convert to menu coords
|
||||
vector(vector vec) gfx_congfxtomen;
|
||||
|
||||
string(string pic_name, float complain) gfx_loadpic;
|
||||
void(string pic_name) gfx_unloadpic;
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawchar;
|
||||
|
||||
void(vector position, string text, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawstring;
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_drawpic;
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_fillarea;
|
||||
|
||||
void(vector position, vector size) gfx_setcliparea;
|
||||
|
||||
void(void) gfx_resetcliparea;
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
menu_drawchar;
|
||||
|
||||
void(vector position, string text, vector scale, vector rgb, float alpha, float flag)
|
||||
menu_drawstring;
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
menu_drawpic;
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
menu_fillarea;
|
||||
|
||||
void(vector position, vector size) menu_setcliparea;
|
||||
|
||||
void(void) menu_resetcliparea;
|
||||
|
||||
vector(string pic_name) gfx_getimagesize;
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Graphic Header File
|
||||
///////////////////////
|
||||
// This file belongs to dpmod/darkplaces
|
||||
// AK contains all gfx prototypes, etc.
|
||||
///////////////////////////////////////////////
|
||||
|
||||
#define SCR_WIDTH 640.0
|
||||
#define SCR_HEIGHT 480.0
|
||||
|
||||
float vid_conwidth;
|
||||
float vid_conheight;
|
||||
|
||||
////////////////
|
||||
// prototypes
|
||||
///
|
||||
|
||||
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(void) gfx_draw;
|
||||
void(void) gfx_shutdown;
|
||||
|
||||
// convert from menu coords to gfx coords
|
||||
vector(vector vec) gfx_conmentogfx;
|
||||
// convert from gfx coords to console coords
|
||||
vector(vector vec) gfx_converttocon;
|
||||
// convert from console coords to gfx coords
|
||||
vector(vector vec) gfx_converttogfx;
|
||||
// convert to menu coords
|
||||
vector(vector vec) gfx_congfxtomen;
|
||||
|
||||
string(string pic_name, float complain) gfx_loadpic;
|
||||
void(string pic_name) gfx_unloadpic;
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawchar;
|
||||
|
||||
void(vector position, string text, vector scale, vector rgb, float alpha, float flag)
|
||||
gfx_drawstring;
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_drawpic;
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
gfx_fillarea;
|
||||
|
||||
void(vector position, vector size) gfx_setcliparea;
|
||||
|
||||
void(void) gfx_resetcliparea;
|
||||
|
||||
void(vector position, float character, vector scale, vector rgb, float alpha, float flag)
|
||||
menu_drawchar;
|
||||
|
||||
void(vector position, string text, vector scale, vector rgb, float alpha, float flag)
|
||||
menu_drawstring;
|
||||
|
||||
void(vector position, string pic_name, vector size, vector rgb, float alpha, float flag)
|
||||
menu_drawpic;
|
||||
|
||||
void(vector position, vector size, vector rgb, float alpha, float flag)
|
||||
menu_fillarea;
|
||||
|
||||
void(vector position, vector size) menu_setcliparea;
|
||||
|
||||
void(void) menu_resetcliparea;
|
||||
|
||||
vector(string pic_name) gfx_getimagesize;
|
||||
|
||||
|
|
|
@ -1,177 +1,177 @@
|
|||
//////////////////////////////////////////////////
|
||||
// common cmd
|
||||
//////////////////////////////////////////////////
|
||||
// AK FIXME: Create perhaps a special builtin file for the common cmds
|
||||
|
||||
void checkextension(string ext) = #1;
|
||||
|
||||
// error cmds
|
||||
void error(string err,...) = #2;
|
||||
void objerror(string err,...) = #3;
|
||||
|
||||
// print
|
||||
|
||||
void print(string text,...) = #4;
|
||||
void bprint(string text,...) = #5;
|
||||
void sprint(float clientnum, string text,...) = #6;
|
||||
void centerprint(string text,...) = #7;
|
||||
|
||||
// vector stuff
|
||||
|
||||
vector normalize(vector v) = #8;
|
||||
float vlen(vector v) = #9;
|
||||
float vectoyaw(vector v) = #10;
|
||||
vector vectoangles(vector v) = #11;
|
||||
|
||||
float random(void) = #12;
|
||||
|
||||
void cmd(string command) = #13;
|
||||
|
||||
// cvar cmds
|
||||
|
||||
float cvar(string name) = #14;
|
||||
const string str_cvar(string name) = #71;
|
||||
void cvar_set(string name, string value) = #15;
|
||||
|
||||
void dprint(string text,...) = #16;
|
||||
|
||||
// conversion functions
|
||||
|
||||
string ftos(float f) = #17;
|
||||
float fabs(float f) = #18;
|
||||
string vtos(vector v) = #19;
|
||||
string etos(entity e) = #20;
|
||||
|
||||
float stof(string val,...) = #21;
|
||||
|
||||
entity spawn(void) = #22;
|
||||
void remove(entity e) = #23;
|
||||
|
||||
entity findstring(entity start, .string field, string match) = #24;
|
||||
entity findfloat(entity start, .float field, float match) = #25;
|
||||
entity findentity(entity start, .entity field, entity match) = #25;
|
||||
|
||||
entity findchainstring(.string field, string match) = #26;
|
||||
entity findchainfloat(.float field, float match) = #27;
|
||||
entity findchainentity(.entity field, entity match) = #27;
|
||||
|
||||
string precache_file(string file) = #28;
|
||||
string precache_sound(string sample) = #29;
|
||||
|
||||
void crash(void) = #72;
|
||||
void coredump(void) = #30;
|
||||
void stackdump(void) = #73;
|
||||
void traceon(void) = #31;
|
||||
void traceoff(void) = #32;
|
||||
|
||||
void eprint(entity e) = #33;
|
||||
float rint(float f) = #34;
|
||||
float floor(float f) = #35;
|
||||
float ceil(float f) = #36;
|
||||
entity nextent(entity e) = #37;
|
||||
float sin(float f) = #38;
|
||||
float cos(float f) = #39;
|
||||
float sqrt(float f) = #40;
|
||||
vector randomvec(void) = #41;
|
||||
|
||||
float registercvar(string name, string value, float flags) = #42; // returns 1 if success
|
||||
|
||||
float min(float f,...) = #43;
|
||||
float max(float f,...) = #44;
|
||||
|
||||
float bound(float min,float value, float max) = #45;
|
||||
float pow(float a, float b) = #46;
|
||||
|
||||
void copyentity(entity src, entity dst) = #47;
|
||||
|
||||
float fopen(string filename, float mode) = #48;
|
||||
void fclose(float fhandle) = #49;
|
||||
string fgets(float fhandle) = #50;
|
||||
void fputs(float fhandle, string s) = #51;
|
||||
|
||||
float strlen(string s) = #52;
|
||||
string strcat(string s1,string s2,...) = #53;
|
||||
string substring(string s, float start, float length) = #54;
|
||||
|
||||
vector stov(string s) = #55;
|
||||
|
||||
string strzone(string s) = #56;
|
||||
void strunzone(string s) = #57;
|
||||
|
||||
float tokenize(string s) = #58
|
||||
string argv(float n) = #59;
|
||||
|
||||
float isserver(void) = #60;
|
||||
float clientcount(void) = #61;
|
||||
float clientstate(void) = #62;
|
||||
void clientcommand(float client, string s) = #63;
|
||||
void changelevel(string map) = #64;
|
||||
void localsound(string sample) = #65;
|
||||
vector getmousepos(void) = #66;
|
||||
float gettime(void) = #67;
|
||||
void loadfromdata(string data) = #68;
|
||||
void loadfromfile(string file) = #69;
|
||||
|
||||
float mod(float val, float m) = #70;
|
||||
|
||||
float search_begin(string pattern, float caseinsensitive, float quiet) = #74;
|
||||
void search_end(float handle) = #75;
|
||||
float search_getsize(float handle) = #76;
|
||||
string search_getfilename(float handle, float num) = #77;
|
||||
|
||||
string chr(float ascii) = #78;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Write* Functions
|
||||
/////////////////////////////////////////////////
|
||||
void WriteByte(float data, float dest, float desto) = #401;
|
||||
void WriteChar(float data, float dest, float desto) = #402;
|
||||
void WriteShort(float data, float dest, float desto) = #403;
|
||||
void WriteLong(float data, float dest, float desto) = #404;
|
||||
void WriteAngle(float data, float dest, float desto) = #405;
|
||||
void WriteCoord(float data, float dest, float desto) = #406;
|
||||
void WriteString(string data, float dest, float desto)= #407;
|
||||
void WriteEntity(entity data, float dest, float desto) = #408;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Draw funtions
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
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 drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;
|
||||
|
||||
float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456;
|
||||
|
||||
float drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457;
|
||||
|
||||
void drawsetcliparea(float x, float y, float width, float height) = #458;
|
||||
|
||||
void drawresetcliparea(void) = #459;
|
||||
|
||||
vector drawgetimagesize(string pic) = #460;
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Menu functions
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void setkeydest(float dest) = #601;
|
||||
float getkeydest(void) = #602;
|
||||
|
||||
void setmousetarget(float trg) = #603;
|
||||
float getmousetarget(void) = #604;
|
||||
|
||||
float isfunction(string function_name) = #607;
|
||||
void callfunction(...) = #605;
|
||||
void writetofile(float fhandle, entity ent) = #606;
|
||||
vector getresolution(float number) = #608;
|
||||
string keynumtostring(float keynum) = #609;
|
||||
string findkeysforcommand(string command) = #610;
|
||||
|
||||
float gethostcachevalue(float type) = #611;
|
||||
string gethostcachestring(float type, float hostnr) = #612;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// common cmd
|
||||
//////////////////////////////////////////////////
|
||||
// AK FIXME: Create perhaps a special builtin file for the common cmds
|
||||
|
||||
void checkextension(string ext) = #1;
|
||||
|
||||
// error cmds
|
||||
void error(string err,...) = #2;
|
||||
void objerror(string err,...) = #3;
|
||||
|
||||
// print
|
||||
|
||||
void print(string text,...) = #4;
|
||||
void bprint(string text,...) = #5;
|
||||
void sprint(float clientnum, string text,...) = #6;
|
||||
void centerprint(string text,...) = #7;
|
||||
|
||||
// vector stuff
|
||||
|
||||
vector normalize(vector v) = #8;
|
||||
float vlen(vector v) = #9;
|
||||
float vectoyaw(vector v) = #10;
|
||||
vector vectoangles(vector v) = #11;
|
||||
|
||||
float random(void) = #12;
|
||||
|
||||
void cmd(string command) = #13;
|
||||
|
||||
// cvar cmds
|
||||
|
||||
float cvar(string name) = #14;
|
||||
const string str_cvar(string name) = #71;
|
||||
void cvar_set(string name, string value) = #15;
|
||||
|
||||
void dprint(string text,...) = #16;
|
||||
|
||||
// conversion functions
|
||||
|
||||
string ftos(float f) = #17;
|
||||
float fabs(float f) = #18;
|
||||
string vtos(vector v) = #19;
|
||||
string etos(entity e) = #20;
|
||||
|
||||
float stof(string val,...) = #21;
|
||||
|
||||
entity spawn(void) = #22;
|
||||
void remove(entity e) = #23;
|
||||
|
||||
entity findstring(entity start, .string field, string match) = #24;
|
||||
entity findfloat(entity start, .float field, float match) = #25;
|
||||
entity findentity(entity start, .entity field, entity match) = #25;
|
||||
|
||||
entity findchainstring(.string field, string match) = #26;
|
||||
entity findchainfloat(.float field, float match) = #27;
|
||||
entity findchainentity(.entity field, entity match) = #27;
|
||||
|
||||
string precache_file(string file) = #28;
|
||||
string precache_sound(string sample) = #29;
|
||||
|
||||
void crash(void) = #72;
|
||||
void coredump(void) = #30;
|
||||
void stackdump(void) = #73;
|
||||
void traceon(void) = #31;
|
||||
void traceoff(void) = #32;
|
||||
|
||||
void eprint(entity e) = #33;
|
||||
float rint(float f) = #34;
|
||||
float floor(float f) = #35;
|
||||
float ceil(float f) = #36;
|
||||
entity nextent(entity e) = #37;
|
||||
float sin(float f) = #38;
|
||||
float cos(float f) = #39;
|
||||
float sqrt(float f) = #40;
|
||||
vector randomvec(void) = #41;
|
||||
|
||||
float registercvar(string name, string value, float flags) = #42; // returns 1 if success
|
||||
|
||||
float min(float f,...) = #43;
|
||||
float max(float f,...) = #44;
|
||||
|
||||
float bound(float min,float value, float max) = #45;
|
||||
float pow(float a, float b) = #46;
|
||||
|
||||
void copyentity(entity src, entity dst) = #47;
|
||||
|
||||
float fopen(string filename, float mode) = #48;
|
||||
void fclose(float fhandle) = #49;
|
||||
string fgets(float fhandle) = #50;
|
||||
void fputs(float fhandle, string s) = #51;
|
||||
|
||||
float strlen(string s) = #52;
|
||||
string strcat(string s1,string s2,...) = #53;
|
||||
string substring(string s, float start, float length) = #54;
|
||||
|
||||
vector stov(string s) = #55;
|
||||
|
||||
string strzone(string s) = #56;
|
||||
void strunzone(string s) = #57;
|
||||
|
||||
float tokenize(string s) = #58
|
||||
string argv(float n) = #59;
|
||||
|
||||
float isserver(void) = #60;
|
||||
float clientcount(void) = #61;
|
||||
float clientstate(void) = #62;
|
||||
void clientcommand(float client, string s) = #63;
|
||||
void changelevel(string map) = #64;
|
||||
void localsound(string sample) = #65;
|
||||
vector getmousepos(void) = #66;
|
||||
float gettime(void) = #67;
|
||||
void loadfromdata(string data) = #68;
|
||||
void loadfromfile(string file) = #69;
|
||||
|
||||
float mod(float val, float m) = #70;
|
||||
|
||||
float search_begin(string pattern, float caseinsensitive, float quiet) = #74;
|
||||
void search_end(float handle) = #75;
|
||||
float search_getsize(float handle) = #76;
|
||||
string search_getfilename(float handle, float num) = #77;
|
||||
|
||||
string chr(float ascii) = #78;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Write* Functions
|
||||
/////////////////////////////////////////////////
|
||||
void WriteByte(float data, float dest, float desto) = #401;
|
||||
void WriteChar(float data, float dest, float desto) = #402;
|
||||
void WriteShort(float data, float dest, float desto) = #403;
|
||||
void WriteLong(float data, float dest, float desto) = #404;
|
||||
void WriteAngle(float data, float dest, float desto) = #405;
|
||||
void WriteCoord(float data, float dest, float desto) = #406;
|
||||
void WriteString(string data, float dest, float desto)= #407;
|
||||
void WriteEntity(entity data, float dest, float desto) = #408;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Draw funtions
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
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 drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;
|
||||
|
||||
float drawpic(vector position, string pic, vector size, vector rgb, float alpha ) = #456;
|
||||
|
||||
float drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457;
|
||||
|
||||
void drawsetcliparea(float x, float y, float width, float height) = #458;
|
||||
|
||||
void drawresetcliparea(void) = #459;
|
||||
|
||||
vector drawgetimagesize(string pic) = #460;
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Menu functions
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void setkeydest(float dest) = #601;
|
||||
float getkeydest(void) = #602;
|
||||
|
||||
void setmousetarget(float trg) = #603;
|
||||
float getmousetarget(void) = #604;
|
||||
|
||||
float isfunction(string function_name) = #607;
|
||||
void callfunction(...) = #605;
|
||||
void writetofile(float fhandle, entity ent) = #606;
|
||||
vector getresolution(float number) = #608;
|
||||
string keynumtostring(float keynum) = #609;
|
||||
string findkeysforcommand(string command) = #610;
|
||||
|
||||
float gethostcachevalue(float type) = #611;
|
||||
string gethostcachestring(float type, float hostnr) = #612;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
void(void) ITEM_WINDOW =
|
||||
{
|
||||
self.flag = self.flag | FLAG_NOSELECT | FLAG_DRAWONLY;
|
||||
pev.flag = pev.flag | FLAG_NOSELECT | FLAG_DRAWONLY;
|
||||
|
||||
item_init(
|
||||
defct_reinit,
|
||||
|
@ -32,19 +32,19 @@ void(void) ITEM_WINDOW =
|
|||
|
||||
void(void) ITEM_REFERENCE =
|
||||
{
|
||||
self.flag = self.flag | FLAG_NOSELECT | FLAG_DRAWONLY;
|
||||
pev.flag = pev.flag | FLAG_NOSELECT | FLAG_DRAWONLY;
|
||||
|
||||
if(self.link == "")
|
||||
if(pev.link == "")
|
||||
{
|
||||
remove(self); // no need to call terminate
|
||||
remove(pev); // no need to call terminate
|
||||
return;
|
||||
}
|
||||
|
||||
self._child = menu_getitem(self.link);
|
||||
if(self._child == null_entity)
|
||||
pev._child = menu_getitem(pev.link);
|
||||
if(pev._child == null_entity)
|
||||
{
|
||||
print(self.name, " removed, cause link ", self.link, " not found\n");
|
||||
remove(self); // no need to call terminate
|
||||
print(pev.name, " removed, cause link ", pev.link, " not found\n");
|
||||
remove(pev); // no need to call terminate
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -78,35 +78,35 @@ void(void) ITEM_CUSTOM =
|
|||
// ITEM_PICTURE has a special draw function
|
||||
void(void) ITEM_PICTURE_DRAW =
|
||||
{
|
||||
menu_drawpic(self.pos, self.picture, self.size, self.color, self.alpha, self.drawflag);
|
||||
menu_drawpic(pev.pos, pev.picture, pev.size, pev.color, pev.alpha, pev.drawflag);
|
||||
|
||||
ctcall_draw();
|
||||
};
|
||||
|
||||
void(void) ITEM_PICTURE_DESTROY =
|
||||
{
|
||||
gfx_unloadpic(self.picture);
|
||||
gfx_unloadpic(pev.picture);
|
||||
|
||||
ctcall_destroy();
|
||||
};
|
||||
|
||||
void(void) ITEM_PICTURE =
|
||||
{
|
||||
if(self.picture == "")
|
||||
if(pev.picture == "")
|
||||
// a picture has to have a picture
|
||||
remove(self); // no need to call terminate
|
||||
remove(pev); // no need to call terminate
|
||||
|
||||
// load the picture if it isnt loaded already
|
||||
gfx_loadpic(self.picture, MENU_ENFORCELOADING);
|
||||
gfx_loadpic(pev.picture, MENU_ENFORCELOADING);
|
||||
|
||||
// if flag wasnt set yet, then set it to FLAG_DRAWONLY
|
||||
if(self.flag == 0)
|
||||
self.flag = FLAG_DRAWONLY;
|
||||
if(pev.flag == 0)
|
||||
pev.flag = FLAG_DRAWONLY;
|
||||
|
||||
if(self.color == '0 0 0')
|
||||
self.color = ITEM_PICTURE_NORMAL_COLOR;
|
||||
if(self.alpha == 0)
|
||||
self.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,
|
||||
|
@ -128,17 +128,17 @@ void(void) ITEM_PICTURE =
|
|||
void(void) ITEM_TEXT_REFRESH =
|
||||
{
|
||||
// first do own refresh, *then* call the default refresh !
|
||||
if(self.size == '0 0 0')
|
||||
if(pev.size == '0 0 0')
|
||||
{
|
||||
if(self.font_size == '0 0 0')
|
||||
self.font_size = ITEM_TEXT_FONT_SIZE;
|
||||
if(pev.font_size == '0 0 0')
|
||||
pev.font_size = ITEM_TEXT_FONT_SIZE;
|
||||
|
||||
self.size_x = self.font_size_x * strlen(self.text);
|
||||
self.size_y = self.font_size_y;
|
||||
} else if(self.font_size == '0 0 0')
|
||||
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')
|
||||
{
|
||||
self.font_size_x = self.size_x / strlen(self.text);
|
||||
self.font_size_y = self.size_y;
|
||||
pev.font_size_x = pev.size_x / strlen(pev.text);
|
||||
pev.font_size_y = pev.size_y;
|
||||
}
|
||||
|
||||
def_refresh();
|
||||
|
@ -147,41 +147,41 @@ void(void) ITEM_TEXT_REFRESH =
|
|||
|
||||
void(void) ITEM_TEXT_DRAW =
|
||||
{
|
||||
if(self.text)
|
||||
if(pev.text)
|
||||
{
|
||||
// align to the rect pos - (pos + size)
|
||||
vector alignpos;
|
||||
// now check the alignement
|
||||
if(self.alignment & TEXT_ALIGN_CENTER)
|
||||
alignpos_x = self.pos_x + (self.size_x - strlen(self.text) * self.font_size_x) / 2;
|
||||
else if(self.alignment & TEXT_ALIGN_RIGHT)
|
||||
alignpos_x = self.pos_x + self.size_x - strlen(self.text) * self.font_size_x;
|
||||
if(pev.alignment & TEXT_ALIGN_CENTER)
|
||||
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 = self.pos_x;
|
||||
alignpos_y = self.pos_y;
|
||||
alignpos_x = pev.pos_x;
|
||||
alignpos_y = pev.pos_y;
|
||||
|
||||
menu_drawstring(alignpos, self.text, self.font_size, self.color, self.alpha, self.drawflag);
|
||||
menu_drawstring(alignpos, pev.text, pev.font_size, pev.color, pev.alpha, pev.drawflag);
|
||||
}
|
||||
ctcall_draw();
|
||||
};
|
||||
|
||||
void(void) ITEM_TEXT =
|
||||
{
|
||||
if(self.flag == 0)
|
||||
self.flag = FLAG_DRAWONLY;
|
||||
if(pev.flag == 0)
|
||||
pev.flag = FLAG_DRAWONLY;
|
||||
|
||||
if(self.color == '0 0 0')
|
||||
self.color = ITEM_TEXT_NORMAL_COLOR;
|
||||
if(self.alpha == 0)
|
||||
self.alpha = ITEM_TEXT_NORMAL_ALPHA;
|
||||
if(pev.color == '0 0 0')
|
||||
pev.color = ITEM_TEXT_NORMAL_COLOR;
|
||||
if(pev.alpha == 0)
|
||||
pev.alpha = ITEM_TEXT_NORMAL_ALPHA;
|
||||
|
||||
ITEM_TEXT_REFRESH();
|
||||
if(self.alignment & TEXT_ALIGN_CENTERPOS)
|
||||
if(pev.alignment & TEXT_ALIGN_CENTERPOS)
|
||||
{
|
||||
self.pos_x = self.pos_x - self.size_x / 2;
|
||||
} else if(self.alignment & TEXT_ALIGN_LEFTPOS)
|
||||
pev.pos_x = pev.pos_x - pev.size_x / 2;
|
||||
} else if(pev.alignment & TEXT_ALIGN_LEFTPOS)
|
||||
{
|
||||
self.pos_x = self.pos_x - self.size_x;
|
||||
pev.pos_x = pev.pos_x - pev.size_x;
|
||||
}
|
||||
|
||||
item_init(
|
||||
|
@ -203,13 +203,13 @@ void(void) ITEM_TEXT =
|
|||
|
||||
void(void) ITEM_RECTANGLE_DRAW =
|
||||
{
|
||||
menu_fillarea(self.pos, self.size, self.color, self.alpha, self.drawflag);
|
||||
menu_fillarea(pev.pos, pev.size, pev.color, pev.alpha, pev.drawflag);
|
||||
};
|
||||
|
||||
void(void) ITEM_RECTANGLE =
|
||||
{
|
||||
if(self.flag == 0)
|
||||
self.flag = FLAG_DRAWONLY;
|
||||
if(pev.flag == 0)
|
||||
pev.flag = FLAG_DRAWONLY;
|
||||
|
||||
item_init(
|
||||
defct_reinit,
|
||||
|
@ -230,12 +230,12 @@ void(void) ITEM_RECTANGLE =
|
|||
|
||||
void(void) ITEM_BUTTON_DRAW =
|
||||
{
|
||||
if(self._button_state == BUTTON_NORMAL)
|
||||
menu_drawpic(self.pos, self.picture, self.size, self.color, self.alpha, self.drawflag);
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
menu_drawpic(self.pos, self.picture_selected, self.size, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
if(pev._button_state == BUTTON_NORMAL)
|
||||
menu_drawpic(pev.pos, pev.picture, pev.size, pev.color, pev.alpha, pev.drawflag);
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
menu_drawpic(pev.pos, pev.picture_selected, pev.size, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
else
|
||||
menu_drawpic(self.pos, self.picture_pressed, self.size, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_drawpic(pev.pos, pev.picture_pressed, pev.size, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
|
||||
ctcall_draw();
|
||||
};
|
||||
|
@ -243,15 +243,15 @@ void(void) ITEM_BUTTON_DRAW =
|
|||
void(void) ITEM_BUTTON_REFRESH =
|
||||
{
|
||||
|
||||
if((self.hold_pressed + self._press_time < time && self._button_state == BUTTON_PRESSED) || (menu_selected != self && self._button_state == BUTTON_SELECTED))
|
||||
if((pev.hold_pressed + pev._press_time < time && pev._button_state == BUTTON_PRESSED) || (menu_selected != pev && pev._button_state == BUTTON_SELECTED))
|
||||
{
|
||||
self._button_state = BUTTON_NORMAL;
|
||||
pev._button_state = BUTTON_NORMAL;
|
||||
}
|
||||
if(menu_selected == self && self._button_state == BUTTON_NORMAL)
|
||||
if(menu_selected == pev && pev._button_state == BUTTON_NORMAL)
|
||||
{
|
||||
self._button_state = BUTTON_SELECTED;
|
||||
if(self.sound_selected)
|
||||
snd_play(self.sound_selected);
|
||||
pev._button_state = BUTTON_SELECTED;
|
||||
if(pev.sound_selected)
|
||||
snd_play(pev.sound_selected);
|
||||
}
|
||||
def_refresh();
|
||||
ctcall_refresh();
|
||||
|
@ -264,76 +264,76 @@ void(float keynr, float ascii) ITEM_BUTTON_KEY =
|
|||
|
||||
if(keynr == K_ENTER || keynr == K_MOUSE1)
|
||||
{
|
||||
self._action();
|
||||
pev._action();
|
||||
} else
|
||||
def_keyevent(keynr, ascii);
|
||||
};
|
||||
|
||||
void(void) ITEM_BUTTON_ACTION =
|
||||
{
|
||||
self._press_time = time;
|
||||
self._button_state = BUTTON_PRESSED;
|
||||
if(self.sound_pressed)
|
||||
snd_play(self.sound_pressed);
|
||||
pev._press_time = time;
|
||||
pev._button_state = BUTTON_PRESSED;
|
||||
if(pev.sound_pressed)
|
||||
snd_play(pev.sound_pressed);
|
||||
|
||||
ctcall_action();
|
||||
};
|
||||
void(void) ITEM_BUTTON_REINIT =
|
||||
{
|
||||
self._button_state = BUTTON_NORMAL;
|
||||
pev._button_state = BUTTON_NORMAL;
|
||||
|
||||
ctcall_reinit();
|
||||
};
|
||||
|
||||
void(void) ITEM_BUTTON_DESTROY =
|
||||
{
|
||||
gfx_unloadpic(self.picture);
|
||||
gfx_unloadpic(self.picture_selected);
|
||||
gfx_unloadpic(self.picture_pressed);
|
||||
gfx_unloadpic(pev.picture);
|
||||
gfx_unloadpic(pev.picture_selected);
|
||||
gfx_unloadpic(pev.picture_pressed);
|
||||
|
||||
ctcall_destroy();
|
||||
};
|
||||
|
||||
void(void) ITEM_BUTTON =
|
||||
{
|
||||
if(self.picture == "" || self.picture_selected == "" || self.picture_pressed == "")
|
||||
if(pev.picture == "" || pev.picture_selected == "" || pev.picture_pressed == "")
|
||||
// a picture has to have pictures
|
||||
remove(self); // no need to call terminate
|
||||
remove(pev); // no need to call terminate
|
||||
|
||||
// load the picture if it isnt loaded already
|
||||
gfx_loadpic(self.picture, MENU_ENFORCELOADING);
|
||||
gfx_loadpic(self.picture_selected, MENU_ENFORCELOADING);
|
||||
gfx_loadpic(self.picture_pressed, MENU_ENFORCELOADING);
|
||||
gfx_loadpic(pev.picture, MENU_ENFORCELOADING);
|
||||
gfx_loadpic(pev.picture_selected, MENU_ENFORCELOADING);
|
||||
gfx_loadpic(pev.picture_pressed, MENU_ENFORCELOADING);
|
||||
|
||||
if(self.sound_selected != "")
|
||||
snd_loadsound(self.sound_selected, SOUND_ENFORCELOADING);
|
||||
if(pev.sound_selected != "")
|
||||
snd_loadsound(pev.sound_selected, SOUND_ENFORCELOADING);
|
||||
else
|
||||
self.sound_selected = SOUND_SELECT;
|
||||
pev.sound_selected = SOUND_SELECT;
|
||||
|
||||
if(self.sound_pressed != "")
|
||||
snd_loadsound(self.sound_pressed, SOUND_ENFORCELOADING);
|
||||
if(pev.sound_pressed != "")
|
||||
snd_loadsound(pev.sound_pressed, SOUND_ENFORCELOADING);
|
||||
else
|
||||
self.sound_pressed = SOUND_ACTION;
|
||||
pev.sound_pressed = SOUND_ACTION;
|
||||
|
||||
// if flag wasnt set yet, then set it to FLAG_DRAWONLY
|
||||
if(self.flag == 0)
|
||||
self.flag = FLAG_AUTOSETCLICK;
|
||||
if(pev.flag == 0)
|
||||
pev.flag = FLAG_AUTOSETCLICK;
|
||||
|
||||
if(self.color == '0 0 0')
|
||||
self.color = ITEM_PICTURE_NORMAL_COLOR;
|
||||
if(self.alpha == 0)
|
||||
self.alpha = ITEM_PICTURE_NORMAL_ALPHA;
|
||||
if(self.color_selected == '0 0 0')
|
||||
self.color_selected = ITEM_PICTURE_SELECTED_COLOR;
|
||||
if(self.alpha_selected == 0)
|
||||
self.alpha_selected = ITEM_PICTURE_SELECTED_ALPHA;
|
||||
if(self.color_pressed == '0 0 0')
|
||||
self.color_pressed = ITEM_PICTURE_PRESSED_COLOR;
|
||||
if(self.alpha_pressed == 0)
|
||||
self.alpha_pressed = ITEM_PICTURE_PRESSED_ALPHA;
|
||||
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_selected == '0 0 0')
|
||||
pev.color_selected = ITEM_PICTURE_SELECTED_COLOR;
|
||||
if(pev.alpha_selected == 0)
|
||||
pev.alpha_selected = ITEM_PICTURE_SELECTED_ALPHA;
|
||||
if(pev.color_pressed == '0 0 0')
|
||||
pev.color_pressed = ITEM_PICTURE_PRESSED_COLOR;
|
||||
if(pev.alpha_pressed == 0)
|
||||
pev.alpha_pressed = ITEM_PICTURE_PRESSED_ALPHA;
|
||||
|
||||
if(self.hold_pressed == 0)
|
||||
self.hold_pressed = ITEM_BUTTON_HOLD_PRESSED;
|
||||
if(pev.hold_pressed == 0)
|
||||
pev.hold_pressed = ITEM_BUTTON_HOLD_PRESSED;
|
||||
|
||||
item_init(
|
||||
ITEM_BUTTON_REINIT,
|
||||
|
@ -355,28 +355,28 @@ void(void) ITEM_BUTTON =
|
|||
void(void) ITEM_TEXTBUTTON_REFRESH =
|
||||
{
|
||||
// first do own refresh, *then* call the default refresh !
|
||||
if(self.size == '0 0 0')
|
||||
if(pev.size == '0 0 0')
|
||||
{
|
||||
if(self.font_size == '0 0 0')
|
||||
self.font_size = ITEM_TEXT_FONT_SIZE;
|
||||
if(pev.font_size == '0 0 0')
|
||||
pev.font_size = ITEM_TEXT_FONT_SIZE;
|
||||
|
||||
self.size_x = self.font_size_x * strlen(self.text);
|
||||
self.size_y = self.font_size_y;
|
||||
} else if(self.font_size == '0 0 0')
|
||||
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')
|
||||
{
|
||||
self.font_size_x = self.size_x / strlen(self.text);
|
||||
self.font_size_y = self.size_y;
|
||||
pev.font_size_x = pev.size_x / strlen(pev.text);
|
||||
pev.font_size_y = pev.size_y;
|
||||
}
|
||||
|
||||
if((self.hold_pressed + self._press_time < time && self._button_state == BUTTON_PRESSED) || (menu_selected != self && self._button_state == BUTTON_SELECTED))
|
||||
if((pev.hold_pressed + pev._press_time < time && pev._button_state == BUTTON_PRESSED) || (menu_selected != pev && pev._button_state == BUTTON_SELECTED))
|
||||
{
|
||||
self._button_state = BUTTON_NORMAL;
|
||||
pev._button_state = BUTTON_NORMAL;
|
||||
}
|
||||
if(menu_selected == self && self._button_state == BUTTON_NORMAL)
|
||||
if(menu_selected == pev && pev._button_state == BUTTON_NORMAL)
|
||||
{
|
||||
self._button_state = BUTTON_SELECTED;
|
||||
if(self.sound_selected)
|
||||
snd_play(self.sound_selected);
|
||||
pev._button_state = BUTTON_SELECTED;
|
||||
if(pev.sound_selected)
|
||||
snd_play(pev.sound_selected);
|
||||
}
|
||||
|
||||
def_refresh();
|
||||
|
@ -385,99 +385,99 @@ void(void) ITEM_TEXTBUTTON_REFRESH =
|
|||
|
||||
void(void) ITEM_TEXTBUTTON_DRAW =
|
||||
{
|
||||
if(self.text == "")
|
||||
if(pev.text == "")
|
||||
return;
|
||||
|
||||
// align to the rect pos - (pos + size)
|
||||
vector alignpos;
|
||||
// now check the alignement
|
||||
if(self.alignment & TEXT_ALIGN_CENTER)
|
||||
alignpos_x = self.pos_x + (self.size_x - strlen(self.text) * self.font_size_x) / 2;
|
||||
else if(self.alignment & TEXT_ALIGN_RIGHT)
|
||||
alignpos_x = self.pos_x + self.size_x - strlen(self.text) * self.font_size_x;
|
||||
if(pev.alignment & TEXT_ALIGN_CENTER)
|
||||
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 = self.pos_x;
|
||||
alignpos_y = self.pos_y;
|
||||
alignpos_x = pev.pos_x;
|
||||
alignpos_y = pev.pos_y;
|
||||
|
||||
if(self.style == TEXTBUTTON_STYLE_OUTLINE && self._button_state != BUTTON_NORMAL)
|
||||
if(pev.style == TEXTBUTTON_STYLE_OUTLINE && pev._button_state != BUTTON_NORMAL)
|
||||
{
|
||||
vector p,s;
|
||||
// left
|
||||
p_x = self.pos_x;
|
||||
p_y = self.pos_y;
|
||||
p_x = pev.pos_x;
|
||||
p_y = pev.pos_y;
|
||||
s_x = TEXTBUTTON_OUTLINE_WIDTH;
|
||||
s_y = self.size_y;
|
||||
if(self._button_state == BUTTON_PRESSED)
|
||||
s_y = pev.size_y;
|
||||
if(pev._button_state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
// right
|
||||
p_x = self.pos_x + self.size_x - TEXTBUTTON_OUTLINE_WIDTH;
|
||||
p_y = self.pos_y;
|
||||
p_x = pev.pos_x + pev.size_x - TEXTBUTTON_OUTLINE_WIDTH;
|
||||
p_y = pev.pos_y;
|
||||
s_x = TEXTBUTTON_OUTLINE_WIDTH;
|
||||
s_y = self.size_y;
|
||||
if(self._button_state == BUTTON_PRESSED)
|
||||
s_y = pev.size_y;
|
||||
if(pev._button_state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
// top
|
||||
p_x = self.pos_x;
|
||||
p_y = self.pos_y;
|
||||
p_x = pev.pos_x;
|
||||
p_y = pev.pos_y;
|
||||
s_y = TEXTBUTTON_OUTLINE_WIDTH;
|
||||
s_x = self.size_x;
|
||||
if(self._button_state == BUTTON_PRESSED)
|
||||
s_x = pev.size_x;
|
||||
if(pev._button_state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
// bottom
|
||||
p_x = self.pos_x;
|
||||
p_y = self.pos_y + self.size_y - TEXTBUTTON_OUTLINE_WIDTH;
|
||||
p_x = pev.pos_x;
|
||||
p_y = pev.pos_y + pev.size_y - TEXTBUTTON_OUTLINE_WIDTH;
|
||||
s_y = TEXTBUTTON_OUTLINE_WIDTH;
|
||||
s_x = self.size_x;
|
||||
if(self._button_state == BUTTON_PRESSED)
|
||||
s_x = pev.size_x;
|
||||
if(pev._button_state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
} else if(self.style == TEXTBUTTON_STYLE_BOX)
|
||||
} else if(pev.style == TEXTBUTTON_STYLE_BOX)
|
||||
{
|
||||
if(self._button_state == BUTTON_PRESSED)
|
||||
if(pev._button_state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(alignpos, self.size, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(alignpos, pev.size, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(alignpos, self.size, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(alignpos, pev.size, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
}
|
||||
|
||||
if(self._button_state == BUTTON_NORMAL || self.style == TEXTBUTTON_STYLE_BOX || self.style == TEXTBUTTON_STYLE_OUTLINE)
|
||||
menu_drawstring(alignpos, self.text, self.font_size, self.color, self.alpha, self.drawflag);
|
||||
if(pev._button_state == BUTTON_NORMAL || pev.style == TEXTBUTTON_STYLE_BOX || pev.style == TEXTBUTTON_STYLE_OUTLINE)
|
||||
menu_drawstring(alignpos, pev.text, pev.font_size, pev.color, pev.alpha, pev.drawflag);
|
||||
|
||||
if(self.style == TEXTBUTTON_STYLE_TEXT)
|
||||
if(pev.style == TEXTBUTTON_STYLE_TEXT)
|
||||
{
|
||||
if(self._button_state == BUTTON_PRESSED)
|
||||
if(pev._button_state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_drawstring(alignpos, self.text, self.font_size, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_drawstring(alignpos, pev.text, pev.font_size, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_drawstring(alignpos, self.text, self.font_size, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_drawstring(alignpos, pev.text, pev.font_size, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,10 +486,10 @@ void(void) ITEM_TEXTBUTTON_DRAW =
|
|||
|
||||
void(void) ITEM_TEXTBUTTON_ACTION =
|
||||
{
|
||||
self._press_time = time;
|
||||
self._button_state = BUTTON_PRESSED;
|
||||
if(self.sound_pressed)
|
||||
snd_play(self.sound_pressed);
|
||||
pev._press_time = time;
|
||||
pev._button_state = BUTTON_PRESSED;
|
||||
if(pev.sound_pressed)
|
||||
snd_play(pev.sound_pressed);
|
||||
|
||||
ctcall_action();
|
||||
};
|
||||
|
@ -501,56 +501,56 @@ void(float keynr, float ascii) ITEM_TEXTBUTTON_KEY =
|
|||
|
||||
if(keynr == K_ENTER || keynr == K_MOUSE1)
|
||||
{
|
||||
self._action();
|
||||
pev._action();
|
||||
} else
|
||||
def_keyevent(keynr, ascii);
|
||||
};
|
||||
|
||||
void(void) ITEM_TEXTBUTTON_REINIT =
|
||||
{
|
||||
self._button_state = BUTTON_NORMAL;
|
||||
pev._button_state = BUTTON_NORMAL;
|
||||
|
||||
ctcall_reinit();
|
||||
};
|
||||
|
||||
void(void) ITEM_TEXTBUTTON =
|
||||
{
|
||||
if(self.flag == 0)
|
||||
self.flag = FLAG_AUTOSETCLICK;
|
||||
if(pev.flag == 0)
|
||||
pev.flag = FLAG_AUTOSETCLICK;
|
||||
|
||||
if(self.color == '0 0 0')
|
||||
self.color = ITEM_TEXT_NORMAL_COLOR;
|
||||
if(self.alpha == 0)
|
||||
self.alpha = ITEM_TEXT_NORMAL_ALPHA;
|
||||
if(self.color_selected == '0 0 0')
|
||||
self.color_selected = ITEM_TEXT_SELECTED_COLOR;
|
||||
if(self.alpha_selected == 0)
|
||||
self.alpha_selected = ITEM_TEXT_SELECTED_ALPHA;
|
||||
if(self.color_pressed == '0 0 0')
|
||||
self.color_pressed = ITEM_TEXT_PRESSED_COLOR;
|
||||
if(self.alpha_pressed == 0)
|
||||
self.alpha_pressed = ITEM_TEXT_PRESSED_ALPHA;
|
||||
if(pev.color == '0 0 0')
|
||||
pev.color = ITEM_TEXT_NORMAL_COLOR;
|
||||
if(pev.alpha == 0)
|
||||
pev.alpha = ITEM_TEXT_NORMAL_ALPHA;
|
||||
if(pev.color_selected == '0 0 0')
|
||||
pev.color_selected = ITEM_TEXT_SELECTED_COLOR;
|
||||
if(pev.alpha_selected == 0)
|
||||
pev.alpha_selected = ITEM_TEXT_SELECTED_ALPHA;
|
||||
if(pev.color_pressed == '0 0 0')
|
||||
pev.color_pressed = ITEM_TEXT_PRESSED_COLOR;
|
||||
if(pev.alpha_pressed == 0)
|
||||
pev.alpha_pressed = ITEM_TEXT_PRESSED_ALPHA;
|
||||
|
||||
if(self.hold_pressed == 0)
|
||||
self.hold_pressed = ITEM_BUTTON_HOLD_PRESSED;
|
||||
if(pev.hold_pressed == 0)
|
||||
pev.hold_pressed = ITEM_BUTTON_HOLD_PRESSED;
|
||||
|
||||
if(self.sound_selected != "")
|
||||
snd_loadsound(self.sound_selected, SOUND_ENFORCELOADING);
|
||||
if(pev.sound_selected != "")
|
||||
snd_loadsound(pev.sound_selected, SOUND_ENFORCELOADING);
|
||||
else
|
||||
self.sound_selected = SOUND_SELECT;
|
||||
pev.sound_selected = SOUND_SELECT;
|
||||
|
||||
if(self.sound_pressed != "")
|
||||
snd_loadsound(self.sound_pressed, SOUND_ENFORCELOADING);
|
||||
if(pev.sound_pressed != "")
|
||||
snd_loadsound(pev.sound_pressed, SOUND_ENFORCELOADING);
|
||||
else
|
||||
self.sound_pressed = SOUND_ACTION;
|
||||
pev.sound_pressed = SOUND_ACTION;
|
||||
|
||||
ITEM_TEXTBUTTON_REFRESH();
|
||||
if(self.alignment & TEXT_ALIGN_CENTERPOS)
|
||||
if(pev.alignment & TEXT_ALIGN_CENTERPOS)
|
||||
{
|
||||
self.pos_x = self.pos_x - self.size_x / 2;
|
||||
} else if(self.alignment & TEXT_ALIGN_LEFTPOS)
|
||||
pev.pos_x = pev.pos_x - pev.size_x / 2;
|
||||
} else if(pev.alignment & TEXT_ALIGN_LEFTPOS)
|
||||
{
|
||||
self.pos_x = self.pos_x - self.size_x;
|
||||
pev.pos_x = pev.pos_x - pev.size_x;
|
||||
}
|
||||
|
||||
item_init(
|
||||
|
@ -573,33 +573,33 @@ void(void) ITEM_SLIDER_DRAW =
|
|||
vector slider_pos;
|
||||
|
||||
// draw the bar
|
||||
if(self.picture_bar != "")
|
||||
if(pev.picture_bar != "")
|
||||
{
|
||||
menu_drawpic(self.pos, self.picture_bar, self.size, self.color, self.alpha, self.drawflag);
|
||||
menu_drawpic(pev.pos, pev.picture_bar, pev.size, pev.color, pev.alpha, pev.drawflag);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_fillarea(self.pos, self.size, self.color, self.alpha, self.drawflag);
|
||||
menu_fillarea(pev.pos, pev.size, pev.color, pev.alpha, pev.drawflag);
|
||||
}
|
||||
|
||||
// draw the slider
|
||||
slider_pos = self.pos;
|
||||
slider_pos_x = slider_pos_x + ((self.size_x - self.slider_size_x) / (self.max_value - self.min_value)) * (self.value - self.min_value);
|
||||
if(self.picture != "")
|
||||
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, self.picture, self.slider_size, self.color, self.alpha, self.drawflag);
|
||||
menu_drawpic(slider_pos, pev.picture, pev.slider_size, pev.color, pev.alpha, pev.drawflag);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_fillarea(slider_pos, self.slider_size, self.color + ITEM_SLIDER_BAR_COLOR_DELTA, self.alpha, self.drawflag);
|
||||
menu_fillarea(slider_pos, pev.slider_size, pev.color + ITEM_SLIDER_BAR_COLOR_DELTA, pev.alpha, pev.drawflag);
|
||||
}
|
||||
};
|
||||
|
||||
void(void) ITEM_SLIDER_UPDATESLIDER =
|
||||
{
|
||||
self.value = bound(self.min_value, self.value, self.max_value);
|
||||
if(self.slidermove)
|
||||
self.slidermove();
|
||||
pev.value = bound(pev.min_value, pev.value, pev.max_value);
|
||||
if(pev.slidermove)
|
||||
pev.slidermove();
|
||||
};
|
||||
|
||||
void(float keynr, float ascii) ITEM_SLIDER_KEY =
|
||||
|
@ -609,19 +609,19 @@ void(float keynr, float ascii) ITEM_SLIDER_KEY =
|
|||
|
||||
if(keynr == K_LEFTARROW)
|
||||
{
|
||||
self.value = (rint(self.value / self.step) - 1) * self.step;
|
||||
pev.value = (rint(pev.value / pev.step) - 1) * pev.step;
|
||||
ITEM_SLIDER_UPDATESLIDER();
|
||||
}
|
||||
else if(keynr == K_RIGHTARROW)
|
||||
{
|
||||
self.value = (rint(self.value / self.step) + 1)* self.step;
|
||||
pev.value = (rint(pev.value / pev.step) + 1)* pev.step;
|
||||
ITEM_SLIDER_UPDATESLIDER();
|
||||
}
|
||||
else if(keynr == K_MOUSE1)
|
||||
{
|
||||
if(inrect(menu_cursor, self.pos, self.size))
|
||||
if(inrect(menu_cursor, pev.pos, pev.size))
|
||||
{
|
||||
self.value = self.min_value + ((menu_cursor_x - self.slider_size_x / 2) - self.pos_x) * ((self.max_value - self.min_value) / (self.size_x - self.slider_size_x));
|
||||
pev.value = pev.min_value + ((menu_cursor_x - pev.slider_size_x / 2) - pev.pos_x) * ((pev.max_value - pev.min_value) / (pev.size_x - pev.slider_size_x));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -630,41 +630,41 @@ void(float keynr, float ascii) ITEM_SLIDER_KEY =
|
|||
return;
|
||||
}
|
||||
// play sound
|
||||
snd_play(self.sound_changed);
|
||||
snd_play(pev.sound_changed);
|
||||
ITEM_SLIDER_UPDATESLIDER();
|
||||
};
|
||||
|
||||
void(void) ITEM_SLIDER_DESTROY =
|
||||
{
|
||||
if(self.picture != "")
|
||||
gfx_unloadpic(self.picture);
|
||||
if(self.picture_bar != "")
|
||||
gfx_unloadpic(self.picture);
|
||||
if(pev.picture != "")
|
||||
gfx_unloadpic(pev.picture);
|
||||
if(pev.picture_bar != "")
|
||||
gfx_unloadpic(pev.picture);
|
||||
|
||||
ctcall_destroy();
|
||||
};
|
||||
|
||||
void(void) ITEM_SLIDER =
|
||||
{
|
||||
if(self.picture != "")
|
||||
self.picture = gfx_loadpic(self.picture, MENU_ENFORCELOADING);
|
||||
if(self.picture_bar != "")
|
||||
self.picture_bar = gfx_loadpic(self.picture_bar, MENU_ENFORCELOADING);
|
||||
if(self.sound_changed == "")
|
||||
self.sound_changed = SOUND_CHANGE;
|
||||
if(pev.picture != "")
|
||||
pev.picture = gfx_loadpic(pev.picture, MENU_ENFORCELOADING);
|
||||
if(pev.picture_bar != "")
|
||||
pev.picture_bar = gfx_loadpic(pev.picture_bar, MENU_ENFORCELOADING);
|
||||
if(pev.sound_changed == "")
|
||||
pev.sound_changed = SOUND_CHANGE;
|
||||
|
||||
if(self.color == '0 0 0')
|
||||
self.color = ITEM_SLIDER_COLOR;
|
||||
if(self.alpha == 0)
|
||||
self.alpha = ITEM_SLIDER_ALPHA;
|
||||
if(self.step == 0)
|
||||
self.step = ITEM_SLIDER_STEP;
|
||||
if(self.slider_size == '0 0 0')
|
||||
if(pev.color == '0 0 0')
|
||||
pev.color = ITEM_SLIDER_COLOR;
|
||||
if(pev.alpha == 0)
|
||||
pev.alpha = ITEM_SLIDER_ALPHA;
|
||||
if(pev.step == 0)
|
||||
pev.step = ITEM_SLIDER_STEP;
|
||||
if(pev.slider_size == '0 0 0')
|
||||
{
|
||||
if(self.picture != "")
|
||||
self.slider_size = gfx_getimagesize(self.picture);
|
||||
if(pev.picture != "")
|
||||
pev.slider_size = gfx_getimagesize(pev.picture);
|
||||
else
|
||||
self.slider_size = ITEM_SLIDER_SIZE;
|
||||
pev.slider_size = ITEM_SLIDER_SIZE;
|
||||
}
|
||||
|
||||
item_init(
|
||||
|
@ -687,23 +687,23 @@ void(void) ITEM_TEXTSWITCH_DRAW =
|
|||
string temp;
|
||||
|
||||
// get the current text
|
||||
temp = self.text;
|
||||
self.text = getaltstring(self.value, self.text);
|
||||
temp = pev.text;
|
||||
pev.text = getaltstring(pev.value, pev.text);
|
||||
// call ITEM_TEXT
|
||||
ITEM_TEXT_DRAW();
|
||||
self.text = temp;
|
||||
pev.text = temp;
|
||||
};
|
||||
|
||||
void(void) ITEM_TEXTSWITCH_REFRESH =
|
||||
{
|
||||
string temp;
|
||||
|
||||
temp = self.text;
|
||||
self.text = getaltstring(self.value, self.text);
|
||||
temp = pev.text;
|
||||
pev.text = getaltstring(pev.value, pev.text);
|
||||
|
||||
ITEM_TEXT_REFRESH();
|
||||
|
||||
self.text = temp;
|
||||
pev.text = temp;
|
||||
};
|
||||
|
||||
void(float keynr, float ascii) ITEM_TEXTSWITCH_KEY =
|
||||
|
@ -713,38 +713,38 @@ void(float keynr, float ascii) ITEM_TEXTSWITCH_KEY =
|
|||
|
||||
if(keynr == K_LEFTARROW || keynr == K_MOUSE2)
|
||||
{
|
||||
self.value = self.value - 1;
|
||||
if(self.value < 0)
|
||||
self.value = getaltstringcount(self.text) - 1;
|
||||
pev.value = pev.value - 1;
|
||||
if(pev.value < 0)
|
||||
pev.value = getaltstringcount(pev.text) - 1;
|
||||
}
|
||||
else if(keynr == K_RIGHTARROW || keynr == K_MOUSE1 || keynr == K_ENTER)
|
||||
{
|
||||
self.value = self.value + 1;
|
||||
if(self.value > getaltstringcount(self.text) - 1)
|
||||
self.value = 0;
|
||||
pev.value = pev.value + 1;
|
||||
if(pev.value > getaltstringcount(pev.text) - 1)
|
||||
pev.value = 0;
|
||||
} else
|
||||
{
|
||||
def_keyevent(keynr, ascii);
|
||||
return;
|
||||
}
|
||||
snd_play(self.sound_changed);
|
||||
if(self.switchchange)
|
||||
self.switchchange();
|
||||
snd_play(pev.sound_changed);
|
||||
if(pev.switchchange)
|
||||
pev.switchchange();
|
||||
};
|
||||
|
||||
void(void) ITEM_TEXTSWITCH =
|
||||
{
|
||||
string temp;
|
||||
|
||||
if(self.sound_changed != "")
|
||||
snd_loadsound(self.sound_changed, SOUND_ENFORCELOADING);
|
||||
if(pev.sound_changed != "")
|
||||
snd_loadsound(pev.sound_changed, SOUND_ENFORCELOADING);
|
||||
else
|
||||
self.sound_changed = SOUND_CHANGE;
|
||||
pev.sound_changed = SOUND_CHANGE;
|
||||
|
||||
temp = self.text;
|
||||
self.text = getaltstring(self.value, self.text);
|
||||
temp = pev.text;
|
||||
pev.text = getaltstring(pev.value, pev.text);
|
||||
ITEM_TEXT();
|
||||
self.text = temp;
|
||||
pev.text = temp;
|
||||
|
||||
item_init(
|
||||
defct_reinit,
|
||||
|
@ -778,9 +778,9 @@ void(string text, vector pos, vector size, float alignment, float style, float s
|
|||
|
||||
// now check the alignement
|
||||
if(alignment & TEXT_ALIGN_CENTER)
|
||||
alignpos_x = pos_x + (size_x - strlen(text) * self.font_size_x) / 2;
|
||||
alignpos_x = pos_x + (size_x - strlen(text) * pev.font_size_x) / 2;
|
||||
else if(alignment & TEXT_ALIGN_RIGHT)
|
||||
alignpos_x = pos_x + size_x - strlen(text) * self.font_size_x;
|
||||
alignpos_x = pos_x + size_x - strlen(text) * pev.font_size_x;
|
||||
else
|
||||
alignpos_x = pos_x;
|
||||
alignpos_y = pos_y;
|
||||
|
@ -795,11 +795,11 @@ void(string text, vector pos, vector size, float alignment, float style, float s
|
|||
s_y = size_y;
|
||||
if(state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
// right
|
||||
p_x = pos_x + size_x - TEXTBUTTON_OUTLINE_WIDTH;
|
||||
|
@ -808,11 +808,11 @@ void(string text, vector pos, vector size, float alignment, float style, float s
|
|||
s_y = size_y;
|
||||
if(state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
// top
|
||||
p_x = pos_x;
|
||||
|
@ -821,11 +821,11 @@ void(string text, vector pos, vector size, float alignment, float style, float s
|
|||
s_x = size_x;
|
||||
if(state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
// bottom
|
||||
p_x = pos_x;
|
||||
|
@ -834,36 +834,36 @@ void(string text, vector pos, vector size, float alignment, float style, float s
|
|||
s_x = size_x;
|
||||
if(state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(p, s, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(p, s, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(p, s, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
} else if(style == TEXTBUTTON_STYLE_BOX)
|
||||
{
|
||||
if(state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_fillarea(alignpos, size, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_fillarea(alignpos, size, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(self._button_state == BUTTON_SELECTED)
|
||||
else if(pev._button_state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_fillarea(alignpos, size, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_fillarea(alignpos, size, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
}
|
||||
|
||||
if(state == BUTTON_NORMAL || style == TEXTBUTTON_STYLE_BOX || style == TEXTBUTTON_STYLE_OUTLINE)
|
||||
menu_drawstring(alignpos, text, self.font_size, self.color, self.alpha, self.drawflag);
|
||||
menu_drawstring(alignpos, text, pev.font_size, pev.color, pev.alpha, pev.drawflag);
|
||||
|
||||
if(style == TEXTBUTTON_STYLE_TEXT)
|
||||
{
|
||||
if(state == BUTTON_PRESSED)
|
||||
{
|
||||
menu_drawstring(alignpos, text, self.font_size, self.color_pressed, self.alpha_pressed, self.drawflag_pressed);
|
||||
menu_drawstring(alignpos, text, pev.font_size, pev.color_pressed, pev.alpha_pressed, pev.drawflag_pressed);
|
||||
}
|
||||
else if(state == BUTTON_SELECTED)
|
||||
{
|
||||
menu_drawstring(alignpos, text, self.font_size, self.color_selected, self.alpha_selected, self.drawflag_selected);
|
||||
menu_drawstring(alignpos, text, pev.font_size, pev.color_selected, pev.alpha_selected, pev.drawflag_selected);
|
||||
}
|
||||
}
|
||||
};*/
|
||||
|
|
|
@ -13,41 +13,41 @@
|
|||
void(void) dpmod_slidertext =
|
||||
{
|
||||
entity ent;
|
||||
if(self.link == "")
|
||||
if(pev.link == "")
|
||||
{
|
||||
print("No link specified\n");
|
||||
eprint(self);
|
||||
self.init = null_function;
|
||||
eprint(pev);
|
||||
pev.init = null_function;
|
||||
return;
|
||||
}
|
||||
|
||||
ent = menu_getitem(self.link);
|
||||
ent = menu_getitem(pev.link);
|
||||
if(ent == null_entity)
|
||||
{
|
||||
objerror("No link found for ", self.link,"\n");
|
||||
objerror("No link found for ", pev.link,"\n");
|
||||
}
|
||||
|
||||
self._link = ent;
|
||||
pev._link = ent;
|
||||
|
||||
self.flag = self.flag | FLAG_DRAWREFRESHONLY;
|
||||
pev.flag = pev.flag | FLAG_DRAWREFRESHONLY;
|
||||
|
||||
self.refresh = _dpmod_slidertext_refresh;
|
||||
pev.refresh = _dpmod_slidertext_refresh;
|
||||
};
|
||||
|
||||
void(void) _dpmod_slidertext_refresh =
|
||||
{
|
||||
self.text = ftos(self._link.value);
|
||||
if(self.maxlen > 0)
|
||||
self.text = substring(self.text,0, self.maxlen);
|
||||
pev.text = ftos(pev._link.value);
|
||||
if(pev.maxlen > 0)
|
||||
pev.text = substring(pev.text,0, pev.maxlen);
|
||||
// reset the size, so its set
|
||||
self.size = '0 0 0';
|
||||
pev.size = '0 0 0';
|
||||
};
|
||||
|
||||
float(float keynr, float ascii) dpmod_redirect_key =
|
||||
{
|
||||
if(keynr == K_ENTER || keynr == K_LEFTARROW || keynr == K_RIGHTARROW || (keynr >= K_MOUSE1 && keynr <= K_MOUSE10))
|
||||
{
|
||||
raise_key(self._child, keynr, ascii);
|
||||
raise_key(pev._child, keynr, ascii);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -55,32 +55,32 @@ float(float keynr, float ascii) dpmod_redirect_key =
|
|||
|
||||
void(void) dpmod_cvar_slider =
|
||||
{
|
||||
self.value = cvar(self.cvarname);
|
||||
self.slidermove = self.switchchange = _dpmod_cvar_slider;
|
||||
self.refresh = _dpmod_cvar_slider_refresh;
|
||||
pev.value = cvar(pev.cvarname);
|
||||
pev.slidermove = pev.switchchange = _dpmod_cvar_slider;
|
||||
pev.refresh = _dpmod_cvar_slider_refresh;
|
||||
};
|
||||
|
||||
void(void) _dpmod_cvar_slider_refresh =
|
||||
{
|
||||
if(self.cvartype == CVAR_INT || self.cvartype == CVAR_FLOAT || self.cvartype == CVAR_STEP)
|
||||
self.value = cvar(self.cvarname);
|
||||
if(pev.cvartype == CVAR_INT || pev.cvartype == CVAR_FLOAT || pev.cvartype == CVAR_STEP)
|
||||
pev.value = cvar(pev.cvarname);
|
||||
};
|
||||
|
||||
void(void) _dpmod_cvar_slider =
|
||||
{
|
||||
if(self.cvarname == "")
|
||||
if(pev.cvarname == "")
|
||||
return;
|
||||
if(self.cvartype == CVAR_INT) // || self.cvartype == CVAR_STRING)
|
||||
self.value = rint(self.value);
|
||||
if(self.cvartype == CVAR_STEP)
|
||||
self.value = rint(self.value / self.step) * self.step;
|
||||
if(self.cvartype == CVAR_INT || self.cvartype == CVAR_FLOAT || self.cvartype == CVAR_STEP)
|
||||
cvar_set(self.cvarname, ftos(self.value));
|
||||
if(pev.cvartype == CVAR_INT) // || pev.cvartype == CVAR_STRING)
|
||||
pev.value = rint(pev.value);
|
||||
if(pev.cvartype == CVAR_STEP)
|
||||
pev.value = rint(pev.value / pev.step) * pev.step;
|
||||
if(pev.cvartype == CVAR_INT || pev.cvartype == CVAR_FLOAT || pev.cvartype == CVAR_STEP)
|
||||
cvar_set(pev.cvarname, ftos(pev.value));
|
||||
/*if(cvartype == CVAR_STRING)
|
||||
{
|
||||
string s;
|
||||
s = getaltstring(self.value, self.cvarvalues);
|
||||
cvar_set(self.cvarname, s);
|
||||
s = getaltstring(pev.value, pev.cvarvalues);
|
||||
cvar_set(pev.cvarname, s);
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
@ -214,7 +214,7 @@ float(float keynr, float ascii) dpmod_quit_key =
|
|||
|
||||
void(void) dpmod_options_alwaysrun_switchchange =
|
||||
{
|
||||
if(self.value)
|
||||
if(pev.value)
|
||||
{
|
||||
cvar_set("cl_forwardspeed","400");
|
||||
cvar_set("cl_backspeed","400");
|
||||
|
@ -229,9 +229,9 @@ void(void) dpmod_options_alwaysrun_switchchange =
|
|||
void(void) dpmod_options_alwaysrun_refresh =
|
||||
{
|
||||
if(cvar("cl_forwardspeed") > 200)
|
||||
self.value = 1;
|
||||
pev.value = 1;
|
||||
else
|
||||
self.value = 0;
|
||||
pev.value = 0;
|
||||
};
|
||||
|
||||
void(void) dpmod_options_invmouse_switchchange =
|
||||
|
@ -244,9 +244,9 @@ void(void) dpmod_options_invmouse_switchchange =
|
|||
void(void) dpmod_options_invmouse_refresh =
|
||||
{
|
||||
if(cvar("m_pitch") > 0)
|
||||
self.value = 0;
|
||||
pev.value = 0;
|
||||
else
|
||||
self.value = 1;
|
||||
pev.value = 1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
@ -254,12 +254,12 @@ void(void) dpmod_options_invmouse_refresh =
|
|||
///
|
||||
void(void) initbrightness =
|
||||
{
|
||||
self.value = cvar("scr_conbrightness");
|
||||
pev.value = cvar("scr_conbrightness");
|
||||
};
|
||||
|
||||
void(void) setbrightness =
|
||||
{
|
||||
cvar_set("scr_conbrightness",ftos(self.value));
|
||||
cvar_set("scr_conbrightness",ftos(pev.value));
|
||||
};
|
||||
|
||||
void(void) dpmod_main_exit =
|
||||
|
|
267
pr_uimenu/menu.c
267
pr_uimenu/menu.c
|
@ -1,134 +1,135 @@
|
|||
///////////////////////////////////////////////
|
||||
// Menu Source File
|
||||
///////////////////////
|
||||
// This file belongs to dpmod/darkplaces
|
||||
// AK contains all menu functions (especially the required ones)
|
||||
///////////////////////////////////////////////
|
||||
|
||||
void(void) m_init =
|
||||
{
|
||||
// init graphic
|
||||
gfx_init();
|
||||
|
||||
// init sound
|
||||
snd_init();
|
||||
|
||||
// init cursor
|
||||
cursor_init();
|
||||
|
||||
// init menu
|
||||
menu_init();
|
||||
|
||||
// init editor
|
||||
//editor_init();
|
||||
};
|
||||
|
||||
// required menu functions
|
||||
void(float keynr, float ascii) m_keydown =
|
||||
{
|
||||
if(!menu_active)
|
||||
return;
|
||||
|
||||
// let also the gfx and sound know
|
||||
gfx_keydown(keynr, ascii);
|
||||
snd_keydown(keynr, ascii);
|
||||
|
||||
// actually only the menu may react on keydown messages
|
||||
menu_keydown(keynr, ascii);
|
||||
|
||||
// let the editor also know
|
||||
//editor_keydown(keynr, ascii);
|
||||
};
|
||||
|
||||
void(void) m_frame =
|
||||
{
|
||||
// graphic frame
|
||||
gfx_frame();
|
||||
|
||||
// sound frame
|
||||
snd_frame();
|
||||
|
||||
// cursor frame
|
||||
cursor_frame();
|
||||
|
||||
// menu frame
|
||||
menu_frame();
|
||||
|
||||
// editor frame
|
||||
//editor_frame();
|
||||
};
|
||||
|
||||
void(void) m_draw =
|
||||
{
|
||||
if(!menu_active)
|
||||
return;
|
||||
|
||||
// call m_frame cause draw is the only menu function called once per frame
|
||||
m_frame();
|
||||
|
||||
// now the drawing code
|
||||
menu_draw();
|
||||
|
||||
// editor drawing code
|
||||
//editor_draw();
|
||||
|
||||
// draw the cursor on top of the menu
|
||||
cursor_draw();
|
||||
|
||||
// and now the gfx drawing code (for special fx)
|
||||
gfx_draw();
|
||||
};
|
||||
|
||||
void(void) m_toggle =
|
||||
{
|
||||
if(!menu_active)
|
||||
{
|
||||
menu_active = true;
|
||||
|
||||
// update isserver and clientstate
|
||||
gamestatus = 0;
|
||||
if(isserver())
|
||||
gamestatus = gamestatus | GAME_ISSERVER;
|
||||
if(clientstate() == CS_CONNECTED)
|
||||
gamestatus = gamestatus | GAME_CONNECTED;
|
||||
if(cvar("developer"))
|
||||
gamestatus = gamestatus | GAME_DEVELOPER;
|
||||
|
||||
// redirect keyboard input
|
||||
setkeydest(KEY_MENU);
|
||||
// stop the client getting mouse coords
|
||||
setmousetarget(MT_MENU);
|
||||
|
||||
// let also the snd and gfx know (perhaps for sfx)
|
||||
gfx_toggle();
|
||||
snd_toggle();
|
||||
|
||||
cursor_toggle();
|
||||
|
||||
// let the menu manager know
|
||||
menu_performreinit();
|
||||
} else
|
||||
{
|
||||
setkeydest(KEY_GAME);
|
||||
setmousetarget(MT_CLIENT);
|
||||
menu_active = false;
|
||||
}
|
||||
};
|
||||
|
||||
void(void) m_shutdown =
|
||||
{
|
||||
// shutdown editor
|
||||
//editor_shutdown();
|
||||
|
||||
// shutdown menu
|
||||
menu_shutdown();
|
||||
|
||||
// shutdown cursor
|
||||
cursor_shutdown();
|
||||
|
||||
// shutdown sound
|
||||
snd_shutdown();
|
||||
|
||||
// shutdown graphic
|
||||
gfx_shutdown();
|
||||
///////////////////////////////////////////////
|
||||
// Menu Source File
|
||||
///////////////////////
|
||||
// This file belongs to dpmod/darkplaces
|
||||
// AK contains all menu functions (especially the required ones)
|
||||
///////////////////////////////////////////////
|
||||
|
||||
void(void) m_init =
|
||||
{
|
||||
// init graphic
|
||||
gfx_init();
|
||||
|
||||
// init sound
|
||||
snd_init();
|
||||
|
||||
// init cursor
|
||||
cursor_init();
|
||||
|
||||
// init menu
|
||||
menu_init();
|
||||
|
||||
// init editor
|
||||
//editor_init();
|
||||
};
|
||||
|
||||
// required menu functions
|
||||
void(float keynr, float ascii) m_keydown =
|
||||
{
|
||||
if(!menu_active)
|
||||
return;
|
||||
|
||||
// let also the gfx and sound know
|
||||
gfx_keydown(keynr, ascii);
|
||||
snd_keydown(keynr, ascii);
|
||||
|
||||
// actually only the menu may react on keydown messages
|
||||
menu_keydown(keynr, ascii);
|
||||
|
||||
// let the editor also know
|
||||
//editor_keydown(keynr, ascii);
|
||||
};
|
||||
|
||||
void(void) m_frame =
|
||||
{
|
||||
// graphic frame
|
||||
gfx_frame();
|
||||
|
||||
// sound frame
|
||||
snd_frame();
|
||||
|
||||
// cursor frame
|
||||
cursor_frame();
|
||||
|
||||
// menu frame
|
||||
menu_frame();
|
||||
|
||||
// editor frame
|
||||
//editor_frame();
|
||||
};
|
||||
|
||||
void(void) m_draw =
|
||||
{
|
||||
if(!menu_active) return;
|
||||
|
||||
|
||||
// call m_frame cause draw is the only menu function called once per frame
|
||||
m_frame();
|
||||
|
||||
// now the drawing code
|
||||
menu_draw();
|
||||
|
||||
// editor drawing code
|
||||
//editor_draw();
|
||||
|
||||
// draw the cursor on top of the menu
|
||||
cursor_draw();
|
||||
|
||||
// and now the gfx drawing code (for special fx)
|
||||
gfx_draw();
|
||||
};
|
||||
|
||||
void(void) m_toggle =
|
||||
{
|
||||
if(!menu_active)
|
||||
{
|
||||
menu_active = true;
|
||||
|
||||
// update isserver and clientstate
|
||||
gamestatus = 0;
|
||||
if(isserver())
|
||||
gamestatus = gamestatus | GAME_ISSERVER;
|
||||
if(clientstate() == CS_CONNECTED)
|
||||
gamestatus = gamestatus | GAME_CONNECTED;
|
||||
if(cvar("developer"))
|
||||
gamestatus = gamestatus | GAME_DEVELOPER;
|
||||
|
||||
// redirect keyboard input
|
||||
setkeydest(KEY_MENU);
|
||||
// stop the client getting mouse coords
|
||||
setmousetarget(MT_MENU);
|
||||
|
||||
// let also the snd and gfx know (perhaps for sfx)
|
||||
gfx_toggle();
|
||||
snd_toggle();
|
||||
|
||||
cursor_toggle();
|
||||
|
||||
// let the menu manager know
|
||||
menu_performreinit();
|
||||
}
|
||||
else
|
||||
{
|
||||
setkeydest(KEY_GAME);
|
||||
setmousetarget(MT_CLIENT);
|
||||
menu_active = false;
|
||||
}
|
||||
};
|
||||
|
||||
void(void) m_shutdown =
|
||||
{
|
||||
// shutdown editor
|
||||
//editor_shutdown();
|
||||
|
||||
// shutdown menu
|
||||
menu_shutdown();
|
||||
|
||||
// shutdown cursor
|
||||
cursor_shutdown();
|
||||
|
||||
// shutdown sound
|
||||
snd_shutdown();
|
||||
|
||||
// shutdown graphic
|
||||
gfx_shutdown();
|
||||
};
|
|
@ -14,10 +14,10 @@ void(entity ent) raise_x =
|
|||
if(!ent._x)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._x();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._x();
|
||||
pev = old;
|
||||
};
|
||||
*/
|
||||
|
||||
|
@ -27,10 +27,10 @@ void(entity ent) raise_reinit =
|
|||
if(!ent._reinit)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._reinit();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._reinit();
|
||||
pev = old;
|
||||
};
|
||||
|
||||
void(entity ent) raise_destroy =
|
||||
|
@ -39,10 +39,10 @@ void(entity ent) raise_destroy =
|
|||
if(!ent._destroy)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._destroy();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._destroy();
|
||||
pev = old;
|
||||
};
|
||||
|
||||
void(entity ent, float keynr, float ascii) raise_key =
|
||||
|
@ -51,10 +51,10 @@ void(entity ent, float keynr, float ascii) raise_key =
|
|||
if(!ent._key)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._key(keynr, ascii);
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._key(keynr, ascii);
|
||||
pev = old;
|
||||
};
|
||||
|
||||
void(entity ent) raise_draw =
|
||||
|
@ -63,10 +63,10 @@ void(entity ent) raise_draw =
|
|||
if(!ent._draw)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._draw();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._draw();
|
||||
pev = old;
|
||||
};
|
||||
|
||||
void(entity ent) raise_mouse_enter =
|
||||
|
@ -75,10 +75,10 @@ void(entity ent) raise_mouse_enter =
|
|||
if(!ent._mouse_enter)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._mouse_enter();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._mouse_enter();
|
||||
pev = old;
|
||||
};
|
||||
|
||||
void(entity ent) raise_mouse_leave =
|
||||
|
@ -87,10 +87,10 @@ void(entity ent) raise_mouse_leave =
|
|||
if(!ent._mouse_leave)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._mouse_leave();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._mouse_leave();
|
||||
pev = old;
|
||||
};
|
||||
|
||||
void(entity ent) raise_action =
|
||||
|
@ -99,10 +99,10 @@ void(entity ent) raise_action =
|
|||
if(!ent._action)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._action();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._action();
|
||||
pev = old;
|
||||
};
|
||||
|
||||
void(entity ent) raise_refresh =
|
||||
|
@ -111,10 +111,10 @@ void(entity ent) raise_refresh =
|
|||
if(!ent._refresh)
|
||||
return;
|
||||
|
||||
old = self;
|
||||
self = ent;
|
||||
self._refresh();
|
||||
self = old;
|
||||
old = pev;
|
||||
pev = ent;
|
||||
pev._refresh();
|
||||
pev = old;
|
||||
};
|
||||
|
||||
// safe call control function functions
|
||||
|
@ -123,64 +123,64 @@ void(entity ent) raise_refresh =
|
|||
|
||||
void(void) ctcall_x =
|
||||
{
|
||||
if(self.x)
|
||||
self.x();
|
||||
if(pev.x)
|
||||
pev.x();
|
||||
};
|
||||
|
||||
*/
|
||||
void(void) ctcall_init =
|
||||
{
|
||||
if(self.init)
|
||||
self.init();
|
||||
if(pev.init)
|
||||
pev.init();
|
||||
};
|
||||
|
||||
void(void) ctcall_reinit =
|
||||
{
|
||||
if(self.reinit)
|
||||
self.reinit();
|
||||
if(pev.reinit)
|
||||
pev.reinit();
|
||||
};
|
||||
|
||||
void(void) ctcall_destroy =
|
||||
{
|
||||
if(self.destroy)
|
||||
self.destroy();
|
||||
if(pev.destroy)
|
||||
pev.destroy();
|
||||
};
|
||||
|
||||
float(float keynr, float ascii) ctcall_key =
|
||||
{
|
||||
if(self.key)
|
||||
return self.key(keynr, ascii);
|
||||
if(pev.key)
|
||||
return pev.key(keynr, ascii);
|
||||
return 0;
|
||||
};
|
||||
|
||||
void(void) ctcall_draw =
|
||||
{
|
||||
if(self.draw)
|
||||
self.draw();
|
||||
if(pev.draw)
|
||||
pev.draw();
|
||||
};
|
||||
|
||||
void(void) ctcall_mouse_enter =
|
||||
{
|
||||
if(self.mouse_enter)
|
||||
self.mouse_enter();
|
||||
if(pev.mouse_enter)
|
||||
pev.mouse_enter();
|
||||
};
|
||||
|
||||
void(void) ctcall_mouse_leave =
|
||||
{
|
||||
if(self.mouse_leave)
|
||||
self.mouse_leave();
|
||||
if(pev.mouse_leave)
|
||||
pev.mouse_leave();
|
||||
};
|
||||
|
||||
void(void) ctcall_action =
|
||||
{
|
||||
if(self.action)
|
||||
self.action();
|
||||
if(pev.action)
|
||||
pev.action();
|
||||
};
|
||||
|
||||
void(void) ctcall_refresh =
|
||||
{
|
||||
if(self.refresh)
|
||||
self.refresh();
|
||||
if(pev.refresh)
|
||||
pev.refresh();
|
||||
}
|
||||
|
||||
// default control functions
|
||||
|
@ -241,15 +241,15 @@ void(void) defct_refresh =
|
|||
void(void) def_refresh =
|
||||
{
|
||||
// refresh stuff
|
||||
if(self.flag & FLAG_AUTOSETCLICK)
|
||||
if(pev.flag & FLAG_AUTOSETCLICK)
|
||||
{
|
||||
self.click_pos = self.pos;
|
||||
self.click_size = self.size;
|
||||
pev.click_pos = pev.pos;
|
||||
pev.click_size = pev.size;
|
||||
}
|
||||
if(self.flag & FLAG_AUTOSETCLIP)
|
||||
if(pev.flag & FLAG_AUTOSETCLIP)
|
||||
{
|
||||
self.clip_pos = self.pos;
|
||||
self.clip_size = self.size;
|
||||
pev.clip_pos = pev.pos;
|
||||
pev.clip_size = pev.size;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -265,67 +265,67 @@ void(float keynr, float ascii) def_keyevent =
|
|||
// move to the previous element
|
||||
menu_loopprev();
|
||||
|
||||
if(menu_selected == self)
|
||||
if(menu_selected == pev)
|
||||
{
|
||||
if(self._prev)
|
||||
if(pev._prev)
|
||||
{
|
||||
menu_selected = self._prev;
|
||||
menu_selected = pev._prev;
|
||||
menu_selectdown();
|
||||
if(menu_selected != self._prev)
|
||||
if(menu_selected != pev._prev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
menu_selected = self;
|
||||
menu_selected = pev;
|
||||
}
|
||||
} else if(keynr == K_RIGHTARROW || keynr == K_DOWNARROW)
|
||||
{
|
||||
// move to the next element
|
||||
menu_loopnext();
|
||||
|
||||
if(menu_selected == self)
|
||||
if(menu_selected == pev)
|
||||
{
|
||||
if(self._next)
|
||||
if(pev._next)
|
||||
{
|
||||
menu_selected = self._next;
|
||||
menu_selected = pev._next;
|
||||
menu_selectdown();
|
||||
if(menu_selected != self._next)
|
||||
if(menu_selected != pev._next)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
menu_selected = self;
|
||||
menu_selected = pev;
|
||||
}
|
||||
} else if(keynr == K_ENTER || keynr == K_MOUSE1)
|
||||
{
|
||||
eprint(self);
|
||||
eprint(pev);
|
||||
print("Action called\n");
|
||||
if(self._action)
|
||||
self._action();
|
||||
if(pev._action)
|
||||
pev._action();
|
||||
// move to the child menu
|
||||
menu_selectdown();
|
||||
} else if(keynr == K_TAB)
|
||||
{
|
||||
// select next and try to "go" down
|
||||
if(self._next)
|
||||
if(pev._next)
|
||||
{
|
||||
menu_selected = self._next;
|
||||
menu_selected = pev._next;
|
||||
menu_selectdown();
|
||||
if(menu_selected != self._next)
|
||||
if(menu_selected != pev._next)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(self._prev)
|
||||
if(pev._prev)
|
||||
{
|
||||
menu_selected = self._prev;
|
||||
menu_selected = pev._prev;
|
||||
menu_selectdown();
|
||||
if(menu_selected != self._prev)
|
||||
if(menu_selected != pev._prev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
menu_selected = self;
|
||||
menu_selected = pev;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -372,15 +372,15 @@ vector(vector r_pos, vector r_size, vector c_pos, vector c_size) cliprectsize =
|
|||
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 =
|
||||
{
|
||||
self._reinit = reinitevent;
|
||||
self._destroy = destroyevent;
|
||||
pev._reinit = reinitevent;
|
||||
pev._destroy = destroyevent;
|
||||
|
||||
self._key = keyevent;
|
||||
self._draw = drawevent;
|
||||
self._mouse_enter = mouse_enterevent;
|
||||
self._mouse_leave = mouse_leaveevent;
|
||||
self._action = actionevent;
|
||||
self._refresh = refreshevent;
|
||||
pev._key = keyevent;
|
||||
pev._draw = drawevent;
|
||||
pev._mouse_enter = mouse_enterevent;
|
||||
pev._mouse_leave = mouse_leaveevent;
|
||||
pev._action = actionevent;
|
||||
pev._refresh = refreshevent;
|
||||
};
|
||||
|
||||
float(float tfactor) getflicker =
|
||||
|
|
|
@ -15,57 +15,42 @@ void(void) menu_init =
|
|||
void(void) menu_load =
|
||||
{
|
||||
// load the menu files
|
||||
float count, i;
|
||||
float i;
|
||||
|
||||
count = tokenize(MENU_FILENAME_LIST);
|
||||
|
||||
for(i = 0; i < count; i = i + 1)
|
||||
for(i = 0; i < 2; i++ )
|
||||
{
|
||||
menu_loadmenu(argv(i));
|
||||
dprint(argv(i), " loaded !\n");
|
||||
menu_loadmenu(MENU_FILENAME_LIST[i]);
|
||||
dprint(MENU_FILENAME_LIST[i], " loaded !\n");
|
||||
}
|
||||
|
||||
menu_linkwindows();
|
||||
};
|
||||
|
||||
void(string file) menu_addfiletolist =
|
||||
{
|
||||
float count, i;
|
||||
|
||||
count = tokenize(MENU_FILENAME_LIST);
|
||||
|
||||
for(i = 0; i < count; i = i + 1)
|
||||
{
|
||||
if(argv(i) == file)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MENU_FILENAME_LIST = strcat(MENU_FILENAME_LIST," ",file);
|
||||
error("menu_addfiletolist called\n");
|
||||
};
|
||||
|
||||
void(void) menu_restart =
|
||||
{
|
||||
// actually we empty the ent list and load everything one more time, thats it
|
||||
entity ent;
|
||||
float selfused;
|
||||
string oldself;
|
||||
float pevused;
|
||||
string oldpev;
|
||||
string oldactive;
|
||||
string oldselected;
|
||||
|
||||
// we backup the active window name and the name of the selected item
|
||||
oldactive = menu_activewindow.name;
|
||||
oldselected = menu_selected.name;
|
||||
// backup self's name
|
||||
if(self != null_entity)
|
||||
// backup pev's name
|
||||
if(pev != null_entity)
|
||||
{
|
||||
oldself = self.name;
|
||||
selfused = true;
|
||||
oldpev = pev.name;
|
||||
pevused = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
selfused = false;
|
||||
pevused = false;
|
||||
}
|
||||
|
||||
// first clear the history
|
||||
|
@ -100,15 +85,15 @@ void(void) menu_restart =
|
|||
}
|
||||
}
|
||||
|
||||
if(selfused)
|
||||
if(pevused)
|
||||
{
|
||||
ent = menu_getitem(oldself);
|
||||
ent = menu_getitem(oldpev);
|
||||
if(ent)
|
||||
{
|
||||
self = ent;
|
||||
} else // we have no current self...
|
||||
pev = ent;
|
||||
} else // we have no current pev...
|
||||
{
|
||||
error("Reloaded menu files, but the former self (", oldself ,") item is missing !\n");
|
||||
error("Reloaded menu files, but the former pev (", oldpev ,") item is missing !\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -159,10 +144,10 @@ void(void) menu_linkwindows =
|
|||
ent = null_entity;
|
||||
while((ent = nextent(ent)) != null_entity)
|
||||
{
|
||||
self = ent;
|
||||
while((self = findstring(self, name, ent.name)) != null_entity)
|
||||
pev = ent;
|
||||
while((pev = findstring(pev, name, ent.name)) != null_entity)
|
||||
{
|
||||
if(self != null_entity)
|
||||
if(pev != null_entity)
|
||||
{
|
||||
objerror("Name ", ent.name, " already used !\n");
|
||||
}
|
||||
|
@ -173,112 +158,112 @@ void(void) menu_linkwindows =
|
|||
// set the parent field with parent_name
|
||||
// set the next and prev fields
|
||||
// set the child field
|
||||
self = null_entity;
|
||||
while((self = nextent(self)) != null_entity)
|
||||
pev = null_entity;
|
||||
while((pev = nextent(pev)) != null_entity)
|
||||
{
|
||||
if(self.name == "")
|
||||
if(pev.name == "")
|
||||
{
|
||||
objerror("Name is missing !\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(self.type == "")
|
||||
if(pev.type == "")
|
||||
{
|
||||
objerror("Type is missing !\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!isfunction(self.type))
|
||||
if(!isfunction(pev.type))
|
||||
{
|
||||
objerror("Control ", self.type, " not found !\n");
|
||||
objerror("Control ", pev.type, " not found !\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// find parent
|
||||
// if parent_name is "" do nothing else set parent
|
||||
if(self.parent != "")
|
||||
if(pev.parent != "")
|
||||
{
|
||||
ent = findstring(null_entity, name, self.parent);
|
||||
ent = findstring(null_entity, name, pev.parent);
|
||||
|
||||
if(ent == null_entity)
|
||||
{
|
||||
objerror("Item ", self.parent, " not found !\n");
|
||||
objerror("Item ", pev.parent, " not found !\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
self._parent = ent;
|
||||
pev._parent = ent;
|
||||
}
|
||||
else
|
||||
{
|
||||
self._parent = null_entity;
|
||||
pev._parent = null_entity;
|
||||
}
|
||||
}
|
||||
|
||||
// now auto-set all ents with orderpos 0
|
||||
self = null_entity;
|
||||
while((self = findfloat(self,orderpos, 0)) != null_entity)
|
||||
pev = null_entity;
|
||||
while((pev = findfloat(pev,orderpos, 0)) != null_entity)
|
||||
{
|
||||
if(self.parent == "")
|
||||
if(pev.parent == "")
|
||||
continue;
|
||||
|
||||
// now go through all orderpos' beginning from 1
|
||||
opos = 1;
|
||||
while((ent = findef(null_entity, _parent, self._parent, orderpos, opos)) != null_entity)
|
||||
while((ent = findef(null_entity, _parent, pev._parent, orderpos, opos)) != null_entity)
|
||||
{
|
||||
opos = opos + 1;
|
||||
}
|
||||
|
||||
self.orderpos = opos;
|
||||
pev.orderpos = opos;
|
||||
}
|
||||
|
||||
self = null_entity;
|
||||
while((self = nextent(self)) != null_entity)
|
||||
pev = null_entity;
|
||||
while((pev = nextent(pev)) != null_entity)
|
||||
{
|
||||
// find first child
|
||||
// orderpos starts with 1
|
||||
ent = findef(null_entity, _parent, self, orderpos, 1);
|
||||
ent = findef(null_entity, _parent, pev, orderpos, 1);
|
||||
|
||||
if(ent == null_entity)
|
||||
{
|
||||
if(findentity(ent, _parent, self) != null_entity)
|
||||
if(findentity(ent, _parent, pev) != null_entity)
|
||||
{
|
||||
objerror("Order pos 1 is missing in the child list of ", self.name, " !\n");
|
||||
objerror("Order pos 1 is missing in the child list of ", pev.name, " !\n");
|
||||
continue;
|
||||
}
|
||||
//else doesnt have any chilren
|
||||
}
|
||||
else
|
||||
self._child = ent;
|
||||
pev._child = ent;
|
||||
|
||||
// add to next, previous list
|
||||
// find orderpos - x (starting with x = 1)
|
||||
x = self.orderpos;
|
||||
x = pev.orderpos;
|
||||
|
||||
while(x > 1)
|
||||
{
|
||||
x = x - 1;
|
||||
|
||||
ent = findef(null_entity, _parent, self._parent, orderpos, x);
|
||||
ent = findef(null_entity, _parent, pev._parent, orderpos, x);
|
||||
if(ent != null_entity)
|
||||
{
|
||||
self._prev = ent;
|
||||
ent._next = self;
|
||||
pev._prev = ent;
|
||||
ent._next = pev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// find orderpos + x (starting with x = 1 until x == self.oderpos + 100)
|
||||
x = self.orderpos;
|
||||
// find orderpos + x (starting with x = 1 until x == pev.oderpos + 100)
|
||||
x = pev.orderpos;
|
||||
|
||||
while(x < self.orderpos + 100)
|
||||
while(x < pev.orderpos + 100)
|
||||
{
|
||||
x = x + 1;
|
||||
|
||||
ent = findef(null_entity, _parent, self._parent, orderpos, x);
|
||||
ent = findef(null_entity, _parent, pev._parent, orderpos, x);
|
||||
if(ent != null_entity)
|
||||
{
|
||||
self._next = ent;
|
||||
ent._prev = self;
|
||||
pev._next = ent;
|
||||
ent._prev = pev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -288,8 +273,8 @@ void(void) menu_linkwindows =
|
|||
ent = null_entity;
|
||||
while((ent = nextent(ent)) != null_entity)
|
||||
{
|
||||
self = ent;
|
||||
callfunction(self.type);
|
||||
pev = ent;
|
||||
callfunction(pev.type);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -309,23 +294,22 @@ void(void) menu_performreinit =
|
|||
menu_clearhistory();
|
||||
|
||||
// and reinit all menu items
|
||||
self = null_entity;
|
||||
while((self = nextent(self)) != null_entity)
|
||||
pev = null_entity;
|
||||
while((pev = nextent(pev)) != null_entity)
|
||||
{
|
||||
if(self.parent == "")
|
||||
self._parent = null_entity;
|
||||
if(pev.parent == "")
|
||||
pev._parent = null_entity;
|
||||
//else actually this shouldnt happen
|
||||
else if(self._parent.name != self.parent)
|
||||
objerror("Parent (should be ", self.parent, ") of non-menu item ", self.name, " changed to ", self._parent.name, " !\n");
|
||||
else if(pev._parent.name != pev.parent)
|
||||
objerror("Parent (should be ", pev.parent, ") of non-menu item ", pev.name, " changed to ", pev._parent.name, " !\n");
|
||||
|
||||
raise_reinit(self); // always call reinit
|
||||
raise_reinit(pev); // always call reinit
|
||||
}
|
||||
|
||||
// choose which menu to display
|
||||
if(MENU_ALLOWINGAME && (gamestatus & GAME_CONNECTED))
|
||||
menu_activewindow = findstring(null_entity, name, MENU_INGAME_NAME);
|
||||
else
|
||||
menu_activewindow = findstring(null_entity, name, MENU_NORMAL_NAME);
|
||||
else menu_activewindow = findstring(null_entity, name, MENU_NORMAL_NAME);
|
||||
|
||||
// set the selected item
|
||||
menu_selected = menu_activewindow;
|
||||
|
@ -335,7 +319,7 @@ void(void) menu_performreinit =
|
|||
|
||||
void(entity par, float selectalways) menu_processmouse =
|
||||
{
|
||||
// self is parent
|
||||
// pev is parent
|
||||
// loop through all childs
|
||||
// and try to find an object whose click rect fits to the mouse coords
|
||||
entity ent;
|
||||
|
@ -463,7 +447,7 @@ void(entity menu) menu_drawwindow =
|
|||
// if it's not visible continue
|
||||
if(menu_isvisible(ent))
|
||||
{
|
||||
self = ent;
|
||||
pev = ent;
|
||||
if(menu_hasevents(ent))
|
||||
{
|
||||
raise_refresh(ent);
|
||||
|
@ -563,10 +547,10 @@ float(entity e) menu_selectable =
|
|||
void(void) menu_shutdown =
|
||||
{
|
||||
// call the terminate event for each object
|
||||
self = null_entity;
|
||||
while((self = nextent(self)) != null_entity)
|
||||
pev = null_entity;
|
||||
while((pev = nextent(pev)) != null_entity)
|
||||
{
|
||||
raise_destroy(self);
|
||||
raise_destroy(pev);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -702,6 +686,7 @@ void(void) menu_selectdown =
|
|||
menu_selected = ent;
|
||||
return;
|
||||
}
|
||||
|
||||
} while((ent = ent._next) != null_entity);
|
||||
|
||||
// we found no selectable child, thus we loop through the children once again
|
||||
|
@ -732,7 +717,6 @@ void(void) menu_selectdown =
|
|||
|
||||
// we didnt find anything
|
||||
menu_selected = old_selected;
|
||||
|
||||
}
|
||||
|
||||
void(void) menu_selectup =
|
||||
|
|
|
@ -31,7 +31,11 @@ const string MENU_INGAME_DEFAULT =
|
|||
"}";
|
||||
|
||||
// insert the files here
|
||||
var string MENU_FILENAME_LIST = "menu/main.menu menu/options.menu";
|
||||
string MENU_FILENAME_LIST[2] =
|
||||
{
|
||||
"scripts/menu/main.txt",
|
||||
"scripts/menu/options.txt"
|
||||
};
|
||||
|
||||
const float MENU_ALLOWINGAME = FALSE;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//////////////////////////////////////////////////////////
|
||||
// sys globals
|
||||
|
||||
entity self;
|
||||
entity pev;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
void end_sys_globals;
|
||||
|
@ -167,9 +167,13 @@ float K_AUX32 = 803;
|
|||
///////////////////////////
|
||||
// key dest constants
|
||||
|
||||
float KEY_GAME = 0;
|
||||
float KEY_MENU = 2;
|
||||
float KEY_UNKNOWN = 3;
|
||||
enum
|
||||
{
|
||||
KEY_GAME,
|
||||
KEY_CONSOLE,
|
||||
KEY_MESSAGE,
|
||||
KEY_MENU
|
||||
};
|
||||
|
||||
///////////////////////////
|
||||
// file constants
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
qcclib -log /V7
|
Reference in New Issue