/*************************************************
 * Decompiled by Serious and Edited by SyndiShanX
 * Script: cp\_debug_menu.gsc
*************************************************/

#namespace debug_menu;

function add_menu(menu_name, title) {
  if(isDefined(level.menu_sys[menu_name])) {
    println(("" + menu_name) + "");
    return;
  }
  level.menu_sys[menu_name] = spawnStruct();
  level.menu_sys[menu_name].title = "";
  level.menu_sys[menu_name].title = title;
}

function add_menuoptions(menu_name, option_text, func, key) {
  if(!isDefined(level.menu_sys[menu_name].options)) {
    level.menu_sys[menu_name].options = [];
  }
  num = level.menu_sys[menu_name].options.size;
  level.menu_sys[menu_name].options[num] = option_text;
  level.menu_sys[menu_name].func[num] = func;
  if(isDefined(key)) {
    if(!isDefined(level.menu_sys[menu_name].func_key)) {
      level.menu_sys[menu_name].func_key = [];
    }
    level.menu_sys[menu_name].func_key[num] = key;
  }
}

function add_menu_child(parent_menu, child_menu, child_title, child_number_override, func) {
  if(!isDefined(level.menu_sys[child_menu])) {
    add_menu(child_menu, child_title);
  }
  level.menu_sys[child_menu].parent_menu = parent_menu;
  if(!isDefined(level.menu_sys[parent_menu].children_menu)) {
    level.menu_sys[parent_menu].children_menu = [];
  }
  if(!isDefined(child_number_override)) {
    size = level.menu_sys[parent_menu].children_menu.size;
  } else {
    size = child_number_override;
  }
  level.menu_sys[parent_menu].children_menu[size] = child_menu;
  if(isDefined(func)) {
    if(!isDefined(level.menu_sys[parent_menu].children_func)) {
      level.menu_sys[parent_menu].children_func = [];
    }
    level.menu_sys[parent_menu].children_func[size] = func;
  }
}

function set_no_back_menu(menu_name) {
  level.menu_sys[menu_name].no_back = 1;
}

function enable_menu(menu_name) {
  disable_menu("");
  if(isDefined(level.menu_cursor)) {
    level.menu_cursor.y = 130;
    level.menu_cursor.current_pos = 0;
  }
  level.menu_sys[""].title = set_menu_hudelem(level.menu_sys[menu_name].title, "");
  level.menu_sys[""].menu_name = menu_name;
  back_option_num = 0;
  if(isDefined(level.menu_sys[menu_name].options)) {
    options = level.menu_sys[menu_name].options;
    for(i = 0; i < options.size; i++) {
      text = ((i + 1) + "") + options[i];
      level.menu_sys[""].options[i] = set_menu_hudelem(text, "", 20 * i);
      back_option_num = i;
    }
  }
  if(isDefined(level.menu_sys[menu_name].parent_menu) && !isDefined(level.menu_sys[menu_name].no_back)) {
    back_option_num++;
    text = ((back_option_num + 1) + "") + "";
    level.menu_sys[""].options[back_option_num] = set_menu_hudelem(text, "", 20 * back_option_num);
  }
}

function disable_menu(menu_name) {
  if(isDefined(level.menu_sys[menu_name])) {
    if(isDefined(level.menu_sys[menu_name].title)) {
      level.menu_sys[menu_name].title destroy();
    }
    if(isDefined(level.menu_sys[menu_name].options)) {
      options = level.menu_sys[menu_name].options;
      for(i = 0; i < options.size; i++) {
        options[i] destroy();
      }
    }
  }
  level.menu_sys[menu_name].title = undefined;
  level.menu_sys[menu_name].options = [];
}

function set_menu_hudelem(text, type, y_offset) {
  y = 100;
  if(isDefined(type) && type == "") {
    scale = 2;
  } else {
    scale = 1.3;
    y = y + 30;
  }
  if(!isDefined(y_offset)) {
    y_offset = 0;
  }
  y = y + y_offset;
  return set_hudelem(text, 10, y, scale);
}

