From 4b1c4f466fa39cb065be8c4b141cabde2125ffe0 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 30 May 2015 14:10:48 +0200 Subject: [PATCH] new command menurenderoffset Moves a menu away from the middle of the screen. Values of "100" represent half the screen width and height. menurenderoffset x-offset y-offset DOCREF menurenderoffset --- source/src/menus.cpp | 10 ++++++++++ source/src/protos.h | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 5180c881..fea826fd 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -919,6 +919,14 @@ void menuinitselection(int *line) } COMMAND(menuinitselection, "i"); +void menurenderoffset(int *xoff, int *yoff) +{ + if(!lastmenu) return; + lastmenu->xoffs = *xoff; + lastmenu->yoffs = *yoff; +} +COMMAND(menurenderoffset, "ii"); + void menuselection(char *menu, int *line) { if(!menu || !menus.access(menu)) return; @@ -1348,6 +1356,8 @@ void gmenu::render() int h = (mdisp+hitems+2)*step; int y = (2*VIRTH-h)/2; int x = hotkeys ? (2*VIRTW-w)/6 : (2*VIRTW-w)/2; + x = clamp(x + (VIRTW * xoffs) / 100, 3 * FONTH, 2 * VIRTW - w - 3 * FONTH); + y = clamp(y + (VIRTH * yoffs) / 100, 3 * FONTH, 2 * VIRTH - h - 3 * FONTH); if(!hotkeys) renderbg(x-FONTH*3/2, y-FONTH, x+w+FONTH*3/2, y+h+FONTH, true); if(offset>0) drawarrow(1, x+w+FONTH*3/2-FONTH*5/6, y-FONTH*5/6, FONTH*2/3); if(offset+pagesize