Ejemplo n.º 1
0
void
RadioView::Refresh()
{
	sim = Sim::GetSim();

	if (!font)
	return;

	font->SetColor(txt_color);
	font->SetAlpha(1);

	if (sim && ship != sim->GetPlayerShip()) {
		ship = sim->GetPlayerShip();
		history.Clear();

		if (ship) {
			if (ship->Life() == 0 || ship->IsDying() || ship->IsDead()) {
				ship = 0;
			}
			else {
				Observe(ship);
			}
		}
	}

	QuantumView* qv = QuantumView::GetInstance();

	if (!qv || !qv->IsMenuShown()) {
		Menu* menu = history.GetCurrent();

		if (menu) {
			Rect menu_rect(width-115, 10, 115, 12);

			font->DrawText(menu->GetTitle(), 0, menu_rect, DT_CENTER);
			menu_rect.y += 15;

			ListIter<MenuItem> item = menu->GetItems();
			while (++item) {
				if (ship->GetEMCON() < 2 || 
						(TargetRequired(item.value()) && !ship->GetTarget()) ||
						item->GetText().contains("KIA")) {
					item->SetEnabled(false);
					font->SetAlpha(0.35);
				}
				else {
					item->SetEnabled(true);
					font->SetAlpha(1);
				}

				font->DrawText(item->GetText(), 0, menu_rect, DT_LEFT);
				menu_rect.y += 10;
			}
		}
	}

	int message_queue_empty = true;

	// age messages:
	for (int i = 0; i < MAX_MSG; i++) {
		if (msg_time[i] > 0) {
			msg_time[i] -= Game::GUITime();

			if (msg_time[i] <= 0) {
				msg_time[i] = 0;
				msg_text[i] = "";
			}

			message_queue_empty = false;
		}
	}

	if (!message_queue_empty) {
		// advance message pipeline:
		for (int i = 0; i < MAX_MSG; i++) {
			if (msg_time[0] == 0) {
				for (int j = 0; j < MAX_MSG-1; j++) {
					msg_time[j] = msg_time[j+1];
					msg_text[j] = msg_text[j+1];
				}

				msg_time[MAX_MSG-1] = 0;
				msg_text[MAX_MSG-1] = "";
			}
		}

		bool hud_off = false;

		if (HUDView::GetInstance())
		hud_off = (HUDView::GetInstance()->GetHUDMode() == HUDView::HUD_MODE_OFF);

		// draw messages:
		if (!hud_off) {
			for (int i = 0; i < MAX_MSG; i++) {
				if (msg_time[i] > 0) {
					Rect msg_rect(0, 95 + i*10, width, 12);

					if (msg_time[i] > 1)
					font->SetAlpha(1);
					else
					font->SetAlpha(0.5 + 0.5*msg_time[i]);

					font->DrawText(msg_text[i].data(), msg_text[i].length(), msg_rect, DT_CENTER);
				}
			}

			font->SetAlpha(1);
		}
	}

	Starshatter* stars = Starshatter::GetInstance();
	if (stars && stars->GetChatMode()) {
		Text chat;

		switch (stars->GetChatMode()) {
		case 1:  chat = "ALL:  ";  break;
		case 2:  chat = "TEAM:  ";  break;
		case 3:  chat = "WING:  ";  break;
		case 4:  chat = "UNIT:  ";  break;
		}

		chat += stars->GetChatText();

		Rect chat_rect(width/2 - 250, height-150, 500, 12);
		font->DrawText(chat, 0, chat_rect, DT_LEFT);

		chat_rect.Inflate(2,2);
		window->DrawRect(chat_rect, hud_color);
	}
}