From 4beb3753dcd3ce57cbd2e3a8f69c26d703c49eea Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 7 Sep 2004 18:20:05 +0000 Subject: [PATCH] menubind command from binds on scripted menus git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@159 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/m_script.c | 55 +++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/engine/client/m_script.c b/engine/client/m_script.c index bee781808..f23986ab7 100644 --- a/engine/client/m_script.c +++ b/engine/client/m_script.c @@ -24,7 +24,7 @@ qboolean M_Script_Key (int key, menu_t *menu) return false; } -void M_Menu_Clear_f (void) +void M_MenuS_Clear_f (void) { if (menu_script) { @@ -35,7 +35,7 @@ void M_Menu_Clear_f (void) // Cvar_Set(menualias.name, ""); } -void M_Menu_Script_f (void) //create a menu. +void M_MenuS_Script_f (void) //create a menu. { int items; extern menu_t *currentmenu; @@ -63,7 +63,7 @@ void M_Menu_Script_f (void) //create a menu. } } selectitem = items - selectitem-1; - M_Menu_Clear_f(); + M_MenuS_Clear_f(); } oldmenu = currentmenu; @@ -83,7 +83,7 @@ void M_Menu_Script_f (void) //create a menu. Cvar_Set(&menualias, alias); } -void M_Menu_Box_f (void) +void M_MenuS_Box_f (void) { int x = atoi(Cmd_Argv(1)); int y = atoi(Cmd_Argv(2)); @@ -99,7 +99,7 @@ void M_Menu_Box_f (void) MC_AddBox(menu_script, x, y, width/8, height/8); } -void M_Menu_CheckBox_f (void) +void M_MenuS_CheckBox_f (void) { int x = atoi(Cmd_Argv(1)); int y = atoi(Cmd_Argv(2)); @@ -118,7 +118,7 @@ void M_Menu_CheckBox_f (void) MC_AddCheckBox(menu_script, x, y, text, cvar); } -void M_Menu_Slider_f (void) +void M_MenuS_Slider_f (void) { int x = atoi(Cmd_Argv(1)); int y = atoi(Cmd_Argv(2)); @@ -139,7 +139,7 @@ void M_Menu_Slider_f (void) MC_AddSlider(menu_script, x, y, text, cvar, min, max); } -void M_Menu_Picture_f (void) +void M_MenuS_Picture_f (void) { int x = atoi(Cmd_Argv(1)); int y = atoi(Cmd_Argv(2)); @@ -154,7 +154,7 @@ void M_Menu_Picture_f (void) MC_AddPicture(menu_script, x, y, picname); } -void M_Menu_Edit_f (void) +void M_MenuS_Edit_f (void) { int x = atoi(Cmd_Argv(1)); int y = atoi(Cmd_Argv(2)); @@ -170,7 +170,7 @@ void M_Menu_Edit_f (void) MC_AddEditCvar(menu_script, x, y, text, def); } -void M_Menu_Text_f (void) +void M_MenuS_Text_f (void) { menuoption_t *option; int x = atoi(Cmd_Argv(1)); @@ -192,6 +192,26 @@ void M_Menu_Text_f (void) menu_script->selecteditem = option; } } + +void M_MenuS_Bind_f (void) +{ + int x = atoi(Cmd_Argv(1)); + int y = atoi(Cmd_Argv(2)); + char *caption = Cmd_Argv(3); + char *command = Cmd_Argv(4); + + if (!menu_script) + { + Con_Printf("%s with no active menu\n", Cmd_Argv(0)); + return; + } + + if (!*caption) + caption = command; + + MC_AddBind(menu_script, x, y, command, caption); +} + /* menuclear menualias menucallback @@ -207,14 +227,15 @@ menutext 0 24 "Cancel" */ void M_Script_Init(void) { - Cmd_AddCommand("menuclear", M_Menu_Clear_f); - Cmd_AddCommand("conmenu", M_Menu_Script_f); - Cmd_AddCommand("menubox", M_Menu_Box_f); - Cmd_AddCommand("menuedit", M_Menu_Edit_f); - Cmd_AddCommand("menutext", M_Menu_Text_f); - Cmd_AddCommand("menupic", M_Menu_Picture_f); - Cmd_AddCommand("menucheck", M_Menu_CheckBox_f); - Cmd_AddCommand("menuslider", M_Menu_Slider_f); + Cmd_AddCommand("menuclear", M_MenuS_Clear_f); + Cmd_AddCommand("conmenu", M_MenuS_Script_f); + Cmd_AddCommand("menubox", M_MenuS_Box_f); + Cmd_AddCommand("menuedit", M_MenuS_Edit_f); + Cmd_AddCommand("menutext", M_MenuS_Text_f); + Cmd_AddCommand("menupic", M_MenuS_Picture_f); + Cmd_AddCommand("menucheck", M_MenuS_CheckBox_f); + Cmd_AddCommand("menuslider", M_MenuS_Slider_f); + Cmd_AddCommand("menubind", M_MenuS_Bind_f); Cvar_Register(&menualias, "Scripting"); }