summaryrefslogtreecommitdiff
path: root/source/ui_script.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2008-05-18 14:37:21 +0000
committerAndrey Nazarov <skuller@skuller.net>2008-05-18 14:37:21 +0000
commitcb43ed08c3cf6410fe4ce22dac3d07952db92893 (patch)
tree0b2b2790941743db47913cdf06b819c36b89e161 /source/ui_script.c
parent179f701f7aec100ac1228fc02778fc4af47b75f0 (diff)
Accept `all' as special argument to `delstuffcmd' command.
Cleaned up Cvar_Get and fixed semantic bug. Accept `background keyword in menu scripts. Renamed `gl_fastsky' to `gl_drawsky'. If at least one of the sky env maps fails lo load, disable entire sky drawing. Reworked loading screen. Fixed Com_Quit argument string handling. Catch more signals on *nix. Updated server docs.
Diffstat (limited to 'source/ui_script.c')
-rw-r--r--source/ui_script.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/source/ui_script.c b/source/ui_script.c
index 394260c..6f51e12 100644
--- a/source/ui_script.c
+++ b/source/ui_script.c
@@ -26,18 +26,6 @@ static menuSound_t Activate( menuCommon_t *self ) {
return QMS_NOTHANDLED;
}
-static void Draw( menuFrameWork_t *self ) {
- static const color_t color = { 0, 0, 255, 32 };
- int y1, y2;
-
- y1 = ( uis.height - MENU_SPACING * self->nitems ) / 2 - MENU_SPACING;
- y2 = ( uis.height + MENU_SPACING * self->nitems ) / 2 + MENU_SPACING;
-
- ref.DrawFillEx( 0, y1, uis.width, y2 - y1, color );
-
- Menu_Draw( self );
-}
-
static void Parse_Spin( menuFrameWork_t *menu, menuType_t type ) {
menuSpinControl_t *s;
int numItems = Cmd_Argc() - 3;
@@ -51,7 +39,7 @@ static void Parse_Spin( menuFrameWork_t *menu, menuType_t type ) {
s = UI_Mallocz( sizeof( *s ) );
s->generic.type = type;
s->generic.name = UI_CopyString( Cmd_Argv( 1 ) );
- s->cvar = Cvar_Get( Cmd_Argv( 2 ), NULL, CVAR_USER_CREATED );
+ s->cvar = Cvar_Ref( Cmd_Argv( 2 ) );
s->itemnames = UI_Mallocz( sizeof( char * ) * ( numItems + 1 ) );
for( i = 0; i < numItems; i++ ) {
s->itemnames[i] = UI_CopyString( Cmd_Argv( 3 + i ) );
@@ -74,7 +62,7 @@ static void Parse_Pairs( menuFrameWork_t *menu ) {
s = UI_Mallocz( sizeof( *s ) );
s->generic.type = MTYPE_PAIRS;
s->generic.name = UI_CopyString( Cmd_Argv( 1 ) );
- s->cvar = Cvar_Get( Cmd_Argv( 2 ), NULL, CVAR_USER_CREATED );
+ s->cvar = Cvar_Ref( Cmd_Argv( 2 ) );
numItems >>= 1;
s->itemnames = UI_Mallocz( sizeof( char * ) * ( numItems + 1 ) );
for( i = 0; i < numItems; i++ ) {
@@ -100,7 +88,7 @@ static void Parse_Range( menuFrameWork_t *menu ) {
s = UI_Mallocz( sizeof( *s ) );
s->generic.type = MTYPE_SLIDER;
s->generic.name = UI_CopyString( Cmd_Argv( 1 ) );
- s->cvar = Cvar_Get( Cmd_Argv( 2 ), NULL, CVAR_USER_CREATED );
+ s->cvar = Cvar_Ref( Cmd_Argv( 2 ) );
s->add = atof( Cmd_Argv( 3 ) );
s->mul = atof( Cmd_Argv( 4 ) );
s->minvalue = atoi( Cmd_Argv( 5 ) );
@@ -196,7 +184,7 @@ static void Parse_Toggle( menuFrameWork_t *menu ) {
s = UI_Mallocz( sizeof( *s ) );
s->generic.type = type;
s->generic.name = UI_CopyString( Cmd_Argv( 1 ) );
- s->cvar = Cvar_Get( Cmd_Argv( 2 ), NULL, CVAR_USER_CREATED );
+ s->cvar = Cvar_Ref( Cmd_Argv( 2 ) );
s->itemnames = ( char ** )yes_no_names;
s->numItems = 2;
s->negate = negate;
@@ -243,7 +231,7 @@ static void Parse_Field( menuFrameWork_t *menu ) {
f->generic.name = UI_CopyString( Cmd_Argv( cmd_optind ) );
f->generic.status = UI_CopyString( status );
f->generic.flags = flags;
- f->cvar = Cvar_Get( Cmd_Argv( cmd_optind + 1 ), NULL, CVAR_USER_CREATED );
+ f->cvar = Cvar_Ref( Cmd_Argv( cmd_optind + 1 ) );
f->width = width;
Menu_AddItem( menu, f );
@@ -258,6 +246,20 @@ static void Parse_Blank( menuFrameWork_t *menu ) {
Menu_AddItem( menu, s );
}
+static void Parse_Background( menuFrameWork_t *menu ) {
+ char *s = Cmd_Argv( 1 );
+
+ if( COM_ParseColor( s, menu->color ) ) {
+ menu->image = 0;
+ if( menu->color[3] != 255 ) {
+ menu->transparent = qtrue;
+ }
+ } else {
+ menu->image = ref.RegisterPic( s );
+ menu->transparent = ref.DrawGetPicSize( NULL, NULL, menu->image );
+ }
+}
+
static qboolean Parse_File( const char *path, int depth ) {
char *data, *p, *cmd;
int argc;
@@ -285,10 +287,6 @@ static qboolean Parse_File( const char *path, int depth ) {
if( menu ) {
if( !strcmp( cmd, "end" ) ) {
if( menu->nitems ) {
- if( !menu->title ) {
- menu->transparent = qtrue;
- menu->draw = Draw;
- }
List_Append( &ui_menus, &menu->entry );
} else {
menu->free( menu );
@@ -299,6 +297,8 @@ static qboolean Parse_File( const char *path, int depth ) {
Z_Free( menu->title );
}
menu->title = UI_CopyString( Cmd_Argv( 1 ) );
+ } else if( !strcmp( cmd, "background" ) ) {
+ Parse_Background( menu );
} else if( !strcmp( cmd, "values" ) ) {
Parse_Spin( menu, MTYPE_SPINCONTROL );
} else if( !strcmp( cmd, "strings" ) ) {
@@ -342,6 +342,8 @@ static qboolean Parse_File( const char *path, int depth ) {
menu->push = Menu_Push;
menu->pop = Menu_Pop;
menu->free = Menu_Free;
+ menu->image = uis.backgroundHandle;
+ *( uint32_t * )menu->color = *( uint32_t * )colorBlack;
} else if( !strcmp( cmd, "include" ) ) {
char *s = Cmd_Argv( 1 );
if( !*s ) {