Changeset View
Changeset View
Standalone View
Standalone View
source/gui/MiniMap.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/RenderingOptions.h" | #include "renderer/RenderingOptions.h" | ||||
#include "renderer/WaterManager.h" | #include "renderer/WaterManager.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "simulation2/components/ICmpMinimap.h" | #include "simulation2/components/ICmpMinimap.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/system/ParamNode.h" | #include "simulation2/system/ParamNode.h" | ||||
#include <math.h> | #include <cmath> | ||||
extern bool g_GameRestarted; | extern bool g_GameRestarted; | ||||
// Set max drawn entities to UINT16_MAX for now, which is more than enough | // Set max drawn entities to UINT16_MAX for now, which is more than enough | ||||
// TODO: we should be cleverer about drawing them to reduce clutter | // TODO: we should be cleverer about drawing them to reduce clutter | ||||
const u16 MAX_ENTITIES_DRAWN = 65535; | const u16 MAX_ENTITIES_DRAWN = 65535; | ||||
static unsigned int ScaleColor(unsigned int color, float x) | static unsigned int ScaleColor(unsigned int color, float x) | ||||
{ | { | ||||
unsigned int r = unsigned(float(color & 0xff) * x); | unsigned int r = unsigned(float(color & 0xff) * x); | ||||
unsigned int g = unsigned(float((color>>8) & 0xff) * x); | unsigned int g = unsigned(float((color>>8) & 0xff) * x); | ||||
unsigned int b = unsigned(float((color>>16) & 0xff) * x); | unsigned int b = unsigned(float((color>>16) & 0xff) * x); | ||||
return (0xff000000 | b | g<<8 | r<<16); | return (0xff000000 | b | g<<8 | r<<16); | ||||
} | } | ||||
float CMiniMap::GetShallowPassageHeight() | |||||
{ | |||||
float shallowPassageHeight = 0.0f; | |||||
CParamNode externalParamNode; | |||||
CParamNode::LoadXML(externalParamNode, L"simulation/data/pathfinder.xml", "pathfinder"); | |||||
const CParamNode pathingSettings = externalParamNode.GetChild("Pathfinder").GetChild("PassabilityClasses"); | |||||
if (pathingSettings.GetChild("default").IsOk() && pathingSettings.GetChild("default").GetChild("MaxWaterDepth").IsOk()) | |||||
shallowPassageHeight = pathingSettings.GetChild("default").GetChild("MaxWaterDepth").ToFloat(); | |||||
return shallowPassageHeight; | |||||
} | |||||
CMiniMap::CMiniMap(CGUI& pGUI) : | CMiniMap::CMiniMap(CGUI& pGUI) : | ||||
IGUIObject(pGUI), | IGUIObject(pGUI), | ||||
m_TerrainTexture(0), m_TerrainData(0), m_MapSize(0), m_Terrain(0), m_TerrainDirty(true), m_MapScale(1.f), | m_TerrainTexture(0), m_TerrainData(0), m_MapSize(0), m_Terrain(0), m_TerrainDirty(true), m_MapScale(1.f), | ||||
m_EntitiesDrawn(0), m_IndexArray(GL_STATIC_DRAW), m_VertexArray(GL_DYNAMIC_DRAW), | m_EntitiesDrawn(0), m_IndexArray(GL_STATIC_DRAW), m_VertexArray(GL_DYNAMIC_DRAW), | ||||
m_NextBlinkTime(0.0), m_PingDuration(25.0), m_BlinkState(false), m_WaterHeight(0.0) | m_NextBlinkTime(0.0), m_PingDuration(25.0), m_BlinkState(false), m_WaterHeight(0.0) | ||||
{ | { | ||||
m_Clicking = false; | m_Clicking = false; | ||||
m_MouseHovering = false; | m_MouseHovering = false; | ||||
// Register Relax NG validator | // Register Relax NG validator | ||||
CXeromyces::AddValidator(g_VFS, "pathfinder", "simulation/data/pathfinder.rng"); | CXeromyces::AddValidator(g_VFS, "pathfinder", "simulation/data/pathfinder.rng"); | ||||
// Get the maximum height for unit passage in water. | m_ShallowPassageHeight = GetShallowPassageHeight(); | ||||
CParamNode externalParamNode; | |||||
CParamNode::LoadXML(externalParamNode, L"simulation/data/pathfinder.xml", "pathfinder"); | |||||
const CParamNode pathingSettings = externalParamNode.GetChild("Pathfinder").GetChild("PassabilityClasses"); | |||||
if (pathingSettings.GetChild("default").IsOk() && pathingSettings.GetChild("default").GetChild("MaxWaterDepth").IsOk()) | |||||
m_ShallowPassageHeight = pathingSettings.GetChild("default").GetChild("MaxWaterDepth").ToFloat(); | |||||
else | |||||
m_ShallowPassageHeight = 0.0f; | |||||
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); | ||||
m_AttributeColor.type = GL_UNSIGNED_BYTE; | m_AttributeColor.type = GL_UNSIGNED_BYTE; | ||||
m_AttributeColor.elems = 4; | m_AttributeColor.elems = 4; | ||||
m_VertexArray.AddAttribute(&m_AttributeColor); | m_VertexArray.AddAttribute(&m_AttributeColor); | ||||
▲ Show 20 Lines • Show All 616 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator