Skip to content
Snippets Groups Projects
Commit 42c935f2 authored by mcmlxxix's avatar mcmlxxix
Browse files

Made menu display spacing dynamic

parent a5bb9db4
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,15 @@ function Menu(title,x,y,color,hkey_color) ...@@ -64,6 +64,15 @@ function Menu(title,x,y,color,hkey_color)
{ {
printf("\1h\1w" + this.title); printf("\1h\1w" + this.title);
} }
this.countEnabled=function()
{
var items=[];
for(i in this.items)
{
if(this.items[i].enabled) items.push(i);
}
return items;
}
this.getHotKey=function(item) this.getHotKey=function(item)
{ {
keyindex=item.indexOf("~")+1; keyindex=item.indexOf("~")+1;
...@@ -71,11 +80,14 @@ function Menu(title,x,y,color,hkey_color) ...@@ -71,11 +80,14 @@ function Menu(title,x,y,color,hkey_color)
} }
this.displayHorizontal=function() this.displayHorizontal=function()
{ {
var enabled=this.countEnabled();
if(!enabled.length) return false;
ClearLine(1,48); ClearLine(1,48);
console.gotoxy(orig_x,orig_y); console.gotoxy(orig_x,orig_y);
for(i in this.items) for(e=0;e<enabled.length;e++)
{ {
if(this.items[i].enabled) console.putmsg(this.items[i].text); console.putmsg(this.items[enabled[e]].text);
if(e<enabled.length-1) write(" ");
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment