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 bool &isGameLoaded() { return _isGameLoaded; }
43 
44  inline MainCharacterKind activeCharacterKind() const {
45  return _activeCharacter == nullptr ? MainCharacterKind::None : _activeCharacter->kind();
46  }
47 
48  void preUpdate();
49  void postUpdate();
50  void updateCursor();
51  void drawCursor(bool forceDefaultCursor = false);
52  void resetCursor();
53  void changeRoom(const Common::String &targetRoomName, bool resetCamera);
54  void changeRoomToBeforeInventory();
55  void triggerObject(ObjectBase *object, const char *action);
56  void triggerDoor(const Door *door);
57  void addLastDialogCharacter(Character *character);
58  void stopLastDialogCharacters();
59  void setActiveCharacter(MainCharacterKind kind);
60  bool isAllowedToOpenMenu();
61  void syncGame(Common::Serializer &s);
62 
63 private:
64  static constexpr const int kMaxLastDialogCharacters = 4;
65 
66  Common::ScopedPtr<Animation> _cursorAnimation;
67  FakeSemaphore _semaphore;
68  Room *_currentRoom = nullptr,
69  *_roomBeforeInventory = nullptr;
70  MainCharacter *_activeCharacter;
71  ShapeObject *_selectedObject = nullptr;
72  void *_pressedObject = nullptr; // terrible but GlobalUI wants to store a Graphic pointer
73  Item *_heldItem = nullptr;
74  int32 _cursorFrameI = 0;
75  bool
76  _isGameLoaded = true,
77  _didLoadGlobalRooms = false;
78  Character *_lastDialogCharacters[kMaxLastDialogCharacters] = { nullptr };
79  int _nextLastDialogCharacter = 0;
80 };
81 
82 }
83 
84 #endif // ALCACHOFA_PLAYER_H
Definition: objects.h:354
Definition: alcachofa.h:45
Definition: str.h:59
Definition: objects.h:36
Definition: objects.h:123
Definition: ptr.h:572
Definition: serializer.h:79
Definition: objects.h:419
Definition: player.h:29
Definition: objects.h:528
Definition: objects.h:399
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:84