]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/quickmenu
authorterencehill <piuntn@gmail.com>
Sun, 4 Dec 2011 15:22:01 +0000 (16:22 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 4 Dec 2011 15:22:01 +0000 (16:22 +0100)
21 files changed:
_hud_common.cfg
_hud_descriptions.cfg
defaultXonotic.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
keybinds.txt
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/hud_config.qc
qcsrc/common/constants.qh
qcsrc/common/util.qh
qcsrc/menu/classes.c
qcsrc/menu/xonotic/dialog_hudpanel_quickmenu.c [new file with mode: 0644]
qcsrc/menu/xonotic/mainwindow.c
quickmenu.txt [new file with mode: 0644]

index c46bbee713bf099c6bf74b45e474ee7baea0a559..cc4d1c8748ad82e3a53e8317b306b5a607469c9e 100644 (file)
@@ -26,6 +26,8 @@ seta hud_panel_engineinfo_framecounter_exponentialmovingaverage 1 "use an averag
 seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight 0.1 "weight of latest data point"
 seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold 0.5 "threshold for fps change when to update instantly, to make big fps changes update faster"
 
+seta hud_panel_quickmenu_file quickmenu.txt "load the quick menu from this file"
+
 // hud panel aliases
 alias hud_panel_radar_rotate "toggle hud_panel_radar_rotation 0 1 2 3 4"
 alias +hud_panel_radar_maximized "cl_cmd hud_panel_radar_maximized 1"
index 061720a844f8b9dc7cb5ee8c4d8cb33c988e7059..08ecb6f6528d991821638ff5392dca1a4b1b133c 100644 (file)
@@ -287,3 +287,14 @@ seta hud_panel_centerprint_fade_subsequent_passtwo "" "division factor for the s
 seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha "" "minimum factor that the second pass can fade to"
 seta hud_panel_centerprint_fade_subsequent_minfontsize "" "minimum factor for the font size from the subsequent fading effects"
 seta hud_panel_centerprint_fade_minfontsize "" "minimum factor for the font size from the fading in/out effects"
+
+seta hud_panel_quickmenu "" "enable/disable this panel"
+seta hud_panel_quickmenu_pos "" "position of this base of the panel"
+seta hud_panel_quickmenu_size "" "size of this panel"
+seta hud_panel_quickmenu_bg "" "if set to something else than \"\" = override default background"
+seta hud_panel_quickmenu_bg_color "" "if set to something else than \"\" = override default panel background color"
+seta hud_panel_quickmenu_bg_color_team "" "override panel color with team color in team based games"
+seta hud_panel_quickmenu_bg_alpha "" "if set to something else than \"\" = override default panel background alpha"
+seta hud_panel_quickmenu_bg_border "" "if set to something else than \"\" = override default size of border around the background"
+seta hud_panel_quickmenu_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
+seta hud_panel_quickmenu_align "text alignment: 0 left, 0.5 center, 1 right"
index acae53764316b211b9448f826f379ac965b024a5..f649ffde4020a01864a8ec69a3db4c9cb6e7e889 100644 (file)
@@ -1068,6 +1068,8 @@ bind F11 disconnect
 bind F12 screenshot
 bind F4 ready
 bind ALT +showaccuracy
+alias quickmenu "cl_cmd hud_panel_quickmenu"
+bind v quickmenu
 
 // Gamepad defaults. Tested with Logitech Rumblepad 2, I hope similar ones works as well.
 bind JOY1 "+crouch"
index f32279f2b9b1d36c06a97512dbd3048037d093a9..a05b3bf03b1f42ef8c1cd4085237f19e88c8afbf 100644 (file)
@@ -23,7 +23,7 @@ seta hud_progressbar_speed_color "1 0.75 0"
 seta hud_progressbar_acceleration_color "0.5 0.75 1" 
 seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5" 
 
-seta _hud_panelorder "15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 16 "
+seta _hud_panelorder "15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 16 17 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -282,4 +282,15 @@ seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha "0.5"
 seta hud_panel_centerprint_fade_subsequent_minfontsize "0.75"
 seta hud_panel_centerprint_fade_minfontsize "0"
 
+seta hud_panel_quickmenu 1
+seta hud_panel_quickmenu_pos "0.000000 0.430000"
+seta hud_panel_quickmenu_size "0.210000 0.250000"
+seta hud_panel_quickmenu_bg ""
+seta hud_panel_quickmenu_bg_color ""
+seta hud_panel_quickmenu_bg_color_team ""
+seta hud_panel_quickmenu_bg_alpha ""
+seta hud_panel_quickmenu_bg_border ""
+seta hud_panel_quickmenu_bg_padding ""
+seta hud_panel_quickmenu_align "0"
+
 menu_sync
index 52a7d96c1327844d54a461e89f6305f0c4c95b7f..5900fdf87cc85e9dbc8b89f9c0f21c51e0f70d3f 100644 (file)
@@ -23,7 +23,7 @@ seta hud_progressbar_speed_color "1 0.75 0"
 seta hud_progressbar_acceleration_color "0.5 0.75 1" 
 seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5" 
 
-seta _hud_panelorder "10 3 0 14 6 9 13 4 1 2 11 12 7 5 8 15 16 "
+seta _hud_panelorder "10 3 0 14 6 9 13 4 1 2 11 12 7 5 8 15 16 17 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -282,4 +282,15 @@ seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha "0.5"
 seta hud_panel_centerprint_fade_subsequent_minfontsize "0.75"
 seta hud_panel_centerprint_fade_minfontsize "0"
 
+seta hud_panel_quickmenu 1
+seta hud_panel_quickmenu_pos "0.000000 0.430000"
+seta hud_panel_quickmenu_size "0.210000 0.250000"
+seta hud_panel_quickmenu_bg ""
+seta hud_panel_quickmenu_bg_color ""
+seta hud_panel_quickmenu_bg_color_team ""
+seta hud_panel_quickmenu_bg_alpha ""
+seta hud_panel_quickmenu_bg_border ""
+seta hud_panel_quickmenu_bg_padding ""
+seta hud_panel_quickmenu_align "0"
+
 menu_sync
index 2d5e07600c09265f849b888e6584ab75c87994c1..11ba6e4eb4a8567cf9729d842b85f9233e3140de 100644 (file)
@@ -23,7 +23,7 @@ seta hud_progressbar_speed_color "1 0.75 0"
 seta hud_progressbar_acceleration_color "0.5 0.75 1" 
 seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5" 
 
-seta _hud_panelorder "15 3 1 2 11 10 0 14 6 9 13 4 12 7 5 8 16 "
+seta _hud_panelorder "15 3 1 2 11 10 0 14 6 9 13 4 12 7 5 8 16 17 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -282,4 +282,15 @@ seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha "0.5"
 seta hud_panel_centerprint_fade_subsequent_minfontsize "0.75"
 seta hud_panel_centerprint_fade_minfontsize "0"
 
+seta hud_panel_quickmenu 1
+seta hud_panel_quickmenu_pos "0.000000 0.430000"
+seta hud_panel_quickmenu_size "0.210000 0.250000"
+seta hud_panel_quickmenu_bg ""
+seta hud_panel_quickmenu_bg_color ""
+seta hud_panel_quickmenu_bg_color_team ""
+seta hud_panel_quickmenu_bg_alpha ""
+seta hud_panel_quickmenu_bg_border ""
+seta hud_panel_quickmenu_bg_padding ""
+seta hud_panel_quickmenu_align "0"
+
 menu_sync
index fe7f66085519cc3ed94cf1e08cd44390e3b2ccd3..df9b804fdad459e9abf81e886655087de92c3548 100644 (file)
@@ -23,7 +23,7 @@ seta hud_progressbar_speed_color "1 0.75 0"
 seta hud_progressbar_acceleration_color "0.5 0.75 1" 
 seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5" 
 
-seta _hud_panelorder "15 10 9 6 8 14 5 0 4 13 2 7 1 3 11 12 16 "
+seta _hud_panelorder "15 10 9 6 8 14 5 0 4 13 2 7 1 3 11 12 16 17 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -282,4 +282,15 @@ seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha "0.5"
 seta hud_panel_centerprint_fade_subsequent_minfontsize "0.75"
 seta hud_panel_centerprint_fade_minfontsize "0"
 
+seta hud_panel_quickmenu 1
+seta hud_panel_quickmenu_pos "0.700000 0.460000"
+seta hud_panel_quickmenu_size "0.210000 0.250000"
+seta hud_panel_quickmenu_bg ""
+seta hud_panel_quickmenu_bg_color ""
+seta hud_panel_quickmenu_bg_color_team ""
+seta hud_panel_quickmenu_bg_alpha ""
+seta hud_panel_quickmenu_bg_border ""
+seta hud_panel_quickmenu_bg_padding ""
+seta hud_panel_quickmenu_align "1"
+
 menu_sync
index 5c2138370660bdf3e40d204af441cbe42cb81b9f..88d380c87125e45db9052498b1ae74d04a58cb3a 100644 (file)
@@ -23,7 +23,7 @@ seta hud_progressbar_speed_color "1 0.75 0"
 seta hud_progressbar_acceleration_color "0.5 0.75 1" 
 seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5" 
 
-seta _hud_panelorder "15 0 11 8 5 6 14 9 13 7 2 3 1 10 12 4 16 "
+seta _hud_panelorder "15 0 11 8 5 6 14 9 13 7 2 3 1 10 12 4 16 17 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.01"
@@ -282,4 +282,15 @@ seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha "0.5"
 seta hud_panel_centerprint_fade_subsequent_minfontsize "0.75"
 seta hud_panel_centerprint_fade_minfontsize "0"
 
+seta hud_panel_quickmenu 1
+seta hud_panel_quickmenu_pos "0.000000 0.380000"
+seta hud_panel_quickmenu_size "0.210000 0.250000"
+seta hud_panel_quickmenu_bg ""
+seta hud_panel_quickmenu_bg_color ""
+seta hud_panel_quickmenu_bg_color_team ""
+seta hud_panel_quickmenu_bg_alpha ""
+seta hud_panel_quickmenu_bg_border ""
+seta hud_panel_quickmenu_bg_padding ""
+seta hud_panel_quickmenu_align "0"
+
 menu_sync
index 2df89afae0e9f0ecf8b5dd4cdc6a737071a65a80..03dd3417cf4fd814380b30b54f18d8c8e3f5298f 100644 (file)
@@ -44,6 +44,7 @@
 "ready"                                 "ready"
 ""                                      ""
 ""                                      "Client"
+"quickmenu"                             "quick menu"
 "+show_info"                            "server info"
 "toggleconsole"                         "enter console"
 "disconnect"                            "disconnect"
index 2252f6f61cec427d69ebe63d9a26eca8394955f3..6bf64d1b4183559f19b151532cc7c9cd052473f9 100644 (file)
@@ -511,6 +511,14 @@ void GameCommand(string msg)
                else
                        hud_panel_radar_maximized = (stof(argv(1)) != 0);
        }
