add megatiles to tiledata (#3211)
This commit is contained in:
parent
d669f8ce19
commit
46ed79ad42
3 changed files with 69 additions and 15 deletions
|
|
@ -52,14 +52,23 @@ enum class DebugGridTextItem : uint16_t {
|
|||
dObject,
|
||||
dItem,
|
||||
dSpecial,
|
||||
|
||||
coords,
|
||||
cursorcoords,
|
||||
objectindex,
|
||||
|
||||
//take dPiece as index
|
||||
nBlockTable,
|
||||
nSolidTable,
|
||||
nTransTable,
|
||||
nMissileTable,
|
||||
nTrapTable,
|
||||
|
||||
// megatiles
|
||||
AutomapView,
|
||||
dungeon,
|
||||
pdungeon,
|
||||
dflags,
|
||||
};
|
||||
|
||||
DebugGridTextItem SelectedDebugGridTextItem;
|
||||
|
|
@ -611,6 +620,10 @@ std::string DebugCmdShowTileData(const string_view parameter)
|
|||
"nTransTable",
|
||||
"nMissileTable",
|
||||
"nTrapTable",
|
||||
"AutomapView",
|
||||
"dungeon",
|
||||
"pdungeon",
|
||||
"dflags",
|
||||
};
|
||||
|
||||
if (parameter == "clear") {
|
||||
|
|
@ -813,9 +826,22 @@ bool IsDebugGridTextNeeded()
|
|||
return SelectedDebugGridTextItem != DebugGridTextItem::None;
|
||||
}
|
||||
|
||||
bool IsDebugGridInMegatiles()
|
||||
{
|
||||
switch (SelectedDebugGridTextItem) {
|
||||
case DebugGridTextItem::AutomapView:
|
||||
case DebugGridTextItem::dungeon:
|
||||
case DebugGridTextItem::pdungeon:
|
||||
case DebugGridTextItem::dflags:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetDebugGridText(Point dungeonCoords, char *debugGridTextBuffer)
|
||||
{
|
||||
int info = 0;
|
||||
Point megaCoords = { (dungeonCoords.x - 16) / 2, (dungeonCoords.y - 16) / 2 };
|
||||
switch (SelectedDebugGridTextItem) {
|
||||
case DebugGridTextItem::coords:
|
||||
sprintf(debugGridTextBuffer, "%d:%d", dungeonCoords.x, dungeonCoords.y);
|
||||
|
|
@ -882,6 +908,18 @@ bool GetDebugGridText(Point dungeonCoords, char *debugGridTextBuffer)
|
|||
case DebugGridTextItem::nTrapTable:
|
||||
info = nTrapTable[dPiece[dungeonCoords.x][dungeonCoords.y]];
|
||||
break;
|
||||
case DebugGridTextItem::AutomapView:
|
||||
info = AutomapView[megaCoords.x][megaCoords.y];
|
||||
break;
|
||||
case DebugGridTextItem::dungeon:
|
||||
info = dungeon[megaCoords.x][megaCoords.y];
|
||||
break;
|
||||
case DebugGridTextItem::pdungeon:
|
||||
info = pdungeon[megaCoords.x][megaCoords.y];
|
||||
break;
|
||||
case DebugGridTextItem::dflags:
|
||||
info = dflags[megaCoords.x][megaCoords.y];
|
||||
break;
|
||||
case DebugGridTextItem::None:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ void NextDebugMonster();
|
|||
void SetDebugLevelSeedInfos(uint32_t mid1Seed, uint32_t mid2Seed, uint32_t mid3Seed, uint32_t endSeed);
|
||||
bool CheckDebugTextCommand(const string_view text);
|
||||
bool IsDebugGridTextNeeded();
|
||||
bool IsDebugGridInMegatiles();
|
||||
bool GetDebugGridText(Point dungeonCoords, char *debugGridTextBuffer);
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -1203,9 +1203,15 @@ void DrawView(const Surface &out, Point startPosition)
|
|||
// force redrawing or debug stuff stays on panel on 640x480 resolution
|
||||
force_redraw = 255;
|
||||
char debugGridTextBuffer[10];
|
||||
bool megaTiles = IsDebugGridInMegatiles();
|
||||
|
||||
for (auto m : DebugCoordsMap) {
|
||||
Point dunCoords = { m.first % MAXDUNX, m.first / MAXDUNX };
|
||||
if (megaTiles && (dunCoords.x % 2 == 1 || dunCoords.y % 2 == 1))
|
||||
continue;
|
||||
Point pixelCoords = m.second;
|
||||
if (megaTiles)
|
||||
pixelCoords += Displacement { 0, TILE_HEIGHT / 2 };
|
||||
if (!zoomflag)
|
||||
pixelCoords *= 2;
|
||||
if (debugGridTextNeeded && GetDebugGridText(dunCoords, debugGridTextBuffer)) {
|
||||
|
|
@ -1215,17 +1221,23 @@ void DrawView(const Surface &out, Point startPosition)
|
|||
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) {
|
||||
int dx = to.x - from.x;
|
||||
int dy = to.y - from.y;
|
||||
int steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
|
||||
float ix = dx / (float)steps;
|
||||
float iy = dy / (float)steps;
|
||||
float sx = from.x;
|
||||
float sy = from.y;
|
||||
auto DrawDebugSquare = [&out](Point center, Displacement hor, Displacement ver, uint8_t col) {
|
||||
auto DrawLine = [&out](Point from, Point to, uint8_t col) {
|
||||
int dx = to.x - from.x;
|
||||
int dy = to.y - from.y;
|
||||
int steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
|
||||
float ix = dx / (float)steps;
|
||||
float iy = dy / (float)steps;
|
||||
float sx = from.x;
|
||||
float sy = from.y;
|
||||
|
||||
for (int i = 0; i <= steps; i++, sx += ix, sy += iy)
|
||||
out.SetPixel({ (int)sx, (int)sy }, col);
|
||||
for (int i = 0; i <= steps; i++, sx += ix, sy += iy)
|
||||
out.SetPixel({ (int)sx, (int)sy }, col);
|
||||
};
|
||||
DrawLine(center - hor, center + ver, col);
|
||||
DrawLine(center + hor, center + ver, col);
|
||||
DrawLine(center - hor, center - ver, col);
|
||||
DrawLine(center + hor, center - ver, col);
|
||||
};
|
||||
|
||||
Displacement hor = { TILE_WIDTH / 2, 0 };
|
||||
|
|
@ -1236,11 +1248,14 @@ void DrawView(const Surface &out, Point startPosition)
|
|||
}
|
||||
Point center = pixelCoords + hor - ver;
|
||||
|
||||
if (megaTiles) {
|
||||
hor *= 2;
|
||||
ver *= 2;
|
||||
}
|
||||
|
||||
uint8_t col = PAL16_BEIGE;
|
||||
DrawLine(center - hor, center + ver, col);
|
||||
DrawLine(center + hor, center + ver, col);
|
||||
DrawLine(center - hor, center - ver, col);
|
||||
DrawLine(center + hor, center - ver, col);
|
||||
|
||||
DrawDebugSquare(center, hor, ver, col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue