I fixed a few things to make the MsgBox more generalized so that you can make it whatever size you want and the choices will still be in the right placement.
//Arguments == MsgBox(x,y,w1,w2,h,xo,yo) w1 is for the window, w2 is for the text box
this.txt_h = Math.floor(h/12);
this.txt_w = Math.floor(w2/2);
The while loop now looks like this
while(!done)
{
RenderMap();
this.window.drawWindow(x,y,w1,h);
var column = 0;
var r = -1;
for(var i=0;i<choices.length;++i){
r = ++r;
if (i == this.txt_h){column = 1;r = 0;}
var choice_x = this.x + column * this.txt_w;
var choice_y = this.y + r * 12;
if (i == choice)this.setcolor(color_2);
this.font.drawText(choice_x,choice_y, choices[i]);
this.setcolor(color_1);
}
But I need to find a ratio between the numbers to fix the case statements for case KEY_RIGHT and case KEY_LEFT
case KEY_RIGHT: if (choice <= 3 && choices.length > 3) choice = choice + 4; break;
case KEY_LEFT: if (choice >= 4) choice = choice - 4; break;
choice + 4 and choice - 4 wont cut it.
For example in the attached screenshot if I press right and I am at choice == 7 it will jump to choice == 11 not choice == 22.
Is there a math formula for this sort of thing?