ScummVM API documentation
resourceprovider.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 STARK_SERVICES_RESOURCE_PROVIDER_H
23 #define STARK_SERVICES_RESOURCE_PROVIDER_H
24 
25 #include "common/list.h"
26 
27 #include "engines/stark/resourcereference.h"
28 
29 namespace Stark {
30 
31 namespace Resources {
32 class Level;
33 class Location;
34 class Object;
35 }
36 
37 class ArchiveLoader;
38 class Current;
39 class Global;
40 class StateProvider;
41 
49 public:
50  ResourceProvider(ArchiveLoader *archiveLoader, StateProvider *stateProvider, Global *global);
51 
53  void initGlobal();
54 
56  void requestLocationChange(uint16 level, uint16 location);
57 
59  bool hasLocationChangeRequest() const { return _locationChangeRequest; }
60 
61  void setShouldRestoreCurrentState() { _restoreCurrentState = true; }
62 
63  void pushAndChangeLocation(int16 level, int16 location);
64  void returnToPushedLocation();
65 
67  void readLocationStack(Common::SeekableReadStream *stream, uint32 version);
68  void writeLocationStack(Common::WriteStream *stream);
69 
76  void performLocationChange();
77 
79  void setNextLocationPosition(const ResourceReference &bookmark, int32 direction);
80 
82  void commitActiveLocationsState();
83 
85  void shutdown();
86 
88  Resources::Level *getLevel(uint16 level) const;
89 
91  Resources::Location *getLocation(uint16 level, uint16 location) const;
92 
94  Resources::Level *getLevelFromLocation(Resources::Location *location) const;
95 
96 private:
97  struct PreviousLocation {
98  uint16 location;
99  uint16 level;
100  bool inventoryOpen;
101  };
102 
103  void pushCurrentLocation();
104  void popCurrentLocation();
105  void saveLoadLocationStack(ResourceSerializer &serializer);
106  Common::Array<PreviousLocation> _locationStack;
107 
109 
110  Current *findLevel(uint16 level) const;
111  Current *findLocation(uint16 level, uint16 location) const;
112 
113  void purgeOldLocations();
114 
115  void runLocationChangeScripts(Resources::Object *resource, uint32 scriptCallMode);
116  void setAprilInitialPosition();
117  void setScrollInitialPosition();
118 
119  Global *_global;
120  ArchiveLoader *_archiveLoader;
121  StateProvider *_stateProvider;
122 
123  bool _locationChangeRequest;
124  bool _restoreCurrentState;
125 
126  CurrentList _locations;
127 
128  ResourceReference _nextPositionBookmarkReference;
129  int32 _nextDirection;
130 };
131 
132 } // End of namespace Stark
133 
134 #endif // STARK_SERVICES_RESOURCE_PROVIDER_H
Definition: location.h:51
Definition: stream.h:77
Definition: global.h:44
Definition: stream.h:745
Definition: archiveloader.h:64
Definition: resourcereference.h:39
Definition: console.h:27
Definition: object.h:143
Definition: stateprovider.h:103
Definition: level.h:39
bool hasLocationChangeRequest() const
Definition: resourceprovider.h:59
Definition: global.h:77
Definition: stateprovider.h:51
Definition: resourceprovider.h:48