1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1995 Presto Studios, Inc.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19 
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  *
24  */
25 
26 #include "buried/buried.h"
27 #include "buried/frame_window.h"
28 #include "buried/graphics.h"
29 #include "buried/video_window.h"
30 #include "buried/demo/movie_scene.h"
31 
32 #include "graphics/surface.h"
33 
34 namespace Buried {
35 
MovieDisplayWindow(BuriedEngine * vm,Window * parent,const Common::String & background,const Common::String & movie,int movieLeft,int movieTop)36 MovieDisplayWindow::MovieDisplayWindow(BuriedEngine *vm, Window *parent, const Common::String &background, const Common::String &movie, int movieLeft, int movieTop)
37 		: Window(vm, parent) {
38 	_background = _vm->_gfx->getBitmap(background);
39 
40 	// Create a rect to use to place the window inside the parent
41 	Common::Rect parentRect = parent->getRect();
42 	_rect.left = (parentRect.right - 640) / 2;
43 	_rect.top = (parentRect.bottom - 480) / 2;
44 	_rect.right = _rect.left + 640;
45 	_rect.bottom = _rect.top + 480;
46 
47 	// Create and position the movie
48 	_movie = new VideoWindow(_vm, this);
49 
50 	if (!_movie->openVideo(movie))
51 		error("Failed to open movie '%s'", movie.c_str());
52 
53 	_movie->setWindowPos(0, movieLeft, movieTop, 0, 0, kWindowPosNoSize | kWindowPosNoZOrder);
54 	_movie->enableWindow(false);
55 
56 	_timer = 0;
57 }
58 
~MovieDisplayWindow()59 MovieDisplayWindow::~MovieDisplayWindow() {
60 	if (_timer != 0)
61 		killTimer(_timer);
62 
63 	delete _movie;
64 
65 	_background->free();
66 	delete _background;
67 }
68 
showMovieInWindow()69 bool MovieDisplayWindow::showMovieInWindow() {
70 	showWindow(kWindowShow);
71 
72 	_movie->enableWindow(false);
73 	_movie->showWindow(kWindowShow);
74 	_movie->playVideo();
75 
76 	_timer = setTimer(5000);
77 	return true;
78 }
79 
onPaint()80 void MovieDisplayWindow::onPaint() {
81 	_vm->_gfx->blit(_background, 0, 0);
82 }
83 
onEraseBackground()84 bool MovieDisplayWindow::onEraseBackground() {
85 	_vm->_gfx->fillRect(getAbsoluteRect(), _vm->_gfx->getColor(0, 0, 0));
86 	return true;
87 }
88 
onLButtonUp(const Common::Point & point,uint flags)89 void MovieDisplayWindow::onLButtonUp(const Common::Point &point, uint flags) {
90 	((FrameWindow *)_parent)->returnToMainMenu();
91 }
92 
onTimer(uint timer)93 void MovieDisplayWindow::onTimer(uint timer) {
94 	if (_movie->getMode() == VideoWindow::kModeStopped)
95 		((FrameWindow *)_parent)->returnToMainMenu();
96 }
97 
98 } // End of namespace Buried
99