]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud_config.qc
Merge remote-tracking branch 'origin/master' into terencehill/cursormode
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud_config.qc
index 5fca9d28fa7444ff22544445a895fee4a2c8c194..d1d5dfc8aec21da63dcada6245c0a9c36184f488 100644 (file)
@@ -35,6 +35,9 @@ void HUD_Panel_ExportCfg(string cfgname)
                HUD_Write_Cvar_q("hud_progressbar_armor_color");
                HUD_Write_Cvar_q("hud_progressbar_fuel_color");
                HUD_Write_Cvar_q("hud_progressbar_nexball_color");
+               HUD_Write_Cvar_q("hud_progressbar_speed_color");
+               HUD_Write_Cvar_q("hud_progressbar_acceleration_color");
+               HUD_Write_Cvar_q("hud_progressbar_acceleration_neg_color");
                HUD_Write("\n");
 
                HUD_Write_Cvar_q("_hud_panelorder");
@@ -45,9 +48,6 @@ void HUD_Panel_ExportCfg(string cfgname)
                HUD_Write_Cvar_q("hud_configure_grid_ysize");
                HUD_Write("\n");
 
-               HUD_Write_Cvar_q("scr_centerpos");
-               HUD_Write("\n");
-
                // common cvars for all panels
                float i;
                for (i = 0; i < HUD_PANEL_NUM; ++i)