function set_hudelem(text, x, y, scale, alpha, sort, debug_hudelem) {
  if(!isDefined(alpha)) {
    alpha = 1;
  }
  if(!isDefined(scale)) {
    scale = 1;
  }
  if(!isDefined(sort)) {
    sort = 20;
  }
  if(isDefined(level.player) && !isDefined(debug_hudelem)) {
    hud = newclienthudelem(level.player);
  } else {
    hud = newdebughudelem();
    hud.debug_hudelem = 1;
  }
  hud.location = 0;
  hud.alignx = "";
  hud.aligny = "";
  hud.foreground = 1;
  hud.fontscale = scale;
  hud.sort = sort;
  hud.alpha = alpha;
  hud.x = x;
  hud.y = y;
  hud.og_scale = scale;
  if(isDefined(text)) {
    hud settext(text);
  }
  return hud;
}

function menu_input() {
  while(true) {
    level waittill("menu_button_pressed", keystring);
    menu_name = level.menu_sys[""].menu_name;
    if(keystring == "" || keystring == "") {
      if(level.menu_cursor.current_pos > 0) {
        level.menu_cursor.y = level.menu_cursor.y - 20;
        level.menu_cursor.current_pos--;
      } else if(level.menu_cursor.current_pos == 0) {
        level.menu_cursor.y = level.menu_cursor.y + ((level.menu_sys[""].options.size - 1) * 20);
        level.menu_cursor.current_pos = level.menu_sys[""].options.size - 1;
      }
      wait(0.1);
      continue;
    } else {
      if(keystring == "" || keystring == "") {
        if(level.menu_cursor.current_pos < (level.menu_sys[""].options.size - 1)) {
          level.menu_cursor.y = level.menu_cursor.y + 20;
          level.menu_cursor.current_pos++;
        } else if(level.menu_cursor.current_pos == (level.menu_sys[""].options.size - 1)) {
          level.menu_cursor.y = level.menu_cursor.y + (level.menu_cursor.current_pos * -20);
          level.menu_cursor.current_pos = 0;
        }
        wait(0.1);
        continue;
      } else {
        if(keystring == "" || keystring == "") {
          key = level.menu_cursor.current_pos;
        } else {
          key = int(keystring) - 1;
        }
      }
    }
    if(key > level.menu_sys[menu_name].options.size) {
      continue;
    } else {
      if(isDefined(level.menu_sys[menu_name].parent_menu) && key == level.menu_sys[menu_name].options.size) {
        level notify("" + menu_name);
        level enable_menu(level.menu_sys[menu_name].parent_menu);
      } else if(isDefined(level.menu_sys[menu_name].func) && isDefined(level.menu_sys[menu_name].func[key])) {
        level.menu_sys[""].options[key] thread hud_selector(level.menu_sys[""].options[key].x, level.menu_sys[""].options[key].y);
        if(isDefined(level.menu_sys[menu_name].func_key) && isDefined(level.menu_sys[menu_name].func_key[key]) && level.menu_sys[menu_name].func_key[key] == keystring) {
          error_msg = level[[level.menu_sys[menu_name].func[key]]]();
        } else {
          error_msg = level[[level.menu_sys[menu_name].func[key]]]();
        }
        level thread hud_selector_fade_out();
        if(isDefined(error_msg)) {
          level thread selection_error(error_msg, level.menu_sys[""].options[key].x, level.menu_sys[""].options[key].y);
        }
      }
    }
    if(!isDefined(level.menu_sys[menu_name].children_menu)) {
      println(("" + menu_name) + "");
      continue;
    } else {
      if(!isDefined(level.menu_sys[menu_name].children_menu[key])) {
        println(((("" + menu_name) + "") + key) + "");
        continue;
      } else if(!isDefined(level.menu_sys[level.menu_sys[menu_name].children_menu[key]])) {
        println(("" + level.menu_sys[menu_name].options[key]) + "");
        continue;
      }
    }
    if(isDefined(level.menu_sys[menu_name].children_func) && isDefined(level.menu_sys[menu_name].children_func[key])) {
      func = level.menu_sys[menu_name].children_func[key];
      error_msg = [[func]]();
      if(isDefined(error_msg)) {
        level thread selection_error(error_msg, level.menu_sys[""].options[key].x, level.menu_sys[""].options[key].y);
        continue;
      }
    }
    level enable_menu(level.menu_sys[menu_name].children_menu[key]);
    wait(0.1);
  }
}

