当前位置: 首页>>代码示例>>C++>>正文


C++ ListIter::GetText方法代码示例

本文整理汇总了C++中ListIter::GetText方法的典型用法代码示例。如果您正苦于以下问题:C++ ListIter::GetText方法的具体用法?C++ ListIter::GetText怎么用?C++ ListIter::GetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListIter的用法示例。


在下文中一共展示了ListIter::GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: menu_rect

void
MenuView::DrawMenu(int mx, int my, Menu* m)
{
	if (m) {
		MenuItem*   locked_item = 0;
		Menu*       submenu     = 0;
		int         subx        = 0;
		int         suby        = 0;
		Font*       font        = FontMgr::Find("HUD");

		Rect menu_rect(mx, my, 100, m->NumItems() * 10 + 6);

		int max_width     = 0;
		int max_height    = 0;
		int extra_width   = 16;

		ListIter<MenuItem> item = m->GetItems();
		while (++item) {
			menu_rect.w = width/2;

			if (item->GetText().length()) {
				window->SetFont(font);
				window->DrawText(item->GetText(), 0, menu_rect, DT_LEFT|DT_SINGLELINE|DT_CALCRECT);
				if (menu_rect.w > max_width)
				max_width = menu_rect.w;
				max_height += 11;

				if (item->GetSubmenu())
				extra_width = 28;

				if (item->GetSelected() > 1)
				locked_item = item.value();
			}
			else {
				max_height += 4;
			}
		}

		menu_rect.h = max_height + 6;
		menu_rect.w = max_width  + extra_width;

		if (menu_rect.x + menu_rect.w >= width)
		menu_rect.x = width - menu_rect.w - 2;

		if (menu_rect.y + menu_rect.h >= height)
		menu_rect.y = height - menu_rect.h - 2;

		window->FillRect(menu_rect, back_color * 0.2);
		window->DrawRect(menu_rect, back_color);

		Rect item_rect = menu_rect;

		item_rect.x += 4;
		item_rect.y += 3;
		item_rect.w -= 8;
		item_rect.h = 12;

		item.reset();
		while (++item) {
			int line_height = 0;

			if (item->GetText().length()) {
				Rect fill_rect = item_rect;
				fill_rect.Inflate(2,-1);
				fill_rect.y -= 1;

				int mx = Mouse::X() - offset.x;
				int my = Mouse::Y() - offset.y;

				// is this item picked?
				if (menu_rect.Contains(mx, my)) {
					if (my >= fill_rect.y && my <= fill_rect.y+fill_rect.h) {
						if (Mouse::LButton()) {
							menu_item = item.value();
							item->SetSelected(2);
							if (locked_item && locked_item->GetMenu() == m)
							locked_item->SetSelected(0);
							locked_item = menu_item;
						}
						else if (!locked_item || locked_item->GetMenu() != m) {
							item->SetSelected(true);
							menu_item = item.value();
						}

						if (menu_item && menu_item != selected) {
							selected = menu_item;
							Button::PlaySound(Button::SND_MENU_HILITE);
						}
					}
					else if (item.value() != locked_item) {
						item->SetSelected(false);
					}
				}

				if (item->GetSelected()) {
					window->FillRect(fill_rect, back_color * 0.35);
					window->DrawRect(fill_rect, back_color * 0.75);

					if (item->GetSubmenu()) {
						submenu  = item->GetSubmenu();
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:MenuView.cpp

示例2: menu_rect

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]);
//.........这里部分代码省略.........
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:101,代码来源:RadioView.cpp


注:本文中的ListIter::GetText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。