Skip to content

Commit

Permalink
PEGASUS: Finish overview implementation
Browse files Browse the repository at this point in the history
Only thick rects remain there
  • Loading branch information
Matthew Hoops committed May 12, 2011
1 parent 02b023e commit 5a86c56
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 11 deletions.
2 changes: 2 additions & 0 deletions engines/pegasus/menu.cpp
Expand Up @@ -175,7 +175,9 @@ void PegasusEngine::setGameMode(int buttonSelected) {
} else {
switch (buttonSelected) {
case kInterfaceOverviewButton:
_sound->stopSound();
runInterfaceOverview();
_sound->playSound("Sounds/Main Menu.aiff", true);
break;
case kStartButton:
_gameMode = kMainGameMode;
Expand Down
67 changes: 58 additions & 9 deletions engines/pegasus/overview.cpp
Expand Up @@ -39,31 +39,65 @@ void PegasusEngine::runInterfaceOverview() {

// Pause the video, we're only getting frames from it
overviewVideo->pauseVideo(true);

// Draw the main image
overviewVideo->seekToTime(1000);
_video->copyFrameToScreen(overviewVideo->decodeNextFrame(), overviewVideo->getWidth(), overviewVideo->getHeight(), kViewScreenOffset, kViewScreenOffset);

static const OverviewHotspot overviewHotspots[] = {
{ Common::Rect(0, 0, 640, 480), 1000 }, // Main
{ Common::Rect(131, 39, 212, 63), 660 }, // Date
{ Common::Rect(210, 33, 326, 63), 330 }, // Compass
{ Common::Rect(324, 39, 448, 63), 800 }, // Energy Bar
{ Common::Rect(531, 35, 601, 57), 2330 }, // Energy Alert
{ Common::Rect(63, 63, 577, 321), 1730 }, // View Window
{ Common::Rect(69, 317, 355, 331), 1360 }, // Inventory Panel
{ Common::Rect(353, 317, 559, 331), 130 }, // BioChip Panel
{ Common::Rect(75, 333, 173, 431), 1460 }, // Inventory Box
{ Common::Rect(171, 333, 365, 431), 2060 }, // Inventory/BioChip Display
{ Common::Rect(363, 333, 461, 431), 1860 }, // BioChip Box
{ Common::Rect(540, 348, 640, 468), 530 }, // Keyboard
};

// Draw the rest of the interface
drawInterfaceOverview();
int curHotspot;
for (int i = 0; i < ARRAYSIZE(overviewHotspots); i++)
if (overviewHotspots[i].rect.contains(_eventMan->getMousePos()))
curHotspot = i;
drawInterfaceOverview(overviewHotspots[curHotspot], overviewVideo);
_system->updateScreen();

bool continueLooping = true;
while (!shouldQuit() && continueLooping) {
Common::Event event;
while (_eventMan->pollEvent(event)) {
bool updateScreen = false;

switch (event.type) {
case Common::EVENT_MOUSEMOVE:
// TODO: Highlighted images and changing the viewscreen image
_system->updateScreen();
updateScreen = true;
break;
case Common::EVENT_KEYDOWN:
// Break on any keypress, but ignore the meta keys
// Except for num lock! num lock on OS9 is 'clear' and we need that for the inventory panel (along with the tilde)
continueLooping = (event.kbd.keycode == Common::KEYCODE_INVALID || (event.kbd.keycode >= Common::KEYCODE_CAPSLOCK && event.kbd.keycode <= Common::KEYCODE_COMPOSE));
break;
case Common::EVENT_LBUTTONDOWN:
continueLooping = false;
break;
default:
break;
}

int oldHotspot = curHotspot;

for (int i = 0; i < ARRAYSIZE(overviewHotspots); i++)
if (overviewHotspots[i].rect.contains(_eventMan->getMousePos()))
curHotspot = i;

if (oldHotspot != curHotspot) {
drawInterfaceOverview(overviewHotspots[curHotspot], overviewVideo);
updateScreen = true;
}

if (updateScreen)
_system->updateScreen();
}

_system->delayMillis(10);
Expand All @@ -73,12 +107,27 @@ void PegasusEngine::runInterfaceOverview() {
delete overviewVideo;
}

void PegasusEngine::drawInterfaceOverview() {
void PegasusEngine::drawInterfaceOverview(const OverviewHotspot &hotspot, Video::QuickTimeDecoder *video) {
_gfx->drawPict("Images/Interface/OVTop.mac", 0, 0, false);
_gfx->drawPict("Images/Interface/OVLeft.mac", 0, kViewScreenOffset, false);
_gfx->drawPict("Images/Interface/OVRight.mac", 640 - kViewScreenOffset, kViewScreenOffset, false);
_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
_system->updateScreen();

video->seekToTime(hotspot.time);
_video->copyFrameToScreen(video->decodeNextFrame(), video->getWidth(), video->getHeight(), kViewScreenOffset, kViewScreenOffset);

if (hotspot.time == 530) {
// The keyboard is special
// Interesting how the file is "controller" and not keyboard. The PlayStation/Pippin versions probably
// had similar names...
_gfx->drawPict("Images/Interface/OVcontrollerHilite.mac", hotspot.rect.left, hotspot.rect.top, false);
} else if (hotspot.time != 1000) {
// TODO: Thicker line (=4px) with rounded edges
uint32 color = _system->getScreenFormat().RGBToColor(232, 232, 0); // Yellow
Graphics::Surface *screen = _system->lockScreen();
screen->frameRect(hotspot.rect, color);
_system->unlockScreen();
}
}

} // End of namespace Pegasus
13 changes: 11 additions & 2 deletions engines/pegasus/pegasus.h
Expand Up @@ -35,6 +35,10 @@
#include "pegasus/graphics.h"
#include "pegasus/video.h"

namespace Video {
class Video::QuickTimeDecoder;
}

namespace Pegasus {

struct PegasusGameDescription;
Expand Down Expand Up @@ -134,6 +138,11 @@ struct RightAreaData {
uint32 time;
};

struct OverviewHotspot {
Common::Rect rect;
uint32 time;
};

enum TimeZone {
kLocPrehistoric = 0,
kLocMars = 1,
Expand Down Expand Up @@ -214,10 +223,10 @@ class PegasusEngine : public ::Engine {
//void drawCompass();
//void runPauseMenu();
void showLoadDialog();
void runInterfaceOverview();

// Interface Overview
void drawInterfaceOverview();
void runInterfaceOverview();
void drawInterfaceOverview(const OverviewHotspot &hotspot, Video::QuickTimeDecoder *video);

// Main Game Functions
void mainGameLoop();
Expand Down

0 comments on commit 5a86c56

Please sign in to comment.