function force_menu_back(waittill_msg) {
  if(isDefined(waittill_msg)) {
    level waittill(waittill_msg);
  }
  wait(0.1);
  menu_name = level.menu_sys[""].menu_name;
  key = level.menu_sys[menu_name].options.size;
  key++;
  if(key == 1) {
    key = "";
  } else {
    if(key == 2) {
      key = "";
    } else {
      if(key == 3) {
        key = "";
      } else {
        if(key == 4) {
          key = "";
        } else {
          if(key == 5) {
            key = "";
          } else {
            if(key == 6) {
              key = "";
            } else {
              if(key == 7) {
                key = "";
              } else {
                if(key == 8) {
                  key = "";
                } else if(key == 9) {
                  key = "";
                }
              }
            }
          }
        }
      }
    }
  }
  level notify("menu_button_pressed", key);
}

function list_menu(list, x, y, scale, func, sort, start_num) {
  if(!isDefined(list) || list.size == 0) {
    return -1;
  }
  hud_array = [];
  for(i = 0; i < 5; i++) {
    if(i == 0) {
      alpha = 0.3;
    } else {
      if(i == 1) {
        alpha = 0.6;
      } else {
        if(i == 2) {
          alpha = 1;
        } else {
          if(i == 3) {
            alpha = 0.6;
          } else {
            alpha = 0.3;
          }
        }
      }
    }
    hud = set_hudelem(list[i], x, y + ((i - 2) * 15), scale, alpha, sort);
    if(!isDefined(hud_array)) {
      hud_array = [];
    } else if(!isarray(hud_array)) {
      hud_array = array(hud_array);
    }
    hud_array[hud_array.size] = hud;
  }
  if(isDefined(start_num)) {
    new_move_list_menu(hud_array, list, start_num);
  }
  current_num = 0;
  old_num = 0;
  selected = 0;
  level.menu_list_selected = 0;
  if(isDefined(func)) {
    [[func]](list[current_num]);
  }
  while(true) {
    level waittill("menu_button_pressed", key);
    level.menu_list_selected = 1;
    if(any_button_hit(key, "")) {
      break;
    } else {
      if(key == "" || key == "") {
        if(current_num >= (list.size - 1)) {
          continue;
        }
        current_num++;
        new_move_list_menu(hud_array, list, current_num);
      } else {
        if(key == "" || key == "") {
          if(current_num <= 0) {
            continue;
          }
          current_num--;
          new_move_list_menu(hud_array, list, current_num);
        } else {
          if(key == "" || key == "") {
            selected = 1;
            break;
          } else if(key == "" || key == "") {
            selected = 0;
            break;
          }
        }
      }
    }
    level notify("scroll_list");
    if(current_num != old_num) {
      old_num = current_num;
      if(isDefined(func)) {
        [[func]](list[current_num]);
      }
    }
    wait(0.1);
  }
  for(i = 0; i < hud_array.size; i++) {
    hud_array[i] destroy();
  }
  if(selected) {
    return current_num;
  }
}

function new_move_list_menu(hud_array, list, num) {
  for(i = 0; i < hud_array.size; i++) {
    if(isDefined(list[i + (num - 2)])) {
      text = list[i + (num - 2)];
    } else {
      text = "";
    }
    hud_array[i] settext(text);
  }
}

function move_list_menu(hud_array, dir, space, num, min_alpha, num_of_fades) {
  if(!isDefined(min_alpha)) {
    min_alpha = 0;
  }
  if(!isDefined(num_of_fades)) {
    num_of_fades = 3;
  }
  side_movement = 0;
  if(dir == "") {
    side_movement = 1;
    movement = space;
  } else {
    if(dir == "") {
      side_movement = 1;
      movement = space * -1;
    } else {
      if(dir == "") {
        movement = space;
      } else {
        movement = space * -1;
      }
    }
  }
  for(i = 0; i < hud_array.size; i++) {
    hud_array[i] moveovertime(0.1);
    if(side_movement) {
      hud_array[i].x = hud_array[i].x + movement;
    } else {
      hud_array[i].y = hud_array[i].y + movement;
    }
    temp = i - num;
    if(temp < 0) {
      temp = temp * -1;
    }
    alpha = 1 / (temp + 1);
    if(alpha < (1 / num_of_fades)) {
      alpha = min_alpha;
    }
    if(!isDefined(hud_array[i].debug_hudelem)) {
      hud_array[i] fadeovertime(0.1);
    }
    hud_array[i].alpha = alpha;
  }
}

