module Controls { export function createBigButton (text : string, resolve : (t : string) => void) { let p = document.createElement("p"); p.classList.add("choice"); p.appendChild(document.createTextNode(text)); p.addEventListener("click", () => { resolve(text); }); Controls.KeyHandler.applyCode(p, Controls.KeyHandler.getFirstKeyCode()); return p; } export async function giveChoices (big? : boolean, ...choices : Array) { let buttons; let chosenPromise = > new Promise((async (resolve) => { Controls.KeyHandler.reset(); let say = new Say(); choices.forEach(choice => { say.add(createBigButton(choice, resolve)) }); buttons = await say.getHTMLContent(); Elements.CurrentTurnHandler.print(...(buttons)); })); let chosen = await chosenPromise; Elements.CurrentTurnHandler.unprint(...buttons); return [chosen, choices.indexOf(chosen)]; } }