aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/overview.cpp
blob: adbfbdbbe8360b21d380ae997c3a9a4f5f3664ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#include "common/events.h"
#include "common/textconsole.h"
#include "graphics/cursorman.h"
#include "video/qt_decoder.h"

#include "pegasus/pegasus.h"

namespace Pegasus {

void PegasusEngine::runInterfaceOverview() {
	CursorMan.showMouse(true);
	_gfx->setCursor(kPointingCursor);

	Video::QuickTimeDecoder *overviewVideo = new Video::QuickTimeDecoder();
	if (!overviewVideo->loadFile("Images/Interface/Overview Mac.movie"))
		error("Could not open overview video");

	// Pause the video, we're only getting frames from it
	overviewVideo->pauseVideo(true);
	
	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
	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:
				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);
	}

	CursorMan.showMouse(false);
	delete overviewVideo;
}

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);

	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) {
		// Draw a yellow outline around the hotspot
		Common::Rect rect = hotspot.rect;
		uint32 color = _system->getScreenFormat().RGBToColor(232, 232, 0); // Yellow
		Graphics::Surface *screen = _system->lockScreen();
		screen->frameRect(rect, color);
		rect.grow(1);
		screen->frameRect(rect, color);
		rect.grow(1);
		screen->frameRect(rect, color);
		screen->hLine(rect.left + 1, rect.top - 1, rect.right - 2, color);
		screen->hLine(rect.left + 1, rect.bottom, rect.right - 2, color);
		screen->vLine(rect.left - 1, rect.top + 1, rect.bottom - 2, color);
		screen->vLine(rect.right, rect.top + 1, rect.bottom - 2, color);
		_system->unlockScreen();
	}
}

} // End of namespace Pegasus