Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/ObjectTypes/CMiniMap.cpp
Show First 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | void CMiniMap::GetMouseWorldCoordinates(float& x, float& z) const | ||||
// Scale world coordinates for shrunken square map | // Scale world coordinates for shrunken square map | ||||
x = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5); | x = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5); | ||||
z = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5); | z = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5); | ||||
} | } | ||||
void CMiniMap::SetCameraPositionFromMousePosition() | void CMiniMap::SetCameraPositionFromMousePosition() | ||||
{ | { | ||||
CTerrain* terrain = g_Game->GetWorld()->GetTerrain(); | const CTerrain& terrain = g_Game->GetWorld()->GetTerrain(); | ||||
CVector3D target; | CVector3D target; | ||||
GetMouseWorldCoordinates(target.X, target.Z); | GetMouseWorldCoordinates(target.X, target.Z); | ||||
target.Y = terrain->GetExactGroundLevel(target.X, target.Z); | target.Y = terrain.GetExactGroundLevel(target.X, target.Z); | ||||
g_Game->GetView()->MoveCameraTarget(target); | g_Game->GetView()->MoveCameraTarget(target); | ||||
} | } | ||||
float CMiniMap::GetAngle() const | float CMiniMap::GetAngle() const | ||||
{ | { | ||||
CVector3D cameraIn = g_Game->GetView()->GetCamera()->GetOrientation().GetIn(); | CVector3D cameraIn = g_Game->GetView()->GetCamera()->GetOrientation().GetIn(); | ||||
return -atan2(cameraIn.X, cameraIn.Z); | return -atan2(cameraIn.X, cameraIn.Z); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | void CMiniMap::Draw(CCanvas2D& canvas) | ||||
if (!m_Mask) | if (!m_Mask) | ||||
canvas.DrawRect(m_CachedActualSize, CColor(0.0f, 0.0f, 0.0f, 1.0f)); | canvas.DrawRect(m_CachedActualSize, CColor(0.0f, 0.0f, 0.0f, 1.0f)); | ||||
CSimulation2* sim = g_Game->GetSimulation2(); | CSimulation2* sim = g_Game->GetSimulation2(); | ||||
CmpPtr<ICmpRangeManager> cmpRangeManager(*sim, SYSTEM_ENTITY); | CmpPtr<ICmpRangeManager> cmpRangeManager(*sim, SYSTEM_ENTITY); | ||||
ENSURE(cmpRangeManager); | ENSURE(cmpRangeManager); | ||||
// Set our globals in case they hadn't been set before | // Set our globals in case they hadn't been set before | ||||
const CTerrain* terrain = g_Game->GetWorld()->GetTerrain(); | const CTerrain& terrain = g_Game->GetWorld()->GetTerrain(); | ||||
m_MapSize = terrain->GetVerticesPerSide(); | m_MapSize = terrain.GetVerticesPerSide(); | ||||
m_MapScale = (cmpRangeManager->GetLosCircular() ? 1.f : 1.414f); | m_MapScale = (cmpRangeManager->GetLosCircular() ? 1.f : 1.414f); | ||||
// Draw the main textured quad | // Draw the main textured quad | ||||
CMiniMapTexture& miniMapTexture = g_Game->GetView()->GetMiniMapTexture(); | CMiniMapTexture& miniMapTexture = g_Game->GetView()->GetMiniMapTexture(); | ||||
if (miniMapTexture.GetTexture()) | if (miniMapTexture.GetTexture()) | ||||
{ | { | ||||
const CVector2D center = m_CachedActualSize.CenterPoint(); | const CVector2D center = m_CachedActualSize.CenterPoint(); | ||||
const CRect source( | const CRect source( | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator