ULTIMA8: Fix MiniMapGump::generate command and add MiniMapGump::clear command

This commit is contained in:
Matthew Jimenez 2022-11-20 13:49:07 -06:00
parent 4db39ab10d
commit 9810d2753c
4 changed files with 47 additions and 6 deletions

View File

@ -80,6 +80,11 @@ void MiniMapGump::run() {
_ax = ax;
_ay = ay;
update(currentmap);
}
void MiniMapGump::update(CurrentMap *currentmap) {
int mapChunkSize = currentmap->getChunkSize();
// Draw into the map surface
for (int x = 0; x < _minimap.w; x++) {
for (int y = 0; y < _minimap.h; y++) {
@ -103,6 +108,20 @@ void MiniMapGump::run() {
}
}
void MiniMapGump::generate() {
World *world = World::get_instance();
CurrentMap *currentmap = world->getCurrentMap();
// TODO - do not leave whole map fast after generation
currentmap->setWholeMapFast();
_minimap.clear();
update(currentmap);
}
void MiniMapGump::clear() {
_minimap.clear();
}
void MiniMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
// Draw the yellow border
surf->Fill32(0xFFFFAF00, 0, 0, _dims.width(), 1);

View File

@ -36,6 +36,7 @@ private:
unsigned int _lastMapNum;
int32 _ax, _ay;
void update(CurrentMap *map);
uint32 sampleAtPoint(CurrentMap *map, int x, int y);
uint32 sampleAtPoint(const Item *item, int x, int y);
public:
@ -47,6 +48,9 @@ public:
void run() override;
void generate();
void clear();
void PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) override;
uint16 TraceObjId(int32 mx, int32 my) override;

View File

@ -205,7 +205,8 @@ Debugger::Debugger() : Shared::Debugger() {
registerCmd("InverterProcess::invertScreen", WRAP_METHOD(Debugger, cmdInvertScreen));
registerCmd("MenuGump::showMenu", WRAP_METHOD(Debugger, cmdShowMenu));
registerCmd("MiniMapGump::toggle", WRAP_METHOD(Debugger, cmdToggleMinimap));
registerCmd("MiniMapGump::generateWholeMap", WRAP_METHOD(Debugger, cmdGenerateWholeMap));
registerCmd("MiniMapGump::generate", WRAP_METHOD(Debugger, cmdGenerateMinimap));
registerCmd("MiniMapGump::clear", WRAP_METHOD(Debugger, cmdClearMinimap));
registerCmd("MovieGump::play", WRAP_METHOD(Debugger, cmdPlayMovie));
registerCmd("MusicProcess::playMusic", WRAP_METHOD(Debugger, cmdPlayMusic));
registerCmd("QuitGump::verifyQuit", WRAP_METHOD(Debugger, cmdVerifyQuit));
@ -1806,10 +1807,26 @@ bool Debugger::cmdToggleMinimap(int argc, const char **argv) {
return false;
}
bool Debugger::cmdGenerateWholeMap(int argc, const char **argv) {
World *world = World::get_instance();
CurrentMap *currentmap = world->getCurrentMap();
currentmap->setWholeMapFast();
bool Debugger::cmdGenerateMinimap(int argc, const char **argv) {
Ultima8Engine *app = Ultima8Engine::get_instance();
Gump *desktop = app->getDesktopGump();
MiniMapGump *gump = dynamic_cast<MiniMapGump *>(desktop->FindGump<MiniMapGump>());
if (gump) {
gump->generate();
}
return false;
}
bool Debugger::cmdClearMinimap(int argc, const char **argv) {
Ultima8Engine *app = Ultima8Engine::get_instance();
Gump *desktop = app->getDesktopGump();
MiniMapGump *gump = dynamic_cast<MiniMapGump *>(desktop->FindGump<MiniMapGump>());
if (gump) {
gump->clear();
}
return false;
}

View File

@ -274,8 +274,9 @@ private:
bool cmdVerifyQuit(int argc, const char **argv);
bool cmdU8ShapeViewer(int argc, const char **argv);
bool cmdShowMenu(int argc, const char **argv);
bool cmdGenerateWholeMap(int argc, const char **argv);
bool cmdToggleMinimap(int argc, const char **argv);
bool cmdGenerateMinimap(int argc, const char **argv);
bool cmdClearMinimap(int argc, const char **argv);
bool cmdInvertScreen(int argc, const char **argv);
bool cmdPlayMovie(int argc, const char **argv);
bool cmdPlayMusic(int argc, const char **argv);