aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control/pet_rooms_glyphs.cpp
blob: 786049791eb7ec96053772302ecf49244fb36bcf (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
/* 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 "titanic/pet_control/pet_rooms_glyphs.h"
#include "titanic/pet_control/pet_section.h"
#include "titanic/support/screen_manager.h"
#include "titanic/room_flags.h"

namespace Titanic {

CPetRoomsGlyph::CPetRoomsGlyph() : CPetGlyph(),
	_roomFlags(0), _field38(0), _mode(RGM_0),
	_field40(nullptr), _field44(nullptr), _field48(nullptr), _field4C(nullptr),
	_field50(nullptr), _field54(nullptr), _field58(nullptr), _field5C(nullptr) {
}

CPetRoomsGlyph::CPetRoomsGlyph(uint flags) : CPetGlyph(),
	_roomFlags(flags), _field38(0), _mode(RGM_0),
	_field40(nullptr), _field44(nullptr), _field48(nullptr), _field4C(nullptr),
	_field50(nullptr), _field54(nullptr), _field58(nullptr), _field5C(nullptr) {
}

bool CPetRoomsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	if (!CPetGlyph::setup(petControl, owner))
		return false;

	CPetSection *section = owner->getOwner();
	_field40 = section->getBackground(9);
	_field44 = section->getBackground(12);
	_field50 = section->getBackground(13);
	_field54 = section->getBackground(10);
	_field48 = section->getBackground(11);
	_field4C = section->getBackground(14);
	_field58 = section->getBackground(15);
	_field5C = _field58;
	return true;
}

void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt) {
	// Clear background
	Rect rect(pt.x, pt.y, pt.x + 52, pt.y + 52);
	screenManager->fillRect(SURFACE_BACKBUFFER, &rect, 0, 0, 0);

	warning("TODO: CPetRoomsGlyph::drawAt");
}

void CPetRoomsGlyph::proc28(const Point &pt) {

}

int CPetRoomsGlyph::proc29(const Point &pt) {
	return 0; 
}

void CPetRoomsGlyph::save2(SimpleFile *file, int indent) const {
	file->writeNumberLine(_roomFlags, indent);
	file->writeNumberLine(_mode, indent);
}

int CPetRoomsGlyph::proc33() {
	return 1;
}

void CPetRoomsGlyph::proc39() {

}

void CPetRoomsGlyph::changeLocation(int newClassNum) {
	CRoomFlags roomFlags(_roomFlags);
	roomFlags.changeLocation(newClassNum);
	_roomFlags = roomFlags.get();
}

/*------------------------------------------------------------------------*/

void CPetRoomsGlyphs::save2(SimpleFile *file, int indent) const {
	file->writeNumberLine(size(), indent);

	for (const_iterator i = begin(); i != end(); ++i)
		(*i)->save2(file, indent);
}

CPetRoomsGlyph *CPetRoomsGlyphs::findMode1() const {
	for (const_iterator i = begin(); i != end(); ++i) {
		CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i);
		if (glyph->isMode1())
			return glyph;
	}

	return nullptr;
}

CPetRoomsGlyph *CPetRoomsGlyphs::findGlyphByFlags(uint flags) const {
	for (const_iterator i = begin(); i != end(); ++i) {
		CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i);
		if (glyph->getRoomFlags() == flags)
			return glyph;
	}

	return nullptr;
}

} // End of namespace Titanic