示例#1
0
/**
**  Display update.
**
**  This functions updates everything on screen. The map, the gui, the
**  cursors.
*/
void UpdateDisplay()
{
	if (GameRunning || Editor.Running == EditorEditing) {
		DrawMapArea();
		DrawMessages();

		if (CursorState == CursorStateRectangle) {
			DrawCursor();
		}

		if ((Preference.BigScreen && !BigMapMode) || (!Preference.BigScreen && BigMapMode)) {
			UiToggleBigMap();
		}

		if (!BigMapMode) {
			for (size_t i = 0; i < UI.Fillers.size(); ++i) {
				UI.Fillers[i].G->DrawSubClip(0, 0,
											 UI.Fillers[i].G->Width,
											 UI.Fillers[i].G->Height,
											 UI.Fillers[i].X, UI.Fillers[i].Y);
			}
			DrawMenuButtonArea();
			DrawUserDefinedButtons();

			UI.Minimap.Draw();
			UI.Minimap.DrawViewportArea(*UI.SelectedViewport);

			UI.InfoPanel.Draw();
			DrawResources();
			UI.StatusLine.Draw();
			UI.StatusLine.DrawCosts();
			UI.ButtonPanel.Draw();
		}

		DrawTimer();
	}

	DrawPieMenu(); // draw pie menu only if needed

	DrawGuichanWidgets();

	if (CursorState != CursorStateRectangle) {
		DrawCursor();
	}

	//
	// Update changes to display.
	//
	Invalidate();
}
示例#2
0
/**
**  Display update.
**
**  This functions updates everything on screen. The map, the gui, the
**  cursors.
*/
void UpdateDisplay(void)
{
	if (GameRunning || Editor.Running == EditorEditing) {
		DrawMapArea();
		DrawMessages();

		if (CursorState == CursorStateRectangle) {
			DrawCursor();
		}

		if (!BigMapMode) {
			for (int i = 0; i < (int)UI.Fillers.size(); ++i) {
				UI.Fillers[i].G->DrawSubClip(0, 0,
					UI.Fillers[i].G->Width,
					UI.Fillers[i].G->Height,
					UI.Fillers[i].X, UI.Fillers[i].Y);
			}
			DrawMenuButtonArea();

			UI.Minimap.Draw(UI.SelectedViewport->MapX, UI.SelectedViewport->MapY);
			UI.Minimap.DrawCursor(UI.SelectedViewport->MapX,
				UI.SelectedViewport->MapY);

			UI.InfoPanel.Draw();
			UI.ButtonPanel.Draw();
			DrawResources();
			UI.StatusLine.Draw();
		}

		DrawCosts();
		DrawTimer();
	}

	DrawPieMenu(); // draw pie menu only if needed

	DrawGuichanWidgets();
	
	if (CursorState != CursorStateRectangle) {
		DrawCursor();
	}

	//
	// Update changes to display.
	//
	Invalidate();
}
示例#3
0
/**
**  Display update.
**
**  This functions updates everything on screen. The map, the gui, the
**  cursors.
*/
void UpdateDisplay()
{
	if (GameRunning || Editor.Running == EditorEditing) {
		// to prevent empty spaces in the UI
#if defined(USE_OPENGL) || defined(USE_GLES)
		Video.FillRectangleClip(ColorBlack, 0, 0, Video.ViewportWidth, Video.ViewportHeight);
#else
		Video.FillRectangleClip(ColorBlack, 0, 0, Video.Width, Video.Height);
#endif
		DrawMapArea();
		DrawMessages();

		if (CursorState == CursorStateRectangle) {
			DrawCursor();
		}

		//Wyrmgus start
		if (CursorBuilding && CursorOn == CursorOnMap) {
			DrawBuildingCursor();
		}
		//Wyrmgus end
	
		if ((Preference.BigScreen && !BigMapMode) || (!Preference.BigScreen && BigMapMode)) {
			UiToggleBigMap();
		}

		if (!BigMapMode) {
			for (size_t i = 0; i < UI.Fillers.size(); ++i) {
				UI.Fillers[i].G->DrawSubClip(0, 0,
											 UI.Fillers[i].G->Width,
											 UI.Fillers[i].G->Height,
											 UI.Fillers[i].X, UI.Fillers[i].Y);
			}
			DrawMenuButtonArea();
			DrawUserDefinedButtons();

			UI.Minimap.Draw();
			UI.Minimap.DrawViewportArea(*UI.SelectedViewport);

			UI.InfoPanel.Draw();
			DrawResources();
			UI.StatusLine.Draw();
			UI.StatusLine.DrawCosts();
			UI.ButtonPanel.Draw();
		}
		
		DrawTimer();
		
		//Wyrmgus start
		//draw worker icon if there are idle workers
		if (UI.IdleWorkerButton && !ThisPlayer->FreeWorkers.empty()) {
			int worker_unit_type_id = PlayerRaces.GetFactionClassUnitType(ThisPlayer->Race, ThisPlayer->Faction, GetUnitTypeClassIndexByName("worker"));
			if (worker_unit_type_id != -1) {
				const CUnitType &type = *UnitTypes[worker_unit_type_id];
				
				const PixelPos pos(UI.IdleWorkerButton->X, UI.IdleWorkerButton->Y);
				const int flag = (ButtonAreaUnderCursor == ButtonAreaIdleWorker && ButtonUnderCursor == 0) ? (IconActive | (MouseButtons & LeftButton)) : 0;
								 
				VariationInfo *varinfo = type.GetDefaultVariation(*ThisPlayer);
				if (varinfo && varinfo->Icon.Icon) { // check if the default variation is valid, and if it is, then make the button use the variation's icon
					varinfo->Icon.Icon->DrawUnitIcon(*UI.IdleWorkerButton->Style, flag, pos, ".", ThisPlayer->Index);
				} else {
					type.Icon.Icon->DrawUnitIcon(*UI.IdleWorkerButton->Style, flag, pos, ".", ThisPlayer->Index);
				}
				
				if (ButtonAreaUnderCursor == ButtonAreaIdleWorker && ButtonUnderCursor == 0) { //if the mouse is hovering over the idle worker button, draw a tooltip
					std::string idle_worker_tooltip = "Find Idle Worker (~!.)";
					if (!Preference.NoStatusLineTooltips) {
						CLabel label(GetGameFont());
						label.Draw(2 + 16, Video.Height + 2 - 16, idle_worker_tooltip);
					}
					DrawGenericPopup(idle_worker_tooltip, UI.IdleWorkerButton->X, UI.IdleWorkerButton->Y);
				}
			}
		}
		
		//draw icon if there are units with available level up upgrades
		if (UI.LevelUpUnitButton && !ThisPlayer->LevelUpUnits.empty()) {
			const PixelPos pos(UI.LevelUpUnitButton->X, UI.LevelUpUnitButton->Y);
			const int flag = (ButtonAreaUnderCursor == ButtonAreaLevelUpUnit && ButtonUnderCursor == 0) ? (IconActive | (MouseButtons & LeftButton)) : 0;
								 
			ThisPlayer->LevelUpUnits[0]->GetIcon().Icon->DrawUnitIcon(*UI.LevelUpUnitButton->Style, flag, pos, "", ThisPlayer->Index);
				
			if (ButtonAreaUnderCursor == ButtonAreaLevelUpUnit && ButtonUnderCursor == 0) { //if the mouse is hovering over the level up unit button, draw a tooltip
				std::string level_up_unit_tooltip = "Find Unit with Available Level Up";
				if (!Preference.NoStatusLineTooltips) {
					CLabel label(GetGameFont());
					label.Draw(2 + 16, Video.Height + 2 - 16, level_up_unit_tooltip);
				}
				DrawGenericPopup(level_up_unit_tooltip, UI.LevelUpUnitButton->X, UI.LevelUpUnitButton->Y);
			}
		}
		//Wyrmgus end
	//Wyrmgus start
	} else if (GrandStrategy && !GameRunning && GameResult == GameNoResult) { //grand strategy mode
		if (!GrandStrategyGamePaused) {
			//scroll map if mouse is in the scroll area
			int scroll_up = 7; //the scroll area in the upper part of the screen is smaller to allow clicking on the menu buttons and etc. more comfortably
			int scroll_down = (Video.Height - 16);
			int scroll_left = 15;
			int scroll_right = (Video.Width - 16);
			bool scrolled = false;
			if (CursorScreenPos.y < scroll_up) {
				if (WorldMapOffsetY > 0) {
					if (GrandStrategyMapHeightIndent == 0) {
						WorldMapOffsetY = WorldMapOffsetY - 1;
					}
					GrandStrategyMapHeightIndent -= 32;
				} else if (WorldMapOffsetY == 0 && GrandStrategyMapHeightIndent == -32) { //this is to make the entire y 0 tiles be shown scrolling to the northmost part of the map
					GrandStrategyMapHeightIndent -= 32;
				}
				GameCursor = UI.ArrowN.Cursor;
				scrolled = true;
			} else if (CursorScreenPos.y > scroll_down) {
				if (WorldMapOffsetY < GetWorldMapHeight() - 1 - ((UI.MapArea.EndY - UI.MapArea.Y) / 64)) {
					if (GrandStrategyMapHeightIndent == -32) {
						WorldMapOffsetY = WorldMapOffsetY + 1;
					}
					GrandStrategyMapHeightIndent += 32;
				} else if (WorldMapOffsetY == GetWorldMapHeight() - 1 - ((UI.MapArea.EndY - UI.MapArea.Y) / 64) && GrandStrategyMapHeightIndent == 0) {
					GrandStrategyMapHeightIndent += 32;
				}
				GameCursor = UI.ArrowS.Cursor;
				scrolled = true;
			}
			if (CursorScreenPos.x < scroll_left) {
				if (WorldMapOffsetX > 0) {
					if (GrandStrategyMapWidthIndent == 0) {
						WorldMapOffsetX = WorldMapOffsetX - 1;
					}
					GrandStrategyMapWidthIndent -= 32;
				} else if (WorldMapOffsetX == 0 && GrandStrategyMapWidthIndent == -32) { //this is to make the entire x 0 tiles be shown scrolling to the westmost part of the map
					GrandStrategyMapWidthIndent -= 32;
				}
				if (GameCursor == UI.ArrowN.Cursor) {
					GameCursor = UI.ArrowNW.Cursor;
				} else if (GameCursor == UI.ArrowS.Cursor) {
					GameCursor = UI.ArrowSW.Cursor;
				} else {
					GameCursor = UI.ArrowW.Cursor;
				}
				scrolled = true;
			} else if (CursorScreenPos.x > scroll_right) {
				if (WorldMapOffsetX < GetWorldMapWidth() - 1 - ((UI.MapArea.EndX - UI.MapArea.X) / 64)) {
					if (GrandStrategyMapWidthIndent == -32) {
						WorldMapOffsetX = WorldMapOffsetX + 1;
					}
					GrandStrategyMapWidthIndent += 32;
				} else if (WorldMapOffsetX == GetWorldMapWidth() - 1 - ((UI.MapArea.EndX - UI.MapArea.X) / 64) && GrandStrategyMapWidthIndent == 0) {
					GrandStrategyMapWidthIndent += 32;
				}
				if (GameCursor == UI.ArrowN.Cursor) {
					GameCursor = UI.ArrowNE.Cursor;
				} else if (GameCursor == UI.ArrowS.Cursor) {
					GameCursor = UI.ArrowSE.Cursor;
				} else {
					GameCursor = UI.ArrowE.Cursor;
				}
				scrolled = true;
			}
			if (scrolled) {
				if (GrandStrategyMapWidthIndent <= -64) {
					GrandStrategyMapWidthIndent = 0;
				}
				if (GrandStrategyMapHeightIndent <= -64) {
					GrandStrategyMapHeightIndent = 0;
				}
				if (GrandStrategyMapWidthIndent > 0) {
					GrandStrategyMapWidthIndent *= -1;
				}
				if (GrandStrategyMapHeightIndent > 0) {
					GrandStrategyMapHeightIndent *= -1;
				}
			} else {
				GameCursor = UI.Point.Cursor;
			}
		}
		
		//draw map
		GrandStrategyGame.DrawMap();
		
		// Fillers
		for (size_t i = 0; i != UI.Fillers.size(); ++i) {
			UI.Fillers[i].G->DrawClip(UI.Fillers[i].X, UI.Fillers[i].Y);
		}
		
		GrandStrategyGame.DrawMinimap();
		
		GrandStrategyGame.DrawInterface();
		
		if (UI.MapArea.Contains(CursorScreenPos) && GrandStrategyGame.WorldMapTiles[GrandStrategyGame.GetTileUnderCursor().x][GrandStrategyGame.GetTileUnderCursor().y] && !GrandStrategyGamePaused) {
			GrandStrategyGame.DrawTileTooltip(GrandStrategyGame.GetTileUnderCursor().x, GrandStrategyGame.GetTileUnderCursor().y);
		}
	//Wyrmgus end
	}

	DrawPieMenu(); // draw pie menu only if needed

	DrawGuichanWidgets();
	
	if (CursorState != CursorStateRectangle) {
		DrawCursor();
	}

	//
	// Update changes to display.
	//
	Invalidate();
}