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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/* 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(0), you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation(0), 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(0), 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(0), if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "titanic/pet_control/pet_text.h"
namespace Titanic {
CPetText::CPetText(uint count) :
_stringsMerged(false), _field30(-1), _lineCount(0), _field38(-1),
_field3C(0), _field40(0), _field44(0), _backR(0xff),
_backG(0xff), _backB(0xff), _field54(0), _field58(0),
_field5C(200), _field60(0), _field64(0), _field68(0),
_field6C(0), _hasBorder(true), _field74(0), _field78(0),
_field7C(0) {
setupArrays(count);
}
void CPetText::setupArrays(int count) {
freeArrays();
if (count < 10 || count > 60)
count = 10;
_array.resize(count);
}
void CPetText::freeArrays() {
_array.clear();
}
void CPetText::setup() {
for (int idx = 0; idx < (int)_array.size(); ++idx) {
_array[idx]._string1.clear();
setArrayStr2(idx, _field54, _field58, _field5C);
_array[idx]._string3.clear();
}
_lineCount = 0;
_stringsMerged = false;
}
void CPetText::setArrayStr2(uint idx, int val1, int val2, int val3) {
char buffer[6];
if (!val1)
val1 = 1;
if (!val2)
val2 = 1;
if (!val3)
val3 = 1;
buffer[0] = 27;
buffer[1] = val1;
buffer[2] = val2;
buffer[3] = val3;
buffer[4] = 27;
buffer[5] = '\0';
_array[idx]._string2 = buffer;
}
void CPetText::load(SimpleFile *file, int param) {
if (!param) {
int var1 = file->readNumber();
int var2 = file->readNumber();
uint count = file->readNumber();
_bounds.left = file->readNumber();
_bounds.top = file->readNumber();
_bounds.right = file->readNumber();
_bounds.bottom = file->readNumber();
_field3C = file->readNumber();
_field40 = file->readNumber();
_field44 = file->readNumber();
_backR = file->readNumber();
_backG = file->readNumber();
_backB = file->readNumber();
_field54 = file->readNumber();
_field58 = file->readNumber();
_field5C = file->readNumber();
_hasBorder = file->readNumber() != 0;
_field74 = file->readNumber();
warning("TODO: CPetText::load %d,%d", var1, var2);
assert(_array.size() >= count);
for (uint idx = 0; idx < count; ++idx) {
_array[idx]._string1 = file->readString();
_array[idx]._string2 = file->readString();
_array[idx]._string3 = file->readString();
}
}
}
void CPetText::draw(CScreenManager *screenManager) {
Rect tempRect = _bounds;
if (_hasBorder) {
// Create border effect
// Top edge
tempRect.bottom = tempRect.top + 1;
screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
// Bottom edge
tempRect.top = _bounds.bottom - 1;
tempRect.bottom = _bounds.bottom;
screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
// Left edge
tempRect = _bounds;
tempRect.right = tempRect.left + 1;
screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
// Right edge
tempRect = _bounds;
tempRect.left = tempRect.right - 1;
screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
}
warning("TODO: CPetText::draw");
}
void CPetText::mergeStrings() {
if (!_stringsMerged) {
_lines.clear();
for (int idx = 0; idx < _lineCount; ++idx) {
CString line = _array[idx]._string2 + _array[idx]._string3 +
_array[idx]._string1 + "\n";
_lines += line;
}
_stringsMerged = true;
}
}
void CPetText::resize(uint count) {
if (!count || _array.size() == count)
return;
_array.clear();
_array.resize(count);
}
void CPetText::setText(const CString &str) {
setup();
changeText(str);
}
void CPetText::changeText(const CString &str) {
warning("TODO: CPetText::changeText");
}
void CPetText::setColor(int val1, int val2) {
warning("CPetText::setColor");
}
} // End of namespace Titanic
|