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 "illusions/illusions.h"
24 #include "illusions/actor.h"
25 #include "illusions/cursor.h"
26 #include "illusions/input.h"
27
28 namespace Illusions {
29
Cursor(IllusionsEngine * vm)30 Cursor::Cursor(IllusionsEngine *vm)
31 : _vm(vm) {
32 _status = 1;
33 _control = 0;
34 _x = 320;
35 _y = 240;
36 _cursorNum = 1;
37 _field_10 = 0;
38 _sequenceId = 0;
39 }
40
place(Control * control,uint32 sequenceId)41 void Cursor::place(Control *control, uint32 sequenceId) {
42 _status = 2;
43 _control = control;
44 _cursorNum = 1;
45 _field_10 = 0;
46 _sequenceId = sequenceId;
47 _visibleCtr = 0;
48 _control->_flags |= 8;
49 setActorIndex(_cursorNum, 1, 0);
50 _vm->_input->setCursorPosition(_control->_actor->_position);
51 }
52
setActorIndex(int actorIndex,int a,int b)53 void Cursor::setActorIndex(int actorIndex, int a, int b) {
54 static int kCursorMap[13][2][2] = {
55 {{ 1, 2}, { 0, 0}},
56 {{ 3, 4}, { 0, 0}},
57 {{ 5, 6}, {13, 14}},
58 {{ 7, 8}, { 0, 0}},
59 {{ 9, 10}, { 0, 0}},
60 {{11, 12}, { 0, 0}},
61 {{ 1, 2}, { 0, 0}},
62 {{ 0, 0}, { 0, 0}},
63 {{ 0, 0}, { 0, 0}},
64 {{15, 16}, { 0, 0}},
65 {{17, 18}, { 0, 0}},
66 {{19, 20}, { 0, 0}},
67 {{21, 22}, { 0, 0}}
68 };
69 _control->_actor->_actorIndex = kCursorMap[actorIndex - 1][b][a - 1];
70 }
71
setControl(Control * control)72 void Cursor::setControl(Control *control) {
73 _control = control;
74 }
75
show()76 void Cursor::show() {
77 ++_visibleCtr;
78 if (_visibleCtr > 0) {
79 _control->_flags |= 1;
80 _control->_actor->_flags |= Illusions::ACTOR_FLAG_IS_VISIBLE;
81 if (_control->_actor->_frameIndex) {
82 _control->_actor->_flags |= Illusions::ACTOR_FLAG_2000;
83 _control->_actor->_flags |= Illusions::ACTOR_FLAG_4000;
84 }
85 _vm->_input->discardAllEvents();
86 }
87 }
88
hide()89 void Cursor::hide() {
90 --_visibleCtr;
91 if (_visibleCtr <= 0) {
92 _control->_flags &= ~1;
93 _control->_actor->_flags &= ~Illusions::ACTOR_FLAG_IS_VISIBLE;
94 }
95 }
96
97 } // End of namespace Illusions
98