AGS: Reimplemented walk path display as a persistent overlay

From upstream 92774437d3c454d16c7c0f51c6b32dabd1880c08
This commit is contained in:
Paul Gilbert 2022-03-19 18:57:48 -07:00
parent b0233b607e
commit cf62e3979b
3 changed files with 36 additions and 0 deletions

View File

@ -41,6 +41,7 @@
#include "ags/engine/ac/global_region.h"
#include "ags/engine/ac/gui.h"
#include "ags/engine/ac/mouse.h"
#include "ags/engine/ac/move_list.h"
#include "ags/engine/ac/object_cache.h"
#include "ags/engine/ac/overlay.h"
#include "ags/engine/ac/sys_events.h"
@ -420,6 +421,11 @@ static void dispose_debug_room_drawdata() {
if (_G(debugRoomMaskDDB) != nullptr)
_G(gfxDriver)->DestroyDDB(_G(debugRoomMaskDDB));
_G(debugRoomMaskDDB) = nullptr;
delete _G(debugMoveListBmp);
_G(debugMoveListBmp) = nullptr;
if (_G(debugMoveListDDB) != nullptr)
_G(gfxDriver)->DestroyDDB(_G(debugMoveListDDB));
_G(debugMoveListDDB) = nullptr;
}
void dispose_room_drawdata() {
@ -519,6 +525,7 @@ void sync_roomview(Viewport *view) {
void init_room_drawdata() {
// Update debug overlays, if any were on
debug_draw_room_mask(_G(debugRoomMask));
debug_draw_movelist(_G(debugMoveListChar));
// Following data is only updated for software renderer
if (_G(gfxDriver)->RequiresFullRedrawEachFrame())
@ -1865,6 +1872,8 @@ void prepare_room_sprites() {
update_room_debug();
if ((_G(debugRoomMask) != kRoomAreaNone) && _G(debugRoomMaskDDB))
add_thing_to_draw(_G(debugRoomMaskDDB), 0, 0);
if ((_G(debugMoveListChar) >= 0) && _G(debugMoveListDDB))
add_thing_to_draw(_G(debugMoveListDDB), 0, 0);
}
// Draws the black surface behind (or rather between) the room viewports
@ -2312,12 +2321,35 @@ void debug_draw_room_mask(RoomAreaMask mask) {
_G(debugRoomMaskDDB)->SetTransparency(150);
}
void debug_draw_movelist(int charnum) {
_G(debugMoveListChar) = charnum;
}
void update_room_debug() {
if (_G(debugRoomMask) == kRoomAreaWalkable) {
Bitmap *mask_bmp = prepare_walkable_areas(-1);
_G(debugRoomMaskDDB) = recycle_ddb_bitmap(_G(debugRoomMaskDDB), mask_bmp, false, true);
_G(debugRoomMaskDDB)->SetTransparency(150);
}
if (_G(debugMoveListChar) >= 0) {
_G(debugMoveListBmp) = recycle_bitmap(_G(debugMoveListBmp), _GP(game).GetColorDepth(),
_GP(thisroom).WalkAreaMask->GetWidth(), _GP(thisroom).WalkAreaMask->GetHeight(), true);
if (_GP(game).chars[_G(debugMoveListChar)].walking > 0) {
int mlsnum = _GP(game).chars[_G(debugMoveListChar)].walking;
if (_GP(game).chars[_G(debugMoveListChar)].walking >= TURNING_AROUND)
mlsnum %= TURNING_AROUND;
const MoveList &cmls = _G(mls)[mlsnum];
for (int i = 0; i < cmls.numstage - 1; i++) {
short srcx = short((cmls.pos[i] >> 16) & 0x00ffff);
short srcy = short(cmls.pos[i] & 0x00ffff);
short targetx = short((cmls.pos[i + 1] >> 16) & 0x00ffff);
short targety = short(cmls.pos[i + 1] & 0x00ffff);
_G(debugMoveListBmp)->DrawLine(Line(srcx, srcy, targetx, targety), MakeColor(i + 1));
}
}
_G(debugMoveListDDB) = recycle_ddb_bitmap(_G(debugMoveListDDB), _G(debugMoveListBmp), false, false);
_G(debugMoveListDDB)->SetTransparency(150);
}
}
// Draw everything

View File

@ -129,6 +129,7 @@ void construct_engine_overlay();
void clear_letterbox_borders();
void debug_draw_room_mask(RoomAreaMask mask);
void debug_draw_movelist(int charnum);
void update_room_debug();
void tint_image(Shared::Bitmap *g, Shared::Bitmap *source, int red, int grn, int blu, int light_level, int luminance = 255);

View File

@ -586,6 +586,9 @@ public:
// For debugging room masks
RoomAreaMask _debugRoomMask = kRoomAreaNone;
Engine::IDriverDependantBitmap *_debugRoomMaskDDB = nullptr;
int _debugMoveListChar = -1;
Shared::Bitmap *_debugMoveListBmp = nullptr;
Engine::IDriverDependantBitmap *_debugMoveListDDB = nullptr;
bool _current_background_is_dirty = false;
// Room background sprite