From: FruitieX Date: Sun, 16 May 2010 18:43:53 +0000 (+0300) Subject: add hud_configure_grid ;). Gridsize can be set manually. Maybe make this default... X-Git-Tag: xonotic-v0.1.0preview~541^2~150 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bcaa418b921e1ad93518cacdf21fae44fce306de;p=xonotic%2Fxonotic-data.pk3dir.git add hud_configure_grid ;). Gridsize can be set manually. Maybe make this default once we have some problems with resizing fixed (this easily reveals those problems, as exactly those test cases happen with this, ie. panel touches another panel in one direction while being resized in the opposite direction) --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index ec4b1d4e8..b6c93ae06 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1339,6 +1339,9 @@ seta hud_progressbar_alpha "0.5" "alpha of progressbars" seta hud_configure_checkcollisions 1 "check for collisions against other panels when in hud configure mode" seta hud_configure_bg_minalpha 0.5 "minimum panel background alpha when in hud configure mode" +seta hud_configure_grid 0 "snap to grid when moving/resizing panels" +seta hud_configure_grid_x 10 "snap each X pixels" +seta hud_configure_grid_y 10 "snap each Y pixels" seta hud_dock 1 "enable/disable a fullscreen background for the hud, useful for creating artificial docks" seta hud_dock_color "0 0.6 0.9" "dock color" diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index e53c10e98..864e1017c 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -852,6 +852,12 @@ float HUD_Panel_SetSize(float id, vector mySize) //mySize_x = bound(0.025 * vid_conwidth, mySize_x, vid_conwidth); //mySize_y = bound(0.025 * vid_conheight, mySize_y, vid_conheight); + if(cvar("hud_configure_grid")) + { + mySize_x = floor(mySize_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x"); + mySize_y = floor(mySize_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y"); + } + // TODO: is this needed? // this is to check if (and how) SetPos should be called if(mySize_x == oldSize_x && mySize_y == oldSize_y) @@ -959,6 +965,12 @@ void HUD_Panel_SetPos(float id, vector pos, float didntresize) pos_x = bound(0, pos_x, vid_conwidth - mySize_x); pos_y = bound(0, pos_y, vid_conheight - mySize_y); + if(cvar("hud_configure_grid")) + { + pos_x = floor(pos_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x"); + pos_y = floor(pos_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y"); + } + if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth) pos_x = pos_x - vid_conwidth; if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)