aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control/pet_remote_glyphs.cpp
blob: 6b7c8cb4aeb389c2ecac9fe0342bdde161df1861 (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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
/* 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_remote_glyphs.h"
#include "titanic/pet_control/pet_remote.h"
#include "titanic/pet_control/pet_control.h"
#include "titanic/messages/pet_messages.h"
#include "titanic/titanic.h"

namespace Titanic {

CPetRemote *CPetRemoteGlyphs::getOwner() const {
	return static_cast<CPetRemote *>(_owner);
}

void CPetRemoteGlyphs::generateMessage(RemoteMessage msgNum, const CString &name, int num) {
	getOwner()->generateMessage(msgNum, name, num);
}

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

void CPetRemoteGlyph::setDefaults(const CString &name, CPetControl *petControl) {
	_element.setBounds(Rect(0, 0, 52, 52));
	_element.setup(MODE_UNSELECTED, name, petControl);
}

CPetRemoteGlyphs *CPetRemoteGlyph::getOwner() const {
	return static_cast<CPetRemoteGlyphs *>(_owner);
}

CPetGfxElement *CPetRemoteGlyph::getElement(uint id) const {
	CPetRemote *remote = static_cast<CPetRemote *>(_owner->getOwner());
	return remote->getElement(id);
}

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

bool CBasicRemoteGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetRemoteGlyph::setup(petControl, owner);
	setDefaults(_gfxName, petControl);
	if (owner)
		_gfxElement = getElement(18);
	return true;
}

void CBasicRemoteGlyph::draw2(CScreenManager *screenManager) {
	if (_gfxElement)
		_gfxElement->draw(screenManager);
}

bool CBasicRemoteGlyph::MouseButtonDownMsg(const Point &pt) {
	return _gfxElement && _gfxElement->MouseButtonDownMsg(pt); 
}

bool CBasicRemoteGlyph::MouseButtonUpMsg(const Point &pt) {
	if (_gfxElement && _gfxElement->MouseButtonUpMsg(pt)) {
		getOwner()->generateMessage(RMSG_ACTIVATE, "Lift");
		return true;
	}

	return false;
}

void CBasicRemoteGlyph::getTooltip(CPetText *text) {
	text->setText(_tooltip);
}

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

bool CToggleRemoteGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetGlyph::setup(petControl, owner);
	if (owner)
		_gfxElement = getElement(0);
	return true;
}

void CToggleRemoteGlyph::draw2(CScreenManager *screenManager) {
	_gfxElement->setMode(_flag ? MODE_SELECTED : MODE_UNSELECTED);
	_gfxElement->draw(screenManager);
}

bool CToggleRemoteGlyph::elementMouseButtonDownMsg(const Point &pt, int petNum) {
	return _gfxElement->MouseButtonDownMsg(pt);
}

bool CToggleRemoteGlyph::elementMouseButtonUpMsg(const Point &pt, int petNum) {
	if (!_gfxElement->MouseButtonUpMsg(pt))
		return false;

	CTreeItem *target = getPetControl()->_remoteTarget;
	if (target) {
		CPETActivateMsg msg("SGTSelector", petNum);
		msg.execute(target);
		_flag = !_flag;
		_gfxElement->setMode(_flag ? MODE_SELECTED : MODE_UNSELECTED);
	}

	return true;
}

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

bool CRemoteGotoGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetRemoteGlyph::setup(petControl, owner);
	setDefaults(_gfxName, petControl);

	if (owner)
		_gfxElement = getElement(7);

	return true;
}

void CRemoteGotoGlyph::draw2(CScreenManager *screenManager) {
	if (_gfxElement)
		_gfxElement->draw(screenManager);
}

bool CRemoteGotoGlyph::MouseButtonDownMsg(const Point &pt) {
	return _gfxElement && _gfxElement->MouseButtonDownMsg(pt);
}

bool CRemoteGotoGlyph::MouseButtonUpMsg(const Point &pt) {
	if (!_gfxElement || !_gfxElement->MouseButtonUpMsg(pt))
		return false;

	CPetControl *petControl = getPetControl();
	if (petControl) {
		CGameManager *gameManager = petControl->getGameManager();

		if (gameManager) {
			CRoomItem *room = gameManager->getRoom();

			if (room) {
				CTransportMsg msg(g_vm->_roomNames[_roomIndex], 1, 0);
				msg.execute(room);
			}
		}
	}

	return true;
}

void CRemoteGotoGlyph::getTooltip(CPetText *text) {
	text->setText(_tooltip);
}

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

bool CTelevisionControlGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetTV", petControl);
	if (owner) {
		_up = getElement(1);
		_down = getElement(2);
		_onOff = getElement(4);
	}
	
	return true;
}

void CTelevisionControlGlyph::draw2(CScreenManager *screenManager) {
	_onOff->setSelected(_flag);
	_onOff->draw(screenManager);
	_up->draw(screenManager);
	_down->draw(screenManager);
}

bool CTelevisionControlGlyph::MouseButtonDownMsg(const Point &pt) {
	if (_onOff && _onOff->MouseButtonDownMsg(pt))
		return true;
	if (_up && _up->MouseButtonDownMsg(pt))
		return true;
	if (_down && _down->MouseButtonDownMsg(pt))
		return true;

	return false;
}

bool CTelevisionControlGlyph::MouseButtonUpMsg(const Point &pt) {
	if (_onOff && _onOff->MouseButtonUpMsg(pt)) {
		_flag = !_flag;
		getOwner()->generateMessage(RMSG_ACTIVATE, "Television");
		return true;
	}

	if (_up && _up->MouseButtonUpMsg(pt)) {
		getOwner()->generateMessage(RMSG_UP, "Television");
		return true;
	}

	if (_down && _down->MouseButtonUpMsg(pt)) {
		getOwner()->generateMessage(RMSG_DOWN, "Television");
		return true;
	}

	return false;
}

void CTelevisionControlGlyph::getTooltip(CPetText *text) {
	text->setText("Television control");
}

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

bool CEntertainmentDeviceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetRemoteGlyph::setup(petControl, owner);
	if (owner) {
		_gfxElement2 = getElement(1);
		_gfxElement3 = getElement(2);
	}

	return true;
}

void CEntertainmentDeviceGlyph::draw2(CScreenManager *screenManager) {
	CString viewName = getPetControl()->getFullViewName();
	if (viewName == "SGTState.Node 1.S") {
		_gfxElement->setSelected(_flag);
		_gfxElement->draw(screenManager);
	} else if (viewName == "SGTState.Node 4.E") {
		_gfxElement->setSelected(_flag2);
		_gfxElement->draw(screenManager);
		_gfxElement2->draw(screenManager);
		_gfxElement3->draw(screenManager);
	}
}

bool CEntertainmentDeviceGlyph::MouseButtonDownMsg(const Point &pt) {
	CString viewName = getPetControl()->getFullViewName();
	if (viewName == "SGTState.Node 1.S") {
		return elementMouseButtonDownMsg(pt, 4);
	} else if (viewName == "SGTState.Node 4.E") {
		return _gfxElement->MouseButtonDownMsg(pt)
			|| _gfxElement2->MouseButtonDownMsg(pt)
			|| _gfxElement3->MouseButtonDownMsg(pt);
	}

	return false;
}

bool CEntertainmentDeviceGlyph::MouseButtonUpMsg(const Point &pt) {
	CString viewName = getPetControl()->getFullViewName();
	if (viewName == "SGTState.Node 1.S") {
		return elementMouseButtonUpMsg(pt, 4);
	} else if (viewName == "SGTState.Node 4.E") {
		if (_gfxElement->MouseButtonUpMsg(pt)) {
			_flag2 = !_flag2;
			getOwner()->generateMessage(RMSG_ACTIVATE, "Television");
			return true;
		} else if (_gfxElement2->MouseButtonUpMsg(pt)) {
			getOwner()->generateMessage(RMSG_UP, "Television");
			return true;
		}
		else if (_gfxElement3->MouseButtonUpMsg(pt)) {
			getOwner()->generateMessage(RMSG_DOWN, "Television");
			return true;
		}
	}

	return false;
}

void CEntertainmentDeviceGlyph::getTooltip(CPetText *text) {
	text->setText("Operate visual entertainment device");
}

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

bool COperateLightsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetLights", petControl);

	if (owner) {
		_left = getElement(3);
		_right = getElement(4);
		_up = getElement(5);
		_down = getElement(6);
		_activate = getElement(7);
	}

	return true;
}

void COperateLightsGlyph::draw2(CScreenManager *screenManager) {
	_left->draw(screenManager);
	_right->draw(screenManager);
	_up->draw(screenManager);
	_down->draw(screenManager);
	_activate->draw(screenManager);
}

bool COperateLightsGlyph::MouseButtonDownMsg(const Point &pt) {
	if (_left->MouseButtonDownMsg(pt)
			|| _right->MouseButtonDownMsg(pt)
			|| _up->MouseButtonDownMsg(pt)
			|| _down->MouseButtonDownMsg(pt)
			|| _activate->MouseButtonDownMsg(pt))
		return true;
	return true;
}

bool COperateLightsGlyph::MouseButtonUpMsg(const Point &pt) {
	if (_left && _left->MouseButtonUpMsg(pt))
		getOwner()->generateMessage(RMSG_LEFT, "Light");
	else if (_right && _right->MouseButtonUpMsg(pt))
		getOwner()->generateMessage(RMSG_RIGHT, "Light");
	else if (_up && _up->MouseButtonUpMsg(pt))
		getOwner()->generateMessage(RMSG_UP, "Light");
	else if (_down && _down->MouseButtonUpMsg(pt))
		getOwner()->generateMessage(RMSG_DOWN, "Light");
	else
		getOwner()->generateMessage(RMSG_ACTIVATE, "Light");

	return true;
}

void COperateLightsGlyph::getTooltip(CPetText *text) {
	text->setText("Operate the lights");
}

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

bool CDeployFloralGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetVase", petControl);
	return true;
}

void CDeployFloralGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy floral enhancement");
}


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

bool CDeployFullyRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetBedfoot", petControl);
	return true;
}

void CDeployFullyRelaxationGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy fully recumbent relaxation device");
}

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

bool CDeployComfortGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetToilet", petControl);
	return true;
}

void CDeployComfortGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy comfort workstation");
}

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

bool CDeployMinorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetDraw", petControl);
	return true;
}

void CDeployMinorStorageGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy minor horizontally mobile storage compartment");
}

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

bool CDeployMajorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetArmChair", petControl);
	return true;
}

void CDeployMajorRelaxationGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy major semi-recumbent relaxation device");
}

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

bool CInflateRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetBedhead", petControl);
	return true;
}

void CInflateRelaxationGlyph::getTooltip(CPetText *text) {
	text->setText("Inflate fully recumbent relaxation device ");
}

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

bool CDeployMaintenanceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetWashstand", petControl);
	return true;
}

void CDeployMaintenanceGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy personal maintenance hub");
}

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

bool CDeployWorkSurfaceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetTable", petControl);
	return true;
}

void CDeployWorkSurfaceGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy executive horizontal worksurface");
}

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

bool CDeployMinorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetDeskchair", petControl);
	return true;
}

void CDeployMinorRelaxationGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy minor semi-recumbent relaxation device");
}

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

bool CDeploySinkGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetDeskchair", petControl);
	return true;
}

void CDeploySinkGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy aqueous cleansing receptacle");
}

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

bool CDeployMajorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CToggleRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetChest", petControl);
	return true;
}

void CDeployMajorStorageGlyph::getTooltip(CPetText *text) {
	text->setText("Deploy major horizontally mobile storage compartment");
}

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

bool CSuccubusDeliveryGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetSuccubus", petControl);

	if (owner) {
		_gfxElement1 = getElement(16);
		_gfxElement2 = getElement(17);
	}

	return true;
}

void CSuccubusDeliveryGlyph::draw2(CScreenManager *screenManager) {
	_gfxElement1->draw(screenManager);
	_gfxElement2->draw(screenManager);
}

bool CSuccubusDeliveryGlyph::MouseButtonDownMsg(const Point &pt) {
	return _gfxElement1->MouseButtonDownMsg(pt)
		|| _gfxElement2->MouseButtonDownMsg(pt);
}

bool CSuccubusDeliveryGlyph::MouseButtonUpMsg(const Point &pt) {
	CTreeItem *target = getPetControl()->_remoteTarget;

	if (_gfxElement1 && _gfxElement1->MouseButtonUpMsg(pt)) {
		if (target) {
			CPETDeliverMsg msg;
			msg.execute(target);
		}
	} else if (_gfxElement2 && _gfxElement2->MouseButtonUpMsg(pt)) {
		if (target) {
			CPETReceiveMsg msg;
			msg.execute(target);
		}
	} else {
		return false;
	}

	return true;
}

void CSuccubusDeliveryGlyph::getTooltip(CPetText *text) {
	text->setText("Succ-U-Bus delivery system control");
}

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

bool CNavigationControllerGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
	CPetRemoteGlyph::setup(petControl, owner);
	setDefaults("3PetStarField", petControl);

	if (owner)
		_gfxElement = getElement(0);

	return true;
}

void CNavigationControllerGlyph::draw2(CScreenManager *screenManager) {
	_gfxElement->setMode(_flag ? MODE_SELECTED : MODE_UNSELECTED);
	_gfxElement->draw(screenManager);
}

bool CNavigationControllerGlyph::MouseButtonDownMsg(const Point &pt) {
	return _gfxElement->MouseButtonDownMsg(pt);
}

bool CNavigationControllerGlyph::MouseButtonUpMsg(const Point &pt) {
	if (!_gfxElement->MouseButtonUpMsg(pt))
		return false;

	_flag = !_flag;
	CTreeItem *target = getPetControl()->_remoteTarget;
	if (target) {
		CPETHelmetOnOffMsg msg;
		msg.execute(target);
	}

	return true;
}

void CNavigationControllerGlyph::getTooltip(CPetText *text) {
	text->setText("Navigation controller");
}

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

} // End of namespace Titanic