Reduce exported functions in debug.h
This commit is contained in:
parent
8a71b9ded3
commit
9678d002d3
3 changed files with 69 additions and 52 deletions
|
|
@ -32,14 +32,32 @@ std::optional<CelSprite> pSquareCel;
|
|||
bool DebugToggle = false;
|
||||
bool DebugGodMode = false;
|
||||
bool DebugVision = false;
|
||||
bool DebugCoords = false;
|
||||
bool DebugCursorCoords = false;
|
||||
bool DebugGrid = false;
|
||||
std::unordered_map<int, Point> DebugCoordsMap;
|
||||
DebugInfoFlags DebugInfoFlag;
|
||||
|
||||
namespace {
|
||||
|
||||
enum class DebugInfoFlags : uint16_t {
|
||||
// clang-format off
|
||||
empty = 0,
|
||||
dPiece = 1 << 0,
|
||||
dTransVal = 1 << 1,
|
||||
dLight = 1 << 2,
|
||||
dPreLight = 1 << 3,
|
||||
dFlags = 1 << 4,
|
||||
dPlayer = 1 << 5,
|
||||
dMonster = 1 << 6,
|
||||
dCorpse = 1 << 7,
|
||||
dObject = 1 << 8,
|
||||
dItem = 1 << 9,
|
||||
dSpecial = 1 << 10,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
bool DebugCoords = false;
|
||||
bool DebugCursorCoords = false;
|
||||
DebugInfoFlags DebugInfoFlag;
|
||||
|
||||
int DebugPlayerId;
|
||||
int DebugQuestId;
|
||||
int DebugMonsterId;
|
||||
|
|
@ -747,31 +765,60 @@ bool CheckDebugTextCommand(const string_view text)
|
|||
return true;
|
||||
}
|
||||
|
||||
int DebugGetTileData(Point dungeonCoords)
|
||||
bool IsDebugGridTextNeeded()
|
||||
{
|
||||
return DebugCoords || DebugGrid || DebugCursorCoords || DebugInfoFlag != DebugInfoFlags::empty;
|
||||
}
|
||||
|
||||
bool GetDebugGridText(Point dungeonCoords, char *debugGridTextBuffer)
|
||||
{
|
||||
if (DebugCoords) {
|
||||
sprintf(debugGridTextBuffer, "%d:%d", dungeonCoords.x, dungeonCoords.y);
|
||||
return true;
|
||||
}
|
||||
if (DebugCursorCoords) {
|
||||
if (dungeonCoords != cursPosition)
|
||||
return false;
|
||||
sprintf(debugGridTextBuffer, "%d:%d", dungeonCoords.x, dungeonCoords.y);
|
||||
return true;
|
||||
}
|
||||
int info = 0;
|
||||
switch (DebugInfoFlag) {
|
||||
case DebugInfoFlags::dPiece:
|
||||
return dPiece[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dPiece[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dTransVal:
|
||||
return dTransVal[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dTransVal[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dLight:
|
||||
return dLight[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dLight[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dPreLight:
|
||||
return dPreLight[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dPreLight[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dFlags:
|
||||
return dFlags[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dFlags[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dPlayer:
|
||||
return dPlayer[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dPlayer[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dMonster:
|
||||
return dMonster[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dMonster[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dCorpse:
|
||||
return dCorpse[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dCorpse[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dItem:
|
||||
return dItem[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dItem[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
case DebugInfoFlags::dSpecial:
|
||||
return dSpecial[dungeonCoords.x][dungeonCoords.y];
|
||||
info = dSpecial[dungeonCoords.x][dungeonCoords.y];
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
if (info == 0)
|
||||
return false;
|
||||
sprintf(debugGridTextBuffer, "%d", info);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -15,32 +15,12 @@
|
|||
|
||||
namespace devilution {
|
||||
|
||||
enum class DebugInfoFlags : uint16_t {
|
||||
// clang-format off
|
||||
empty = 0,
|
||||
dPiece = 1 << 0,
|
||||
dTransVal = 1 << 1,
|
||||
dLight = 1 << 2,
|
||||
dPreLight = 1 << 3,
|
||||
dFlags = 1 << 4,
|
||||
dPlayer = 1 << 5,
|
||||
dMonster = 1 << 6,
|
||||
dCorpse = 1 << 7,
|
||||
dObject = 1 << 8,
|
||||
dItem = 1 << 9,
|
||||
dSpecial = 1 << 10,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
extern std::optional<CelSprite> pSquareCel;
|
||||
extern bool DebugToggle;
|
||||
extern bool DebugGodMode;
|
||||
extern bool DebugVision;
|
||||
extern bool DebugCoords;
|
||||
extern bool DebugCursorCoords;
|
||||
extern bool DebugGrid;
|
||||
extern std::unordered_map<int, Point> DebugCoordsMap;
|
||||
extern DebugInfoFlags DebugInfoFlag;
|
||||
|
||||
void FreeDebugGFX();
|
||||
void LoadDebugGFX();
|
||||
|
|
@ -50,6 +30,7 @@ void GetDebugMonster();
|
|||
void NextDebugMonster();
|
||||
void SetDebugLevelSeedInfos(uint32_t mid1Seed, uint32_t mid2Seed, uint32_t mid3Seed, uint32_t endSeed);
|
||||
bool CheckDebugTextCommand(const string_view text);
|
||||
int DebugGetTileData(Point dungeonCoords);
|
||||
bool IsDebugGridTextNeeded();
|
||||
bool GetDebugGridText(Point dungeonCoords, char *debugGridTextBuffer);
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -1201,32 +1201,21 @@ void DrawView(const Surface &out, Point startPosition)
|
|||
DrawAutomap(out.subregionY(0, gnViewportHeight));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
bool debugInfo = DebugInfoFlag != DebugInfoFlags::empty;
|
||||
if (DebugCoords || DebugGrid || DebugCursorCoords || debugInfo) {
|
||||
bool debugGridTextNeeded = IsDebugGridTextNeeded();
|
||||
if (debugGridTextNeeded || DebugGrid) {
|
||||
// force redrawing or debug stuff stays on panel on 640x480 resolution
|
||||
force_redraw = 255;
|
||||
char debugGridTextBuffer[10];
|
||||
for (auto m : DebugCoordsMap) {
|
||||
Point dunCoords = { m.first % MAXDUNX, m.first / MAXDUNX };
|
||||
Point pixelCoords = m.second;
|
||||
if (!zoomflag)
|
||||
pixelCoords *= 2;
|
||||
if (DebugCoords || (DebugCursorCoords && dunCoords == cursPosition) || debugInfo) {
|
||||
char buffer[10];
|
||||
bool drawText = true;
|
||||
if (!debugInfo)
|
||||
sprintf(buffer, "%d:%d", dunCoords.x, dunCoords.y);
|
||||
else {
|
||||
int value = DebugGetTileData(dunCoords);
|
||||
sprintf(buffer, "%d", value);
|
||||
if (value == 0)
|
||||
drawText = false;
|
||||
}
|
||||
|
||||
if (debugGridTextNeeded && GetDebugGridText(dunCoords, debugGridTextBuffer)) {
|
||||
Size tileSize = { TILE_WIDTH, TILE_HEIGHT };
|
||||
if (!zoomflag)
|
||||
tileSize *= 2;
|
||||
if (drawText)
|
||||
DrawString(out, buffer, { pixelCoords - Displacement { 0, tileSize.height }, tileSize }, UiFlags::ColorRed | UiFlags::AlignCenter | UiFlags::VerticalCenter);
|
||||
DrawString(out, debugGridTextBuffer, { pixelCoords - Displacement { 0, tileSize.height }, tileSize }, UiFlags::ColorRed | UiFlags::AlignCenter | UiFlags::VerticalCenter);
|
||||
}
|
||||
if (DebugGrid) {
|
||||
auto DrawLine = [&out](Point from, Point to, uint8_t col) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue