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 "ags/engine/ac/screen_overlay.h"
24 #include "ags/shared/util/stream.h"
25 
26 namespace AGS3 {
27 
28 using AGS::Shared::Stream;
29 
ReadFromFile(Stream * in,int32_t cmp_ver)30 void ScreenOverlay::ReadFromFile(Stream *in, int32_t cmp_ver) {
31 	// Skipping bmp and pic pointer values
32 	// TODO: find out if it's safe to just drop these pointers!! replace with unique_ptr?
33 	bmp = nullptr;
34 	pic = nullptr;
35 	in->ReadInt32(); // bmp
36 	hasSerializedBitmap = in->ReadInt32() != 0;
37 	type = in->ReadInt32();
38 	x = in->ReadInt32();
39 	y = in->ReadInt32();
40 	timeout = in->ReadInt32();
41 	bgSpeechForChar = in->ReadInt32();
42 	associatedOverlayHandle = in->ReadInt32();
43 	hasAlphaChannel = in->ReadBool();
44 	positionRelativeToScreen = in->ReadBool();
45 	if (cmp_ver >= 1) {
46 		_offsetX = in->ReadInt32();
47 		_offsetY = in->ReadInt32();
48 	}
49 }
50 
WriteToFile(Stream * out) const51 void ScreenOverlay::WriteToFile(Stream *out) const {
52 	// Writing bitmap "pointers" to correspond to full structure writing
53 	out->WriteInt32(0); // bmp
54 	out->WriteInt32(pic ? 1 : 0); // pic
55 	out->WriteInt32(type);
56 	out->WriteInt32(x);
57 	out->WriteInt32(y);
58 	out->WriteInt32(timeout);
59 	out->WriteInt32(bgSpeechForChar);
60 	out->WriteInt32(associatedOverlayHandle);
61 	out->WriteBool(hasAlphaChannel);
62 	out->WriteBool(positionRelativeToScreen);
63 	// since cmp_ver = 1
64 	out->WriteInt32(_offsetX);
65 	out->WriteInt32(_offsetY);
66 }
67 
68 } // namespace AGS3
69