X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud_config.qc;h=31e865ff0c9995eca5f0ce928867caa8267c43c5;hp=869e30dda0d782f593b9a95e8b60cd371dd94048;hb=845401fd312c66c059aaee1772ac5d79555ab4fc;hpb=3b2bc1bdee04f4c454279bf14ac8ed6b37c6ddb5 diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index 869e30dda..31e865ff0 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"); @@ -193,11 +197,11 @@ void HUD_Panel_ExportCfg(string cfgname) } HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated - print(sprintf(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename)); + printf(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename); fclose(fh); } else - print(sprintf(_("^1Couldn't write to %s\n"), filename)); + printf(_("^1Couldn't write to %s\n"), filename); } void HUD_Configure_Exit_Force() @@ -213,11 +217,9 @@ void HUD_Configure_Exit_Force() // check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector vector HUD_Panel_CheckMove(vector myPos, vector mySize) { - float i; - float myCenter_x, myCenter_y, targCenter_x, targCenter_y; - vector myTarget; - myTarget = myPos; - + vector myCenter, targCenter; + vector myTarget = myPos; + int i; for (i = 0; i < HUD_PANEL_NUM; ++i) { panel = hud_panel[i]; if(panel == highlightedPanel) continue; @@ -227,51 +229,51 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize) panel_pos -= '1 1 0' * panel_bg_border; panel_size += '2 2 0' * panel_bg_border; - if(myPos_y + mySize_y < panel_pos_y) + if(myPos.y + mySize.y < panel_pos.y) continue; - if(myPos_y > panel_pos_y + panel_size_y) + if(myPos.y > panel_pos.y + panel_size.y) continue; - if(myPos_x + mySize_x < panel_pos_x) + if(myPos.x + mySize.x < panel_pos.x) continue; - if(myPos_x > panel_pos_x + panel_size_x) + if(myPos.x > panel_pos.x + panel_size.x) continue; // OK, there IS a collision. - myCenter_x = myPos_x + 0.5 * mySize_x; - myCenter_y = myPos_y + 0.5 * mySize_y; + myCenter_x = myPos.x + 0.5 * mySize.x; + myCenter_y = myPos.y + 0.5 * mySize.y; - targCenter_x = panel_pos_x + 0.5 * panel_size_x; - targCenter_y = panel_pos_y + 0.5 * panel_size_y; + targCenter_x = panel_pos.x + 0.5 * panel_size.x; + targCenter_y = panel_pos.y + 0.5 * panel_size.y; - if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel) + if(myCenter.x < targCenter.x && myCenter.y < targCenter.y) // top left (of the target panel) { - if(myPos_x + mySize_x - panel_pos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side - myTarget_x = panel_pos_x - mySize_x; + if(myPos.x + mySize.x - panel_pos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side + myTarget_x = panel_pos.x - mySize.x; else // push it upwards - myTarget_y = panel_pos_y - mySize_y; + myTarget_y = panel_pos.y - mySize.y; } - else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right + else if(myCenter.x > targCenter.x && myCenter.y < targCenter.y) // top right { - if(panel_pos_x + panel_size_x - myPos_x < myPos_y + mySize_y - panel_pos_y) // push it to the side - myTarget_x = panel_pos_x + panel_size_x; + if(panel_pos.x + panel_size.x - myPos.x < myPos.y + mySize.y - panel_pos.y) // push it to the side + myTarget_x = panel_pos.x + panel_size.x; else // push it upwards - myTarget_y = panel_pos_y - mySize_y; + myTarget_y = panel_pos.y - mySize.y; } - else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left + else if(myCenter.x < targCenter.x && myCenter.y > targCenter.y) // bottom left { - if(myPos_x + mySize_x - panel_pos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side - myTarget_x = panel_pos_x - mySize_x; + if(myPos.x + mySize.x - panel_pos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side + myTarget_x = panel_pos.x - mySize.x; else // push it downwards - myTarget_y = panel_pos_y + panel_size_y; + myTarget_y = panel_pos.y + panel_size.y; } - else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right + else if(myCenter.x > targCenter.x && myCenter.y > targCenter.y) // bottom right { - if(panel_pos_x + panel_size_x - myPos_x < panel_pos_y + panel_size_y - myPos_y) // push it to the side - myTarget_x = panel_pos_x + panel_size_x; + if(panel_pos.x + panel_size.x - myPos.x < panel_pos.y + panel_size.y - myPos.y) // push it to the side + myTarget_x = panel_pos.x + panel_size.x; else // push it downwards - myTarget_y = panel_pos_y + panel_size_y; + myTarget_y = panel_pos.y + panel_size.y; } //if(cvar("hud_configure_checkcollisions_debug")) //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL); @@ -292,18 +294,18 @@ void HUD_Panel_SetPos(vector pos) if(autocvar_hud_configure_grid) { - pos_x = floor((pos_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x; - pos_y = floor((pos_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y; + pos_x = floor((pos.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x; + pos_y = floor((pos.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y; } if(hud_configure_checkcollisions) pos = HUD_Panel_CheckMove(pos, mySize); - pos_x = bound(0, pos_x, vid_conwidth - mySize_x); - pos_y = bound(0, pos_y, vid_conheight - mySize_y); + pos_x = bound(0, pos.x, vid_conwidth - mySize.x); + pos_y = bound(0, pos.y, vid_conheight - mySize.y); string s; - s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight)); + s = strcat(ftos(pos.x/vid_conwidth), " ", ftos(pos.y/vid_conheight)); cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s); } @@ -314,9 +316,9 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) { vector targEndPos; - float dist_x, dist_y; + vector dist; float ratio; - ratio = mySize_x/mySize_y; + ratio = mySize.x/mySize.y; for (i = 0; i < HUD_PANEL_NUM; ++i) { panel = hud_panel[i]; @@ -330,19 +332,19 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) { targEndPos = panel_pos + panel_size; // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour! - if(resizeorigin_x > panel_pos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > panel_pos_y && resizeorigin_y < targEndPos_y) + if(resizeorigin.x > panel_pos.x && resizeorigin.x < targEndPos.x && resizeorigin.y > panel_pos.y && resizeorigin.y < targEndPos.y) continue; if (resizeCorner == 1) { // check if this panel is on our way - if (resizeorigin_x <= panel_pos_x) + if (resizeorigin.x <= panel_pos.x) continue; - if (resizeorigin_y <= panel_pos_y) + if (resizeorigin.y <= panel_pos.y) continue; - if (targEndPos_x <= resizeorigin_x - mySize_x) + if (targEndPos.x <= resizeorigin.x - mySize.x) continue; - if (targEndPos_y <= resizeorigin_y - mySize_y) + if (targEndPos.y <= resizeorigin.y - mySize.y) continue; // there is a collision: @@ -351,66 +353,66 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) { // // dist is the distance between resizeorigin and the "analogous" point of the panel // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel - dist_x = resizeorigin_x - targEndPos_x; - dist_y = resizeorigin_y - targEndPos_y; - if (dist_y <= 0 || dist_x / dist_y > ratio) - mySize_x = min(mySize_x, dist_x); + dist_x = resizeorigin.x - targEndPos.x; + dist_y = resizeorigin.y - targEndPos.y; + if (dist.y <= 0 || dist.x / dist.y > ratio) + mySize_x = min(mySize.x, dist.x); else - mySize_y = min(mySize_y, dist_y); + mySize_y = min(mySize.y, dist.y); } else if (resizeCorner == 2) { - if (resizeorigin_x >= targEndPos_x) + if (resizeorigin.x >= targEndPos.x) continue; - if (resizeorigin_y <= panel_pos_y) + if (resizeorigin.y <= panel_pos.y) continue; - if (panel_pos_x >= resizeorigin_x + mySize_x) + if (panel_pos.x >= resizeorigin.x + mySize.x) continue; - if (targEndPos_y <= resizeorigin_y - mySize_y) + if (targEndPos.y <= resizeorigin.y - mySize.y) continue; - dist_x = panel_pos_x - resizeorigin_x; - dist_y = resizeorigin_y - targEndPos_y; - if (dist_y <= 0 || dist_x / dist_y > ratio) - mySize_x = min(mySize_x, dist_x); + dist_x = panel_pos.x - resizeorigin.x; + dist_y = resizeorigin.y - targEndPos.y; + if (dist.y <= 0 || dist.x / dist.y > ratio) + mySize_x = min(mySize.x, dist.x); else - mySize_y = min(mySize_y, dist_y); + mySize_y = min(mySize.y, dist.y); } else if (resizeCorner == 3) { - if (resizeorigin_x <= panel_pos_x) + if (resizeorigin.x <= panel_pos.x) continue; - if (resizeorigin_y >= targEndPos_y) + if (resizeorigin.y >= targEndPos.y) continue; - if (targEndPos_x <= resizeorigin_x - mySize_x) + if (targEndPos.x <= resizeorigin.x - mySize.x) continue; - if (panel_pos_y >= resizeorigin_y + mySize_y) + if (panel_pos.y >= resizeorigin.y + mySize.y) continue; - dist_x = resizeorigin_x - targEndPos_x; - dist_y = panel_pos_y - resizeorigin_y; - if (dist_y <= 0 || dist_x / dist_y > ratio) - mySize_x = min(mySize_x, dist_x); + dist_x = resizeorigin.x - targEndPos.x; + dist_y = panel_pos.y - resizeorigin.y; + if (dist.y <= 0 || dist.x / dist.y > ratio) + mySize_x = min(mySize.x, dist.x); else - mySize_y = min(mySize_y, dist_y); + mySize_y = min(mySize.y, dist.y); } else if (resizeCorner == 4) { - if (resizeorigin_x >= targEndPos_x) + if (resizeorigin.x >= targEndPos.x) continue; - if (resizeorigin_y >= targEndPos_y) + if (resizeorigin.y >= targEndPos.y) continue; - if (panel_pos_x >= resizeorigin_x + mySize_x) + if (panel_pos.x >= resizeorigin.x + mySize.x) continue; - if (panel_pos_y >= resizeorigin_y + mySize_y) + if (panel_pos.y >= resizeorigin.y + mySize.y) continue; - dist_x = panel_pos_x - resizeorigin_x; - dist_y = panel_pos_y - resizeorigin_y; - if (dist_y <= 0 || dist_x / dist_y > ratio) - mySize_x = min(mySize_x, dist_x); + dist_x = panel_pos.x - resizeorigin.x; + dist_y = panel_pos.y - resizeorigin.y; + if (dist.y <= 0 || dist.x / dist.y > ratio) + mySize_x = min(mySize.x, dist.x); else - mySize_y = min(mySize_y, dist_y); + mySize_y = min(mySize.y, dist.y); } //if(cvar("hud_configure_checkcollisions_debug")) //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL); @@ -425,16 +427,16 @@ void HUD_Panel_SetPosSize(vector mySize) HUD_Panel_UpdatePosSize() vector resizeorigin; resizeorigin = panel_click_resizeorigin; - local noref vector myPos; // fteqcc sucks + vector myPos; // minimum panel size cap - mySize_x = max(0.025 * vid_conwidth, mySize_x); - mySize_y = max(0.025 * vid_conheight, mySize_y); + mySize_x = max(0.025 * vid_conwidth, mySize.x); + mySize_y = max(0.025 * vid_conheight, mySize.y); if(highlightedPanel == HUD_PANEL(CHAT)) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small. { - mySize_x = max(17 * autocvar_con_chatsize, mySize_x); - mySize_y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize_y); + mySize_x = max(17 * autocvar_con_chatsize, mySize.x); + mySize_y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize.y); } // collision testing| @@ -442,30 +444,30 @@ void HUD_Panel_SetPosSize(vector mySize) // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?) if(resizeCorner == 1) { - myPos_x = resizeorigin_x - mySize_x; - myPos_y = resizeorigin_y - mySize_y; + myPos_x = resizeorigin.x - mySize.x; + myPos_y = resizeorigin.y - mySize.y; } else if(resizeCorner == 2) { - myPos_x = resizeorigin_x; - myPos_y = resizeorigin_y - mySize_y; + myPos_x = resizeorigin.x; + myPos_y = resizeorigin.y - mySize.y; } else if(resizeCorner == 3) { - myPos_x = resizeorigin_x - mySize_x; - myPos_y = resizeorigin_y; + myPos_x = resizeorigin.x - mySize.x; + myPos_y = resizeorigin.y; } else { // resizeCorner == 4 - myPos_x = resizeorigin_x; - myPos_y = resizeorigin_y; + myPos_x = resizeorigin.x; + myPos_y = resizeorigin.y; } // left/top screen edges - if(myPos_x < 0) - mySize_x = mySize_x + myPos_x; - if(myPos_y < 0) - mySize_y = mySize_y + myPos_y; + if(myPos.x < 0) + mySize_x = mySize.x + myPos.x; + if(myPos.y < 0) + mySize_y = mySize.y + myPos.y; // bottom/right screen edges - if(myPos_x + mySize_x > vid_conwidth) - mySize_x = vid_conwidth - myPos_x; - if(myPos_y + mySize_y > vid_conheight) - mySize_y = vid_conheight - myPos_y; + if(myPos.x + mySize.x > vid_conwidth) + mySize_x = vid_conwidth - myPos.x; + if(myPos.y + mySize.y > vid_conheight) + mySize_y = vid_conheight - myPos.y; //if(cvar("hud_configure_checkcollisions_debug")) //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL); @@ -473,40 +475,40 @@ void HUD_Panel_SetPosSize(vector mySize) // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken if(autocvar_hud_configure_grid) { - mySize_x = floor((mySize_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x; - mySize_y = floor((mySize_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y; + mySize_x = floor((mySize.x/vid_conwidth)/hud_configure_gridSize.x + 0.5) * hud_configure_realGridSize.x; + mySize_y = floor((mySize.y/vid_conheight)/hud_configure_gridSize.y + 0.5) * hud_configure_realGridSize.y; } if(hud_configure_checkcollisions) mySize = HUD_Panel_CheckResize(mySize, resizeorigin); // minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then) - mySize_x = max(0.025 * vid_conwidth, mySize_x); - mySize_y = max(0.025 * vid_conheight, mySize_y); + mySize_x = max(0.025 * vid_conwidth, mySize.x); + mySize_y = max(0.025 * vid_conheight, mySize.y); // do another pos check, as size might have changed by now if(resizeCorner == 1) { - myPos_x = resizeorigin_x - mySize_x; - myPos_y = resizeorigin_y - mySize_y; + myPos_x = resizeorigin.x - mySize.x; + myPos_y = resizeorigin.y - mySize.y; } else if(resizeCorner == 2) { - myPos_x = resizeorigin_x; - myPos_y = resizeorigin_y - mySize_y; + myPos_x = resizeorigin.x; + myPos_y = resizeorigin.y - mySize.y; } else if(resizeCorner == 3) { - myPos_x = resizeorigin_x - mySize_x; - myPos_y = resizeorigin_y; + myPos_x = resizeorigin.x - mySize.x; + myPos_y = resizeorigin.y; } else { // resizeCorner == 4 - myPos_x = resizeorigin_x; - myPos_y = resizeorigin_y; + myPos_x = resizeorigin.x; + myPos_y = resizeorigin.y; } //if(cvar("hud_configure_checkcollisions_debug")) //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL); string s; - s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight)); + s = strcat(ftos(mySize.x/vid_conwidth), " ", ftos(mySize.y/vid_conheight)); cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s); - s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight)); + s = strcat(ftos(myPos.x/vid_conwidth), " ", ftos(myPos.y/vid_conheight)); cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_pos"), s); } @@ -525,16 +527,16 @@ void HUD_Panel_Arrow_Action(float nPrimary) if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW) { if (hudShiftState & S_SHIFT) - step = hud_configure_realGridSize_y; + step = hud_configure_realGridSize.y; else - step = 2 * hud_configure_realGridSize_y; + step = 2 * hud_configure_realGridSize.y; } else { if (hudShiftState & S_SHIFT) - step = hud_configure_realGridSize_x; + step = hud_configure_realGridSize.x; else - step = 2 * hud_configure_realGridSize_x; + step = 2 * hud_configure_realGridSize.x; } } else @@ -580,15 +582,15 @@ void HUD_Panel_Arrow_Action(float nPrimary) panel_click_resizeorigin = panel_pos; if(resizeCorner == 1) { panel_click_resizeorigin += mySize; - mySize_y += step; + mySize.y += step; } else if(resizeCorner == 2) { - panel_click_resizeorigin_y += mySize_y; - mySize_x += step; + panel_click_resizeorigin.y += mySize.y; + mySize.x += step; } else if(resizeCorner == 3) { - panel_click_resizeorigin_x += mySize_x; - mySize_x += step; + panel_click_resizeorigin.x += mySize.x; + mySize.x += step; } else { // resizeCorner == 4 - mySize_y += step; + mySize.y += step; } HUD_Panel_SetPosSize(mySize); } @@ -598,13 +600,13 @@ void HUD_Panel_Arrow_Action(float nPrimary) vector pos; pos = panel_pos; if(nPrimary == K_UPARROW) - pos_y -= step; + pos.y -= step; else if(nPrimary == K_DOWNARROW) - pos_y += step; + pos.y += step; else if(nPrimary == K_LEFTARROW) - pos_x -= step; + pos.x -= step; else // if(nPrimary == K_RIGHTARROW) - pos_x += step; + pos.x += step; HUD_Panel_SetPos(pos); } @@ -621,11 +623,11 @@ 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 +const int S_MOUSE1 = 1; +const int S_MOUSE2 = 2; +const int S_MOUSE3 = 4; +int mouseClicked; +int prevMouseClicked; // previous state float prevMouseClickedTime; // time during previous left mouse click, to check for doubleclicks vector prevMouseClickedPos; // pos during previous left mouse click, to check for doubleclicks @@ -651,10 +653,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 +660,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 +728,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) @@ -763,14 +769,14 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) } tab_backward = (hudShiftState & S_SHIFT); - float k, level = 0, start_pos_x; + float k, level = 0, start_posX; vector candidate_pos = '0 0 0'; const float LEVELS_NUM = 4; float level_height = vid_conheight / LEVELS_NUM; :find_tab_panel - level = floor(tab_panel_pos_y / level_height) * level_height; //starting level + level = floor(tab_panel_pos.y / level_height) * level_height; //starting level candidate_pos_x = (!tab_backward) ? vid_conwidth : 0; - start_pos_x = tab_panel_pos_x; + start_posX = tab_panel_pos.x; tab_panel = world; k=0; while(++k) @@ -781,9 +787,9 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) if (panel == tab_panels[i] || panel == starting_panel) continue; HUD_Panel_UpdatePosSize() - if (panel_pos_y >= level && (panel_pos_y - level) < level_height) - if ( ( !tab_backward && panel_pos_x >= start_pos_x && (panel_pos_x < candidate_pos_x || (panel_pos_x == candidate_pos_x && panel_pos_y <= candidate_pos_y)) ) - || ( tab_backward && panel_pos_x <= start_pos_x && (panel_pos_x > candidate_pos_x || (panel_pos_x == candidate_pos_x && panel_pos_y >= candidate_pos_y)) ) ) + if (panel_pos.y >= level && (panel_pos.y - level) < level_height) + if ( ( !tab_backward && panel_pos.x >= start_posX && (panel_pos.x < candidate_pos.x || (panel_pos_x == candidate_pos.x && panel_pos.y <= candidate_pos.y)) ) + || ( tab_backward && panel_pos.x <= start_posX && (panel_pos.x > candidate_pos.x || (panel_pos_x == candidate_pos.x && panel_pos.y >= candidate_pos.y)) ) ) { tab_panel = panel; tab_panel_pos = candidate_pos = panel_pos; @@ -805,14 +811,14 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) } if (!tab_backward) { - level = mod(level + level_height, vid_conheight); - start_pos_x = 0; + level = (level + level_height) % vid_conheight; + start_posX = 0; candidate_pos_x = vid_conwidth; } else { - level = mod(level - level_height, vid_conheight); - start_pos_x = vid_conwidth; + level = (level - level_height) % vid_conheight; + start_posX = vid_conwidth; candidate_pos_x = 0; } } @@ -854,10 +860,10 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) // reduce size if it'd go beyond screen boundaries vector tmp_size = panel_size_copied; - if (panel_pos_x + panel_size_copied_x > vid_conwidth) - tmp_size_x = vid_conwidth - panel_pos_x; - if (panel_pos_y + panel_size_copied_y > vid_conheight) - tmp_size_y = vid_conheight - panel_pos_y; + if (panel_pos.x + panel_size_copied.x > vid_conwidth) + tmp_size_x = vid_conwidth - panel_pos.x; + if (panel_pos.y + panel_size_copied.y > vid_conheight) + tmp_size_y = vid_conheight - panel_pos.y; if (panel_size == tmp_size) return true; @@ -867,7 +873,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) panel_size_backup = panel_size; highlightedPanel_backup = highlightedPanel; - s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight)); + s = strcat(ftos(tmp_size.x/vid_conwidth), " ", ftos(tmp_size.y/vid_conheight)); cvar_set(strcat("hud_panel_", highlightedPanel.panel_name, "_size"), s); } else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action @@ -877,9 +883,9 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) //restore previous values if (highlightedPanel_backup) { - s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight)); + s = strcat(ftos(panel_pos_backup.x/vid_conwidth), " ", ftos(panel_pos_backup.y/vid_conheight)); cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_pos"), s); - s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight)); + s = strcat(ftos(panel_size_backup.x/vid_conwidth), " ", ftos(panel_size_backup.y/vid_conheight)); cvar_set(strcat("hud_panel_", highlightedPanel_backup.panel_name, "_size"), s); highlightedPanel_backup = world; } @@ -925,27 +931,27 @@ float HUD_Panel_Check_Mouse_Pos(float allow_move) border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize // move - 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) + 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; } // resize from topleft border - else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + 0.5 * panel_size_y) + else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y) { return 2; } // resize from topright border - else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + 0.5 * panel_size_y) + else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y) { return 3; } // resize from bottomleft border - else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + panel_size_y + border) + else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border) { return 3; } // resize from bottomright border - else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + panel_size_y + border) + else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border) { return 2; } @@ -956,8 +962,8 @@ float HUD_Panel_Check_Mouse_Pos(float allow_move) // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else) void HUD_Panel_FirstInDrawQ(float id) { - float i; - var float place = -1; + int i; + int place = -1; // find out where in the array our current id is, save into place for(i = 0; i < HUD_PANEL_NUM; ++i) { @@ -1006,7 +1012,7 @@ void HUD_Panel_Highlight(float allow_move) border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize // move - 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) + 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 = hud_panel[i]; HUD_Panel_FirstInDrawQ(i); @@ -1015,7 +1021,7 @@ void HUD_Panel_Highlight(float allow_move) return; } // resize from topleft border - else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + 0.5 * panel_size_y) + else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y) { highlightedPanel = hud_panel[i]; HUD_Panel_FirstInDrawQ(i); @@ -1026,31 +1032,31 @@ void HUD_Panel_Highlight(float allow_move) return; } // resize from topright border - else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y - border && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + 0.5 * panel_size_y) + else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y) { highlightedPanel = hud_panel[i]; HUD_Panel_FirstInDrawQ(i); highlightedAction = 2; resizeCorner = 2; - panel_click_distance_x = panel_size_x - mousepos_x + panel_pos_x; - panel_click_distance_y = mousepos_y - panel_pos_y; - panel_click_resizeorigin = panel_pos + eY * panel_size_y; + panel_click_distance_x = panel_size.x - mousepos.x + panel_pos.x; + panel_click_distance_y = mousepos.y - panel_pos.y; + panel_click_resizeorigin = panel_pos + eY * panel_size.y; return; } // resize from bottomleft border - else if(mousepos_x >= panel_pos_x - border && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + 0.5 * panel_size_x && mousepos_y <= panel_pos_y + panel_size_y + border) + else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border) { highlightedPanel = hud_panel[i]; HUD_Panel_FirstInDrawQ(i); highlightedAction = 2; resizeCorner = 3; - panel_click_distance_x = mousepos_x - panel_pos_x; - panel_click_distance_y = panel_size_y - mousepos_y + panel_pos_y; - panel_click_resizeorigin = panel_pos + eX * panel_size_x; + panel_click_distance_x = mousepos.x - panel_pos.x; + panel_click_distance_y = panel_size.y - mousepos.y + panel_pos.y; + panel_click_resizeorigin = panel_pos + eX * panel_size.x; return; } // resize from bottomright border - else if(mousepos_x >= panel_pos_x + 0.5 * panel_size_x && mousepos_y >= panel_pos_y + 0.5 * panel_size_y && mousepos_x <= panel_pos_x + panel_size_x + border && mousepos_y <= panel_pos_y + panel_size_y + border) + else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border) { highlightedPanel = hud_panel[i]; HUD_Panel_FirstInDrawQ(i); @@ -1068,22 +1074,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; @@ -1091,8 +1086,8 @@ void HUD_Panel_Mouse() { mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed; - mousepos_x = bound(0, mousepos_x, vid_conwidth); - mousepos_y = bound(0, mousepos_y, vid_conheight); + mousepos_x = bound(0, mousepos.x, vid_conwidth); + mousepos_y = bound(0, mousepos.y, vid_conheight); } if(mouseClicked) @@ -1158,17 +1153,17 @@ void HUD_Panel_Mouse() { vector mySize = '0 0 0'; if(resizeCorner == 1) { - mySize_x = panel_click_resizeorigin_x - (mousepos_x - panel_click_distance_x); - mySize_y = panel_click_resizeorigin_y - (mousepos_y - panel_click_distance_y); + mySize_x = panel_click_resizeorigin.x - (mousepos.x - panel_click_distance.x); + mySize_y = panel_click_resizeorigin.y - (mousepos.y - panel_click_distance.y); } else if(resizeCorner == 2) { - mySize_x = mousepos_x + panel_click_distance_x - panel_click_resizeorigin_x; - mySize_y = panel_click_distance_y + panel_click_resizeorigin_y - mousepos_y; + mySize_x = mousepos.x + panel_click_distance.x - panel_click_resizeorigin.x; + mySize_y = panel_click_distance.y + panel_click_resizeorigin.y - mousepos.y; } else if(resizeCorner == 3) { - mySize_x = panel_click_resizeorigin_x + panel_click_distance_x - mousepos_x; - mySize_y = mousepos_y + panel_click_distance_y - panel_click_resizeorigin_y; + mySize_x = panel_click_resizeorigin.x + panel_click_distance.x - mousepos.x; + mySize_y = mousepos.y + panel_click_distance.y - panel_click_resizeorigin.y; } else { // resizeCorner == 4 - mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x); - mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y); + mySize_x = mousepos.x - (panel_click_resizeorigin.x - panel_click_distance.x); + mySize_y = mousepos.y - (panel_click_resizeorigin.y - panel_click_distance.y); } HUD_Panel_SetPosSize(mySize); } @@ -1178,7 +1173,7 @@ void HUD_Panel_Mouse() if(menu_enabled == 2) mouse_over_panel = 0; else - mouse_over_panel = HUD_Panel_Check_Mouse_Pos(TRUE); + mouse_over_panel = HUD_Panel_Check_Mouse_Pos(true); if (mouse_over_panel && !tab_panel) drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL); } @@ -1197,15 +1192,94 @@ 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); + } +} -const float hlBorderSize = 4; +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 = 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) { 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); + 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); +} + +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)); + } + } }