+       else if(cmd == "hud_panel_quickmenu")
+       {
+               if(argc == 1 && HUD_QuickMenu_IsOpened())
+                       HUD_QuickMenu_Close();
+               else
+                       if (HUD_QuickMenu_Buffer_Init())
+                               HUD_QuickMenu_Open("", 0);
+       }
        else if(cmd == "settemp") {
                cvar_clientsettemp(argv(1), argv(2));
        }
@@ -646,6 +654,9 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
        if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
                return true;
 
+       if (HUD_QuickMenu_InputEvent(bInputType, nPrimary, nSecondary))
+               return true;
+
        if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
                return true;
 
index d9f6df7ee77281fdf2e52b650d25680dec5f72a9..66fdd710bc308846a13510872c91cfa232d56761 100644 (file)
@@ -457,7 +457,7 @@ void CSQC_UpdateView(float w, float h)
        }
        
        // do lockview after event chase camera so that it still applies whenever necessary.
-       if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1)
+       if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1 || HUD_QuickMenu_IsOpened())
        {
                setproperty(VF_ORIGIN, freeze_org);
                setproperty(VF_ANGLES, freeze_ang);
@@ -1426,18 +1426,21 @@ void CSQC_UpdateView(float w, float h)
 
        if(autocvar__hud_configure)
                HUD_Panel_Mouse();
-    
-    if(hud && !intermission)
-    {        
-        if(hud == HUD_SPIDERBOT)
-            CSQC_SPIDER_HUD();
-        else if(hud == HUD_WAKIZASHI)
-            CSQC_WAKIZASHI_HUD();
-        else if(hud == HUD_RAPTOR)
-            CSQC_RAPTOR_HUD();
-        else if(hud == HUD_BUMBLEBEE)
-            CSQC_BUMBLE_HUD();
-    }
+       else if (HUD_QuickMenu_IsOpened())
+               HUD_QuickMenu_Mouse();
+
+       if(hud && !intermission)
+       {
+               if(hud == HUD_SPIDERBOT)
+                       CSQC_SPIDER_HUD();
+               else if(hud == HUD_WAKIZASHI)
+                       CSQC_WAKIZASHI_HUD();
+               else if(hud == HUD_RAPTOR)
+                       CSQC_RAPTOR_HUD();
+               else if(hud == HUD_BUMBLEBEE)
+                       CSQC_BUMBLE_HUD();
+       }
+
        // let's reset the view back to normal for the end
        setproperty(VF_MIN, '0 0 0');
        setproperty(VF_SIZE, '1 0 0' * w + '0 1 0' * h);
index e18433e9666465ef36702c7ba10637eb4e3d1a6a..2bd3f7b00f3cc93ad9d763e74719b684d3f80072 100644 (file)
@@ -273,6 +273,7 @@ string autocvar_hud_panel_powerups_progressbar_strength;
 float autocvar_hud_panel_powerups_text;
 float autocvar_hud_panel_pressedkeys;
 float autocvar_hud_panel_pressedkeys_aspect;
+string autocvar_hud_panel_quickmenu_file;
 float autocvar_hud_panel_racetimer;
 float autocvar_hud_panel_radar;
 float autocvar_hud_panel_radar_foreground_alpha;
@@ -311,6 +312,8 @@ float autocvar_hud_panel_weapons_label;
 float autocvar_hud_panel_weapons_onlyowned;
 float autocvar_hud_panel_weapons_timeout;
 float autocvar_hud_panel_weapons_timeout_effect;
+float autocvar_hud_panel_quickmenu;
+float autocvar_hud_panel_quickmenu_align;
 float autocvar_hud_progressbar_alpha;
 float autocvar_hud_showbinds;
 float autocvar_hud_showbinds_limit;
index 86b49761e5ca59cd34e978073f82e79ad9ddf395..78334cc16b53ddf45ca14db8137f883a50f7096e 100644 (file)
@@ -4778,6 +4778,431 @@ void HUD_CenterPrint (void)
        }
 }
 
