X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud_config.qc;h=e19e2378754b1d4052fd3ecdf9eb1195b2ca3cdf;hb=c5184c4799e76d3b4e214dfcfc152d42b85df66c;hp=d361454843feea745f877ba898872a4dd2ea467a;hpb=b7d32c1f333da63877913b30c861230243ce1213;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index d36145484..e19e23787 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -67,6 +67,7 @@ void HUD_Panel_ExportCfg(string cfgname) case HUD_PANEL_WEAPONS: HUD_Write_PanelCvar_q("_accuracy"); HUD_Write_PanelCvar_q("_label"); + HUD_Write_PanelCvar_q("_label_scale"); HUD_Write_PanelCvar_q("_complainbubble"); HUD_Write_PanelCvar_q("_complainbubble_padding"); HUD_Write_PanelCvar_q("_complainbubble_time"); @@ -88,6 +89,8 @@ void HUD_Panel_ExportCfg(string cfgname) break; case HUD_PANEL_AMMO: HUD_Write_PanelCvar_q("_onlycurrent"); + HUD_Write_PanelCvar_q("_noncurrent_alpha"); + HUD_Write_PanelCvar_q("_noncurrent_scale"); HUD_Write_PanelCvar_q("_iconalign"); HUD_Write_PanelCvar_q("_progressbar"); HUD_Write_PanelCvar_q("_progressbar_name"); @@ -119,6 +122,7 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_PanelCvar_q("_fontsize"); HUD_Write_PanelCvar_q("_time"); HUD_Write_PanelCvar_q("_fadetime"); + HUD_Write_PanelCvar_q("_icon_aspect"); break; case HUD_PANEL_TIMER: HUD_Write_PanelCvar_q("_increment"); @@ -651,10 +655,6 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) 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; @@ -662,6 +662,15 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) return true; } + // block any input while a menu dialog is fading + // don't block mousepos read as it leads to cursor jumps in the interaction with the menu + if(autocvar__menu_alpha) + { + hudShiftState = 0; + mouseClicked = 0; + return true; + } + // allow console bind to work string con_keys; float keys; @@ -721,7 +730,6 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) if (bInputType == 1) return true; menu_enabled = 1; - menu_enabled_time = time; localcmd("menu_showhudexit\n"); } else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL) @@ -805,13 +813,13 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) } if (!tab_backward) { - level = mod(level + level_height, vid_conheight); + level = (level + level_height) % vid_conheight; start_pos_x = 0; candidate_pos_x = vid_conwidth; } else { - level = mod(level - level_height, vid_conheight); + level = (level - level_height) % vid_conheight; start_pos_x = vid_conwidth; candidate_pos_x = 0; } @@ -1068,22 +1076,11 @@ void HUD_Panel_Highlight(float allow_move) void HUD_Panel_EnableMenu() { menu_enabled = 2; - menu_enabled_time = time; localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n"); } float mouse_over_panel; void HUD_Panel_Mouse() { - // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled - if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5) - menu_enabled = 0; - - /* - print("menu_enabled: ", ftos(menu_enabled), "\n"); - print("Highlighted: ", ftos(highlightedPanel), "\n"); - print("Menu theAlpha: ", ftos(autocvar__menu_alpha), "\n"); - */ - if(autocvar__menu_alpha == 1) return; @@ -1197,8 +1194,68 @@ void HUD_Panel_Mouse() prevMouseClicked = mouseClicked; } +void HUD_Configure_DrawGrid() +{ + float i; + if(autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha) + { + hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2); + hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2); + hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth; + hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight; + vector s; + // x-axis + s = eX + eY * vid_conheight; + for(i = 1; i < 1/hud_configure_gridSize_x; ++i) + drawfill(eX * i * hud_configure_realGridSize_x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL); + // y-axis + s = eY + eX * vid_conwidth; + for(i = 1; i < 1/hud_configure_gridSize_y; ++i) + drawfill(eY * i * hud_configure_realGridSize_y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL); + } +} + +float _menu_alpha_prev; +void HUD_Configure_Frame() +{ + float i; + if(autocvar__hud_configure) + { + if(isdemo() || intermission == 2) + { + HUD_Configure_Exit_Force(); + return; + } + + if(!hud_configure_prev || hud_configure_prev == -1) + { + if(autocvar_hud_cursormode) + setcursormode(1); + hudShiftState = 0; + for(i = HUD_PANEL_NUM - 1; i >= 0; --i) + hud_panel[panel_order[i]].update_time = time; + } + + // NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled + if(autocvar__menu_alpha != _menu_alpha_prev) + { + if(autocvar__menu_alpha == 0) + menu_enabled = 0; + _menu_alpha_prev = autocvar__menu_alpha; + } + + HUD_Configure_DrawGrid(); + } + else if(hud_configure_prev) + { + if(menu_enabled) + menu_enabled = 0; + if(autocvar_hud_cursormode) + setcursormode(0); + } +} -const float hlBorderSize = 4; +const float hlBorderSize = 2; 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 theAlpha) @@ -1209,3 +1266,22 @@ void HUD_Panel_HlBorder(float myBorder, vector color, float theAlpha) 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); } + +void HUD_Configure_PostDraw() +{ + if(autocvar__hud_configure) + { + if(tab_panel) + { + panel = tab_panel; + HUD_Panel_UpdatePosSize() + drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL); + } + if(highlightedPanel) + { + panel = highlightedPanel; + HUD_Panel_UpdatePosSize() + HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha)); + } + } +}