@@ -65,16 +65,22 @@ void HUD_Panel_ExportCfg(string cfgname)
                        HUD_Write_PanelCvar_q("_bg_padding");
                        switch(i) {
                                case HUD_PANEL_WEAPONS:
+                                       HUD_Write_PanelCvar_q("_accuracy");
+                                       HUD_Write_PanelCvar_q("_label");
                                        HUD_Write_PanelCvar_q("_complainbubble");
                                        HUD_Write_PanelCvar_q("_complainbubble_padding");
+                                       HUD_Write_PanelCvar_q("_complainbubble_time");
+                                       HUD_Write_PanelCvar_q("_complainbubble_fadetime");
                                        HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
                                        HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
                                        HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
+                                       HUD_Write_PanelCvar_q("_ammo");
                                        HUD_Write_PanelCvar_q("_ammo_color");
                                        HUD_Write_PanelCvar_q("_ammo_alpha");
                                        HUD_Write_PanelCvar_q("_aspect");
                                        HUD_Write_PanelCvar_q("_timeout");
                                        HUD_Write_PanelCvar_q("_timeout_effect");
+                                       HUD_Write_PanelCvar_q("_onlyowned");
                                        break;
                                case HUD_PANEL_AMMO:
                                        HUD_Write_PanelCvar_q("_onlycurrent");
@@ -91,6 +97,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_PanelCvar_q("_progressbar");
                                        HUD_Write_PanelCvar_q("_progressbar_strength");
                                        HUD_Write_PanelCvar_q("_progressbar_shield");
+                                       HUD_Write_PanelCvar_q("_text");
                                        break;
                                case HUD_PANEL_HEALTHARMOR:
                                        HUD_Write_PanelCvar_q("_flip");
@@ -99,39 +106,101 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_PanelCvar_q("_progressbar");
                                        HUD_Write_PanelCvar_q("_progressbar_health");
                                        HUD_Write_PanelCvar_q("_progressbar_armor");
+                                       HUD_Write_PanelCvar_q("_progressbar_gfx");
+                                       HUD_Write_PanelCvar_q("_progressbar_gfx_smooth");
                                        HUD_Write_PanelCvar_q("_text");
                                        break;
                                case HUD_PANEL_NOTIFY:
                                        HUD_Write_PanelCvar_q("_flip");
+                                       HUD_Write_PanelCvar_q("_fontsize");
                                        HUD_Write_PanelCvar_q("_print");
+                                       HUD_Write_PanelCvar_q("_time");
+                                       HUD_Write_PanelCvar_q("_fadetime");
+                                       break;
+                               case HUD_PANEL_TIMER:
+                                       HUD_Write_PanelCvar_q("_increment");
                                        break;
                                case HUD_PANEL_RADAR:
                                        HUD_Write_PanelCvar_q("_foreground_alpha");
+                                       HUD_Write_PanelCvar_q("_rotation");
+                                       HUD_Write_PanelCvar_q("_zoommode");
+                                       HUD_Write_PanelCvar_q("_scale");
+                                       HUD_Write_PanelCvar_q("_maximized_scale");
+                                       HUD_Write_PanelCvar_q("_maximized_size");
+                                       break;
+                               case HUD_PANEL_SCORE:
+                                       HUD_Write_PanelCvar_q("_rankings");
                                        break;
                                case HUD_PANEL_VOTE:
                                        HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
                                        break;
+                               case HUD_PANEL_MODICONS:
+                                       HUD_Write_PanelCvar_q("_dom_layout");
+                                       break;
                                case HUD_PANEL_PRESSEDKEYS:
+                                       HUD_Write_PanelCvar_q("_attack");
                                        HUD_Write_PanelCvar_q("_aspect");
                                        break;
+                               case HUD_PANEL_ENGINEINFO:
+                                       HUD_Write_PanelCvar_q("_framecounter_time");
+                                       HUD_Write_PanelCvar_q("_framecounter_decimals");
+                                       break;
                                case HUD_PANEL_INFOMESSAGES:
                                        HUD_Write_PanelCvar_q("_flip");
                                        break;
                                case HUD_PANEL_PHYSICS:
+                                       HUD_Write_PanelCvar_q("_speed_unit");
+                                       HUD_Write_PanelCvar_q("_speed_unit_show");
+                                       HUD_Write_PanelCvar_q("_speed_max");
+                                       HUD_Write_PanelCvar_q("_speed_vertical");
+                                       HUD_Write_PanelCvar_q("_topspeed");
+                                       HUD_Write_PanelCvar_q("_topspeed_time");
+                                       HUD_Write_PanelCvar_q("_acceleration_max");
+                                       HUD_Write_PanelCvar_q("_acceleration_vertical");
                                        HUD_Write_PanelCvar_q("_flip");
                                        HUD_Write_PanelCvar_q("_baralign");
                                        HUD_Write_PanelCvar_q("_progressbar");
+                                       HUD_Write_PanelCvar_q("_progressbar_acceleration_mode");
+                                       HUD_Write_PanelCvar_q("_progressbar_acceleration_scale");
+                                       HUD_Write_PanelCvar_q("_progressbar_acceleration_nonlinear");
+                                       HUD_Write_PanelCvar_q("_text");
+                                       HUD_Write_PanelCvar_q("_text_scale");
+                                       break;
+                               case HUD_PANEL_CENTERPRINT:
+                                       HUD_Write_PanelCvar_q("_align");
+                                       HUD_Write_PanelCvar_q("_flip");
+                                       HUD_Write_PanelCvar_q("_fontscale");
+                                       HUD_Write_PanelCvar_q("_time");
+                                       HUD_Write_PanelCvar_q("_fade_in");
+                                       HUD_Write_PanelCvar_q("_fade_out");
+                                       HUD_Write_PanelCvar_q("_fade_subsequent");
+                                       HUD_Write_PanelCvar_q("_fade_subsequent_passone");
+                                       HUD_Write_PanelCvar_q("_fade_subsequent_passone_minalpha");
+                                       HUD_Write_PanelCvar_q("_fade_subsequent_passtwo");
+                                       HUD_Write_PanelCvar_q("_fade_subsequent_passtwo_minalpha");
+                                       HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize");
+                                       HUD_Write_PanelCvar_q("_fade_minfontsize");
                                        break;
                        }
                        HUD_Write("\n");
                }
                HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
 
-               print("^2Successfully exported to ", filename, "! (Note: It's saved in data/data/)\n");
+               print(sprintf(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename));
                fclose(fh);
        }
        else
-               print("^1Couldn't write to ", filename, "\n");
+               print(sprintf(_("^1Couldn't write to %s\n"), filename));
+}
+
+void HUD_Configure_Exit_Force()
+{
+       if (menu_enabled)
+       {
+               menu_enabled = 0;
+               localcmd("togglemenu\n");
+       }
+       cvar_set("_hud_configure", "0");
 }
 
 // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
@@ -348,7 +417,7 @@ void HUD_Panel_SetPosSize(vector mySize)
        HUD_Panel_UpdatePosSizeForId(highlightedPanel);
        vector resizeorigin;
        resizeorigin = panel_click_resizeorigin;
-       vector myPos;
+       local noref vector myPos; // fteqcc sucks
 
        // minimum panel size cap
        mySize_x = max(0.025 * vid_conwidth, mySize_x);
@@ -543,10 +612,13 @@ void HUD_Panel_Arrow_Action(float nPrimary)
        }
 }
 
+const float S_MOUSE1 = 1;
+const float S_MOUSE2 = 2;
+const float S_MOUSE3 = 4;
 float mouseClicked;
 float prevMouseClicked; // previous state
-float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
-vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
+float prevMouseClickedTime; // time during previous left mouse click, to check for doubleclicks
+vector prevMouseClickedPos; // pos during previous left mouse click, to check for doubleclicks
 
 void HUD_Panel_EnableMenu();
 float tab_panels[HUD_PANEL_NUM];
@@ -563,14 +635,28 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {
        string s;
 
+       if(bInputType == 2)
+               return false;
+
        if(!autocvar__hud_configure)
                return false;
 
+       // block any input while a menu dialog is fading
+       if(autocvar__menu_alpha)
+               return true;
+
+       if(bInputType == 3)
+       {
+               mousepos_x = nPrimary;
+               mousepos_y = nSecondary;
+               return true;
+       }
+
        // allow console bind to work
        string con_keys;
        float keys;
-       con_keys = findkeysforcommand("toggleconsole");
-       keys = tokenize(con_keys);
+       con_keys = findkeysforcommand("toggleconsole", 0);
+       keys = tokenize(con_keys); // findkeysforcommand returns data for this
 
        float hit_con_bind, i;
        for (i = 0; i < keys; ++i)
@@ -608,14 +694,17 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
        if(nPrimary == K_MOUSE1)
        {
-               if(bInputType == 0) { // key pressed
-                       mouseClicked = 1;
-                       return true;
-               }
-               else if(bInputType == 1) {// key released
-                       mouseClicked = 0;
-                       return true;
-               }
+               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(nPrimary == K_ESCAPE)
        {
@@ -625,6 +714,13 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                menu_enabled_time = time;
                localcmd("menu_showhudexit\n");
        }
+       else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
+       {
+               if (bInputType == 1)
+                       return true;
+               if (!menu_enabled)
+                       cvar_set("_hud_configure", "0");
+       }
        else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // select and highlight another panel
        {
                if (bInputType == 1 || mouseClicked)
@@ -657,7 +753,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                float k, level, start_pos_x;
                vector candidate_pos;
                const float LEVELS_NUM = 4;
-               const float level_height = vid_conheight / LEVELS_NUM;
+               float level_height = vid_conheight / LEVELS_NUM;
 :find_tab_panel
                level = floor(tab_panel_pos_y / level_height) * level_height; //starting level
                candidate_pos_x = (!tab_backward) ? vid_conwidth : 0;
@@ -804,7 +900,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
        return true;
 }
 
-float HUD_Panel_Check_Mouse_Pos()
+float HUD_Panel_Check_Mouse_Pos(float allow_move)
 {
        float i, j, border;
 
@@ -818,7 +914,7 @@ float HUD_Panel_Check_Mouse_Pos()
                border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
 
                // move
-               if(mousepos_x >= panel_pos_x && mousepos_y >= panel_pos_y && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= panel_pos_y + panel_size_y)
+               if(allow_move && mousepos_x > panel_pos_x && mousepos_y > panel_pos_y && mousepos_x < panel_pos_x + panel_size_x && mousepos_y < panel_pos_y + panel_size_y)
                {
                        return 1;
                }
@@ -884,7 +980,7 @@ void HUD_Panel_FirstInDrawQ(float id)
        hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
 }
 
-void HUD_Panel_Highlight()
+void HUD_Panel_Highlight(float allow_move)
 {
        float i, j, border;
 
@@ -898,7 +994,7 @@ void HUD_Panel_Highlight()
                border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
 
                // move
-               if(mousepos_x >= panel_pos_x && mousepos_y >= panel_pos_y && mousepos_x <= panel_pos_x + panel_size_x && mousepos_y <= panel_pos_y + panel_size_y)
+               if(allow_move && mousepos_x > panel_pos_x && mousepos_y > panel_pos_y && mousepos_x < panel_pos_x + panel_size_x && mousepos_y < panel_pos_y + panel_size_y)
                {
                        highlightedPanel = i;
                        HUD_Panel_FirstInDrawQ(i);
@@ -974,20 +1070,12 @@ void HUD_Panel_Mouse()
        /*
        print("menu_enabled: ", ftos(menu_enabled), "\n");
        print("Highlighted: ", ftos(highlightedPanel), "\n");
-       print("Menu alpha: ", ftos(autocvar__menu_alpha), "\n");
+       print("Menu theAlpha: ", ftos(autocvar__menu_alpha), "\n");
        */
 
-       // instantly hide the editor cursor if we open the HUDExit dialog
-       // as hud_fade_alpha doesn't decrease to 0 in this case
-       // TODO: find a way to fade the cursor out even in this case
-       if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
+       if(autocvar__menu_alpha == 1)
                return;
 
-       mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
-
-       mousepos_x = bound(0, mousepos_x, vid_conwidth);
-       mousepos_y = bound(0, mousepos_y, vid_conheight);
-
        if(mouseClicked)
        {
                if(prevMouseClicked == 0)
@@ -998,7 +1086,7 @@ void HUD_Panel_Mouse()
                                tab_panel = -1;
                                reset_tab_panels();
                        }
-                       HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
+                       HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
                                                                        // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
                        if (highlightedPanel != -1)
                        {
@@ -1006,15 +1094,19 @@ void HUD_Panel_Mouse()
                                highlightedPanel_initial_size = panel_size;
                        }
                        // doubleclick check
-                       if (time - prevMouseClickedTime < 0.4 && highlightedPanel != -1 && prevMouseClickedPos == mousepos)
+                       if ((mouseClicked & S_MOUSE1) && time - prevMouseClickedTime < 0.4 && highlightedPanel != -1 && prevMouseClickedPos == mousepos)
                        {
                                mouseClicked = 0; // to prevent spam, I guess.
                                HUD_Panel_EnableMenu();
                        }
                        else
                        {
-                               prevMouseClickedTime = time;
-                               prevMouseClickedPos = mousepos;
+                               if (mouseClicked & S_MOUSE1)
+                               {
+                                       prevMouseClickedTime = time;
+                                       prevMouseClickedPos = mousepos;
+                               }
+                               mouse_over_panel = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
                        }
                }
                else
@@ -1064,21 +1156,22 @@ void HUD_Panel_Mouse()
                if(menu_enabled == 2)
                        mouse_over_panel = 0;
                else
-                       mouse_over_panel = HUD_Panel_Check_Mouse_Pos();
+                       mouse_over_panel = HUD_Panel_Check_Mouse_Pos(TRUE);
                if (mouse_over_panel && tab_panel == -1)
                        drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
        }
        // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
        const vector cursorsize = '32 32 0';
+       float cursor_alpha = 1 - autocvar__menu_alpha;
 
        if(!mouse_over_panel)
-               drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
        else if(mouse_over_panel == 1)
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
        else if(mouse_over_panel == 2)
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
        else
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
 
        prevMouseClicked = mouseClicked;
 }
@@ -1086,11 +1179,11 @@ void HUD_Panel_Mouse()
 const float hlBorderSize = 4;
 const string hlBorder = "gfx/hud/default/border_highlighted";
 const string hlBorder2 = "gfx/hud/default/border_highlighted2";
-void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
+void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha)
 {
-       drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * alpha, DRAWFLAG_NORMAL);
-       drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
-       drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size_y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
-       drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
-       drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, alpha, DRAWFLAG_NORMAL);
-}
\ No newline at end of file
+       drawfill(panel_pos - '1 1 0' * myBorder, panel_size + '2 2 0' * myBorder, '0 0.5 1', .5 * theAlpha, DRAWFLAG_NORMAL);
+       drawpic_tiled(panel_pos - '1 1 0' * myBorder, hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL);
+       drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * (panel_size_y + 2 * myBorder - hlBorderSize), hlBorder, '8 1 0' * hlBorderSize, eX * (panel_size_x + 2 * myBorder) + eY * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL);
+       drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize, hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL);
+       drawpic_tiled(panel_pos - '1 1 0' * myBorder + eY * hlBorderSize + eX * (panel_size_x + 2 * myBorder - hlBorderSize), hlBorder2, '1 8 0' * hlBorderSize, eY * (panel_size_y + 2 * myBorder - 2 * hlBorderSize) + eX * hlBorderSize, color, theAlpha, DRAWFLAG_NORMAL);
+}