this.drawChoice = function(choices) { var done = false; var choice = 0; while (!done) { RenderMap(); // ... draw the textboxes and text and stuff ... this.arrow.blit(this.x, this.y + choice * 16); for (var i = 0; i < choices.length; ++i) { this.font.drawText(this.x + 16, this.y + i * 16, choices[i]); } FlipScreen(); while (AreKeysLeft()) { switch (GetKey()) { case KEY_X: done = true; break; case KEY_DOWN: if (choice < choices.length-1) choice++; break; case KEY_UP: if (choice > 0) choice--; break; case KEY_ENTER: done = true; } } } return choice; // this is important!}
switch (textbox.showChoice(["Hi.", "Who are you?", "Go away fool!"])){ case 0: break; // maps to choice 0 case 1: break; // maps to choice 1 case 2: break; // maps to choice 2}
for (var i = 0; i < choices.length; ++i) { if (i == choice) { this.font.setColorMask(yellow); } this.font.drawText(this.x + 16, this.y + i * 16, choices[i]); this.font.setColorMask(white); }
function faceplayer(){var player_direction = GetPersonDirection(player); switch (player_direction) { case "north": return "south" ; break; case "east" : return "west" ; break; case "south": return "north" ; break; case "west" : return "east" ; break; }}
SetPersonDirection("seishin",faceplayer());
if (this.y + i*12 > h && i==4){this.y = 4; this.x = sw/2 + 20}
var column = 0; for (var i = 0; i < choices.length; ++i) { if (i == 4) column = 1; var x = this.x + column*100; var y = this.y + i * 16; if (i == choice) { arrow.blit(x, y); this.font.setColorMask(yellow); } this.font.drawText(16 + x, y, choices[i]); this.font.setColorMask(white); }
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;} //this.txt_h = Math.floor(h/12) 12 is the font height, h is the msgbox height var choice_x = this.x + column * 88; //var x and var y cant be used var choice_y = this.y + r * 12; // r is used not i if (i == choice)this.setcolor(color_2); this.font.drawText(x,y, choices[i]); this.setcolor(color_1); }
while (AreKeysLeft()) { switch(GetKey()) { case KEY_Z:done = true;break; case KEY_DOWN: if (choice < choices.length-1) choice++; break; case KEY_UP: if (choice > 0) choice--; break; case KEY_RIGHT: if (choice <= 3 && choices.length > 3) choice = choice + 4; break; case KEY_LEFT: if (choice >= 4) choice = choice - 4; break; } }
//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);
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); }
case KEY_RIGHT: if (choice <= 3 && choices.length > 3) choice = choice + 4; break;case KEY_LEFT: if (choice >= 4) choice = choice - 4; break;
this.txt_h = Math.floor(h/12);
while (AreKeysLeft()) { switch(GetKey()) { case KEY_Z:done = true;break; case KEY_DOWN: if (choice < choices.length-1) choice++; break; case KEY_UP: if (choice > 0) choice--; break; case KEY_RIGHT: if (choice <= this.txt_h - 1 && choices.length > this.txt_h - 1) choice = choice + this.txt_h; break; case KEY_LEFT: if (choice >= this.txt_h) choice = choice - this.txt_h; break; } }