From d265ce29a2e31c8b07dfacee1c9dcdcc7d7a4171 Mon Sep 17 00:00:00 2001 From: catdbg Date: Fri, 6 Mar 2026 13:34:37 -0800 Subject: [PATCH] Scale debug overlay, truncate terrain lines (#751) --- Minecraft.Client/Gui.cpp | 55 +++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/Minecraft.Client/Gui.cpp b/Minecraft.Client/Gui.cpp index c59cb063..7353e802 100644 --- a/Minecraft.Client/Gui.cpp +++ b/Minecraft.Client/Gui.cpp @@ -846,17 +846,29 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) MemSect(31); if (minecraft->options->renderDebug) { + const int debugLeft = 1; + const int debugTop = 1; + const float maxContentWidth = 1200.f; + const float maxContentHeight = 420.f; + float scale = (float)(screenWidth - debugLeft - 8) / maxContentWidth; + float scaleV = (float)(screenHeight - debugTop - 80) / maxContentHeight; + if (scaleV < scale) scale = scaleV; + if (scale > 1.f) scale = 1.f; + if (scale < 0.5f) scale = 0.5f; glPushMatrix(); + glTranslatef((float)debugLeft, (float)debugTop, 0.f); + glScalef(scale, scale, 1.f); + glTranslatef((float)-debugLeft, (float)-debugTop, 0.f); if (Minecraft::warezTime > 0) glTranslatef(0, 32, 0); - font->drawShadow(ClientConstants::VERSION_STRING + L" (" + minecraft->fpsString + L")", iSafezoneXHalf+2, 20, 0xffffff); - font->drawShadow(L"Seed: " + std::to_wstring(minecraft->level->getLevelData()->getSeed() ), iSafezoneXHalf+2, 32 + 00, 0xffffff); - font->drawShadow(minecraft->gatherStats1(), iSafezoneXHalf+2, 32 + 10, 0xffffff); - font->drawShadow(minecraft->gatherStats2(), iSafezoneXHalf+2, 32 + 20, 0xffffff); - font->drawShadow(minecraft->gatherStats3(), iSafezoneXHalf+2, 32 + 30, 0xffffff); - font->drawShadow(minecraft->gatherStats4(), iSafezoneXHalf+2, 32 + 40, 0xffffff); + font->drawShadow(ClientConstants::VERSION_STRING + L" (" + minecraft->fpsString + L")", debugLeft, debugTop, 0xffffff); + font->drawShadow(L"Seed: " + std::to_wstring(minecraft->level->getLevelData()->getSeed() ), debugLeft, debugTop + 12, 0xffffff); + font->drawShadow(minecraft->gatherStats1(), debugLeft, debugTop + 22, 0xffffff); + font->drawShadow(minecraft->gatherStats2(), debugLeft, debugTop + 32, 0xffffff); + font->drawShadow(minecraft->gatherStats3(), debugLeft, debugTop + 42, 0xffffff); + font->drawShadow(minecraft->gatherStats4(), debugLeft, debugTop + 52, 0xffffff); // TERRAIN FEATURES - int iYPos=82; + int iYPos = debugTop + 62; if(minecraft->level->dimension->id==0) { @@ -867,18 +879,31 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) wfeature[eTerrainFeature_Village] = L"Village: "; wfeature[eTerrainFeature_Ravine] = L"Ravine: "; - for(int i=0;iwidth(L"..."); + bool truncated[eTerrainFeature_Count] = {}; + + for (int i = 0; i < (int)app.m_vTerrainFeatures.size(); i++) { FEATURE_DATA *pFeatureData=app.m_vTerrainFeatures[i]; + int type = pFeatureData->eTerrainFeature; + if (type < eTerrainFeature_Stronghold || type > eTerrainFeature_Ravine) continue; + if (truncated[type]) continue; wstring itemInfo = L"[" + std::to_wstring( pFeatureData->x*16 ) + L", " + std::to_wstring( pFeatureData->z*16 ) + L"] "; - wfeature[pFeatureData->eTerrainFeature] += itemInfo; + if (font->width(wfeature[type] + itemInfo) <= maxWForContent) + wfeature[type] += itemInfo; + else + { + wfeature[type] += L"..."; + truncated[type] = true; + } } for( int i = eTerrainFeature_Stronghold; i < (int) eTerrainFeature_Count; i++ ) { - font->drawShadow(wfeature[i], iSafezoneXHalf + 2, iYPos, 0xffffff); iYPos+=10; + font->drawShadow(wfeature[i], debugLeft, iYPos, 0xffffff); } } @@ -899,10 +924,10 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) double xBlockPos = floor(minecraft->player->x); double yBlockPos = floor(minecraft->player->y); double zBlockPos = floor(minecraft->player->z); - drawString(font, L"x: " + std::to_wstring(minecraft->player->x) + L"/ Head: " + std::to_wstring(static_cast(xBlockPos)) + L"/ Chunk: " + std::to_wstring(minecraft->player->xChunk), iSafezoneXHalf+2, iYPos + 8 * 0, 0xe0e0e0); - drawString(font, L"y: " + std::to_wstring(minecraft->player->y) + L"/ Head: " + std::to_wstring(static_cast(yBlockPos)), iSafezoneXHalf+2, iYPos + 8 * 1, 0xe0e0e0); - drawString(font, L"z: " + std::to_wstring(minecraft->player->z) + L"/ Head: " + std::to_wstring(static_cast(zBlockPos)) + L"/ Chunk: " + std::to_wstring(minecraft->player->zChunk), iSafezoneXHalf+2, iYPos + 8 * 2, 0xe0e0e0); - drawString(font, L"f: " + std::to_wstring(Mth::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) & 0x3) + L"/ yRot: " + std::to_wstring(minecraft->player->yRot), iSafezoneXHalf+2, iYPos + 8 * 3, 0xe0e0e0); + drawString(font, L"x: " + std::to_wstring(minecraft->player->x) + L"/ Head: " + std::to_wstring(static_cast(xBlockPos)) + L"/ Chunk: " + std::to_wstring(minecraft->player->xChunk), debugLeft, iYPos + 8 * 0, 0xe0e0e0); + drawString(font, L"y: " + std::to_wstring(minecraft->player->y) + L"/ Head: " + std::to_wstring(static_cast(yBlockPos)), debugLeft, iYPos + 8 * 1, 0xe0e0e0); + drawString(font, L"z: " + std::to_wstring(minecraft->player->z) + L"/ Head: " + std::to_wstring(static_cast(zBlockPos)) + L"/ Chunk: " + std::to_wstring(minecraft->player->zChunk), debugLeft, iYPos + 8 * 2, 0xe0e0e0); + drawString(font, L"f: " + std::to_wstring(Mth::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) & 0x3) + L"/ yRot: " + std::to_wstring(minecraft->player->yRot), debugLeft, iYPos + 8 * 3, 0xe0e0e0); iYPos += 8*4; int px = Mth::floor(minecraft->player->x); @@ -914,7 +939,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) Biome *biome = chunkAt->getBiome(px & 15, pz & 15, minecraft->level->getBiomeSource()); drawString( font, - L"b: " + biome->m_name + L" (" + std::to_wstring(biome->id) + L")", iSafezoneXHalf+2, iYPos, 0xe0e0e0); + L"b: " + biome->m_name + L" (" + std::to_wstring(biome->id) + L")", debugLeft, iYPos, 0xe0e0e0); } glPopMatrix();