ScummVM API documentation
player.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ALCACHOFA_PLAYER_H
23#define ALCACHOFA_PLAYER_H
24
25#include "alcachofa/rooms.h"
26
27namespace Alcachofa {
28
29class Player {
30public:
31 Player();
32
33 inline Room *currentRoom() const { return _currentRoom; }
34 inline MainCharacter *activeCharacter() const { return _activeCharacter; }
35 inline ShapeObject *&selectedObject() { return _selectedObject; }
36 inline void *&pressedObject() { return _pressedObject; }
37 inline Item *&heldItem() { return _heldItem; }
38 inline FakeSemaphore &semaphore() { return _semaphore; }
39 MainCharacter *inactiveCharacter() const;
40 FakeSemaphore &semaphoreFor(MainCharacterKind kind);
41
42 inline MainCharacterKind activeCharacterKind() const {
43 return _activeCharacter == nullptr ? MainCharacterKind::None : _activeCharacter->kind();
44 }
45
46 void preUpdate();
47 void postUpdate();
48 void updateCursor();
49 void drawCursor(bool forceDefaultCursor = false);
50 void resetCursor();
51 void changeRoom(const Common::String &targetRoomName, bool resetCamera, bool isTemporary = false);
52 void changeRoomToBeforeInventory();
53 void triggerObject(ObjectBase *object, const char *action);
54 void triggerDoor(const Door *door);
55 void addLastDialogCharacter(Character *character);
56 void stopLastDialogCharacters();
57 void setActiveCharacter(MainCharacterKind kind);
58 bool isAllowedToOpenMenu();
59 Room *lastGameRoom() const; // used for saves and music chapter
60 void syncGame(Common::Serializer &s);
61
62private:
63 static constexpr const int kMaxLastDialogCharacters = 4;
64
65 Common::ScopedPtr<Animation> _cursorAnimation;
66 FakeSemaphore _semaphore;
67 Room *_currentRoom = nullptr,
68 *_roomBeforeInventory = nullptr;
69 MainCharacter *_activeCharacter;
70 ShapeObject *_selectedObject = nullptr;
71 void *_pressedObject = nullptr; // terrible but GlobalUI wants to store a Graphic pointer
72 Item *_heldItem = nullptr;
73 int32 _cursorFrameI = 0;
74 bool _didLoadGlobalRooms = false,
75 _isInTemporaryRoom = false;
76 Character *_lastDialogCharacters[kMaxLastDialogCharacters] = { nullptr };
77 int _nextLastDialogCharacter = 0;
78};
79
80}
81
82#endif // ALCACHOFA_PLAYER_H
Definition: objects.h:492
Definition: objects.h:472
Definition: objects.h:425
Definition: objects.h:601
Definition: objects.h:37
Definition: player.h:29
Definition: rooms.h:31
Definition: objects.h:124
Definition: ptr.h:572
Definition: serializer.h:80
Definition: str.h:59
This fake semaphore does not work in multi-threaded scenarios It is used as a safer option for a simp...
Definition: common.h:93