ScummVM API documentation
util.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 #ifndef NANCY_UTIL_H
22 #define NANCY_UTIL_H
23 
24 #include "common/array.h"
25 #include "common/hashmap.h"
26 #include "common/path.h"
27 #include "common/rect.h"
28 #include "common/serializer.h"
29 
30 #include "engines/nancy/commontypes.h"
31 
32 namespace Nancy {
33 
34 void readRect(Common::SeekableReadStream &stream, Common::Rect &inRect);
35 void readRect(Common::Serializer &stream, Common::Rect &inRect, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
36 void readRectArray(Common::SeekableReadStream &stream, Common::Array<Common::Rect> &inArray, uint num, uint totalNum = 0);
37 void readRectArray(Common::Serializer &stream, Common::Array<Common::Rect> &inArray, uint num, uint totalNum = 0, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
38 
39 void readRect16(Common::SeekableReadStream &stream, Common::Rect &inRect);
40 void readRect16(Common::Serializer &stream, Common::Rect &inRect, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
41 void readRectArray16(Common::SeekableReadStream &stream, Common::Array<Common::Rect> &inArray, uint num, uint totalNum = 0);
42 void readRectArray16(Common::Serializer &stream, Common::Array<Common::Rect> &inArray, uint num, uint totalNum = 0, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
43 
44 void readFilename(Common::SeekableReadStream &stream, Common::String &inString);
45 void readFilename(Common::Serializer &stream, Common::String &inString, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
46 inline void readFilename(Common::SeekableReadStream &stream, Common::Path &inPath) {
47  Common::String inString;
48  readFilename(stream, inString);
49  inPath = Common::Path(inString);
50 }
51 inline void readFilename(Common::Serializer &stream, Common::Path &inPath, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion) {
52  Common::String inString;
53  readFilename(stream, inString, minVersion, maxVersion);
54  inPath = Common::Path(inString);
55 }
56 void readFilenameArray(Common::SeekableReadStream &stream, Common::Array<Common::String> &inArray, uint num);
57 void readFilenameArray(Common::Serializer &stream, Common::Array<Common::String> &inArray, uint num, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
58 void readFilenameArray(Common::SeekableReadStream &stream, Common::Array<Common::Path> &inArray, uint num);
59 void readFilenameArray(Common::Serializer &stream, Common::Array<Common::Path> &inArray, uint num, Common::Serializer::Version minVersion = 0, Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
60 
61 void assembleTextLine(char *rawCaption, Common::String &output, uint size);
62 
63 void readUIButton(Common::SeekableReadStream &stream, UIButtonRecord &dst);
64 void readUISlider(Common::SeekableReadStream &stream, UISliderRecord &dst);
65 void readUIPopupHeader(Common::SeekableReadStream &stream, UIPopupHeader &dst);
66 void readUIButtonSlot(Common::SeekableReadStream &stream, UIButtonSlot &dst);
67 
68 Common::String getTextFromCaseInsensitiveKey(Common::HashMap<Common::String, Common::String> texts, Common::String &key);
69 
70 // Abstract base class used for loading data that would take too much time in a single frame
72 public:
73  DeferredLoader() {}
74  virtual ~DeferredLoader() {}
75 
76  // Calls loadInner() one or many times, until its allotted time is done
77  bool load(uint32 endTime);
78 
79 protected:
80  // Contains the actual loading logic, split up into tasks that are as small as possible
81  virtual bool loadInner() = 0;
82 };
83 
84 } // End of namespace Nancy
85 
86 #endif // NANCY_UTIL_H
Definition: str.h:59
Definition: rect.h:524
Definition: path.h:52
Definition: stream.h:745
Definition: serializer.h:80
Definition: util.h:71
Definition: actionmanager.h:32