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 
27 namespace Alcachofa {
28 
29 class Player {
30 public:
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  void syncGame(Common::Serializer &s);
60 
61 private:
62  static constexpr const int kMaxLastDialogCharacters = 4;
63 
64  Common::ScopedPtr<Animation> _cursorAnimation;
65  FakeSemaphore _semaphore;
66  Room *_currentRoom = nullptr,
67  *_roomBeforeInventory = nullptr;
68  MainCharacter *_activeCharacter;
69  ShapeObject *_selectedObject = nullptr;
70  void *_pressedObject = nullptr; // terrible but GlobalUI wants to store a Graphic pointer
71  Item *_heldItem = nullptr;
72  int32 _cursorFrameI = 0;
73  bool _didLoadGlobalRooms = false,
74  _isInTemporaryRoom = false;
75  Character *_lastDialogCharacters[kMaxLastDialogCharacters] = { nullptr };
76  int _nextLastDialogCharacter = 0;
77 };
78 
79 }
80 
81 #endif // ALCACHOFA_PLAYER_H
Definition: objects.h:396
Definition: alcachofa.h:45
Definition: str.h:59
Definition: objects.h:37
Definition: objects.h:124
Definition: ptr.h:572
Definition: serializer.h:79
Definition: objects.h:463
Definition: player.h:29
Definition: objects.h:572
Definition: objects.h:443
Definition: rooms.h:31
This fake semaphore does not work in multi-threaded scenarios It is used as a safer option for a simp...
Definition: common.h:93