From e7de5c7d478e65c9a52aff9917529e8aac3a9e7c Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 23 Aug 2010 01:30:53 +0200 Subject: [PATCH] ctrl-v: reduce size if it'd go beyond screen boundaries --- qcsrc/client/hud.qc | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 5c69b9f7f..b0ea78197 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1095,17 +1095,29 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) if (bInputType == 1) return true; - if (highlightedPanel_copied != -1 && highlightedPanel_prev != -1) - { - // backup first! - panel_pos_backup = panel_pos; - panel_size_backup = panel_size; - highlightedPanel_backup = highlightedPanel_prev; + if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1) + return true; - string s; - s = strcat(ftos(panel_size_copied_x/vid_conwidth), " ", ftos(panel_size_copied_y/vid_conheight)); - cvar_set(strcat("hud_panel_", panel_name, "_size"), s); - } + HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev) + + // 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_size == tmp_size) + return true; + + // backup first! + panel_pos_backup = panel_pos; + panel_size_backup = panel_size; + highlightedPanel_backup = highlightedPanel_prev; + + string s; + s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight)); + cvar_set(strcat("hud_panel_", panel_name, "_size"), s); } else if(nPrimary == 'z') // undo last action { -- 2.39.2