Пример #1
0
void MiniMap::showBookMiniMap(int showLevel) {
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(m_levels[showLevel].m_texContainer) {
		
		GRenderer->SetRenderState(Renderer::DepthTest, false);
		
		float zoom = 900.f;
		
		Vec2f start = Vec2f_ZERO;
		Vec2f playerPos(0.f, 0.f);
		
		if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
			playerPos = computePlayerPos(zoom, showLevel);
			start = Vec2f(490.f, 220.f) - playerPos;
			playerPos += start;
		}
		
		drawBackground(showLevel, Rect(360, 85, 555, 355), start.x, start.y, zoom, 20.f);
		
		GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
		
		if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
			drawPlayer(6.f, playerPos);
			drawDetectedEntities(showLevel, start, zoom);
		}
		
	}
}
Пример #2
0
void MiniMap::showPlayerMiniMap(int showLevel) {
	
	const float miniMapZoom = 300.f; // zoom of the minimap
	const Rect miniMapRect(390, 135, 590, 295); // minimap rect on a 640*480 screen
	const float playerSize = 4.f; // red arrow size
	
	const float decalY = -150;
	const float decalX = +40;
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(m_levels[showLevel].m_texContainer) {
		
		GRenderer->SetRenderState(Renderer::DepthTest, false);
		
		float startX = 0.f;
		float startY = 0.f;
		
		Vec2f playerPos(0.f, 0.f);
		
		if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
			playerPos = computePlayerPos(miniMapZoom, showLevel);
			startX = 490.f - playerPos.x;
			startY = 220.f - playerPos.y;
			playerPos.x += startX;
			playerPos.y += startY;
		}
		
		// Draw the background
		drawBackground(showLevel, Rect(390, 135, 590, 295), startX, startY, miniMapZoom, 20.f, decalX, decalY, true, 0.5f);
		
		GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
		
		// Draw the player (red arrow)
		if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
			drawPlayer(playerSize, playerPos.x + decalX, playerPos.y + decalY, true);
			drawDetectedEntities(showLevel, startX + decalX, startY + decalY, miniMapZoom);
		}
		
	}
}
Пример #3
0
void MiniMap::revealPlayerPos(int showLevel) {
	
	float zoom = 250.f;
	float startX = 140.f;
	float startY = 120.f;
	float caseX = zoom / ((float)MINIMAP_MAX_X);
	float caseY = zoom / ((float)MINIMAP_MAX_Z);
	
	Vec2f playerPos = computePlayerPos(zoom, showLevel);
	playerPos.x += startX;
	playerPos.y += startY;
	
	// TODO this is inefficient - we don't really need to iterate over the whole minimap!
	// only the area around the player will be modified
	for(int j = 0; j < MINIMAP_MAX_Z; j++) {
		for(int i = 0; i < MINIMAP_MAX_X; i++) {
			
			float posx = startX + i * caseX;
			float posy = startY + j * caseY;
			
			float d = fdist(Vec2f(posx + caseX * 0.5f, posy), playerPos);
			if(d > 6.f) {
				continue;
			}
			
			float vv = (6 - d) * (1.f / 6);
			
			if(vv >= 0.5f) {
				vv = 1.f;
			} else if(vv > 0.f) {
				vv = vv * 2.f;
			} else {
				vv = 0.f;
			}
			
			int r = vv * 255.f;
			
			int ucLevel =  max(r, (int)m_levels[showLevel].m_revealed[i][j]);
			m_levels[showLevel].m_revealed[i][j] = checked_range_cast<unsigned char>(ucLevel);
		}
	}
}
Пример #4
0
void MiniMap::revealPlayerPos(int showLevel) {
	
	float zoom = 250.f;
	Vec2f start = Vec2f(140.f, 120.f);
	Vec2f cas;
	cas.x = zoom / MINIMAP_MAX_X;
	cas.y = zoom / MINIMAP_MAX_Z;
	
	Vec2f playerPos = computePlayerPos(zoom, showLevel);
	playerPos += start;
	
	// TODO this is inefficient - we don't really need to iterate over the whole minimap!
	// only the area around the player will be modified
	for(size_t z = 0; z < MINIMAP_MAX_Z; z++) {
	for(size_t x = 0; x < MINIMAP_MAX_X; x++) {
		
		Vec2f pos;
		pos.x = start.x + x * cas.x;
		pos.y = start.y + z * cas.y;
		
		float d = fdist(Vec2f(pos.x + cas.x * 0.5f, pos.y), playerPos);
		if(d > 6.f) {
			continue;
		}
		
		float vv = (6 - d) * (1.f / 6);
		
		if(vv >= 0.5f) {
			vv = 1.f;
		} else if(vv > 0.f) {
			vv = vv * 2.f;
		} else {
			vv = 0.f;
		}
		
		int r = vv * 255.f;
		
		int ucLevel = std::max(r, (int)m_levels[showLevel].m_revealed[x][z]);
		m_levels[showLevel].m_revealed[x][z] = checked_range_cast<unsigned char>(ucLevel);
	}
	}
}
Пример #5
0
void MiniMap::showPlayerMiniMap(int showLevel) {
	
	ARX_PROFILE_FUNC();
	
	const float miniMapZoom = 300.f; // zoom of the minimap
	const Rect miniMapRect(390, 135, 590, 295); // minimap rect on a 640*480 screen
	const float playerSize = 4.f; // red arrow size
	
	static const Vec2f decal = Vec2f(40.f, -150.f);
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(m_levels[showLevel].m_texContainer) {
		
		GRenderer->SetRenderState(Renderer::DepthTest, false);
		
		Vec2f start = Vec2f_ZERO;
		
		Vec2f playerPos(0.f, 0.f);
		
		if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
			playerPos = computePlayerPos(miniMapZoom, showLevel);
			start = Vec2f(490.f, 220.f) - playerPos;
			playerPos += start;
		}
		
		// Draw the background
		drawBackground(showLevel, Rect(390, 135, 590, 295), start, miniMapZoom, 20.f, decal, true, 0.5f);
		
		GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
		
		// Draw the player (red arrow)
		if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
			drawPlayer(playerSize, playerPos + decal, true);
			drawDetectedEntities(showLevel, start + decal, miniMapZoom);
		}
		
	}
}
Пример #6
0
void MiniMap::showBookEntireMap(int showLevel) {
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(!m_levels[showLevel].m_texContainer) {
		return;
	}
	
	GRenderer->SetRenderState(Renderer::DepthTest, false);
	
	float zoom = 250.f;
	float startX = 140.f;
	float startY = 120.f;
	
	Vec2f playerPos(0.f, 0.f);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		playerPos = computePlayerPos(zoom, showLevel);
		playerPos.x += startX;
		playerPos.y += startY;
	}
	
	drawBackground(showLevel, Rect(0, 0, 345, 290), startX, startY, zoom);
	
	GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		drawPlayer(3.f, playerPos.x, playerPos.y);
		drawDetectedEntities(showLevel, startX, startY, zoom);
	}
	
	TexturedVertex verts[4];
	for(int k = 0; k < 4; k++) {
		verts[k].color = 0xFFFFFFFF;
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	float caseX = zoom / ((float)MINIMAP_MAX_X);
	float caseY = zoom / ((float)MINIMAP_MAX_Z);
	float ratio = 1.f;
	
	for(size_t i = 0; i < m_mapMarkers.size(); i++) {
		
		if(m_mapMarkers[i].m_lvl != showLevel + 1) {
			continue;
		}
		
		float pos_x = m_mapMarkers[i].m_x * 8 * ratio * m_activeBkg->Xmul * caseX + startX;
		float pos_y = m_mapMarkers[i].m_y * 8 * ratio * m_activeBkg->Zmul * caseY + startY;
		float size = 5.f * ratio;
		verts[0].color = 0xFFFF0000;
		verts[1].color = 0xFFFF0000;
		verts[2].color = 0xFFFF0000;
		verts[3].color = 0xFFFF0000;
		verts[0].p.x = (pos_x - size) * Xratio;
		verts[0].p.y = (pos_y - size) * Yratio;
		verts[1].p.x = (pos_x + size) * Xratio;
		verts[1].p.y = (pos_y - size) * Yratio;
		verts[2].p.x = (pos_x + size) * Xratio;
		verts[2].p.y = (pos_y + size) * Yratio;
		verts[3].p.x = (pos_x - size) * Xratio;
		verts[3].p.y = (pos_y + size) * Yratio;
		verts[0].uv = Vec2f::ZERO;
		verts[1].uv = Vec2f::X_AXIS;
		verts[2].uv = Vec2f::ONE;
		verts[3].uv = Vec2f::Y_AXIS;
		
		if(MouseInRect(verts[0].p.x, verts[0].p.y, verts[2].p.x, verts[2].p.y)) {
			if(!m_mapMarkers[i].m_text.empty()) {
				
				Rect bRect(140, 290, 140 + 205, 358);
				
				Rect::Num left = checked_range_cast<Rect::Num>((bRect.left) * Xratio);
				Rect::Num right = checked_range_cast<Rect::Num>((bRect.right) * Xratio);
				Rect::Num top = checked_range_cast<Rect::Num>((bRect.top) * Yratio);
				Rect::Num bottom = checked_range_cast<Rect::Num>((bRect.bottom) * Yratio);
				Rect rRect = Rect(left, top, right, bottom);
				
				long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, m_mapMarkers[i].m_text, rRect);
				
				DrawBookTextInRect(hFontInGameNote, float(bRect.left), float(bRect.top), float(bRect.right), m_mapMarkers[i].m_text.substr(0, lLengthDraw), Color::none);
			}
		}
		
		if(m_mapMarkerTexCont == NULL) {
			m_mapMarkerTexCont = TextureContainer::Load("graph/interface/icons/mapmarker");
		}
		
		GRenderer->SetTexture(0, m_mapMarkerTexCont);
		
		EERIEDRAWPRIM(Renderer::TriangleFan, verts, 4);
	}
}
Пример #7
0
void MiniMap::showBookEntireMap(int showLevel) {
	
	// First Load Minimap TC & DATA if needed
	if(m_levels[showLevel].m_texContainer == NULL) {
		getData(showLevel);
	}
	
	if(!m_levels[showLevel].m_texContainer) {
		return;
	}
	
	GRenderer->SetRenderState(Renderer::DepthTest, false);
	
	float zoom = 250.f;
	
	Vec2f start(140.f, 120.f);
	
	Vec2f playerPos(0.f, 0.f);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		playerPos = computePlayerPos(zoom, showLevel);
		playerPos += start;
	}
	
	drawBackground(showLevel, Rect(0, 0, 345, 290), start, zoom);
	
	GRenderer->GetTextureStage(0)->setWrapMode(TextureStage::WrapRepeat);
	
	if(showLevel == ARX_LEVELS_GetRealNum(m_currentLevel)) {
		drawPlayer(3.f, playerPos, false);
		drawDetectedEntities(showLevel, start, zoom);
	}
	
	TexturedVertex verts[4];
	for(int k = 0; k < 4; k++) {
		verts[k].color = Color(255, 255, 255, 255).toRGBA();
		verts[k].rhw = 1;
		verts[k].p.z = 0.00001f;
	}
	
	Vec2f casePos(zoom / MINIMAP_MAX_X, zoom / MINIMAP_MAX_Z);
	float ratio = 1.f;
	
	for(size_t i = 0; i < m_mapMarkers.size(); i++) {
		
		if(m_mapMarkers[i].m_lvl != showLevel + 1) {
			continue;
		}
		
		Vec2f pos;
		pos.x = m_mapMarkers[i].m_pos.x * 8 * ratio * m_activeBkg->Xmul * casePos.x + start.x;
		pos.y = m_mapMarkers[i].m_pos.y * 8 * ratio * m_activeBkg->Zmul * casePos.y + start.y;
		
		float size = 5.f * ratio;
		verts[0].color = Color(255, 0, 0, 255).toRGBA();
		verts[1].color = Color(255, 0, 0, 255).toRGBA();
		verts[2].color = Color(255, 0, 0, 255).toRGBA();
		verts[3].color = Color(255, 0, 0, 255).toRGBA();
		verts[0].p.x = (pos.x - size) * g_sizeRatio.x;
		verts[0].p.y = (pos.y - size) * g_sizeRatio.y;
		verts[1].p.x = (pos.x + size) * g_sizeRatio.x;
		verts[1].p.y = (pos.y - size) * g_sizeRatio.y;
		verts[2].p.x = (pos.x + size) * g_sizeRatio.x;
		verts[2].p.y = (pos.y + size) * g_sizeRatio.y;
		verts[3].p.x = (pos.x - size) * g_sizeRatio.x;
		verts[3].p.y = (pos.y + size) * g_sizeRatio.y;
		verts[0].uv = Vec2f_ZERO;
		verts[1].uv = Vec2f_X_AXIS;
		verts[2].uv = Vec2f_ONE;
		verts[3].uv = Vec2f_Y_AXIS;
		
		const Rect mouseTestRect(
			verts[0].p.x,
			verts[0].p.y,
			verts[2].p.x,
			verts[2].p.y
		);
		
		if(mouseTestRect.contains(Vec2i(DANAEMouse))) {
			if(!m_mapMarkers[i].m_text.empty()) {
				
				Rect bRect(140, 295, 140 + 205, 358);
				
				Rect::Num left = checked_range_cast<Rect::Num>((bRect.left) * g_sizeRatio.x);
				Rect::Num right = checked_range_cast<Rect::Num>((bRect.right) * g_sizeRatio.x);
				Rect::Num top = checked_range_cast<Rect::Num>((bRect.top) * g_sizeRatio.y);
				Rect::Num bottom = checked_range_cast<Rect::Num>((bRect.bottom) * g_sizeRatio.y);
				Rect rRect = Rect(left, top, right, bottom);
				
				long lLengthDraw = ARX_UNICODE_ForceFormattingInRect(hFontInGameNote, m_mapMarkers[i].m_text, rRect);
				
				
				ARX_UNICODE_DrawTextInRect(hFontInGameNote,
				                           (BOOKDEC + Vec2f(bRect.topLeft())) * g_sizeRatio,
				                           (BOOKDEC.x + float(bRect.right)) * g_sizeRatio.x,
				                           m_mapMarkers[i].m_text.substr(0, lLengthDraw),
				                           Color::none);
			}
		}
		
		if(m_mapMarkerTexCont == NULL) {
			m_mapMarkerTexCont = TextureContainer::Load("graph/interface/icons/mapmarker");
		}
		
		GRenderer->SetTexture(0, m_mapMarkerTexCont);
		
		EERIEDRAWPRIM(Renderer::TriangleFan, verts, 4);
	}
}