function hud_selector(x, y) {
  if(isDefined(level.hud_selector)) {
    level thread hud_selector_fade_out();
  }
  level.menu_cursor.alpha = 0;
  level.hud_selector = set_hudelem(undefined, x - 10, y, 1);
  level.hud_selector setshader("", 125, 20);
  level.hud_selector.color = (1, 1, 0.5);
  level.hud_selector.alpha = 0.5;
  level.hud_selector.sort = 10;
}

function hud_selector_fade_out(time) {
  if(!isDefined(time)) {
    time = 0.25;
  }
  level.menu_cursor.alpha = 0.5;
  hud = level.hud_selector;
  level.hud_selector = undefined;
  if(!isDefined(hud.debug_hudelem)) {
    hud fadeovertime(time);
  }
  hud.alpha = 0;
  wait(time + 0.1);
  hud destroy();
}

function selection_error(msg, x, y) {
  hud = set_hudelem(undefined, x - 10, y, 1);
  hud setshader("", 125, 20);
  hud.color = vectorscale((1, 0, 0), 0.5);
  hud.alpha = 0.7;
  error_hud = set_hudelem(msg, x + 125, y, 1);
  error_hud.color = (1, 0, 0);
  if(!isDefined(hud.debug_hudelem)) {
    hud fadeovertime(3);
  }
  hud.alpha = 0;
  if(!isDefined(error_hud.debug_hudelem)) {
    error_hud fadeovertime(3);
  }
  error_hud.alpha = 0;
  wait(3.1);
  hud destroy();
  error_hud destroy();
}

function hud_font_scaler(mult) {
  self notify("stop_fontscaler");
  self endon("death");
  self endon("stop_fontscaler");
  og_scale = self.og_scale;
  if(!isDefined(mult)) {
    mult = 1.5;
  }
  self.fontscale = og_scale * mult;
  dif = og_scale - self.fontscale;
  dif = dif / (1 * 20);
  for(i = 0; i < (1 * 20); i++) {
    self.fontscale = self.fontscale + dif;
    wait(0.05);
  }
}

function menu_cursor() {
  level.menu_cursor = set_hudelem(undefined, 0, 130, 1.3);
  level.menu_cursor setshader("", 125, 20);
  level.menu_cursor.color = (1, 0.5, 0);
  level.menu_cursor.alpha = 0.5;
  level.menu_cursor.sort = 1;
  level.menu_cursor.current_pos = 0;
}

function new_hud(hud_name, msg, x, y, scale) {
  if(!isDefined(level.hud_array)) {
    level.hud_array = [];
  }
  if(!isDefined(level.hud_array[hud_name])) {
    level.hud_array[hud_name] = [];
  }
  hud = set_hudelem(msg, x, y, scale);
  level.hud_array[hud_name][level.hud_array[hud_name].size] = hud;
  return hud;
}

function remove_hud(hud_name) {
  if(!isDefined(level.hud_array[hud_name])) {
    return;
  }
  huds = level.hud_array[hud_name];
  for(i = 0; i < huds.size; i++) {
    destroy_hud(huds[i]);
  }
  level.hud_array[hud_name] = undefined;
}

function destroy_hud(hud) {
  if(isDefined(hud)) {
    hud destroy();
  }
}

function set_menus_pos_by_num(hud_array, num, x, y, space, min_alpha, num_of_fades) {
  if(!isDefined(min_alpha)) {
    min_alpha = 0.1;
  }
  if(!isDefined(num_of_fades)) {
    num_of_fades = 3;
  }
  for(i = 0; i < hud_array.size; i++) {
    temp = i - num;
    hud_array[i].y = y + (temp * space);
    if(temp < 0) {
      temp = temp * -1;
    }
    alpha = 1 / (temp + 1);
    if(alpha < (1 / num_of_fades)) {
      alpha = min_alpha;
    }
    hud_array[i].alpha = alpha;
  }
}

function popup_box(x, y, width, height, time, color, alpha) {
  if(!isDefined(alpha)) {
    alpha = 0.5;
  }
  if(!isDefined(color)) {
    color = vectorscale((0, 0, 1), 0.5);
  }
  if(isDefined(level.player)) {
    hud = newclienthudelem(level.player);
  } else {
    hud = newdebughudelem();
    hud.debug_hudelem = 1;
  }
  hud.alignx = "";
  hud.aligny = "";
  hud.foreground = 1;
  hud.sort = 30;
  hud.x = x;
  hud.y = y;
  hud.alpha = alpha;
  hud.color = color;
  if(isDefined(level.player)) {
    hud.background = newclienthudelem(level.player);
  } else {
    hud.background = newdebughudelem();
    hud.debug_hudelem = 1;
  }
  hud.background.alignx = "";
  hud.background.aligny = "";
  hud.background.foreground = 1;
  hud.background.sort = 25;
  hud.background.x = x + 2;
  hud.background.y = y + 2;
  hud.background.alpha = 0.75;
  hud.background.color = (0, 0, 0);
  hud setshader("", 0, 0);
  hud scaleovertime(time, width, height);
  hud.background setshader("", 0, 0);
  hud.background scaleovertime(time, width, height);
  wait(time);
  return hud;
}

function destroy_popup() {
  self.background scaleovertime(0.25, 0, 0);
  self scaleovertime(0.25, 0, 0);
  wait(0.1);
  if(isDefined(self.background)) {
    self.background destroy();
  }
  if(isDefined(self)) {
    self destroy();
  }
}

function dialog_text_box(dialog_msg, dialog_msg2, word_length) {
  y = 100;
  hud = new_hud("", undefined, 320 - (300 * 0.5), y, 1);
  hud setshader("", 300, 100);
  hud.aligny = "";
  hud.color = vectorscale((0, 0, 1), 0.2);
  hud.alpha = 0.85;
  hud.sort = 20;
  hud = new_hud("", dialog_msg, (320 - (300 * 0.5)) + 10, y + 10, 1.25);
  hud.sort = 25;
  if(isDefined(dialog_msg2)) {
    hud = new_hud("", dialog_msg2, (320 - (300 * 0.5)) + 10, y + 30, 1.1);
    hud.sort = 25;
  }
  bg2_shader_width = 300 - 20;
  y = 150;
  hud = new_hud("", undefined, 320 - (bg2_shader_width * 0.5), y, 1);
  hud setshader("", bg2_shader_width, 20);
  hud.aligny = "";
  hud.color = (0, 0, 0);
  hud.alpha = 0.85;
  hud.sort = 30;
  cursor_x = (320 - (bg2_shader_width * 0.5)) + 2;
  cursor_y = y + 8;
  if(level.xenon) {
    hud = new_hud("", "", 320 - 50, y + 30, 1.25);
    hud.alignx = "";
    hud.sort = 25;
    hud = new_hud("", "", 320 + 50, y + 30, 1.25);
    hud.alignx = "";
    hud.sort = 25;
  } else {
    hud = new_hud("", "", 320 - 50, y + 30, 1.25);
    hud.alignx = "";
    hud.sort = 25;
    hud = new_hud("", "", 320 + 50, y + 30, 1.25);
    hud.alignx = "";
    hud.sort = 25;
  }
  result = dialog_text_box_input(cursor_x, cursor_y, word_length);
  remove_hud("");
  return result;
}

