From 42c935f2297b676dba693fc172d02db1cc2b261a Mon Sep 17 00:00:00 2001 From: mcmlxxix <> Date: Thu, 9 Apr 2009 01:11:11 +0000 Subject: [PATCH] Made menu display spacing dynamic --- xtrn/chess/menu.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xtrn/chess/menu.js b/xtrn/chess/menu.js index 3e2f0bc066..95e35a8f1a 100644 --- a/xtrn/chess/menu.js +++ b/xtrn/chess/menu.js @@ -64,6 +64,15 @@ function Menu(title,x,y,color,hkey_color) { 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) { keyindex=item.indexOf("~")+1; @@ -71,11 +80,14 @@ function Menu(title,x,y,color,hkey_color) } this.displayHorizontal=function() { + var enabled=this.countEnabled(); + if(!enabled.length) return false; ClearLine(1,48); 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(" "); } } } -- GitLab