ScummVM API documentation
custom_properties.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 //=============================================================================
23 //
24 // Custom property structs
25 //
26 //-----------------------------------------------------------------------------
27 //
28 // Custom property schema is kept by GameSetupStruct object as a single
29 // instance and defines property type and default value. Every game entity that
30 // has properties implemented keeps CustomProperties object, which stores
31 // actual property values only if ones are different from defaults.
32 //
33 //=============================================================================
34 
35 #ifndef AGS_SHARED_GAME_CUSTOM_PROPERTIES_H
36 #define AGS_SHARED_GAME_CUSTOM_PROPERTIES_H
37 
38 #include "common/std/map.h"
39 #include "ags/shared/util/string.h"
40 #include "ags/shared/util/string_types.h"
41 
42 namespace AGS3 {
43 
44 #define LEGACY_MAX_CUSTOM_PROPERTIES 30
45 // NOTE: for some reason the property name stored in schema object was limited
46 // to only 20 characters, while the custom properties map could hold up to 200.
47 // Whether this was an error or design choice is unknown.
48 #define LEGACY_MAX_CUSTOM_PROP_SCHEMA_NAME_LENGTH 20
49 #define LEGACY_MAX_CUSTOM_PROP_NAME_LENGTH 200
50 #define LEGACY_MAX_CUSTOM_PROP_DESC_LENGTH 100
51 #define LEGACY_MAX_CUSTOM_PROP_VALUE_LENGTH 500
52 
53 namespace AGS {
54 namespace Shared {
55 
56 enum PropertyVersion {
57  kPropertyVersion_Initial = 1,
58  kPropertyVersion_340,
59  kPropertyVersion_Current = kPropertyVersion_340
60 };
61 
62 enum PropertyType {
63  kPropertyUndefined = 0,
64  kPropertyBoolean,
65  kPropertyInteger,
66  kPropertyString
67 };
68 
69 enum PropertyError {
70  kPropertyErr_NoError,
71  kPropertyErr_UnsupportedFormat
72 };
73 
74 //
75 // PropertyDesc - a description of a single custom property
76 //
77 struct PropertyDesc {
78  String Name;
79  PropertyType Type;
80  String Description;
81  String DefaultValue;
82 
83  PropertyDesc();
84  PropertyDesc(const String &name, PropertyType type, const String &desc, const String &def_value);
85 };
86 
87 // NOTE: AGS has case-insensitive property IDs
88 // Schema - a map of property descriptions
90 
91 
92 namespace Properties {
93 PropertyError ReadSchema(PropertySchema &schema, Stream *in);
94 void WriteSchema(const PropertySchema &schema, Stream *out);
95 
96 // Reads property values from the stream and assign them to map.
97 // The non-matching existing map items, if any, are NOT erased.
98 PropertyError ReadValues(StringIMap &map, Stream *in);
99 // Writes property values chunk to the stream
100 void WriteValues(const StringIMap &map, Stream *out);
101 
102 } // namespace Properties
103 
104 } // namespace Shared
105 } // namespace AGS
106 } // namespace AGS3
107 
108 #endif
Definition: achievements_tables.h:27
Definition: custom_properties.h:77
Definition: string.h:62
Definition: map.h:40
Definition: stream.h:52
Definition: ags.h:40