Resources debug mode
parent
4af02c86f8
commit
e4f9360e63
|
@ -384,9 +384,10 @@ enum EventType
|
|||
EVENT_DBG_SPAWN_OBJ = 851,
|
||||
EVENT_DBG_TELEPORT = 852,
|
||||
EVENT_DBG_LIGHTNING = 853,
|
||||
EVENT_DBG_CRASHSPHERES = 854,
|
||||
EVENT_DBG_LIGHTS = 855,
|
||||
EVENT_DBG_LIGHTS_DUMP = 856,
|
||||
EVENT_DBG_RESOURCES = 854,
|
||||
EVENT_DBG_CRASHSPHERES = 855,
|
||||
EVENT_DBG_LIGHTS = 856,
|
||||
EVENT_DBG_LIGHTS_DUMP = 857,
|
||||
|
||||
EVENT_SPAWN_CANCEL = 860,
|
||||
EVENT_SPAWN_ME = 861,
|
||||
|
|
|
@ -3971,7 +3971,7 @@ void CEngine::UpdateGroundSpotTextures()
|
|||
set = true;
|
||||
}
|
||||
|
||||
if (clear || set)
|
||||
if (clear || set || m_debugResources)
|
||||
{
|
||||
CImage shadowImg(Math::IntPoint(256, 256));
|
||||
shadowImg.Fill(Gfx::IntColor(255, 255, 255, 255));
|
||||
|
@ -4131,6 +4131,29 @@ void CEngine::UpdateGroundSpotTextures()
|
|||
}
|
||||
}
|
||||
|
||||
if (m_debugResources)
|
||||
{
|
||||
for (float x = min.x; x < max.x; x += 1.0f)
|
||||
{
|
||||
for (float y = min.y; y < max.y; y += 1.0f)
|
||||
{
|
||||
Math::Vector pos(
|
||||
x / 4.0f / 254.0f * 3200.0f - 1600.0f,
|
||||
0.0f,
|
||||
y / 4.0f / 254.0f * 3200.0f - 1600.0f
|
||||
);
|
||||
TerrainRes res = m_terrain->GetResource(pos);
|
||||
Math::IntPoint p(x-min.x, y-min.y);
|
||||
if (res == TR_NULL)
|
||||
{
|
||||
shadowImg.SetPixel(p, Gfx::Color(0.5f, 0.5f, 0.5f));
|
||||
continue;
|
||||
}
|
||||
shadowImg.SetPixelInt(p, ResourceToColor(res));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << "textures/shadow" << std::setfill('0') << std::setw(2) << s << ".png";
|
||||
std::string texName = str.str();
|
||||
|
@ -5094,4 +5117,16 @@ void CEngine::DebugDumpLights()
|
|||
m_debugDumpLights = true;
|
||||
}
|
||||
|
||||
void CEngine::SetDebugResources(bool debugResources)
|
||||
{
|
||||
m_debugResources = debugResources;
|
||||
m_firstGroundSpot = true; // Force a refresh of ground spot textures
|
||||
UpdateGroundSpotTextures();
|
||||
}
|
||||
|
||||
bool CEngine::GetDebugResources()
|
||||
{
|
||||
return m_debugResources;
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -1188,6 +1188,9 @@ public:
|
|||
bool GetDebugLights();
|
||||
void DebugDumpLights();
|
||||
|
||||
void SetDebugResources(bool debugResources);
|
||||
bool GetDebugResources();
|
||||
|
||||
protected:
|
||||
//! Resets some states and flushes textures after device was changed (e.g. resoulution changed)
|
||||
/** Instead of calling this directly, send EVENT_RESOLUTION_CHANGED event **/
|
||||
|
@ -1478,6 +1481,7 @@ protected:
|
|||
bool m_debugLights;
|
||||
bool m_debugDumpLights;
|
||||
bool m_debugCrashSpheres = false;
|
||||
bool m_debugResources = false;
|
||||
|
||||
std::string m_timerText;
|
||||
|
||||
|
|
|
@ -192,6 +192,22 @@ void CTerrain::AddMaterial(int id, const std::string& texName, const Math::Point
|
|||
}
|
||||
|
||||
|
||||
// values from original bitmap palette
|
||||
const std::map<TerrainRes, Gfx::IntColor> RESOURCE_PALETTE = {
|
||||
{TR_STONE, Gfx::IntColor(255, 0, 0)},
|
||||
{TR_URANIUM, Gfx::IntColor(255, 255, 0)},
|
||||
{TR_POWER, Gfx::IntColor( 0, 255, 0)},
|
||||
{TR_KEY_A, Gfx::IntColor( 0, 204, 0)},
|
||||
{TR_KEY_B, Gfx::IntColor( 51, 204, 0)},
|
||||
{TR_KEY_C, Gfx::IntColor(102, 204, 0)},
|
||||
{TR_KEY_D, Gfx::IntColor(153, 204, 0)}
|
||||
};
|
||||
|
||||
Gfx::IntColor ResourceToColor(TerrainRes res)
|
||||
{
|
||||
return RESOURCE_PALETTE.at(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* The image must be 24 bits/pixel and grayscale and dx x dy in size
|
||||
* with dx = dy = (mosaic*brick)+1 */
|
||||
|
@ -224,21 +240,11 @@ bool CTerrain::LoadResources(const std::string& fileName)
|
|||
Gfx::IntColor pixel = img.GetPixelInt(Math::IntPoint(x, size - y - 1));
|
||||
TerrainRes res = TR_NULL;
|
||||
|
||||
// values from original bitmap palette
|
||||
if (pixel.r == 255 && pixel.g == 0 && pixel.b == 0)
|
||||
res = TR_STONE;
|
||||
else if (pixel.r == 255 && pixel.g == 255 && pixel.b == 0)
|
||||
res = TR_URANIUM;
|
||||
else if (pixel.r == 0 && pixel.g == 255 && pixel.b == 0)
|
||||
res = TR_POWER;
|
||||
else if (pixel.r == 0 && pixel.g == 204 && pixel.b == 0)
|
||||
res = TR_KEY_A;
|
||||
else if (pixel.r == 51 && pixel.g == 204 && pixel.b == 0)
|
||||
res = TR_KEY_B;
|
||||
else if (pixel.r == 102 && pixel.g == 204 && pixel.b == 0)
|
||||
res = TR_KEY_C;
|
||||
else if (pixel.r == 153 && pixel.g == 204 && pixel.b == 0)
|
||||
res = TR_KEY_D;
|
||||
for (const auto& it : RESOURCE_PALETTE)
|
||||
{
|
||||
if (pixel.r == it.second.r && pixel.g == it.second.g && pixel.b == it.second.b)
|
||||
res = it.first;
|
||||
}
|
||||
|
||||
m_resources[x+size*y] = static_cast<unsigned char>(res);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ enum TerrainRes
|
|||
TR_KEY_D = 7
|
||||
//@}
|
||||
};
|
||||
//! Converts TerrainRes to color
|
||||
Gfx::IntColor ResourceToColor(TerrainRes res);
|
||||
|
||||
/**
|
||||
* \class CTerrain
|
||||
|
|
|
@ -94,6 +94,9 @@ void CDebugMenu::CreateInterface()
|
|||
pc->SetName("Display stats");
|
||||
pos.y -= 0.048f;
|
||||
pos.y -= 0.048f;
|
||||
pc = pw->CreateCheck(pos, ddim, -1, EVENT_DBG_RESOURCES);
|
||||
pc->SetName("Underground resources");
|
||||
pos.y -= 0.048f;
|
||||
pc = pw->CreateCheck(pos, ddim, -1, EVENT_DBG_CRASHSPHERES);
|
||||
pc->SetName("Render crash spheres");
|
||||
pos.y -= 0.048f;
|
||||
|
@ -124,6 +127,7 @@ void CDebugMenu::CreateSpawnInterface()
|
|||
pos.y = oy+sy*9.0f;
|
||||
pb = pw->CreateButton(pos, ddim, -1, EVENT_SPAWN_CANCEL);
|
||||
pb->SetName("Cancel");
|
||||
pos.y -= ddim.y;
|
||||
|
||||
pos.y -= dim.y;
|
||||
pw->CreateButton(pos, dim, 128+8, EVENT_SPAWN_ME);
|
||||
|
@ -203,6 +207,12 @@ void CDebugMenu::UpdateInterface()
|
|||
pc->SetState(STATE_CHECK, m_engine->GetShowStats());
|
||||
}
|
||||
|
||||
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_DBG_RESOURCES));
|
||||
if (pc != nullptr)
|
||||
{
|
||||
pc->SetState(STATE_CHECK, m_engine->GetDebugResources());
|
||||
}
|
||||
|
||||
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_DBG_CRASHSPHERES));
|
||||
if (pc != nullptr)
|
||||
{
|
||||
|
@ -265,6 +275,11 @@ bool CDebugMenu::EventProcess(const Event &event)
|
|||
UpdateInterface();
|
||||
break;
|
||||
|
||||
case EVENT_DBG_RESOURCES:
|
||||
m_engine->SetDebugResources(!m_engine->GetDebugResources());
|
||||
UpdateInterface();
|
||||
break;
|
||||
|
||||
case EVENT_DBG_CRASHSPHERES:
|
||||
m_main->SetDebugCrashSpheres(!m_main->GetDebugCrashSpheres());
|
||||
UpdateInterface();
|
||||
|
|
Loading…
Reference in New Issue