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
This commit is contained in:
ac-stef
2015-06-05 16:00:02 +02:00
parent ca7fbe9f19
commit 4b1c4f466f
2 changed files with 12 additions and 1 deletions
+10
View File
@@ -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<items.length()) drawarrow(0, x+w+FONTH*3/2-FONTH*5/6, y+h+FONTH/6, FONTH*2/3);
+2 -1
View File
@@ -163,9 +163,10 @@ struct gmenu
const char *mdl;
int anim, rotspeed, scale;
int footlen;
int xoffs, yoffs;
mdirlist *dirlist;
gmenu() : name(0), title(0), header(0), footer(0), initaction(0), usefont(0), allowblink(0), mdl(0), footlen(0), dirlist(0) {}
gmenu() : name(0), title(0), header(0), footer(0), initaction(0), usefont(0), allowblink(0), mdl(0), footlen(0), xoffs(0), yoffs(0), dirlist(0) {}
virtual ~gmenu()
{
DELETEA(name);