HYPNO: allow to jump into the system menu in spider

This commit is contained in:
neuromancer 2022-01-17 11:34:03 +01:00
parent b7c06ee881
commit 542139a129
3 changed files with 28 additions and 19 deletions

View File

@ -28,11 +28,11 @@ namespace Hypno {
//Actions
void HypnoEngine::runMenu(Hotspots hs) {
const Hotspot h = *hs.begin();
assert(h.type == MakeMenu);
debugC(1, kHypnoDebugScene, "hotspot actions size: %d", h.actions.size());
for (Actions::const_iterator itt = h.actions.begin(); itt != h.actions.end(); ++itt) {
void HypnoEngine::runMenu(Hotspots *hs) {
Hotspot *h = hs->begin();
assert(h->type == MakeMenu);
debugC(1, kHypnoDebugScene, "hotspot actions size: %d", h->actions.size());
for (Actions::const_iterator itt = h->actions.begin(); itt != h->actions.end(); ++itt) {
Action *action = *itt;
switch (action->type) {
case QuitAction:
@ -68,14 +68,20 @@ void HypnoEngine::runMenu(Hotspots hs) {
// runMice(h, (Mice*) action);
}
Graphics::Surface *menu = nullptr;
if (_conversation.empty()) {
if (h.flags[0] == "HINTS" || h.flags[1] == "HINTS" || h.flags[2] == "HINTS")
loadImage("int_main/hint1.smk", 0, 0, true);
else if (h.flags[0] == "AUTO_BUTTONS" || h.flags[0] == "SINGLE_RUN") {
if (h->flags[0] == "HINTS" || h->flags[1] == "HINTS" || h->flags[2] == "HINTS") {
menu = decodeFrame("int_main/hint1.smk", 0);
h->rect = Common::Rect(0, 0, menu->w, menu->h);
drawImage(*menu, 0, 0, true);
} else if (h->flags[0] == "AUTO_BUTTONS" || h->flags[0] == "SINGLE_RUN") {
if (isDemo())
loadImage("int_main/resume.smk", 0, 0, true, false, 0);
else
loadImage("int_main/menu.smk", 0, 0, true, false, 0);
else {
menu = decodeFrame("int_main/menu.smk", 0);
h->rect = Common::Rect(0, 0, menu->w, menu->h);
drawImage(*menu, 0, 0, true);
}
}
}
}

View File

@ -151,7 +151,7 @@ public:
void changeCursor(const Common::String &cursor);
// Actions
void runMenu(Hotspots hs);
void runMenu(Hotspots *hs);
void runBackground(Background *a);
void runOverlay(Overlay *a);
void runMice(Mice *a);

View File

@ -110,9 +110,6 @@ void HypnoEngine::clickedHotspot(Common::Point mousePos) {
int cs = 0;
for (Hotspots::const_iterator it = hots->begin(); it != hots->end(); ++it) {
const Hotspot h = *it;
if (h.type != MakeHotspot)
continue;
cs = h.rect.width() * h.rect.height();
if (h.rect.contains(mousePos)) {
if (cs < rs) {
@ -122,6 +119,12 @@ void HypnoEngine::clickedHotspot(Common::Point mousePos) {
}
}
}
if (selected.type == MakeMenu) {
// TODO: remove when proper escape to main menu is implemented
openMainMenuDialog();
return;
}
if (!found)
return;
@ -278,7 +281,7 @@ void HypnoEngine::runScene(Scene *scene) {
if (lastCountdown == _countdown) {}
else if (_countdown > 0) {
uint32 c = _pixelFormat.RGBToColor(255, 0, 0);
runMenu(*stack.back());
runMenu(stack.back());
uint32 minutes = _countdown / 60;
uint32 seconds = _countdown % 60;
_font->drawString(_compositeSurface, Common::String::format("TIME: %d:%d", minutes, seconds), 80, 10, 60, c);
@ -303,7 +306,7 @@ void HypnoEngine::runScene(Scene *scene) {
if (it->decoder) {
skipVideo(*it);
if (it->scaled) {
runMenu(*stack.back());
runMenu(stack.back());
drawScreen();
}
}
@ -418,7 +421,7 @@ void HypnoEngine::runScene(Scene *scene) {
( it->currentFrame->w == _screenW
&& it->currentFrame->h == _screenH
&& it->decoder->getCurFrame() > 0)) {
runMenu(*stack.back());
runMenu(stack.back());
drawScreen();
}
it->decoder->close();
@ -485,13 +488,13 @@ void HypnoEngine::runScene(Scene *scene) {
if (_nextHotsToRemove) {
debugC(1, kHypnoDebugScene, "Removing a hotspot list!");
stack.pop_back();
runMenu(*stack.back());
runMenu(stack.back());
_nextHotsToRemove = nullptr;
drawScreen();
} else if (_nextHotsToAdd) {
debugC(1, kHypnoDebugScene, "Adding a hotspot list!");
stack.push_back(_nextHotsToAdd);
runMenu(*stack.back());
runMenu(stack.back());
_nextHotsToAdd = nullptr;
drawScreen();
}