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  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "neverhood/background.h"
24 
25 namespace Neverhood {
26 
27 // Background
28 
Background(NeverhoodEngine * vm,int objectPriority)29 Background::Background(NeverhoodEngine *vm, int objectPriority)
30 	: Entity(vm, objectPriority), _surface(NULL), _spriteResource(vm) {
31 	// Empty
32 }
33 
Background(NeverhoodEngine * vm,uint32 fileHash,int objectPriority,int surfacePriority)34 Background::Background(NeverhoodEngine *vm, uint32 fileHash, int objectPriority, int surfacePriority)
35 	: Entity(vm, objectPriority), _surface(NULL), _spriteResource(vm) {
36 
37 	_spriteResource.load(fileHash);
38 	createSurface(surfacePriority, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height);
39 	_surface->drawSpriteResource(_spriteResource);
40 
41 }
42 
~Background()43 Background::~Background() {
44 	delete _surface;
45 }
46 
createSurface(int surfacePriority,int16 width,int16 height)47 void Background::createSurface(int surfacePriority, int16 width, int16 height) {
48 	_surface = new BaseSurface(_vm, surfacePriority, width, height, "background");
49 	_surface->setTransparent(false);
50 	_spriteResource.getPosition().x = width;
51 	_spriteResource.getPosition().y = height;
52 }
53 
load(uint32 fileHash)54 void Background::load(uint32 fileHash) {
55 	_spriteResource.load(fileHash);
56 	if (_surface)
57 		_surface->drawSpriteResource(_spriteResource);
58 }
59 
60 } // End of namespace Neverhood
61