Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectTypes/CMiniMap.cpp
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | |||||
CMiniMap::CMiniMap(CGUI& pGUI) : | CMiniMap::CMiniMap(CGUI& pGUI) : | ||||
IGUIObject(pGUI), | IGUIObject(pGUI), | ||||
m_MapSize(0), m_MapScale(1.f), | m_MapSize(0), m_MapScale(1.f), | ||||
m_EntitiesDrawn(0), m_IndexArray(GL_STATIC_DRAW), m_VertexArray(GL_DYNAMIC_DRAW), m_Mask(this, "mask", false), | m_EntitiesDrawn(0), m_IndexArray(GL_STATIC_DRAW), m_VertexArray(GL_DYNAMIC_DRAW), m_Mask(this, "mask", false), | ||||
m_NextBlinkTime(0.0), m_PingDuration(25.0), m_BlinkState(false), | m_NextBlinkTime(0.0), m_PingDuration(25.0), m_BlinkState(false), | ||||
m_FlareTextureCount(this, "flare_texture_count", 0), m_FlareRenderSize(this, "flare_render_size", 0), | m_FlareTextureCount(this, "flare_texture_count", 0), m_FlareRenderSize(this, "flare_render_size", 0), | ||||
m_FlareInterleave(this, "flare_interleave", false), m_FlareAnimationSpeed(this, "flare_animation_speed", 0.0f), | m_FlareInterleave(this, "flare_interleave", false), m_FlareAnimationSpeed(this, "flare_animation_speed", 0.0f), | ||||
m_FlareLifetimeSeconds(this, "flare_lifetime_seconds", 0.0f) | m_FlareLifetimeSeconds(this, "flare_lifetime_seconds", 0.0f), m_MoveCameraOnClick(this, "move_camera_on_click", true), | ||||
m_ShowCamera(this, "show_camera", true) | |||||
{ | { | ||||
m_Clicking = false; | m_Clicking = false; | ||||
m_MouseHovering = false; | m_MouseHovering = false; | ||||
m_AttributePos.type = GL_FLOAT; | m_AttributePos.type = GL_FLOAT; | ||||
m_AttributePos.elems = 2; | m_AttributePos.elems = 2; | ||||
m_VertexArray.AddAttribute(&m_AttributePos); | m_VertexArray.AddAttribute(&m_AttributePos); | ||||
▲ Show 20 Lines • Show All 147 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() | ||||
{ | { | ||||
if(!m_MoveCameraOnClick) return; | |||||
CTerrain* terrain = g_Game->GetWorld()->GetTerrain(); | 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); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 378 Lines • ▼ Show 20 Lines | |||||
#if !CONFIG2_GLES | #if !CONFIG2_GLES | ||||
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); | glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); | ||||
#endif | #endif | ||||
} | } | ||||
tech->EndPass(); | tech->EndPass(); | ||||
if(m_ShowCamera) | |||||
DrawViewRect(unitMatrix); | DrawViewRect(unitMatrix); | ||||
while (!m_MapFlares.empty() && m_FlareLifetimeSeconds + m_MapFlares.front().time < cur_time) | while (!m_MapFlares.empty() && m_FlareLifetimeSeconds + m_MapFlares.front().time < cur_time) | ||||
m_MapFlares.pop_front(); | m_MapFlares.pop_front(); | ||||
for (const MapFlare& flare : m_MapFlares) | for (const MapFlare& flare : m_MapFlares) | ||||
DrawFlare(canvas, flare, cur_time); | DrawFlare(canvas, flare, cur_time); | ||||
PROFILE_END("minimap units and flares"); | PROFILE_END("minimap units and flares"); | ||||
Show All 13 Lines |
Wildfire Games · Phabricator