Ejemplo n.º 1
0
void
RadioView::ExecFrame()
{
	HUDView* hud = HUDView::GetInstance();
	if (hud) {
		if (txt_color != hud->GetTextColor()) {
			txt_color = hud->GetTextColor();
			SetColor(txt_color);
		}

		hud_color = hud->GetHUDColor();
	}

	static int current_key = 0;

	if (current_key > 0 && Keyboard::KeyDown(current_key))
	return;

	current_key = 0;

	Menu* menu = history.GetCurrent();
	if (menu) {
		int max_items = menu->NumItems();

		if (menu == starship_menu && Keyboard::KeyDown('0')) {
			current_key = '0';
			if (++starship_page >= num_pages)
			starship_page = 0;

			history.Pop();
			history.Push(GetRadioMenu(ship));
		}
		else {
			for (int i = 0; i < max_items; i++) {
				if (Keyboard::KeyDown('1' + i)) {
					current_key = '1' + i;
					MenuItem* item = menu->GetItem(i);
					if (item && item->GetEnabled()) {
						if (item->GetSubmenu()) {
							if (history.GetCurrent() == starship_menu)
							dst_elem = (Element*) item->GetData();

							history.Push(item->GetSubmenu());
						}
						else {
							// execute radio message:
							SendRadioMessage(ship, item);

							// clear radio menu:
							history.Clear();
						}

						break;
					}
				}
			}
		}
	}
}