+
+// QUICKMENU_MAXLINES must be <= 10
+#define QUICKMENU_MAXLINES 10
+#define QUICKMENU_MAXENTRIES 256
+string QuickMenu_Command[QUICKMENU_MAXLINES];
+string QuickMenu_Description[QUICKMENU_MAXLINES];
+float QuickMenu_CurrentPage;
+float QuickMenu_IsLastPage;
+var float QuickMenu_Buffer = -1;
+float QuickMenu_Buffer_Size;
+float QuickMenu_Buffer_Index;
+string QuickMenu_CurrentSubMenu;
+float QuickMenu_CurrentPage_FirstEntry;
+var float QuickMenu_Entries;
+void HUD_QuickMenu_load_entry(float i, string s, string s1)
+{
+       //print(sprintf("^xc80 entry %d: %s, %s\n", i, s, s1));
+       if (QuickMenu_Description[i])
+               strunzone(QuickMenu_Description[i]);
+       QuickMenu_Description[i] = strzone(s);
+       if (QuickMenu_Command[i])
+               strunzone(QuickMenu_Command[i]);
+       QuickMenu_Command[i] = strzone(s1);
+}
+void HUD_QuickMenu_clear_entry(float i)
+{
+       if (QuickMenu_Description[i])
+               strunzone(QuickMenu_Description[i]);
+       QuickMenu_Description[i] = string_null;
+       if (QuickMenu_Command[i])
+               strunzone(QuickMenu_Command[i]);
+       QuickMenu_Command[i] = string_null;
+}
+
+float HUD_QuickMenu_Buffer_Init()
+{
+       float fh, i;
+       string s;
+       fh = fopen(autocvar_hud_panel_quickmenu_file, FILE_READ);
+       if(fh < 0)
+       {
+               print(sprintf("Error: Couldn't open file %d!\n", autocvar_hud_panel_quickmenu_file));
+               return false;
+       }
+
+       QuickMenu_Buffer = buf_create();
+       if (QuickMenu_Buffer < 0)
+       {
+               fclose(fh);
+               return false;
+       }
+
+       i = 0;
+       while((s = fgets(fh)) && i < QUICKMENU_MAXENTRIES)
+       {
+               // first skip invalid entries, so we don't check them anymore
+               float argc;
+               argc = tokenize_console(s);
+               if(argc == 0 || argc > 2)
+                       continue;
+
+               bufstr_set(QuickMenu_Buffer, i, s);
+               ++i;
+       }
+       QuickMenu_Buffer_Size = i;
+
+       if (QuickMenu_Buffer_Size <= 0)
+       {
+               buf_del(QuickMenu_Buffer);
+               QuickMenu_Buffer = -1;
+       }
+       fclose(fh);
+       return true;
+}
+void HUD_QuickMenu_Buffer_Close()
+{
+       if (QuickMenu_Buffer >= 0)
+       {
+               buf_del(QuickMenu_Buffer);
+               QuickMenu_Buffer = -1;
+               QuickMenu_Buffer_Size = 0;
+       }
+}
+void HUD_QuickMenu_Close()
+{
+       if (QuickMenu_CurrentSubMenu)
+               strunzone(QuickMenu_CurrentSubMenu);
+       QuickMenu_CurrentSubMenu = string_null;
+       float i;
+       for (i = 0; i < QUICKMENU_MAXLINES; ++i)
+               HUD_QuickMenu_clear_entry(i);
+       QuickMenu_Entries = 0;
+       hud_panel_quickmenu = 0;
+       mouseClicked = 0;
+       HUD_QuickMenu_Buffer_Close();
+}
+
+// It assumes submenu open tag is already detected
+void HUD_QuickMenu_skip_submenu(string submenu)
+{
+       string s, z_submenu;
+       z_submenu = strzone(submenu);
+       for(++QuickMenu_Buffer_Index ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
+       {
+               s = bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index);
+               float argc;
+               argc = tokenize_console(s);
+               if(argc == 2)
+                       continue;
+               if (argv(0) == "")
+                       continue;
+               if (argv(0) == z_submenu) // submenu end
+                       break;
+               HUD_QuickMenu_skip_submenu(argv(0));
+       }
+       strunzone(z_submenu);
+}
+
+
+float HUD_QuickMenu_IsOpened()
+{
+       return (QuickMenu_Entries > 0);
+}
+
+// new_page 0 means page 0, new_page != 0 means next page
+float QuickMenu_Buffer_Index_Prev;
+void HUD_QuickMenu_Open(string target_submenu, float new_page)
+{
+       float total, i;
+       string s, z_submenu;
+
+       if (new_page == 0)
+               QuickMenu_CurrentPage = 0;
+       else
+               ++QuickMenu_CurrentPage;
+       QuickMenu_CurrentPage_FirstEntry = QuickMenu_CurrentPage * (QUICKMENU_MAXLINES - 2);
+
+       z_submenu = strzone(target_submenu);
+       if (QuickMenu_CurrentSubMenu)
+               strunzone(QuickMenu_CurrentSubMenu);
+       QuickMenu_CurrentSubMenu = strzone(z_submenu);
+
+       QuickMenu_IsLastPage = TRUE;
+       QuickMenu_Entries = 0;
+
+       QuickMenu_Buffer_Index = 0;
+       if (z_submenu != "")
+       {
+               // skip everything until the submenu open tag is found
+               for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
+               {
+                       s = bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index);
+                       if (tokenize_console(s) == 1 && argv(0) == z_submenu)
+                       {
+                               // print(sprintf("^3 beginning of %s\n", z_submenu));
+                               ++QuickMenu_Buffer_Index;
+                               break;
+                       }
+                       // print(sprintf("^1 skipping %s\n", s));
+               }
+       }
+       for( ; QuickMenu_Buffer_Index < QuickMenu_Buffer_Size; ++QuickMenu_Buffer_Index)
+       {
+               s = bufstr_get(QuickMenu_Buffer, QuickMenu_Buffer_Index);
+               float argc;
+               argc = tokenize_console(s);
+
+               if (z_submenu != "" && z_submenu == argv(0))
+               {
+                       // print(sprintf("^3 end of %s\n", z_submenu));
+                       break;
+               }
+
+               if (total - QuickMenu_CurrentPage_FirstEntry >= 0)
+               {
+                       ++QuickMenu_Entries;
+                       if(QuickMenu_Entries == QUICKMENU_MAXLINES - 2)
+                               QuickMenu_Buffer_Index_Prev = QuickMenu_Buffer_Index;
+                       else if(QuickMenu_Entries == QUICKMENU_MAXLINES)
+                       {
+                               HUD_QuickMenu_clear_entry(QUICKMENU_MAXLINES - 1);
+                               QuickMenu_Buffer_Index = QuickMenu_Buffer_Index_Prev;
+                               QuickMenu_IsLastPage = FALSE;
+                               break;
+                       }
+               }
+
+               // NOTE: entries are loaded starting from 1, not from 0
+               if (argc == 1 && argv(0) != "") // submenu
+               {
+                       if (total - QuickMenu_CurrentPage_FirstEntry >= 0)
+                               HUD_QuickMenu_load_entry(QuickMenu_Entries, argv(0), "");
+                       HUD_QuickMenu_skip_submenu(argv(0));
+               }
+               else if (total - QuickMenu_CurrentPage_FirstEntry >= 0)
+                       HUD_QuickMenu_load_entry(QuickMenu_Entries, argv(0), argv(1));
+
+               ++total;
+       }
+       strunzone(z_submenu);
+       if (QuickMenu_Entries == 0)
+               HUD_QuickMenu_Close();
+       else
+               hud_panel_quickmenu = 1;
+}
+
+void HUD_QuickMenu_ActionForNumber(float num)
+{
+       if (!QuickMenu_IsLastPage)
+       {
+               if (num < 0 || num >= QUICKMENU_MAXLINES)
+                       return;
+               if (num == QUICKMENU_MAXLINES - 1)
+                       return;
+               if (num == 0)
+               {
+                       HUD_QuickMenu_Open(QuickMenu_CurrentSubMenu, +1);
+                       return;
+               }
+       } else if (num <= 0 || num > QuickMenu_Entries)
+               return;
+
+       if (QuickMenu_Command[num] != "")
+       {
+               localcmd(strcat("\n", QuickMenu_Command[num], "\n"));
+               if (!(hudShiftState & S_CTRL))
+                       HUD_QuickMenu_Close();
+               return;
+       }
+       if (QuickMenu_Description[num] != "")
+               HUD_QuickMenu_Open(QuickMenu_Description[num], 0);
+}
+float HUD_QuickMenu_InputEvent(float bInputType, float nPrimary, float nSecondary)
+{
+       string s;
+
+       // we only care for keyboard events
+       if(bInputType != 0 && bInputType != 1)
+               return false;
+
+       if(!HUD_QuickMenu_IsOpened() || autocvar__hud_configure)
+               return false;
+
+       // allow console bind to work
+       string con_keys;
+       float keys;
+       con_keys = findkeysforcommand("toggleconsole");
+       keys = tokenize(con_keys); // findkeysforcommand returns data for this
+
+       float hit_con_bind, i;
+       for (i = 0; i < keys; ++i)
+       {
+               if(nPrimary == stof(argv(i)))
+                       hit_con_bind = 1;
+       }
+
+       if(bInputType == 0) {
+               if(nPrimary == K_ALT) hudShiftState |= S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
+       }
+       else if(bInputType == 1) {
+               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
+               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
+               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+       }
+
+       if(nPrimary == K_ESCAPE)
+       {
+               if (bInputType == 1)
+                       return true;
+               HUD_QuickMenu_Close();
+       }
+       else if(nPrimary >= '0' && nPrimary <= '9')
+       {
+               if (bInputType == 1)
+                       return true;
+               HUD_QuickMenu_ActionForNumber(stof(chr2str(nPrimary)));
+       }
+       if(nPrimary == K_MOUSE1)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE1;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE1);
+       }
+       else if(nPrimary == K_MOUSE2)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE2;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE2);
+       }
+       else if(hit_con_bind)
+               return false;
+
+       return true;
+}
+void HUD_QuickMenu_Mouse()
+{
+       if (mouseClicked & S_MOUSE2)
+       {
+               HUD_QuickMenu_Close();
+               return;
+       }
+
+       mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
+
+       mousepos_x = bound(0, mousepos_x, vid_conwidth);
+       mousepos_y = bound(0, mousepos_y, vid_conheight);
+
+       HUD_Panel_UpdatePosSize(quickmenu)
+       float first_entry_pos, entries_height;
+       vector fontsize;
+       fontsize = '1 1 0' * (panel_size_y / QUICKMENU_MAXLINES);
+       first_entry_pos = panel_pos_y + ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y) / 2;
+       entries_height = panel_size_y - ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y);
+
+       if (mousepos_x >= panel_pos_x && mousepos_y >= first_entry_pos && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= first_entry_pos + entries_height)
+       {
+               float entry_num;
+               entry_num = floor((mousepos_y - first_entry_pos) / fontsize_y);
+               if (QuickMenu_IsLastPage || entry_num != QUICKMENU_MAXLINES - 2)
+               {
+                       panel_pos_y = first_entry_pos + entry_num * fontsize_y;
+                       vector color;
+                       if (mouseClicked & S_MOUSE1)
+                       {
+                               color = '0 1 0';
+                               if (entry_num < QUICKMENU_MAXLINES - 1)
+                                       HUD_QuickMenu_ActionForNumber(entry_num + 1);
+                               else
+                                       HUD_QuickMenu_ActionForNumber(0);
+                               mouseClicked -= (mouseClicked & S_MOUSE1);
+                       }
+                       else
+                               color = '1 1 1';
+                       drawfill(panel_pos, eX * panel_size_x + eY * fontsize_y, color, .2, DRAWFLAG_NORMAL);
+               }
+       }
+
+       const vector cursorsize = '32 32 0';
+       drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+}
+void HUD_QuickMenu_DrawEntry(vector pos, string s, vector fontsize)
+{
+       string entry;
+       float offset;
+       entry = textShortenToWidth(s, panel_size_x, fontsize, stringwidth_colors);
+       if (autocvar_hud_panel_quickmenu_align > 0)
+       {
+               offset = (panel_size_x - stringwidth_colors(entry, fontsize)) * min(autocvar_hud_panel_quickmenu_align, 1);
+               drawcolorcodedstring(pos + eX * offset, entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
+       }
+       else
+               drawcolorcodedstring(pos + eY * (panel_size_y - fontsize_y), entry, fontsize, panel_fg_alpha, DRAWFLAG_ADDITIVE);
+}
+void HUD_QuickMenu(void)
+{
+       if(!autocvar__hud_configure)
+       {
+               if (hud_configure_prev && hud_configure_prev != -1)
+                       HUD_QuickMenu_Close();
+
+               if(!hud_draw_maximized) return;
+               //if(!autocvar_hud_panel_quickmenu) return; // autocvar exists only for conformity with other panels
+               if(!hud_panel_quickmenu) return;
+       }
+       else
+       {
+               if(!HUD_QuickMenu_IsOpened())
+               {
+                       QuickMenu_Entries = 1;
+                       HUD_QuickMenu_load_entry(QuickMenu_Entries, sprintf(_("Submenu%d"), QuickMenu_Entries), "");
+                       ++QuickMenu_Entries;
+                       HUD_QuickMenu_load_entry(QuickMenu_Entries, sprintf(_("Submenu%d"), QuickMenu_Entries), "");
+                       ++QuickMenu_Entries;
+                       // although real command doesn't matter here, it must not be empty
+                       // otherwise the entry is displayed like a submenu
+                       for (; QuickMenu_Entries < QUICKMENU_MAXLINES - 1; ++QuickMenu_Entries)
+                               HUD_QuickMenu_load_entry(QuickMenu_Entries, sprintf(_("Command%d"), QuickMenu_Entries), "-");
+                       ++QuickMenu_Entries;
+                       HUD_QuickMenu_clear_entry(QuickMenu_Entries);
+                       QuickMenu_IsLastPage = FALSE;
+               }
+
+               hud_configure_active_panel = HUD_PANEL_QUICKMENU;
+       }
+
+       HUD_Panel_UpdateCvars(quickmenu);
+       HUD_Panel_ApplyFadeAlpha();
+
+       HUD_Panel_DrawBg(1);
+
+       if(panel_bg_padding)
+       {
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
+       }
+
+       float i;
+       vector fontsize;
+       string color;
+       fontsize = '1 1 0' * (panel_size_y / QUICKMENU_MAXLINES);
+
+       if (!QuickMenu_IsLastPage)
+       {
+               color = "^5";
+               HUD_QuickMenu_DrawEntry(panel_pos + eY * (panel_size_y - fontsize_y), sprintf("%d: %s%s", 0, color, _("Continue...")), fontsize);
+       }
+       else
+               panel_pos_y += ((QUICKMENU_MAXLINES - QuickMenu_Entries) * fontsize_y) / 2;
+
+       for (i = 1; i <= QuickMenu_Entries; ++i) {
+               if (QuickMenu_Description[i] == "")
+                       break;
+               if (QuickMenu_Command[i] == "")
+                       color = "^4";
+               else
+                       color = "^3";
+               HUD_QuickMenu_DrawEntry(panel_pos, sprintf("%d: %s%s", i, color, QuickMenu_Description[i]), fontsize);
+               panel_pos_y += fontsize_y;
+       }
+}
+
 /*
 ==================
 Main HUD system
@@ -4829,6 +5254,8 @@ switch (id) {\
                 HUD_Physics(); break;\
        case (HUD_PANEL_CENTERPRINT):\
                 HUD_CenterPrint(); break;\
+       case (HUD_PANEL_QUICKMENU):\
+                HUD_QuickMenu(); break;\
 } ENDS_WITH_CURLY_BRACE
 
 void HUD_Main (void)
@@ -4990,6 +5417,8 @@ void HUD_Main (void)
                HUD_Radar();
        if(autocvar__con_chat_maximized)
                HUD_Chat();
+       if(hud_panel_quickmenu)
+               HUD_QuickMenu();
 
        if(autocvar__hud_configure)
        {
index 16ccd0c79c0d33aea202eaa3d7c2aab7b4b2721f..533a2a4bbb0f0dab7caebeeb86e457d0eb84ce05 100644 (file)
@@ -3,6 +3,7 @@ string hud_panelorder_prev;
 
 float hud_draw_maximized;
 float hud_panel_radar_maximized;
+float hud_panel_quickmenu;
 
 vector mousepos;
 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
@@ -287,6 +288,7 @@ switch(id) { \
        case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
        case HUD_PANEL_PHYSICS: HUD_Panel_UpdateCvars(physics); break;\
        case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdateCvars(centerprint); break;\
+       case HUD_PANEL_QUICKMENU: HUD_Panel_UpdateCvars(quickmenu); break;\
 }
 
 #define HUD_Panel_UpdateCvarsForId(id) \
@@ -325,6 +327,7 @@ switch(id) { \
        case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages) break;\
        case HUD_PANEL_PHYSICS: HUD_Panel_UpdatePosSize(physics); break;\
        case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdatePosSize(centerprint); break;\
+       case HUD_PANEL_QUICKMENU: HUD_Panel_UpdatePosSize(quickmenu); break;\
 }
 
 #define HUD_Panel_UpdatePosSizeForId(id) \
index 3ad600e41c74de9e6d42918fbae7634dcedb091d..c6b1201517b50aa1ed447397f487ad58e59619d8 100644 (file)
@@ -177,6 +177,9 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize");
                                        HUD_Write_PanelCvar_q("_fade_minfontsize");
                                        break;
+                               case HUD_PANEL_QUICKMENU:
+                                       HUD_Write_PanelCvar_q("_align");
+                                       break;
                        }
                        HUD_Write("\n");
                }
index 7e5e99edbf9a5a2c64476c7e526c305a70284c6f..fdd4fd0fe5e8991d3d698b68e42b9ca3e059c37d 100644 (file)
@@ -532,42 +532,44 @@ float WR_SWITCHABLE       = 12; // (CSQC) impact effect
 float WR_PLAYERDEATH    = 13; // (SVQC) does not need to do anything
 float WR_GONETHINK     = 14; // (SVQC) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed
 
-float HUD_PANEL_WEAPONS                = 0;
-float HUD_PANEL_AMMO           = 1;
-float HUD_PANEL_POWERUPS       = 2;
-float HUD_PANEL_HEALTHARMOR    = 3;
-float HUD_PANEL_NOTIFY         = 4;
-float HUD_PANEL_TIMER          = 5;
-float HUD_PANEL_RADAR          = 6;
-float HUD_PANEL_SCORE          = 7;
-float HUD_PANEL_RACETIMER      = 8;
-float HUD_PANEL_VOTE           = 9;
-float HUD_PANEL_MODICONS       = 10;
-float HUD_PANEL_PRESSEDKEYS    = 11;
-float HUD_PANEL_CHAT           = 12;
-float HUD_PANEL_ENGINEINFO     = 13;
+float HUD_PANEL_WEAPONS                        = 0;
+float HUD_PANEL_AMMO                   = 1;
+float HUD_PANEL_POWERUPS               = 2;
+float HUD_PANEL_HEALTHARMOR            = 3;
+float HUD_PANEL_NOTIFY                 = 4;
+float HUD_PANEL_TIMER                  = 5;
+float HUD_PANEL_RADAR                  = 6;
+float HUD_PANEL_SCORE                  = 7;
+float HUD_PANEL_RACETIMER              = 8;
+float HUD_PANEL_VOTE                   = 9;
+float HUD_PANEL_MODICONS               = 10;
+float HUD_PANEL_PRESSEDKEYS            = 11;
+float HUD_PANEL_CHAT                   = 12;
+float HUD_PANEL_ENGINEINFO             = 13;
 float HUD_PANEL_INFOMESSAGES   = 14;
-float HUD_PANEL_PHYSICS        = 15;
-float HUD_PANEL_CENTERPRINT    = 16;
-float HUD_PANEL_NUM            = 17; // always last panel id + 1, please increment when adding a new panel
-
-string HUD_PANELNAME_WEAPONS           = "weapons";
-string HUD_PANELNAME_AMMO              = "ammo";
-string HUD_PANELNAME_POWERUPS          = "powerups";
-string HUD_PANELNAME_HEALTHARMOR       = "healtharmor";
-string HUD_PANELNAME_NOTIFY            = "notify";
-string HUD_PANELNAME_TIMER             = "timer";
-string HUD_PANELNAME_RADAR             = "radar";
-string HUD_PANELNAME_SCORE             = "score";
-string HUD_PANELNAME_RACETIMER         = "racetimer";
-string HUD_PANELNAME_VOTE              = "vote";
-string HUD_PANELNAME_MODICONS          = "modicons";
-string HUD_PANELNAME_PRESSEDKEYS       = "pressedkeys";
-string HUD_PANELNAME_CHAT              = "chat";
-string HUD_PANELNAME_ENGINEINFO                = "engineinfo";
+float HUD_PANEL_PHYSICS                        = 15;
+float HUD_PANEL_CENTERPRINT            = 16;
+float HUD_PANEL_QUICKMENU              = 17;
+float HUD_PANEL_NUM                            = 18; // always last panel id + 1, please increment when adding a new panel
+
+string HUD_PANELNAME_WEAPONS           = "weapons";
+string HUD_PANELNAME_AMMO                      = "ammo";
+string HUD_PANELNAME_POWERUPS          = "powerups";
+string HUD_PANELNAME_HEALTHARMOR       = "healtharmor";
+string HUD_PANELNAME_NOTIFY                    = "notify";
+string HUD_PANELNAME_TIMER                     = "timer";
+string HUD_PANELNAME_RADAR                     = "radar";
+string HUD_PANELNAME_SCORE                     = "score";
+string HUD_PANELNAME_RACETIMER         = "racetimer";
+string HUD_PANELNAME_VOTE                      = "vote";
+string HUD_PANELNAME_MODICONS          = "modicons";
+string HUD_PANELNAME_PRESSEDKEYS       = "pressedkeys";
+string HUD_PANELNAME_CHAT                      = "chat";
+string HUD_PANELNAME_ENGINEINFO                = "engineinfo";
 string HUD_PANELNAME_INFOMESSAGES      = "infomessages";
-string HUD_PANELNAME_PHYSICS   = "physics";
+string HUD_PANELNAME_PHYSICS           = "physics";
 string HUD_PANELNAME_CENTERPRINT       = "centerprint";
+string HUD_PANELNAME_QUICKMENU         = "quickmenu";
 
 float HUD_MENU_ENABLE          = 0;
 
index b2e77484e398695ea3b2febb290bd217cdf83af5..80794c96c466e79c2b470872f84eaddc7e3d92a3 100644 (file)
@@ -223,6 +223,7 @@ switch(id) {\
        case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
        case HUD_PANEL_PHYSICS: panel_name = HUD_PANELNAME_PHYSICS; break; \
        case HUD_PANEL_CENTERPRINT: panel_name = HUD_PANELNAME_CENTERPRINT; break; \
+       case HUD_PANEL_QUICKMENU: panel_name = HUD_PANELNAME_QUICKMENU; break; \
 } ENDS_WITH_CURLY_BRACE
 
 // Get name of specified panel id
index 5b7331e3752be37be4231150c89627e38c5baa5e..fc0a9109443e2a3c53ce455655dd6c9387414dc7 100644 (file)
 #include "xonotic/dialog_hudpanel_weapons.c"
 #include "xonotic/dialog_hudpanel_physics.c"
 #include "xonotic/dialog_hudpanel_centerprint.c"
+#include "xonotic/dialog_hudpanel_quickmenu.c"
 #include "xonotic/slider_picmip.c"
diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_quickmenu.c b/qcsrc/menu/xonotic/dialog_hudpanel_quickmenu.c
new file mode 100644 (file)
index 0000000..4aed758
--- /dev/null
@@ -0,0 +1,29 @@
+#ifdef INTERFACE
+CLASS(XonoticHUDQuickMenuDialog) EXTENDS(XonoticRootDialog)
+       METHOD(XonoticHUDQuickMenuDialog, fill, void(entity))
+       ATTRIB(XonoticHUDQuickMenuDialog, title, string, _("Quick Menu Panel"))
+       ATTRIB(XonoticHUDQuickMenuDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT)
+       ATTRIB(XonoticHUDQuickMenuDialog, intendedWidth, float, 0.4)
+       ATTRIB(XonoticHUDQuickMenuDialog, rows, float, 15)
+       ATTRIB(XonoticHUDQuickMenuDialog, columns, float, 4)
+       ATTRIB(XonoticHUDQuickMenuDialog, name, string, "HUDquickmenu")
+ENDCLASS(XonoticHUDQuickMenuDialog)
+#endif
+
+#ifdef IMPLEMENTATION
+void XonoticHUDQuickMenuDialog_fill(entity me)
+{
+       entity e;
+       string panelname = "quickmenu";
+
+       DIALOG_HUDPANEL_COMMON();
+
+       me.TR(me);
+               me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Text alignment:")));
+       me.TR(me);
+               me.TDempty(me, 0.2);
+                       me.TD(me, 1, 3.8/3, e = makeXonoticRadioButton(3, "hud_panel_quickmenu_align", "0", _("Left")));
+                       me.TD(me, 1, 3.8/3, e = makeXonoticRadioButton(3, "hud_panel_quickmenu_align", "0.5", _("Center")));
+                       me.TD(me, 1, 3.8/3, e = makeXonoticRadioButton(3, "hud_panel_quickmenu_align", "1", _("Right")));
+}
+#endif
index 55d496047138cf23ec68b55251db14e8658d17d9..336622e143a7425da05fa91da64873b59e6d84f7 100644 (file)
@@ -122,6 +122,10 @@ void MainWindow_configureMainWindow(entity me)
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
+       i = spawnXonoticHUDQuickMenuDialog();
+       i.configureDialog(i);
+       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
        me.advancedDialog = i = spawnXonoticAdvancedDialog();
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
diff --git a/quickmenu.txt b/quickmenu.txt
new file mode 100644 (file)
index 0000000..229f088
--- /dev/null
@@ -0,0 +1,25 @@
+"Chat"
+"nice one" "say :-) / nice one"
+"good game" "say good game"
+"hi / good luck" "say hi / good luck and have fun"
+"Chat"
+"Team chat"
+"quad soon" "say_team quad soon"
+"free item, icon" "say_team free item %x^7 (l:%y^7); g_waypointsprite_team_here_p"
+"took item, icon" "say_team took item (l:%l^7); g_waypointsprite_team_here"
+"negative" "say_team negative"
+"positive" "say_team positive"
+"need help, icon" "say_team need help (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_helpme; cmd voice needhelp"
+"enemy seen, icon" "say_team enemy seen (l:%y^7); g_waypointsprite_team_danger_p; cmd voice incoming"
+"flag seen, icon" "say_team flag seen (l:%y^7); g_waypointsprite_team_here_p; cmd voice seenflag"
+"defending, icon" "say_team defending (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_here"
+"roaming, icon" "say_team roaming (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_here"
+"attacking, icon" "say_team attacking (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_here"
+"killed flag, icon" "say_team killed flagcarrier (l:%y^7); g_waypointsprite_team_p"
+"dropped flag, icon" "say_team dropped flag (l:%d^7); g_waypointsprite_team_here_d"
+"drop gun, icon" "say_team dropped gun %w^7 (l:%l^7); g_waypointsprite_team_here; wait; dropweapon"
+"drop flag/key, icon" "say_team dropped flag/key %w^7 (l:%l^7); g_waypointsprite_team_here; wait; +use"
+"Team chat"
+"screenshot" "wait; screenshot"
+"toggle recording .avi" "wait; toggle cl_capturevideo"
+"toggle fullscreen" "toggle vid_fullscreen; vid_restart"