function dialog_text_box_input(cursor_x, cursor_y, word_length) {
  level.dialog_box_cursor = new_hud("", "", cursor_x, cursor_y, 1.25);
  level.dialog_box_cursor.sort = 75;
  level thread dialog_text_box_cursor();
  dialog_text_box_buttons();
  hud_word = new_hud("", "", cursor_x, cursor_y, 1.25);
  hud_word.sort = 75;
  hud_letters = [];
  word = "";
  while(true) {
    level waittill("dialog_box_button_pressed", button);
    if(button == "" || button == "") {
      word = "";
      break;
    } else {
      if(button == "" || button == "" || button == "") {
        break;
      } else {
        if(button == "" || button == "") {
          new_word = "";
          for(i = 0; i < (word.size - 1); i++) {
            new_word = new_word + word[i];
          }
          word = new_word;
        } else if(word.size < word_length) {
          word = word + button;
        }
      }
    }
    hud_word settext(word);
    x = cursor_x;
    for(i = 0; i < word.size; i++) {
      x = x + get_letter_space(word[i]);
    }
    level.dialog_box_cursor.x = x;
    wait(0.05);
  }
  level notify("stop_dialog_text_box_cursor");
  level notify("stop_dialog_text_input");
  return word;
}

function dialog_text_box_buttons() {
  clear_universal_buttons("");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  add_universal_button("", "");
  if(level.xenon) {
    add_universal_button("", "");
    add_universal_button("", "");
  }
  level thread universal_input_loop("", "", undefined, undefined);
}

function dialog_text_box_cursor() {
  level endon("stop_dialog_text_box_cursor");
  while(true) {
    level.dialog_box_cursor.alpha = 0;
    wait(0.5);
    level.dialog_box_cursor.alpha = 1;
    wait(0.5);
  }
}

function get_letter_space(letter) {
  if(letter == "" || letter == "" || letter == "") {
    space = 10;
  } else {
    if(letter == "" || letter == "" || letter == "" || letter == "" || letter == "" || letter == "") {
      space = 7;
    } else {
      if(letter == "" || letter == "" || letter == "") {
        space = 5;
      } else {
        if(letter == "" || letter == "") {
          space = 4;
        } else {
          if(letter == "") {
            space = 3;
          } else {
            space = 6;
          }
        }
      }
    }
  }
  return space;
}

function add_universal_button(button_group, name) {
  if(!isDefined(level.u_buttons[button_group])) {
    level.u_buttons[button_group] = [];
  }
  if(!isinarray(level.u_buttons[button_group], name)) {
    level.u_buttons[button_group][level.u_buttons[button_group].size] = name;
  }
}

function clear_universal_buttons(button_group) {
  level.u_buttons[button_group] = [];
}

function universal_input_loop(button_group, end_on, use_attackbutton, mod_button, no_mod_button) {
  level endon(end_on);
  if(!isDefined(use_attackbutton)) {
    use_attackbutton = 0;
  }
  notify_name = button_group + "";
  buttons = level.u_buttons[button_group];
  level.u_buttons_disable[button_group] = 0;
  while(true) {
    if(level.u_buttons_disable[button_group]) {
      wait(0.05);
      continue;
    }
    if(isDefined(mod_button) && !level.player buttonPressed(mod_button)) {
      wait(0.05);
      continue;
    } else if(isDefined(no_mod_button) && level.player buttonPressed(no_mod_button)) {
      wait(0.05);
      continue;
    }
    if(use_attackbutton && level.player attackButtonPressed()) {
      level notify(notify_name, "");
      wait(0.1);
      continue;
    }
    for(i = 0; i < buttons.size; i++) {
      if(level.player buttonPressed(buttons[i])) {
        level notify(notify_name, buttons[i]);
        wait(0.1);
        break;
      }
    }
    wait(0.05);
  }
}

function disable_buttons(button_group) {
  level.u_buttons_disable[button_group] = 1;
}

function enable_buttons(button_group) {
  wait(1);
  level.u_buttons_disable[button_group] = 0;
}

function any_button_hit(button_hit, type) {
  buttons = [];
  if(type == "") {
    buttons[0] = "";
    buttons[1] = "";
    buttons[2] = "";
    buttons[3] = "";
    buttons[4] = "";
    buttons[5] = "";
    buttons[6] = "";
    buttons[7] = "";
    buttons[8] = "";
    buttons[9] = "";
  } else {
    buttons = level.buttons;
  }
  for(i = 0; i < buttons.size; i++) {
    if(button_hit == buttons[i]) {
      return true;
    }
  }
  return false;
}